:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --border: #e3e5e9;
  --text: #15171c;
  --muted: #646a76;
  --accent: #3b5bdb;
  --accent-soft: #e7ecff;
  --accent-text: #ffffff;
  --danger: #c92a2a;
  --radius: 16px;
  --sidebar: 240px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --surface-2: #20242c;
    --border: #2a2e37;
    --text: #eceef2;
    --muted: #9198a5;
    --accent: #748ffc;
    --accent-soft: #232a45;
    --accent-text: #0f1115;
    --danger: #ff6b6b;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
main {
  max-width: 880px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
}
[hidden] { display: none !important; }
h1 { font-size: 1.75rem; margin: 0; letter-spacing: -0.02em; line-height: 1.2; overflow-wrap: anywhere; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--danger); min-height: 1.5em; margin: 0; }
a { color: var(--accent); }

/* ---------- Écrans de connexion ---------- */
.center {
  min-height: calc(100dvh - 80px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 12px; max-width: 360px; margin: 0 auto;
}
.center p { margin: 0; }
.lock {
  width: 88px; height: 88px; border-radius: 28px;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border); margin-bottom: 8px;
}
svg { width: 40px; height: 40px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Boutons & champs ---------- */
button { font: inherit; color: inherit; border: 0; border-radius: 12px; padding: 12px 18px; cursor: pointer; background: none; }
button:disabled { opacity: 0.55; cursor: progress; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { background: var(--accent); color: var(--accent-text); font-weight: 600; width: 100%; padding: 14px; margin-top: 12px; }
.accent-btn { background: var(--accent); color: var(--accent-text); font-weight: 600; padding: 10px 16px; white-space: nowrap; }
.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); padding: 10px 16px; }
.ghost-btn { color: var(--muted); padding: 8px 12px; border: 1px solid var(--border); background: var(--surface); }
.ghost-btn.small { font-size: 0.85rem; padding: 6px 10px; }
.danger { color: var(--danger); border: 1px solid var(--border); margin-top: 8px; }
.danger-link { color: var(--danger); padding: 10px 4px; }
.icon-btn {
  width: 40px; height: 40px; padding: 0; border-radius: 10px;
  display: inline-grid; place-items: center; color: var(--muted); text-decoration: none; font-size: 1.05rem;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.field { display: flex; flex-direction: column; gap: 6px; width: 100%; text-align: left; font-size: 0.9rem; color: var(--muted); margin-top: 8px; }
.field-label { font-size: 0.9rem; color: var(--muted); margin: 14px 0 6px; }
input, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; width: 100%; min-width: 0;
}

/* ---------- Coquille : menu latéral + contenu ---------- */
.shell { min-height: 100dvh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 30;
  display: flex; flex-direction: column; gap: 4px;
  padding: max(20px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
  background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; padding: 4px 10px 20px; }
.brand img { border-radius: 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-bottom { margin-top: auto; border-top: 1px solid var(--border); padding-top: 10px; }
.nav a, .nav button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border-radius: 10px; text-align: left;
  color: var(--text); text-decoration: none; font-weight: 500;
}
.nav a:hover, .nav button:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav-ico { width: 24px; text-align: center; font-size: 1.1rem; }

.content {
  margin-left: var(--sidebar);
  padding: 32px clamp(16px, 4vw, 48px) max(40px, env(safe-area-inset-bottom));
  max-width: calc(var(--sidebar) + 1000px);
}
.mobilebar { display: none; }
.backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / 0.4); z-index: 20; }

@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: none; }
  .menu-open .sidebar { transform: none; box-shadow: 0 0 40px rgb(0 0 0 / 0.25); }
  .content { margin-left: 0; padding: 0 16px 40px; }
  .mobilebar {
    display: flex; align-items: center; gap: 8px;
    position: sticky; top: 0; z-index: 10;
    margin: 0 -16px 16px; padding: max(8px, env(safe-area-inset-top)) 12px 8px;
    background: var(--bg); border-bottom: 1px solid var(--border); font-weight: 600;
  }
  .mobilebar .icon-btn { color: var(--text); font-size: 1.3rem; }
  #mobile-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* ---------- Pages ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head p { margin: 0; }
.back { display: inline-block; margin-bottom: 12px; text-decoration: none; font-size: 0.95rem; }
.search { margin-bottom: 20px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.card {
  display: flex; flex-direction: column; gap: 6px; padding: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: inherit; text-decoration: none; min-width: 0;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.card:hover { border-color: var(--accent); }
.card:active { transform: scale(0.98); }
.card .icon { font-size: 1.9rem; line-height: 1; margin-bottom: 4px; }
.card .name { font-weight: 600; overflow-wrap: anywhere; }
.card .desc { color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }

.empty { padding: 32px 20px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); }
.empty p { margin: 4px 0; }
.empty-line { padding: 12px 4px; margin: 0; }

/* ---------- Matière ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tool { background: var(--surface); border: 1px solid var(--border); padding: 10px 14px; font-weight: 500; }
.tool:hover { border-color: var(--accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { padding: 6px 12px; border-radius: 999px; font-size: 0.9rem; color: var(--muted); border: 1px solid var(--border); }
.chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
#cours-subject.dragging { outline: 2px dashed var(--accent); outline-offset: 8px; border-radius: var(--radius); }

.items { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.items:empty { display: none; }
.item { display: flex; align-items: center; gap: 4px; padding-right: 6px; border-top: 1px solid var(--border); }
.item:first-child { border-top: 0; }
.item-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; text-align: left; color: inherit; text-decoration: none; border-radius: 0;
}
.item-main:hover { background: var(--surface-2); }
.item-ico {
  flex: none; width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center; background: var(--surface-2); font-size: 1.15rem;
}
.item-ico .ext { font-size: 0.65rem; font-weight: 700; letter-spacing: 0.02em; color: var(--accent); }
.item-text { display: flex; flex-direction: column; min-width: 0; }
.item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { color: var(--muted); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-actions { display: flex; flex: none; }

.uploads { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.uploads:empty { display: none; }
.upload { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.upload-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }
.upload progress { width: 40%; accent-color: var(--accent); }

/* ---------- Sécurité ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.devices { list-style: none; padding: 0; margin: 0 0 16px; }
.devices li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-top: 1px solid var(--border); }
.devices li div { display: flex; flex-direction: column; min-width: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row input { flex: 1 1 180px; }

/* ---------- Dialogues ---------- */
.dlg {
  width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  padding: 20px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
}
.dlg::backdrop { background: rgb(0 0 0 / 0.45); }
.dlg-wide { width: min(820px, calc(100vw - 32px)); }
.dlg form { display: flex; flex-direction: column; }
.dlg-actions { display: flex; align-items: center; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.spacer { flex: 1; }
.title-input { font-size: 1.2rem; font-weight: 600; border: 0; padding: 4px 0 10px; border-radius: 0; border-bottom: 1px solid var(--border); background: transparent; }
.title-input:focus-visible { outline: none; border-bottom-color: var(--accent); }
#note-content { min-height: 50dvh; margin-top: 12px; resize: vertical; line-height: 1.6; }
@media (max-width: 820px) {
  .dlg-wide { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border: 0; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
  .dlg-wide form { height: 100%; }
  .dlg-wide #note-content { flex: 1; min-height: 0; resize: none; }
}
.emoji-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; }
.emoji { font-size: 1.3rem; padding: 6px 0; border: 1px solid var(--border); border-radius: 10px; }
.emoji[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }

.spinner {
  width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } .card { transition: none; } }

/* ---------- Révisions ---------- */
select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; min-width: 0;
}
.section-title { margin: 28px 0 10px; font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.section-hint { margin: -4px 0 10px; }
.settings-list { padding: 4px 16px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--border); }
.setting-row:first-child { border-top: 0; }
.setting-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.setting-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.setting-controls input { width: auto; padding: 9px 12px; }
.info { background: var(--accent-soft); color: var(--text); border-radius: 10px; padding: 10px 12px; margin: 14px 0 0; }
.pending p { margin: 6px 0; }
.head-actions { display: flex; gap: 8px; }

.segmented { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; margin-bottom: 16px; width: fit-content; max-width: 100%; overflow-x: auto; }
.segmented button { padding: 8px 14px; border-radius: 9px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }

.md { overflow-wrap: anywhere; line-height: 1.65; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1 { font-size: 1.5rem; margin: 0 0 12px; }
.md h2 { font-size: 1.2rem; margin: 26px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.md h3 { font-size: 1.05rem; margin: 18px 0 6px; }
.md ul, .md ol { padding-left: 1.4em; }
.md li { margin: 3px 0; }
.md blockquote { margin: 12px 0; padding: 10px 14px; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; }
.md blockquote p { margin: 0; }
.md code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 0.9em; }
.md table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; margin: 12px 0; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md th { background: var(--surface-2); }
.md math { font-size: 1.1em; }
.md math[display="block"] { margin: 10px 0; overflow-x: auto; overflow-y: hidden; }
.fiche { padding: clamp(18px, 3vw, 32px); }
.print-btn { margin-top: 12px; }

.quiz-card { display: flex; flex-direction: column; gap: 14px; max-width: 720px; }
.quiz-q { font-size: 1.1rem; font-weight: 500; }
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice { text-align: left; border: 1px solid var(--border); background: var(--surface); padding: 12px 14px; }
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice:disabled { cursor: default; opacity: 1; }
.choice.right { border-color: #2f9e44; background: rgb(47 158 68 / 0.12); }
.choice.wrong { border-color: var(--danger); background: rgb(201 42 42 / 0.1); }
.feedback { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.feedback.ok strong { color: #2f9e44; }
.feedback.ko strong { color: var(--danger); }
.feedback .md { margin-top: 6px; }
.grade { display: flex; gap: 8px; flex-wrap: wrap; }
.grade button { flex: 1 1 140px; }
.ok-btn { border-color: #2f9e44; }
.ko-btn { border-color: var(--danger); }
.result { align-items: center; text-align: center; margin: 0 auto; }
.result p { margin: 0; }
.big-score { font-size: 2.6rem; font-weight: 700; }
.history ul { list-style: none; padding: 0; margin: 4px 0 0; font-size: 0.9rem; }

.flashcard {
  display: flex; flex-direction: column; gap: 14px; justify-content: center;
  width: 100%; max-width: 720px; min-height: 220px; margin: 8px 0;
  padding: 24px; text-align: center; font-size: 1.15rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.06);
}
.flashcard .back { display: none; padding-top: 14px; border-top: 1px dashed var(--border); color: var(--text); font-size: 1rem; text-align: left; }
.flashcard.flipped .back { display: block; }
.flashcard .front { font-weight: 600; }
.center-text { text-align: center; max-width: 720px; }
#pane-cards .grade { max-width: 720px; }

@media print {
  .sidebar, .mobilebar, .back, .page-head .head-actions, .segmented, .print-btn, #prep-pending { display: none !important; }
  .content { margin: 0; padding: 0; }
  body { background: #fff; color: #000; }
  .fiche { border: 0; padding: 0; }
}

/* Photo de cours */
.fab {
  position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 50%; font-size: 1.6rem; z-index: 20;
  background: var(--accent); color: var(--accent-text); box-shadow: 0 6px 20px rgb(0 0 0 / 0.3);
}
@media (min-width: 900px) { .fab { display: none; } }
.photo-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.photo-pages:empty { display: none; }
.photo-page { position: relative; aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.photo-page img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-page .num { position: absolute; left: 6px; bottom: 6px; font-size: 0.75rem; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: rgb(0 0 0 / 0.6); color: #fff; }
.photo-page .del { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; padding: 0; border-radius: 50%; background: rgb(0 0 0 / 0.6); color: #fff; font-size: 0.85rem; }
.photo-more { margin-top: 10px; width: 100%; padding: 14px; }

/* ---------- Cours : sous-onglets Matières | Révisions ---------- */
.cours-switch { margin-bottom: 20px; }
.segmented a { padding: 8px 16px; border-radius: 9px; color: var(--muted); font-weight: 500; text-decoration: none; white-space: nowrap; }
.segmented a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }
.search-row { display: flex; gap: 8px; margin-bottom: 20px; }
.search-row .search { margin-bottom: 0; flex: 1; }
.action-row { display: flex; justify-content: flex-end; margin-bottom: -8px; }
.action-row + .section-title { margin-top: 0; }
@media (max-width: 520px) { .action-row { justify-content: stretch; } .action-row button { width: 100%; } .action-row + .section-title { margin-top: 20px; } }
.subject-preps { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.subject-preps:empty { display: none; }
.subject-preps-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge { font-size: 0.8rem; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---------- Dictée vocale (dictee.js) ---------- */
.mic-wrap { position: relative; display: block; width: 100%; min-width: 0; }
.mic-wrap > input, .mic-wrap > textarea { padding-right: 46px; }
.search-row > .mic-wrap { flex: 1; }
.row > .mic-wrap { flex: 1 1 180px; }
.wrap-search { margin-bottom: 20px; }
.wrap-search > .search, .search-row > .mic-wrap { margin-bottom: 0; }
.mic-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; padding: 0; border-radius: 50%;
  display: grid; place-items: center; color: var(--muted); background: transparent;
}
.mic-btn svg { width: 20px; height: 20px; stroke-width: 1.8; }
.mic-btn:hover { color: var(--accent); background: var(--surface-2); }
.mic-area .mic-btn { top: auto; bottom: 14px; right: 14px; transform: none; background: var(--surface-2); }
.mic-btn.listening { color: #fff; background: var(--danger); animation: mic-pulse 1.2s ease-in-out infinite; }
@keyframes mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgb(201 42 42 / 0.45); } 50% { box-shadow: 0 0 0 8px rgb(201 42 42 / 0); } }
@media (prefers-reduced-motion: reduce) { .mic-btn.listening { animation: none; } }
@media (max-width: 820px) {
  .dlg-wide .mic-area { flex: 1; display: flex; flex-direction: column; min-height: 0; }
  .dlg-wide .mic-area > textarea { flex: 1; min-height: 0; }
}
@media print { .mic-btn { display: none; } }

/* Préparation automatique et fiches bac */
.pending .accent-btn { margin-top: 10px; }
.job-error { color: var(--danger, #c92a2a); }
.item-actions .start-btn { font-size: 0.85rem; padding: 6px 10px; white-space: nowrap; }
.bac-list { display: flex; flex-direction: column; gap: 10px; }
.bac-subject { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 16px; }
.bac-subject > summary { cursor: pointer; padding: 12px 0; font-weight: 600; list-style: none; display: flex; gap: 8px; align-items: center; }
.bac-subject > summary::-webkit-details-marker { display: none; }
.bac-subject > summary::after { content: '▾'; margin-left: auto; color: var(--muted); }
.bac-subject[open] > summary::after { content: '▴'; }
.bac-exam { margin: 0 0 8px; }
.bac-chapter { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.bac-chapter .ch-name { flex: 1; min-width: 0; }
.bac-chapter a.ch-name { color: inherit; text-decoration: none; font-weight: 500; }
.bac-chapter .ch-state { font-size: 0.82rem; color: var(--muted); white-space: nowrap; }
.bac-other { display: flex; gap: 8px; padding: 10px 0 14px; border-top: 1px solid var(--border); }
.bac-other input { flex: 1; min-width: 0; }
.bac-empty { padding: 10px 0 14px; }
@media print { #bac-pending { display: none !important; } }

/* Quiz : progression, brouillon, explications */
.quiz-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.explain { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 12px; border-left: 4px solid var(--accent); background: var(--accent-soft); }
.explain p { margin: 0; }
.explain-title { font-weight: 700; }
.explain .md.inline, .explain .md.inline p { display: inline; }
.explain .ghost-btn { align-self: flex-start; }
.explain-more > summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; padding: 4px 0; }
.explain-more[open] > summary { margin-bottom: 8px; }
.scratch { max-width: 720px; margin-top: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 14px 14px; }
.scratch > summary { cursor: pointer; font-weight: 600; padding: 10px 0; }
.scratch-modes, .scratch-tools { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.scratch-draw { border: 1px dashed var(--border); border-radius: 10px; overflow: hidden; background: var(--bg); }
.scratch-canvas { display: block; width: 100%; height: 320px; touch-action: none; cursor: crosshair; color: var(--text, currentColor); }
.scratch-text { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.missed { max-width: 720px; display: flex; flex-direction: column; gap: 10px; }
.missed-q { display: flex; flex-direction: column; gap: 10px; }
@media print { .scratch { display: none; } }

/* Brouillon : formules du cours */
.formulas { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.formulas-title { margin: 0 0 8px; font-weight: 600; font-size: 0.92rem; }
.formula-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.formula-tab { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 0.88rem; white-space: nowrap; }
.formula-tab[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.formula-tab-ico { font-family: 'Cambria Math', 'STIX Two Math', 'Times New Roman', serif; font-weight: 700; }
.formula-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; margin-top: 8px; max-height: 280px; overflow-y: auto; }
.formula-grid.compact { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
.formula { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); }
.formula-grid.compact .formula { align-items: center; padding: 8px 4px; }
.formula:hover { border-color: var(--accent); }
.formula:active { background: var(--accent-soft); }
.formula-text { font-family: 'Cambria Math', 'STIX Two Math', 'Times New Roman', serif; font-size: 0.98rem; overflow-wrap: anywhere; }
.formula-label { font-size: 0.75rem; color: var(--muted); }

/* Écran de déverrouillage : rester déverrouillé */
.remember { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; font-size: 0.92rem; color: var(--muted); }
.remember label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.remember input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.remember select { width: auto; padding: 6px 10px; }
.remember select:disabled { opacity: 0.5; }
