/* ============================================================
   MA BIBLIOTHÈQUE — Thème "bibliothèque chaude"
   Palette : fond #2a2823, cartes #353129/#34302a/#2e2b26
   Accent  : terracotta #c98a5e
   Titres  : Spectral (serif)   Corps : Hanken Grotesk
   ============================================================ */

:root {
    --accent: #c98a5e;
    --accent-ink: #1a1510;
    --fond: #2a2823;
    --carte: #353129;
    --carte-2: #34302a;
    --champ: #2e2b26;
    --bordure: #45413a;
    --bordure-claire: #544f44;
    --texte: #ece6da;
    --texte-doux: #a39d8f;
    --texte-faible: #8f897c;

    --st-encours: #d3945f;
    --st-alire: #a39d8f;
    --st-lu: #82ad86;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: var(--fond);
    color: var(--texte);
    font-family: 'Hanken Grotesk', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

h1, h2, h3 { font-family: 'Spectral', Georgia, serif; }

/* ============ EN-TÊTE ============ */

#entete {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(42, 40, 35, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--bordure);
}

.entete-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 16px 28px;
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.entete-titre { flex: 1; min-width: 160px; }

.entete-titre h1 {
    font-weight: 600;
    font-size: 25px;
    letter-spacing: 0.01em;
    color: var(--texte);
}

#sous-titre {
    font-size: 13px;
    color: var(--texte-faible);
    margin-left: 12px;
}

.entete-recherche {
    position: relative;
    flex: 0 1 260px;
    min-width: 190px;
}

.recherche-loupe {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: #6e685c;
    font-size: 16px;
    pointer-events: none;
}

#recherche-biblio {
    width: 100%;
    padding: 10px 14px 10px 36px;
    border: 1px solid var(--bordure);
    border-radius: 10px;
    background: var(--carte);
    color: var(--texte);
    font-size: 14px;
    font-family: inherit;
    outline: none;
}

#recherche-biblio::placeholder { color: #6e685c; }
#recherche-biblio:focus { border-color: var(--accent); }

.entete-lecteurs {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 12px 6px 14px;
    border: 1px solid var(--bordure);
    border-radius: 999px;
    background: var(--carte);
}

.entete-lecteurs .avatars { display: flex; }
.entete-lecteurs .avatars .avatar { margin-left: -6px; border: 2px solid var(--carte); }
.entete-lecteurs .avatars .avatar:first-child { margin-left: 0; }
.entete-lecteurs .label { font-size: 13px; color: #b6afa1; font-weight: 500; }

.avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

.btn-accent {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: filter .15s;
}
.btn-accent:hover { filter: brightness(1.07); }

/* ============ CONTENU ============ */

#contenu {
    max-width: 1180px;
    margin: 0 auto;
    padding: 30px 28px 90px;
}

/* --- Cartes statistiques --- */

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 26px;
}

.stat {
    text-align: left;
    padding: 17px 18px;
    border: 1px solid var(--bordure);
    border-radius: 14px;
    background: var(--carte);
    cursor: pointer;
    font-family: inherit;
    transition: all .15s;
}
.stat:hover { border-color: var(--bordure-claire); }
.stat.actif { box-shadow: 0 0 0 1px var(--accent); border-color: var(--accent); }

.stat-valeur {
    font-family: 'Spectral', serif;
    font-size: 30px;
    font-weight: 600;
    line-height: 1;
    color: var(--texte);
}
.stat-bas { display: flex; align-items: center; gap: 7px; margin-top: 9px; }
.stat-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.stat-label { font-size: 13px; color: var(--texte-doux); }

/* --- Filtres + tri --- */

.barre-filtres {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 30px;
}
.pills { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }

.pill {
    padding: 8px 15px;
    border: 1px solid var(--bordure-claire);
    border-radius: 999px;
    background: var(--champ);
    color: var(--texte);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    transition: all .15s;
}
.pill .compte { font-size: 11px; color: var(--texte-doux); }
.pill:hover { border-color: var(--accent); }
.pill.actif {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 700;
}
.pill.actif .compte { color: rgba(26, 21, 16, 0.55); font-weight: 700; }

.tri-wrap { position: relative; }
#tri {
    padding: 9px 32px 9px 14px;
    border: 1px solid var(--bordure);
    border-radius: 999px;
    background: var(--carte);
    color: #b6afa1;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}
.tri-fleche {
    position: absolute;
    right: 13px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: var(--texte-doux);
    pointer-events: none;
}

/* --- Sections --- */

.section { margin-bottom: 42px; }
.section-titre { display: flex; align-items: baseline; gap: 12px; margin-bottom: 18px; }
.section-titre h2 { font-size: 20px; font-weight: 600; letter-spacing: 0.01em; color: var(--texte); }
.section-titre .compte { font-size: 13px; color: var(--texte-faible); }

/* --- Cartes "En lecture" (horizontales) --- */

.grille-encours {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    gap: 16px;
}

.carte-h {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--carte);
    border: 1px solid var(--bordure);
    border-radius: 14px;
    cursor: pointer;
    transition: all .15s;
}
.carte-h:hover { border-color: var(--bordure-claire); box-shadow: 0 10px 28px rgba(0,0,0,0.4); }

.carte-h .cover {
    flex: none;
    width: 58px;
    height: 82px;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
}
.carte-h-infos { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.carte-h-eyebrow {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--st-encours);
    font-weight: 700;
    margin-bottom: 3px;
}
.carte-h-infos h3 { font-size: 18px; font-weight: 600; margin: 0; line-height: 1.2; color: var(--texte); }
.carte-h-meta { font-size: 13px; color: var(--texte-doux); margin-top: 2px; }
.carte-h-spacer { flex: 1; min-height: 8px; }
.carte-h-bas { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.carte-h-bas .reader-label { font-size: 12px; color: var(--texte-faible); }
.carte-h-bas .reprendre { font-size: 13px; font-weight: 600; color: var(--st-encours); margin-left: auto; }

/* --- Couvertures (texte généré) --- */

.cover-texte {
    position: absolute;
    inset: 0;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.cover-genre {
    font-size: 8px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.7;
    font-weight: 700;
}
.cover-titre { font-family: 'Spectral', serif; font-size: 12px; font-weight: 600; line-height: 1.2; }

/* --- Grille de couvertures (À lire / Lu) --- */

.grille-cover {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
    gap: 16px;
}
.grille-cover.compact { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }

.cover-item { cursor: pointer; }
.cover-grande {
    aspect-ratio: 3/4;
    border-radius: 9px;
    position: relative;
    overflow: hidden;
    transition: transform .15s, box-shadow .15s;
}
.cover-item:hover .cover-grande { transform: translateY(-3px); box-shadow: 0 16px 32px rgba(0,0,0,0.55); }

.cover-grande .cover-texte { padding: 11px 11px 11px 13px; }
.cover-grande .cover-bande {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
}
.cover-grande .cover-titre { font-size: 13px; }
.cover-grande .cover-auteur { font-size: 10px; opacity: 0.82; margin-top: 5px; }

.cover-bas { margin-top: 8px; display: flex; align-items: center; gap: 6px; }
.cover-bas .st-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.cover-bas .st-label { font-size: 11px; color: var(--texte-doux); }
.cover-bas .chips { display: flex; gap: 3px; margin-left: auto; }
.cover-bas .avatar { width: 18px; height: 18px; font-size: 9px; }

/* --- État vide --- */

.vide {
    text-align: center;
    padding: 70px 20px;
    color: var(--texte-faible);
    font-size: 15px;
}
.vide-sous { font-size: 13px; margin-top: 6px; color: #6e685c; }

/* ============ TIROIR DE DÉTAIL ============ */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 7, 6, 0.6);
    z-index: 40;
    animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.tiroir {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(440px, 100%);
    background: var(--carte-2);
    z-index: 41;
    box-shadow: -22px 0 55px rgba(0,0,0,0.5);
    overflow-y: auto;
    border-left: 1px solid var(--bordure);
    animation: drawerIn .28s cubic-bezier(.2,.7,.2,1);
}
@keyframes drawerIn { from { transform: translateX(40px); opacity: 0.6; } to { transform: translateX(0); opacity: 1; } }

.tiroir-haut { position: relative; padding: 26px 26px 0; }
.tiroir-fermer {
    position: absolute;
    top: 18px; right: 18px;
    width: 32px; height: 32px;
    border: 1px solid var(--bordure);
    border-radius: 8px;
    background: var(--champ);
    color: var(--texte-doux);
    font-size: 16px;
    cursor: pointer;
    font-family: inherit;
}
.tiroir-fermer:hover { color: var(--texte); }

.tiroir-cover {
    width: 116px;
    height: 164px;
    border-radius: 9px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 12px 30px rgba(0,0,0,0.45);
}

.tiroir-cover-btn {
    display: block;
    position: relative;
    width: 116px;
    height: 164px;
    margin-bottom: 18px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 9px;
}
.tiroir-cover-btn .tiroir-cover { margin-bottom: 0; }

.tiroir-cover-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 7, 6, 0.55);
    color: #f3efe6;
    font-size: 12.5px;
    font-weight: 700;
    border-radius: 9px;
    opacity: 0;
    transition: opacity .15s;
}
.tiroir-cover-btn:hover .tiroir-cover-overlay,
.tiroir-cover-btn:focus-visible .tiroir-cover-overlay { opacity: 1; }

.tiroir h2 { font-size: 23px; font-weight: 600; line-height: 1.2; color: var(--texte); }
.tiroir-meta { font-size: 14px; color: var(--texte-doux); margin-top: 6px; }

.tiroir-corps { padding: 22px 26px 30px; }
.champ-bloc { margin-bottom: 22px; }
.champ-label {
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--texte-faible);
    font-weight: 700;
    display: block;
    margin-bottom: 10px;
}

.select-std, .textarea-std {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--bordure);
    border-radius: 10px;
    background: var(--champ);
    color: var(--texte);
    font-size: 14px;
    font-family: inherit;
    outline: none;
}
.select-std { cursor: pointer; -webkit-appearance: none; appearance: none; }
.select-std:focus, .textarea-std:focus { border-color: var(--accent); }
.textarea-std { min-height: 88px; line-height: 1.5; resize: vertical; }

.resume-lecture {
    font-size: 14px;
    line-height: 1.6;
    color: #cfc8ba;
    white-space: pre-wrap;
}
.resume-traduit { font-size: 11px; color: #6e685c; font-style: italic; margin-top: 8px; }

/* toggles lecteurs dans le tiroir */
.lecteurs-toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.lecteur-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 13px 7px 8px;
    border: 1px solid var(--bordure);
    border-radius: 999px;
    background: var(--champ);
    color: var(--texte-doux);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}
.lecteur-toggle.actif { border-color: var(--accent); color: var(--texte); }
.lecteur-toggle .avatar { width: 22px; height: 22px; font-size: 10px; }

.btn-supprimer-livre {
    margin-top: 6px;
    width: 100%;
    padding: 12px;
    border: 1px solid #4a352e;
    border-radius: 10px;
    background: #2c211c;
    color: #d98e6f;
    font-size: 13.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}
.btn-supprimer-livre:hover { background: #34261f; }

/* ============ MODALE D'AJOUT ============ */

.modale-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 7, 6, 0.62);
    z-index: 50;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 44px 20px;
    overflow-y: auto;
    animation: fadeIn .2s ease;
}
.modale {
    width: min(560px, 100%);
    background: var(--carte-2);
    border: 1px solid var(--bordure);
    border-radius: 18px;
    box-shadow: 0 30px 70px rgba(0,0,0,0.5);
    animation: modaleIn .25s cubic-bezier(.2,.7,.2,1);
}
@keyframes modaleIn { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modale-haut {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 24px;
    border-bottom: 1px solid var(--bordure);
}
.modale-haut h2 { font-size: 21px; font-weight: 600; color: var(--texte); }
.modale-fermer {
    width: 32px; height: 32px;
    border: 1px solid var(--bordure);
    border-radius: 8px;
    background: var(--champ);
    color: var(--texte-doux);
    font-size: 16px;
    cursor: pointer;
    font-family: inherit;
}
.modale-corps { padding: 22px 24px 26px; }

.recherche-gb { position: relative; margin-bottom: 8px; }
.recherche-gb input {
    width: 100%;
    padding: 11px 90px 11px 14px;
    border: 1px solid var(--bordure);
    border-radius: 9px;
    background: var(--champ);
    color: var(--texte);
    font-size: 14px;
    font-family: inherit;
    outline: none;
}
.recherche-gb input:focus { border-color: var(--accent); }
.recherche-gb button {
    position: absolute;
    right: 6px; top: 50%;
    transform: translateY(-50%);
    padding: 7px 14px;
    border: none;
    border-radius: 7px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
}

.gb-resultats { margin: 6px 0 18px; display: flex; flex-direction: column; gap: 6px; max-height: 230px; overflow-y: auto; }
.gb-info { font-size: 13px; color: var(--texte-faible); font-style: italic; padding: 6px 0; }
.gb-item {
    display: flex;
    gap: 11px;
    padding: 9px;
    border: 1px solid var(--bordure);
    border-radius: 9px;
    background: var(--carte);
    cursor: pointer;
    align-items: center;
}
.gb-item:hover { border-color: var(--accent); }
.gb-thumb { flex: none; width: 38px; height: 54px; border-radius: 4px; background-size: cover; background-position: center; }
.gb-item .titre { font-size: 13px; font-weight: 600; color: var(--texte); }
.gb-item .meta { font-size: 12px; color: var(--texte-doux); }
.gb-item .choisir { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--accent); }

.grille-champs { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grille-champs .plein { grid-column: 1 / -1; }
.champ-input {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--bordure);
    border-radius: 9px;
    background: var(--champ);
    color: var(--texte);
    font-size: 14px;
    font-family: inherit;
    outline: none;
}
.champ-input:focus { border-color: var(--accent); }
.champ-input::placeholder { color: #6e685c; }
.champ-mini {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--texte-faible);
    font-weight: 700;
    display: block;
    margin-bottom: 8px;
}

.cover-import { display: flex; align-items: center; gap: 12px; }
.cover-apercu {
    width: 46px; height: 64px;
    border-radius: 6px;
    background-size: cover;
    background-position: center;
    border: 1px solid var(--bordure);
    flex: none;
}
.btn-import {
    padding: 7px 13px;
    border: 1px solid var(--bordure);
    border-radius: 8px;
    background: #3d3a32;
    color: var(--texte);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}
.btn-retirer-cover {
    padding: 7px 13px;
    border: none;
    background: none;
    color: #d98e6f;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

.modale-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.btn-annuler {
    padding: 10px 18px;
    border: 1px solid var(--bordure);
    border-radius: 9px;
    background: var(--carte);
    color: #cfc8ba;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}
.btn-enregistrer {
    padding: 10px 20px;
    border: none;
    border-radius: 9px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
}
.btn-enregistrer:disabled { opacity: 0.6; cursor: default; }

/* ============ RESPONSIVE ============ */

@media (max-width: 720px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .entete-recherche { order: 3; flex: 1 1 100%; }
    .grille-encours { grid-template-columns: 1fr; }
    .grille-champs { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
