/* ── Courses21 — style.css ──
   Vanilla CSS, mobile-first, palette emerald (#10B981). */

* { box-sizing: border-box; }

:root {
    /* ── Thème clair (par défaut) ── */
    --bg:        #f7f7f5;
    --bg-card:   #ffffff;
    --bg-soft:   #f0efed;
    --border:    #e5e5e3;
    --text:      #111827;
    --text-soft: #6b7280;
    --text-mute: #9ca3af;
    --accent:    #10B981;
    --accent-d:  #059669;
    --danger:    #EF4444;
    --danger-d:  #DC2626;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
    --shadow:    0 4px 16px rgba(0,0,0,.06);
    --radius:    10px;
    --radius-lg: 14px;
    --topbar-h:  56px;
    --content-max: 640px;

    /* iOS safe areas */
    --safe-top:    env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Thème sombre auto (suit le système si l'user n'a pas choisi) ── */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg:        #0f1115;
        --bg-card:   #181b21;
        --bg-soft:   #232732;
        --border:    #2a2f3a;
        --text:      #e7e9ee;
        --text-soft: #9ca3af;
        --text-mute: #6b7280;
        --accent:    #34D399;
        --accent-d:  #10B981;
        --danger:    #F87171;
        --danger-d:  #EF4444;
        --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
        --shadow:    0 4px 18px rgba(0,0,0,.5);
    }
}

/* ── Override forcé par toggle utilisateur ── */
:root[data-theme="dark"] {
    --bg:        #0f1115;
    --bg-card:   #181b21;
    --bg-soft:   #232732;
    --border:    #2a2f3a;
    --text:      #e7e9ee;
    --text-soft: #9ca3af;
    --text-mute: #6b7280;
    --accent:    #34D399;
    --accent-d:  #10B981;
    --danger:    #F87171;
    --danger-d:  #EF4444;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
    --shadow:    0 4px 18px rgba(0,0,0,.5);
}

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

/* La page elle-même ne scrolle jamais : c'est la zone des items qui scrolle.
   Sans ça, une liste longue allongerait .app et pousserait la sidebar-footer
   (profil / thème / deco) hors de l'ecran. */
html, body { height: 100%; }
body { overflow: hidden; }

button { font-family: inherit; cursor: pointer; }
input, button, textarea { font-family: inherit; font-size: inherit; }
input:focus, button:focus, textarea:focus { outline: none; }

.hidden { display: none !important; }

/* ── Loader ─────────────────────────────────────────────── */
.init-loader {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg);
    z-index: 9999;
}
.init-spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toasts ─────────────────────────────────────────────── */
.toasts {
    position: fixed;
    top: calc(var(--safe-top) + 12px);
    left: 50%; transform: translateX(-50%);
    z-index: 10000;
    display: flex; flex-direction: column; gap: 8px;
    pointer-events: none;
}
.toast {
    /* On joue l'inverse du fond de page : en thème clair, fond sombre +
       texte clair ; en thème sombre, fond clair + texte sombre. Auparavant
       `color: #fff` était hardcodé, ce qui rendait le toast illisible
       en mode sombre (texte blanc sur fond clair). */
    background: var(--text);
    color: var(--bg);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow);
    animation: toast-in .22s ease;
}
/* Le variant erreur force du blanc sur rouge — meilleure lisibilité que
   du texte sombre sur rouge, indépendamment du thème. */
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Auth screen ────────────────────────────────────────── */
.auth-screen {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    padding-top:    calc(var(--safe-top) + 24px);
    padding-bottom: calc(var(--safe-bottom) + 24px);
    background:
        radial-gradient(circle at 30% 10%, rgba(16,185,129,.10), transparent 60%),
        var(--bg);
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 32px 28px;
    width: 100%; max-width: 380px;
}
.auth-logo {
    font-size: 26px; font-weight: 700; color: var(--text);
    margin-bottom: 4px;
}
.auth-logo span { color: var(--accent); }
.auth-subtitle {
    font-size: 15px; font-weight: 500; color: var(--text-soft);
    margin: 0 0 22px;
}
.auth-switch {
    text-align: center; font-size: 13px; color: var(--text-soft);
    margin: 14px 0 0;
}
.auth-switch a { color: var(--accent); text-decoration: none; font-weight: 600; }

/* ── Forms ──────────────────────────────────────────────── */
.form-row { margin-bottom: 14px; }
.form-row label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--text-soft); margin-bottom: 5px;
    text-transform: uppercase; letter-spacing: .05em;
}
.form-row input, .form-row textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text);
    transition: border-color .12s;
}
.form-row input:focus, .form-row textarea:focus {
    border-color: var(--accent);
}
.password-field {
    position: relative;
    width: 100%;
}
.form-row .password-field input {
    padding-right: 44px;
}
.password-toggle {
    position: absolute;
    top: 50%;
    right: 7px;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
}
.password-toggle:hover,
.password-toggle:focus-visible {
    background: var(--bg-soft);
    color: var(--accent);
    outline: none;
}
.password-toggle svg {
    width: 18px;
    height: 18px;
    pointer-events: none;
}
.form-row textarea {
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    min-height: 64px;
    line-height: 1.4;
}
/* Deux champs côte à côte (ex. quantité + rayon dans la modale article) */
.form-row-pair {
    display: flex; gap: 10px;
}
.form-row-pair .form-col {
    flex: 1; min-width: 0;
}
.form-row-pair .form-col label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--text-soft); margin-bottom: 5px;
    text-transform: uppercase; letter-spacing: .05em;
}
.form-row-pair .form-col input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text);
    transition: border-color .12s;
}
.form-row-pair .form-col input:focus { border-color: var(--accent); }
.form-hint {
    font-size: 11px; font-weight: 400;
    color: var(--text-mute);
    text-transform: none; letter-spacing: 0;
    margin-left: 4px;
}
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 6px 0 0; }

/* ── Buttons ────────────────────────────────────────────── */
.btn-primary {
    background: var(--accent); color: #fff;
    border: none; border-radius: 8px;
    padding: 10px 16px; font-weight: 600;
    transition: background .12s;
}
.btn-primary:hover { background: var(--accent-d); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-block { width: 100%; padding: 12px; margin-top: 4px; }

.btn-secondary {
    background: var(--bg-soft); color: var(--text);
    border: 1px solid var(--border); border-radius: 8px;
    padding: 10px 16px; font-weight: 500;
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
    background: var(--danger); color: #fff;
    border: none; border-radius: 8px;
    padding: 10px 16px; font-weight: 600;
}
.btn-danger:hover { background: var(--danger-d); }

.btn-icon {
    background: transparent; border: none;
    width: 40px; height: 40px;
    border-radius: 8px;
    color: var(--text-soft);
    font-size: 20px;
    display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: var(--bg-soft); color: var(--text); }

.btn-icon-sidebar {
    background: transparent; border: none;
    width: 24px; height: 24px;
    border-radius: 6px;
    color: var(--text-mute);
    font-size: 18px; line-height: 1;
}
.btn-icon-sidebar:hover { background: var(--bg-soft); color: var(--text); }

.btn-link {
    background: transparent; border: none;
    color: var(--accent); font-weight: 600; font-size: 13px;
    padding: 0;
}

.btn-logout {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px; font-weight: 500;
    color: var(--text-soft);
}
.btn-logout:hover { background: var(--bg-soft); color: var(--text); }

/* Bouton de bascule thème — affiche soleil ou lune selon le thème actif */
.btn-theme {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 28px; height: 28px;
    padding: 0;
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.btn-theme:hover { background: var(--bg-soft); color: var(--text); }
.btn-theme .theme-icon-sun  { display: none; }
.btn-theme .theme-icon-moon { display: inline; }
:root[data-theme="dark"] .btn-theme .theme-icon-sun  { display: inline; }
:root[data-theme="dark"] .btn-theme .theme-icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .btn-theme .theme-icon-sun  { display: inline; }
    :root:not([data-theme="light"]) .btn-theme .theme-icon-moon { display: none; }
}

/* ── App layout ─────────────────────────────────────────── */
.app {
    display: flex;
    height: 100vh;
    height: 100dvh; /* dvh = la viewport hauteur "dynamique" sur mobile (barres iOS) */
    overflow: hidden;
}

.sidebar {
    width: 240px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    padding: calc(var(--safe-top) + 16px) 12px calc(var(--safe-bottom) + 12px);
    flex-shrink: 0;
}
.sidebar-header {
    padding: 4px 8px 14px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}
.sidebar-logo {
    font-size: 19px; font-weight: 700; color: var(--text);
}
.sidebar-logo span { color: var(--accent); }

.sidebar-section {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 8px;
    margin-top: 4px;
}
.sidebar-section-title {
    font-size: 11px; font-weight: 600;
    color: var(--text-mute);
    text-transform: uppercase; letter-spacing: .08em;
}

.sidebar-nav {
    display: flex; flex-direction: column; gap: 2px;
    padding: 0 4px;
    flex: 1;
    overflow-y: auto;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text);
    font-size: 14px;
    transition: background .12s;
}
.nav-item:hover { background: var(--bg-soft); }
.nav-item.active { background: var(--bg-soft); font-weight: 600; }
.nav-item .dot {
    width: 8px; height: 8px; border-radius: 50%;
    flex-shrink: 0;
}
.nav-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count {
    font-size: 12px; color: var(--text-mute); font-variant-numeric: tabular-nums;
}
/* Badge "liste partagée" — visible si members_count > 1. Icône uniquement,
   le hover/title donne le détail (nb de membres). */
.nav-item .nav-shared {
    display: inline-flex; align-items: center;
    color: var(--text-mute);
    flex-shrink: 0;
}
.nav-item .nav-shared svg { display: block; }

/* Lien discret juste au-dessus du footer — accès aux listes archivées */
.sidebar-link {
    display: flex; align-items: center; gap: 10px;
    margin: 8px 4px 4px;
    padding: 8px 10px;
    border: none;
    background: transparent;
    color: var(--text-mute);
    font-size: 13px;
    font-family: inherit;
    border-radius: 6px;
    cursor: pointer;
    transition: background .12s, color .12s;
}
.sidebar-link:hover {
    background: var(--bg-soft);
    color: var(--text);
}
.sidebar-link svg { flex-shrink: 0; }

.sidebar-footer {
    margin-top: 0;
    border-top: 1px solid var(--border);
    padding-top: 12px;
    display: flex; align-items: center; gap: 8px;
}
.sidebar-user { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff; font-weight: 600; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.user-name {
    font-size: 13px; color: var(--text); font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.3);
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}
.sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* ── Main ───────────────────────────────────────────────── */
.main {
    flex: 1;
    display: flex; flex-direction: column;
    min-width: 0;
}
.topbar {
    display: flex; align-items: center; gap: 12px;
    min-height: var(--topbar-h);
    padding: calc(var(--safe-top) + 14px) 18px 14px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0; z-index: 10;
}
/* Trois zones de largeur égale : gauche (burger mobile), centre (dot+titre),
   droite (gear). Le centre est ainsi visuellement centré dans la barre. */
.topbar-side {
    flex: 1;
    display: flex; align-items: center;
    min-width: 0;
}
.topbar-side-left  { justify-content: flex-start; }
.topbar-side-right { justify-content: flex-end; }
.topbar-center {
    flex: 0 1 auto;
    display: flex; align-items: center; gap: 8px;
    min-width: 0;
}
.topbar #btn-menu { display: none; }
.list-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
    box-shadow: 0 0 0 2px var(--bg-card);
}
.list-title-wrap {
    display: flex; flex-direction: column;
    min-width: 0; flex: 0 1 auto;
}
.list-title-row {
    display: flex; align-items: center; gap: 8px;
    min-width: 0;
}
.list-title {
    margin: 0;
    font-size: 18px; font-weight: 600;
    line-height: 1.2;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    min-width: 0;
}
.list-subtitle {
    margin: 2px 0 0 18px; /* aligné sous le titre, après la pastille */
    font-size: 11px;
    color: var(--text-mute);
    line-height: 1.2;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.btn-icon svg { display: block; }

.add-row {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 14px 18px 16px;
}
.add-row form {
    display: flex;
    gap: 8px;
    align-items: stretch;
    max-width: var(--content-max);
    margin: 0 auto;
}
.add-row input {
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    transition: border-color .12s;
    min-width: 0;
}
.add-row input:focus { border-color: var(--accent); }
#add-name { flex: 1 1 0; }
#add-qty  { flex: 0 0 70px;  text-align: center; }
#add-cat  { flex: 0 0 130px; }
.add-row .btn-add {
    flex: 0 0 auto;
    height: 40px; width: 44px;
    padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
}
@media (max-width: 520px) {
    .add-row form { flex-wrap: wrap; }
    #add-name { flex: 1 1 100%; }
    #add-qty  { flex: 0 0 70px; }
    #add-cat  { flex: 1 1 auto; }
    .add-row .btn-add { flex: 0 0 44px; }
}

/* Quand une suggestion auto-rayon est dispo, on rend le placeholder du champ
   Rayon visiblement différent pour signaler l'utilisateur. */
#add-cat.has-suggestion::placeholder {
    color: var(--accent);
    opacity: 0.85;
    font-weight: 500;
}

/* ── Favoris / récurrence ───────────────────────────────── */
.favorites-row {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 10px 18px 12px;
}
.favorites-panel {
    max-width: var(--content-max);
    margin: 0 auto;
    display: flex;
}
.btn-favorites-activate {
    padding: 7px 12px;
    font-size: 13px;
    margin-left: auto;
}

/* ── Items ──────────────────────────────────────────────── */
.items-wrap {
    flex: 1;
    padding: 12px 16px calc(var(--safe-bottom) + 24px);
    overflow-y: auto;
}
.items-container {
    max-width: var(--content-max);
    margin: 0 auto;
}
.cat-group { margin-bottom: 14px; }
.cat-group:last-child { margin-bottom: 0; }
.cat-header {
    margin: 14px 4px 6px;
    font-size: 11px; font-weight: 600;
    color: var(--text-mute);
    text-transform: uppercase;
    letter-spacing: .08em;
}
.cat-group:first-child .cat-header { margin-top: 4px; }

.items {
    list-style: none; margin: 0; padding: 0;
    display: flex; flex-direction: column; gap: 4px;
}
.item {
    display: flex; align-items: stretch; gap: 0;
    padding: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: background .12s, opacity .12s;
    cursor: pointer; /* l'espace vide de la ligne toggle l'item */
}
.item:hover { background: var(--bg-soft); }
.item .check {
    width: 22px; height: 22px;
    margin: 10px 10px 10px 12px;
    border: 2px solid var(--border);
    border-radius: 50%;
    flex-shrink: 0;
    align-self: center;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: all .12s;
    background: var(--bg-card);
}
.item .check:hover { border-color: var(--accent); }
.item .check.done {
    background: var(--accent);
    border-color: var(--accent);
}
.item .check.done::after {
    content: '✓';
    color: #fff; font-size: 13px; font-weight: 700;
}
.item .body {
    flex: 1; min-width: 0;
    padding: 10px 0;
    display: flex; flex-direction: column; gap: 2px;
    align-self: center;
    cursor: pointer; /* clic sur la zone vide a cote du nom = toggle */
}
.item .body-line {
    display: flex; align-items: baseline; gap: 8px;
    min-width: 0;
}
.item .note {
    font-size: 12px;
    font-style: italic;
    color: var(--text-mute);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    min-width: 0;
}
.item .name {
    font-size: 15px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    min-width: 0;
    border-radius: 4px;
    padding: 1px 3px;
    margin: -1px -3px;
    cursor: text; /* seul le texte du nom permet de renommer */
}
.item .name.editing {
    overflow: visible;
    white-space: normal;
    text-overflow: clip;
    background: var(--bg-card);
    box-shadow: 0 0 0 2px var(--accent);
    cursor: text;
    outline: none;
}
.item .name.editing::selection { background: rgba(16,185,129,.25); }
.item .qty {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-soft);
    background: var(--bg-soft);
    padding: 2px 7px;
    border-radius: 6px;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}
.item .item-action {
    border: none;
    border-left: 1px solid var(--border);
    width: 48px;
    flex-shrink: 0;
    align-self: stretch;
    color: var(--text-soft);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .12s, color .12s;
}
.item .favorite-zone {
    background: var(--bg-card);
}
.item .favorite-zone:hover,
.item .favorite-zone.active {
    background: color-mix(in srgb, var(--list-color, var(--accent)) 10%, var(--bg-card));
    color: var(--list-color, var(--accent));
}
/* Zone droite de la ligne, cible cliquable qui ouvre la modale
   d'édition (qty, rayon, note). */
.item .actions-zone {
    background: color-mix(in srgb, var(--list-color, var(--accent)) 8%, var(--bg-card));
}
.item .actions-zone:hover {
    background: color-mix(in srgb, var(--list-color, var(--accent)) 22%, var(--bg-card));
    color: var(--list-color, var(--accent));
}
.item .item-action:focus-visible {
    outline: 2px solid var(--list-color, var(--accent));
    outline-offset: -2px;
}
/* Quand le row entier passe en :hover, garder la zone visuellement
   distincte (sinon elle se confond avec le bg-soft du row) */
.item:hover .actions-zone {
    background: color-mix(in srgb, var(--list-color, var(--accent)) 14%, var(--bg-soft));
}
.item:hover .favorite-zone {
    background: var(--bg-soft);
}
.item:hover .favorite-zone.active {
    background: color-mix(in srgb, var(--list-color, var(--accent)) 12%, var(--bg-soft));
}
.item .item-action svg {
    width: 20px; height: 20px;
}

.items-done .item {
    opacity: .55;
}
.items-done .item .name {
    text-decoration: line-through;
    color: var(--text-soft);
}

.checked-block-wrap {
    position: relative;
    margin-top: 16px;
}
.checked-block {
    margin-top: 0;
}
.checked-block summary {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 64px 8px 4px;
    font-size: 13px; color: var(--text-soft);
    cursor: pointer;
    list-style: none;
}
.checked-block summary::-webkit-details-marker { display: none; }
.checked-block summary::before {
    content: '▸';
    font-size: 10px;
    transition: transform .15s;
}
.checked-block[open] summary::before { transform: rotate(90deg); }
.checked-clear {
    position: absolute;
    top: 8px;
    right: 4px;
}
.checked-block ul { margin-top: 8px; }

.empty-state {
    color: var(--text-mute);
    text-align: center;
    margin: 32px 0;
    font-size: 14px;
}

/* ── Modale ─────────────────────────────────────────────── */
.modal {
    position: fixed; inset: 0;
    z-index: 100;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.4);
}
.modal-card {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%; max-width: 400px;
    box-shadow: var(--shadow);
}
.modal-card h2 { margin: 0 0 14px; font-size: 18px; }
.modal-actions {
    display: flex; gap: 8px; justify-content: flex-end;
    margin-top: 16px;
}
.modal-actions .btn-danger { margin-right: auto; }

.color-picker {
    display: flex; gap: 8px; flex-wrap: wrap;
}
.color-swatch {
    width: 30px; height: 30px;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: transform .12s, border-color .12s;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.selected {
    border-color: var(--text);
    transform: scale(1.1);
}
.color-swatch:disabled { cursor: not-allowed; opacity: 0.6; }
.color-swatch:disabled:hover { transform: none; }

/* ── Section partage (Lots 1 & 2) ──────────────────────── */
.share-block { display: block; }
.share-invite-row, .share-add-row {
    display: flex; gap: 8px; margin-bottom: 10px;
}
.share-invite-row input, .share-add-row input {
    flex: 1; min-width: 0;
}
.share-members {
    list-style: none; padding: 0; margin: 0 0 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    max-height: 200px; overflow-y: auto;
}
.share-member {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.share-member:last-child { border-bottom: none; }
.share-name { font-weight: 500; }
.share-tag {
    font-size: 11px; font-weight: 600;
    padding: 2px 8px; border-radius: 999px;
    background: var(--bg-soft); color: var(--text-mute);
    text-transform: uppercase; letter-spacing: 0.05em;
}
.share-tag-owner {
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    color: var(--accent);
}
.share-remove {
    margin-left: auto;
    font-size: 12px; color: var(--danger, #b91c1c);
}
.share-empty, .share-loading, .share-error {
    list-style: none; padding: 12px;
    color: var(--text-mute); font-size: 13px; text-align: center;
}
.share-error { color: var(--danger, #b91c1c); }

/* Liste des invitations pending (Lot 2). Affichée seulement si non-vide.
   Layout en grid 2 lignes : l'email a sa propre ligne pleine largeur (donc
   pas d'ellipsis sur mobile), meta + actions s'alignent sur la 2e ligne. */
.share-pending {
    list-style: none; padding: 0; margin: 0 0 10px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: color-mix(in srgb, var(--accent) 4%, transparent);
}
.share-pending:empty { display: none; }
.share-pending-item {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "email email"
        "meta  actions";
    column-gap: 10px;
    row-gap: 4px;
    padding: 8px 12px;
    border-bottom: 1px dashed var(--border);
    font-size: 13px;
}
.share-pending-item:last-child { border-bottom: none; }
.share-pending-email {
    grid-area: email;
    font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    min-width: 0;
}
.share-pending-meta {
    grid-area: meta;
    font-size: 11px; color: var(--text-mute);
    align-self: center;
}
.share-pending-actions {
    grid-area: actions;
    display: flex; gap: 8px; align-items: center;
    justify-content: flex-end;
}
.share-pending-actions .btn-link {
    font-size: 12px;
}
.share-pending-actions .share-revoke {
    color: var(--danger, #b91c1c);
}

/* Bandeau d'invitation au-dessus de l'écran d'auth (Lot 2) */
.auth-invite {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px;
    margin: 0 0 18px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--accent) 8%, var(--bg-soft));
    border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.auth-invite-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
    background: var(--accent);
}
.auth-invite-text {
    margin: 0;
    font-size: 13px; line-height: 1.45;
    color: var(--text);
}
.auth-invite-text strong { font-weight: 600; }

/* ── Modale Listes archivées ────────────────────────────── */
.modal-hint {
    margin: 0 0 14px;
    font-size: 13px;
    color: var(--text-soft);
    line-height: 1.4;
}
.archives-list {
    list-style: none; margin: 0 0 14px; padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    max-height: 360px; overflow-y: auto;
}
.archived-list-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.archived-list-item:last-child { border-bottom: none; }
.archived-list-item .dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.archived-meta {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; gap: 2px;
}
.archived-name {
    font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.archived-sub {
    font-size: 12px;
    color: var(--text-mute);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.archived-restore {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 13px;
}
.archived-purge {
    flex-shrink: 0;
    color: var(--danger);
    font-size: 12px;
}
.archives-empty, .archives-loading, .archives-error {
    list-style: none;
    padding: 24px 12px;
    color: var(--text-mute);
    font-size: 13px;
    text-align: center;
}
.archives-error { color: var(--danger); }

/* ── Modale Import depuis du texte ──────────────────────── */
.import-target {
    display: flex; flex-direction: column; gap: 6px;
}
.import-target-opt {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 0;
    font-size: 14px;
    cursor: pointer;
    color: var(--text);
}
.import-target-opt input[type="radio"] { accent-color: var(--accent); cursor: pointer; }
.import-target-opt input[type="radio"]:disabled + span,
.import-target-opt input[type="radio"]:disabled { cursor: not-allowed; opacity: 0.6; }

#import-text {
    width: 100%;
    min-height: 160px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.45;
    resize: vertical;
}
.import-help {
    margin-top: 6px;
}
.import-help code {
    background: var(--bg-soft);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
}
.import-preview {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--text-soft);
    min-height: 1.2em;
}

/* ── Mobile ─────────────────────────────────────────────── */
@media (max-width: 720px) {
    .topbar #btn-menu { display: flex; }

    /* Sur mobile on respire encore plus : padding vertical genereux et titre
       legerement plus gros pour une vraie hierarchie avec le contenu en dessous. */
    .topbar {
        padding: calc(var(--safe-top) + 16px) 14px 16px;
        gap: 10px;
    }
    .list-title { font-size: 19px; }

    .add-row { padding: 14px 14px 14px; }
    .favorites-row { padding: 10px 14px; }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 100;
        width: 84vw; max-width: 280px;
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: 4px 0 18px rgba(0,0,0,.08);
    }
    .sidebar.open { transform: translateX(0); }
}
