:root {
  color-scheme: light;
  --ink: #1e2d29;
  --muted: #53665e;
  --paper: #f5f7f5;
  --rail: #edf2ee;
  --card: #fff;
  --border: #dbe4de;
  --line: #e6ece7;
  --brand: #165d4a;
  --tint: #e8f2ec;
  --warm: #faf0d7;
  --warm-ink: #684a17;
  --radius: 12px;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
a { color: var(--brand); }
button, input, select { font: inherit; }
button, select, .outline-link { cursor: pointer; }
button, .outline-link, input, select {
  min-height: 34px; border: 1px solid var(--border); border-radius: 7px;
  padding: .34rem .57rem; background: var(--card); color: var(--ink);
}
button, select, .outline-link { font-size: .875rem; line-height: 1.25; }
button:hover, .outline-link:hover { background: var(--tint); }
:focus-visible { outline: 2px solid #1c8568; outline-offset: 2px; }
button.primary { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 650; }
button.primary:hover { background: #114a3b; }
button.tinted, button[aria-pressed="true"] { background: var(--tint); color: var(--brand); border-color: #c4ded0; font-weight: 650; }
button.tinted:hover, button[aria-pressed="true"]:hover { background: #d9ede1; }
.outline-link { display: inline-flex; align-items: center; text-decoration: none; white-space: nowrap; }

.shell { display: grid; grid-template-columns: 188px minmax(0, 1fr); min-height: 100dvh; }
.library {
  position: sticky; top: 0; height: 100dvh; min-width: 0;
  display: flex; flex-direction: column; gap: .65rem;
  padding: 1.1rem .72rem .85rem; background: var(--rail); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .58rem; padding: .12rem .15rem; }
.brand strong { display: block; font-size: .99rem; font-weight: 750; white-space: nowrap; }
.brand small { display: block; color: var(--muted); font-size: .73rem; white-space: nowrap; }
.brand-mark {
  width: 32px; height: 32px; flex: 0 0 32px; display: flex; align-items: center; justify-content: center;
  gap: 2px; border-radius: 8px; background: #dcebe1;
}
.brand-mark i { width: 2.5px; height: 9px; border-radius: 2px; background: var(--brand); }
.brand-mark i:nth-child(2) { height: 18px; }
.brand-mark i:nth-child(3) { height: 13px; }
.library-heading { display: flex; justify-content: space-between; align-items: center; color: var(--muted); padding: .75rem .25rem 0; border-top: 1px solid var(--border); }
.library-heading h2, #lesson-count { margin: 0; font-size: .875rem; font-weight: 600; }
#lesson-links { min-height: 0; display: grid; gap: .25rem; align-content: start; overflow: auto; }
.lesson-day { min-width: 0; }
.lesson-day > summary {
  display: flex; align-items: center; gap: .55rem; list-style: none; cursor: pointer;
  padding: .34rem .55rem; border-radius: 7px; font-size: .875rem; font-weight: 680;
}
.lesson-day > summary::-webkit-details-marker { display: none; }
.lesson-day > summary::before {
  content: ""; width: .33rem; height: .33rem; flex: none;
  border: solid var(--muted); border-width: 0 1px 1px 0; transform: rotate(-45deg);
}
.lesson-day[open] > summary::before { transform: translateY(-.1rem) rotate(45deg); }
.lesson-day > summary:hover { background: #e4eee7; }
.day-lessons { display: grid; gap: .12rem; margin: .1rem 0 .2rem .7rem; padding-left: .35rem; border-left: 1px solid var(--border); }
.lesson-link {
  display: flex; justify-content: space-between; align-items: center; gap: .28rem;
  padding: .34rem .34rem; border: 1px solid transparent; border-radius: 7px;
  color: var(--ink); text-decoration: none; font-size: .875rem; line-height: 1.4;
}
.lesson-link:hover { background: #e4eee7; }
.lesson-link[aria-current] { background: #fff; border-color: #cbded1; color: var(--brand); font-weight: 650; }
.lesson-series-number { flex: none; color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.lesson-link-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.lesson-progress { flex: none; width: .625rem; height: .625rem; border: 1px solid currentColor; border-radius: 50%; color: var(--brand); }
.lesson-progress[data-level="partial"] { background: linear-gradient(to right, currentColor 50%, transparent 50%); }
.lesson-progress[data-level="complete"] { background: currentColor; }
@media (forced-colors: active) {
  .lesson-progress { color: CanvasText; forced-color-adjust: none; }
}
.library-footer { margin-top: auto; padding: .55rem .25rem 0; border-top: 1px solid var(--border); font-size: .85rem; }
.library-footer a { color: var(--muted); text-decoration-color: #a1b2aa; text-underline-offset: .14em; }

.workspace { width: 100%; max-width: 1250px; margin: 0 auto; padding: 1.1rem clamp(.85rem, 2vw, 1.6rem) 1.8rem; }
.message { padding: .75rem; }
.lesson-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: .75rem; margin-bottom: .72rem; }
.lesson-number { margin: 0 0 .15rem; color: var(--brand); font-size: .875rem; font-weight: 650; }
h1 { margin: 0; font-size: clamp(1.42rem, 2.3vw, 1.95rem); font-weight: 750; line-height: 1.22; letter-spacing: -.02em; }
h2 { margin: 0; font-size: 1rem; font-weight: 700; }
.lesson-heading .outline-link { margin-bottom: .02rem; }
.lesson-layout {
  --video-height-limit: min(42vh, 345px);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(218px, .38fr); gap: .75rem; align-items: start;
}
.card { min-width: 0; overflow: hidden; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }

#video-stage { background: #000; }
#video-stage[data-picture="hidden"] video { opacity: 0; }
.player video {
  display: block; width: 100%; aspect-ratio: 16/9; max-height: var(--video-height-limit);
  background: #192420; object-fit: contain; cursor: pointer;
}
#video-stage:fullscreen video, .player video:fullscreen { height: 100%; max-height: none; }
.player-controls { padding: .42rem .65rem .58rem; }
.timeline {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
  gap: .48rem; color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums;
}
.timeline input { width: 100%; min-height: 22px; margin: 0; padding: 0; accent-color: var(--brand); cursor: pointer; }
.player-toolbar, .transport, .play-options, .exercise-controls { display: flex; align-items: center; gap: .42rem; }
.player-toolbar { flex-wrap: wrap; margin-top: .32rem; }
.play-options { flex-wrap: wrap; margin-left: auto; }
#toggle-picture { white-space: nowrap; }
#play { min-width: 3.25rem; }
.segmented { display: inline-flex; align-items: stretch; min-width: 0; }
.segmented > :first-child { border-radius: 7px 0 0 7px; }
.segmented > :last-child { margin-left: -1px; border-radius: 0 7px 7px 0; }
.segmented input:focus-visible, .segmented button:focus-visible { z-index: 1; }
.segmented button { white-space: nowrap; }
#jump { width: 4.1rem; }
#skip { width: 2.75rem; padding-inline: .25rem; text-align: center; }
#skip::-webkit-inner-spin-button { -webkit-appearance: none; }
#skip { appearance: textfield; }
#jump, #skip, .loop-point input { font-size: .875rem; font-variant-numeric: tabular-nums; }
.compact-label { display: inline-flex; align-items: center; gap: .25rem; color: var(--muted); font-size: .875rem; }
select {
  appearance: none; padding-right: 1.31rem;
  background: linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 10px) 52%/4px 4px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 6px) 52%/4px 4px no-repeat, var(--card);
}
.loop-settings { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; padding: .48rem .65rem; background: #f9fbf9; border-top: 1px solid var(--line); }
.loop-settings h2 { font-size: .875rem; }
.loop-form { display: flex; align-items: center; gap: .42rem; flex-wrap: wrap; }
.loop-point { display: flex; align-items: center; gap: .26rem; }
.loop-point label { min-width: .7rem; font-size: .875rem; color: var(--brand); font-weight: 650; }
.loop-point input { width: 4.5rem; }
.loop-form button, .loop-form input { min-height: 32px; }
.player-message { margin: .34rem 0 0; color: #882a25; font-size: .875rem; }
.player-message:empty { display: none; }

.card-heading { display: flex; justify-content: space-between; align-items: center; gap: .55rem; padding: .58rem .68rem; border-bottom: 1px solid var(--line); }
.chapter-panel {
  max-height: var(--video-stage-height, var(--video-height-limit));
  display: grid; grid-template-rows: auto minmax(0, 1fr);
}
#chapters { min-height: 0; overflow-y: auto; padding: .3rem; scrollbar-gutter: stable; }
#chapters::-webkit-scrollbar { width: 10px; background: var(--card); }
#chapters::-webkit-scrollbar-thumb { border: 2px solid var(--card); border-radius: 8px; background: #aebfb5; }
#chapters::-webkit-scrollbar-thumb:hover { background: #82998c; }
.chapter {
  display: grid; grid-template-columns: 2.5rem minmax(0, 1fr) auto; align-items: start; gap: .35rem;
  padding: .43rem .42rem; width: 100%; border-color: transparent; text-align: left; line-height: 1.37;
}
.chapter + .chapter { margin-top: .12rem; }
.chapter[aria-current] { background: var(--tint); border-color: #c8ded1; }
.chapter .time { color: var(--brand); }
.chapter-title { overflow-wrap: anywhere; }
.key { justify-self: end; border-radius: 4px; padding: .03rem .25rem; background: var(--warm); color: var(--warm-ink); font-size: .78rem; white-space: nowrap; }

.dictation, .transcript { grid-column: 1 / -1; }
.practice-heading { flex-wrap: wrap; }
#active-exercise, .transcript-content { padding: .58rem .68rem .72rem; }
.exercise-selector { padding: .5rem .68rem 0; display: flex; flex-wrap: wrap; gap: .35rem; }
.exercise-controls { flex-wrap: wrap; }
.muted, .field-help { color: var(--muted); font-size: .875rem; }
#practice-best {
  padding: .05rem .37rem; border-radius: 5px; background: var(--tint); color: var(--brand);
  font-size: .8rem; font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.field-help { margin: 0 0 .55rem; }
.time { font-variant-numeric: tabular-nums; }
#word-fields { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem .72rem; }
.word { display: inline-flex; align-items: baseline; gap: .18rem; min-width: 0; max-width: 100%; }
.word label {
  align-self: flex-start; margin-top: .24rem; font-size: .75rem; line-height: 1;
  font-variant-numeric: tabular-nums; color: var(--muted); cursor: text;
}
.word-cell {
  display: inline-flex; align-items: baseline; min-width: 0; max-width: 100%; min-height: 2rem;
  padding-inline: .23rem; border-bottom: 1px solid #81958a; white-space: nowrap;
  font-size: 1rem; line-height: 1.6; font-kerning: none; font-variant-ligatures: none;
}
.word-cell[data-fixed] { border-bottom-color: transparent; }
.word-cell[data-numeric] { border-bottom-style: dashed; }
.word-cell[data-grade="incorrect"] { border-bottom-color: #aa3933; }
.word-cell[data-grade="correct"] { border-bottom-color: #397c55; }
.word-cell:focus-within { border-bottom-color: var(--brand); box-shadow: inset 0 -1px var(--brand); }
.word-cell[data-numeric]:focus-within { box-shadow: none; }
.word-fixed { flex: none; color: var(--muted); }
.word-run { position: relative; display: inline-grid; min-width: 0; padding: .11rem 0; }
.word-measure, .word-ink { grid-area: 1 / 1; white-space: pre; }
.word-measure { visibility: hidden; }
.word-ink { pointer-events: none; }
.word-run input {
  position: absolute; inset: 0; width: 100%; height: 100%; min-width: 0; min-height: 0;
  border: 0; border-radius: 0; padding: .11rem 0; outline: 0; background: transparent;
  font: inherit; font-kerning: inherit; font-variant-ligatures: inherit;
  color: transparent; -webkit-text-fill-color: transparent; caret-color: var(--ink);
}
.word-run input::selection { background: #b8d8c775; }
.letter-right { color: #197446; }
.letter-wrong { color: #a62923; }
.form-actions { margin-top: .6rem; }
#practice-result { font-weight: 650; font-size: .9rem; }
#answer-panel {
  margin-top: .65rem; padding: .62rem .75rem .72rem; border: 1px solid var(--border);
  border-radius: 8px; background: var(--paper); overflow-wrap: anywhere;
}
#correct-answer { margin: 0; color: var(--ink); font-size: 1rem; font-weight: 650; line-height: 1.55; }
.answer-translation { margin: .25rem 0 .62rem; color: var(--muted); font-size: .9rem; }
.answer-notes {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: .72rem 1.1rem; padding-top: .6rem; border-top: 1px solid var(--border);
}
.answer-notes h3 { margin: 0 0 .2rem; color: var(--brand); font-size: .92rem; }
.answer-entries { margin: 0; font-size: .88rem; }
.answer-entries > div + div { margin-top: .48rem; padding-top: .46rem; border-top: 1px solid var(--line); }
.answer-entries dt { font-weight: 650; }
.answer-entries dd { margin: .07rem 0 0; }
.answer-usage, .answer-example-translation { color: var(--muted); }
.answer-entries .answer-example {
  display: grid; gap: .04rem; margin-top: .25rem; padding-left: .55rem;
  border-left: 2px solid #c8ded1;
}

.transcript summary { padding: .6rem .68rem; cursor: pointer; font-weight: 650; }
.transcript summary .muted { margin-left: .45rem; font-weight: 400; }
.transcript-content { border-top: 1px solid var(--line); }
#transcript-lines { max-height: 44vh; overflow-y: auto; margin-top: .48rem; }
.transcript-line { display: grid; grid-template-columns: 3.25rem minmax(0, 1fr); gap: .5rem; padding: .25rem 0; }
.transcript-line p { margin: .28rem 0; }
.transcript-line button { align-self: start; padding: .22rem; color: var(--brand); }

@media (max-width: 1050px) {
  .shell { grid-template-columns: 164px minmax(0, 1fr); }
  .library { padding-inline: .5rem; }
  .lesson-layout { grid-template-columns: minmax(0, 1fr) minmax(194px, .46fr); }
}
@media (max-width: 780px) {
  .shell { display: block; }
  .library { position: static; height: auto; gap: .36rem; padding: .5rem .7rem; border-right: 0; border-bottom: 1px solid var(--border); }
  .library-heading { padding-top: .32rem; }
  #lesson-links { display: flex; align-items: start; padding-bottom: .12rem; }
  .lesson-day { flex: 0 0 auto; }
  .lesson-day[open] { width: clamp(8.8rem, 42vw, 10.25rem); }
  .library-footer { display: none; }
  .workspace { padding: .72rem .68rem 1.2rem; }
  .lesson-layout { --video-height-limit: min(44vh, 330px); grid-template-columns: minmax(0, 1fr); gap: .55rem; }
  .chapter-panel { grid-row: 3; }
  .lesson-heading { align-items: start; }
  .lesson-heading .outline-link { font-size: .875rem; padding-inline: .42rem; }
  .answer-notes { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .lesson-heading { gap: .35rem; }
  h1 { font-size: 1.25rem; }
  .lesson-heading .platform { display: none; }
  .player-toolbar { gap: .34rem; }
  .transport { gap: .28rem; }
  .play-options { margin-left: 0; }
  #jump, #skip, .loop-point input { font-size: 1rem; }
  #jump { width: 3.25rem; }
  .keyboard-hint { display: none; }
  .loop-settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .34rem; }
  .loop-settings h2 { grid-area: 1 / 1; }
  .loop-form { display: contents; }
  .loop-point { grid-row: 2; }
  #loop-toggle { grid-area: 1 / 2; justify-self: end; }
  .loop-point input { width: 3.8rem; }
  #word-fields { column-gap: .57rem; }
}
