:root {
    --primary: #5b3fd6;
    --primary-dark: #4527a0;
    --bg: #f7f6fb;
    --card-bg: #ffffff;
    --text: #24202e;
    --muted: #6b6478;
    --border: #e3e0ec;
    --danger: #d64545;
    --success: #256a38;

    --radius-card: 16px;
    --ombre: 0 1px 2px rgba(16, 40, 70, .04), 0 6px 18px rgba(16, 40, 70, .05);
    --ombre-levee: 0 4px 10px rgba(16, 40, 70, .08), 0 16px 36px rgba(16, 40, 70, .12);
}

* { box-sizing: border-box; }

/* Filet de sécurité : aucune image ne peut déborder de son conteneur.
   Son absence faisait s'afficher les couvertures à leur taille native,
   par-dessus le texte voisin, sur les pages sans règle dédiée. */
img { max-width: 100%; height: auto; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.container { max-width: 1000px; margin: 0 auto; padding: 1.5rem; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
h1 { margin: 0.2rem 0; }
h2 { margin-top: 1.5rem; }

.btn, .btn-secondary, .btn-danger {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 0.6rem 1.1rem;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.95rem;
    cursor: pointer;
}
a.btn, a.btn-secondary, a.btn-danger { display: inline-block; }
.btn:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--muted); }
.btn-secondary:hover { background: var(--text); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { filter: brightness(.92); }

/* wrap : sur un écran étroit, champ + tri + bouton ne tiennent pas sur
   une ligne, et le bouton sortait de l'écran. */
.search-bar { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.search-bar input { min-width: 0; }
.search-bar input { flex: 1; padding: 0.55rem 0.8rem; border: 1px solid var(--border); border-radius: 8px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }
.card {
    background: var(--card-bg); border-radius: 14px; overflow: hidden;
    text-decoration: none; color: var(--text);
    display: flex; flex-direction: column;
    box-shadow: var(--ombre); transition: box-shadow .15s, transform .15s;
}
a.card:hover { box-shadow: var(--ombre-levee); transform: translateY(-2px); }
.card img { width: 100%; aspect-ratio: 2/3; object-fit: cover; background: #eee; }
.no-cover { width: 100%; aspect-ratio: 2/3; background: #eee; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 0.8rem; text-align: center; padding: 0.5rem; }
.card-body { padding: 0.75rem 0.85rem 0.9rem; display: flex; flex-direction: column; gap: 0.2rem; }
.muted { color: var(--muted); font-size: 0.85rem; display: block; }
.badges { margin-top: 0.3rem; display: flex; gap: 0.3rem; flex-wrap: wrap; }
.badge { font-size: 0.7rem; background: var(--border); padding: 0.15rem 0.5rem; border-radius: 6px; display: inline-block; }
.badge-public { background: #d7f0dd; color: var(--success); }
/* Mention d'édition (« Nouv. éd. recolorisée », « Intégrale »…) : c'est
   ce qui distingue deux exemplaires du même album, donc ça doit se voir. */
.badge-edition { background: var(--ic-violet-bg); color: var(--ic-violet-fg); font-weight: 600; }
.fiche-meta .badge-edition { align-self: flex-start; margin-top: 0.35rem; }
.edition-trouvee { margin: 0 0 0.5rem; }

.empty, .hint { color: var(--muted); }
.error { color: var(--danger); }
.success { color: var(--success); }

.book-form { display: flex; flex-direction: column; gap: 0.35rem; max-width: 500px; }
.book-form label { font-weight: 600; margin-top: 0.5rem; font-size: 0.9rem; }
.book-form input[type=text], .book-form input[type=email], .book-form input[type=password], .book-form textarea {
    padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 1rem;
}
.checkbox-label { display: flex; align-items: center; gap: 0.5rem; font-weight: normal; }
.book-form button { margin-top: 1rem; align-self: flex-start; }

.detail-layout { display: flex; gap: 2rem; flex-wrap: wrap; align-items: flex-start; }
.cover-preview { width: 190px; flex-shrink: 0; }
.cover-preview img, .cover-preview .no-cover {
    width: 100%; aspect-ratio: 2/3; object-fit: cover;
    border-radius: 12px; box-shadow: var(--ombre);
}
.detail-corps { flex: 1; min-width: 280px; }
/* Bloc d'identité de l'album : série, auteurs, éditeur. */
.fiche-meta { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 1.25rem; }
.fiche-meta .muted { font-size: 0.92rem; }
.fiche-resume {
    background: var(--card-bg); border-radius: 12px; box-shadow: var(--ombre);
    padding: 0.9rem 1.1rem; margin-bottom: 1.5rem; line-height: 1.55;
}
.fiche-bloc {
    background: var(--card-bg); border-radius: 12px; box-shadow: var(--ombre);
    padding: 1.1rem 1.25rem;
}
.fiche-retrait { margin-top: 1.5rem; }
.fiche-bloc h2 {
    font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .05em; color: var(--muted); margin: 0 0 0.75rem;
}

.manual-isbn { display: flex; gap: 0.5rem; max-width: 400px; margin-bottom: 0.5rem; }
.manual-isbn input { flex: 1; padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: 8px; }

#reader { max-width: 400px; }

body.login-body { padding-left: 0; }
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--primary); }
.login-box { background: #fff; padding: 2rem; border-radius: 12px; width: 90%; max-width: 340px; text-align: center; }
.login-box form { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 1rem; text-align: left; }
.login-box input { padding: 0.6rem 0.8rem; border: 1px solid var(--border); border-radius: 8px; }
.login-box .btn { text-align: center; }

.collection-list { display: flex; flex-direction: column; gap: 0.5rem; }
.collection-row {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--card-bg); border-radius: 12px; box-shadow: var(--ombre);
    padding: 0.9rem 1.1rem; text-decoration: none; color: var(--text);
    transition: box-shadow .15s;
    gap: 1rem;
}
a.collection-row:hover { box-shadow: var(--ombre-levee); }

.reco-list { display: flex; flex-direction: column; gap: 1rem; }
.reco-card {
    display: flex; gap: 1.1rem; align-items: flex-start;
    background: var(--card-bg); border-radius: 14px; box-shadow: var(--ombre);
    padding: 1.1rem 1.25rem;
}
.reco-cover { width: 64px; flex-shrink: 0; }
.reco-cover img, .reco-cover .no-cover {
    width: 64px; aspect-ratio: 2/3; object-fit: cover;
    border-radius: 6px; display: block;
}
.reco-cover .no-cover { font-size: 0.62rem; padding: 0.2rem; }
.reco-card > div:last-child { min-width: 0; flex: 1; }
.reco-card p { margin: 0.5rem 0 0.7rem; line-height: 1.5; }
.reco-card strong { display: block; margin-bottom: 0.15rem; }

/* ===================================================================
   Tableau de bord
   =================================================================== */

:root {
    --ic-violet-bg: #f0edff;  --ic-violet-fg: #5b3fd6;
    --ic-bleu-bg:   #e7f0ff;  --ic-bleu-fg:   #2563eb;
    --ic-vert-bg:   #e6f9ee;  --ic-vert-fg:   #1e7e34;
    --ic-orange-bg: #fef3e2;  --ic-orange-fg: #b45309;
    --ic-rose-bg:   #fdeaf0;  --ic-rose-fg:   #be185d;
    --ic-gris-bg:   #f1f0f5;  --ic-gris-fg:   #6b6478;
}

[hidden] { display: none !important; }

.page-tableau-de-bord .container { max-width: 1180px; }

/* ── En-tête ───────────────────────────────────────────────────── */
.tb-entete {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.tb-entete h1 { margin: 0; font-size: 1.5rem; letter-spacing: -0.4px; }
.tb-actions { display: flex; align-items: center; gap: 0.5rem; }

.btn-ghost {
    background: transparent; border: 1px solid var(--border); border-radius: 8px;
    padding: 0.4rem 0.8rem; font-size: 0.85rem; color: var(--text);
    cursor: pointer; font-family: inherit;
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

.tb-badge-edition {
    font-size: 0.8rem; font-weight: 600; color: var(--primary-dark);
    background: var(--ic-violet-bg); border-radius: 999px; padding: 0.3rem 0.7rem;
}

/* ── Menu d'ajout de tuile ─────────────────────────────────────── */
.tb-ajout { position: relative; }
.tb-ajout-plus { font-weight: 700; }
.tb-menu {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 40;
    width: 320px; max-height: 60vh; overflow-y: auto;
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: 12px; box-shadow: var(--ombre-levee); padding: 0.75rem;
}
.tb-menu-titre {
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--muted); margin-bottom: 0.5rem;
}
.tb-menu-liste { display: flex; flex-direction: column; gap: 0.2rem; }
.tb-menu-option {
    display: flex; align-items: center; gap: 0.6rem; width: 100%;
    background: none; border: 0; border-radius: 8px; padding: 0.45rem 0.5rem;
    cursor: pointer; text-align: left; font-family: inherit;
    font-size: 0.88rem; color: var(--text);
}
.tb-menu-option:hover { background: var(--bg); }
.tb-menu-vide { font-size: 0.85rem; color: var(--muted); margin: 0.4rem 0; }
.tb-menu-pied { margin-top: 0.6rem; padding-top: 0.6rem; border-top: 1px solid var(--border); }
.tb-lien-discret {
    background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit;
    color: var(--muted); font-size: 0.78rem; text-decoration: underline;
}
.tb-lien-discret:hover { color: var(--danger); }

/* ── Grille ────────────────────────────────────────────────────── */
.tb-grille {
    --tb-unite: 150px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-auto-rows: var(--tb-unite);
    gap: 16px;
}

.tb-widget {
    position: relative; min-width: 0; z-index: 2;
    display: flex; flex-direction: column;
    border-radius: var(--radius-card);
    transition: opacity .15s;
}

/* ── Tuile chiffrée, format BDGest ─────────────────────────────── */
.tb-carte-stat {
    flex: 1; min-height: 0; overflow: hidden; box-sizing: border-box;
    border-radius: var(--radius-card); box-shadow: var(--ombre);
    display: flex; flex-direction: column; color: #fff;
}
.tb-stat-corps {
    position: relative; flex: 1; min-height: 0; overflow: hidden;
    padding: 14px 16px; display: flex; flex-direction: column;
    justify-content: center; align-items: flex-end; text-align: right;
}
/* Pictogramme en filigrane, décalé à gauche : repère la tuile sans
   entrer en concurrence avec le chiffre. */
.tb-stat-filigrane {
    position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
    width: 74px; height: 74px; opacity: .22; pointer-events: none;
}
.tb-stat-filigrane svg { width: 100%; height: 100%; }
.tb-valeur {
    font-size: 34px; font-weight: 700; letter-spacing: -1px; line-height: 1;
    position: relative;
}
.tb-libelle {
    font-size: 0.9rem; font-weight: 500; opacity: .92; position: relative;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.tb-stat-pied {
    display: flex; align-items: center; justify-content: space-between;
    padding: 7px 14px; background: rgba(0, 0, 0, .16);
    color: #fff; text-decoration: none;
    font-size: 0.66rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; flex-shrink: 0;
}
.tb-stat-pied:hover { background: rgba(0, 0, 0, .28); }

.tb-teinte-vert   { background: #12a594; }
.tb-teinte-orange { background: #e08c34; }
.tb-teinte-bleu   { background: #3b82f6; }
.tb-teinte-rouge  { background: #e05252; }
.tb-teinte-violet { background: #7c5cd6; }
.tb-teinte-rose   { background: #d1477e; }
.tb-teinte-gris   { background: #6b6478; }

/* ── Panneau (carte + liste) ───────────────────────────────────── */
.tb-carte {
    flex: 1; min-height: 0; overflow: hidden;
    background: var(--card-bg); border-radius: var(--radius-card);
    box-shadow: var(--ombre);
    display: flex; flex-direction: column;
}
.tb-carte-tete {
    display: flex; align-items: center; gap: 0.55rem;
    padding: 13px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.tb-carte-titre { font-size: 0.9rem; font-weight: 600; letter-spacing: -0.2px; }
.tb-carte-corps { flex: 1; min-height: 0; overflow-y: auto; padding: 0.35rem 16px 0.6rem; }

.tb-ligne {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.5rem 0; border-bottom: 1px solid var(--border);
    text-decoration: none; color: var(--text);
}
.tb-ligne:last-child { border-bottom: 0; }
a.tb-ligne:hover .tb-ligne-texte strong { color: var(--primary); }
.tb-ligne-couv { flex: 0 0 34px; }
.tb-ligne-couv img {
    width: 34px; height: 46px; object-fit: cover; display: block;
    border-radius: 4px; box-shadow: 0 1px 3px rgba(16, 40, 70, .18);
}
.tb-ligne-couv .no-cover {
    width: 34px; height: 46px; border-radius: 4px; background: var(--bg);
    border: 1px dashed var(--border); font-size: 0; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}
.tb-ligne-couv .no-cover::after {
    content: "BD"; font-size: 9px; font-weight: 600; letter-spacing: .04em;
    color: var(--border);
}
.tb-ligne-texte { display: flex; flex-direction: column; min-width: 0; gap: 0.12rem; }
.tb-ligne-texte strong {
    font-size: 0.88rem; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tb-ligne-texte .muted { font-size: 0.78rem; }
.tb-carte-corps .empty {
    font-size: 0.85rem; color: var(--muted); margin: 0.6rem 0; padding: 0;
    background: none; border: 0;
}

/* ── Grille de couvertures (derniers ajouts) ───────────────────── */
.tb-couvertures {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
    gap: 8px; padding-top: 0.2rem;
}
.tb-couv img {
    width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block;
    border-radius: 4px; box-shadow: 0 1px 4px rgba(16, 40, 70, .22);
    transition: transform .12s;
}
.tb-couv:hover img { transform: translateY(-2px) scale(1.03); }
.tb-couv .no-cover {
    width: 100%; aspect-ratio: 2/3; border-radius: 4px; font-size: 0;
    background: var(--bg); border: 1px dashed var(--border);
    display: flex; align-items: center; justify-content: center;
}
.tb-couv .no-cover::after {
    content: "BD"; font-size: 10px; font-weight: 600; letter-spacing: .04em;
    color: var(--border);
}

/* ── Ajout rapide ──────────────────────────────────────────────── */
.tb-ajout-form { display: flex; flex-direction: column; gap: 0.5rem; padding-top: 0.3rem; }
.tb-ajout-form select, .tb-ajout-form input {
    width: 100%; padding: 0.5rem 0.65rem; font-family: inherit; font-size: 0.88rem;
    border: 1px solid var(--border); border-radius: 8px; background: var(--card-bg);
}
.tb-ajout-ligne { display: flex; gap: 0.4rem; }
.tb-ajout-ligne input { flex: 1; min-width: 0; }
.tb-ajout-ligne button {
    padding: 0 0.9rem; border: 0; border-radius: 8px; cursor: pointer;
    background: var(--primary); color: #fff; font-weight: 600; font-family: inherit;
}
.tb-ajout-form .hint { font-size: 0.76rem; margin: 0; }

/* ── Mode modification ─────────────────────────────────────────── */
.tb-fantome {
    position: relative; align-self: stretch; z-index: 1;
    border: 2px dashed transparent; border-radius: var(--radius-card);
    box-sizing: border-box; pointer-events: none;
    transition: border-color .1s, background .1s;
}
.tb-edition .tb-fantome { border-color: var(--border); }
.tb-edition .tb-fantome.tb-fantome-occupe { border-color: transparent; }
.tb-glisse-actif .tb-widget { pointer-events: none !important; }
.tb-glisse-actif .tb-fantome { z-index: 20; border-color: rgba(91, 63, 214, .22); }
.tb-fantome.tb-fantome-cible {
    border-color: var(--primary) !important;
    background: var(--ic-violet-bg) !important;
}

.tb-retirer, .tb-poignee-droite, .tb-poignee-bas { display: none; }

.tb-edition .tb-widget { outline: 2px dashed var(--border); outline-offset: 4px; cursor: move; }
.tb-edition .tb-widget:hover { outline-color: var(--primary); }
.tb-edition .tb-widget * { user-select: none; -webkit-user-select: none; }
.tb-edition .tb-carte, .tb-edition .tb-carte-stat { pointer-events: none; }
.tb-widget.tb-en-deplacement { opacity: .35; }

.tb-edition .tb-retirer {
    display: flex; align-items: center; justify-content: center;
    position: absolute; top: 6px; right: 6px; z-index: 11;
    width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%;
    background: var(--danger); color: #fff; font-size: 15px; line-height: 1;
    cursor: pointer; box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
    transition: transform .1s;
}
.tb-edition .tb-retirer:hover { transform: scale(1.12); }

.tb-edition .tb-poignee-droite {
    display: flex; align-items: center; justify-content: center;
    position: absolute; bottom: 26px; right: 4px; width: 12px; height: 32px;
    cursor: ew-resize; z-index: 10; touch-action: none;
}
.tb-edition .tb-poignee-droite::before {
    content: ''; width: 3px; height: 20px; border-radius: 2px; background: var(--muted);
}
.tb-edition .tb-poignee-droite:hover::before { background: var(--primary); }

.tb-edition .tb-poignee-bas {
    display: flex; align-items: center; justify-content: center;
    position: absolute; bottom: 0; left: 0; right: 0; height: 16px;
    cursor: ns-resize; z-index: 10; touch-action: none;
    border-radius: 0 0 var(--radius-card) var(--radius-card);
}
.tb-edition .tb-poignee-bas::before {
    content: ''; width: 40px; height: 4px; border-radius: 2px; background: var(--muted);
}
.tb-edition .tb-poignee-bas:hover { background: rgba(0, 0, 0, .04); }
.tb-edition .tb-poignee-bas:hover::before { background: var(--primary); }

/* -------------------------------------------------------------------
   Version portable : tableau de bord simplifié.
   Une colonne, hauteur laissée au contenu, pas de personnalisation —
   les positions de la grille n'ont plus de sens sur un écran étroit.
   ------------------------------------------------------------------- */
@media (max-width: 768px) {
    .tb-grille { display: flex; flex-direction: column; gap: 0.75rem; }
    .tb-grille .tb-widget { grid-area: auto !important; }
    .tb-fantome { display: none; }
    .tb-actions { display: none; }

    .tb-carte-stat {
        flex-direction: row; align-items: center; gap: 0.9rem;
        padding: 14px 16px;
    }
    .tb-stat-haut { margin-bottom: 0; }
    .tb-carte-stat .tb-valeur { font-size: 26px; margin-left: auto; order: 3; }
    .tb-carte-stat .tb-libelle { -webkit-line-clamp: 1; font-size: 0.85rem; }
    .tb-carte-corps { max-height: 340px; }
}

/* ===================================================================
   Barre latérale
   =================================================================== */

:root {
    --barre-largeur: 232px;
    --barre-fond: #1e1b26;
    --barre-fond-clair: #2a2634;
    --barre-texte: #c9c4d4;
    --barre-texte-vif: #ffffff;
    --barre-accent: #8b6ff0;
}

body { padding-left: var(--barre-largeur); }

.barre {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
    width: var(--barre-largeur);
    background: var(--barre-fond); color: var(--barre-texte);
    display: flex; flex-direction: column;
    overflow-y: auto;
}

.barre-marque {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 1.1rem 1rem; text-decoration: none;
    color: var(--barre-texte-vif); font-weight: 700; font-size: 1.05rem;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.barre-marque-ic { font-size: 1.2rem; }

.barre-nav { flex: 1; padding: 0.6rem 0; }
.barre-pied { padding: 0.5rem 0 0.9rem; border-top: 1px solid rgba(255, 255, 255, .07); }

.barre-lien {
    display: flex; align-items: center; gap: 0.55rem;
    padding: 0.5rem 1rem; text-decoration: none;
    color: var(--barre-texte); font-size: 0.88rem;
    border-left: 3px solid transparent;
}
.barre-lien:hover { background: var(--barre-fond-clair); color: var(--barre-texte-vif); }
.barre-lien.actif {
    background: var(--barre-fond-clair); color: var(--barre-texte-vif);
    border-left-color: var(--barre-accent); font-weight: 600;
}
.barre-ic { width: 18px; text-align: center; opacity: .8; flex-shrink: 0; }

/* Sections repliables : <details> natif, donc sans JavaScript. */
.barre-section { border-top: 1px solid rgba(255, 255, 255, .05); margin-top: 0.4rem; }
.barre-section > summary {
    display: flex; align-items: center; gap: 0.55rem;
    padding: 0.65rem 1rem; cursor: pointer; list-style: none;
    color: var(--barre-texte-vif); font-size: 0.72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em;
}
.barre-section > summary::-webkit-details-marker { display: none; }
.barre-section > summary:hover { background: var(--barre-fond-clair); }
.barre-section-nom { flex: 1; }
/* Chevron : tourne quand la section s'ouvre. */
.barre-section > summary::after {
    content: "›"; font-size: 1.1rem; line-height: 1; opacity: .6;
    transition: transform .15s;
}
.barre-section[open] > summary::after { transform: rotate(90deg); }
.barre-section .barre-lien { padding-left: 2.1rem; }

.barre-compte, .barre-pastille {
    background: rgba(255, 255, 255, .1); color: var(--barre-texte-vif);
    border-radius: 999px; padding: 0.1rem 0.5rem;
    font-size: 0.7rem; font-weight: 600; letter-spacing: 0;
}
.barre-pastille { margin-left: auto; }
.barre-lien.actif .barre-pastille { background: var(--barre-accent); }

/* Bouton d'ouverture et voile : grands écrans = inutiles. */
.barre-bouton, .barre-voile { display: none; }

/* Compteur à côté d'un titre de page. */
.compte-titre {
    font-size: 0.85rem; font-weight: 600; color: var(--muted);
    background: var(--card-bg); border-radius: 999px;
    padding: 0.15rem 0.6rem; vertical-align: middle; margin-left: 0.4rem;
    box-shadow: var(--ombre);
}
.champ-tri {
    padding: 0.55rem 0.7rem; border: 1px solid var(--border);
    border-radius: 8px; font-family: inherit; background: var(--card-bg);
}
.grid-series { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

/* -------------------------------------------------------------------
   Version portable : la barre sort du flux et s'ouvre par-dessus.
   ------------------------------------------------------------------- */
@media (max-width: 900px) {
    body { padding-left: 0; }
    .barre {
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: 0 0 40px rgba(0, 0, 0, .4);
    }
    body.barre-ouverte .barre { transform: translateX(0); }

    .barre-bouton {
        display: flex; align-items: center; justify-content: center;
        position: fixed; top: 10px; left: 10px; z-index: 60;
        width: 40px; height: 40px; border: 0; border-radius: 10px;
        background: var(--barre-fond); color: #fff; font-size: 1.1rem;
        cursor: pointer; box-shadow: var(--ombre);
    }
    .barre-voile {
        display: block; position: fixed; inset: 0; z-index: 45;
        background: rgba(0, 0, 0, .45);
    }
    /* Laisser la place au bouton flottant. */
    .container { padding-top: 3.75rem; }
}

/* ── Recherche globale dans la barre ───────────────────────────── */
.barre-recherche { padding: 0.7rem 0.85rem 0.2rem; }
.barre-recherche input {
    width: 100%; padding: 0.45rem 0.7rem;
    background: rgba(255, 255, 255, .08); color: var(--barre-texte-vif);
    border: 1px solid rgba(255, 255, 255, .1); border-radius: 8px;
    font-family: inherit; font-size: 0.82rem;
}
.barre-recherche input::placeholder { color: rgba(255, 255, 255, .42); }
.barre-recherche input:focus {
    outline: none; border-color: var(--barre-accent);
    background: rgba(255, 255, 255, .13);
}

/* ── Titres de section dans une page ───────────────────────────── */
.section-titre {
    font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--muted);
    margin: 1.8rem 0 0.7rem;
}

/* ── Liste d'envies ────────────────────────────────────────────── */
.envie-liste { display: flex; flex-direction: column; gap: 0.9rem; }
.envie-carte {
    display: flex; gap: 1.1rem; align-items: flex-start;
    background: var(--card-bg); border-radius: 14px; box-shadow: var(--ombre);
    padding: 1rem 1.2rem; flex-wrap: wrap;
}
.envie-couv { width: 60px; flex-shrink: 0; }
.envie-couv img, .envie-couv .no-cover {
    width: 60px; aspect-ratio: 2/3; object-fit: cover; border-radius: 6px; display: block;
}
.envie-couv .no-cover { font-size: 0.6rem; padding: 0.2rem; }
.envie-corps { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 0.15rem; }
.envie-note { margin: 0.4rem 0 0; font-size: 0.88rem; }
.envie-actions { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-end; }
.envie-acquis { display: flex; gap: 0.4rem; }
.envie-acquis select {
    padding: 0.4rem 0.5rem; border: 1px solid var(--border);
    border-radius: 8px; font-family: inherit; font-size: 0.85rem;
}

/* ── Import : jauge et tableaux ────────────────────────────────── */
.jauge {
    height: 10px; border-radius: 999px; background: var(--bg);
    overflow: hidden; margin: 0.6rem 0;
}
.jauge-remplie { height: 100%; background: var(--primary); transition: width .4s; }
.tableau-defile { overflow-x: auto; }
.tableau-corres { border-collapse: collapse; width: 100%; font-size: 0.87rem; }
.tableau-corres th, .tableau-corres td {
    text-align: left; padding: 0.45rem 0.7rem; border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.tableau-corres th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tableau-corres code { font-size: 0.82rem; background: var(--bg); padding: 0.1rem 0.35rem; border-radius: 4px; }

/* ── Recherche d'un album par titre ────────────────────────────── */
.recherche-titre { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.recherche-titre input { flex: 1; min-width: 180px; padding: 0.55rem 0.8rem; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; }
.recherche-titre select { padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; background: var(--card-bg); }
.recherche-titre button { padding: 0 1.1rem; border: 0; border-radius: 8px; background: var(--primary); color: #fff; cursor: pointer; font-family: inherit; }

.resultat-titre {
    display: flex; gap: 1.1rem; align-items: flex-start; flex-wrap: wrap;
    background: var(--card-bg); border-radius: 14px; box-shadow: var(--ombre);
    padding: 1rem 1.2rem; margin-bottom: 0.8rem;
}
.resultat-couv { width: 58px; flex-shrink: 0; }
.resultat-couv img, .resultat-couv .no-cover {
    width: 58px; aspect-ratio: 2/3; object-fit: cover; border-radius: 6px; display: block;
    background: var(--bg); border: 0;
}
.resultat-couv .no-cover { border: 1px dashed var(--border); }
.resultat-corps { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 0.12rem; }
.resultat-action { display: flex; align-items: center; }

/* Séparateur « ou » entre les deux modes d'ajout du tableau de bord. */
.tb-ajout-separateur {
    display: flex; align-items: center; gap: 0.6rem;
    margin: 0.7rem 0 0.2rem; color: var(--muted); font-size: 0.75rem;
}
.tb-ajout-separateur::before, .tb-ajout-separateur::after {
    content: ""; flex: 1; height: 1px; background: var(--border);
}

.filtres-albums { display: flex; flex-direction: column; gap: 0.2rem; margin: -0.6rem 0 1.2rem; font-size: 0.85rem; }
.filtres-albums .muted { font-size: 0.8rem; }

/* Dépôt d'une couverture depuis la liste filtrée : on enchaîne les
   albums sans jamais ouvrir leur fiche. */
.carte-avec-depot { display: flex; flex-direction: column; }
.carte-avec-depot .card { flex: 1; }
.depot-couv {
    background: var(--card-bg); border-radius: 0 0 14px 14px;
    margin-top: -14px; padding: 0.6rem 0.85rem 0.7rem;
    box-shadow: var(--ombre);
}
.depot-couv input[type=file] { width: 100%; font-size: 0.74rem; }

/* Invitation à photographier, juste après un scan sans couverture. */
.invite-photo {
    background: var(--ic-violet-bg); border: 1px solid var(--primary);
    border-radius: 14px; padding: 1rem 1.2rem; margin-bottom: 1.5rem;
}
.invite-photo strong { display: block; margin-bottom: 0.3rem; }
.invite-photo p { margin: 0.3rem 0 0.7rem; font-size: 0.9rem; }
.invite-photo input[type=file] { font-size: 0.85rem; }

/* ── Recadrage d'une couverture ────────────────────────────────── */
.rec-voile {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(20, 16, 30, .82);
    display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.rec-boite {
    background: var(--card-bg); border-radius: 16px; box-shadow: var(--ombre-levee);
    padding: 1rem 1.1rem 1.1rem; width: 100%; max-width: 560px;
    display: flex; flex-direction: column; gap: 0.8rem;
}
.rec-aide { margin: 0; font-size: 0.9rem; color: var(--muted); }
/* Hauteur FIXE et non « max-height » : Cropper remplace l'image par son
   propre conteneur en position absolue, et un parent sans hauteur propre
   s'effondrerait à zéro — la zone de recadrage resterait vide. */
.rec-zone { height: 55vh; min-height: 260px; }
.rec-zone img { max-width: 100%; display: block; }
.rec-actions { display: flex; gap: 0.5rem; justify-content: flex-end; flex-wrap: wrap; }

/* ── Actions rapides sur mobile ────────────────────────────────── */
.actions-mobile { display: none; }

@media (max-width: 768px) {
    .actions-mobile {
        display: flex; align-items: center; gap: 0.6rem;
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
        background: var(--card-bg); border-top: 1px solid var(--border);
        padding: 0.6rem 0.8rem;
        /* Encoche des téléphones récents. */
        padding-bottom: calc(0.6rem + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -2px 16px rgba(16, 40, 70, .1);
    }
    .actions-recherche { flex: 1; min-width: 0; }
    .actions-recherche input {
        width: 100%; padding: 0.6rem 0.8rem; font-family: inherit; font-size: 0.95rem;
        border: 1px solid var(--border); border-radius: 999px; background: var(--bg);
    }
    .actions-scan {
        display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0;
        background: var(--primary); color: #fff; text-decoration: none;
        border-radius: 999px; padding: 0.6rem 1.1rem;
        font-size: 0.92rem; font-weight: 600;
    }
    .actions-scan-ic { display: flex; }
    .actions-scan-ic svg { width: 19px; height: 19px; }

    /* La barre du bas ne doit pas masquer la fin du contenu. */
    .container { padding-bottom: 5.5rem; }

    /* Recherche et tri passent chacun sur leur ligne plutôt que de
       déborder de l'écran. */
    .search-bar input[type="text"] { flex: 1 1 100%; }
    .search-bar select, .search-bar button { flex: 1 1 auto; }
    .recherche-titre input { flex: 1 1 100%; }
}

/* ── Page de scan ──────────────────────────────────────────────── */
.scan-entete { margin-bottom: 1rem; }
.scan-retour { font-size: 0.9rem; }
.scan-entete h1 { margin: 0.3rem 0 0; }

.scan-cadre {
    position: relative; overflow: hidden;
    border-radius: var(--radius-card); background: #14111c;
    aspect-ratio: 4 / 3; max-width: 560px;
}
.scan-lecteur { width: 100%; height: 100%; }
/* La bibliothèque insère sa propre vidéo : on la force à remplir le
   cadre, sinon elle s'affiche à sa taille naturelle avec des marges. */
.scan-lecteur video, .scan-lecteur canvas {
    width: 100% !important; height: 100% !important; object-fit: cover; display: block;
}
/* Et on masque l'habillage résiduel de la bibliothèque. */
.scan-lecteur img[alt="Info icon"], .scan-lecteur a { display: none !important; }

/* Viseur : un rectangle large et bas, à la forme d'un code-barres. */
.scan-viseur {
    position: absolute; left: 8%; right: 8%; top: 50%;
    transform: translateY(-50%); height: 34%;
    border: 2px solid rgba(255, 255, 255, .9); border-radius: 10px;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35);
    pointer-events: none;
}
.scan-etat {
    position: absolute; left: 0; right: 0; bottom: 0; margin: 0;
    padding: 0.55rem 0.8rem; text-align: center;
    background: rgba(0, 0, 0, .55); color: #fff; font-size: 0.85rem;
}
.scan-erreur {
    background: #fdeaea; border-left: 4px solid var(--danger);
    padding: 0.8rem 1rem; border-radius: 8px; font-size: 0.9rem;
}

.scan-manuel { margin-top: 1.2rem; max-width: 560px; }
.scan-manuel form { display: flex; gap: 0.5rem; }
.scan-manuel input {
    flex: 1; min-width: 0; padding: 0.6rem 0.8rem; font-family: inherit; font-size: 1rem;
    border: 1px solid var(--border); border-radius: 8px;
}
.scan-manuel button {
    padding: 0 1.2rem; border: 0; border-radius: 8px; cursor: pointer;
    background: var(--primary); color: #fff; font-weight: 600; font-family: inherit;
}
.scan-manuel .hint { margin-top: 0.6rem; }

@media (max-width: 768px) {
    /* Plein cadre : on tient le téléphone à la verticale devant l'album. */
    .scan-cadre { aspect-ratio: 3 / 4; max-width: none; }
}

/* -------------------------------------------------------------------
   Épuration mobile.
   Sur un écran étroit, une carte affichait le titre, la série, le tome,
   la mention complète des auteurs avec leurs rôles, l'année et les
   badges — six lignes de texte pour une vignette de 150 px. Le détail
   appartient à la fiche de l'album ; la liste doit se parcourir à l'œil.
   ------------------------------------------------------------------- */
@media (max-width: 768px) {
    .page-header { margin-bottom: 0.8rem; }
    .page-header h1 { font-size: 1.35rem; }
    .compte-titre { font-size: 0.75rem; padding: 0.1rem 0.45rem; }

    .grid { gap: 0.7rem; }
    .card-body { padding: 0.55rem 0.6rem 0.65rem; gap: 0.1rem; }
    .card-body strong {
        font-size: 0.85rem; line-height: 1.25;
        display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
        overflow: hidden;
    }
    .card-body .muted { font-size: 0.76rem; }
    /* On garde la première ligne secondaire (la série et le tome) et on
       masque les suivantes : auteurs et année. */
    .card-body .muted ~ .muted { display: none; }
    .badges { margin-top: 0.25rem; }
    .badge { font-size: 0.64rem; padding: 0.1rem 0.4rem; }

    /* Le filtre est utile mais n'a pas à s'annoncer comme un titre. */
    .filtres-albums { font-size: 0.8rem; margin: -0.3rem 0 0.9rem; }

    /* Les panneaux du tableau de bord respirent moins. */
    .tb-carte-tete { padding: 10px 13px; }
    .tb-carte-corps { padding: 0.3rem 13px 0.5rem; }
    .tb-ligne-texte .muted { display: none; }
    .tb-ligne { padding: 0.4rem 0; }
}
