/* ================================================================
   Dashboard d'apprentissage — Charte « Hanji »
   Encre + papier. Filets, pas d'ombres. Aucun arrondi.
   Pastels = décoration seule. Vert/orange/rouge = statuts seuls.
   ================================================================ */
/* Police de la langue cible : remplacer la famille si l'alphabet l'exige
   (ex. 'Noto Serif KR' pour le coreen, 'Noto Serif JP' pour le japonais). */
@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,300..700;1,6..72,300..600&family=Outfit:wght@200;300;400;500;600;700&family=JetBrains+Mono:wght@300;400;500&display=swap');

/* ================================================================
   1. TOKENS
   ================================================================ */
:root {
    /* base : encre + blanc, rien d'autre */
    --ink:         #17191a;
    --ink-soft:    #4c4f50;
    --ink-mute:    #8e9192;
    --ink-faint:   #b4b6b7;
    --paper:       #ffffff;
    --paper-alt:   #fafbfc;
    --line:        #ededeb;
    --line-soft:   #f2f2f0;
    --line-strong: #17191a;

    /* accents pastel — décoratifs UNIQUEMENT */
    --pastel-red:  #c98d92;
    --pastel-blue: #8fa8cc;
    --accent-red:  #b0545c;
    --accent-blue: #4a6fa5;
    --tint-red:    #faeef0;
    --tint-blue:   #eef2f8;
    --line-red:    #f2dfe1;

    /* statuts — jamais décoratifs */
    --status-known:    #2f9e5f;
    --status-learning: #d98b1f;
    --status-todo:     #cd2e3a;
    --status-none:     #dcdcda;

    /* surfaces encre (sidebar, cartes pleines) */
    --ink-surface: #17191a;
    --ink-line:    #2a2d2e;
    --ink-ghost:   #1f2223;
    --on-ink:      #ffffff;
    --on-ink-soft: #c6c9ca;
    --on-ink-mute: #8b8f90;
    --on-ink-dim:  #6a6e6f;

    /* ------------------------------------------------------------------
       ZONE A ADAPTER — glyphes decoratifs de la langue cible.
       Le gabarit pose de gros caracteres decoratifs (filigrane des cartes,
       titre vertical de la page vocab). Mettre ici ce qui a du sens pour la
       langue enseignee : une lettre, une abreviation, un ideogramme.
       ------------------------------------------------------------------ */
    --deco-front: 'A';        /* filigrane recto des flashcards */
    --deco-back:  'B';        /* filigrane verso des flashcards */
    --deco-vocab: 'Voc';      /* titre vertical de la page vocabulaire */

    /* typographie */
    --f-target: 'Newsreader', serif;   /* police de la langue cible */
    --f-ed:   'Newsreader', serif;
    --f-ui:   'Outfit', system-ui, sans-serif;
    --f-mono: 'JetBrains Mono', monospace;

    --sidebar-w: 236px;
    --transition: all .18s cubic-bezier(.4, 0, .2, 1);

    /* ---- alias legacy : consommés par le JS en style inline ----
       Ne pas supprimer : renderWeekList / mastery-bar / stats écrivent
       var(--green), var(--red), var(--border)… directement dans le HTML. */
    --bg:          #ffffff;
    --bg-card:     #ffffff;
    --bg-card-alt: #fafbfc;
    --bg-hover:    #fafbfc;
    --border:      #ededeb;
    --text:        #17191a;
    --text-dim:    #4c4f50;
    --text-muted:  #8e9192;
    --accent:      #17191a;
    --accent-dim:  #4c4f50;
    --accent-glow: rgba(23, 25, 26, .06);
    --green:       #2f9e5f;
    --orange:      #d98b1f;
    --red:         #cd2e3a;
    --radius:      0;
    --radius-sm:   0;
    --radius-xs:   0;
    --shadow:      none;
}

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

body {
    font-family: var(--f-ui);
    background: var(--paper);
    color: var(--ink);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.kr { font-family: var(--f-target); }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); }

/* Label de section — 10px, tracking large, capitales */
.nav-section-label,
.section-label {
    font: 500 10px/1 var(--f-ui);
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--ink-mute);
}

/* ================================================================
   2. SIDEBAR — encre pleine, 236px, sans arrondi
   ================================================================ */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--ink-surface);
    color: var(--on-ink);
    display: flex;
    flex-direction: column;
    z-index: 200;
    overflow: hidden;
    transition: transform .3s cubic-bezier(.4, 0, .2, 1);
}

/* cercle décoratif en fond */
.sidebar::before {
    content: '';
    position: absolute;
    right: -56px; top: 150px;
    width: 200px; height: 200px;
    border-radius: 50%;
    background: linear-gradient(150deg, var(--pastel-red) 0 50%, var(--pastel-blue) 50% 100%);
    opacity: .16;
    pointer-events: none;
}

.sidebar-header { position: relative; padding: 26px 22px 0; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    text-decoration: none;
    color: var(--on-ink);
}

.sidebar-logo {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.sidebar-brand-text { display: flex; flex-direction: column; gap: 1px; }

.sidebar-title {
    font: 500 18px/1.1 var(--f-target);
    color: var(--on-ink);
    letter-spacing: 0;
}

/* surtitre (CFG.tagline) sous le nom */
.sidebar-sup {
    font: 400 9.5px/1.4 var(--f-ui);
    color: var(--on-ink-mute);
    letter-spacing: .2em;
    text-transform: uppercase;
}

.sidebar-nav {
    position: relative;
    flex: 1;
    padding: 26px 22px 16px;
    overflow-y: auto;
}
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--ink-line); }

.sidebar-nav .nav-section-label {
    font: 500 9px/1 var(--f-ui);
    letter-spacing: .22em;
    color: var(--on-ink-dim);
    padding: 0 0 9px 2px;
}
.sidebar-nav .nav-section-label:not(:first-child) { padding-top: 22px; }

/* entrée de nav = pastille (CFG.deco) + libellé */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    text-decoration: none;
    color: var(--on-ink-soft);
    font: 400 13px var(--f-ui);
    transition: var(--transition);
}

.sidebar-link .sidebar-icon {
    font-family: var(--f-target);
    font-size: 13px;
    font-weight: 400;
    width: auto;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    color: var(--pastel-blue);
    line-height: 1;
}
/* alternance des pastels sur les pastilles de nav */
.sidebar-link:nth-of-type(even) .sidebar-icon { color: var(--pastel-red); }

.sidebar-link:hover { background: rgba(255, 255, 255, .08); color: var(--on-ink); }

.sidebar-link.active {
    background: var(--paper);
    color: var(--ink);
    font-weight: 500;
}
.sidebar-link.active .sidebar-icon { color: var(--ink); font-weight: 500; }

/* icônes lucide résiduelles dans la nav : neutralisées au profit des pastilles */
.sidebar-link .sidebar-icon svg { width: 15px; height: 15px; }

.sidebar-sub {
    margin: 2px 0 8px;
    padding-left: 12px;
    border-left: 1px solid var(--ink-line);
}
.sidebar-sub .sidebar-link { font-size: 12px; padding: 7px 10px; color: var(--on-ink-mute); }
.sidebar-sub .sidebar-link:hover { color: var(--on-ink); }

/* blocs « Livres » / « Unites » injectés dans #sidebar-extra */
#sidebar-extra { display: block; }

/* livres : grille 2×2 de pastilles (maquette vocabulaire) */
.side-books {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 4px;
}
.side-book {
    padding: 10px;
    background: rgba(255, 255, 255, .06);
    color: #9fa2a3;
    font: 400 13px var(--f-ui);
    text-decoration: none;
    transition: var(--transition);
}
.side-book:hover { background: rgba(255, 255, 255, .12); color: var(--on-ink); }
.side-book.active { background: var(--paper); color: var(--ink); font-weight: 500; }

/* chapitres : nom de l'unite à gauche, compteur mono à droite */
.side-chap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 10px;
}
.side-chap-n { font: 400 12.5px var(--f-target); }
.side-chap.active .side-chap-n { font-weight: 500; }
.side-chap-c { font: 400 10px var(--f-mono); color: var(--on-ink-dim); }
.side-chap.active .side-chap-c { color: var(--ink-mute); }

/* bloc « Paquet du jour » (maquette flashcards) */
.side-deck { margin-top: 22px; }
.side-deck-scope {
    font: 400 12.5px/1.7 var(--f-ui);
    color: #9fa2a3;
    margin-bottom: 10px;
}
.side-deck-stats { display: flex; gap: 6px; }
.side-deck-stat {
    flex: 1;
    background: rgba(255, 255, 255, .06);
    padding: 9px;
    text-align: center;
}
.side-deck-n { display: block; font: 400 16px var(--f-ed); color: var(--on-ink); }
.side-deck-l {
    display: block;
    margin-top: 3px;
    font: 400 9px var(--f-ui);
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #7f8384;
}

/* bloc progression en pied de sidebar (maquette vocabulaire) */
.side-progress { margin-top: 22px; }
.side-progress-label {
    font: 400 10px var(--f-ui);
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--on-ink-dim);
    margin-bottom: 9px;
}
.side-progress-bar { display: flex; height: 4px; background: var(--ink-line); }
.side-progress-bar span { display: block; }
.side-progress-foot {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font: 400 10px var(--f-mono);
    color: #7f8384;
}

.sidebar-footer {
    position: relative;
    padding: 16px 22px 22px;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* badge carré du prof (CFG.teacher.badge) — filet pastel rouge */
.side-teacher-badge {
    width: 34px; height: 34px;
    border: 1.5px solid var(--pastel-red);
    display: grid;
    place-items: center;
    font: 500 15px var(--f-target);
    color: var(--pastel-red);
}

.sidebar-footer-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    font: 400 10.5px/1.6 var(--f-ui);
    color: var(--on-ink-dim);
}
.sidebar-footer-text .kr {
    font-family: var(--f-target);
    color: #7f8384;
}
.side-teacher-sub { color: #5e6263; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(23, 25, 26, .5);
    z-index: 150;
}

/* ================================================================
   3. TOPBAR (mobile)
   ================================================================ */
.topbar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 54px;
    background: var(--ink-surface);
    border-bottom: none;
    padding: 0 16px;
    align-items: center;
    gap: 12px;
    z-index: 100;
}
.topbar::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--pastel-red) 0 50%, var(--pastel-blue) 50% 100%);
}

.topbar-toggle {
    width: 34px; height: 34px;
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    gap: 5px;
    background: none; border: none;
    cursor: pointer;
}
.topbar-toggle span {
    display: block;
    width: 18px; height: 1.5px;
    background: var(--on-ink-soft);
    transition: var(--transition);
}
.topbar-toggle:hover span { background: var(--on-ink); }

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    text-decoration: none;
    color: var(--on-ink);
    font: 500 16px var(--f-target);
}
.topbar-brand span { color: var(--on-ink); }
.topbar-logo { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }

/* ================================================================
   4. CONTENU — bandeau + gouttière
   ================================================================ */
.main-wrap {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    background: var(--paper);
}

/* bandeau supérieur 5px, deux moitiés pastel */
.main-wrap::before {
    content: '';
    display: block;
    height: 5px;
    background: linear-gradient(90deg, var(--pastel-red) 0 50%, var(--pastel-blue) 50% 100%);
}

main {
    max-width: 1180px;
    margin: 0;
    padding: 34px 42px 42px;
}

.loading {
    font: 400 13px var(--f-ui);
    color: var(--ink-mute);
    padding: 40px 0;
}

/* ================================================================
   5. EN-TÊTE DE PAGE — titre vertical (langue cible) + H1 Newsreader
   ================================================================ */
.hero,
.vocab-header {
    display: flex;
    align-items: stretch;
    gap: 26px;
    margin-bottom: 22px;
}

/* le mot en langue cible du H1 devient le titre vertical à gauche */
.hero h1,
.vocab-title-group h1 {
    font: 300 42px/1.05 var(--f-ed);
    color: var(--ink);
    font-weight: 300;
    margin: 9px 0 0;
    display: flex;
    align-items: flex-start;
    gap: 18px;
}

/* page vocab : le H1 est le nom du livre — on pose le titre vertical
   decoratif (--deco-vocab) de la charte en amorce. */
.vocab-title-group h1:not(:has(.kr))::before {
    content: var(--deco-vocab, 'Voc');
    writing-mode: vertical-rl;
    font: 400 30px/1 var(--f-target);
    color: var(--ink);
    letter-spacing: .1em;
    border-right: 1.5px solid var(--ink);
    padding: 2px 13px 2px 0;
    flex-shrink: 0;
    align-self: stretch;
    min-height: 74px;
}

.hero h1 .kr,
.vocab-title-group h1 .kr {
    writing-mode: vertical-rl;
    font: 400 32px/1 var(--f-target);
    color: var(--ink);
    letter-spacing: .1em;
    border-right: 1.5px solid var(--ink);
    padding: 2px 13px 2px 0;
    flex-shrink: 0;
    align-self: stretch;
    min-height: 96px;
}

.hero .subtitle,
.vocab-title-group .week-sub {
    margin: 8px 0 0;
    font: 400 13px/1.6 var(--f-ui);
    color: var(--ink-mute);
    max-width: 460px;
}

.hero { flex-direction: column; gap: 0; }

/* fil d'ariane */
.breadcrumb,
.crumb {
    font: 400 10px var(--f-ui);
    letter-spacing: .24em;
    text-transform: uppercase;
    color: var(--ink-mute);
}
.breadcrumb a, .crumb a { color: var(--ink-soft); text-decoration: none; }
.breadcrumb a:hover, .crumb a:hover { color: var(--ink); text-decoration: underline; }

.vocab-header { justify-content: space-between; flex-wrap: wrap; align-items: flex-start; }
.vocab-title-group { flex: 1; min-width: 260px; }
/* le bouton d'export ne doit jamais s'étirer sur la hauteur du titre */
.vocab-header > .dl-btn { align-self: flex-start; flex-shrink: 0; margin-top: 9px; }

/* ================================================================
   6. BOUTONS
   ================================================================ */
.btn-primary,
.dl-btn,
.practice-btn,
.test-btn,
.add-word-btn,
.toggle-btn,
.btn-secondary,
.lvl-filter-btn,
.ch-pill,
.fc-chapter-all-btn {
    font-family: var(--f-ui);
    border-radius: 0;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

/* primaire : encre plein */
.btn-primary,
.dl-btn {
    padding: 10px 18px;
    border: 1px solid var(--ink);
    background: var(--ink);
    color: var(--paper);
    font-size: 12px;
    font-weight: 500;
}
.btn-primary:hover, .dl-btn:hover { background: var(--ink-soft); border-color: var(--ink-soft); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }

/* secondaire : contour encre */
.btn-secondary,
.practice-btn {
    padding: 10px 18px;
    border: 1px solid var(--ink);
    background: transparent;
    color: var(--ink);
    font-size: 12px;
    font-weight: 400;
}
.btn-secondary:hover, .practice-btn:hover { background: var(--ink); color: var(--paper); }

.practice-bar { display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; }

/* ================================================================
   7. COMPTEURS DE STATUT (encadrés filets)
   ================================================================ */
.stats-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.stat-card {
    border: 1px solid var(--line);
    padding: 11px 14px;
    flex: 1;
    min-width: 128px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.stat-value {
    font: 400 20px var(--f-ed);
    color: var(--ink);
    order: 2;
}
.stat-label {
    font: 400 11.5px var(--f-ui);
    color: var(--ink-mute);
    text-transform: none;
    letter-spacing: 0;
    order: 1;
}

/* les statuts gardent leur couleur, le reste est encre */
.stat-value.green { color: var(--status-known); }
.stat-value.purple,
.stat-value.pink,
.stat-value.cyan { color: var(--ink); }

/* ================================================================
   8. PILLS DE CHAPITRE
   ================================================================ */
.chapter-nav {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    margin-bottom: 22px;
    padding-bottom: 0;
    border-bottom: none;
}

.ch-pill {
    padding: 6px 13px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--ink-soft);
    font: 400 11.5px var(--f-target);
}
.ch-pill:hover { border-color: var(--ink); color: var(--ink); }
.ch-pill.active {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--paper);
    font-family: var(--f-ui);
    font-weight: 500;
}
.ch-pill .count { color: var(--ink-faint); margin-left: 5px; font-family: var(--f-ui); }
.ch-pill.active .count { color: #9fa2a3; }

/* ================================================================
   9. BARRE DE RECHERCHE + TOGGLES (ligne unique entre deux filets)
   ================================================================ */
.controls {
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 10px 0;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.search-box { flex: 1; min-width: 220px; position: relative; display: flex; align-items: center; }
.search-box .icon {
    position: absolute;
    left: 0;
    color: var(--ink-faint);
    display: inline-flex;
    align-items: center;
    pointer-events: none;
}
.search-box input {
    width: 100%;
    padding: 2px 0 2px 23px;
    background: transparent;
    border: none;
    color: var(--ink);
    font: 400 13px var(--f-ui);
    outline: none;
}
.search-box input::placeholder { color: var(--ink-faint); }

.toggle-btn {
    padding: 7px 13px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--ink-mute);
    font-size: 11.5px;
    font-weight: 400;
}
.toggle-btn:hover { border-color: var(--ink); color: var(--ink); }
/* actif : les deux premiers toggles prennent un tint pastel décoratif */
.toggle-btn.active {
    border-color: transparent;
    background: var(--tint-blue);
    color: var(--accent-blue);
    font-weight: 500;
}
#toggle-details.active { background: var(--tint-red); color: var(--accent-red); }

.word-counter {
    font: 400 11.5px var(--f-ui);
    color: var(--ink-mute);
    margin-bottom: 10px;
}
.word-counter strong { color: var(--ink); font-weight: 500; }

/* filtre de niveau */
.level-filter-bar,
.fc-level-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
    padding: 0;
    background: transparent;
    border: none;
}
.lvl-filter-btn,
.fc-lvl-btn {
    padding: 6px 13px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--ink-mute);
    font: 400 11.5px var(--f-ui);
    cursor: pointer;
    transition: var(--transition);
}
.lvl-filter-btn:hover,
.fc-lvl-btn:hover { border-color: var(--ink); color: var(--ink); }
.lvl-filter-btn.active,
.fc-lvl-btn.active {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--paper);
    font-weight: 500;
}
.filter-label {
    font: 500 10px var(--f-ui);
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--ink-mute);
    align-self: center;
    margin-right: 4px;
}

/* ================================================================
   10. TABLE DE VOCABULAIRE
   ================================================================ */
.vocab-table-wrap {
    background: var(--paper);
    border: none;
    overflow: visible;
}

.vocab-table { width: 100%; border-collapse: collapse; }

.vocab-table thead th {
    padding: 9px 16px;
    text-align: left;
    background: transparent;
    font: 400 9.5px var(--f-ui);
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-faint);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 2;
}

.vocab-table tbody tr.vocab-row {
    border-bottom: 1px solid var(--line-soft);
    cursor: pointer;
    transition: background .15s ease;
}
/* lignes alternées */
.vocab-table tbody tr.vocab-row:nth-of-type(even) { background: var(--paper-alt); }
.vocab-table tbody tr.vocab-row:hover { background: var(--tint-blue); }
.vocab-table tbody tr.vocab-row.expanded { background: var(--paper-alt); }

.vocab-table td {
    padding: 13px 16px;
    vertical-align: middle;
    font-size: 13px;
}

/* colonnes — largeurs de la charte */
.col-level { width: 44px; text-align: left; padding: 0 0 0 16px !important; vertical-align: middle !important; cursor: pointer; }
.col-term  { width: 230px; font: 500 19px var(--f-target); color: var(--ink); }
.col-translation  { width: 210px; font: 400 13.5px var(--f-ed); color: var(--ink-soft); }
.col-example { font: 400 12.5px var(--f-target); color: var(--ink-mute); }
.col-translated { font: 300 12.5px var(--f-ed); font-style: italic; color: var(--ink-mute); }
.col-explanation { font: 400 12px/1.7 var(--f-ui); color: var(--ink-mute); max-width: 320px; }

/* index en mono */
.vocab-table td:nth-child(2) { font: 400 11px var(--f-mono) !important; color: var(--ink-faint) !important; width: 40px; }

/* pastille de niveau — cercle 9px */
.level-dot {
    display: block;
    width: 9px; height: 9px;
    border-radius: 50%;
    background: transparent;
    border: 1.5px solid var(--status-none);
    transition: transform .15s ease, background .18s ease, border-color .18s ease;
    cursor: pointer;
}
.col-level:hover .level-dot { transform: scale(1.4); border-color: var(--ink-mute); }

.vocab-row[data-level="green"]  .level-dot { background: var(--status-known);    border-color: var(--status-known); }
.vocab-row[data-level="orange"] .level-dot { background: var(--status-learning); border-color: var(--status-learning); }
.vocab-row[data-level="red"]    .level-dot { background: var(--status-todo);     border-color: var(--status-todo); }

/* séparateur de chapitre — bandeau plein encre */
.chapter-sep td {
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    cursor: default !important;
}
.chapter-sep:hover { background: transparent !important; }

.chapter-sep-content {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    background: var(--ink-surface);
    color: var(--on-ink);
    padding: 11px 16px;
    margin-top: 14px;
    font: 500 14px var(--f-target);
}
.chapter-sep:first-child .chapter-sep-content { margin-top: 0; }
.chapter-sep-content > span:first-child { display: inline-flex; align-items: center; gap: 8px; }
.chapter-sep-content .icon-xs { color: var(--on-ink-mute); }

.add-word-btn {
    margin-left: auto;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--pastel-red);
    font: 400 11px var(--f-ui);
}
.add-word-btn:hover { color: var(--paper); background: transparent; }

/* barre de maîtrise empilée */
.mastery-bar {
    display: flex;
    height: 4px;
    overflow: hidden;
    background: var(--line);
    margin-bottom: 14px;
}
.mastery-bar span { display: block; }

/* ================================================================
   11. ACCUEIL — cartes d'entrée
   ================================================================ */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
    gap: 12px;
}

.book-card {
    border: 1px solid var(--line);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    min-height: 150px;
    text-decoration: none;
    color: var(--ink);
    transition: var(--transition);
}
.book-card:hover { border-color: var(--ink); }

/* dernière carte en fond encre, comme la maquette accueil */
.books-grid .book-card:last-child {
    background: var(--ink-surface);
    border-color: var(--ink-surface);
    color: var(--on-ink);
}
.books-grid .book-card:last-child .book-title { color: var(--on-ink); }
.books-grid .book-card:last-child .book-stat-value { color: var(--on-ink); }
.books-grid .book-card:last-child .book-stat-label { color: var(--on-ink-mute); }
.books-grid .book-card:last-child .book-level { color: var(--pastel-red); border-color: transparent; }

.book-level {
    display: inline-block;
    padding: 0;
    border: none;
    background: transparent;
    font: 400 10px var(--f-ui);
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--ink-mute);
}
.book-level.l3, .book-level.l4 { background: transparent; color: var(--ink-mute); }

.book-title { font: 400 22px var(--f-target); color: var(--ink); }

.book-stats { display: flex; gap: 20px; margin-top: auto; }
.book-stat { display: flex; flex-direction: column; gap: 2px; }
.book-stat-value { font: 400 20px var(--f-ed); color: var(--ink); }
.book-stat-label {
    font: 400 9.5px var(--f-ui);
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-mute);
}

/* ================================================================
   12. VOCAB SEMAINE
   ================================================================ */
.week-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}

.week-card {
    border: 1px solid var(--line);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    min-height: 148px;
    text-decoration: none;
    color: var(--ink);
    transition: var(--transition);
}
.week-card:hover { border-color: var(--ink); }

.week-card-range { font: 400 17px var(--f-target); color: var(--ink); }
.week-card-count { font: 400 11.5px var(--f-ui); color: var(--ink-mute); }
.week-card .mastery-bar { margin-top: auto; margin-bottom: 0; }
.week-card-actions { display: flex; justify-content: flex-end; }
.week-card-go { font: 400 11.5px var(--f-ui); color: var(--accent-blue); }

/* ================================================================
   13. LEÇONS — liste
   ================================================================ */
.lessons-grid { display: flex; flex-direction: column; gap: 0; }

.lesson-card {
    border-top: 1.5px solid var(--ink);
    border-bottom: none;
    text-decoration: none;
    color: var(--ink);
    display: block;
    transition: background .15s ease;
}
.lesson-card:hover { background: var(--paper-alt); }

.lesson-card-inner { display: flex; align-items: stretch; }
.lesson-card-accent { display: none; }
.lesson-card-content { flex: 1; padding: 18px 4px 20px; }

.lesson-card-header { display: flex; align-items: baseline; gap: 12px; margin-bottom: 0; }

.lesson-card-number {
    display: inline-flex;
    align-items: baseline;
    width: auto; height: auto;
    background: transparent;
    color: var(--ink-faint);
    font: 400 11px var(--f-mono);
    flex-shrink: 0;
}

.lesson-card-title { font: 500 30px var(--f-target); color: var(--ink); line-height: 1.2; }

.lesson-card-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 12px;
    padding-top: 0;
    border-top: none;
}

.topic-tag {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    padding: 0;
    border: none;
    background: transparent;
    font: 400 12.5px/1.7 var(--f-ui);
    color: var(--ink-soft);
}
.topic-tag + .topic-tag::before {
    content: '·';
    color: var(--ink-faint);
    margin-right: 5px;
}
.topic-tag .topic-num { font-family: var(--f-mono); font-size: 10.5px; color: var(--ink-faint); }
.topic-tag .topic-text { color: var(--ink-soft); }
.lesson-card:hover .topic-tag .topic-text { color: var(--ink); }

.lesson-card-arrow {
    display: flex;
    align-items: center;
    padding: 0 8px 0 20px;
    color: var(--ink-faint);
    transition: var(--transition);
}
.lesson-card:hover .lesson-card-arrow { color: var(--ink); transform: translateX(3px); }

/* groupes de niveau */
.level-group { margin-bottom: 34px; }
.level-group-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 4px;
    padding-bottom: 10px;
    border-bottom: none;
}
.level-group-icon { display: none; }
.level-group-title { font: 400 10px var(--f-ui); letter-spacing: .24em; text-transform: uppercase; color: var(--ink-mute); }
.level-group-badge {
    padding: 0;
    background: transparent !important;
    color: var(--ink-faint) !important;
    font: 400 10px var(--f-mono);
    letter-spacing: .1em;
    text-transform: none;
}

.empty-state {
    color: var(--ink-mute);
    font: 300 14px var(--f-ed);
    font-style: italic;
    padding: 26px;
    text-align: center;
    background: transparent;
    border: 1px solid var(--line);
}

/* ================================================================
   14. FLASHCARDS — sélecteur chapitre / jour
   ================================================================ */
.fc-chapters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.fc-chapter-card {
    border: 1px solid var(--line);
    padding: 18px;
    transition: var(--transition);
}
.fc-chapter-card:hover { border-color: var(--ink); }

.fc-chapter-card-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
}
.fc-chapter-card-head h3 { font: 500 20px var(--f-target); color: var(--ink); }
.fc-chapter-count { font: 400 10px var(--f-mono); color: var(--ink-mute); white-space: nowrap; }

.fc-chapter-all-btn {
    display: block;
    text-align: center;
    padding: 9px 14px;
    border: 1px solid var(--ink);
    background: transparent;
    color: var(--ink);
    font: 400 11.5px var(--f-ui);
    text-decoration: none;
    margin-bottom: 14px;
}
.fc-chapter-all-btn:hover { background: var(--ink); color: var(--paper); }

.fc-week-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
    gap: 6px;
}
.fc-week-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 9px 4px 7px;
    border: 1px solid var(--line);
    background: transparent;
    text-decoration: none;
    color: var(--ink);
    transition: var(--transition);
}
.fc-week-chip:hover { border-color: var(--ink); background: var(--paper-alt); }
.fc-week-num { font: 500 12.5px var(--f-ui); }
.fc-week-count { font: 400 9px var(--f-mono); color: var(--ink-faint); }
.fc-week-chip .mastery-bar { width: 100%; height: 3px; margin: 0; }

/* ================================================================
   15. YOUTUBE
   ================================================================ */
.yt-channel-section { margin-bottom: 34px; }
.yt-channel-title {
    font: 400 10px var(--f-ui);
    letter-spacing: .24em;
    text-transform: uppercase;
    color: var(--ink-mute);
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.yt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
    gap: 12px;
}

.yt-card {
    border: 1px solid var(--line);
    overflow: hidden;
    transition: var(--transition);
}
.yt-card:hover { border-color: var(--ink); }

.yt-thumb-wrap { position: relative; aspect-ratio: 16 / 9; background: var(--ink-surface); cursor: pointer; overflow: hidden; }
.yt-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }

.yt-play-btn {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(23, 25, 26, .3); color: var(--paper); opacity: 0;
    transition: var(--transition);
}
.yt-thumb-wrap:hover .yt-play-btn { opacity: 1; background: rgba(23, 25, 26, .45); }
.yt-play-btn i { width: 44px; height: 44px; }

.yt-embed-wrap iframe { width: 100%; height: 100%; border: none; display: block; }

.yt-info { padding: 14px 16px; }
.yt-title {
    font: 400 13.5px/1.45 var(--f-ed);
    color: var(--ink);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    margin-bottom: 6px;
}
.yt-meta { font: 400 10px var(--f-mono); color: var(--ink-mute); }

.yt-more-btn { margin-top: 14px; }
.yt-extra { display: none; }
.yt-extra.show { display: block; }

/* ================================================================
   16. MODALE — ajout de mot
   ================================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(23, 25, 26, .55);
    z-index: 400;
    opacity: 0;
    transition: opacity .2s ease;
}
.modal-overlay.open { display: block; opacity: 1; }

.modal {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 500;
    width: min(560px, 94vw);
    background: var(--paper);
    border: 1px solid var(--ink);
    padding: 28px 30px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}
.modal.open { opacity: 1; pointer-events: all; }

.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.modal-title {
    font: 300 26px var(--f-ed);
    color: var(--ink);
    display: flex; align-items: center; gap: 9px;
}
.modal-subtitle {
    font: 400 10px var(--f-ui);
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--ink-mute);
    margin-bottom: 22px;
}
.modal-close {
    width: 30px; height: 30px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--ink-mute);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.modal-close:hover { border-color: var(--ink); color: var(--ink); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 22px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group-full { grid-column: 1 / -1; }
.form-label {
    font: 400 10px var(--f-ui);
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--ink-mute);
}
.form-label .req,
.form-label .required { color: var(--status-todo); margin-left: 2px; }

.form-input {
    padding: 10px 12px;
    background: transparent;
    border: 1px solid var(--line);
    color: var(--ink);
    font: 400 13px var(--f-ui);
    outline: none;
    transition: var(--transition);
}
.form-input::placeholder { color: var(--ink-faint); }
.form-input:focus { border-color: var(--ink); }
.form-textarea { resize: vertical; min-height: 72px; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.modal-success {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid var(--status-known);
    color: var(--status-known);
    font: 400 12.5px var(--f-ui);
    margin-top: 12px;
}

/* ================================================================
   17. ICÔNES
   ================================================================ */
.lucide { display: inline-block; vertical-align: middle; }
.icon-sm { width: 1.05rem; height: 1.05rem; }
.icon-xs { width: .9rem; height: .9rem; }

/* ================================================================
   18. RESPONSIVE
   ================================================================ */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .topbar { display: flex; }

    .main-wrap { margin-left: 0; }
    .main-wrap::before { display: none; }
    main { padding: 74px 18px 40px; }

    .hero h1,
    .vocab-title-group h1 { font-size: 30px; }
    .hero h1 .kr,
    .vocab-title-group h1 .kr { font-size: 20px; }

    .vocab-header { flex-direction: column; gap: 14px; }
    .stats-bar { flex-direction: column; }
    .books-grid, .week-grid, .yt-grid, .fc-chapters-grid { grid-template-columns: 1fr; }

    /* table vocab → cartes empilées */
    .vocab-table thead { display: none; }
    .vocab-table, .vocab-table tbody { display: block; width: 100%; }
    .vocab-table tbody tr.vocab-row {
        display: grid;
        grid-template-columns: 22px 1fr;
        gap: 2px 10px;
        padding: 14px 2px;
        border-bottom: 1px solid var(--line-soft);
    }
    .vocab-table tbody tr.vocab-row td { display: block; padding: 0; border: none; }
    /* la pastille occupe la colonne étroite ; TOUT le texte va en colonne 2,
       sinon une cellule retombe sous la pastille et se compose en vertical. */
    .col-level { grid-column: 1; grid-row: 1; width: auto; padding: 6px 0 0 !important; }
    .vocab-table tbody tr.vocab-row td:not(.col-level) { grid-column: 2; width: auto; }
    .vocab-table td:nth-child(2) { display: none !important; }
    .col-explanation { display: none; }
    .col-example { margin-top: 4px; }
    .chapter-sep, .chapter-sep td { display: block; width: 100%; }

    .lesson-card-arrow { display: none; }
    .lesson-card-title { font-size: 24px; }
    .lesson-card-content { padding: 16px 2px 18px; }
}

@media (max-width: 480px) {
    main { padding: 68px 14px 32px; }
    .form-grid { grid-template-columns: 1fr; }
    .modal { padding: 20px 18px; }
    .hero h1, .vocab-title-group h1 { font-size: 26px; }
}
