:root {
    --bg: #1a1410;
    --surface: #2a2118;
    --surface-2: #3a2f22;
    --text: #f0e6d8;
    --muted: #b8a68e;
    --accent: #d97706;
    --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 — .book-grid reprend la même card dans la vue collection, sans le
   padding propre à #grid (l'alignement y est porté par la section .collection-view). */
.grid, .book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.grid { padding: 16px; }
.book-grid { margin-bottom: 16px; }
/* Vue collection : une collection sans série (ou sans roman isolé) laisse l'une des
   deux grilles vide — la neutraliser pour ne pas creuser d'espace fantôme. */
.vcard-grid:empty, .book-grid:empty { display: none; }
.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;
}
.card .author {
    font-size: .8rem;
    color: var(--muted);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* 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: var(--text); }
/* Badge année : pas de sémantique catégorielle, même style neutre que le badge état. */
.badge.badge-year { background: rgba(0, 0, 0, .72); color: var(--text); }
.badge {
    font-size: .7rem;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
}
.badge.support { background: var(--accent); color: #1a1410; font-weight: 600; }
/* Couleur de la puce selon le format de reliure. */
.badge.support[data-support="Broché"]      { background: #d97706; color: #1a1410; }
.badge.support[data-support="Poche"]       { background: #65a30d; color: #1a1410; }
.badge.support[data-support="Relié"]       { background: #b45309; color: #fff; }
.badge.support[data-support="Grand format"]{ background: #9a3412; color: #fff; }
.badge.support[data-support="Numérique"]   { background: #1f6feb; color: #fff; }
.badge.support[data-support="Audio"]       { background: #7c3aed; color: #fff; }
.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: #1a1410;
    font-size: 2rem;
    line-height: 1;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
    z-index: 20;
    cursor: pointer;
}

/* Menu à choix du bouton flottant (ex. collection : nouvelle série / roman isolé) */
.fab-menu {
    position: fixed; right: 18px; bottom: calc(18px + var(--safe-b) + 58px + 10px); 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;
}

/* 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; }

.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: #1a1410; 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; flex-wrap: wrap; }
.spacer { flex: 1; }
[hidden] { display: none !important; }

/* 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;
}
.hint { color: var(--muted); font-size: .72rem; margin: 8px 0 0; }

/* OCR (ajout de tome) : lecture auto de la couverture + auto-remplissage des champs. */
.ocr-status { color: var(--muted); font-size: .82rem; margin-top: 10px; }
.ocr-results { display: grid; gap: 8px; margin-top: 10px; }
.ocr-hint, .ocr-conflict {
    display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
    padding: 8px; background: var(--surface-2); border-radius: 10px; font-size: .82rem;
}
#ocr-retry-btn { margin-top: 8px; }

/* 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; }

.detail-gallery h3 { font-size: .85rem; color: var(--muted); margin: 0 0 8px; text-transform: uppercase; letter-spacing: .03em; }

/* 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; } }

/* ===== 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)); }
}
/* Le formulaire d'édition porte trois boutons (Supprimer, Déplacer, Enregistrer) :
   sur un écran étroit ils ne tiennent sur une ligne qu'avec un rembourrage réduit. */
@media (max-width: 420px) {
    .dialog-foot .btn { padding: 11px 12px; }
}
.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; }

/* --- Tomes (livres physiques rattachés à une série) --- */

/* Mode coffret : masque le titre original et les champs portés par la série. */
.dialog.is-coffret .coffret-hide { display: none !important; }
/* Mode simplifié (création de tome, par défaut) : ne garde que Titre/État/Année/Photos. */
.dialog.is-simple-tome .tome-detail-hide { display: none !important; }

/* Grille des tomes d'une série (fiche détail série, réutilisée dans #book-serie-tomes-list). */
.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;
}

/* --- Collections de livres (Collection > Série > Tome) --- */

/* Onglets : « Romans isolés » + une collection par onglet + « + ». */
.collection-tabs {
    display: flex; gap: 6px; margin-top: 10px;
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.collection-tabs::-webkit-scrollbar { display: none; }
.collection-tabs .tab {
    flex: 0 0 auto; background: var(--surface); border: 1px solid var(--surface-2);
    color: var(--muted); font-size: .88rem; font-weight: 500;
    padding: 7px 13px; border-radius: calc(var(--radius) - 3px); cursor: pointer;
    white-space: nowrap; transition: background .15s, color .15s;
}
.collection-tabs .tab.active {
    background: var(--accent); border-color: var(--accent); color: var(--bg); font-weight: 700;
}
.collection-tabs .tab.tab-add { font-size: 1.05rem; font-weight: 700; }

/* Régions principales collection / série. */
.collection-view, .vcard-view { padding-top: 12px; }

/* Bannière de collection (image d'illustration optionnelle en fond). */
.coll-banner {
    position: relative; border-radius: var(--radius); overflow: hidden;
    background: var(--surface-2); padding: 15px 18px; margin-bottom: 16px;
    min-height: 92px; display: flex; flex-direction: column; justify-content: flex-end;
}
.coll-banner.has-cover { min-height: 150px; }
.coll-banner > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
.coll-banner.has-cover::after {
    content: ''; position: absolute; inset: 0; z-index: 1;
    background: linear-gradient(to top, rgba(0, 0, 0, .78), rgba(0, 0, 0, .15));
}
.coll-banner-body { position: relative; z-index: 2; }
.coll-banner-title { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.coll-banner-sub { font-size: .85rem; color: var(--muted); margin-top: 2px; font-weight: 500; }
.coll-banner-notes { font-size: .85rem; color: var(--text); margin-top: 8px; white-space: pre-wrap; }
.coll-banner-actions { position: absolute; top: 8px; right: 8px; z-index: 3; display: flex; gap: 4px; }
.coll-banner-actions .icon-btn { font-size: 1.05rem; color: var(--muted); }
.coll-banner.has-cover .icon-btn { color: #fff; }
/* Bouton retour du bandeau de série (le bandeau de collection n'en a pas). */
.coll-banner-back { position: absolute; top: 8px; left: 8px; z-index: 3; font-size: 1.05rem; color: var(--muted); }

/* Grille des séries d'une collection. */
.vcard-grid {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px; margin-bottom: 16px;
}
.vcard-item {
    cursor: pointer; background: var(--surface); border: 1px solid var(--surface-2);
    border-radius: var(--radius); padding: 14px 14px 12px;
}
.vcard-item-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.vcard-item-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 6px;
    margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--surface-2);
}
.vcard-scale {
    font-size: .68rem; font-weight: 600; color: var(--muted);
    min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Jeton de couverture (série ou fiche série) : image si disponible, sinon icône. */
.vcard-cover {
    position: relative; flex: 0 0 52px; width: 52px; height: 52px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg); border-radius: 10px; overflow: hidden; font-size: 1.4rem;
}
.vcard-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vcard-name {
    min-width: 0; font-size: .88rem; font-weight: 700; color: var(--text);
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
/* Badge « N tomes » — réutilisé dans la grille des séries et l'en-tête de fiche série. */
.vcard-ex-badge {
    display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
    background: var(--accent); color: var(--bg); font-size: .68rem; font-weight: 700;
    padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
/* Regroupe les badges de la card série (nombre de tomes, complétude, avancement). */
.vcard-item-badges { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.vcard-complete-badge { background: #65a30d; color: #1a1410; }
.vcard-incomplete-badge { background: var(--muted); color: var(--bg); }
.vcard-status-badge { background: var(--surface-2); color: var(--text); }
/* Sur smartphone, 1 card pleine largeur par ligne (au lieu de 2 colonnes fixes).
   Placé après la règle de base pour l'emporter à spécificité égale. */
@media (max-width: 640px) {
    .vcard-grid { grid-template-columns: 1fr; }
}

/* Image d'illustration dans les formulaires collection / série. */
.cover-label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 6px; }
.coll-cover-field { margin-bottom: 12px; }
.coll-cover-preview {
    width: 100%; aspect-ratio: 16 / 6; border-radius: 10px; overflow: hidden;
    background: var(--surface-2); margin-bottom: 8px; display: none;
}
.coll-cover-preview.has-img { display: block; }
.coll-cover-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Formulaire série : nombre de tomes prévus saisi seulement si l'avancement est « Terminée ». */
#book-series-form-dialog.status-ongoing .series-status-hide { display: none !important; }

/* Actions de formulaire (Enregistrer / Supprimer). */
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.form-actions .btn.primary { flex: 1; }

/* Sélecteur « Déplacer vers une série » : séries regroupées par collection. */
.move-series-group {
    margin: 12px 0 2px; font-size: .74rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .04em; color: var(--muted);
}
.move-series-group:first-child { margin-top: 0; }
.move-series-current { opacity: .55; }
