:root,
[data-theme="light"] {
  color-scheme: light;
  --page: oklch(0.985 0.004 270);
  --surface: oklch(1 0 0);
  --surface-subtle: oklch(0.958 0.012 270);
  --surface-strong: oklch(0.925 0.022 270);
  --ink: oklch(0.235 0.04 260);
  --muted: oklch(0.46 0.035 260);
  --line: oklch(0.875 0.018 270);
  --primary: oklch(0.45 0.18 270);
  --primary-strong: oklch(0.39 0.17 270);
  --primary-soft: oklch(0.94 0.035 270);
  --success: oklch(0.48 0.12 155);
  --success-soft: oklch(0.94 0.035 155);
  --warning: oklch(0.58 0.135 76);
  --warning-soft: oklch(0.955 0.035 76);
  --danger: oklch(0.52 0.18 28);
  --danger-soft: oklch(0.95 0.035 28);
  --record: oklch(0.5 0.2 25);
  --focus: oklch(0.56 0.19 270);
  --book-shadow: oklch(0.24 0.05 270 / 0.2);
  --radius-panel: 14px;
  --radius-control: 10px;
  --z-sticky: 20;
  --z-toast: 40;
}

[data-theme="dark"] {
  color-scheme: dark;
  --page: oklch(0.16 0.018 270);
  --surface: oklch(0.205 0.022 270);
  --surface-subtle: oklch(0.245 0.025 270);
  --surface-strong: oklch(0.29 0.03 270);
  --ink: oklch(0.94 0.012 270);
  --muted: oklch(0.74 0.028 270);
  --line: oklch(0.36 0.03 270);
  --primary: oklch(0.67 0.16 270);
  --primary-strong: oklch(0.73 0.14 270);
  --primary-soft: oklch(0.29 0.055 270);
  --success: oklch(0.7 0.13 155);
  --success-soft: oklch(0.27 0.045 155);
  --warning: oklch(0.77 0.13 76);
  --warning-soft: oklch(0.29 0.05 76);
  --danger: oklch(0.7 0.17 28);
  --danger-soft: oklch(0.28 0.055 28);
  --record: oklch(0.72 0.18 25);
  --focus: oklch(0.72 0.17 270);
  --book-shadow: oklch(0.05 0 0 / 0.48);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--page);
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

body.has-control-footer {
  padding-bottom: calc(58px + env(safe-area-inset-bottom));
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: var(--z-toast);
  padding: 10px 14px;
  border-radius: var(--radius-control);
  background: var(--ink);
  color: var(--page);
  transform: translateY(-140%);
}

.skip-link:focus {
  transform: translateY(0);
}

.button,
.brand-button {
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms cubic-bezier(0.16, 1, 0.3, 1), background-color 160ms ease-out, border-color 160ms ease-out, color 160ms ease-out;
}

.button {
  padding: 10px 16px;
}

.button:not(:disabled):hover,
.brand-button:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.button:not(:disabled):active,
.brand-button:active {
  transform: translateY(1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button--primary {
  border-color: var(--primary);
  background: var(--primary);
  color: oklch(0.99 0 0);
}

.button--primary:not(:disabled):hover {
  border-color: var(--primary-strong);
  background: var(--primary-strong);
}

.button--quiet {
  background: transparent;
}

.button--large {
  min-height: 52px;
  padding-inline: 22px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklch, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
}

.topbar__inner {
  width: min(1180px, calc(100% - 40px));
  min-height: 68px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand-button {
  min-height: 44px;
  padding: 8px 12px;
  border-color: transparent;
  background: transparent;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

html.is-embedded .topbar {
  display: none;
}

html.is-embedded .control-footer {
  display: none;
}

html.is-embedded body.has-control-footer {
  padding-bottom: 0;
}

html.is-embedded .topbar__inner {
  min-height: 56px;
  justify-content: flex-end;
}

html.is-embedded .brand-button {
  display: none;
}

.score-readout {
  margin: 0 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  white-space: nowrap;
}

.score-readout strong {
  margin-left: 4px;
  color: var(--ink);
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
}

.score-readout span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.view {
  min-height: calc(100dvh - 69px);
}

.library-view {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
  padding-block: 46px 80px;
}

.library-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.section-kicker,
.library-step {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 0.88rem;
  font-weight: 750;
}

.library-heading h1 {
  max-width: 14ch;
  margin: 0;
  font-size: 2.15rem;
  line-height: 1.12;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.library-heading > div > p:last-child {
  max-width: 60ch;
  margin: 12px 0 0;
  color: var(--muted);
}

.library-count {
  margin: 0 0 4px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.library-status {
  min-height: 180px;
  display: grid;
  place-content: center;
  gap: 6px;
  margin-top: 32px;
  padding: 28px;
  border-radius: var(--radius-panel);
  background: var(--surface-subtle);
  text-align: center;
}

.library-status strong {
  font-size: 1.08rem;
}

.library-status span {
  color: var(--muted);
}

.library-status .button {
  justify-self: center;
  margin-top: 12px;
}

.library-status--error {
  background: var(--danger-soft);
}

.library-content {
  padding-top: 8px;
}

.level-section,
.article-section {
  padding-block: 32px;
}

.level-section {
  border-bottom: 1px solid var(--line);
}

.library-section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 20px;
}

.library-section-heading h2 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}

.library-section-heading > p {
  margin: 0 0 2px;
  color: var(--muted);
}

.level-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.level-option {
  min-width: 132px;
  display: grid;
  gap: 2px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform 160ms cubic-bezier(0.16, 1, 0.3, 1), border-color 160ms ease-out, background-color 160ms ease-out;
}

.level-option:hover {
  border-color: var(--primary);
}

.level-option:active {
  transform: translateY(1px);
}

.level-option[data-selected="true"] {
  border-color: var(--primary);
  background: var(--primary);
  color: oklch(0.99 0 0);
}

.level-option strong {
  font-size: 1.16rem;
}

.level-option span {
  color: var(--muted);
  font-size: 0.84rem;
}

.level-option[data-selected="true"] span {
  color: oklch(0.93 0.025 270);
}

.article-search-label {
  min-width: min(310px, 100%);
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.article-search-label input {
  min-height: 44px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
}

.article-search-label input::placeholder {
  color: color-mix(in oklch, var(--muted) 90%, var(--ink));
}

.article-search-label input:disabled {
  opacity: 0.55;
}

.article-prompt {
  margin: 26px 0;
  color: var(--muted);
}

.article-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.article-card {
  min-width: 0;
}

.article-card__button {
  width: 100%;
  min-height: 100%;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform 160ms cubic-bezier(0.16, 1, 0.3, 1), border-color 160ms ease-out, background-color 160ms ease-out;
}

.article-card__button:hover,
.article-card[data-current="true"] .article-card__button {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.article-card__button:active {
  transform: translateY(1px);
}

.article-card__image {
  position: relative;
  display: block;
  width: 92px;
  aspect-ratio: 306 / 396;
  overflow: hidden;
  border-radius: 3px;
  background: var(--surface-strong);
}

.article-card__image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 180ms ease-out;
}

.article-card__image img.is-loaded {
  opacity: 1;
}

.article-card__image-progress {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 720;
  line-height: 1.25;
  text-align: center;
}

.article-card__copy {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.article-card__copy strong {
  font-size: 1.02rem;
  line-height: 1.25;
  text-wrap: pretty;
}

.article-card__meta,
.article-card__score {
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.article-card__score {
  color: var(--primary-strong);
  font-weight: 700;
}

.text-button {
  min-height: 36px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 750;
  cursor: pointer;
}

.text-button:hover {
  color: var(--primary-strong);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.article-picker-button {
  min-height: 44px;
  flex: 0 0 auto;
  padding: 8px 18px;
  border: 2px solid var(--primary);
  border-radius: var(--radius-control);
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 180ms ease-out, border-color 180ms ease-out, color 180ms ease-out, transform 180ms ease-out;
}

.article-picker-button:hover {
  border-color: var(--primary-strong);
  background: var(--primary);
  color: oklch(0.985 0.004 270);
}

.article-picker-button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.article-picker-button:active {
  transform: translateY(1px);
}

.section-heading > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.home-view {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
  padding-block: 42px 72px;
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.78fr) minmax(460px, 1.35fr);
  gap: clamp(36px, 7vw, 92px);
  align-items: start;
}

.book-intro {
  position: sticky;
  top: 104px;
}

.book-cover-link {
  display: block;
  width: min(100%, 360px);
  margin-inline: auto;
  border-radius: 4px;
}

.book-cover {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  background: oklch(1 0 0);
  box-shadow: 0 6px 8px var(--book-shadow);
}

.book-copy {
  width: min(100%, 420px);
  margin: 24px auto 0;
}

.book-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.86rem;
}

.book-copy h1,
.section-heading h2,
.records-heading h2,
.quiz-header h1,
.self-intro h2,
.quiz-intro h2,
.round-summary h2 {
  text-wrap: balance;
}

.book-copy h1 {
  max-width: 12ch;
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1.06;
  letter-spacing: -0.035em;
}

.book-copy > p:last-child {
  max-width: 34ch;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.03rem;
}

.journey {
  padding-top: 12px;
}

.section-heading {
  margin-bottom: 28px;
}

.section-heading h2,
.records-heading h2 {
  margin: 0;
  font-size: 1.7rem;
  letter-spacing: -0.025em;
}

.section-heading p,
.records-heading p {
  max-width: 55ch;
  margin: 8px 0 0;
  color: var(--muted);
}

.stage-list {
  border-top: 1px solid var(--line);
}

.stage-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding-block: 26px;
  border-bottom: 1px solid var(--line);
}

.stage-row[data-complete="true"] {
  background: linear-gradient(90deg, var(--success-soft), transparent 68%);
}

.stage-number {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stage-row[data-complete="true"] .stage-number {
  background: var(--success);
  color: oklch(0.99 0 0);
}

.stage-title-line {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.stage-title-line h3 {
  margin: 0;
  font-size: 1.24rem;
  letter-spacing: -0.015em;
}

.stage-points {
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 800;
}

.stage-copy > p {
  max-width: 56ch;
  margin: 7px 0 0;
  color: var(--muted);
}

.stage-copy .stage-status {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 750;
}

.voice-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.voice-picker label {
  margin-right: 2px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 750;
}

.voice-picker select {
  min-height: 44px;
  padding: 8px 34px 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
}

.voice-picker select:hover,
.voice-picker select:focus-visible {
  border-color: var(--primary);
}

.voice-picker select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.voice-preview-button {
  min-height: 44px;
  padding-inline: 12px;
  font-size: 0.88rem;
}

.stage-action {
  min-width: 118px;
  white-space: nowrap;
}

.records-section {
  margin-top: 64px;
  padding-top: 36px;
  border-top: 1px solid var(--line);
}

.records-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.record-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 32px;
}

.summary-item {
  min-width: 170px;
  padding: 16px;
  border-radius: var(--radius-panel);
  background: var(--surface-subtle);
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
}

.summary-item strong {
  display: block;
  margin-top: 4px;
  font-size: 1.12rem;
}

.record-block {
  margin-top: 34px;
}

.record-block h3 {
  margin: 0 0 14px;
  font-size: 1.12rem;
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-panel);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:nth-child(even) {
  background: var(--surface-subtle);
}

.recordings-list {
  display: grid;
  gap: 12px;
}

.recording-row {
  display: grid;
  grid-template-columns: minmax(160px, 0.7fr) minmax(220px, 1.3fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  border-radius: var(--radius-panel);
  background: var(--surface);
}

.recording-row p {
  margin: 0;
}

.recording-row small {
  display: block;
  color: var(--muted);
}

.recording-row audio {
  width: 100%;
}

.recording-actions {
  display: flex;
  gap: 8px;
}

.download-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.download-link:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.empty-message {
  margin: 0;
  padding: 22px;
  border-radius: var(--radius-panel);
  background: var(--surface-subtle);
  color: var(--muted);
  text-align: center;
}

.reader-view {
  width: min(1580px, calc(100% - 16px));
  margin-inline: auto;
  padding-block: 18px 32px;
}

.reader-toolbar {
  min-height: 72px;
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 150px;
  gap: 18px;
  align-items: center;
}

.reader-heading {
  text-align: center;
}

.reader-heading p,
.reader-heading h1,
.quiz-header p,
.quiz-header h1 {
  margin: 0;
}

.reader-heading p,
.quiz-header > div > p {
  color: var(--muted);
  font-size: 0.84rem;
}

.reader-heading h1 {
  margin-top: 2px;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.reader-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.recording-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--record);
  font-weight: 800;
}

.recording-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--record);
  animation: recording-pulse 1.6s ease-in-out infinite;
}

@keyframes recording-pulse {
  50% { opacity: 0.34; }
}

.self-intro,
.quiz-intro {
  width: min(760px, 100%);
  min-height: 56dvh;
  margin: 28px auto 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 36px;
  align-items: center;
  padding: clamp(28px, 6vw, 64px);
  border-radius: var(--radius-panel);
  background: var(--surface);
}

.self-intro h2,
.quiz-intro h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.self-intro p,
.quiz-intro p {
  max-width: 52ch;
  margin: 16px 0 0;
  color: var(--muted);
}

.privacy-note {
  font-weight: 750;
}

.inline-error {
  padding: 10px 12px;
  border-radius: var(--radius-control);
  background: var(--danger-soft);
  color: var(--danger) !important;
  font-weight: 700;
}

.reader-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(220px, 16vw, 300px);
  gap: clamp(16px, 1.5vw, 24px);
  align-items: center;
  min-height: calc(100dvh - 160px);
}

.page-area {
  position: relative;
  display: grid;
  grid-template-columns: 60px minmax(0, 880px) 60px;
  gap: 10px;
  align-items: center;
  justify-content: center;
}

.book-spread {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(100%, 880px);
  margin: 0;
  border-radius: 4px;
  background: oklch(1 0 0);
  box-shadow: 0 6px 8px var(--book-shadow);
}

.book-spread::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  z-index: 2;
  width: 1px;
  background: oklch(0.76 0.01 270);
  box-shadow: 1px 0 4px oklch(0.18 0.02 270 / 0.22);
  pointer-events: none;
}

.book-page {
  min-width: 0;
  background: oklch(1 0 0);
}

.book-page--left,
.book-page--left img {
  border-radius: 4px 0 0 4px;
}

.book-page--right,
.book-page--right img {
  border-radius: 0 4px 4px 0;
}

.book-page img {
  display: block;
  width: 100%;
  height: auto;
  background: oklch(1 0 0);
}

.book-spread figcaption {
  position: absolute;
  inset: 28% 12%;
  z-index: 3;
  padding: 24px;
  border-radius: var(--radius-panel);
  background: var(--danger-soft);
  color: var(--danger);
  text-align: center;
}

.page-button {
  min-width: 60px;
  padding-inline: 4px;
  font-size: 0.9rem;
  white-space: nowrap;
}

.book-fullscreen-button {
  position: absolute;
  top: 12px;
  right: 72px;
  z-index: 5;
  display: grid;
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 8px;
  place-items: center;
  background: color-mix(in oklch, var(--surface) 92%, transparent);
  backdrop-filter: blur(6px);
}

.fullscreen-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fullscreen-icon__exit {
  display: none;
}

.book-fullscreen-button[aria-pressed="true"] .fullscreen-icon__enter {
  display: none;
}

.book-fullscreen-button[aria-pressed="true"] .fullscreen-icon__exit {
  display: block;
}

.reader-panel {
  max-width: none;
  padding-left: clamp(16px, 1.5vw, 24px);
  border-left: 1px solid var(--line);
}

.reader-status {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.status-label {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.reader-status strong {
  text-align: right;
}

.transcript-block {
  margin-top: 26px;
}

.transcript-block h2 {
  margin: 0;
  font-size: 0.94rem;
}

.transcript-pages {
  display: grid;
  gap: 18px;
  margin-top: 14px;
}

.transcript-pages > div + div {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.transcript-pages h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.transcript-pages p {
  margin: 12px 0 0;
  font-size: clamp(0.98rem, 1.6vw, 1.16rem);
  line-height: 1.62;
  text-wrap: pretty;
}

.follow-controls,
.self-controls {
  display: grid;
  gap: 10px;
  margin-top: 30px;
}

.control-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.quiz-view {
  width: min(980px, calc(100% - 40px));
  margin-inline: auto;
  padding-block: 28px 64px;
}

.quiz-shell {
  min-height: calc(100dvh - 150px);
}

.quiz-header {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 150px;
  gap: 18px;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.quiz-header > div {
  text-align: center;
}

.quiz-header h1 {
  margin-top: 2px;
  font-size: 1.2rem;
}

.quiz-score {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.quiz-score strong {
  margin-right: 3px;
  color: var(--primary);
  font-size: 1.5rem;
}

.question-panel,
.round-results {
  width: min(760px, 100%);
  margin: 42px auto 0;
}

.question-progress {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  width: 100%;
  margin-bottom: 26px;
  font-size: clamp(1.45rem, 3vw, 2rem);
  line-height: 1.28;
  font-weight: 780;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.option-list {
  display: grid;
  gap: 12px;
}

.option-label {
  position: relative;
  display: grid;
  grid-template-columns: 26px 32px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  min-height: 58px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
  cursor: pointer;
  transition: transform 160ms cubic-bezier(0.16, 1, 0.3, 1), border-color 160ms ease-out, background-color 160ms ease-out;
}

.option-label:hover {
  border-color: var(--primary);
}

.option-label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-1px);
}

.option-label input {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--primary);
}

.option-label .option-text {
  font-size: 1.03rem;
  line-height: 1.48;
}

.option-letter {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 780;
}

.option-label:has(input:checked) .option-letter {
  background: var(--primary);
  color: oklch(0.99 0 0);
}

.quiz-form-actions {
  display: grid;
  grid-template-columns: minmax(112px, 0.34fr) minmax(0, 1fr);
  gap: 12px;
  margin-top: 24px;
}

.quiz-form-actions .button {
  width: 100%;
}

.control-footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: var(--z-sticky);
  border-top: 1px solid var(--line);
  background: color-mix(in oklch, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
  padding-bottom: env(safe-area-inset-bottom);
}

.control-footer__inner {
  display: flex;
  width: min(1180px, 100%);
  min-height: 58px;
  margin-inline: auto;
  padding-inline: 20px;
  align-items: center;
  justify-content: center;
  gap: 20px;
  overflow-x: auto;
  scrollbar-width: none;
}

.control-footer__inner::-webkit-scrollbar {
  display: none;
}

.control-footer__context {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.control-footer__shortcuts {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 18px;
}

.control-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 0.88rem;
  white-space: nowrap;
}

.control-shortcut__keys {
  display: inline-flex;
  gap: 4px;
}

.control-shortcut kbd {
  display: inline-grid;
  min-width: 29px;
  height: 28px;
  padding-inline: 6px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-subtle);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 780;
  line-height: 1;
}

.has-control-footer .reward-toast {
  bottom: calc(72px + env(safe-area-inset-bottom));
}

.round-summary {
  padding: 26px;
  border-radius: var(--radius-panel);
  background: var(--surface);
}

.round-summary h2 {
  margin: 0;
  font-size: 1.75rem;
  letter-spacing: -0.025em;
}

.round-summary p {
  margin: 10px 0 0;
  color: var(--muted);
}

.wrong-review {
  margin-top: 28px;
}

.wrong-review > h3 {
  margin: 0 0 14px;
}

.wrong-item {
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.wrong-item:first-of-type {
  border-top: 1px solid var(--line);
}

.wrong-item h4 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.45;
}

.wrong-item p {
  margin: 9px 0 0;
  color: var(--muted);
}

.wrong-item .wrong-answer {
  color: var(--danger);
}

.result-actions {
  display: flex;
  gap: 12px;
  margin-top: 28px;
}

.reward-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: var(--z-toast);
  min-width: 210px;
  padding: 18px 20px;
  border-radius: var(--radius-panel);
  background: var(--primary);
  color: oklch(0.99 0 0);
  box-shadow: 0 6px 8px var(--book-shadow);
  animation: toast-in 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

.reward-toast strong,
.reward-toast span {
  display: block;
}

.voice-loading-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: calc(var(--z-toast) + 10);
  max-width: min(88vw, 360px);
  padding: 16px 20px;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--ink);
  color: var(--page);
  font-size: 1rem;
  font-weight: 760;
  text-align: center;
  box-shadow: 0 6px 8px var(--book-shadow);
}

html:fullscreen,
html[data-book-fullscreen="true"],
html[data-book-fullscreen="true"] body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

html[data-book-fullscreen="true"] .topbar,
html[data-book-fullscreen="true"] .reader-toolbar,
html[data-book-fullscreen="true"] .reader-panel,
html[data-book-fullscreen="true"] .control-footer {
  display: none !important;
}

html[data-book-fullscreen="true"] body.has-control-footer {
  padding-bottom: 0;
}

html[data-book-fullscreen="true"] #main-content,
html[data-book-fullscreen="true"] .reader-view,
html[data-book-fullscreen="true"] .reader-workspace {
  width: 100%;
  max-width: none;
  height: 100%;
  min-height: 100%;
  margin: 0;
  padding: 0;
}

html[data-book-fullscreen="true"] .reader-workspace {
  display: block;
}

html[data-book-fullscreen="true"] .page-area {
  grid-template-columns: 64px minmax(0, min(calc(100vw - 176px), calc((100vh - 32px) * 1.5455))) 64px;
  width: 100%;
  height: 100vh;
  padding: 16px;
  gap: 12px;
}

html[data-book-fullscreen="true"] .book-spread {
  width: 100%;
  max-height: calc(100vh - 32px);
}

html[data-book-fullscreen="true"] .book-fullscreen-button {
  top: 24px;
  right: 84px;
}

.reward-toast strong {
  font-size: 1.45rem;
}

.reward-toast span {
  margin-top: 2px;
  opacity: 0.9;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

noscript {
  display: block;
  padding: 20px;
  background: var(--danger-soft);
  color: var(--danger);
  text-align: center;
}

@media (max-width: 980px) {
  .home-grid {
    grid-template-columns: minmax(240px, 0.7fr) minmax(420px, 1.3fr);
    gap: 36px;
  }

  .stage-row {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .stage-action {
    grid-column: 2;
    justify-self: start;
  }

  .page-area {
    grid-template-columns: 60px minmax(0, 820px) 60px;
  }

  .page-button {
    min-width: 60px;
    padding-inline: 4px;
  }
}

@media (max-width: 1100px) {
  .reader-workspace {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .reader-panel {
    max-width: none;
    padding: 24px 0 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .transcript-pages {
    grid-template-columns: 1fr 1fr;
  }

  .transcript-pages > div + div {
    padding-top: 0;
    padding-left: 18px;
    border-top: 0;
    border-left: 1px solid var(--line);
  }
}

@media (max-width: 820px) {
  .topbar__inner,
  .library-view,
  .home-view,
  .quiz-view {
    width: min(100% - 28px, 720px);
  }

  .home-grid,
  .reader-workspace {
    grid-template-columns: 1fr;
  }

  .book-intro {
    position: static;
    display: grid;
    grid-template-columns: minmax(180px, 0.75fr) minmax(260px, 1.25fr);
    gap: 28px;
    align-items: center;
  }

  .book-copy {
    margin: 0;
  }

  .book-cover-link {
    width: min(100%, 300px);
  }

  .reader-toolbar,
  .quiz-header {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .reader-workspace {
    padding-top: 16px;
  }

  .recording-row {
    grid-template-columns: 1fr;
  }

  .recording-actions {
    justify-content: flex-start;
  }

  .library-heading {
    align-items: start;
    flex-direction: column;
    gap: 14px;
  }

  .library-section-heading--articles {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .topbar__inner {
    min-height: 64px;
    gap: 8px;
  }

  .control-footer__inner {
    justify-content: flex-start;
    gap: 14px;
    padding-inline: 14px;
  }

  .control-footer__context {
    display: none;
  }

  .control-footer__shortcuts {
    gap: 14px;
  }

  .control-shortcut {
    font-size: 0.82rem;
  }

  .brand-button {
    max-width: none;
    padding-inline: 4px;
    font-size: 0.88rem;
    text-align: left;
    white-space: nowrap;
  }

  .topbar__actions {
    flex: 1;
    justify-content: flex-end;
    gap: 6px;
  }

  .topbar__actions .button {
    min-width: 44px;
    padding-inline: 8px;
    font-size: 0.84rem;
    white-space: nowrap;
  }

  .score-readout {
    margin-right: 0;
    font-size: 0;
  }

  .score-readout strong,
  .score-readout span {
    font-size: 0.95rem;
  }

  .home-view {
    padding-block: 24px 48px;
  }

  .library-view {
    width: min(100% - 24px, 600px);
    padding-block: 28px 54px;
  }

  .library-heading h1 {
    font-size: 1.8rem;
  }

  .library-section-heading {
    align-items: start;
    flex-direction: column;
    gap: 8px;
  }

  .level-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .level-option {
    min-width: 0;
  }

  .article-list {
    grid-template-columns: 1fr;
  }

  .article-card__button {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .article-card__image {
    width: 84px;
  }

  .book-intro {
    grid-template-columns: 1fr;
  }

  .book-cover-link {
    width: min(72vw, 280px);
  }

  .book-copy {
    text-align: center;
  }

  .book-copy h1,
  .book-copy > p:last-child {
    margin-inline: auto;
  }

  .book-meta {
    justify-content: center;
  }

  .stage-row {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 14px;
  }

  .stage-action {
    width: 100%;
  }

  .records-heading,
  .result-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .reader-view {
    width: min(100% - 20px, 600px);
    padding-top: 8px;
  }

  .reader-toolbar,
  .quiz-header {
    grid-template-columns: 1fr auto;
    gap: 10px;
  }

  .reader-heading,
  .quiz-header > div {
    grid-column: 1 / -1;
    grid-row: 1;
    text-align: left;
  }

  .reader-toolbar > .button,
  .quiz-header > .button {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
  }

  .reader-meta,
  .quiz-score {
    grid-column: 2;
    grid-row: 2;
  }

  .self-intro,
  .quiz-intro {
    min-height: 50dvh;
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 28px 22px;
  }

  .page-area {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .book-spread {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .page-button {
    width: 100%;
    min-width: 0;
  }

  #previous-page-button {
    grid-column: 1;
    grid-row: 2;
  }

  #next-page-button {
    grid-column: 2;
    grid-row: 2;
  }

  .transcript-pages {
    grid-template-columns: 1fr;
  }

  .transcript-pages > div + div {
    padding-top: 16px;
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .reward-toast {
    right: 14px;
    bottom: 14px;
    left: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .topbar,
  .control-footer {
    background: var(--surface);
    backdrop-filter: none;
  }
}
