/* ============================================================================
   pages.css — view-specific layout (Ask, Library, Upload, Activity, Account).
   ========================================================================== */

@layer pages {

/* ─── Login gate ────────────────────────────────────────────────────────── */
.gate {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: var(--sp-5);
  background: var(--bg);
}
.gate-card { width: 100%; max-width: 380px; }
.gate-brand {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  margin-bottom: var(--sp-5);
}
.gate-brand h1 {
  background: var(--brand-gradient);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.gate-tabs { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.gate-tabs button {
  flex: 1; padding: var(--sp-2); border-radius: var(--r-md);
  font-weight: var(--fw-medium); color: var(--text-2); border: 1px solid var(--border);
}
.gate-tabs button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.gate-error { color: var(--danger); font-size: var(--fs-sm); min-height: 1.2em; margin-top: var(--sp-2); }
.gate-skip { text-align: center; margin-top: var(--sp-3); }
.gate-skip button { color: var(--text-3); font-size: var(--fs-sm); text-decoration: underline; }

/* ─── Ask view ──────────────────────────────────────────────────────────────
   Two surfaces share this view. On landing only .ask-hero shows (search box as
   the central hero). After the first question we add .conversing to .ask-view:
   the hero is hidden (via [hidden]) and the thread + docked composer take over. */
/* La vue Demander occupe TOUTE la hauteur du main : le fil scrolle en interne
   et le composer reste collé en bas (comme ChatGPT). Sans ça, .view étant en
   display:block sans hauteur, .ask-layout{height:100%} retombait sur auto →
   la barre flottait sous les messages avec un grand vide en dessous. */
#view-ask.active { height: 100%; }
.ask-view { display: flex; flex-direction: column; height: 100%; }

/* — HERO (landing): the search box is the obvious focal point — */
.ask-hero {
  flex: 1 1 auto; display: flex; align-items: center; justify-content: center;
  /* sit a touch above centre so it reads like Spotlight, not vertically lost */
  padding: clamp(var(--sp-6), 6vh, var(--sp-12)) var(--sp-6);
}
/* Le display:flex ci-dessus écraserait l'attribut hidden posé par ask.js en
   entrant en conversation — le hero ne doit exister QUE pour un nouveau fil. */
.ask-hero[hidden] { display: none; }
.ask-hero-inner {
  width: 100%; max-width: 720px; margin-bottom: 6vh; position: relative;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.ask-title { font-size: var(--fs-3xl); letter-spacing: -.02em; margin-top: var(--sp-4); }
.ask-sub { font-size: var(--fs-lg); margin-top: var(--sp-2); }

/* The hero search field — large, centred, the visual anchor of the whole app. */
.hero-search {
  width: 100%; margin-top: var(--sp-6);
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  transition: border-color var(--t), box-shadow var(--t);
}
.hero-search:focus-within { border-color: var(--accent); box-shadow: var(--shadow-lg), var(--ring); }
.hero-search-ic { display: flex; color: var(--text-3); flex: none; }
.hero-search-ic .ico { width: 22px; height: 22px; }
.hero-input {
  flex: 1 1 auto; min-width: 0; border: none; background: transparent;
  color: var(--text); font-size: var(--fs-xl); line-height: var(--lh-normal);
  resize: none; padding: var(--sp-2) 0; max-height: 180px;
}
.hero-input:focus { outline: none; box-shadow: none; }
.hero-input::placeholder { color: var(--text-3); }
.hero-send { width: 44px; height: 44px; padding: 0; border-radius: var(--r-lg); flex: none; }
.hero-send .ico { width: 20px; height: 20px; }

.ask-hero .suggestions { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: center; margin-top: var(--sp-5); }

/* — CONVERSATION (after first question) — */
.ask-scroll { flex: 1 1 auto; overflow-y: auto; position: relative; }
.ask-thread { max-width: 820px; margin: 0 auto; padding: var(--sp-8) var(--sp-6) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-5); }
.ask-composer-wrap { border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); }
.ask-composer {
  max-width: 820px; margin: 0 auto; padding: var(--sp-3) var(--sp-6);
  display: flex; gap: var(--sp-2); align-items: flex-end;
}
.ask-composer .textarea { max-height: 160px; }

.msg { display: flex; gap: var(--sp-3); }
.msg .msg-avatar { width: 30px; height: 30px; flex: none; border-radius: var(--r-sm); }
.msg.user .msg-avatar { background: var(--surface-3); display: flex; align-items: center; justify-content: center; color: var(--text-2); }
.msg.user .msg-avatar .ico { width: 18px; height: 18px; }
.msg.neko .neko-avatar { padding: 2px; background: var(--accent-soft); border-radius: var(--r-sm); }
.msg .msg-body { flex: 1 1 auto; min-width: 0; }
.msg .msg-role { font-size: var(--fs-xs); color: var(--text-3); font-weight: var(--fw-medium); margin-bottom: var(--sp-1); }
.msg.user .bubble {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4);
}
.msg .sources-label { font-size: var(--fs-xs); color: var(--text-3); margin: var(--sp-3) 0 var(--sp-2); }

/* head-tilt micro-interaction while thinking (respects reduced-motion via tokens) */
.neko-thinking { animation: tilt 1.6s var(--ease) infinite; transform-origin: 50% 80%; }
@keyframes tilt { 0%,100% { transform: rotate(0); } 50% { transform: rotate(-6deg); } }

/* — Sidebar de conversations (façon ChatGPT) : 2 colonnes de la vue ask — */
.ask-layout { display: flex; height: 100%; position: relative; }
.ask-layout .ask-view { flex: 1 1 auto; min-width: 0; }
.ask-sidebar {
  flex: none; width: 260px; display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-3); border-right: 1px solid var(--border);
  background: var(--surface); overflow-y: auto;
}
.ask-new-btn {
  display: flex; align-items: center; gap: var(--sp-2); flex: none;
  padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); background: var(--surface-2); color: var(--text);
  font-weight: var(--fw-medium); font-size: var(--fs-sm);
  transition: border-color var(--t), background var(--t);
}
.ask-new-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.ask-new-btn .ico { width: 16px; height: 16px; flex: none; }
.ask-conv-list { display: flex; flex-direction: column; gap: 2px; }
.ask-conv-empty { padding: var(--sp-3) var(--sp-2); font-size: var(--fs-sm); }
.ask-conv-item {
  display: flex; align-items: center; gap: var(--sp-1);
  border-radius: var(--r-md); border: 1px solid transparent;
  transition: background var(--t), border-color var(--t);
}
.ask-conv-item:hover { background: var(--surface-2); }
.ask-conv-item.active { background: var(--accent-soft); border-color: var(--accent); }
.ask-conv-open {
  flex: 1 1 auto; min-width: 0; text-align: left;
  padding: var(--sp-2) var(--sp-3); color: var(--text); font-size: var(--fs-sm);
}
.ask-conv-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ask-conv-del { flex: none; width: 30px; height: 30px; opacity: 0; color: var(--text-3); }
.ask-conv-del .ico { width: 15px; height: 15px; }
.ask-conv-item:hover .ask-conv-del { opacity: 1; }
.ask-conv-del:hover { color: var(--danger); }

/* Bouton d'ouverture de la sidebar (visible surtout en responsive). */
.ask-sidebar-toggle {
  display: none; align-items: center; justify-content: center;
  width: 34px; height: 34px; border: 1px solid var(--border);
  border-radius: var(--r-md); background: var(--surface); color: var(--text-2);
}
.ask-sidebar-toggle .ico { width: 18px; height: 18px; }
.ask-sidebar-toggle.floating { position: absolute; top: var(--sp-3); left: var(--sp-3); z-index: 5; }
.ask-sidebar-scrim { display: none; }

/* — Cartes fichiers (find_docs / provider 'search') — */
.file-cards {
  display: grid; gap: var(--sp-2); margin-top: var(--sp-3);
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.file-card {
  display: flex; align-items: center; gap: var(--sp-3); text-align: left;
  padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow-xs);
  transition: border-color var(--t), box-shadow var(--t), transform var(--t);
}
.file-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.file-card:disabled { opacity: .6; cursor: default; }
.file-card-ic {
  display: flex; align-items: center; justify-content: center; flex: none;
  width: 36px; height: 36px; border-radius: var(--r-md);
  background: var(--accent-soft); color: var(--accent);
}
.file-card-ic .ico { width: 20px; height: 20px; }
.file-card-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.file-card-stem { font-weight: var(--fw-semibold); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-card-meta { font-size: var(--fs-xs); color: var(--text-3); }

/* — Overlay fichier plein écran (par-dessus la conversation) — */
.file-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.file-overlay.open { opacity: 1; }
.file-overlay-backdrop { position: absolute; inset: 0; background: rgba(8,9,14,.62); }
.file-overlay-panel {
  position: relative; width: 90vw; height: 90vh; max-width: 1200px;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  transform: scale(.97); transition: transform var(--dur) var(--ease);
}
.file-overlay.open .file-overlay-panel { transform: scale(1); }
.file-overlay-head {
  flex: none; display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
}
.file-overlay-title { flex: 1 1 auto; min-width: 0; font-weight: var(--fw-semibold);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-overlay-body { flex: 1 1 auto; overflow-y: auto; padding: var(--sp-4); }
.file-overlay-img { display: block; max-width: 100%; margin: 0 auto; }
.file-overlay-frame { width: 100%; height: 100%; border: none; }

/* ── Overlay scindé sujet / correction ────────────────────────────────── */
.file-overlay-panel.split { max-width: 1500px; }
.file-overlay-cols { flex: 1 1 auto; display: flex; min-height: 0; }
.file-overlay-col { flex: 1 1 50%; min-width: 0; display: flex; flex-direction: column;
  overflow: hidden; }
.file-overlay-correction { border-left: 1px solid var(--border); }
.file-overlay-corr-switch { flex: none; display: flex; flex-wrap: wrap; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4); }
.file-overlay-corr-switch:empty { display: none; }
.file-overlay-corr-body { flex: 1 1 auto; overflow-y: auto; padding: var(--sp-4); }
.file-overlay-badge { flex: none; font-size: var(--fs-sm); font-weight: var(--fw-semibold);
  padding: 2px 10px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text-2); }
.file-overlay-badge[data-nature="prof"] { color: var(--success, #2e7d32); }
.file-overlay-badge[data-nature="ia"] { color: var(--accent, #6b5bff); }
.file-overlay-nocorr { margin-top: var(--sp-4); }

@media (max-width: 900px) {
  .file-overlay-cols { flex-direction: column; overflow-y: auto; }
  .file-overlay-col { flex: 1 1 auto; }
  .file-overlay-correction { border-left: none; border-top: 1px solid var(--border); }
}

@media (max-width: 900px) {
  /* Sidebar repliée en tiroir : le bouton hamburger la fait glisser. */
  .ask-sidebar {
    position: absolute; top: 0; bottom: 0; left: 0; z-index: 8;
    transform: translateX(-100%); transition: transform var(--dur) var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .ask-layout.sidebar-open .ask-sidebar { transform: translateX(0); }
  .ask-layout.sidebar-open .ask-sidebar-scrim {
    display: block; position: absolute; inset: 0; z-index: 7;
    background: rgba(8,9,14,.4);
  }
  .ask-sidebar-toggle { display: flex; }
  .ask-hero-inner .ask-sidebar-toggle { position: absolute; top: var(--sp-3); left: var(--sp-3); }
  .file-overlay-panel { width: 96vw; height: 94vh; }
}

/* ─── Library ───────────────────────────────────────────────────────────── */
.lib-toolbar { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; margin-bottom: var(--sp-4); }
.lib-toolbar .grow { min-width: 200px; }
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1); font-size: var(--fs-sm); color: var(--text-3); margin-bottom: var(--sp-3); }
.breadcrumb button { color: var(--accent); }
.breadcrumb .sep { color: var(--text-3); }

.lib-layout { display: grid; grid-template-columns: 1fr; gap: var(--sp-5); }

.lib-list { display: flex; flex-direction: column; gap: var(--sp-4); }
.lib-rows { display: flex; flex-direction: column; gap: var(--sp-1); }

/* Subject / folder cards — a responsive grid that fills wide screens. */
.subject-grid {
  display: grid; gap: var(--sp-3);
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.subject-card {
  display: flex; align-items: center; gap: var(--sp-3); text-align: left;
  padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow-xs);
  transition: border-color var(--t), box-shadow var(--t), transform var(--t), background var(--t);
}
.subject-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.subject-card .sc-ic {
  display: flex; align-items: center; justify-content: center; flex: none;
  width: 40px; height: 40px; border-radius: var(--r-md);
  background: var(--accent-soft); color: var(--accent);
}
.subject-card .sc-ic .ico { width: 22px; height: 22px; }
.subject-card .sc-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.subject-card .sc-name { font-weight: var(--fw-semibold); color: var(--text); }
.subject-card .sc-meta { font-size: var(--fs-xs); color: var(--text-3); }
.subject-card .sc-chev { color: var(--text-3); flex: none; opacity: 0; transition: opacity var(--t); }
.subject-card .sc-chev .ico { width: 18px; height: 18px; }
.subject-card:hover .sc-chev { opacity: 1; }
.lib-row {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md);
  border: 1px solid transparent; text-align: left;
  transition: background var(--t), border-color var(--t);
}
.lib-row:hover { background: var(--surface-2); }
.lib-row[aria-selected="true"] { background: var(--accent-soft); border-color: var(--accent); }
.lib-row .ico { width: 18px; height: 18px; flex: none; color: var(--text-3); }
.lib-row .lr-name { font-weight: var(--fw-medium); }
.lib-row .lr-meta { font-size: var(--fs-xs); color: var(--text-3); margin-left: auto; white-space: nowrap; }

/* Vue large : le détail d'un fichier occupe toute la zone de contenu (la
   liste est masquée) ; l'aperçu profite de la pleine largeur. */
.lib-detail { display: flex; flex-direction: column; gap: var(--sp-4); }
.lib-detail-head { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.lib-detail-head h2 { min-width: 0; }
.lib-detail-actions { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; flex-wrap: wrap; }
.lib-detail-body { display: block; }
/* Split « aperçu | correction » côte à côte, empilé en mobile (media query). */
.lib-detail-body.is-split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); align-items: start; }
.lib-detail .lib-pane { min-width: 0; }
.lib-detail img.preview-img { width: 100%; border-radius: var(--r-md); border: 1px solid var(--border); }
.lib-corr-pills { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-3); }

/* ─── Exos ──────────────────────────────────────────────────────────────────
   Navigation matières/chapitres puis split view : énoncé à gauche, correction
   à droite (corrigé IA / corrections uploadées). + scanner OCR + QCM unifiés. */

/* Étiquette du type d'épreuve (DS, DM, interro, QCM, TD, TP, scan…) */
.kind-tag {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; padding: 2px var(--sp-2);
  border-radius: var(--r-sm); font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: .02em;
}
.kind-tag[data-k="ds"], .kind-tag[data-k="cb"] { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.kind-tag[data-k="dm"], .kind-tag[data-k="interro"] { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.kind-tag[data-k="qcm"] { background: var(--info-soft); color: var(--info); border-color: transparent; }
.kind-tag[data-k="td"], .kind-tag[data-k="tp"], .kind-tag[data-k="tne"] { background: var(--success-soft); color: var(--success); border-color: transparent; }
.kind-tag[data-k="scan"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* Chip de chapitre active */
.chip.chip-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: var(--fw-semibold); }


.exo-head { display: flex; align-items: center; gap: var(--sp-3); margin: var(--sp-2) 0 var(--sp-4); min-width: 0; }
.exo-head h2 { font-size: var(--fs-xl); min-width: 0; }
.exo-head #exFsBtn { flex: none; }

/* ═══ Sélecteur d'exos — surfaces browse (cartes matières + liste d'une
   matière). Refonte « mockup » : Instrument Serif pour titres/glyphes, Manrope
   pour le reste, pastels par matière, slider de difficulté draggable. Toutes
   les classes sont préfixées .exsel- pour éviter les collisions. Le reste du
   site garde Inter. ═══════════════════════════════════════════════════════ */

/* Alias de fontes locaux à la surface (fallback système si le <link> Google
   Fonts n'a pas chargé). */
.view-exos { --exsel-serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
             --exsel-sans: 'Manrope', var(--font-sans, system-ui, sans-serif); }

/* ─── Cartes matières ─────────────────────────────────────────────────────── */
.exsel-head { margin-bottom: var(--sp-4); }
.exsel-head-title {
  font-family: var(--exsel-serif); font-weight: 400;
  font-size: 28px; line-height: 1.1; color: var(--text);
}
.exsel-head-sub {
  font-family: var(--exsel-sans); font-weight: 500;
  font-size: var(--fs-sm); color: var(--text-3); margin-top: 2px;
}
.exsel-grid { display: grid; gap: 14px; grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) {
  .exsel-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}
/* Accent stable par matière : accent = hsl(h 55% 45%), fond = hsl(h 80% 93%)
   (variantes sombres plus bas). --exsel-h posé inline en JS. */
.exsel-card {
  --ac: hsl(var(--exsel-h, 250) 55% 45%);
  --acbg: hsl(var(--exsel-h, 250) 80% 93%);
  display: flex; flex-direction: column; gap: 12px; text-align: left;
  padding: 18px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow-xs);
  transition: transform .2s cubic-bezier(.2,.8,.3,1), box-shadow .25s, border-color .2s;
}
.exsel-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 18px 34px -20px rgba(2,6,23,.5);
  border-color: color-mix(in srgb, var(--ac) 45%, var(--border));
}
.exsel-card-ic {
  display: flex; align-items: center; justify-content: center; flex: none;
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--acbg); color: var(--ac);
  font-family: var(--exsel-serif); font-size: 27px; line-height: 1;
}
.exsel-card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.exsel-card-name { font-family: var(--exsel-sans); font-weight: 700; font-size: 17px; color: var(--text); }
.exsel-card-meta { font-family: var(--exsel-sans); font-weight: 600; font-size: 12px; color: var(--text-3); margin-top: 2px; }
@media (prefers-reduced-motion: reduce) { .exsel-card:hover { transform: none; } }

/* ─── Header de matière (remplace l'ancien hero) ─────────────────────────────
   Dégradé accentBg→surface, glyphe blanc, barre tricolore + légende à droite,
   bouton « Changer » pour revenir aux matières. */
.exsel-subject-head {
  --ac: hsl(var(--exsel-h, 250) 55% 45%);
  --acbg: hsl(var(--exsel-h, 250) 80% 93%);
  display: flex; flex-direction: column; align-items: stretch;
  gap: 14px;
  padding: 16px 22px 18px; margin-bottom: var(--sp-4);
  background: linear-gradient(135deg, var(--acbg), var(--surface));
  border: 1px solid var(--border); border-radius: 18px;
  animation: exselIn .5s ease both;
}
/* Rangée titre + répartition des difficultés, sous le bouton retour. */
.exsel-sh-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 20px; flex-wrap: wrap;
}
.exsel-sh-left { display: flex; gap: 16px; align-items: center; min-width: 0; }
.exsel-sh-ic {
  flex: none; width: 60px; height: 60px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); font-size: 30px; line-height: 1;
  box-shadow: 0 4px 12px rgba(2,6,23,.1);
}
.exsel-sh-titles { min-width: 0; }
.exsel-sh-name { font-family: var(--exsel-serif); font-weight: 400; font-size: 30px; line-height: 1; color: var(--text); }
.exsel-sh-meta { font-family: var(--exsel-sans); font-weight: 600; font-size: 13px; color: var(--text-2); margin-top: 3px; }
.exsel-sh-back {
  align-self: flex-start; flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border: 1px solid var(--border); color: var(--text-2);
  font-family: var(--exsel-sans); font-weight: 600; font-size: 12.5px;
  padding: 6px 13px; border-radius: 999px; cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: background var(--t), color var(--t), transform var(--t);
}
.exsel-sh-back:hover { background: var(--surface); color: var(--text); transform: translateX(-2px); }
@media (prefers-reduced-motion: reduce) { .exsel-sh-back:hover { transform: none; } }
.exsel-sh-diff { min-width: 210px; }
.exsel-sh-bar {
  height: 9px; border-radius: 999px; overflow: hidden; display: flex;
  background: var(--surface-3);
}
.exsel-sh-bar span { display: block; }
.exsel-sh-legend {
  display: flex; flex-direction: column; gap: 1px; margin-top: 8px;
  font-family: var(--exsel-sans); font-weight: 600; font-size: 12px; color: var(--text-2);
}
.exsel-lg { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.exsel-lg-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* ─── Recherche + type ────────────────────────────────────────────────────── */
.exsel-search-row { display: flex; gap: var(--sp-3); align-items: center; margin-bottom: var(--sp-4); }
.exsel-search { position: relative; flex: 1 1 auto; min-width: 0; }
.exsel-search-ic {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); pointer-events: none; font-size: 15px;
}
.exsel-search-input {
  width: 100%; padding: 14px 16px 14px 40px;
  border: 1px solid var(--border); border-radius: 14px;
  font-family: var(--exsel-sans); font-size: 15px;
  color: var(--text); background: var(--surface); outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.exsel-search-input::placeholder { color: var(--text-3); }
.exsel-search-input:focus { border-color: #4f46e5; box-shadow: 0 0 0 4px rgba(79,70,229,.12); }
.exsel-kind {
  flex: none; border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 14px; background: var(--surface); color: var(--text);
  font-family: var(--exsel-sans); font-size: 14px; cursor: pointer;
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.exsel-kind:focus { border-color: #4f46e5; box-shadow: 0 0 0 4px rgba(79,70,229,.12); }

/* ─── Chips de thèmes (palette pastel PAL cyclée, --cbg/--cfg posés en JS) ──── */
.exsel-chips { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: var(--sp-4); }
.exsel-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; border: 1px solid transparent; border-radius: 999px;
  background: var(--cbg, var(--surface-2)); color: var(--cfg, var(--text-2));
  font-family: var(--exsel-sans); font-weight: 600; font-size: 14px;
  cursor: pointer; max-width: 100%; min-width: 0;
  transition: transform .15s, box-shadow .2s, background .2s, color .2s;
}
.exsel-chip-lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exsel-chip:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(2,6,23,.12); }
.exsel-chip-n {
  flex: none; background: rgb(2 6 23 / .06); color: inherit; border-radius: 999px;
  padding: 1px 8px; font-size: 12px; font-weight: 700;
}
.exsel-chip.is-active { background: #4f46e5; color: #fff; border-color: #4f46e5; }
.exsel-chip.is-active .exsel-chip-n { background: rgb(255 255 255 / .24); color: #fff; }
@media (prefers-reduced-motion: reduce) { .exsel-chip:hover { transform: none; } }

/* ─── Liste d'exos (lignes du mockup) ─────────────────────────────────────────
   Liseré gauche = couleur du niveau (--lv, gris neutre si aucune), pastille
   ronde sur fond pastel du tier (--lvbg/--lvfg), badge tier à droite. */
.exsel-list {
  display: flex; flex-direction: column; gap: 9px;
  max-height: 420px; overflow: auto; padding-right: 6px;
}
.exsel-row {
  display: flex; align-items: center; gap: 16px; width: 100%; text-align: left;
  padding: 13px 16px; background: var(--surface);
  border: 1px solid var(--border); border-left: 4px solid var(--lv, var(--border-strong));
  border-radius: 14px; cursor: pointer;
  animation: exselRowIn .45s cubic-bezier(.2,.7,.3,1) both;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}
.exsel-row:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.exsel-row:focus-visible { outline: none; box-shadow: var(--ring); }
.exsel-row-num {
  flex: none; width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--lvbg, var(--surface-2)); color: var(--lvfg, var(--text-2));
  font-family: var(--exsel-sans); font-weight: 700; font-size: 15px;
}
.exsel-row-num .ico { width: 18px; height: 18px; }
.exsel-row-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.exsel-row-title { font-family: var(--exsel-sans); font-weight: 700; font-size: 15px; color: var(--text); }
.exsel-row-meta {
  font-family: var(--exsel-sans); font-weight: 600; font-size: 12px; color: var(--text-3);
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
}
.exsel-row-chap {
  display: inline-flex; padding: 1px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.exsel-row-flag { display: inline-flex; align-items: center; gap: 3px; color: var(--accent); }
.exsel-row-flag .ico { width: 12px; height: 12px; }
.exsel-row-badge {
  flex: none; display: flex; align-items: center; gap: 7px;
  background: var(--lvbg); color: var(--lvfg);
  padding: 6px 12px; border-radius: 999px;
  font-family: var(--exsel-sans); font-weight: 600; font-size: 12px; white-space: nowrap;
}
.exsel-row-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--lv); }
#exList .empty { border-radius: 18px; }
@keyframes exselRowIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes exselIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .exsel-row:hover { transform: none; }
  .exsel-row, .exsel-subject-head { animation: none; }
}

/* ─── Adaptations thème sombre : accents remontés, pastels des chips atténués.
   Les pastilles/badges des lignes gardent leurs pastels (pilules claires qui
   ressortent sur fond sombre, comme dans le mockup). ─────────────────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .exsel-card,
  :root:not([data-theme="light"]) .exsel-subject-head {
    --ac: hsl(var(--exsel-h, 250) 70% 72%);
    --acbg: hsl(var(--exsel-h, 250) 45% 45% / .18);
  }
  :root:not([data-theme="light"]) .exsel-chip:not(.is-active) {
    background: color-mix(in srgb, var(--cbg, var(--surface-2)) 24%, var(--surface-2));
    color: color-mix(in srgb, var(--cfg, var(--text-2)) 60%, #fff);
  }
  :root:not([data-theme="light"]) .exsel-chip-n { background: rgb(255 255 255 / .09); }
}
:root[data-theme="dark"] .exsel-card,
:root[data-theme="dark"] .exsel-subject-head {
  --ac: hsl(var(--exsel-h, 250) 70% 72%);
  --acbg: hsl(var(--exsel-h, 250) 45% 45% / .18);
}
:root[data-theme="dark"] .exsel-chip:not(.is-active) {
  background: color-mix(in srgb, var(--cbg, var(--surface-2)) 24%, var(--surface-2));
  color: color-mix(in srgb, var(--cfg, var(--text-2)) 60%, #fff);
}
:root[data-theme="dark"] .exsel-chip-n { background: rgb(255 255 255 / .09); }

/* ─── Bloc difficulté (carte + slider draggable à 3 zones, façon mockup) ──────
   Carte surface-2, en-tête « DIFFICULTÉ » + libellé du tier en serif coloré,
   bouton « Tous niveaux », compteur animé, et un track draggable dont le knob
   snappe sur 3 zones. Position/couleurs du knob+tooltip posées inline en JS. */
.exsel-diff {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 18px; padding: 20px 22px; margin-bottom: var(--sp-5);
  display: flex; flex-direction: column; gap: 14px;
}
.exsel-diff-top { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--sp-3); flex-wrap: wrap; }
.exsel-diff-kicker {
  font-family: var(--exsel-sans); font-weight: 700; font-size: 12px;
  color: var(--text-3); text-transform: uppercase; letter-spacing: .09em;
}
.exsel-diff-tier { font-family: var(--exsel-serif); font-weight: 400; font-size: 26px; line-height: 1.1; margin-top: 2px; }
.exsel-diff-right { display: flex; align-items: center; gap: 14px; }
.exsel-diff-all {
  background: var(--surface); color: var(--text-2); border: 1px solid var(--border);
  font-family: var(--exsel-sans); font-weight: 600; font-size: 13px;
  padding: 8px 14px; border-radius: 10px; cursor: pointer; transition: all .2s;
}
.exsel-diff-all.is-on { background: #0f172a; color: #fff; border-color: #0f172a; }
.exsel-diff-count { text-align: right; }
.exsel-diff-num { font-family: var(--exsel-sans); font-weight: 800; font-size: 36px; line-height: 1; color: var(--text); }
.exsel-diff-lbl { font-family: var(--exsel-sans); font-weight: 600; font-size: 12px; color: var(--text-3); }

/* Slider : padding-top réserve la place du tooltip flottant. */
.exsel-slider-pad { position: relative; padding-top: 44px; }
.exsel-tip { position: absolute; top: 0; left: 16.67%; transform: translateX(-50%); pointer-events: none; }
.exsel-tip-bubble {
  font-family: var(--exsel-sans); font-weight: 700; font-size: 12px; color: #fff;
  padding: 5px 11px; border-radius: 8px; white-space: nowrap;
  box-shadow: 0 6px 14px rgba(2,6,23,.22); background: #16a34a;
}
.exsel-tip-arrow { width: 9px; height: 9px; background: #16a34a; transform: rotate(45deg); margin: -5px auto 0; }
.exsel-track {
  position: relative; height: 60px; border-radius: 16px;
  background: linear-gradient(90deg, #dcfce7, #fef3c7 50%, #fee2e2);
  cursor: grab; touch-action: none; overflow: hidden; outline: none;
  box-shadow: inset 0 1px 3px rgb(0 0 0 / .08);
}
.exsel-track:active { cursor: grabbing; }
.exsel-track:focus-visible { box-shadow: inset 0 1px 3px rgb(0 0 0 / .08), 0 0 0 3px rgba(79,70,229,.4); }
.exsel-zones { position: absolute; inset: 0; display: flex; }
.exsel-zone {
  flex: 1; display: flex; align-items: center; justify-content: center;
  font-family: var(--exsel-sans); font-weight: 700; font-size: 13px;
  text-align: center; padding: 0 6px; overflow: hidden;
}
.exsel-zone-1 { color: #166534; }
.exsel-zone-2 { color: #92400e; border-left: 2px solid rgb(255 255 255 / .7); border-right: 2px solid rgb(255 255 255 / .7); }
.exsel-zone-3 { color: #991b1b; }
.exsel-mark {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 5px; height: 5px; border-radius: 50%; background: rgb(15 23 42 / .18);
}
.exsel-knob {
  position: absolute; top: 50%; left: 16.67%; transform: translate(-50%, -50%);
  width: 44px; height: 50px; border-radius: 14px;
  background: #fff; border: 2px solid #16a34a; box-shadow: 0 8px 20px rgb(2 6 23 / .28);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.exsel-knob-cap {
  position: absolute; top: 0; left: 8px; right: 8px; height: 5px;
  border-radius: 0 0 6px 6px; background: #16a34a;
}
.exsel-knob-bar { width: 16px; height: 2px; border-radius: 2px; background: #cbd5e1; }
@media (prefers-reduced-motion: reduce) {
  .exsel-knob, .exsel-tip { transition: none !important; }
}

/* Lien « Extrait de : … » sous le titre d'un exo issu d'une fiche PDF */
.exo-origin { margin: calc(-1 * var(--sp-2)) 0 var(--sp-4); }
.exo-origin:empty { display: none; }
.exo-origin-link {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  font-size: var(--fs-sm); color: var(--text-3); cursor: pointer;
}
.exo-origin-link .ico { width: 14px; height: 14px; }
.exo-origin-link:hover { color: var(--accent); }

/* Le split : les deux panneaux remplissent l'écran, scroll interne chacun. */
.exo-split {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--sp-4); align-items: stretch;
  min-height: calc(100vh - var(--topbar-h) - 210px);
}
/* Plein écran du détail : #exBody passe en overlay fixe, fil d'Ariane + en-tête
   restent visibles en haut (← Retour accessible), le split occupe le reste. */
.exo-full {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: flex; flex-direction: column;
  padding: var(--sp-3) var(--sp-5);
  overflow: hidden;
}
.exo-full .exo-split { flex: 1 1 auto; min-height: 0; }
.exo-pane { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.exo-pane-head {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
}
.exo-pane-head h3 { font-size: var(--fs-md); color: var(--text-2); }
.exo-corr-actions { display: flex; gap: var(--sp-1); align-items: center; }
.exo-corr-switch { display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4) 0; }
.exo-corr-switch:empty { display: none; }
.exo-corr-switch .chip .ico { width: 14px; height: 14px; }

/* Barre « Génère une correction avec l'IA » + ruban de choix d'IA.
   Gemini est la seule option branchée ; Claude/ChatGPT restent visibles
   mais grisés (connexion de compte prévue plus tard). */
.exo-genbar {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.exo-genbar:empty { display: none; }
.exo-genbar .btn .ico { width: 14px; height: 14px; }
.ai-ribbon { position: relative; }
.ai-ribbon-cur {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-xs); color: var(--text-2);
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); padding: 3px 10px; cursor: pointer;
}
.ai-ribbon-cur:hover { border-color: var(--accent); color: var(--text-1); }
.ai-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok, #34a853); flex: none;
}
.ai-tag {
  font-size: 10px; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 999px; padding: 1px 7px; white-space: nowrap;
}
.ai-caret { font-size: 9px; color: var(--text-3); }
.ai-ribbon-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 240px; padding: var(--sp-1);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-2, 0 8px 24px rgba(0,0,0,.18));
}
.ai-opt {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%;
  padding: var(--sp-2) var(--sp-3); border: 0; background: none;
  border-radius: var(--r-sm); font-size: var(--fs-sm); color: var(--text-1);
  cursor: pointer; text-align: left;
}
.ai-opt:hover:not(:disabled) { background: var(--surface-2); }
.ai-opt:disabled { opacity: .45; cursor: not-allowed; }
.ai-opt:disabled .ai-tag { color: var(--text-3); background: var(--surface-2); }
.ai-opt .ai-name { font-weight: 600; }
.ai-opt .ai-check { margin-left: auto; color: var(--ok, #34a853); font-weight: 700; }
.exo-pane-body { flex: 1 1 auto; overflow-y: auto; padding: var(--sp-4); min-height: 0; }
.exo-frame { width: 100%; height: 100%; min-height: 460px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.exo-img { width: 100%; border-radius: var(--r-md); border: 1px solid var(--border); }

/* Rendu « feuille A4 » : fond blanc + texte noir quel que soit le thème,
   pour que corrections et énoncés markdown ressemblent aux PDF de fiches. */
.paper-sheet {
  background: #fff; color: #111;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: clamp(18px, 5%, 44px);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 10px; line-height: 1.55;   /* taille d'une fiche imprimée */
  box-shadow: 0 1px 4px rgba(0, 0, 0, .08);
}
/* Jamais de barre de défilement horizontale : les formules trop larges sont
   réduites par fitMath() pour tenir dans la colonne (voir markdown.js). */
.paper-sheet mjx-container[display="true"] { overflow: hidden; max-width: 100%; }
.paper-sheet h1, .paper-sheet h2, .paper-sheet h3, .paper-sheet h4 {
  color: #111; font-family: inherit; margin: 1.1em 0 .45em;
}
.paper-sheet h2 { font-size: 1.25em; border-bottom: 1px solid #ddd; padding-bottom: .2em; }
.paper-sheet h3 { font-size: 1.08em; }
.paper-sheet strong { color: #000; }
.paper-sheet a { color: #1a4b8c; }
.paper-sheet hr { border: none; border-top: 1px solid #ddd; }
.paper-sheet code { background: #f4f4f2; color: #111; }
.paper-sheet pre { background: #f4f4f2; color: #111; border: 1px solid #e2e2df; }
.paper-sheet table { border-collapse: collapse; }
.paper-sheet th, .paper-sheet td { border: 1px solid #bbb; padding: 3px 9px; color: #111; }
.paper-sheet blockquote { border-left: 3px solid #ccc; color: #444; }
.paper-sheet mjx-container { color: #111; }

/* Visionneuse PDF locale (pdfview.js) */
.pdfv { display: flex; flex-direction: column; gap: var(--sp-2); }
.pdfv-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); position: sticky; top: 0; z-index: 2; background: var(--surface-1); padding: 2px 0; }
.pdfv-tools { display: flex; align-items: center; gap: 2px; }
.pdfv-pages { display: flex; flex-direction: column; gap: var(--sp-2); }
.pdfv-page { border: 1px solid var(--border); border-radius: var(--r-sm); background: #fff; line-height: 0; overflow-x: auto; }
.pdfv-page canvas { max-width: none; border-radius: var(--r-sm); }
/* Présentation homogène des deux volets du split : les pages PDF (énoncé ou
   correction, rendues par pdfview.js) partagent le même cadre « feuille » que
   le markdown (.paper-sheet) — fond blanc, ombre légère. Portée limitée au
   split des exos pour ne pas toucher la visionneuse de la Bibliothèque. */
.exo-pane-body .pdfv-page { box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }

.exo-empty { border: none; padding: var(--sp-8) var(--sp-4); }
.exo-pending { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-4) 0; }

@media (max-width: 980px) {
  .exo-split { grid-template-columns: 1fr; min-height: 0; }
  .exo-frame { min-height: 320px; }
  /* Plein écran empilé : deux rangées égales, chaque .exo-pane-body scrolle. */
  .exo-full .exo-split { grid-template-rows: 1fr 1fr; }
  .exo-full .exo-pane { min-height: 0; }
}
/* Header de matière empilé sous 860px : la barre tricolore passe sous le titre,
   le bouton « Changer » se replie proprement. */
@media (max-width: 860px) {
  .exsel-subject-head { padding: 16px; gap: var(--sp-3); }
  .exsel-sh-ic { width: 48px; height: 48px; font-size: 26px; }
  .exsel-sh-row { gap: var(--sp-3); }
  .exsel-sh-diff { width: 100%; min-width: 0; }
}
@media (max-width: 560px) {
  /* Bloc difficulté empilé : compteur sous le libellé plutôt qu'à droite. */
  .exsel-diff-top { align-items: flex-start; }
  .exsel-zone { font-size: 11px; }
  .exsel-search-row { flex-wrap: wrap; }
  .exsel-kind { flex: 1 1 100%; }
  /* La view-head (titre + segmented + Scanner) ne tient pas sur une ligne à
     375px et forçait TOUTE la vue à déborder horizontalement — on la laisse
     passer à la ligne. (Portée : vue Exos seulement, prudence.) */
  .view-exos .view-head { flex-wrap: wrap; }
}

/* ─── Scanner OCR ───────────────────────────────────────────────────────── */
.scan-dialog { max-width: 560px; }
.scan-dialog-wide { max-width: 1080px; width: calc(100% - 48px); }
.scan-thumbs { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }
.scan-thumb { width: 84px; height: 84px; object-fit: cover; border-radius: var(--r-md); border: 1px solid var(--border); }
.scan-result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.scan-md { min-height: 320px; font-family: var(--font-mono); font-size: var(--fs-sm); }
.scan-preview { min-height: 320px; max-height: 440px; overflow-y: auto; }
.scan-save-row { display: flex; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-2); }
.scan-save-row .field { flex: 1; min-width: 120px; margin-bottom: 0; }
@media (max-width: 860px) { .scan-result-grid { grid-template-columns: 1fr; } }

/* ─── QCM (présentation unifiée) ────────────────────────────────────────── */
.qcm-q { padding: var(--sp-4) 0; border-bottom: 1px solid var(--border); }
.qcm-q:last-child { border-bottom: none; }
.qcm-q-title { margin-bottom: var(--sp-3); line-height: var(--lh-relaxed); }
.qcm-q-title span > p { display: inline; }
.qcm-choices { display: flex; flex-direction: column; gap: var(--sp-2); }
.qcm-choice {
  text-align: left; padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
  transition: border-color var(--t), background var(--t);
}
.qcm-choice:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.qcm-choice > p { display: inline; margin: 0; }
.qcm-choice.good { border-color: var(--success); background: var(--success-soft); }
.qcm-choice.bad  { border-color: var(--danger); background: var(--danger-soft); }
.qcm-choice:disabled { cursor: default; opacity: 1; }
.qcm-expl { margin-top: var(--sp-3); padding: var(--sp-3); border-radius: var(--r-md); background: var(--info-soft); font-size: var(--fs-sm); }

/* ─── Upload ────────────────────────────────────────────────────────────── */
.upload-grid { display: grid; grid-template-columns: 1fr; gap: var(--sp-4); }
@media (min-width: 760px) { .upload-grid { grid-template-columns: 2fr 1fr; } }

/* ─── Coming-soon / TODO placeholder ────────────────────────────────────── */
.todo-card { display: flex; flex-direction: column; gap: var(--sp-2); align-items: flex-start; padding: var(--sp-5); }
.todo-card .badge { background: var(--warning-soft); color: var(--warning); }

/* ─── Responsive: rail → bottom tab bar on narrow screens ───────────────── */
@media (max-width: 720px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr auto;
    grid-template-areas: "topbar" "main" "rail";
  }
  /* Sans min-width:0, la colonne 1fr gonfle au min-content du topbar/main et
     TOUTE l'app déborde horizontalement (509px vus dans 375px). */
  .topbar, .main, .rail { min-width: 0; }
  .rail {
    flex-direction: row; border-right: none; border-top: 1px solid var(--border);
    padding: var(--sp-1) var(--sp-2); overflow-x: auto;
  }
  .rail-brand, .rail-sep, .rail-foot { display: none; }
  .rail-nav { flex-direction: row; gap: var(--sp-1); }
  .nav-item { flex-direction: column; gap: 2px; font-size: var(--fs-xs); padding: var(--sp-1) var(--sp-2); }
  .nav-item[aria-current="page"]::before { display: none; }
  .nav-item .nav-label { display: block !important; }
  .lib-detail-body.is-split { grid-template-columns: 1fr; }
  .topbar .cmd-trigger kbd { display: none; }
  /* Le libellé de recherche doit pouvoir rétrécir (ellipse), et la pastille
     d'état garde juste son point coloré — sinon la topbar déborde à 375px. */
  .topbar .cmd-trigger { min-width: 0; }
  .topbar .cmd-trigger span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .status-pill span:not(.dot) { display: none; }
}

/* ═══ Signalements : bouton, modal, page Tickets ═════════════════════════════
   Réutilise l'esprit exsel (Manrope, pastels, pilules). Couleurs pilotées par
   --tkbg / --tkfg posées en JS depuis la table des raisons. */

/* Bouton « 🚩 Signaler » discret. */
.report-btn { color: var(--text-3); }
.report-btn:hover { color: var(--danger); background: var(--danger-soft); }

/* ── Modal ── */
.report-dialog { max-width: 440px; width: calc(100vw - 32px); }
.report-dialog .report-target {
  font-size: var(--fs-sm); margin-bottom: var(--sp-4);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--border);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.report-reasons { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.report-chip {
  padding: 7px 13px; border-radius: var(--r-full);
  background: var(--surface-2); border: 1.5px solid transparent;
  color: var(--text-2); font-weight: var(--fw-semibold); font-size: var(--fs-sm);
  cursor: pointer; transition: transform .15s var(--ease), box-shadow .2s, background .2s, color .2s;
}
.report-chip:hover { transform: translateY(-2px); }
.report-chip.is-active {
  background: var(--tkbg, var(--accent-soft)); color: var(--tkfg, var(--accent));
  border-color: color-mix(in srgb, var(--tkfg, var(--accent)) 45%, transparent);
  box-shadow: 0 4px 12px -4px rgba(2,6,23,.25);
}
@media (prefers-reduced-motion: reduce) { .report-chip:hover { transform: none; } }

/* ── Page Tickets ── */
.tk-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.tk-card {
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--accent); border-radius: 16px;
  box-shadow: var(--shadow-xs);
  animation: exselRowIn .4s cubic-bezier(.2,.7,.3,1) both;
}
.tk-card.tk-resolved { border-left-color: var(--border-strong); opacity: .72; }
.tk-top { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-2); }
.tk-reason {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 11px; border-radius: var(--r-full);
  background: var(--tkbg, var(--surface-2)); color: var(--tkfg, var(--text-2));
  font-weight: var(--fw-bold); font-size: var(--fs-xs);
}
.tk-type { font-size: var(--fs-xs); color: var(--text-3); font-weight: var(--fw-medium); }
.tk-status { font-size: var(--fs-xs); font-weight: var(--fw-bold); padding: 2px 9px; border-radius: var(--r-full); }
.tk-status.is-open { background: var(--warning-soft); color: var(--warning); }
.tk-status.is-done { background: var(--success-soft); color: var(--success); }
.tk-target {
  display: block; max-width: 100%; text-align: left;
  font-weight: var(--fw-semibold); font-size: var(--fs-md); color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-decoration: underline dotted var(--border-strong); text-underline-offset: 3px;
}
.tk-target:hover:not(:disabled) { color: var(--accent); }
.tk-target:disabled { text-decoration: none; cursor: default; }
.tk-msg {
  margin-top: var(--sp-2); font-size: var(--fs-sm); color: var(--text-2);
  line-height: var(--lh-normal); white-space: pre-wrap;
  padding: var(--sp-2) var(--sp-3); background: var(--surface-2); border-radius: var(--r-md);
}
.tk-foot { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-3); }
.tk-author { font-size: var(--fs-xs); color: var(--text-3); }

/* ═══════════════════════════════════════════════════════════════════════════
   HOMOGÉNÉISATION « exsel » — le reste du site aligné sur l'esprit de la
   section Exos : titres Instrument Serif, libellés Manrope, cartes à hue par
   matière, hover lift springy, chips pastel, entrées en stagger. Tout en
   transform/opacity (GPU-friendly), reduced-motion respecté.
   ═══════════════════════════════════════════════════════════════════════════ */

/* — En-têtes de page : grand titre serif, comme .exsel-head-title — */
.view-head h1 {
  font-family: var(--font-serif); font-weight: 400;
  font-size: 30px; line-height: 1.1; letter-spacing: 0;
}
.view-head { align-items: baseline; }
/* Les h2 de section (« File d'attente », etc.) prennent aussi le serif. */
.view-inner > h2,
.card-pad > h3 { font-family: var(--font-serif); font-weight: 400; letter-spacing: 0; }
.view-inner > h2 { font-size: 22px; }
.card-pad > h3 { font-size: 20px; }

/* Petite entrée en fondu montant, réutilisable, avec délai plafonné. */
@keyframes hzIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* — Boutons : rebond léger au clic (ne touche pas aux couleurs) — */
.btn { transition: background var(--t), border-color var(--t), color var(--t),
                   transform var(--dur-fast) cubic-bezier(.2,.8,.3,1); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.98); }
@media (prefers-reduced-motion: reduce) { .btn:active:not(:disabled) { transform: none; } }

/* ─── Bibliothèque : cartes matières joyeuses (hue posé en JS via --exsel-h) ── */
.subject-grid { gap: 14px; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); }
.subject-card {
  --ac: hsl(var(--exsel-h, 250) 55% 45%);
  --acbg: hsl(var(--exsel-h, 250) 80% 93%);
  gap: 14px; padding: 18px; border-radius: 18px;
  border: 1px solid var(--border); box-shadow: var(--shadow-xs);
  transition: transform .2s cubic-bezier(.2,.8,.3,1), box-shadow .25s, border-color .2s;
  animation: hzIn .45s cubic-bezier(.2,.7,.3,1) both;
}
.subject-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 18px 34px -20px rgba(2,6,23,.5);
  border-color: color-mix(in srgb, var(--ac) 45%, var(--border));
}
.subject-card .sc-ic {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--acbg); color: var(--ac);
  font-family: var(--font-serif); font-size: 26px; line-height: 1;
}
/* Glyphe emoji injecté par le JS : on masque l'icône SVG de repli si présent. */
.subject-card .sc-ic[data-glyph] .ico { display: none; }
.subject-card .sc-name { font-family: var(--font-display); font-weight: 700; font-size: 17px; }
.subject-card .sc-meta { font-family: var(--font-display); font-weight: 600; }
.subject-card .sc-chev { transition: opacity var(--t), transform var(--t); }
.subject-card:hover .sc-chev { transform: translateX(3px); }

/* Lignes de fichiers : léger lift + liseré accent au survol. */
.lib-rows { gap: 6px; }
.lib-row {
  border-radius: 12px;
  transition: background var(--t), border-color var(--t), transform var(--dur-fast) var(--ease);
}
.lib-row:hover { transform: translateX(3px); }
@media (prefers-reduced-motion: reduce) {
  .subject-card { animation: none; }
  .subject-card:hover, .lib-row:hover, .subject-card:hover .sc-chev { transform: none; }
}

/* Dégradé de retrait pour un stagger léger (plafonné à 6 cartes). */
.subject-card:nth-child(1) { animation-delay: .02s; }
.subject-card:nth-child(2) { animation-delay: .06s; }
.subject-card:nth-child(3) { animation-delay: .10s; }
.subject-card:nth-child(4) { animation-delay: .14s; }
.subject-card:nth-child(5) { animation-delay: .18s; }
.subject-card:nth-child(n+6) { animation-delay: .22s; }

/* ─── Dépôt : dropzone vivante + pulse de succès ────────────────────────────── */
.dropzone {
  border-radius: 18px; gap: var(--sp-3);
  transition: border-color var(--t), background var(--t), transform var(--dur) cubic-bezier(.2,.8,.3,1);
}
.dropzone .dz-icon { transition: transform var(--dur) cubic-bezier(.2,.8,.3,1); }
.dropzone:hover .dz-icon { transform: translateY(-3px) scale(1.06); }
.dropzone.dragover {
  transform: scale(1.015);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border-color: var(--accent);
}
.dropzone.dragover .dz-icon { transform: translateY(-4px) scale(1.14) rotate(-4deg); }
/* Pulse joyeux quand un envoi réussit (classe posée par upload.js). */
.dropzone.up-ok { animation: dzPop .5s cubic-bezier(.2,.8,.3,1); border-color: var(--success); }
@keyframes dzPop { 0% { transform: scale(1); } 40% { transform: scale(1.03); box-shadow: 0 0 0 6px var(--success-soft); } 100% { transform: scale(1); } }

/* Micro-confettis CSS purs (pas d'image) émis au succès, retirés par le JS. */
.confetti-burst { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.confetti-burst i {
  position: absolute; top: 50%; left: 50%; width: 8px; height: 8px; border-radius: 2px;
  background: var(--c, var(--accent)); opacity: 0;
  animation: confetti .8s ease-out forwards;
}
@keyframes confetti {
  0% { opacity: 1; transform: translate(-50%, -50%) rotate(0); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(320deg); }
}
.up-wrap { position: relative; }
@media (prefers-reduced-motion: reduce) {
  .dropzone:hover, .dropzone.dragover, .dropzone:hover .dz-icon,
  .dropzone.dragover .dz-icon, .dropzone.up-ok { transform: none; animation: none; }
  .confetti-burst { display: none; }
}

/* File d'attente / progress : entrée douce + états colorés joyeux. */
.queue-item { border-radius: 14px; animation: hzIn .4s cubic-bezier(.2,.7,.3,1) both; }
.badge { font-family: var(--font-display); font-weight: 700; }
.badge.done { animation: badgePop .4s cubic-bezier(.2,.8,.3,1); }
@keyframes badgePop { 0% { transform: scale(.7); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .queue-item, .badge.done { animation: none; } }

/* ─── Activité + Compte : cartes stat vivantes, chiffres display ────────────── */
.stat-card {
  border-radius: 16px;
  transition: transform .2s cubic-bezier(.2,.8,.3,1), box-shadow .25s, border-color .2s;
  animation: hzIn .45s cubic-bezier(.2,.7,.3,1) both;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.stat-card .stat-value { font-family: var(--font-display); font-weight: 800; letter-spacing: -.02em; }
.stat-card .stat-label { font-family: var(--font-display); font-weight: 600; }
.stat-grid .stat-card:nth-child(2) { animation-delay: .05s; }
.stat-grid .stat-card:nth-child(3) { animation-delay: .10s; }
.stat-grid .stat-card:nth-child(4) { animation-delay: .15s; }
@media (prefers-reduced-motion: reduce) { .stat-card { animation: none; } .stat-card:hover { transform: none; } }

/* Cartes de contenu (Compte, Photos→PDF…) : coins plus doux. */
.card { border-radius: 16px; }

/* Classement : lignes façon pilules, médailles mises en avant. */
#accBoard .lib-row { padding: var(--sp-2) var(--sp-3); border-radius: 12px; animation: hzIn .4s ease both; }
#accBoard .kind-tag {
  font-size: 15px; min-width: 34px; background: transparent; border-color: transparent;
}

/* ─── Empty states : Neko plus expressif, phrases fun (dans le JS) ──────────── */
.empty { border-radius: 18px; gap: var(--sp-4); }
.empty .neko-empty { animation: nekoBob 4s var(--ease) infinite; }
.empty h3 { font-family: var(--font-serif); font-weight: 400; font-size: 22px; }
.empty p { font-family: var(--font-display); font-weight: 500; }
@keyframes nekoBob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-5px) rotate(2deg); } }
@media (prefers-reduced-motion: reduce) { .empty .neko-empty { animation: none; } }

/* ─── Toasts : accent Manrope ──────────────────────────────────────────────── */
.toast { border-radius: 14px; font-family: var(--font-display); font-weight: 600; }

/* ─── Demander : accueil plus chaleureux + chips pastel + bulles raffinées ──── */
.ask-title { font-family: var(--font-serif); font-weight: 400; letter-spacing: 0; font-size: 40px; }
.ask-sub { font-family: var(--font-display); font-weight: 500; }
.ask-hero .neko-hero { animation: nekoBob 4.5s var(--ease) infinite; }
@media (prefers-reduced-motion: reduce) { .ask-hero .neko-hero { animation: none; } }
/* Chips de suggestion : pastels cyclés (--cbg/--cfg posés en JS), pop au survol. */
.ask-hero .suggestions .chip {
  font-family: var(--font-display); font-weight: 600;
  background: var(--cbg, var(--surface-2)); border-color: transparent;
  color: var(--cfg, var(--text-2)); border-radius: var(--r-full);
  transition: transform .15s var(--ease), box-shadow .2s, background .2s, color .2s;
  animation: hzIn .5s cubic-bezier(.2,.7,.3,1) both;
}
.ask-hero .suggestions .chip:hover {
  transform: translateY(-3px); box-shadow: 0 8px 18px -8px rgba(2,6,23,.3);
  background: var(--cbg, var(--accent-soft)); color: var(--cfg, var(--accent));
}
.ask-hero .suggestions .chip:nth-child(2) { animation-delay: .05s; }
.ask-hero .suggestions .chip:nth-child(3) { animation-delay: .10s; }
.ask-hero .suggestions .chip:nth-child(4) { animation-delay: .15s; }
@media (prefers-reduced-motion: reduce) {
  .ask-hero .suggestions .chip { animation: none; }
  .ask-hero .suggestions .chip:hover { transform: none; }
}
/* Bulles + rôles : rôle en Manrope, bulle utilisateur plus ronde, entrée douce. */
.msg { animation: hzIn .35s cubic-bezier(.2,.7,.3,1) both; }
.msg .msg-role { font-family: var(--font-display); font-weight: 700; }
.msg.user .bubble { border-radius: 16px 16px 4px 16px; }
.file-card { border-radius: 14px; transition: border-color var(--t), box-shadow var(--t), transform var(--dur) cubic-bezier(.2,.8,.3,1); }
.file-card:hover { transform: translateY(-3px); }
.file-card-stem { font-family: var(--font-display); font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .msg, .file-card:hover { animation: none; transform: none; } }

/* ─── Focus rings accessibles homogènes sur les surfaces cliquables custom ──── */
.subject-card:focus-visible, .lib-row:focus-visible, .stat-card:focus-visible,
.file-card:focus-visible, .nav-item:focus-visible { outline: none; box-shadow: var(--ring); }

/* ─── Adaptations thème sombre (accents remontés, pastels atténués) ─────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .subject-card {
    --ac: hsl(var(--exsel-h, 250) 70% 72%);
    --acbg: hsl(var(--exsel-h, 250) 45% 45% / .18);
  }
  :root:not([data-theme="light"]) .ask-hero .suggestions .chip {
    background: color-mix(in srgb, var(--cbg, var(--surface-2)) 22%, var(--surface-2));
    color: color-mix(in srgb, var(--cfg, var(--text-2)) 55%, #fff);
  }
}
:root[data-theme="dark"] .subject-card {
  --ac: hsl(var(--exsel-h, 250) 70% 72%);
  --acbg: hsl(var(--exsel-h, 250) 45% 45% / .18);
}
:root[data-theme="dark"] .ask-hero .suggestions .chip {
  background: color-mix(in srgb, var(--cbg, var(--surface-2)) 22%, var(--surface-2));
  color: color-mix(in srgb, var(--cfg, var(--text-2)) 55%, #fff);
}

} /* @layer pages */
