:root {
  color-scheme: light;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --page: #f5f2e9;
  --surface: #fffcf6;
  --board: #fffef8;
  --ink: #24332c;
  --muted: #555e53;
  --border: #ddd7c8;
  --frame: #d4cab6;
  --dot: #dfdfcf;
  --accent: #9e3d23;
  --accent-hover: #81311b;
  --on-accent: #fffdf8;
  --accent-soft: #f8e7dd;
  --green: #3c6250;
  --green-soft: #e8eee2;
  --track: #e8e2d5;
  --shadow: 0 10px 34px #4948310a, 0 2px 6px #49483109;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #151d1a;
  --surface: #212c26;
  --board: #20372e;
  --ink: #f4ede0;
  --muted: #c2ccc0;
  --border: #414f45;
  --frame: #57695b;
  --dot: #3c5046;
  --accent: #ffb89f;
  --accent-hover: #ffccb9;
  --on-accent: #30170f;
  --accent-soft: #4c342a;
  --green: #b4d6b9;
  --green-soft: #2f4438;
  --track: #3e4b42;
  --shadow: 0 10px 34px #0002, 0 2px 6px #0002;
}

* { box-sizing: border-box; }

body { margin: 0; color: var(--ink); background: var(--page); }

h1, h2, p { margin: 0; }
button, select, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
a { color: var(--accent); text-underline-offset: .2em; }
[hidden] { display: none !important; }

:where(a, button, input, select, summary):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.shell {
  width: min(1180px, calc(100% - max(32px, env(safe-area-inset-left) + env(safe-area-inset-right) + 24px)));
  margin-inline: auto;
}

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 1.15rem; font-weight: 800; white-space: nowrap; }
.brand-group { display: flex; align-items: center; gap: clamp(8px, 1.5vw, 24px); }
.course-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding-inline-start: clamp(8px, 1.3vw, 20px);
  border-inline-start: 1px solid var(--border);
  color: var(--muted);
  font-size: .86rem;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}
.course-link:hover { color: var(--accent); }
.brand-mark { position: relative; width: 39px; height: 39px; border-radius: 12px; background: var(--accent); color: var(--on-accent); }
.brand-mark::before {
  content: "";
  position: absolute;
  inset: 10px 8px 11px;
  border: 2px solid currentColor;
  border-radius: 3px;
}
.brand-mark::after {
  content: "";
  position: absolute;
  width: 15px;
  height: 3px;
  border-radius: 2px;
  top: 17px;
  left: 13px;
  background: currentColor;
  transform: rotate(-40deg);
  box-shadow: 0 0 0 2px var(--accent);
}

.header-actions, .theme-control, .button, .theme-control button { display: inline-flex; align-items: center; justify-content: center; }
.header-actions { gap: 10px; }
.theme-control { border: 1px solid var(--border); padding: 3px; background: var(--page); border-radius: 13px; }
.theme-control button {
  gap: 6px;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 700;
}
.theme-control button[aria-pressed="true"] { color: var(--ink); background: var(--surface); border-color: var(--border); box-shadow: 0 1px 3px #0001; }
.button {
  gap: 8px;
  padding: .48rem .85rem;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  font-size: .92rem;
  font-weight: 750;
  line-height: 1.25;
  white-space: nowrap;
}
.settings-button, .secondary { border-color: var(--border); background: var(--surface); }
.primary { background: var(--accent); color: var(--on-accent); }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.secondary:hover, .settings-button:hover, .icon-button:hover:not(:disabled) { background: var(--green-soft); }
.icon-button { min-width: 44px; padding: 0; }

.lesson { padding-block: 25px 24px; }
.lesson-header { margin-bottom: 23px; }
.lesson-context { color: var(--green); font-size: .84rem; font-weight: 800; letter-spacing: .05em; }
.lesson-context span { padding-inline: .25em; }
.lesson-intro { display: flex; align-items: baseline; gap: clamp(15px, 2.15vw, 34px); }
.lesson-heading { display: flex; align-items: baseline; gap: inherit; }
.lesson-intro h1 { font-size: clamp(2.4rem, 1.4rem + 3.3vw, 3.65rem); line-height: 1.15; letter-spacing: -.055em; font-weight: 900; }
.lesson-intro p { color: var(--muted); line-height: 1.55; font-weight: 550; }
.noscript { padding: 12px; margin-block: 12px; border: 1px solid var(--accent); }
.lesson-layout { display: grid; grid-template-columns: minmax(0, 1fr) 282px; gap: 20px; align-items: start; }

.player {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.player-content { display: contents; }
.board {
  position: relative;
  margin: 7px 7px 0;
  border: 1px solid var(--frame);
  border-radius: 16px;
  background: var(--board) radial-gradient(circle, var(--dot) .75px, transparent 1.15px) 50% 50% / 18px 18px;
  box-shadow: inset 0 0 0 4px color-mix(in srgb, var(--frame) 17%, transparent);
}
.board-inner {
  min-height: 344px;
  display: grid;
  grid-template-columns: minmax(0, .86fr) minmax(0, 1.58fr);
  align-items: center;
  gap: clamp(12px, 1.8vw, 26px);
  padding: 16px 24px 40px 29px;
}
.board-copy { position: relative; z-index: 1; }
.board-topic {
  display: inline-flex;
  align-items: center;
  min-height: 29px;
  padding: 4px 10px;
  border-radius: 7px;
  color: var(--green);
  background: var(--green-soft);
  font-size: .83rem;
  font-weight: 800;
}
.board-copy h2 {
  margin-block: 11px 10px;
  font-size: clamp(1.7rem, 1rem + 1.6vw, 2.48rem);
  line-height: 1.25;
  font-weight: 900;
  letter-spacing: -.045em;
  text-wrap: balance;
}
.board-hint { max-width: 24ch; color: var(--muted); font-size: clamp(1rem, .92rem + .35vw, 1.13rem); line-height: 1.65; font-weight: 650; }
.board-art { min-width: 0; aspect-ratio: 600 / 354; }
.board-art canvas { display: block; width: 100%; height: 100%; }
.board-toggle {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
}
.board-toggle:focus-visible { outline-offset: -5px; }
.board-tip {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 7px;
  color: var(--muted);
  background: var(--surface);
  font-size: .78rem;
  font-weight: 750;
}
.board-toggle:hover .board-tip { color: var(--accent); border-color: var(--accent); }
.board-tip .icon { width: 14px; height: 14px; }
.board-tools {
  position: absolute;
  left: 18px;
  bottom: 12px;
  display: flex;
  align-items: end;
  gap: 5px;
  pointer-events: none;
}
.marker, .eraser { display: block; height: 6px; border-radius: 3px; opacity: .82; }
.marker { width: 34px; background: linear-gradient(to right, currentColor 0 72%, var(--board) 72% 78%, currentColor 78%); }
.marker-green { color: var(--green); transform: rotate(-6deg); }
.marker-red { color: var(--accent); transform: rotate(4deg); }
.eraser { height: 9px; width: 25px; border: 1px solid var(--frame); background: linear-gradient(to bottom, var(--frame) 65%, var(--muted) 65%); }

.player-caption {
  display: flex;
  align-items: start;
  gap: 10px;
  min-height: 65px;
  margin: 0 7px;
  padding: 12px 11px 11px;
  border-bottom: 1px solid var(--border);
}
.caption-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
  background: var(--green-soft);
  color: var(--green);
  border-radius: 6px;
  font-size: .79rem;
  font-weight: 800;
  white-space: nowrap;
}
.caption-label .icon { width: 15px; height: 15px; }
.player-caption p { flex: 1; font-weight: 600; font-size: .96rem; line-height: 1.6; }
.finish-quiz { min-height: 44px; border: 0; padding-inline: 5px; background: transparent; color: var(--accent); font-weight: 800; white-space: nowrap; }

.player-controls { display: flex; align-items: center; gap: 12px; padding: 8px 13px 9px; }
.play-button { min-width: 119px; }
.step-buttons { display: flex; gap: 1px; }
.timeline { flex: 1; min-width: 90px; }
.timeline-label { display: flex; justify-content: space-between; align-items: baseline; gap: 5px; font-size: .78rem; color: var(--muted); font-weight: 750; white-space: nowrap; }
#step-count, .outline-count { font-variant-numeric: tabular-nums; }
.timeline input {
  --fill: 0%;
  display: block;
  width: 100%;
  height: 29px;
  margin: 0;
  background: transparent;
  appearance: none;
  cursor: pointer;
  accent-color: var(--accent);
}
.timeline input::-webkit-slider-runnable-track {
  height: 6px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--track) var(--fill));
  border-radius: 99px;
}
.timeline input::-moz-range-track {
  height: 6px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--track) var(--fill));
  border-radius: 99px;
}
.timeline input::-webkit-slider-thumb {
  appearance: none;
  width: 15px;
  height: 15px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  margin-top: -4.5px;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.timeline input::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.fullscreen-button { border: 1px solid var(--border); }

.outline {
  min-width: 0;
  padding: 13px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.outline-header { padding: 3px 5px 11px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.outline-header h2 { font-size: 1.04rem; font-weight: 850; }
.outline-count { font: 700 .78rem/1.5 ui-monospace, Consolas, monospace; color: var(--muted); }
.chapters { display: grid; gap: 4px; list-style: none; margin: 0; padding: 0; }
.chapter {
  width: 100%;
  min-height: 57px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 6px 7px;
  border: 1px solid transparent;
  border-radius: 11px;
  text-align: left;
  background: transparent;
}
.chapter:hover { background: var(--page); }
.chapter[aria-current="step"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 24%, transparent); }
.chapter-index {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--page);
  font: 750 .81rem/1 ui-monospace, Consolas, monospace;
  color: var(--muted);
}
.chapter[aria-current="step"] .chapter-index { color: var(--on-accent); background: var(--accent); border-color: transparent; }
.chapter-copy, .practice-copy { display: grid; gap: 3px; line-height: 1.2; }
.chapter-copy strong, .practice-copy strong { font-size: .96rem; font-weight: 800; }
.chapter-copy > span, .practice-copy > span { font-size: .8rem; color: var(--muted); font-weight: 600; }
.chapter .icon { visibility: hidden; width: 15px; height: 15px; color: var(--accent); }
.chapter[aria-current="step"] .icon, .chapter:hover .icon { visibility: visible; }
.practice { padding-top: 11px; margin-top: 10px; border-top: 1px solid var(--border); }
.practice-button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 62px;
  background: var(--green-soft);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 7px;
  text-align: left;
  color: var(--green);
}
.practice-button:hover { border-color: var(--green); }
.practice-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: var(--surface); }
.practice-copy > span { color: var(--green); }

.lesson-footer { min-height: 44px; margin-top: 11px; color: var(--muted); }
.sources { width: max-content; max-width: 100%; }
.sources summary { display: flex; align-items: center; gap: 8px; min-height: 44px; width: max-content; cursor: pointer; font-size: .88rem; font-weight: 750; }
.sources summary::-webkit-details-marker { display: none; }
.sources[open] .icon-chevron { transform: rotate(180deg); }
.sources-content { display: grid; gap: 8px; padding-block: 2px 10px; line-height: 1.6; }

.modal {
  width: min(100% - 28px, 475px);
  max-height: min(88dvh, 680px);
  border: 1px solid var(--frame);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  padding: 17px 20px 20px;
  box-shadow: 0 20px 85px #14251c38;
}
.modal:modal { overscroll-behavior: contain; }
.modal::backdrop { overflow: hidden; overscroll-behavior: contain; background: #101c16a3; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 12px; }
.modal-header h2 { font-size: 1.33rem; font-weight: 850; }
.settings-fields { display: grid; gap: 7px; }
.settings-fields label { font-weight: 750; }
.settings-fields select { width: 100%; min-height: 44px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--page); color: var(--ink); }
.field-hint { min-height: 27px; margin-bottom: 4px; color: var(--muted); line-height: 1.45; font-size: .87rem; }
.modal-actions { display: flex; justify-content: end; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.modal-actions .button { min-width: 84px; }
.quiz-modal { width: min(100% - 28px, 515px); }
.quiz-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; color: var(--green); font-size: .86rem; font-weight: 750; }
.quiz-progress progress { flex: 1; min-width: 50px; height: 8px; border: 0; border-radius: 99px; appearance: none; }
.quiz-progress progress::-webkit-progress-bar { background: var(--track); border-radius: 99px; }
.quiz-progress progress::-webkit-progress-value { background: var(--green); border-radius: 99px; }
.quiz-progress progress::-moz-progress-bar { background: var(--green); border-radius: 99px; }
#choices { min-width: 0; padding: 0; margin: 0; border: 0; }
#question { padding: 0; margin-bottom: 12px; line-height: 1.5; font-size: 1.15rem; font-weight: 800; }
.choice-list { display: grid; gap: 7px; }
.choice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--page);
  cursor: pointer;
}
.choice:hover, .choice:has(:checked) { border-color: var(--accent); }
.choice:has(:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.choice input { width: 17px; height: 17px; margin: 2px; accent-color: var(--accent); }
.choice.correct { background: var(--green-soft); border-color: var(--green); }
.choice.wrong { background: var(--accent-soft); }
.choice-result { margin-left: auto; font-weight: 800; font-size: .83rem; color: var(--muted); white-space: nowrap; }
.quiz-feedback { line-height: 1.55; margin-top: 9px; font-weight: 650; }
.quiz-feedback:empty { margin: 0; }
.score { margin-bottom: 4px; font-size: 1.7rem; color: var(--green); font-weight: 850; }
.quiz-review { padding-inline-start: 23px; line-height: 1.7; color: var(--muted); }

.icon { position: relative; display: inline-block; width: 20px; height: 20px; flex-shrink: 0; }
.icon::before, .icon::after { content: ""; position: absolute; }
.icon-play::before { inset: 3px 2px 3px 5px; background: currentColor; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.icon-pause::before { inset: 2px 4px; background: linear-gradient(to right, currentColor 0 32%, transparent 32% 68%, currentColor 68%); border-radius: 1px; }
.icon-next::before, .icon-prev::before { inset: 4px 5px 4px 3px; background: currentColor; clip-path: polygon(0 0, 91% 50%, 0 100%); }
.icon-next::after, .icon-prev::after { inset: 4px 2px 4px auto; width: 2px; background: currentColor; border-radius: 1px; }
.icon-prev { transform: scaleX(-1); }
.icon-settings::before { inset: 3px 1px; background: repeating-linear-gradient(to bottom, currentColor 0 2px, transparent 2px 6px); }
.icon-settings::after { inset: 0; background: radial-gradient(circle at 30% 20%, currentColor 0 2.5px, transparent 2.8px), radial-gradient(circle at 68% 50%, currentColor 0 2.5px, transparent 2.8px), radial-gradient(circle at 40% 80%, currentColor 0 2.5px, transparent 2.8px); }
.icon-sun, .icon-moon { width: 16px; height: 16px; }
.icon-sun::before { inset: 4px; border: 1.5px solid currentColor; border-radius: 50%; }
.icon-sun::after { inset: 0; background: radial-gradient(circle at 50% 8%, currentColor 0 1px, transparent 1.4px), radial-gradient(circle at 50% 92%, currentColor 0 1px, transparent 1.4px), radial-gradient(circle at 8% 50%, currentColor 0 1px, transparent 1.4px), radial-gradient(circle at 92% 50%, currentColor 0 1px, transparent 1.4px); }
.icon-moon::before { inset: 1px 3px 2px 1px; border-radius: 50%; box-shadow: inset 4px -2px 0 currentColor; transform: rotate(-23deg); }
.icon-caption::before { inset: 2px 1px 4px; border: 1.5px solid currentColor; border-radius: 3px; }
.icon-caption::after { width: 4px; height: 4px; left: 4px; bottom: 2px; border-left: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: skewY(-35deg); background: var(--green-soft); }
.icon-fullscreen::before, .icon-exit-fullscreen::before {
  inset: 2px;
  --ink-stroke: linear-gradient(currentColor, currentColor);
  background:
    var(--ink-stroke) top left / 6px 2px, var(--ink-stroke) top right / 6px 2px,
    var(--ink-stroke) bottom left / 6px 2px, var(--ink-stroke) bottom right / 6px 2px,
    var(--ink-stroke) top left / 2px 6px, var(--ink-stroke) top right / 2px 6px,
    var(--ink-stroke) bottom left / 2px 6px, var(--ink-stroke) bottom right / 2px 6px;
  background-repeat: no-repeat;
}
.icon-exit-fullscreen::before {
  background-position: 0 4px, 100% 4px, 0 calc(100% - 4px), 100% calc(100% - 4px),
    4px 0, calc(100% - 4px) 0, 4px 100%, calc(100% - 4px) 100%;
}
.icon-arrow::before { inset: 9px 4px auto 2px; height: 2px; background: currentColor; }
.icon-arrow::after { width: 6px; height: 6px; right: 4px; top: 6px; border-top: 2px solid currentColor; border-right: 2px solid currentColor; rotate: 45deg; }
.icon-chevron::before { width: 6px; height: 6px; left: 6px; top: 5px; border-bottom: 2px solid currentColor; border-right: 2px solid currentColor; rotate: 45deg; }
.icon-quiz::before { inset: 2px 3px 1px; border: 2px solid currentColor; border-radius: 3px; }
.icon-quiz::after { width: 6px; height: 4px; inset: 7px auto auto 7px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; rotate: -45deg; }
.icon-close::before, .icon-close::after { inset: 9px 1px; height: 2px; background: currentColor; rotate: 45deg; }
.icon-close::after { rotate: -45deg; }

:is(.player:fullscreen, .player.is-expanded) {
  color: var(--ink);
  background: var(--page);
  border: 0;
  border-radius: 0;
  display: grid;
  grid-template-rows: minmax(170px, 1fr) auto auto;
  overflow: auto;
  overscroll-behavior: contain;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
.player.is-expanded { position: fixed; inset: 0; width: 100%; height: 100dvh; z-index: 5; }
:root:has(.player.is-expanded) { overflow: hidden; }
:is(.player:fullscreen, .player.is-expanded) .board { margin: 0; }
:is(.player:fullscreen, .player.is-expanded) .board-inner { height: 100%; min-height: 0; grid-template-rows: minmax(0, 1fr); }
:is(.player:fullscreen, .player.is-expanded) .board-art { height: 100%; aspect-ratio: auto; }
:is(.player:fullscreen, .player.is-expanded) .player-caption { min-height: 0; }

@media (max-width: 1000px) {
  .lesson-layout { grid-template-columns: minmax(0, 1fr) 235px; gap: 12px; }
  .board-inner { padding-inline: 17px; }
}

@media (max-width: 750px) {
  .lesson-layout { grid-template-columns: minmax(0, 1fr); }
  .lesson-header { margin-bottom: 15px; }
  .lesson-intro, .lesson-heading { display: grid; gap: 4px; }
  .lesson { padding-top: 16px; }
  .header-inner { min-height: 60px; }
  .board-inner { min-height: 285px; }
}

@media (max-width: 520px) {
  .shell { width: min(100% - 24px, 490px); }
  .header-inner { flex-wrap: wrap; }
  .header-actions { gap: 5px; }
  .brand { gap: 7px; font-size: 1.03rem; }
  .brand-mark { width: 34px; height: 34px; border-radius: 9px; }
  .brand-mark::before { inset: 9px 7px 9px; }
  .brand-mark::after { left: 11px; top: 15px; width: 13px; }
  .theme-control { padding: 2px; }
  .theme-control button { padding: 0 7px; gap: 4px; }
  .theme-control .icon, .settings-button > span:last-child { display: none; }
  .settings-button { min-width: 44px; padding-inline: 7px; }
  .lesson-intro p { font-size: .95rem; }
  .player { border-radius: 17px; }
  .board { margin: 5px 5px 0; border-radius: 13px; }
  .board-inner {
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
    padding: 13px 13px 32px;
  }
  .board-copy h2 { margin-block: 6px 4px; font-size: 1.68rem; text-wrap: initial; }
  .board-topic { min-height: 25px; }
  .board-hint { max-width: 100%; font-size: 1rem; line-height: 1.4; }
  .board-tip { right: 6px; bottom: 6px; }
  .board-tools { left: 10px; bottom: 11px; }
  .player-caption { padding: 10px 5px; gap: 7px; flex-wrap: wrap; }
  .player-caption p { font-size: 1rem; line-height: 1.5; min-width: 64%; }
  .finish-quiz { margin-left: auto; }
  .player-controls {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "play steps full" "seek seek seek";
    gap: 4px 8px;
    padding: 7px 10px 4px;
  }
  .play-button { grid-area: play; min-width: 110px; }
  .step-buttons { grid-area: steps; justify-self: center; }
  .timeline { grid-area: seek; }
  .timeline input { height: 32px; }
  .fullscreen-button { grid-area: full; }
  .outline { padding: 10px; }
  .chapter { min-height: 53px; }
  :is(.player:fullscreen, .player.is-expanded) .board-inner { grid-template-rows: auto minmax(0, 1fr); align-items: stretch; }
}

@media (max-width: 360px) {
  .settings-button > span:last-child, .theme-control .icon { display: none; }
  .theme-control button { min-width: 48px; }
}

@media (orientation: landscape) and (max-height: 530px) and (min-width: 580px) {
  .header-inner { min-height: 48px; }
  .theme-control { padding: 0 2px; }
  .lesson { padding-top: 4px; }
  .lesson-header { display: flex; gap: 10px; align-items: baseline; margin-bottom: 4px; }
  .lesson-intro, .lesson-heading { display: flex; gap: 9px; }
  .lesson-intro h1 { font-size: 1.78rem; line-height: 1.05; }
  .lesson-intro p, .lesson-context { font-size: .81rem; }
  .lesson-layout { grid-template-columns: minmax(0, 1fr) 183px; gap: 9px; }
  .board { margin: 5px 5px 0; border-radius: 11px; }
  .board-inner { min-height: 0; gap: 5px; padding: 5px 10px 22px; grid-template-columns: minmax(0, .88fr) minmax(0, 1.35fr); }
  .board-topic { min-height: 24px; font-size: .76rem; }
  .board-copy h2 { font-size: clamp(1.19rem, .76rem + 1.1vw, 1.52rem); margin-block: 4px 3px; }
  .board-hint { font-size: .91rem; line-height: 1.4; }
  .board-art { height: clamp(112px, 37dvh, 196px); aspect-ratio: auto; }
  .board-tip { bottom: 4px; right: 4px; padding: 1px 4px; }
  .board-tools { bottom: 8px; }
  .player-caption { min-height: 0; padding: 7px 5px; gap: 5px; }
  .player-caption p { font-size: .9rem; line-height: 1.42; }
  .player-controls { padding: 3px 6px; gap: 4px; }
  .play-button { min-width: 93px; padding-inline: 6px; font-size: .85rem; }
  .outline { padding: 5px; border-radius: 14px; }
  .outline-header { padding: 1px 3px 3px; }
  .outline-header h2 { font-size: .9rem; }
  .chapters { gap: 1px; }
  .chapter { min-height: 44px; gap: 5px; padding: 3px 4px; }
  .chapter-index { width: 25px; height: 25px; }
  .chapter-copy strong, .practice-copy strong { font-size: .85rem; }
  .chapter-copy > span, .practice-copy > span { font-size: .72rem; }
  .chapter .icon { width: 11px; }
  .practice { margin-top: 3px; padding-top: 3px; }
  .practice-button { min-height: 44px; gap: 5px; padding: 3px 4px; }
  .practice-icon { width: 27px; height: 27px; }
  .practice-button > .icon { width: 13px; }
}

@media (orientation: landscape) and (max-height: 350px) {
  .lesson-intro p { display: none; }
}

@media (pointer: coarse) {
  .timeline input { height: 44px; }
}

@media (prefers-reduced-motion: no-preference) {
  .button, .board-tip, .chapter, .practice-button { transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out; }
}

@media (forced-colors: active) {
  .icon { forced-color-adjust: none; color: ButtonText; }
  .primary, .chapter[aria-current="step"], .choice:has(:checked) { border: 2px solid Highlight; }
  .timeline input, .quiz-progress progress { appearance: auto; }
}

:root[data-course="paper"] { --accent: #89501e; --accent-soft: #f4e8d3; }

:root[data-course="paper"][data-theme="dark"] {
  --page: #0e1a19;
  --surface: #142523;
  --board: #132a28;
  --ink: #f4f0e6;
  --muted: #b9cac2;
  --border: #304843;
  --frame: #45625a;
  --dot: #45645a55;
  --accent: #ffc780;
  --accent-hover: #ffdaa5;
  --on-accent: #2e2418;
  --accent-soft: #3a3024;
  --green: #8ee5cc;
  --green-soft: #233e36;
  --track: #37524b;
}

[data-course="paper"] .lesson-intro { justify-content: space-between; align-items: center; }
[data-course="paper"] .lesson-heading { display: grid; gap: 5px; }
[data-course="paper"] .lesson-intro h1 {
  color: var(--ink);
  font-size: clamp(1.7rem, 1.15rem + 2.45vw, 3.1rem);
  line-height: 1.2;
  letter-spacing: -.035em;
}
[data-course="paper"] .lesson-context { margin-bottom: 5px; }
[data-course="paper"] #open-presentation { flex: none; }
[data-course="paper"] .board {
  background:
    radial-gradient(ellipse at 70% 9%, color-mix(in srgb, var(--green) 8%, transparent), transparent 68%),
    radial-gradient(circle, var(--dot) .7px, transparent 1px) 50% 50% / 24px 24px,
    var(--board);
}
[data-course="paper"] .board-inner {
  grid-template-columns: minmax(0, .85fr) minmax(0, 1.45fr);
  min-height: 342px;
  gap: clamp(12px, 2vw, 32px);
  padding: 14px 20px 4px 27px;
}
[data-course="paper"] .board-topic {
  min-height: 0;
  color: var(--green);
  background: transparent;
  padding: 0;
  letter-spacing: .045em;
  line-height: 1.45;
}
[data-course="paper"] .board-copy h2 {
  margin-block: 12px;
  font-size: clamp(1.5rem, 1.08rem + 1.35vw, 2.32rem);
  line-height: 1.24;
  letter-spacing: -.025em;
  white-space: pre-line;
}
[data-course="paper"] .board-hint { max-width: 27ch; font-weight: 550; text-wrap: pretty; }
[data-course="paper"] .board-tools { display: none; }
.board-source { padding: 2px 109px 3px 26px; color: var(--muted); }
.board-source a {
  position: relative;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  column-gap: 9px;
  min-height: 36px;
  font-size: .78rem;
  font-weight: 650;
  line-height: 1.3;
  text-decoration: none;
  color: inherit;
}
.board-source a > span:first-child { color: var(--green); }
.board-source-id { display: none; }
.board-source a:hover { text-decoration: underline; }
[data-course="paper"] .player-caption { min-height: 72px; }
[data-course="paper"] .player-caption p { font-weight: 550; text-wrap: pretty; }
[data-course="paper"] .chapter-index {
  width: 52px;
  background: transparent;
  border-color: transparent;
  font-weight: 650;
}
[data-course="paper"] .chapter[aria-current="step"] .chapter-index { background: var(--accent); }
[data-course="paper"] .chapter-copy { gap: 4px; }
[data-course="paper"] :is(.player:fullscreen, .player.is-expanded) .board {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}
[data-course="paper"] :is(.player:fullscreen, .player.is-expanded) .board-art { min-height: 0; }

@media (max-width: 750px) {
  [data-course="paper"] .lesson-header { margin-bottom: 9px; }
  [data-course="paper"] #open-presentation { justify-self: start; margin-top: 2px; }
}

@media (max-width: 520px) {
  [data-course="paper"] .lesson-intro p { font-size: .9rem; }
  [data-course="paper"] .board-inner {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    gap: 7px;
    padding: 12px 12px 0;
  }
  [data-course="paper"] .board-copy h2 { margin-block: 5px; }
  [data-course="paper"] .board-hint { max-width: none; font-size: .94rem; }
  [data-course="paper"] .board-art { max-width: 410px; width: 100%; margin-inline: auto; }
  [data-course="paper"] .caption-label { display: none; }
  .board-source { padding-inline: 12px 109px; }
  .board-source a { font-size: .75rem; column-gap: 6px; }
}

@media (orientation: landscape) and (max-height: 530px) and (min-width: 580px) {
  [data-course="paper"] .lesson-layout { grid-template-columns: minmax(0, 1fr) 190px; }
  [data-course="paper"] .lesson-context, [data-course="paper"] .lesson-intro p { display: none; }
  [data-course="paper"] .lesson-intro h1 { font-size: clamp(1.25rem, .8rem + 1.5vw, 1.8rem); }
  [data-course="paper"] #open-presentation { margin: 0; }
  [data-course="paper"] .board-inner { min-height: 0; padding: 4px 10px 0; gap: 8px; }
  [data-course="paper"] .board-copy h2 { font-size: 1.22rem; margin-block: 5px; }
  [data-course="paper"] .board-art { height: clamp(122px, 41dvh, 188px); }
  [data-course="paper"] .player-caption { min-height: 0; }
  .board-source { padding: 0 95px 0 11px; }
  .board-source a { min-height: 28px; }
  [data-course="paper"] .chapter-index { width: 44px; font-size: .73rem; }
  [data-course="paper"] .chapter { grid-template-columns: auto minmax(0, 1fr); }
  [data-course="paper"] .chapter-copy > span, [data-course="paper"] .chapter .icon { display: none; }
  [data-course="paper"] .timeline { position: relative; }
  [data-course="paper"] .timeline-label { position: absolute; inset: 0 0 auto; pointer-events: none; }
  [data-course="paper"] .timeline input { height: 44px; padding-top: 15px; }
}

@media (orientation: landscape) and (max-height: 430px) and (min-width: 760px) {
  [data-course="paper"] .lesson-header { margin: 0; }
  [data-course="paper"] .lesson-heading {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  [data-course="paper"] #open-presentation {
    position: absolute;
    inset-block-start: 2px;
    inset-inline-start: 50%;
    transform: translateX(-50%);
  }
}

@media (pointer: coarse) {
  .board-source a { min-height: 44px; }
}

.player.is-presenting {
  position: fixed;
  inset: 0;
  z-index: 5;
  height: 100dvh;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: var(--page);
  outline: none;
}
:root:has(.player.is-presenting) { overflow: hidden; }
.is-presenting .player-content {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: min(100vw, 100dvh * 16 / 9);
  aspect-ratio: 16 / 9;
  container: presentation / inline-size;
  background: var(--board);
}
.is-presenting .board {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
[data-course="paper"] .is-presenting .board-inner {
  grid-template-columns: minmax(0, .89fr) minmax(0, 1.32fr);
  min-height: 0;
  gap: 3.25cqw;
  padding: 2.8cqw 4.8cqw .8cqw;
}
[data-course="paper"] .is-presenting .board-topic { font-size: 1.54cqw; }
[data-course="paper"] .is-presenting .board-copy h2 { font-size: 4.15cqw; margin-block: .9cqw; }
[data-course="paper"] .is-presenting .board-hint { font-size: 1.86cqw; line-height: 1.55; }
[data-course="paper"] .is-presenting .board-art { width: 100%; height: auto; max-width: none; aspect-ratio: 600 / 354; }
.is-presenting .board-source { padding: 0 4.8cqw 1.05cqw; }
.is-presenting .board-source a { min-height: 0; column-gap: .7cqw; font-size: 1.16cqw; }
.is-presenting .board-source-id { display: inline; }
[data-course="paper"] .is-presenting .player-caption {
  align-items: center;
  min-height: 9.2cqw;
  margin: 0;
  padding: 1.05cqw 4.8cqw 2.55cqw;
  border: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
[data-course="paper"] .is-presenting .player-caption p { max-width: 78cqw; font-size: 2cqw; line-height: 1.37; }
.is-presenting :is(.player-controls, .caption-label, .board-tip) { display: none; }
.presentation-tools {
  position: absolute;
  z-index: 4;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  opacity: 0;
}
.presentation-tools:hover, .presentation-tools:focus-within { opacity: 1; }
.presentation-tools > span { padding-inline-start: 8px; font-size: .82rem; }
@media (hover: none) {
  .presentation-tools { opacity: 1; }
  .presentation-tools > span { display: none; }
}
