/* Grimoire — charte inspirée de dipole-security.fr */
:root {
  --navy: #0B2540;
  --cyan: #29B6E6;
  --blue: #1565C0;
  --blue-light: #5AA7F2;
  --bg: #071B30;
  --bg-deep: #04111F;
  --surface: #0F2E4F;
  --surface-alt: #133A62;
  --line: #1F4269;
  --frame: #2D547E;
  --text: #D5DEE8;
  --muted: #B5C3D3;
  --heading: #FFFFFF;
  --ok: #4ADE9B;
  --warn: #FFC861;
  --danger: #FF8A80;
  --glass: linear-gradient(160deg, rgba(21,101,192,.20), rgba(15,46,79,.35) 55%, rgba(11,37,64,.15));
  --glass-border: rgba(90,167,242,.16);
  --glow: 0 0 0 1px rgba(41,182,230,.25), 0 18px 40px -18px rgba(41,182,230,.35);
  --shadow: 0 22px 44px -20px rgba(0,0,0,.7);
  --font: "Liberation Sans", Arial, Helvetica, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 4px;
  --hex: polygon(25% 4%, 75% 4%, 100% 50%, 75% 96%, 25% 96%, 0 50%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg-deep); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(ellipse 60% 900px at 85% 0, rgba(21,101,192,.38), transparent 70%),
    radial-gradient(ellipse 45% 700px at 0% 18%, rgba(41,182,230,.08), transparent 70%);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
[hidden] { display: none !important; }
h1, h2, h3 { color: var(--heading); line-height: 1.2; margin: 0; }
a { color: var(--cyan); }
small { color: var(--muted); font-weight: 400; }

.kicker {
  margin: 0 0 8px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--cyan);
}
.accent { color: var(--cyan); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px;
  background: rgba(4,17,31,.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 12px;
  font-weight: 700; font-size: .95rem; letter-spacing: .22em; text-transform: uppercase;
  color: var(--heading); text-decoration: none; white-space: nowrap;
}
.logo-mark { width: 34px; height: 34px; }
.brand-sub { display: block; margin-top: 2px; font-size: .6rem; font-weight: 400; color: var(--cyan); letter-spacing: .16em; }
.topnav { display: flex; align-items: center; gap: 18px; }
.navlinks { display: flex; align-items: center; gap: 18px; }
.navlinks .short { display: none; }
.logout-icon { display: none; }
.topnav a { color: var(--muted); text-decoration: none; font-size: .9rem; padding: 6px 2px; border-bottom: 2px solid transparent; }
.topnav a:hover, .topnav a.active { color: var(--heading); border-bottom-color: var(--cyan); }

.credits {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  border-radius: 999px;
  font-size: .85rem;
}
.credits strong { color: var(--heading); font-size: 1rem; }
.credits.low strong { color: var(--warn); }
.credits.empty strong { color: var(--danger); }
.credits .hex { width: 14px; height: 14px; background: var(--cyan); clip-path: var(--hex); }
.credits-label { color: var(--muted); }

.banner {
  padding: 8px 24px; font-size: .85rem; text-align: center;
  background: rgba(255,200,97,.12); color: var(--warn); border-bottom: 1px solid rgba(255,200,97,.25);
}

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px;
  font: inherit; font-size: .92rem; font-weight: 700;
  border: 1px solid transparent; border-radius: var(--radius);
  cursor: pointer; transition: transform .1s, background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--cyan); color: var(--navy); }
.btn-primary:hover:not(:disabled) { background: #4CC6F0; }
.btn-primary small { color: rgba(11,37,64,.7); font-weight: 400; }
.btn-outline { background: transparent; border-color: rgba(213,222,232,.45); color: var(--heading); }
.btn-outline:hover:not(:disabled) { border-color: var(--cyan); color: var(--cyan); }
.btn-ghost { background: transparent; color: var(--muted); padding: 6px 10px; font-weight: 400; }
.btn-ghost:hover { color: var(--heading); }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-block { width: 100%; }
.btn-danger { background: transparent; border-color: rgba(255,138,128,.5); color: var(--danger); }

.form { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--muted); }
input, textarea, select {
  font: inherit; font-size: 1rem; color: var(--heading);
  background: rgba(4,17,31,.6);
  border: 1px solid var(--frame); border-radius: var(--radius);
  padding: 10px 12px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(41,182,230,.18); }
.form-error { min-height: 1.2em; margin: 12px 0 0; color: var(--danger); font-size: .88rem; }

.card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card-lite { background: rgba(15,46,79,.45); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tab {
  flex: 1; padding: 10px 12px; font: inherit; font-size: .9rem; font-weight: 700;
  color: var(--muted); background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer;
}
.tab.active { color: var(--heading); border-bottom-color: var(--cyan); }
.tabs-inline .tab { flex: 0 0 auto; padding: 10px 18px; }

main { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }

/* ---------- Auth ---------- */
.auth {
  flex: 1; display: grid; grid-template-columns: 1.1fr .9fr; gap: 56px; align-items: center;
  max-width: 1160px; width: 100%; margin: 0 auto; padding: 56px 24px;
}
.auth-hero h1 { font-size: clamp(2rem, 4vw, 3rem); margin-bottom: 16px; }
.lead { font-size: 1.08rem; color: var(--muted); max-width: 560px; }
.steps { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.steps li { display: flex; align-items: center; gap: 14px; color: var(--text); }
.steps span {
  display: grid; place-items: center; width: 34px; height: 34px; flex-shrink: 0;
  background: var(--cyan); color: var(--navy); font-weight: 700; clip-path: var(--hex);
}
.auth-card { max-width: 440px; width: 100%; justify-self: end; }

/* ---------- Learn ---------- */
.learn {
  flex: 1; display: grid; grid-template-columns: 320px 1fr; min-height: 0;
  max-width: 1400px; width: 100%; margin: 0 auto;
  height: 100%; position: relative;
}
.sidebar {
  border-right: 1px solid var(--line);
  padding: 20px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
  background: rgba(4,17,31,.35);
}
.side-head { display: flex; align-items: center; justify-content: space-between; }
.side-head .kicker { margin: 0; }
.ref-search { position: relative; }
.ref-search input { width: 100%; padding: 8px 64px 8px 34px; font-size: .9rem;
  background: rgba(4,17,31,.6) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23B5C3D3' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 3.5 3.5'/%3E%3C/svg%3E") no-repeat 11px 50%; }
.ref-search-count { position: absolute; right: 34px; top: 50%; transform: translateY(-50%); font-size: .72rem; color: var(--muted); pointer-events: none; }
.ref-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.ref {
  display: block; position: relative; cursor: pointer;
  padding: 12px 14px 12px 44px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: rgba(15,46,79,.35);
  transition: border-color .15s, background .15s;
}
.ref:hover { border-color: var(--frame); }
.ref.selected { border-color: var(--cyan); background: rgba(41,182,230,.08); box-shadow: var(--glow); }
.ref input { position: absolute; opacity: 0; pointer-events: none; }
.ref .check {
  position: absolute; left: 14px; top: 14px; width: 18px; height: 18px;
  clip-path: var(--hex); background: var(--frame);
}
.ref:hover .check { background: var(--blue-light); }
.ref.selected .check { background: var(--cyan); border-color: var(--cyan); }
.ref-name { display: block; color: var(--heading); font-weight: 700; font-size: .92rem; }
.ref-meta { display: flex; justify-content: space-between; gap: 8px; font-size: .75rem; color: var(--muted); margin-top: 4px; }
.badge {
  display: inline-block; padding: 1px 7px; font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  border: 1px solid var(--frame); border-radius: 3px; color: var(--blue-light);
}
.bar { height: 5px; margin-top: 8px; background: rgba(4,17,31,.7); border-radius: 3px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--cyan)); }
.stats { font-size: .85rem; }
.stats h3 { font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; color: var(--cyan); margin-bottom: 10px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stat-grid strong { display: block; font-size: 1.3rem; color: var(--heading); }
.stat-grid span { font-size: .72rem; color: var(--muted); }
.empty-note { color: var(--muted); font-size: .88rem; }

.chat { display: flex; flex-direction: column; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 16px 24px; border-bottom: 1px solid var(--line); }
.chat-title h2 { font-size: 1.05rem; }
.chat-title p { margin: 2px 0 0; font-size: .82rem; color: var(--muted); }
.difficulty { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; min-width: 230px; }
.difficulty-label { flex-direction: row; gap: 6px; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.difficulty-label strong { color: var(--cyan); letter-spacing: normal; text-transform: none; font-size: .9rem; }
.difficulty-label strong[data-level="1"] { color: var(--ok); }
.difficulty-label strong[data-level="3"] { color: var(--warn); }
.difficulty-label strong[data-level="4"] { color: var(--danger); }
.difficulty-desc { font-size: .72rem; color: var(--muted); text-align: right; }
#difficulty {
  --fill: 33%;
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; padding: 0; margin: 6px 0;
  border: none; border-radius: 3px; cursor: pointer;
  background: linear-gradient(90deg, var(--ok), var(--cyan) 40%, var(--warn) 70%, var(--danger)) 0 0 / var(--fill) 100% no-repeat, var(--line);
}
#difficulty:focus { box-shadow: none; outline: none; }
#difficulty::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; background: var(--heading); clip-path: var(--hex); cursor: grab;
}
#difficulty::-moz-range-thumb { width: 18px; height: 18px; border: none; border-radius: 50%; background: var(--heading); cursor: grab; }
#difficulty:focus-visible::-webkit-slider-thumb { background: var(--cyan); }
.chip-diff { background: transparent; }
.chip-diff.d1 { color: var(--ok); border-color: rgba(74,222,155,.4); }
.chip-diff.d2 { color: var(--cyan); }
.chip-diff.d3 { color: var(--warn); border-color: rgba(255,200,97,.4); }
.chip-diff.d4 { color: var(--danger); border-color: rgba(255,138,128,.4); }
.graded { font-size: .78rem; font-weight: 400; color: var(--muted); }
.messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; scroll-behavior: smooth; }

.msg { display: flex; gap: 12px; max-width: 820px; animation: pop .25s ease-out; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.avatar {
  width: 36px; height: 36px; flex-shrink: 0; display: grid; place-items: center;
  clip-path: var(--hex); font-weight: 700; font-size: .85rem;
}
.msg.bot .avatar { clip-path: none; }
.msg.bot .avatar img { width: 36px; height: 36px; }
.msg.user .avatar { background: var(--surface-alt); color: var(--heading); }
.bubble {
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  min-width: 0; overflow-wrap: anywhere;
}
.msg.user .bubble { background: var(--blue); border-color: var(--blue); color: #fff; }
.bubble .q-tag { display: inline-block; margin-right: 4px; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--cyan); }
.bubble .q-text { font-size: 1.05rem; color: var(--heading); }
.q-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; }
.chip {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .7rem; font-weight: 700;
  background: rgba(41,182,230,.12); color: var(--cyan); border: 1px solid rgba(41,182,230,.3);
}
.chip-level { background: transparent; color: var(--muted); border-color: var(--frame); }
.chip-level.lvl-approfondissement { color: var(--ok); border-color: rgba(74,222,155,.4); }
.chip-level.lvl-consolidation { color: var(--warn); border-color: rgba(255,200,97,.4); }
.hint { margin-top: 10px; font-size: .9rem; }
.hint summary { cursor: pointer; color: var(--cyan); font-weight: 700; list-style: none; display: inline-block; }
.hint summary::-webkit-details-marker { display: none; }
.hint[open] summary { margin-bottom: 4px; }
.hint p { color: var(--muted); }
.didactic { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius); font-size: .92rem; }
.didactic b { display: block; font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 2px; }
.didactic.why { background: rgba(21,101,192,.18); }
.didactic.why b { color: var(--blue-light); }
.didactic.memo { background: rgba(74,222,155,.08); }
.didactic.memo b { color: var(--ok); }
.bubble p { margin: 0; }

.result { width: 100%; max-width: 720px; }
.result-top { display: flex; align-items: center; gap: 16px; }
.score-ring {
  --p: 0; --c: var(--danger);
  width: 64px; height: 64px; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), rgba(4,17,31,.8) 0);
}
.score-ring span {
  width: 50px; height: 50px; border-radius: 50%; background: var(--surface);
  display: grid; place-items: center; font-weight: 700; color: var(--heading); font-size: 1rem;
}
.verdict { font-weight: 700; font-size: 1rem; }
.verdict.correct { color: var(--ok); }
.verdict.partiel { color: var(--warn); }
.verdict.incorrect { color: var(--danger); }
.feedback { margin-top: 2px; color: var(--text); }
.expected { margin-top: 12px; padding: 10px 12px; background: rgba(4,17,31,.5); border-radius: var(--radius); font-size: .92rem; }
.expected b { color: var(--cyan); font-weight: 700; }
.extract {
  margin-top: 12px; padding: 12px 14px;
  border-left: 4px solid var(--cyan);
  background: rgba(41,182,230,.06);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.extract-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .78rem; color: var(--muted); margin-bottom: 6px; }
.extract-head .label { font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--cyan); }
.extract-head .code { font-family: var(--mono); color: var(--heading); background: var(--surface-alt); padding: 1px 6px; border-radius: 3px; }
.extract-body { white-space: pre-wrap; font-size: .92rem; color: var(--text); }

.welcome { margin: auto; text-align: center; max-width: 520px; padding: 24px; }
.welcome img { width: 72px; height: 72px; margin-bottom: 16px; }
.welcome h2 { font-size: 1.5rem; margin-bottom: 8px; }
.welcome p { color: var(--muted); }

.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.composer { border-top: 1px solid var(--line); padding: 16px 24px 20px; background: rgba(4,17,31,.55); display: flex; flex-direction: column; gap: 10px; }
.composer-box { position: relative; }
.composer textarea { width: 100%; resize: none; padding-right: 70px; min-height: 56px; }
.counter { position: absolute; right: 10px; bottom: 10px; font-size: .72rem; color: var(--muted); }
.composer-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Demander ---------- */
.ask { flex: 1; display: flex; min-height: 0; max-width: 1100px; width: 100%; margin: 0 auto; height: 100%; }
.ask .chat { flex: 1; }
.inquiry .answer-main p { font-size: 1.05rem; color: var(--heading); }
.inquiry .answer-main p + p, .details p + p { margin-top: 6px; }
.details { margin-top: 12px; padding: 10px 12px; background: rgba(4,17,31,.5); border-radius: var(--radius); font-size: .95rem; }
.details > b { display: block; font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--cyan); margin-bottom: 4px; }
.details ul { margin: 6px 0; padding-left: 20px; }
.details li + li { margin-top: 4px; }
.cite {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; margin: 0 1px;
  font-size: .7rem; font-weight: 700; line-height: 1; vertical-align: super;
  color: var(--navy); background: var(--cyan); border-radius: 3px; text-decoration: none;
}
a.cite:hover { background: var(--heading); }
.extract-head .cite { vertical-align: middle; }
.chip-found { color: var(--ok); background: rgba(74,222,155,.08); border-color: rgba(74,222,155,.4); }
.chip-notfound { color: var(--warn); background: rgba(255,200,97,.08); border-color: rgba(255,200,97,.4); }
.extract.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: rgba(41,182,230,.3); } to { background: rgba(41,182,230,.06); } }

/* ---------- Examen ---------- */
.exam { flex: 1; overflow-y: auto; min-height: 0; }
.exam-inner { max-width: 860px; margin: 0 auto; padding: 32px 24px 56px; display: flex; flex-direction: column; gap: 18px; }
.exam-head h1 { font-size: 1.8rem; margin-bottom: 8px; }
.exam-head .lead { font-size: 1rem; }
.exam-start { display: flex; flex-direction: column; gap: 16px; align-items: flex-start; }
.scope { border: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; width: 100%; }
.scope legend { font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; color: var(--cyan); font-weight: 700; margin-bottom: 8px; }
.radio {
  flex-direction: row; align-items: center; gap: 12px; cursor: pointer;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(15,46,79,.35);
}
.radio:has(input:checked) { border-color: var(--cyan); background: rgba(41,182,230,.08); }
.radio.disabled { opacity: .5; cursor: not-allowed; }
.radio input { accent-color: var(--cyan); width: 18px; height: 18px; }
.radio span { display: flex; flex-direction: column; }
.radio b { color: var(--heading); font-size: .95rem; }
.exam-note { margin: 0; font-size: .82rem; color: var(--muted); }
.exam-history h3, .exam-correction-title { font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; color: var(--cyan); margin-bottom: 10px; }
.exam-correction-title { margin: 8px 0 0; }
.exam-loading { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 48px 24px; text-align: center; }
.exam-run { display: flex; flex-direction: column; gap: 16px; }
.exam-progress-top { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; color: var(--muted); }
.exam-progress-top .kicker { margin: 0; }
.exam-dots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.dot {
  width: 34px; height: 34px; font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer;
  color: var(--muted); background: rgba(15,46,79,.5); border: 1px solid var(--line); clip-path: var(--hex);
}
.dot.done { background: rgba(41,182,230,.25); color: var(--heading); }
.dot.current { background: var(--cyan); color: var(--navy); }
.exam-question { display: flex; flex-direction: column; gap: 14px; }
.exam-question .q-text { font-size: 1.15rem; color: var(--heading); margin: 0; }
.exam-question textarea { width: 100%; resize: vertical; padding-right: 70px; min-height: 90px; }
.exam-score { display: flex; align-items: center; gap: 28px; }
.exam-score h2 { font-size: 1.6rem; margin-bottom: 8px; }
.exam-score .kicker { margin-bottom: 4px; }
.score-ring.big { width: 120px; height: 120px; }
.score-ring.big span { width: 96px; height: 96px; font-size: 1.7rem; background: var(--bg); }
.exam-summary { display: flex; flex-wrap: wrap; gap: 14px; font-weight: 700; font-size: .92rem; }
.exam-summary .ok { color: var(--ok); }
.exam-summary .warn { color: var(--warn); }
.exam-summary .bad { color: var(--danger); }
.exam-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.exam-item .q-text { font-size: 1.05rem; color: var(--heading); margin: 0 0 10px; }
.your-answer { padding: 10px 12px; margin-bottom: 12px; border-radius: var(--radius); background: rgba(21,101,192,.25); font-size: .95rem; }
.your-answer b { color: var(--blue-light); }
.exam-item .score-ring span { background: var(--surface-alt); }

/* ---------- Admin ---------- */
.admin { max-width: 1160px; width: 100%; margin: 0 auto; padding: 32px 24px 56px; }
.admin-head { margin-bottom: 20px; }
.admin-head h1 { font-size: 1.8rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
td.num, th.num { text-align: right; }
td .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.role-admin { color: var(--cyan); font-weight: 700; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; flex-direction: row; }
.switch input { width: 18px; height: 18px; accent-color: var(--cyan); }
.hint { font-size: .85rem; color: var(--muted); margin: 0 0 16px; }
.hint code, .extract code { font-family: var(--mono); background: var(--surface-alt); padding: 1px 5px; border-radius: 3px; color: var(--heading); }

.dialog {
  max-width: 720px; width: calc(100% - 32px); max-height: 80vh;
  color: var(--text); background: var(--bg); border: 1px solid var(--frame); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px;
}
.dialog::backdrop { background: rgba(4,17,31,.75); }
.dialog h3 { margin-bottom: 12px; }
.dialog .item { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .88rem; white-space: pre-wrap; }
.dialog .item .extract-head { margin-bottom: 2px; }

.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast {
  max-width: 380px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--frame); box-shadow: var(--shadow);
  font-size: .9rem; animation: pop .2s ease-out;
}
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.ok { border-color: var(--ok); }

.only-mobile { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; gap: 32px; padding: 32px 16px; }
  .auth-card { justify-self: stretch; max-width: none; }
  .learn { grid-template-columns: 1fr; }
  .sidebar {
    position: absolute; inset: 0; z-index: 15; transform: translateX(-100%);
    transition: transform .2s; background: var(--bg); border-right: none;
  }
  .sidebar.open { transform: none; }
  .only-mobile { display: inline-flex; }
  /* En-tête sur deux lignes : logo + crédits + déconnexion, puis les onglets en pleine largeur */
  .topbar { padding: 8px 16px 0; flex-wrap: wrap; row-gap: 4px; gap: 10px; }
  .brand { padding-bottom: 4px; }
  .topnav { display: contents; }
  .credits { order: 1; margin-left: auto; margin-bottom: 4px; }
  #logout { order: 2; padding: 6px 8px; margin-bottom: 4px; }
  #logout .logout-icon { display: block; }
  #logout .logout-label { display: none; }
  .navlinks { order: 3; flex-basis: 100%; gap: 0; overflow-x: auto; scrollbar-width: none; }
  .navlinks::-webkit-scrollbar { display: none; }
  .navlinks a { flex: 1; text-align: center; font-size: .85rem; padding: 8px 6px; white-space: nowrap; }
  .navlinks .full { display: none; }
  .navlinks .short { display: inline; }
  .messages, .composer, .chat-head { padding-left: 16px; padding-right: 16px; }
  .chat-head { flex-wrap: wrap; }
  .difficulty { margin-left: 0; width: 100%; min-width: 0; align-items: stretch; }
  .difficulty-desc { text-align: left; }
  .admin { padding: 24px 16px 40px; }
  .exam-inner { padding: 24px 16px 40px; }
  .exam-score { flex-direction: column; align-items: flex-start; gap: 16px; }
  .brand-sub { display: none; }
}
@media (max-width: 520px) {
  .composer-actions .btn { flex: 1; }
  #next small { display: none; }
  .credits { padding: 5px 10px; }
}
