/* =====================================================
   StudyGrasp — design system
   Rustig, gefocust, typografie-eerst. Dark & light.
   ===================================================== */

:root {
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", monospace;

  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 8px;

  --shadow-1: 0 1px 2px rgba(0,0,0,.25);
  --shadow-2: 0 8px 30px rgba(0,0,0,.35);

  --topbar-h: 56px;
  --ease: cubic-bezier(.22,.8,.36,1);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0e14;
  --bg-soft: #0e1219;
  --surface: #121722;
  --surface-2: #171d2b;
  --surface-3: #1d2435;
  --border: rgba(148,163,196,.14);
  --border-strong: rgba(148,163,196,.26);
  --text: #e7ebf4;
  --text-soft: #b6bfd1;
  --muted: #8791a5;
  --accent: #6d9bff;
  --accent-strong: #85acff;
  --accent-soft: rgba(109,155,255,.13);
  --accent-border: rgba(109,155,255,.4);
  --green: #45d6b2;
  --green-soft: rgba(69,214,178,.13);
  --amber: #f2b95c;
  --amber-soft: rgba(242,185,92,.14);
  --red: #f27e7e;
  --red-soft: rgba(242,126,126,.13);
  --slide-bg: #05070b;
  --scrim: rgba(4,6,10,.6);
  --code-bg: #0d1119;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fa;
  --bg-soft: #eef1f7;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f8;
  --border: rgba(30,45,80,.12);
  --border-strong: rgba(30,45,80,.24);
  --text: #17203a;
  --text-soft: #3c4761;
  --muted: #6b7690;
  --accent: #3565d9;
  --accent-strong: #274fb3;
  --accent-soft: rgba(53,101,217,.09);
  --accent-border: rgba(53,101,217,.4);
  --green: #109673;
  --green-soft: rgba(16,150,115,.1);
  --amber: #b97e14;
  --amber-soft: rgba(185,126,20,.12);
  --red: #cc4444;
  --red-soft: rgba(204,68,68,.1);
  --slide-bg: #e6e9f0;
  --scrim: rgba(20,28,48,.4);
  --code-bg: #f1f4f9;
  --shadow-1: 0 1px 2px rgba(25,40,80,.08);
  --shadow-2: 0 10px 32px rgba(25,40,80,.14);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
/* De app scrollt alleen binnen panelen; het document zelf nooit. */
html { overflow: hidden; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
#app { height: 100vh; display: flex; flex-direction: column; }

::selection { background: var(--accent-soft); }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; padding: 0; }

/* Eén duidelijke focusring voor wie met het toetsenbord navigeert, in dezelfde
   accentkleur als de velden. :focus-visible => muisklikken krijgen hem niet,
   alleen Tab-navigatie. De browserstandaard is op de donkere achtergrond
   nauwelijks te zien. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, textarea, select { font: inherit; color: inherit; }
kbd {
  font-family: var(--font-mono); font-size: 11px; padding: 1.5px 5px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 5px; background: var(--surface-2); color: var(--muted);
}

.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2.5px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }

/* =====================================================
   Buttons & inputs
   ===================================================== */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); font-weight: 500; font-size: 13.5px;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap; user-select: none;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn.icon-btn { padding: 8px; }
.btn.lg { padding: 11px 20px; font-size: 14.5px; border-radius: var(--radius-sm); }

.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
}
.seg button {
  padding: 5px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 500;
  color: var(--muted); transition: all .15s; white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; box-shadow: var(--shadow-1); }
.seg.subtle button.on { background: var(--surface); color: var(--text); }

/* eigen tooltip: verschijnt na even hoveren, boven het element */
.tip { position: relative; }
.tip::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 9px); left: 50%;
  transform: translateX(-50%) translateY(3px);
  padding: 6px 11px; border-radius: 8px;
  background: var(--surface-3); border: 1px solid var(--border-strong);
  color: var(--text); font-size: 11.5px; font-weight: 600; line-height: 1.4;
  white-space: nowrap; pointer-events: none; opacity: 0; z-index: 60;
  box-shadow: var(--shadow-2);
  transition: opacity .15s ease .5s, transform .15s ease .5s;
}
.tip:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 3px 10px;
  border-radius: 99px; border: 1px solid var(--border);
  color: var(--muted); background: var(--surface-2);
}
.chip.accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.chip.green { color: var(--green); background: var(--green-soft); border-color: transparent; }
.chip.amber { color: var(--amber); background: var(--amber-soft); border-color: transparent; }
.chip.red { color: var(--red); background: var(--red-soft); border-color: transparent; }

.field {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s;
}
.field::placeholder { color: var(--muted); }
.field:focus { border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-soft); }
select.field { appearance: none; cursor: pointer; }

/* =====================================================
   Topbar
   ===================================================== */
.topbar {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); flex: none; }
.brand-symbol { display: block; width: 28px; height: 28px; flex: none; }
.brand-wordmark {
  font-weight: 800; font-size: 15.5px; letter-spacing: -.025em; line-height: 1;
}
.brand-wordmark-accent { color: var(--accent); }
.brand.compact { gap: 0; }
.topbar .doc-name {
  font-size: 13px; color: var(--muted); max-width: 260px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .spacer { flex: 1; }

@media (max-width: 370px) {
  .topbar .brand-wordmark { display: none; }
}

.tabs { display: flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.tabs button {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
  color: var(--muted); transition: all .15s;
}
.tabs button:hover { color: var(--text); }
.tabs button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tabs .badge {
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 99px;
  background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 700;
  display: grid; place-items: center;
}

/* =====================================================
   Home
   ===================================================== */
.home { flex: 1; overflow-y: auto; position: relative; }
.home-inner { max-width: 880px; margin: 0 auto; padding: 48px 24px 80px; position: relative; z-index: 1; }

/* Rustige lijntjes-achtergrond achter de hero. Vervaagt naar onderen/zijkanten
   zodat het decoratief blijft en niet afleidt. Kleuren via theme-variabelen. */
.hero-bg {
  position: absolute; top: 0; left: 0; right: 0; z-index: 0;
  pointer-events: none; overflow: hidden; line-height: 0;
  -webkit-mask-image: radial-gradient(120% 90% at 50% 8%, #000 45%, transparent 78%);
  mask-image: radial-gradient(120% 90% at 50% 8%, #000 45%, transparent 78%);
}
.hero-bg svg { width: 100%; height: auto; display: block; }
.hero-bg .ln { fill: none; stroke: var(--border-strong); stroke-width: 1; opacity: .5; }
.hero-bg .nd { fill: var(--bg); stroke: var(--accent); stroke-width: 1.5; opacity: .45; }
.hero-bg .nd.ctr { fill: var(--accent); opacity: .55; }
.hero-bg .dot { fill: var(--accent); opacity: .4; }

.hero { text-align: center; margin-bottom: 36px; }
.hero h1 {
  font-size: clamp(30px, 4.6vw, 44px); font-weight: 800; letter-spacing: -.03em;
  line-height: 1.12; margin: 0 0 14px;
}
.hero h1 .grad {
  background: linear-gradient(100deg, var(--accent), #9d7bff 60%, var(--green));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
/* De roterende, getypte zin op een eigen regel met gereserveerde hoogte, zodat
   de inhoud eronder niet meebeweegt terwijl er wordt getypt. Aanhef blijft in de
   normale tekstkleur, de getypte zin in het merkgroen (Graspr-stijl). */
.hero h1 .hero-type-line { display: block; min-height: 1.14em; }
/* Werkwoorden groen (.g), de rest erft de normale tekstkleur (Graspr-stijl). */
.hero h1 .hero-type .g { color: var(--green); }
/* In light mode zijn de highlight-woorden blauw (merk-accent) i.p.v. groen. */
[data-theme="light"] .hero h1 .hero-type .g { color: var(--accent); }
[data-theme="light"] .hero .hero-caret { background: var(--accent); }
.hero .hero-caret {
  display: inline-block; width: 2px; height: 1em; margin-left: 2px;
  vertical-align: -.12em; background: var(--green);
  animation: hero-caret-blink 1s steps(1) infinite;
}
.hero .hero-type-line.static .hero-caret { display: none; }
@keyframes hero-caret-blink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .hero .hero-caret { display: none; }
}
.hero p { color: var(--muted); font-size: 16px; margin: 0 auto; max-width: 520px; }

.dropzone {
  position: relative; margin: 0 auto 14px; padding: 42px 24px;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: var(--surface); text-align: center; cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s var(--ease);
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.drag { transform: scale(1.008); }
.dropzone .dz-icon {
  width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px;
  display: grid; place-items: center; color: var(--accent);
  background: var(--accent-soft); border: 1px solid var(--accent-border);
}
.dropzone h3 { margin: 0 0 4px; font-size: 16px; font-weight: 650; }
.dropzone p { margin: 0; color: var(--muted); font-size: 13px; }
.dropzone .formats { display: flex; gap: 6px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
/* compacte variant: ingebed in een bestaande pagina (bv. opgaven in een vakmap) */
.dropzone.compact { padding: 20px 18px; }
.dropzone.compact .dz-icon { width: 38px; height: 38px; margin-bottom: 10px; border-radius: 11px; }
.dropzone.compact h3 { font-size: 14.5px; }
.dropzone.compact p { font-size: 12.5px; }

.home-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }

/* woordenlijst-editor */
.wl-editor { display: flex; flex-direction: column; gap: 10px; }
.wl-rows { display: flex; flex-direction: column; gap: 8px; }
.wl-row { display: flex; gap: 8px; align-items: center; }
.wl-row .wl-term { flex: 0 0 34%; }
.wl-row .wl-def { flex: 1; }
@media (max-width: 640px) {
  .wl-row { flex-wrap: wrap; }
  .wl-row .wl-term, .wl-row .wl-def { flex: 1 1 100%; }
}

/* snel-foto uitlegscherm */
.quick-photo-wrap { display: grid; place-items: center; margin: 0 0 20px; }
.quick-photo { max-width: 100%; max-height: 44vh; border-radius: 10px; border: 1px solid var(--border); box-shadow: var(--shadow-1); }

.upload-progress { max-width: 560px; margin: 0 auto; padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.upload-progress .row { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; margin-bottom: 10px; }
.upload-progress .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-progress .pct { color: var(--muted); font-variant-numeric: tabular-nums; }

.progress-track { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), #9d7bff); transition: width .25s var(--ease); }
.progress-fill.indeterminate { width: 40% !important; animation: indet 1.2s infinite var(--ease); }
@keyframes indet { 0% { transform: translateX(-110%);} 100% { transform: translateX(280%);} }

.section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); margin: 40px 0 14px;
}
.section-title .line { flex: 1; height: 1px; background: var(--border); }

.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.doc-card {
  position: relative; border-radius: var(--radius); overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; transition: transform .18s var(--ease), border-color .18s, box-shadow .18s;
  display: flex; flex-direction: column; text-align: left;
}
.doc-card:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.doc-card .thumb {
  aspect-ratio: 16/9.6; background: var(--slide-bg); position: relative; overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.doc-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.doc-card .thumb .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.doc-card .restart-chip {
  position: absolute; left: 9px; bottom: 9px; z-index: 2;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  border: 1px solid color-mix(in srgb, var(--text) 18%, transparent);
  color: var(--text); font-size: 11px; font-weight: 650;
  box-shadow: var(--shadow-1); backdrop-filter: blur(8px);
  opacity: .82; transition: opacity .15s, border-color .15s, background .15s;
}
.doc-card .restart-chip .icon { width: 13px; height: 13px; }
.doc-card .restart-chip:hover,
.doc-card .restart-chip:focus-visible { opacity: 1; border-color: var(--accent-border); background: var(--surface-2); }
.doc-card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.doc-card .title { font-weight: 600; font-size: 13.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.doc-card .meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: auto; }
.doc-card .del {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px;
  display: grid; place-items: center; border-radius: 8px;
  background: var(--scrim); color: #fff; opacity: 0; transition: opacity .15s;
  backdrop-filter: blur(4px);
}
.doc-card:hover .del { opacity: 1; }
.doc-card .del:hover { background: var(--red); }
.doc-card .resume-badge { position: absolute; top: 8px; left: 8px; }

.empty-state { text-align: center; padding: 44px 20px; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }

/* =====================================================
   Workspace (studeer-omgeving)
   ===================================================== */
.workspace { flex: 1; display: flex; min-height: 0; }

/* ---- dia-kant ---- */
.stage {
  flex: 1.15; min-width: 0; display: flex; flex-direction: column;
  background: var(--slide-bg); position: relative;
}
.stage-nav .tools { display: flex; gap: 6px; align-items: center; }
.stage-nav .nav-btn.on { background: var(--accent); border-color: transparent; color: #fff; }

/* Ingezoomd op de dia: de houder mag scrollen zodat je eroverheen kunt schuiven.
   "safe center" houdt de dia gecentreerd zolang hij past, maar laat bij overloop
   de linker-/bovenkant bereikbaar (met gewoon "center" val je die kwijt). */
.slide-holder.zoomed { overflow: auto; place-items: safe center; cursor: grab; touch-action: none; }
.slide-holder.zoomed.panning { cursor: grabbing; }

.slide-holder {
  flex: 1; min-height: 0; display: grid; place-items: center; padding: 18px; position: relative;
}
.slide-frame { position: relative; max-width: 100%; max-height: 100%; box-shadow: var(--shadow-2); border-radius: 6px; overflow: hidden; background: #fff; }
.slide-frame img { display: block; max-width: 100%; max-height: calc(100vh - var(--topbar-h) - 120px); user-select: none; -webkit-user-drag: none; }
.slide-frame.loading img { opacity: .3; }

.slide-spinner {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
}
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* regio-selectie */
.slide-frame.selecting { cursor: crosshair; }
.slide-holder.zoomed:has(.slide-frame.selecting) { cursor: crosshair; }
.region-box {
  position: absolute; border: 2px solid var(--accent); background: rgba(109,155,255,.15);
  border-radius: 3px; pointer-events: none; z-index: 5;
  box-shadow: 0 0 0 9999px rgba(5,8,14,.35);
}
.region-hint {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 7;
  padding: 7px 14px; border-radius: 99px; font-size: 12.5px; font-weight: 600;
  background: var(--scrim); color: #fff; backdrop-filter: blur(8px); white-space: nowrap;
}

.stage-nav {
  flex: none; display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(to top, rgba(0,0,0,.25), transparent);
}
[data-theme="light"] .stage-nav { background: none; }
.stage-nav .page-label { font-size: 12.5px; color: var(--text-soft); font-variant-numeric: tabular-nums; font-weight: 600; min-width: 90px; text-align: center; }
.stage-nav .nav-btn {
  display: inline-flex; align-items: center; gap: 5px; padding: 7px 13px;
  border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text-soft);
  background: var(--surface); border: 1px solid var(--border);
  transition: all .15s;
}
.stage-nav .nav-btn:hover:not(:disabled) { color: var(--text); border-color: var(--border-strong); }
.stage-nav .nav-btn:disabled { opacity: .35; cursor: default; }
.stage-nav .spacer { flex: 1; }
.stage-progress { flex: 1; max-width: 340px; }

/* markering-stippen op thumbnails (belangrijk / aandacht nodig) */
.fdot {
  position: absolute; top: 5px; left: 6px; width: 9px; height: 9px;
  border-radius: 50%; border: 1.5px solid rgba(5,8,14,.4); display: none;
}
.fdot.star { background: var(--amber); }
.fdot.weak { background: var(--red); left: 19px; }
.fdot.show { display: block; }

/* ---- verdeler tussen dia en uitleg (sleepbaar) ---- */
.panel-divider {
  flex: none; width: 10px; margin: 0 -5px; cursor: col-resize;
  position: relative; z-index: 25; touch-action: none;
}
.panel-divider::after {
  content: ""; position: absolute; inset: 0 4px; border-radius: 2px;
  background: transparent; transition: background .15s;
}
.panel-divider:hover::after, .panel-divider.dragging::after { background: var(--accent-border); }

/* ---- uitleg-kant ---- */
.panel {
  flex: 1; min-width: 380px; max-width: 620px;
  display: flex; flex-direction: column; min-height: 0; position: relative;
  background: var(--bg-soft); border-left: 1px solid var(--border); container-type: inline-size;
}
.panel-head {
  flex: none; padding: 10px 12px; display: flex; flex-direction: column; gap: 9px;
  border-bottom: 1px solid var(--border); background: var(--bg-soft); z-index: 3;
}
.panel-head .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel-head .row .spacer { flex: 1; }
.panel-head .explain-toolbar {
  flex-wrap: nowrap; gap: 6px; min-width: 0; overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; overscroll-behavior-x: contain;
}
.panel-head .explain-toolbar::-webkit-scrollbar { display: none; }
.panel-head .explain-toolbar > * { flex-shrink: 0; }
.panel-head .explain-toolbar .spacer { flex: 1 0 2px; min-width: 2px; }
.panel-head .explain-toolbar .seg { padding: 2px; gap: 1px; }
.panel-head .explain-toolbar .seg button { padding: 5px 6px; font-size: 12px; }
.panel-head .explain-toolbar .icon-btn { width: 32px; height: 32px; padding: 6px; }

@container (max-width: 430px) {
  .panel-head { padding-inline: 8px; }
  .panel-head .explain-toolbar { gap: 4px; }
  .panel-head .explain-toolbar .seg button { padding: 4px 3px; font-size: 10px; }
  .panel-head .explain-toolbar .icon-btn { width: 28px; height: 28px; padding: 5px; }
}

.panel-body { flex: 1; overflow-y: auto; padding: 18px 22px 26px; scroll-behavior: smooth; position: relative; }
/* Alleen de uitleg schaalt mee met Ctrl+scroll boven het paneel — de rest van
   de interface blijft op zijn eigen maat. */
.panel-body .md { font-size: calc(15px * var(--explain-scale, 1)); }

/* Dia-afbeelding die na alle pogingen niet laadt: eerlijk melden i.p.v.
   eindeloos blijven draaien. */
.slide-error {
  position: absolute; inset: 0; margin: auto; width: max-content; height: max-content;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  padding: 14px 18px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-soft); font-size: 13px;
}
.slide-error svg { color: var(--amber, var(--accent)); }

/* Eerder gestelde vraag bij deze dia: ingeklapt knopje, klik = bewaard antwoord */
.chat-turn.collapsed { margin-top: 10px; }
.chat-recall {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 8px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-soft); font-size: 13px;
  transition: background .15s, border-color .15s;
}
.chat-recall:hover { background: var(--surface-3); border-color: var(--border-strong); }
.chat-recall .q { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-recall svg:first-child { color: var(--accent); }
.chat-recall svg:last-child { transition: transform .15s; }
.chat-recall.open svg:last-child { transform: rotate(90deg); }
.chat-turn.collapsed .chat-a { margin-top: 8px; }

/* zwevend pijltje: terug naar de uitleg bovenaan */
.to-top {
  position: absolute; right: 16px; bottom: 104px; z-index: 8;
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-3); border: 1px solid var(--border-strong);
  color: var(--text-soft); box-shadow: var(--shadow-2);
  opacity: 0; pointer-events: none; transform: translateY(6px);
  transition: opacity .2s var(--ease), transform .2s var(--ease), color .15s, border-color .15s;
}
.to-top.show { opacity: 1; pointer-events: auto; transform: none; }
.to-top:hover { color: var(--accent); border-color: var(--accent-border); }

.panel-foot {
  flex: none; padding: 10px 14px 14px; border-top: 1px solid var(--border);
  background: var(--bg-soft);
}
/* regio-bijlage boven het invoerveld */
.attach-bar {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; margin-bottom: 9px; border-radius: 11px;
  border: 1px dashed var(--accent-border); background: var(--accent-soft);
}
.attach-preview {
  width: 78px; height: 52px; flex: none; border-radius: 6px;
  background-color: #fff; background-repeat: no-repeat;
  border: 1px solid var(--border-strong);
}
.attach-label { flex: 1; min-width: 0; line-height: 1.35; }
.attach-label strong { display: block; font-size: 12.5px; color: var(--accent); }
.attach-label span { font-size: 11.5px; color: var(--muted); }
.attach-x {
  width: 28px; height: 28px; flex: none; border-radius: 8px;
  display: grid; place-items: center; color: var(--muted); transition: all .15s;
}
.attach-x:hover { background: var(--surface-3); color: var(--text); }

.ask-row { display: flex; gap: 8px; align-items: flex-end; }
.ask-row textarea {
  flex: 1; resize: none; max-height: 130px; min-height: 42px;
  padding: 10px 13px; border-radius: 11px; line-height: 1.45;
  border: 1px solid var(--border); background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s; font-size: 13.5px;
}
.ask-row textarea:focus { border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-soft); }
.ask-row .send {
  width: 42px; height: 42px; flex: none; border-radius: 11px;
  display: grid; place-items: center; background: var(--accent); color: #fff;
  transition: background .15s, opacity .15s;
}
.ask-row .send:hover { background: var(--accent-strong); }
.ask-row .send:disabled { opacity: .4; cursor: default; }
.ask-row .mic {
  width: 42px; height: 42px; flex: none; border-radius: 11px;
  display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-soft);
  transition: all .15s;
}
.ask-row .mic:hover { color: var(--text); border-color: var(--border-strong); }
.ask-row .mic.rec { color: var(--red); border-color: var(--red); background: var(--red-soft); animation: micPulse 1.4s infinite; }
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--red-soft); }
  50% { box-shadow: 0 0 0 6px var(--red-soft); }
}
.panel-foot .hint { font-size: 11px; color: var(--muted); margin-top: 7px; text-align: center; }

/* chat-blokken onder de uitleg */
.chat-turn { margin-top: 18px; }
.chat-q {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 10px 14px; border-radius: 12px 12px 12px 4px;
  background: var(--accent-soft); border: 1px solid var(--accent-border);
  font-size: 13.5px; font-weight: 500; color: var(--text);
}
.chat-q .chip { flex: none; margin-top: 1px; }
.chat-a { padding: 4px 2px 0; }

/* status-regel tijdens streamen */
.stream-status { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; padding: 6px 0 14px; }
.stream-status .dots { display: inline-flex; gap: 4px; }
.stream-status .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: bounce 1.2s infinite; }
.stream-status .dots i:nth-child(2) { animation-delay: .15s; }
.stream-status .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.md-error {
  display: flex; gap: 10px; align-items: flex-start; padding: 14px;
  border-radius: var(--radius); background: var(--red-soft); border: 1px solid var(--red);
  color: var(--text); font-size: 13.5px;
}
.md-error .icon { color: var(--red); margin-top: 1px; }

/* snelle acties onder de uitleg */
.quick-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.quick-chips button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 99px; font-size: 12.5px; font-weight: 550;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-soft);
  transition: all .15s;
}
.quick-chips button:hover { border-color: var(--accent-border); color: var(--accent); background: var(--accent-soft); }
.quick-chips .icon { width: 13px; height: 13px; }

/* notitie + markeringen bij een dia (achter de potlood-knop) */
.note-box {
  margin-bottom: 16px; padding: 11px 13px; border-radius: 12px;
  background: var(--amber-soft); border: 1px solid rgba(242,185,92,.35);
}
.note-box .flag-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.flag-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 99px; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-soft);
  transition: all .15s;
}
.flag-chip:hover { border-color: var(--border-strong); color: var(--text); }
.flag-chip.star.on { color: var(--amber); border-color: var(--amber); background: var(--amber-soft); }
.flag-chip.unclear.on { color: var(--red); border-color: var(--red); background: var(--red-soft); }
.note-box label {
  display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--amber); margin-bottom: 5px;
}
.note-box textarea {
  width: 100%; border: none; background: none; outline: none; resize: vertical;
  color: var(--text); font-size: 13.5px; line-height: 1.55; min-height: 54px;
  border-radius: 6px;
}
.note-box textarea:focus { box-shadow: 0 0 0 3px var(--accent-soft); }
.icon-btn.on { background: var(--accent-soft); color: var(--accent); }
.icon-btn.has-dot { position: relative; }
.icon-btn.has-dot::after {
  content: ""; position: absolute; top: 5px; right: 5px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--amber);
}

/* meta-regel onder afgeronde uitleg */
.answer-meta {
  display: flex; align-items: center; gap: 8px; margin-top: 16px; padding-top: 12px;
  border-top: 1px dashed var(--border); font-size: 11.5px; color: var(--muted); flex-wrap: wrap;
}
.answer-meta .spacer { flex: 1; }

/* =====================================================
   Markdown-typografie (het hart van de leeservaring)
   ===================================================== */
.md { font-size: 15px; line-height: 1.72; color: var(--text); overflow-wrap: break-word; }
.md > *:first-child { margin-top: 0; }
.md h1, .md h2, .md h3, .md h4 { font-weight: 700; letter-spacing: -.015em; line-height: 1.3; margin: 1.5em 0 .5em; }
.md h1 { font-size: 21px; } .md h2 { font-size: 18px; } .md h3 { font-size: 16px; } .md h4 { font-size: 14.5px; }
.md h2 { padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.md p { margin: .7em 0; }
.md strong { font-weight: 650; color: var(--text); }
.md ul, .md ol { margin: .6em 0; padding-left: 1.45em; }
.md li { margin: .32em 0; }
.md li::marker { color: var(--accent); font-weight: 600; }
.md blockquote {
  margin: 1em 0; padding: 10px 16px; border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 10px 10px 0; color: var(--text-soft);
}
.md blockquote p { margin: .3em 0; }
.md code { font-family: var(--font-mono); font-size: .86em; padding: 2px 6px; border-radius: 5px; background: var(--code-bg); border: 1px solid var(--border); }

/* Meeleesindicator: het blok dat nu wordt voorgelezen (TTS) licht subtiel op.
   box-shadow i.p.v. padding => geen layout-verschuiving. */
.md .tts-reading {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  border-radius: 6px;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 15%, transparent);
  transition: background .15s ease, box-shadow .15s ease;
}
.md pre { margin: 1em 0; padding: 14px 16px; border-radius: 10px; background: var(--code-bg); border: 1px solid var(--border); overflow-x: auto; }
.md pre code { padding: 0; border: none; background: none; font-size: 13px; line-height: 1.6; }
.md table { border-collapse: collapse; margin: 1em 0; width: 100%; font-size: 13.5px; }
.md th, .md td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; }
.md th { background: var(--surface-2); font-weight: 600; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 1.6em 0; }
.md img { max-width: 100%; border-radius: 8px; }
.md .katex { font-size: 1.06em; }
.md .katex-display { margin: 1em 0; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow-x: auto; overflow-y: hidden; }

/* grafieken (```chart-blokken) */
.md .chart-wrap {
  position: relative; height: 300px; max-width: 100%; margin: 1.2em 0;
  padding: 12px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
}
.md .chart-error {
  margin: 1em 0; padding: 10px 14px; border-radius: 10px;
  background: var(--red-soft); border: 1px solid var(--red);
  color: var(--text-soft); font-size: 13px;
}

.md .stream-caret {
  display: inline-block; width: 8px; height: 17px; margin-left: 2px; vertical-align: -3px;
  background: var(--accent); border-radius: 2px; animation: caret 1s infinite;
}
@keyframes caret { 0%, 55% { opacity: 1; } 60%, 100% { opacity: .15; } }

/* skeleton */
.skeleton { display: flex; flex-direction: column; gap: 12px; padding: 6px 0; }
.skeleton .bone { height: 13px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 45%, var(--surface-2) 65%); background-size: 220% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { 0% { background-position: 130% 0; } 100% { background-position: -90% 0; } }

/* =====================================================
   Content-tabs (samenvatting / quiz / flashcards)
   ===================================================== */
.content-page { flex: 1; overflow-y: auto; min-height: 0; }
.content-inner { max-width: 780px; margin: 0 auto; padding: 34px 28px 90px; }
.content-inner.narrow { max-width: 620px; }

.page-title { display: flex; align-items: center; gap: 12px; margin: 0 0 6px; font-size: 23px; font-weight: 750; letter-spacing: -.02em; }
.page-title .icon { color: var(--accent); width: 24px; height: 24px; }
.page-sub { color: var(--muted); margin: 0 0 26px; font-size: 14px; }

.setup-card { padding: 22px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 18px; }
.setup-row { display: flex; flex-direction: column; gap: 8px; }
.setup-row > label { font-size: 12.5px; font-weight: 650; color: var(--text-soft); }

/* ---- quiz ---- */
.quiz-top { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.quiz-top .progress-track { flex: 1; }
.quiz-top .count { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.q-card { padding: 24px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); }
.q-card .q-meta { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.q-text { font-size: 16.5px; font-weight: 600; line-height: 1.5; margin-bottom: 18px; }

.mc-opts { display: flex; flex-direction: column; gap: 9px; }
.mc-opt {
  display: flex; align-items: flex-start; gap: 12px; text-align: left;
  padding: 12px 15px; border-radius: 11px; font-size: 14px; line-height: 1.5;
  border: 1px solid var(--border); background: var(--surface-2);
  transition: all .15s; width: 100%;
}
.mc-opt:hover:not(:disabled) { border-color: var(--accent-border); background: var(--accent-soft); }
.mc-opt .key {
  flex: none; width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--muted); margin-top: 1px;
}
.mc-opt.correct { border-color: var(--green); background: var(--green-soft); }
.mc-opt.correct .key { background: var(--green); color: #fff; }
.mc-opt.wrong { border-color: var(--red); background: var(--red-soft); }
.mc-opt.wrong .key { background: var(--red); color: #fff; }
.mc-opt:disabled { cursor: default; }

.grade-box { margin-top: 18px; padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); }

/* zelfbeoordeling bij open vragen */
.btn.self-good { color: var(--green); border-color: var(--green); background: var(--green-soft); font-weight: 600; }
.btn.self-good:hover { background: var(--green); color: #fff; }
.btn.self-wrong { color: var(--red); border-color: var(--red); background: var(--red-soft); font-weight: 600; }
.btn.self-wrong:hover { background: var(--red); color: #fff; }
.grade-box.correct { border-color: var(--green); background: var(--green-soft); }
.grade-box.partial { border-color: var(--amber); background: var(--amber-soft); }
.grade-box.incorrect { border-color: var(--red); background: var(--red-soft); }
.grade-head { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; margin-bottom: 8px; }

/* Foutanalyse: welk type fout is gemaakt (amber = "let op", niet fout-rood). */
.err-chip { color: var(--amber); background: var(--amber-soft); border-color: transparent; font-weight: 600; }
.grade-head .err-chip { margin-left: auto; }

/* Herstelvragen: gerichte oefening na een fout. */
.recovery-wrap { margin-top: 12px; }
.recovery-box { margin-top: 12px; padding: 12px 14px; border: 1px dashed var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.recovery-q { margin-top: 12px; }
.recovery-q:first-of-type { margin-top: 4px; }
.recovery-q-text { font-weight: 600; font-size: 13.5px; }
.recovery-answer { margin-top: 8px; }

/* Opgaven-tab */
.exercise-stage { display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.exercise-img { max-width: 100%; max-height: 62vh; border-radius: var(--radius-sm); }
.widen-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-soft); cursor: pointer; }
.locate-box, .help-box { padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); }
.locate-slide { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.locate-slide img { width: 96px; height: 60px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); flex-shrink: 0; }
.help-box .field { margin-top: 10px; }
.scope-chip {
  display: inline-flex; align-items: center; gap: 6px; margin: 2px 0 14px;
  padding: 4px 10px; border-radius: 99px; font-size: 12.5px;
  color: var(--text-soft); background: var(--surface-2); border: 1px solid var(--border);
}
.scope-chip svg { color: var(--accent); }
.question-card { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); margin-top: 12px; }
.question-text { font-size: 14px; line-height: 1.5; }

.quiz-actions { display: flex; gap: 10px; margin-top: 22px; align-items: center; }
.quiz-actions .spacer { flex: 1; }

.score-hero { text-align: center; padding: 36px 20px 26px; }
.score-ring { width: 132px; height: 132px; margin: 0 auto 16px; position: relative; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring .val { position: absolute; inset: 0; display: grid; place-items: center; font-size: 28px; font-weight: 800; }
.review-list { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }
.review-item { padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); display: flex; gap: 12px; align-items: flex-start; font-size: 13.5px; }
.review-item .icon { margin-top: 2px; flex: none; }

/* ---- flashcards ---- */
.fc-stats { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-card { flex: 1; min-width: 130px; padding: 14px 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.stat-card .num { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.stat-card .lbl { font-size: 12px; color: var(--muted); font-weight: 500; }

.fc-scene { perspective: 1400px; margin: 8px 0 18px; }
.fc-card {
  position: relative; width: 100%; min-height: 270px; cursor: pointer;
  transform-style: preserve-3d; transition: transform .5s var(--ease);
}
.fc-card.flipped { transform: rotateX(180deg); }
.fc-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 30px 34px; border-radius: var(--radius-lg); text-align: center;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1);
  overflow-y: auto;
}
.fc-face.back { transform: rotateX(180deg); background: var(--surface-2); }
.fc-face .side-lbl { position: absolute; top: 14px; left: 16px; font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.fc-face .page-ref { position: absolute; top: 12px; right: 14px; }
.fc-face .md { font-size: 16.5px; text-align: center; }

.fc-rates { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.rate-btn {
  padding: 12px 8px; border-radius: 11px; text-align: center; font-weight: 650; font-size: 13.5px;
  border: 1px solid var(--border); background: var(--surface); transition: all .15s;
  display: flex; flex-direction: column; gap: 2px; align-items: center;
}
.rate-btn small { font-size: 10.5px; color: var(--muted); font-weight: 500; }
.rate-btn:hover { transform: translateY(-1px); }
.rate-btn.again:hover { border-color: var(--red); background: var(--red-soft); }
.rate-btn.hard:hover { border-color: var(--amber); background: var(--amber-soft); }
.rate-btn.good:hover { border-color: var(--accent); background: var(--accent-soft); }
.rate-btn.easy:hover { border-color: var(--green); background: var(--green-soft); }

.fc-done { text-align: center; padding: 50px 20px; }
.fc-done .big { font-size: 42px; margin-bottom: 10px; }

/* =====================================================
   Modals, drawer, zoeken, toasts
   ===================================================== */
.modal-scrim {
  position: fixed; inset: 0; background: var(--scrim); z-index: 60;
  display: grid; place-items: start center; padding: 12vh 16px 16px;
  backdrop-filter: blur(3px); animation: fadeIn .16s var(--ease);
}
.modal-scrim.center { place-items: center; padding: 16px; }
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 620px; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-2); overflow: hidden; animation: pop .2s var(--ease);
  display: flex; flex-direction: column; max-height: 78vh;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.modal.sm { max-width: 420px; }

.search-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.search-head .icon { color: var(--muted); }
.search-head input { flex: 1; background: none; border: none; outline: none; font-size: 15.5px; color: var(--text); border-radius: 6px; }
.search-head input:focus { box-shadow: 0 0 0 3px var(--accent-soft); }
.search-results { overflow-y: auto; padding: 8px; }
.search-hit {
  display: flex; gap: 12px; padding: 9px 10px; border-radius: 10px; cursor: pointer;
  align-items: center; width: 100%; text-align: left;
}
.search-hit:hover, .search-hit.sel { background: var(--surface-2); }
.search-hit img { width: 74px; aspect-ratio: 16/9.4; object-fit: cover; border-radius: 6px; background: var(--slide-bg); flex: none; border: 1px solid var(--border); }
.search-hit .info { min-width: 0; }
.search-hit .t { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-hit .s { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-hit .s mark { background: var(--amber-soft); color: var(--amber); border-radius: 3px; padding: 0 2px; }
.search-empty { padding: 26px; text-align: center; color: var(--muted); font-size: 13.5px; }

/* modal-inhoud die intern moet scrollen (raster, zoekresultaten) */
.grid-wrap { display: flex; flex-direction: column; min-height: 0; }
.grid-wrap .search-head { flex: none; }
.grid-wrap .grid-scroll, .grid-wrap .search-results { flex: 1; min-height: 0; overflow-y: auto; }

/* raster-overzicht van alle dia's (het raster zelf houdt zijn natuurlijke
   hoogte; de .grid-scroll eromheen doet het scrollen) */
.grid-ov {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px; padding: 14px;
}
.grid-ov button {
  position: relative; border-radius: 9px; overflow: hidden;
  border: 2px solid var(--border); background: var(--slide-bg);
  cursor: pointer; transition: border-color .15s, transform .15s;
}
.grid-ov button:hover { transform: translateY(-1px); border-color: var(--border-strong); }
.grid-ov button.on { border-color: var(--accent); }
.grid-ov img { width: 100%; aspect-ratio: 16/9.3; object-fit: cover; display: block; }
.grid-ov .n {
  position: absolute; bottom: 4px; right: 5px; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 5px; background: rgba(5,8,14,.72); color: #fff;
}

.drawer-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 55; animation: fadeIn .16s var(--ease); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 340px; max-width: 92vw; z-index: 56;
  background: var(--surface); border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow-2); display: flex; flex-direction: column;
  animation: slideIn .22s var(--ease);
}
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.drawer-head h3 { margin: 0; font-size: 15.5px; }
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 22px; }
.drawer-sec { display: flex; flex-direction: column; gap: 9px; }
.drawer-sec > label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* Account staat echt onderaan de scrollbare instellingeninhoud; niet sticky. */
.drawer-account-section { margin-top: 2px; padding-top: 18px; border-top: 1px solid var(--border); }
.account-card {
  position: relative; overflow: visible; flex: none; border: 1px solid var(--border-strong);
  border-radius: 14px; background: var(--surface-2); box-shadow: var(--shadow-1);
}
.account-card-head {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px;
  border: 0; color: var(--text); background: transparent; text-align: left;
}
.account-card-head:hover { background: var(--surface-3); }
.account-avatar {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center;
  border-radius: 50%; color: #fff; font-size: 12px; font-weight: 800; letter-spacing: .04em;
  background: var(--avatar-color, #2563eb);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.account-identity { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.account-identity strong { font-size: 13.5px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-identity span { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-plan {
  position: relative; overflow: hidden; flex: none; padding: 3px 7px; border-radius: 99px; color: var(--accent);
  background: var(--accent-soft); font-size: 10px; font-weight: 750;
}
.account-plan.owner {
  color: #fff; background: linear-gradient(110deg, #6d28d9, #2563eb, #db2777, #d97706, #6d28d9);
  background-size: 280% 100%; border: 1px solid rgba(255,255,255,.2);
  box-shadow: 0 0 16px rgba(124,58,237,.28);
  animation: ownerGradient 5s linear infinite;
}
.account-plan.owner::after {
  content: ""; position: absolute; inset: -2px auto -2px -45%; width: 32%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.68), transparent);
  transform: skewX(-18deg); animation: ownerShine 2.8s ease-in-out infinite;
}
@keyframes ownerGradient { to { background-position: 280% 0; } }
@keyframes ownerShine { 0%, 48% { left: -45%; } 78%, 100% { left: 125%; } }
@media (prefers-reduced-motion: reduce) {
  .account-plan.owner, .account-plan.owner::after, .owner-plan-title { animation: none; }
}
.account-toggle-icon { width: 18px; color: var(--muted); transition: transform .18s; }
.account-card-head[aria-expanded="true"] .account-toggle-icon { transform: rotate(180deg); }
.account-menu {
  position: absolute; z-index: 3; left: -1px; right: -1px; bottom: calc(100% + 8px);
  overflow: hidden; border: 1px solid var(--border-strong); border-radius: 14px;
  background: var(--surface-2); box-shadow: var(--shadow-2);
  transform-origin: bottom center; animation: accountMenuUp .16s var(--ease);
}
@keyframes accountMenuUp {
  from { opacity: 0; transform: translateY(7px) scale(.985); }
}
.account-menu[hidden] { display: none; }
.account-menu-row {
  width: 100%; min-height: 42px; padding: 9px 12px; display: flex; align-items: center; gap: 10px;
  color: var(--text-soft); text-align: left; border: 0; border-bottom: 1px solid var(--border);
  background: transparent; font-size: 12.5px; transition: background .15s, color .15s;
}
.account-menu-row:last-child { border-bottom: 0; }
button.account-menu-row:hover { color: var(--text); background: var(--surface-3); }
.account-menu-row:disabled { opacity: .55; cursor: wait; }
.account-menu-row.static { cursor: default; }
.account-row-icon { width: 22px; height: 22px; flex: none; display: grid; place-items: center; color: var(--muted); }
.account-row-main { min-width: 0; flex: 1; font-weight: 580; }
.account-row-value { color: var(--muted); font-size: 11px; text-align: right; }
.account-menu-row > .icon { width: 14px; height: 14px; color: var(--muted); }
.account-menu-row.danger, .account-menu-row.danger .account-row-icon { color: var(--red); }

.plans-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.plan-card { display: flex; flex-direction: column; min-height: 180px; padding: 15px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface-2); }
.plan-card.current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.plan-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plan-card-top strong { font-size: 15px; }
.plan-current { padding: 3px 7px; border-radius: 99px; color: var(--accent); background: var(--accent-soft); font-size: 10px; font-weight: 750; }
.plan-price { margin-top: 14px; color: var(--text); font-size: 20px; font-weight: 760; letter-spacing: -.025em; }
.plan-credits { margin-top: 3px; color: var(--accent); font-size: 11.5px; font-weight: 700; }
.plan-card p { flex: 1; margin: 10px 0 18px; color: var(--text-soft); font-size: 12.5px; line-height: 1.55; }
.plan-card .btn { width: 100%; justify-content: center; }
.plan-credit-rules { margin: 14px 2px 0; color: var(--muted); font-size: 11.5px; line-height: 1.5; }

/* Volwaardige plan- en factureringspagina. */
.billing-inner { max-width: 980px; }
.billing-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.billing-overview {
  display: flex; align-items: center; justify-content: space-between; gap: 28px;
  margin: 26px 0 34px; padding: 22px 24px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); background: linear-gradient(135deg, var(--surface), var(--surface-2));
  box-shadow: var(--shadow-1);
}
.billing-overview-main { min-width: 0; }
.billing-eyebrow { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; }
.billing-current-line { display: flex; align-items: center; gap: 10px; }
.billing-current-line h2 { margin: 0; font-size: 24px; letter-spacing: -.025em; }
.billing-current-line .owner-plan-title {
  color: transparent; background: linear-gradient(100deg, #8b5cf6, #60a5fa, #f472b6, #fbbf24, #8b5cf6);
  background-size: 280% 100%; -webkit-background-clip: text; background-clip: text;
  text-shadow: 0 0 24px rgba(139,92,246,.2); animation: ownerGradient 5s linear infinite;
}
.billing-overview-main p { margin: 6px 0 0; max-width: 590px; color: var(--text-soft); font-size: 13px; }
.billing-usage { flex: none; min-width: 170px; padding: 13px 15px; border-radius: 12px; background: var(--bg-soft); border: 1px solid var(--border); }
.billing-usage span { display: block; color: var(--muted); font-size: 11px; }
.billing-usage strong { display: block; margin-top: 3px; font-size: 14px; }
.billing-plans > h2 { margin: 0 0 14px; font-size: 17px; }
.billing-page .plan-card { min-height: 245px; padding: 20px; }
.billing-page .plan-card-top strong { font-size: 17px; }
.billing-page .plan-price { margin-top: 18px; font-size: 24px; }
.billing-invoices {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  margin-top: 28px; padding: 18px 20px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
}
.billing-invoices h2 { margin: 0 0 3px; font-size: 15px; }
.billing-invoices p { margin: 0; color: var(--muted); font-size: 12.5px; }
.billing-invoices > span { flex: none; padding: 5px 9px; border-radius: 99px; color: var(--muted); background: var(--surface-2); font-size: 10.5px; font-weight: 700; }

/* upgrade-melding (maandcredits op) */
.upgrade-modal { padding: 28px 26px 22px; text-align: center; }
.upgrade-modal .upgrade-badge {
  width: 60px; height: 60px; margin: 0 auto 16px; border-radius: 16px;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent), #9d7bff);
  box-shadow: var(--shadow-2);
}
.upgrade-modal h3 { margin: 0 0 8px; font-size: 18px; letter-spacing: -.01em; }
.upgrade-modal p { margin: 0 auto; max-width: 380px; color: var(--text-soft); font-size: 13.5px; line-height: 1.6; }
.upgrade-foot { display: flex; gap: 10px; justify-content: center; margin-top: 22px; }

.confirm-body { padding: 22px; }
.confirm-body h3 { margin: 0 0 8px; font-size: 16px; }
.confirm-body p { margin: 0; color: var(--muted); font-size: 13.5px; }
.confirm-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 22px 20px; }

#toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  display: flex; align-items: center; gap: 9px; padding: 10px 18px;
  border-radius: 99px; background: var(--surface-3); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-2); font-size: 13.5px; font-weight: 500;
  animation: toastIn .25s var(--ease);
}
.toast.err { border-color: var(--red); }
.toast.err .icon { color: var(--red); }
.toast.ok .icon { color: var(--green); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
.toast.leaving { opacity: 0; transform: translateY(8px); transition: all .25s; }

/* =====================================================
   Focusmodus
   ===================================================== */
body.focus-mode .topbar { display: none; }
body.focus-mode .panel { max-width: 560px; }
/* alleen een klein, rustig kruisje — geen timer of tekst */
.focus-exit {
  position: fixed; top: 14px; right: 14px; z-index: 40;
  display: none; width: 38px; height: 38px; border-radius: 50%;
  place-items: center;
  background: var(--scrim); color: #e8ecf5; backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.12);
  opacity: .55; transition: opacity .15s;
}
.focus-exit:hover { opacity: 1; }
body.focus-mode .focus-exit { display: grid; }

/* =====================================================
   Responsief
   ===================================================== */
@media (max-width: 980px) {
  .workspace { flex-direction: column; overflow-y: auto; }
  .panel-divider { display: none; }
  .panel { flex: 1 !important; max-width: none !important; }
  .stage { flex: none; min-height: 46vh; }
  .panel { max-width: none; min-width: 0; border-left: none; border-top: 1px solid var(--border); flex: 1; }
  .slide-frame img { max-height: 42vh; }
  .topbar { overflow-x: auto; }
  .tabs button span.lbl { display: none; }
  .stage-nav .nav-btn .lbl { display: none; }
}

/* telefoons */
@media (max-width: 640px) {
  .plans-grid { grid-template-columns: 1fr; }
  .billing-overview { align-items: stretch; flex-direction: column; padding: 18px; }
  .billing-usage { min-width: 0; }
  .billing-invoices { align-items: flex-start; flex-direction: column; }
  .home-inner { padding: 26px 14px 60px; }
  .hero { margin-bottom: 22px; }
  .hero h1 .hero-type-line { min-height: 2.3em; }
  .hero p { font-size: 14px; }
  .dropzone { padding: 26px 14px; }
  .dropzone .formats { gap: 5px; }
  .doc-grid, .folder-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }

  .topbar { padding: 0 10px; gap: 6px; }
  .topbar .doc-name { max-width: 110px; }

  .content-inner, .content-inner.narrow { max-width: none; padding: 18px 14px 70px; }
  .setup-card { padding: 15px; }
  .q-card { padding: 15px; }
  .q-text { font-size: 15px; }
  .quiz-actions { flex-wrap: wrap; row-gap: 8px; }
  .fc-rates { grid-template-columns: repeat(2, 1fr); }
  .fc-face { padding: 22px 18px; }
  .fc-card { min-height: 220px; }
  .score-ring { width: 104px; height: 104px; }

  .stage-nav { flex-wrap: wrap; row-gap: 6px; }
  .stage-progress { flex: 1 1 100%; order: 3; max-width: none; }

  .modal-scrim { padding: 4vh 10px 10px; }
  .modal-scrim.center { padding: 10px; }
  .modal { max-height: 88vh; }
  .drawer { width: 100%; max-width: 100vw; }
  .grid-ov { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }

  .plan-row { flex-wrap: wrap; row-gap: 6px; }
}

/* =====================================================
   Mappen (vakken)
   ===================================================== */
.section-title .btn { text-transform: none; letter-spacing: 0; margin-left: 4px; }

.folder-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px; margin-bottom: 8px;
}
.folder-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; transition: transform .18s var(--ease), border-color .18s, box-shadow .18s;
  color: var(--text);
}
.folder-card:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.folder-card .f-icon {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center;
  border-radius: 10px; background: var(--accent-soft); color: var(--accent);
}
.folder-card .f-name {
  font-weight: 650; font-size: 13.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.folder-card .f-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.folder-card > .icon { color: var(--muted); flex: none; }

/* tweede hover-knop op documentkaarten: in map zetten */
.doc-card .del.move { right: 44px; }
.doc-card .del.move:hover { background: var(--accent); }

/* mapkiezer in de modal */
.folder-pick { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; }
.folder-pick-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; font-size: 13px;
  transition: border-color .15s, background .15s;
}
.folder-pick-row:hover { border-color: var(--accent-border); background: var(--surface-3); }
.folder-pick-row.new { color: var(--accent); background: transparent; border-style: dashed; }

/* snelkoppelingen op documentkaarten in de mapweergave */
.doc-card .card-actions { display: flex; gap: 8px; margin-top: 4px; }
.doc-card .card-actions .btn { font-size: 12px; padding: 4px 10px; }

/* =====================================================
   Tentamenmodus: herhaalplanning
   ===================================================== */
.plan-bucket {
  margin-top: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  padding: 14px 16px;
}
.plan-bucket-head {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; font-weight: 700; margin-bottom: 10px;
}
.plan-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.plan-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0; border-top: 1px solid var(--border);
}
.plan-row:first-of-type { border-top: none; }

/* =====================================================
   Offline-indicator
   ===================================================== */
.offline-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: none; align-items: center; justify-content: center;
  padding: 7px 14px; font-size: 12.5px; font-weight: 600;
  background: var(--amber); color: #1a1200; text-align: center;
}

/* =====================================================
   Print (samenvatting -> "opslaan als PDF")
   ===================================================== */
@media print {
  :root, [data-theme="dark"], [data-theme="light"] {
    --bg: #fff; --bg-soft: #fff; --surface: #fff; --surface-2: #fff; --surface-3: #fff;
    --text: #111; --text-soft: #333; --muted: #555;
    --border: #ccc; --border-strong: #999; --code-bg: #f4f4f4;
    --accent: #234; --green: #227755; --amber: #8a6414; --red: #a33;
  }
  html, body, #app { height: auto; overflow: visible; background: #fff; }
  body * { visibility: hidden; }
  .content-page, .content-page * { visibility: visible; }
  .content-page { position: absolute; inset: 0; width: 100%; height: auto; overflow: visible; }
  .content-inner, .content-inner.narrow { max-width: none; padding: 0 12px 24px; }
  .no-print { display: none !important; }
}

/* =====================================================
   INLOGGEN
   ===================================================== */
.auth-page { flex: 1; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth-card {
  width: 100%; max-width: 380px; padding: 30px 28px 24px;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow-2);
}
.auth-brand { display: flex; justify-content: center; margin-bottom: 20px; }
.auth-title { margin: 0 0 6px; font-size: 21px; font-weight: 700; text-align: center; }
.auth-sub { margin: 0; font-size: 13.5px; color: var(--muted); text-align: center; line-height: 1.5; }
.password-field { position: relative; width: 100%; }
.password-field .field { width: 100%; padding-right: 46px; }
.password-toggle {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 8px; color: var(--muted); transition: color .15s, background .15s;
}
.password-toggle:hover, .password-toggle:focus-visible { color: var(--text); background: var(--surface-3); }
.password-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.auth-error {
  margin-top: 12px; padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--red-soft, rgba(220,80,80,.12)); color: var(--red, #e06b6b);
  font-size: 13px; border: 1px solid var(--red-border, rgba(220,80,80,.25));
}
.auth-fine { margin: 16px 0 0; font-size: 11.5px; color: var(--muted); text-align: center; line-height: 1.5; }
.auth-notice {
  margin-top: 12px; padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--green-soft); color: var(--green);
  font-size: 13px; line-height: 1.45; border: 1px solid transparent;
}
.auth-links { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-top: 10px; }
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 16px 0 12px; color: var(--muted); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
