:root {
  color-scheme: light;
  --bg: #eef3eb;
  --surface: #fffdf7;
  --surface-soft: #f7f3e8;
  --ink: #173026;
  --muted: #65746c;
  --line: rgba(47, 91, 72, 0.18);
  --line-strong: rgba(47, 91, 72, 0.34);
  --accent: #3f7d5a;
  --accent-strong: #285f42;
  --accent-soft: #e2f1e7;
  --blue: #3f73b8;
  --gold: #bd8644;
  --red: #c85050;
  --green: #2f8b57;
  --shadow: 0 24px 70px rgba(32, 58, 47, 0.16);
  --radius: 8px;
  --nav-width: 72px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100dvh;
  background: #edf3ec;
  color: var(--ink);
  overflow-x: hidden;
}

button,
a,
input {
  font: inherit;
}

button,
a {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(63, 115, 184, 0.28);
  outline-offset: 3px;
}

.reader-app {
  width: 100%;
  min-height: 100dvh;
  margin: 0;
  padding: 6px 6px 14px;
}

.reader-topbar,
.unit-map,
.lesson-panel {
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(31, 63, 50, 0.08);
}

.reader-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 50px;
  padding: 6px 8px;
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.94);
  backdrop-filter: blur(12px);
}

.brand-link,
.top-actions,
.unit-switcher,
.word-actions,
.page-tabs,
.modal-page-tabs,
.audio-card,
.section-title-row,
.lesson-head,
.exercise-head,
.fill-row,
.question-feedback,
.page-dialog-head {
  display: flex;
  align-items: center;
}

.brand-link {
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
}

.brand-link strong,
.panel-head h2,
.unit-copy h1,
.lesson-head h2,
.section-title-row h3,
.exercise-head h4 {
  margin: 0;
}

.brand-link strong {
  display: block;
  font-size: 15px;
}

.brand-link small,
.unit-copy span,
.lesson-head span,
.section-title-row span,
.source-note,
.exercise-page,
.audio-status small,
.panel-head p {
  color: var(--muted);
}

.top-actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.top-actions a,
.top-actions button,
.unit-button,
.page-tab,
.word-actions button,
.word-actions a,
.choice-option,
.fill-check,
.page-dialog-head button,
.play-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffaf0;
  color: var(--ink);
}

.top-actions a,
.top-actions button {
  padding: 7px 10px;
}

.top-actions button,
.unit-button,
.page-tab,
.word-actions button,
.choice-option,
.fill-check,
.fill-clear,
.page-dialog-head button,
.play-button {
  appearance: none;
}

.unit-copy p,
.lesson-head p,
.section-title-row p,
.panel-head p {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.unit-copy h1 {
  font-size: clamp(32px, 5vw, 64px);
  line-height: 1;
  letter-spacing: 0;
}

.unit-copy span {
  display: block;
  margin-top: 12px;
  font-size: 17px;
  line-height: 1.5;
}

.unit-switcher {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  flex: 1;
}

.unit-button {
  padding: 7px 11px;
  background: rgba(255, 255, 255, 0.74);
}

.unit-button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.reader-layout {
  display: grid;
  grid-template-columns: var(--nav-width) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin-top: 10px;
  transition: grid-template-columns 180ms ease;
}

body.is-nav-expanded {
  --nav-width: 210px;
}

.unit-map,
.lesson-panel {
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.88);
}

.unit-map {
  position: sticky;
  top: 62px;
}

.unit-map,
.lesson-panel {
  padding: 12px;
}

.panel-head {
  margin-bottom: 10px;
}

.unit-map .panel-head {
  display: grid;
  gap: 8px;
}

.unit-map-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

.unit-map-toggle span {
  position: relative;
  display: block;
  width: 16px;
  height: 12px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.unit-map-toggle span::before {
  content: "";
  position: absolute;
  left: 0;
  top: 3px;
  width: 16px;
  border-top: 2px solid currentColor;
}

.unit-map-title {
  min-width: 0;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 160ms ease, max-height 160ms ease;
}

.unit-map.is-expanded .unit-map-title {
  opacity: 1;
  max-height: 56px;
}

.panel-head h2 {
  font-size: 17px;
  line-height: 1.2;
}

.section-list {
  display: grid;
  gap: 7px;
}

.section-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
  min-width: 0;
  transition: background 160ms ease, border-color 160ms ease, padding 160ms ease;
}

.section-item.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.section-item.is-unavailable {
  background: rgba(255, 255, 255, 0.38);
}

.section-main {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.section-main:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.72;
}

.section-main::before {
  content: attr(data-short-label);
  display: grid;
  place-items: center;
  overflow: hidden;
  min-height: 32px;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.section-main strong {
  display: none;
  font-size: 14px;
}

.section-main span {
  display: none;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.unit-map.is-expanded .section-main::before {
  display: none;
}

.unit-map.is-expanded .section-main strong,
.unit-map.is-expanded .section-main span {
  display: block;
}

.section-audio {
  min-width: 50px;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffaf0;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
}

.unit-map:not(.is-expanded) {
  padding: 8px;
}

.unit-map:not(.is-expanded) .section-list {
  gap: 6px;
}

.unit-map:not(.is-expanded) .section-item {
  display: block;
  padding: 5px;
}

.unit-map:not(.is-expanded) .section-audio {
  display: none;
}

.section-audio.is-playing {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.source-note {
  display: none;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.5;
}

.lesson-panel {
  min-width: 0;
  background: rgba(255, 253, 247, 0.94);
}

.lesson-head {
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.lesson-head h2 {
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.05;
  letter-spacing: 0;
}

.lesson-head span {
  display: block;
  max-width: 760px;
  margin-top: 8px;
  font-size: 16px;
  line-height: 1.6;
}

.review-chip,
#scoreBadge {
  flex: 0 0 auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.audio-card {
  gap: 14px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f6fbf4;
}

.play-button {
  flex: 0 0 auto;
  gap: 9px;
  padding: 10px 16px;
  border-color: rgba(36, 95, 63, 0.28);
  background: var(--accent);
  color: #fff;
}

.play-icon {
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 12px solid currentColor;
}

.play-button.is-playing .play-icon {
  width: 12px;
  height: 16px;
  border: 0;
  background: linear-gradient(90deg, currentColor 0 4px, transparent 4px 8px, currentColor 8px 12px);
}

.audio-main {
  flex: 1;
  min-width: 180px;
}

.audio-status {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.audio-status span {
  font-weight: 800;
}

.audio-seek {
  width: 100%;
  accent-color: var(--accent);
}

.audio-segments {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.segment-button {
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf7;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 900;
}

.segment-button.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.segment-button.is-playing {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.study-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(420px, 0.96fr);
  gap: 12px;
  align-items: stretch;
  margin-top: 12px;
  height: calc(100dvh - 214px);
  min-height: 560px;
}

.material-pane,
.exercise-pane {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.58);
}

.material-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.material-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 251, 244, 0.78);
}

.material-tab {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf7;
  color: var(--ink);
  font-weight: 900;
}

.material-tab.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.material-panel {
  min-height: 0;
  overflow: auto;
  padding: 12px;
  scrollbar-gutter: stable;
}

.material-panel.is-active {
  display: block;
}

.exercise-pane {
  overflow: auto;
  padding: 12px;
  scrollbar-gutter: stable;
}

.coach-section {
  display: grid;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.coach-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.coach-head p {
  margin: 0 0 5px;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.coach-head h3 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

.coach-head span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.coach-score {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  gap: 2px;
  min-width: 70px;
  padding: 8px 10px;
  border: 1px solid rgba(63, 125, 90, 0.25);
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-strong);
  text-align: right;
}

.coach-score strong {
  font-size: 25px;
  line-height: 1;
}

.coach-score small {
  color: var(--muted);
  font-size: 11px;
}

.coach-mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.coach-mode {
  min-height: 40px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf7;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.coach-mode.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.coach-transcript {
  display: grid;
  gap: 9px;
  min-height: 190px;
  max-height: 330px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fbf6;
  scrollbar-gutter: stable;
}

.coach-empty {
  align-self: center;
  padding: 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  text-align: center;
}

.coach-bubble {
  max-width: 92%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf7;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.coach-bubble.is-user {
  justify-self: end;
  border-color: rgba(63, 125, 90, 0.28);
  background: var(--accent-soft);
}

.coach-bubble.is-pending {
  color: var(--muted);
  font-style: italic;
}

.coach-bubble small {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.coach-bubble strong {
  color: var(--accent-strong);
}

.coach-prompts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.coach-prompt {
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffdf7;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.coach-composer {
  display: grid;
  gap: 8px;
}

.coach-composer textarea {
  width: 100%;
  min-height: 68px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fffdf7;
  color: var(--ink);
  line-height: 1.5;
}

.coach-composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.coach-voice-button,
.coach-send-button {
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 900;
}

.coach-voice-button {
  background: #fffdf7;
  color: var(--accent-strong);
}

.coach-send-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.coach-voice-button:disabled,
.coach-send-button:disabled {
  cursor: wait;
  opacity: .55;
}

.coach-status {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

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

.section-card,
.exercise-section {
  margin: 0;
  padding: 0;
  border: 0;
}

.section-title-row {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-title-row h3 {
  font-size: 22px;
  line-height: 1.2;
}

.section-title-row span {
  font-size: 13px;
}

.paragraph-list {
  display: grid;
  gap: 14px;
}

.lesson-placeholder {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #fffaf0;
  color: #20362d;
}

.lesson-placeholder strong {
  color: var(--accent-strong);
  font-size: 22px;
  line-height: 1.2;
}

.lesson-placeholder p {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
}

.lesson-placeholder button {
  justify-self: start;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

.reader-paragraph {
  position: relative;
  margin: 0;
  padding: 16px 18px 16px 52px;
  border: 1px solid rgba(47, 91, 72, 0.14);
  border-radius: var(--radius);
  background: #fffaf0;
  color: #20362d;
  font-size: clamp(21px, 1.9vw, 25px);
  line-height: 1.85;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.reader-paragraph.is-audio-active {
  border-color: rgba(53, 116, 130, 0.58);
  background: #f5fbf9;
  box-shadow: inset 4px 0 0 var(--accent);
}

.reader-paragraph::before {
  content: attr(data-paragraph);
  position: absolute;
  top: 18px;
  left: 16px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 900;
}

.tap-word {
  display: inline;
  margin: 0 1px;
  padding: 1px 2px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  line-height: inherit;
  text-align: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(63, 125, 90, 0.28);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.tap-word:hover,
.tap-word:focus-visible,
.tap-word.is-active {
  background: #dff1e6;
  text-decoration-color: transparent;
}

.original-card {
  display: grid;
  position: relative;
  grid-template-rows: auto auto;
  gap: 8px;
  min-height: 100%;
}

.original-preview {
  position: relative;
  width: 100%;
  padding: 0;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffaf0;
  color: var(--ink);
}

.original-preview img {
  display: block;
  width: 100%;
  height: auto;
  background: #f3efe5;
  border-bottom: 0;
}

.original-preview:not(.is-empty) span {
  display: none;
}

.original-preview.is-empty {
  display: grid;
  min-height: 360px;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.5;
  text-align: center;
}

.original-preview.is-empty img {
  display: none;
}

.page-empty-label {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 7px 11px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.page-tabs,
.modal-page-tabs {
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.original-card .page-tabs {
  position: static;
  margin: 0;
  padding: 6px;
  border: 1px solid rgba(47, 91, 72, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.9);
}

.page-tab {
  min-width: 58px;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.66);
  font-size: 13px;
  font-weight: 900;
}

.tap-popover {
  position: fixed;
  z-index: 80;
  display: grid;
  gap: 7px;
  width: min(300px, calc(100vw - 20px));
  padding: 12px;
  border: 1px solid rgba(47, 91, 72, 0.2);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.97);
  box-shadow: 0 18px 42px rgba(23, 48, 38, 0.2);
}

.tap-popover strong {
  color: var(--accent-strong);
  font-size: 18px;
  line-height: 1.1;
}

.tap-popover span {
  color: #253b32;
  font-size: 14px;
  line-height: 1.45;
}

.tap-popover button {
  justify-self: start;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

.tap-popover button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.page-tab.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.exercise-list,
#exerciseList {
  display: grid;
  gap: 14px;
}

.exercise-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffaf0;
  overflow: hidden;
}

.exercise-head {
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(226, 241, 231, 0.50);
}

.exercise-head h4 {
  font-size: 22px;
  line-height: 1.35;
}

.exercise-body {
  padding: 16px 18px 18px;
}

.exercise-prompt {
  margin: 0 0 14px;
  color: #273d34;
  font-size: 20px;
  line-height: 1.6;
}

.choice-grid {
  display: grid;
  gap: 8px;
}

.choice-option {
  width: 100%;
  padding: 14px 16px;
  background: #fffdf7;
  font-size: 18px;
  text-align: left;
  line-height: 1.55;
}

.choice-option.is-selected {
  border-color: var(--blue);
  background: #eaf2ff;
}

.choice-option.is-correct {
  border-color: rgba(47, 139, 87, 0.55);
  background: #e7f7ed;
}

.choice-option.is-wrong {
  border-color: rgba(200, 80, 80, 0.55);
  background: #ffeceb;
}

.fill-list {
  display: grid;
  gap: 10px;
}

.fill-row {
  position: relative;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(47, 91, 72, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.58);
  font-size: 18px;
}

.fill-row span {
  line-height: 1.45;
}

.fill-prefix,
.fill-suffix {
  flex: 0 1 auto;
}

.letter-fill-control {
  position: relative;
  display: inline-flex;
  flex: 0 1 auto;
  align-items: center;
  max-width: 100%;
}

.letter-fill {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  max-width: 100%;
  gap: 4px;
  min-height: 44px;
  padding: 4px 5px;
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.72);
}

.letter-fill-control:focus-within .letter-fill {
  outline: 3px solid rgba(63, 115, 184, 0.24);
  outline-offset: 2px;
}

.letter-box {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fffdf7;
  color: var(--ink);
  font-size: 20px;
  font-weight: 900;
  text-transform: lowercase;
}

.letter-gap {
  width: 12px;
  height: 36px;
}

.letter-separator {
  display: inline-grid;
  place-items: center;
  width: 14px;
  height: 36px;
  color: var(--muted);
  font-weight: 900;
}

.letter-fill-input {
  position: absolute;
  inset: 0;
  width: 100%;
  min-width: 0;
  min-height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: var(--accent-strong);
}

.letter-fill-input::selection {
  color: transparent;
  background: rgba(63, 125, 90, 0.18);
}

.fill-check {
  padding: 9px 12px;
  font-weight: 900;
}

.fill-clear {
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid rgba(200, 80, 80, 0.28);
  border-radius: var(--radius);
  background: #fff7f5;
  color: var(--red);
  font-weight: 900;
}

.fill-result {
  min-width: 96px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
}

.fill-row.is-correct {
  border-color: rgba(47, 139, 87, 0.48);
  background: #edf9f1;
}

.fill-row.is-wrong {
  border-color: rgba(200, 80, 80, 0.48);
  background: #fff0ef;
}

.question-feedback {
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  min-height: 36px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.45;
}

.question-feedback.is-good {
  color: var(--green);
}

.question-feedback.is-bad {
  color: var(--red);
}

.page-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(18, 30, 24, 0.52);
}

.page-dialog {
  width: min(920px, 100%);
  max-height: min(92dvh, 980px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  background: #fffdf7;
  box-shadow: var(--shadow);
}

.page-dialog-head {
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.page-dialog-head button {
  width: 44px;
  padding: 0;
  font-size: 26px;
}

.modal-page-tabs {
  margin: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.page-figure {
  min-height: 0;
  margin: 0;
  overflow: auto;
  padding: 16px;
  background: #f3efe5;
}

.page-figure img {
  display: block;
  width: min(720px, 100%);
  margin: 0 auto;
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(23, 48, 38, 0.22);
}

.page-figure figcaption {
  margin-top: 12px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1180px) {
  .reader-layout {
    grid-template-columns: 180px minmax(0, 1fr);
  }

  body:not(.is-nav-expanded) .reader-layout {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  body.is-nav-expanded {
    --nav-width: 180px;
  }

  .study-workspace {
    grid-template-columns: minmax(0, 1fr) minmax(380px, 0.92fr);
  }
}

@media (max-width: 820px) {
  body,
  body.is-nav-expanded {
    --nav-width: 100%;
  }

  .lesson-head,
  .audio-card,
  .section-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .reader-topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px 8px;
    position: sticky;
  }

  .unit-switcher {
    justify-content: center;
  }

  .top-actions {
    gap: 6px;
    justify-content: flex-end;
  }

  .top-actions a,
  .top-actions button {
    min-height: 36px;
    padding: 6px 9px;
    font-size: 13px;
  }

  .unit-button {
    min-height: 36px;
    padding: 6px 9px;
    font-size: 13px;
  }

  .reader-layout {
    grid-template-columns: 1fr;
  }

  .unit-map {
    position: static;
  }

  .unit-map {
    padding: 12px;
  }

  .unit-map-title {
    opacity: 1;
    max-height: none;
  }

  .unit-map-toggle {
    justify-content: flex-start;
  }

  .section-main::before {
    display: none;
  }

  .section-main strong,
  .section-main span {
    display: block;
  }

  .unit-map:not(.is-expanded) .section-item {
    display: grid;
    padding: 9px 10px;
  }

  .unit-map:not(.is-expanded) .section-audio {
    display: inline-flex;
  }

  .study-workspace {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .material-pane,
  .exercise-pane {
    overflow: visible;
  }

  .material-panel {
    overflow: visible;
  }

  #materialSourcePanel {
    min-height: min(72dvh, 760px);
  }

  .section-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .reader-paragraph {
    padding-left: 18px;
    padding-top: 54px;
    font-size: 20px;
  }

  .reader-paragraph::before {
    top: 16px;
  }
}

@media (max-width: 520px) {
  .reader-app {
    padding-inline: 10px;
  }

  .reader-topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .unit-switcher {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .section-list {
    grid-template-columns: 1fr;
  }

  .unit-copy h1 {
    font-size: 36px;
  }

  .top-actions a,
  .top-actions button,
  .unit-button {
    flex: 1 1 auto;
    justify-content: center;
    text-align: center;
  }

  .audio-status,
  .question-feedback {
    flex-direction: column;
  }
}
