:root {
  --bg: #f4f8fa;
  --surface: #ffffff;
  --surface-2: #eef5f7;
  --ink: #16313d;
  --muted: #62808e;
  --line: #e1ebef;
  --brand: #12a594;
  --brand-ink: #0b6f63;
  --brand-soft: #dff5f1;
  --accent: #ff7a59;
  --accent-soft: #ffe9e2;
  --danger: #d6423a;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(22, 49, 61, .05), 0 8px 24px rgba(22, 49, 61, .06);
  --bar-h: 64px;
  --tab-h: 72px;
  --side-w: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1a20; --surface: #15262e; --surface-2: #1b303a; --ink: #e6f1f4; --muted: #8fb0bc;
    --line: #24404c; --brand: #2cc4b1; --brand-ink: #7fe3d5; --brand-soft: #14423e;
    --accent-soft: #4a2a22; --shadow: 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
a { color: var(--brand-ink); }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- knoppen & formulieren ---------- */
button, .btn {
  font: inherit; cursor: pointer; border: 1px solid transparent; border-radius: 12px;
  padding: .65rem 1.1rem; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  background: var(--brand); color: #fff; font-weight: 600; text-decoration: none;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
}
button:hover, .btn:hover { background: var(--brand-ink); }
button:active { transform: scale(.98); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
button.secondary:hover { background: var(--surface-2); }
button.ghost { background: transparent; color: var(--brand-ink); }
button.ghost:hover { background: var(--brand-soft); }
button.danger { background: transparent; color: var(--danger); border-color: var(--line); }
button.danger:hover { background: var(--accent-soft); }
button.accent { background: var(--accent); }
button.accent:hover { background: #e9633f; }
button.icon-btn { padding: 0; width: 44px; background: transparent; color: var(--ink); }
button.icon-btn:hover { background: var(--surface-2); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }

label { display: block; font-weight: 600; font-size: .9rem; margin: 0 0 .35rem; }
input, textarea, select {
  width: 100%; font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: .65rem .8rem; min-height: 44px;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 3px solid color-mix(in srgb, var(--brand) 40%, transparent); border-color: var(--brand); }
.field { margin-bottom: 1rem; }
.hint { font-size: .85rem; color: var(--muted); margin-top: .3rem; }
.error-msg { background: var(--accent-soft); color: var(--danger); border-radius: 12px; padding: .6rem .8rem; margin-bottom: 1rem; font-size: .95rem; }
.ok-msg { background: var(--brand-soft); color: var(--brand-ink); border-radius: 12px; padding: .6rem .8rem; margin-bottom: 1rem; font-size: .95rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.card + .card { margin-top: 1rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---------- avatar ---------- */
.avatar {
  --size: 40px; width: var(--size); height: var(--size); border-radius: 50%; flex: none; overflow: hidden;
  display: inline-grid; place-items: center; color: #fff; font-weight: 700; font-size: calc(var(--size) * .4);
  background: var(--avatar-bg, var(--brand)); user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- login ---------- */
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem 16px;
  background: radial-gradient(1200px 500px at 10% -10%, var(--brand-soft), transparent 60%), radial-gradient(900px 400px at 100% 110%, var(--accent-soft), transparent 55%), var(--bg); }
.auth-card { width: 100%; max-width: 420px; }
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.25rem; letter-spacing: -.02em; }
.brand img { width: 36px; height: 36px; border-radius: 10px; }
.auth-card .brand { justify-content: center; margin-bottom: .4rem; font-size: 1.6rem; }
.auth-card .tagline { text-align: center; color: var(--muted); margin-bottom: 1.5rem; }
.auth-card button[type=submit] { width: 100%; }
.switch { text-align: center; margin-top: 1rem; font-size: .95rem; }

/* ---------- shell ---------- */
.shell { min-height: 100dvh; display: grid; grid-template-columns: var(--side-w) 1fr; }
.sidebar { position: sticky; top: 0; height: 100dvh; padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: 1rem;
  background: var(--surface); border-right: 1px solid var(--line); }
.nav { display: flex; flex-direction: column; gap: .25rem; }
.nav a {
  display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem; border-radius: 12px;
  color: var(--ink); text-decoration: none; font-weight: 600; min-height: 44px;
}
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-ink); }
.nav svg, .tab svg, .icon svg { width: 22px; height: 22px; flex: none; }
.side-spacer { flex: 1; }
.usercard { display: flex; align-items: center; gap: .7rem; padding: .6rem; border-radius: 14px; background: var(--surface-2); text-decoration: none; color: inherit; }
.usercard .who { min-width: 0; line-height: 1.25; }
.usercard .who b, .usercard .who span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usercard .who span { font-size: .8rem; color: var(--muted); }
.main { min-width: 0; padding: 2rem clamp(16px, 4vw, 40px) 3rem; }
.page { max-width: 960px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head p { margin: 0; color: var(--muted); }

.topbar, .tabbar, .drawer, .scrim { display: none; }

/* ---------- lessen ---------- */
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.lesson-card { display: flex; flex-direction: column; overflow: hidden; padding: 0; text-decoration: none; color: inherit; transition: transform .12s ease, box-shadow .12s ease; }
.lesson-card:hover { transform: translateY(-2px); }
.lesson-cover { aspect-ratio: 16 / 9; background: linear-gradient(135deg, var(--brand-soft), var(--accent-soft)); display: grid; place-items: center; color: var(--brand-ink); overflow: hidden; }
.lesson-cover img { width: 100%; height: 100%; object-fit: cover; }
.lesson-cover svg { width: 40px; height: 40px; opacity: .7; }
.lesson-body { padding: 1rem 1.1rem 1.1rem; }
.lesson-body h3 { margin-bottom: .3rem; }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .6rem; border-radius: 99px; font-size: .8rem; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.chip.brand { background: var(--brand-soft); color: var(--brand-ink); }
.empty { text-align: center; padding: 2.5rem 1rem; }
.empty .art { width: 84px; height: 84px; margin: 0 auto 1rem; border-radius: 26px; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; }
.empty .art svg { width: 40px; height: 40px; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .75rem; }
.media-item { position: relative; border-radius: 14px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.media-item img, .media-item video { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: #000; }
.media-item audio { width: 100%; display: block; padding: .5rem; }
.media-item .meta { padding: .5rem .7rem; font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-item .del { position: absolute; top: 6px; right: 6px; width: 34px; min-height: 34px; padding: 0; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; }
.media-item .del:hover { background: var(--danger); }
.media-item .del svg { width: 18px; height: 18px; }
.audio-box { padding: 1.2rem .5rem .2rem; text-align: center; color: var(--brand-ink); }

.lesson-video { width: 100%; border-radius: 14px; background: #000; margin-top: .75rem; aspect-ratio: 16 / 9; }
.scene-list { display: grid; gap: .5rem; margin: 1rem 0; }
.scene { border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.scene summary { display: flex; align-items: center; gap: .6rem; padding: .7rem .9rem; cursor: pointer; font-weight: 600; min-height: 44px; list-style-position: inside; }
.scene[open] { background: var(--surface); box-shadow: var(--shadow); }
.scene-body { padding: .25rem .9rem 1rem; }
.scene-actions { justify-content: flex-end; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.steps li { display: flex; align-items: center; gap: .8rem; padding: .7rem .9rem; border-radius: 12px; background: var(--surface-2); }
.steps .dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--line); font-size: .8rem; font-weight: 700; color: var(--muted); flex: none; }
.steps li.done .dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.steps li.soon { opacity: .7; }

.prose h2 { margin-top: 1.6rem; }
.prose ol, .prose ul { padding-left: 1.3rem; margin: 0 0 1em; }
.prose li { margin-bottom: .35rem; }
.kbd { display: inline-flex; align-items: center; gap: .3rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 0 .5rem; font-weight: 600; font-size: .9rem; }

.profile-head { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.profile-head .avatar { --size: 96px; }

/* ---------- modal / sheet / toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 25, 31, .5); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { width: 100%; max-width: 520px; max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); border-radius: 20px; padding: 1.25rem; box-shadow: 0 24px 60px rgba(0, 0, 0, .3); }
.modal h2 { margin-bottom: 1rem; }
.modal .actions { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1rem; }
.recorder video { width: 100%; border-radius: 14px; background: #000; max-height: 50dvh; }
.rec-timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.4rem; text-align: center; margin: .6rem 0; }
.rec-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--danger); margin-right: .5rem; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; }
.choice-grid button { flex-direction: column; padding: 1rem .5rem; gap: .4rem; }
.choice-grid svg { width: 28px; height: 28px; }
.progress { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .15s linear; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--bg); padding: .7rem 1.1rem; border-radius: 12px; max-width: calc(100vw - 32px); box-shadow: var(--shadow); }
@media (min-width: 821px) { .toast { bottom: 24px; } }

/* ---------- mobiel ---------- */
@media (max-width: 820px) {
  .shell { display: block; padding-top: calc(var(--bar-h) + env(safe-area-inset-top)); padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
  .sidebar { display: none; }
  .main { padding: 1.25rem 16px 2rem; }
  h1 { font-size: 1.4rem; }

  .topbar { display: flex; align-items: center; gap: .5rem; position: fixed; top: 0; left: 0; right: 0; z-index: 30;
    height: calc(var(--bar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
  .topbar .brand { flex: 1; justify-content: center; font-size: 1.1rem; }
  .topbar .brand img { width: 30px; height: 30px; }
  .topbar .avatar-btn { padding: 0; width: 44px; background: transparent; }
  .topbar .avatar-btn:hover { background: transparent; }

  .scrim { display: block; position: fixed; inset: 0; background: rgba(10, 25, 31, .5); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .drawer { display: flex; flex-direction: column; gap: 1rem; position: fixed; top: 0; bottom: 0; left: 0; width: min(84vw, 320px); z-index: 45;
    padding: calc(1rem + env(safe-area-inset-top)) 1rem calc(1rem + env(safe-area-inset-bottom)); background: var(--surface);
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow); overflow-y: auto; }
  body.menu-open .drawer { transform: none; }
  body.menu-open .scrim { opacity: 1; pointer-events: auto; }
  body.menu-open { overflow: hidden; }

  .tabbar { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding: 6px 6px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
  .tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 0; padding: 4px 2px;
    background: transparent; color: var(--muted); font-size: .72rem; font-weight: 600; border-radius: 14px; }
  .tab:hover { background: transparent; }
  .tab[aria-current="page"] { color: var(--brand-ink); }
  .tab.rec { color: var(--accent); }
  .tab.rec .icon { display: grid; place-items: center; width: 46px; height: 46px; margin-top: -18px; border-radius: 50%;
    background: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(255, 122, 89, .45); }
  .tab.rec .icon svg { width: 24px; height: 24px; }

  .modal-bg { align-items: end; padding: 0; }
  .modal { max-width: none; border-radius: 22px 22px 0 0; padding-bottom: calc(1.25rem + env(safe-area-inset-bottom)); }
  .lesson-grid { grid-template-columns: 1fr; }
  .media-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
