:root {
  --bg: #F2F5F6;
  --surface: #FFFFFF;
  --surface-2: #E6ECEE;
  --ink: #16222B;
  --muted: #5A6A74;
  --line: #D5DEE1;
  --accent: #0B7A70;
  --accent-ink: #FFFFFF;
  --accent-soft: #D3ECE8;
  --track: #D5DEE1;
  --danger: #B3261E;
  --shadow: 0 -6px 24px rgba(22, 34, 43, 0.08);
  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 14px;
  --player-h: 0px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1519;
    --surface: #162127;
    --surface-2: #1F2C33;
    --ink: #E4ECEE;
    --muted: #93A4AC;
    --line: #26343B;
    --accent: #40C9B8;
    --accent-ink: #062521;
    --accent-soft: #173A36;
    --track: #33454E;
    --danger: #FF8A80;
    --shadow: 0 -6px 24px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0E1519;
  --surface: #162127;
  --surface-2: #1F2C33;
  --ink: #E4ECEE;
  --muted: #93A4AC;
  --line: #26343B;
  --accent: #40C9B8;
  --accent-ink: #062521;
  --accent-soft: #173A36;
  --track: #33454E;
  --danger: #FF8A80;
  --shadow: 0 -6px 24px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--body);
  -webkit-tap-highlight-color: transparent;
}

button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding-inline: max(16px, env(safe-area-inset-left, 0px));
  padding-block: calc(env(safe-area-inset-top, 0px) + 28px) calc(var(--player-h) + 32px);
  display: grid;
  gap: 24px;
}

/* Kop */
.masthead { display: grid; gap: 4px; }
.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(28px, 7vw, 38px);
  line-height: 1.1;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.summary { margin: 4px 0 0; color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }

/* Verder luisteren */
.resume-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  text-align: left;
}
.resume-icon {
  flex: none;
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent-ink);
  color: var(--accent);
}
.resume-icon svg { width: 22px; height: 22px; fill: currentColor; }
.resume-text { display: grid; min-width: 0; }
.resume-label { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.85; }
.resume-title { font-family: var(--display); font-weight: 600; font-size: 19px; line-height: 1.25; }
.resume-meta { font-size: 14px; opacity: 0.9; font-variant-numeric: tabular-nums; }

/* Lijst */
.episodes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.ep {
  display: flex;
  align-items: stretch;
  border-top: 1px solid var(--line);
}
.ep:first-child { border-top: 0; }
.ep.is-current { background: var(--accent-soft); }

.ep-main {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 40px 1fr;
  column-gap: 12px;
  row-gap: 6px;
  align-items: center;
  padding: 14px 4px 14px 14px;
  border: 0;
  background: none;
  text-align: left;
}
.ep-num {
  grid-row: span 2;
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  font-family: var(--display);
  font-weight: 700;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}
.ep.is-current .ep-num { background: var(--accent); color: var(--accent-ink); }
.ep-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.ep-title { font-weight: 600; font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; }
.ep-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.ep-bar {
  flex: 1;
  min-width: 48px;
  height: 4px;
  border-radius: 2px;
  background: var(--track);
  overflow: hidden;
}
.ep-bar > span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 2px; }
.ep-dur, .ep-state { white-space: nowrap; }
.ep-state:empty { display: none; }
.ep.is-done .ep-state { color: var(--accent); font-weight: 600; }

.ep-check {
  flex: none;
  width: 56px;
  display: grid; place-items: center;
  border: 0;
  background: none;
  color: var(--muted);
}
.ep-check span {
  display: grid; place-items: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--line);
}
.ep-check svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 3; opacity: 0; }
.ep.is-done .ep-check span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ep.is-done .ep-check svg { opacity: 1; }
@media (hover: hover) {
  .ep-main:hover, .ep-check:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
  .ep-check:hover svg { opacity: 0.5; }
  .ep.is-done .ep-check:hover svg { opacity: 1; }
}

.empty {
  margin: 0;
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}
.empty code { font-size: 14px; }

/* Instellingen */
.settings { display: grid; gap: 18px; font-size: 15px; }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  flex: none;
  position: relative;
  width: 44px; height: 26px;
  border-radius: 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: background 0.15s;
}
.switch-track::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.reset-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.text-btn {
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.danger-btn {
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--danger);
  color: var(--bg);
  font-weight: 600;
}
.keys, .storage-note { margin: 0; color: var(--muted); font-size: 13px; }
kbd {
  font: 12px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
}
@media (hover: none) { .keys { display: none; } }

/* Speler */
.player {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.player-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  display: grid;
  gap: 6px;
}
.now { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.now-num {
  flex: none;
  font-family: var(--display);
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.now-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.timeline { display: grid; gap: 2px; }
.times {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  --pct: 0%;
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  touch-action: none;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--accent) var(--pct), var(--track) var(--pct));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  margin-top: -6px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--track); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: var(--accent); }

.controls {
  display: grid;
  grid-template-columns: 1fr auto auto auto 1fr;
  align-items: center;
  gap: 8px;
}
.speed { justify-self: start; }
.speed select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ctl {
  display: grid; place-items: center;
  width: 52px; height: 52px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink);
}
.ctl svg { width: 30px; height: 30px; fill: currentColor; }
.ctl text { font: 700 6.5px var(--body); fill: currentColor; }
.ctl-main { width: 60px; height: 60px; background: var(--accent); color: var(--accent-ink); }
.ctl-main svg { width: 30px; height: 30px; }
#next { justify-self: end; width: 44px; height: 44px; color: var(--muted); }
#next svg { width: 22px; height: 22px; }
.ctl:disabled { opacity: 0.35; cursor: default; }
@media (hover: hover) {
  .ctl:not(.ctl-main):not(:disabled):hover { background: var(--surface-2); }
}

.i-pause { display: none; }
.player.is-playing .i-play { display: none; }
.player.is-playing .i-pause { display: block; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Terug-link en vakkenoverzicht */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  margin-left: -4px;
  padding: 4px 4px 4px 0;
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}
.back-link svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.5; }

.courses {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}
.course {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 16px 48px 16px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}
.course-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 21px;
  line-height: 1.2;
  text-wrap: balance;
}
.course-meta { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.course-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.course-progress .ep-bar { max-width: 180px; }
.course.is-done .course-state { color: var(--accent); font-weight: 600; }
.course-arrow {
  position: absolute;
  right: 16px;
  top: 50%;
  width: 22px; height: 22px;
  margin-top: -11px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2.5;
}
@media (hover: hover) {
  .course:hover { border-color: var(--accent); }
  .course:hover .course-arrow { stroke: var(--accent); }
}

.empty a, .manage-link { color: var(--accent); font-weight: 600; }
.settings p { margin: 0; }
