:root {
    --bg: #0f1419;
    --surface: #1f2933;
    --surface-2: #2a3744;
    --text: #e6edf3;
    --muted: #93a1b0;
    --accent: #4f9cf9;
    --danger: #f97066;
    --ok: #4ade80;
    --radius: 12px;
    --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* Écran de démarrage : logo + nom + loader, masqué une fois la collection chargée. */
.app-splash {
    position: fixed; inset: 0; z-index: 50;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
    background: var(--bg);
    transition: opacity .35s ease;
}
.app-splash.hide { opacity: 0; pointer-events: none; }
.splash-logo { width: 96px; height: 96px; border-radius: 20px; }
.splash-name { font-size: 1.5rem; font-weight: 700; letter-spacing: .04em; }
.splash-loader {
    width: 28px; height: 28px; border-radius: 50%;
    border: 3px solid var(--surface-2); border-top-color: var(--accent);
    animation: splash-spin .8s linear infinite;
}
@keyframes splash-spin { to { transform: rotate(360deg); } }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    padding-bottom: calc(80px + var(--safe-b));
}

/* Barre supérieure */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
    padding: 12px 16px calc(12px + env(safe-area-inset-top, 0px));
    box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
}
.topbar h1 { margin: 0 0 10px; font-size: 1.2rem; }
.topbar-row { display: flex; align-items: center; justify-content: space-between; }
.topbar-row h1 { margin: 0 0 10px; }
.topbar-row .icon-btn { font-size: 1.3rem; }
.collection-count { font-size: .9rem; font-weight: 400; color: var(--muted); }
.search input {
    width: 100%;
    padding: 11px 14px;
    border: none;
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    font-size: 1rem;
}
.search input::placeholder { color: var(--muted); }
.search { display: flex; gap: 8px; align-items: center; }
.search input { flex: 1; }

/* Barre de filtres & tri */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-top: 10px;
    align-items: flex-end;
}
.filters .flt { margin: 0; font-size: .72rem; }
.filters select,
.filters input {
    display: block;
    margin-top: 4px;
    padding: 7px 9px;
    border: none;
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    font-size: .9rem;
    max-width: 150px;
}
.filters #flt-year { max-width: 90px; }

/* Grille de cartes */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    padding: 16px;
}
.card {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    transition: transform .12s ease;
}
.card:active { transform: scale(.97); }
.card .cover {
    position: relative;
    aspect-ratio: 2 / 3;
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 2.5rem;
    overflow: hidden;
}
.card .cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.card .body { padding: 8px 10px 10px; }
.card .title {
    font-weight: 600;
    font-size: .92rem;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
/* Badges support + état superposés en bas à gauche de l'affiche. */
.card-badges {
    position: absolute;
    left: 6px;
    bottom: 6px;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    max-width: calc(100% - 12px);
}
.card-badges .badge { box-shadow: 0 1px 3px rgba(0, 0, 0, .55); }
/* Le badge état (non-support) a besoin d'un fond opaque pour rester lisible sur l'affiche. */
.card-badges .badge:not(.support) { background: rgba(0, 0, 0, .72); color: #e6edf3; }
.badge {
    font-size: .7rem;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
}
.badge.support { background: var(--accent); color: #06121f; font-weight: 600; }
/* Couleur de la puce selon le support : DVD rouge, Blu-ray bleu, VHS noir. */
.badge.support[data-support="DVD"]     { background: #e5484d; color: #fff; }
.badge.support[data-support="Blu-ray"] { background: #1f6feb; color: #fff; }
.badge.support[data-support="VHS"]     { background: #16191d; color: #e6edf3; }
.flags { display: flex; gap: 4px; font-size: .8rem; }
/* Pictos sous le titre de la carte (pas d'espace réservé s'il n'y en a aucun). */
.card .flags:not(:empty) { margin-top: 6px; font-size: .9rem; }

.empty {
    text-align: center;
    color: var(--muted);
    margin-top: 25vh;
    padding: 0 24px;
}

/* Bouton flottant */
.fab {
    position: fixed;
    right: 18px;
    bottom: calc(18px + var(--safe-b));
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #06121f;
    font-size: 2rem;
    line-height: 1;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
    z-index: 20;
    cursor: pointer;
}

/* Modale */
.dialog {
    border: none;
    border-radius: 16px 16px 0 0;
    padding: 0;
    width: 100%;
    max-width: 560px;
    margin: auto auto 0;
    background: var(--surface);
    color: var(--text);
}
.dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog form { padding: 16px 16px calc(16px + var(--safe-b)); max-height: 92vh; overflow-y: auto; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dialog-head strong { font-size: 1.1rem; }
/* En-tête des dialogs sans <form> (compte/partage/à propos) : il est enfant direct
   du <dialog> et n'héritait d'aucun padding → titre et croix collés aux bords. */
.dialog > .dialog-head { padding: 12px 16px 0; margin-bottom: 8px; }

label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 12px; }
input, select, textarea {
    width: 100%;
    margin-top: 5px;
    padding: 10px 12px;
    border: 1px solid var(--surface-2);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
}
textarea { resize: vertical; }
.row { display: flex; gap: 12px; }
.row label { flex: 1; }
.title-row { display: flex; gap: 8px; align-items: flex-end; }
.title-row input { flex: 1; }

.checks { display: flex; gap: 16px; margin-bottom: 12px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); margin: 0; }
.check input { width: auto; margin: 0; }

/* Boutons */
.btn {
    border: none;
    border-radius: 10px;
    padding: 11px 18px;
    font-size: 1rem;
    cursor: pointer;
    background: var(--surface-2);
    color: var(--text);
}
.btn.primary { background: var(--accent); color: #06121f; font-weight: 600; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-sm {
    border: none;
    border-radius: 8px;
    padding: 9px 12px;
    background: var(--surface-2);
    color: var(--text);
    font-size: .85rem;
    cursor: pointer;
}
.btn-sm.ghost { background: transparent; border: 1px solid var(--surface-2); }
.icon-btn { background: none; border: none; color: var(--muted); font-size: 1.2rem; cursor: pointer; }
.dialog-foot { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.spacer { flex: 1; }
[hidden] { display: none !important; }

/* Enrichissement */
.enrich-results { margin-bottom: 12px; display: grid; gap: 8px; max-height: 240px; overflow-y: auto; }
.enrich-item { display: flex; gap: 10px; padding: 8px; background: var(--surface-2); border-radius: 10px; cursor: pointer; }
.enrich-item .ei-thumb { width: 46px; height: 69px; flex: 0 0 auto; object-fit: cover; border-radius: 6px; background: #000; }
.enrich-item .ei-thumb-empty { display: flex; align-items: center; justify-content: center; background: var(--surface); font-size: 1.2rem; }
.enrich-item .ei-body { font-size: .82rem; }
.enrich-item .ei-title { font-weight: 600; }
.enrich-item .ei-syn { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.enrich-search { display: flex; gap: 6px; }
.enrich-search input { flex: 1; min-width: 0; }
.enrich-status { color: var(--muted); font-size: .82rem; }
.enrich-list { display: grid; gap: 8px; }
.poster-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.poster-opt { padding: 2px; border: 2px solid transparent; border-radius: 8px; background: none; cursor: pointer; line-height: 0; }
.poster-opt.selected { border-color: var(--accent); }
.poster-opt .ei-thumb { width: 72px; height: 108px; }
.poster-foot { display: flex; gap: 8px; margin-top: 10px; }

/* Photos */
.photos-fs { border: 1px solid var(--surface-2); border-radius: 10px; padding: 10px; margin-bottom: 12px; }
.photos-fs legend { color: var(--muted); font-size: .8rem; padding: 0 6px; }
.photo-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.file-label { display: inline-flex; align-items: center; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumb { position: relative; width: 70px; height: 70px; cursor: grab; touch-action: manipulation; }
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; pointer-events: none; }
.thumb.cover img { outline: 2px solid var(--accent, gold); outline-offset: -2px; }
.thumb .cover-badge { display: none; }
.thumb.cover .cover-badge {
    display: block; position: absolute; bottom: 2px; left: 2px; right: 2px;
    font-size: .58rem; text-align: center; line-height: 1.4;
    background: rgba(0, 0, 0, .65); color: #fff; border-radius: 0 0 6px 6px;
}
.thumb.sortable-ghost { opacity: .4; }
.thumb.sortable-chosen { cursor: grabbing; }
.thumb .rm {
    position: absolute; top: -6px; right: -6px;
    width: 22px; height: 22px; border-radius: 50%;
    border: none; background: var(--danger); color: #fff; cursor: pointer; line-height: 1;
}
.thumb .fix, .thumb .revert {
    position: absolute; top: -6px;
    width: 22px; height: 22px; border-radius: 50%;
    border: none; background: var(--surface-2); color: var(--text); cursor: pointer;
    font-size: .75rem; line-height: 1;
}
.thumb .fix { left: -6px; }
.thumb .revert { left: 18px; }
.hint { color: var(--muted); font-size: .72rem; margin: 8px 0 0; }

/* Toast */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(90px + var(--safe-b));
    transform: translateX(-50%);
    background: var(--surface-2);
    color: var(--text);
    padding: 10px 18px;
    border-radius: 999px;
    z-index: 50;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
    font-size: .9rem;
}
.toast.err { background: var(--danger); color: #fff; }

/* --- Écrans d'authentification --- */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.auth-card {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
}
.auth-card h1 { margin: 0 0 4px; text-align: center; }
.auth-intro { color: var(--muted); font-size: .85rem; text-align: center; margin: 0 0 16px; }
.auth-card .btn { width: 100%; margin-top: 8px; }
.auth-error { color: var(--danger); font-size: .85rem; margin: 12px 0 0; text-align: center; }
.auth-welcome { color: var(--text); font-size: 1rem; text-align: center; margin: 0 0 12px; }
.auth-link {
    display: block; width: 100%; margin-top: 10px;
    background: none; border: 0; color: var(--muted);
    font-size: .82rem; text-decoration: underline; cursor: pointer;
}

/* --- Panneau compte / admin --- */
.account-body { padding: 0 16px 16px; max-height: 82vh; overflow-y: auto; }
.acc-section { margin-top: 18px; border-top: 1px solid var(--surface-2); padding-top: 14px; }
.acc-section h3 { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin: 0 0 10px; }
.passkey-row, .user-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; padding: 6px 0; font-size: .9rem;
}
.passkey-list:empty::after { content: "Aucun appareil enregistré."; color: var(--muted); font-size: .82rem; }
.user-create { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.user-create input[type="text"], .user-create input[type="password"] { width: auto; flex: 1; min-width: 120px; }

/* --- Vue détail (plein écran) --- */
.dialog.detail {
    max-width: 100%;
    width: 100%;
    height: 100%;
    max-height: 100%;
    margin: 0;
    border-radius: 0;
}
/* display scopé à [open] : sinon la spécificité écraserait le display:none de fermeture. */
.dialog.detail[open] { display: flex; flex-direction: column; }
.dialog.detail .detail-body {
    padding: 0 16px;
    flex: 1;
    overflow-y: auto;
    /* Sur desktop, on garde le contenu dans une colonne lisible alignée plutôt que
       de l'étaler sur toute la largeur (badges/infos qui « flottaient » à droite). */
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    transition: transform .18s ease, opacity .18s ease;
}
/* Transition de swipe entre fiches (session 20260705) : sortie/entrée latérale. */
.dialog.detail .detail-body.detail-slide-left { transform: translateX(-32px); opacity: 0; }
.dialog.detail .detail-body.detail-slide-right { transform: translateX(32px); opacity: 0; }
@media (prefers-reduced-motion: reduce) {
    .dialog.detail .detail-body { transition: none; }
}
.dialog.detail .dialog-head {
    padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 8px;
    margin-bottom: 0;
}
.dialog.detail .dialog-foot { padding: 12px 16px calc(16px + var(--safe-b)); }

.detail-hero { display: flex; gap: 14px; margin-bottom: 14px; }
.d-poster {
    flex: 0 0 132px;
    aspect-ratio: 2 / 3;
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface-2);
}
.d-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.d-poster.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}
.detail-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.d-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.d-line { margin: 0; font-size: .9rem; }
.d-line.muted { color: var(--muted); font-size: .8rem; }
/* Pictos alignés à gauche, dans le flux des autres infos (plus de flottement bas/droite). */
.d-flags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.d-flags:empty { margin-top: 0; }
.d-flag {
    font-size: .8rem;
    color: var(--text);
    background: var(--surface-2);
    padding: 3px 9px;
    border-radius: 999px;
    align-self: flex-start;
}
.d-synopsis { font-size: .9rem; line-height: 1.45; color: var(--text); margin: 0 0 16px; }

/* Bloc infos API */
.api-info { margin-bottom: 16px; }
.api-info-head { display: flex; align-items: center; gap: 8px; }
.api-info-head h3 { margin: 0; flex: 1; }
.api-info-head #api-refresh { margin-left: auto; }
.api-info h3,
.detail-gallery h3 { font-size: .85rem; color: var(--muted); margin: 0 0 8px; text-transform: uppercase; letter-spacing: .03em; }
.api-info-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.api-info-list li { display: flex; gap: 10px; font-size: .88rem; }
.api-info-list .ai-label { flex: 0 0 90px; color: var(--muted); }

/* Galerie photos (vignettes agrandies) */
.detail-gallery { margin-bottom: 8px; }
.detail-photos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 8px;
}
.detail-photos img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 10px;
    background: var(--surface-2);
}

/* ===== Caméra plein écran (session 09) ===== */
/* <dialog> ouvert en showModal() → top layer, au-dessus des autres modales. */
body.overlay-open { overflow: hidden; }
.camera-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background: #000;
}
.camera-overlay[open] { display: flex; flex-direction: column; }
.camera-overlay::backdrop { background: #000; }
.camera-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}
.camera-bar {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    gap: 12px;
}
.camera-bar-top {
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    background: linear-gradient(rgba(0, 0, 0, .55), transparent);
}
.camera-bar-bottom {
    margin-top: auto;
    padding-bottom: calc(20px + var(--safe-b));
    background: linear-gradient(transparent, rgba(0, 0, 0, .55));
}
.cam-icon {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, .45);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
}
.camera-count { color: #fff; font-size: .85rem; text-shadow: 0 1px 2px #000; }
.cam-spacer, .cam-done { flex: 1 1 0; }
.cam-done {
    text-align: right;
    background: none;
    border: none;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    padding: 10px 4px;
}
/* Gros bouton obturateur, atteignable au pouce */
.shutter {
    flex: 0 0 auto;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: #fff;
    border: 5px solid rgba(255, 255, 255, .55);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, .25);
    cursor: pointer;
}
.shutter:active { transform: scale(.92); }
.camera-flash {
    position: absolute;
    inset: 0;
    background: #fff;
    opacity: 0;
    pointer-events: none;
    z-index: 3;
}
.camera-overlay.flash .camera-flash { animation: cam-flash .25s ease-out; }
@keyframes cam-flash { from { opacity: .85; } to { opacity: 0; } }

/* ===== Éditeur photo : redressement du boîtier avant envoi ===== */
/* Même pattern top layer que .camera-overlay ; peut s'ouvrir par-dessus elle. */
.photo-editor {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background: var(--bg);
}
.photo-editor[open] { display: flex; flex-direction: column; }
.photo-editor::backdrop { background: #000; }
.pe-top {
    padding: calc(14px + env(safe-area-inset-top, 0px)) 18px 10px;
    color: #fff;
    text-align: center;
    font-size: .9rem;
    font-weight: 600;
}
.pe-host {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}
.pe-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px calc(14px + var(--safe-b));
    background: linear-gradient(transparent, rgba(0, 0, 0, .35));
}
.pe-foot .btn-sm.ghost { margin-right: auto; }

/* Éditeur de coins scanic (assets/js/vendor/scanic.min.js) : valeurs par défaut de
   la lib, surchargées à l'exécution par l'option `theme` (voir photo-editor.js). */
.scanic-corner-editor {
    --scanic-accent: #6366f1;
    --scanic-mask: rgba(15, 23, 42, 0.45);
    --scanic-edge-color: var(--scanic-accent);
    --scanic-edge-width: 2.5;
    --scanic-handle-size: 20px;
    --scanic-handle-hit: 44px;
    --scanic-handle-color: #ffffff;
    --scanic-handle-ring: 2px;
    --scanic-handle-ring-color: var(--scanic-accent);
    --scanic-handle-shadow: 0 1px 4px rgba(15, 23, 42, 0.45);
    --scanic-handle-active-shadow: 0 8px 22px rgba(15, 23, 42, 0.5);
    --scanic-handle-active-scale: 1.28;
}
.scanic-handle {
    position: absolute;
    box-sizing: border-box;
    width: var(--scanic-handle-size);
    height: var(--scanic-handle-size);
    margin: 0;
    padding: 0;
    border: var(--scanic-handle-ring) solid var(--scanic-handle-ring-color);
    border-radius: 50%;
    background: var(--scanic-handle-color);
    box-shadow: var(--scanic-handle-shadow);
    transform: translate(-50%, -50%);
    cursor: grab;
    touch-action: none;
    z-index: 2;
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
}
.scanic-handle::after {
    content: '';
    position: absolute;
    left: 50%; top: 50%;
    width: var(--scanic-handle-hit);
    height: var(--scanic-handle-hit);
    transform: translate(-50%, -50%);
    border-radius: 50%;
}
.scanic-handle::before {
    content: '';
    position: absolute;
    left: 50%; top: 50%;
    width: 0; height: 0;
    border-radius: 50%;
    background: var(--scanic-accent);
    opacity: 0;
    transform: translate(-50%, -50%);
    transition: opacity .15s ease, width .15s ease, height .15s ease;
    pointer-events: none;
}
.scanic-handle:hover { transform: translate(-50%, -50%) scale(1.12); }
.scanic-handle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--scanic-accent) 45%, transparent), var(--scanic-handle-shadow);
}
.scanic-handle.is-selected {
    border-color: var(--scanic-accent);
    transform: translate(-50%, -50%) scale(1.12);
}
.scanic-handle.is-selected::before {
    opacity: .16;
    width: calc(var(--scanic-handle-size) * 2);
    height: calc(var(--scanic-handle-size) * 2);
}
.scanic-handle.is-active {
    cursor: grabbing;
    background: var(--scanic-accent);
    border-color: #ffffff;
    transform: translate(-50%, -50%) scale(var(--scanic-handle-active-scale));
    box-shadow: var(--scanic-handle-active-shadow);
}
.scanic-handle.is-active::before {
    opacity: .22;
    width: calc(var(--scanic-handle-size) * 2.8);
    height: calc(var(--scanic-handle-size) * 2.8);
}

/* ===== Visionneuse photo plein écran (session 10) ===== */
/* <dialog> ouvert en showModal() → top layer, au-dessus de la fiche détail. */
.lightbox {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background: rgba(0, 0, 0, .94);
}
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox::backdrop { background: rgba(0, 0, 0, .6); }
.lb-stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    touch-action: none;
}
.lb-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transform-origin: center center;
    transition: transform .05s linear;
    cursor: zoom-in;
    user-select: none;
    -webkit-user-drag: none;
}
.lb-img.zoomed { cursor: grab; }
.lb-btn {
    position: absolute;
    z-index: 2;
    border: none;
    background: rgba(0, 0, 0, .45);
    color: #fff;
    cursor: pointer;
}
.lb-close {
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: 14px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.3rem;
}
.lb-nav {
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 64px;
    border-radius: 10px;
    font-size: 2rem;
    line-height: 1;
}
.lb-prev { left: 8px; }
.lb-next { right: 8px; }
.lb-counter {
    position: absolute;
    bottom: calc(16px + var(--safe-b));
    left: 0;
    right: 0;
    text-align: center;
    color: #fff;
    font-size: .85rem;
    text-shadow: 0 1px 2px #000;
    z-index: 2;
}
/* Indique que les photos sont cliquables pour agrandir */
.d-poster img, .detail-photos img { cursor: zoom-in; }

/* --- Menu burger --- */
.menu-wrap { position: relative; }
#menu-btn { position: relative; }
.main-menu {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
    background: var(--surface-2); border: 1px solid #38465610;
    border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.4);
    min-width: 220px; padding: 6px; display: flex; flex-direction: column;
}
.menu-item {
    display: flex; align-items: center; gap: 8px;
    background: none; border: none; color: var(--text);
    text-align: left; padding: 11px 12px; border-radius: 8px;
    font-size: .95rem; cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface); }
/* Pastille de notification (compteur d'invitations) — classe distincte des
   pastilles de collection (.badge) pour éviter toute collision de styles. */
.count-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 5px; margin-left: auto;
    background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700;
    border-radius: 999px; line-height: 1;
}
#menu-btn .count-badge { position: absolute; top: -4px; right: -4px; margin: 0; }

/* --- Bandeau « consultation d'une collection amie » --- */
.view-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    margin-top: 10px; padding: 8px 12px;
    background: var(--surface-2); border-radius: var(--radius);
    font-size: .85rem; color: var(--text);
}

/* --- Avatar --- */
.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; flex: 0 0 36px; border-radius: 50%;
    background: var(--surface-2); color: var(--text);
    font-size: .8rem; font-weight: 700; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 64px; height: 64px; flex-basis: 64px; font-size: 1.2rem; }

/* En-tête du menu burger : avatar + nom affiché de l'utilisateur. */
.menu-head {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px 10px; margin-bottom: 4px;
    border-bottom: 1px solid var(--surface);
}
.menu-head:empty, .menu-name:empty { display: none; }
.menu-head .avatar { background: var(--surface); }
.menu-name { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- Profil (compte) --- */
.profile-row { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* --- Listes de partage --- */
.share-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.share-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; }
.share-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.share-name { font-size: .92rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.share-sub { color: var(--muted); font-size: .76rem; }
.share-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.share-status { font-size: .74rem; padding: 2px 8px; border-radius: 999px; }
.share-status.ok { color: var(--ok); border: 1px solid var(--ok); }
.share-status.pending { color: var(--muted); border: 1px solid var(--surface-2); }

/* --- Mobile : tous les popins occupent tout l'écran (comme la vue détail) --- */
@media (max-width: 640px) {
    .dialog {
        max-width: 100%;
        width: 100%;
        height: 100%;
        max-height: 100%;
        margin: 0;
        border-radius: 0;
    }
    /* display scopé à [open] pour ne pas écraser le display:none de fermeture. */
    .dialog[open] { display: flex; flex-direction: column; }
    /* Le contenu scrollable prend la hauteur restante au lieu d'un plafond en vh. */
    .dialog > form,
    .dialog > .account-body { flex: 1; min-height: 0; max-height: none; }
    .dialog > form { padding-top: calc(16px + env(safe-area-inset-top, 0px)); }
    .dialog > .dialog-head { padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
}
.btn-sm.danger { color: var(--danger); border-color: var(--danger); }

/* --- Liste « Mes recherches » — switch Collection / Recherches --- */
.list-switch {
    display: flex; gap: 0; margin-top: 10px;
    background: var(--surface); border-radius: var(--radius);
    padding: 3px; overflow: hidden;
}
.list-switch-btn {
    flex: 1; background: none; border: none;
    color: var(--muted); font-size: .88rem; font-weight: 500;
    padding: 7px 10px; border-radius: calc(var(--radius) - 3px);
    cursor: pointer; transition: background .15s, color .15s;
}
.list-switch-btn.active {
    background: var(--surface-2); color: var(--text); font-weight: 600;
}
.list-switch-btn:not(.active):hover { color: var(--text); }

/* --- Statut « Vendu » --- */
/* Badge « Vendu » dans les cartes et la fiche détail. */
.badge.sold {
    background: var(--muted); color: var(--bg); font-weight: 600;
}
/* Carte vendue : légèrement désaturée et transparente. */
.card.sold {
    opacity: .65;
    filter: saturate(.45);
}
.card.sold:hover, .card.sold:focus-visible { opacity: .85; filter: saturate(.65); }

/* Filtre « Inclure les vendus » dans le panneau de filtres. */
.check-flt {
    display: flex; align-items: center; gap: 6px;
    font-size: .88rem; color: var(--muted);
}
.check-flt input[type="checkbox"] { cursor: pointer; }

/* Préférences du compte (section sous le formulaire profil). */
.acc-prefs { margin-top: 10px; }
.acc-prefs .check { font-size: .88rem; color: var(--text); }

/* --- Statistiques de collection (session 31) --- */
.stats-section { margin-bottom: 18px; }
.stats-section h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 8px; }
.stats-kv { display: flex; flex-direction: column; gap: 5px; }
.stats-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: .92rem; }
.stats-label { color: var(--muted); }
.stats-value { font-weight: 600; text-align: right; }
.stats-bar-wrap { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.stats-bar-row { display: flex; align-items: center; gap: 8px; font-size: .88rem; }
.stats-bar-label { flex: 0 0 70px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats-bar { flex: 1; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.stats-bar-fill { height: 100%; background: var(--accent); border-radius: 99px; }
.stats-bar-count { flex: 0 0 28px; text-align: right; color: var(--text); font-weight: 600; }

/* --- Séries TV avec coffrets (sessions 33-34) --- */

/* Fond légèrement différent pour distinguer les séries dans la grille. */
.card.series { background: var(--surface-2); }

/* Carte série : badge coffrets à la place du badge support. */
.badge.coffrets {
    background: var(--surface-2); color: var(--text);
    font-size: .7rem; padding: 2px 7px; border-radius: 999px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .55);
}

/* Mode série dans le formulaire : masque les champs inutiles. */
.dialog.is-series .series-hide { display: none !important; }
/* Mode coffret : masque l'enrichissement et le titre original. */
.dialog.is-coffret .coffret-hide { display: none !important; }

/* Section coffrets dans la fiche détail. */
.d-coffrets-head { display: flex; align-items: baseline; justify-content: space-between; margin: 16px 0 8px; }
.d-coffrets-head h3 { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin: 0; }
.d-coffrets-count { font-size: .8rem; color: var(--muted); font-weight: 400; margin-left: 6px; }
.d-coffrets-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 16px;
}
.coffret-card {
    background: var(--surface-2); border-radius: 10px;
    overflow: hidden; cursor: pointer;
    transition: transform .12s ease;
}
.coffret-card:active { transform: scale(.97); }
.coffret-cover {
    aspect-ratio: 2 / 3; background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    color: var(--muted); font-size: 1.8rem; position: relative; overflow: hidden;
}
.coffret-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.coffret-cover .card-badges { bottom: 4px; left: 4px; }
.coffret-title {
    padding: 5px 8px 7px; font-size: .82rem; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Modale de choix d'ajout (FAB → Élément unique | Série TV). */
.add-choice .add-choice-body {
    padding: 12px 16px calc(20px + var(--safe-b));
    display: flex; flex-direction: column; gap: 10px;
}
.choice-btn {
    display: flex; align-items: center; gap: 14px;
    background: var(--surface-2); border: none; border-radius: var(--radius);
    padding: 16px; cursor: pointer; text-align: left;
    transition: background .12s;
}
.choice-btn:hover, .choice-btn:focus-visible { background: #2f3e50; }
.choice-icon { font-size: 2rem; flex: 0 0 auto; }
.choice-text { display: flex; flex-direction: column; gap: 3px; }
.choice-label { color: var(--text); font-size: 1rem; font-weight: 600; }
.choice-desc { color: var(--muted); font-size: .82rem; }
@media (max-width: 640px) {
    .add-choice { height: auto !important; }
}
