:root {
  --bg: #f6f0e6;
  --bg-desk: #e4d7c6;
  --card: #fffdf9;
  --ink: #1c1612;
  --ink-soft: #3a332c;
  --pine: #1a4638;
  --pine-deep: #0f2e25;
  --cinnabar: #8a2c1b;
  --line: #dccdbb;
  --good-bg: #e6f2eb;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(48, 30, 12, 0.05);
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 112.5%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", "Heiti SC", "Source Han Sans SC", sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

[hidden] {
  display: none !important;
}

.frame {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
}

.wrap {
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: 2.05rem;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.28rem;
  line-height: 1.3;
  margin-bottom: 8px;
}

a {
  color: var(--pine);
  font-weight: 700;
}

button,
a {
  -webkit-tap-highlight-color: rgba(26, 70, 56, 0.16);
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--pine);
  outline-offset: 3px;
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--cinnabar);
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 0.86rem;
}

.hero {
  padding-top: calc(12px + env(safe-area-inset-top));
}

.hero h1 {
  display: inline-block;
  margin-bottom: 12px;
  border-bottom: 6px solid var(--cinnabar);
  padding-bottom: 2px;
}

.lede {
  font-size: 1.12rem;
  color: var(--ink);
  margin-bottom: 18px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}

.stack.later {
  margin-top: 18px;
}

.btn-primary,
.btn-ghost,
.listen-btn,
.en-btn,
.choice,
.day {
  border-radius: var(--radius);
  border: 2px solid var(--ink);
  text-decoration: none;
}

.btn-primary,
.btn-ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 58px;
  padding: 12px 16px;
  font-size: 1.12rem;
  font-weight: 800;
  text-align: center;
}

.btn-primary {
  background: var(--pine);
  color: #f7f3ea;
  border-color: var(--pine-deep);
}

.when-playing {
  display: none;
}

#app.is-playing .when-idle {
  display: none;
}

#app.is-playing .when-playing {
  display: inline;
}

#app.is-playing [data-action="play-all"] {
  background: var(--cinnabar);
  border-color: #6e2114;
}

.btn-ghost {
  background: var(--card);
  color: var(--ink);
}

.btn-primary:active,
.btn-ghost:active,
.listen-btn:active,
.choice:active,
.day:active {
  transform: translateY(1px);
}

.section {
  margin-top: 28px;
}

.section-lead,
.fine,
.scene-line,
.mode-hint,
.week-focus,
.week-meta,
.voice-status {
  color: var(--ink-soft);
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.steps li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.num {
  flex: 0 0 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  margin-top: 2px;
}

.steps strong {
  display: block;
  font-size: 1.12rem;
}

.steps p {
  margin: 2px 0 0;
}

.rules {
  margin: 0;
  padding-left: 1.2em;
}

.rules li {
  margin: 8px 0;
  padding-left: 4px;
}

.rules li::marker {
  color: var(--cinnabar);
  font-weight: 800;
}

.sticky {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: calc(8px + env(safe-area-inset-top)) 16px 12px;
}

.back {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  text-decoration: none;
  font-size: 1.05rem;
}

.page-title {
  margin: 0 0 4px;
  font-size: 1.85rem;
}

.week-heading {
  margin: 0 0 8px;
  font-size: 1.35rem;
  line-height: 1.25;
}

.sticky .mode-hint {
  margin: 8px 0 0;
}

.segment {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 2px solid var(--ink);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card);
}

.segment button {
  min-height: 52px;
  border: 0;
  background: transparent;
  border-right: 2px solid var(--ink);
  font-weight: 800;
  font-size: 1.05rem;
  padding: 8px 4px;
}

.segment button:last-child {
  border-right: 0;
}

.segment button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
}

.focus {
  font-size: 1.12rem;
  font-weight: 800;
  margin: 12px 0 4px;
}

.scene-line,
.mode-hint,
.day-caption,
.fine,
.next-step {
  margin: 0 0 8px;
}

.days-block {
  margin: 16px 0 8px;
}

.day-caption {
  font-weight: 800;
  margin-bottom: 8px;
}

.days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.day {
  min-height: 52px;
  background: var(--card);
  font-weight: 800;
  font-size: 1rem;
  padding: 0;
}

.day[aria-pressed="true"] {
  background: var(--pine);
  color: #f7f3ea;
  border-color: var(--pine-deep);
}

.done-note,
.nudge,
.all-known {
  background: var(--good-bg);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 8px 0 12px;
}

.transport {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 6px 0 14px;
}

.speed {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 8px;
  align-items: stretch;
}

.speed-label {
  display: flex;
  align-items: center;
  font-weight: 800;
  padding-right: 4px;
}

.choice {
  min-height: 52px;
  background: var(--card);
  font-weight: 800;
}

.choice[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
}

.voice-note {
  background: #fff6ea;
  border: 2px solid var(--cinnabar);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 14px;
}

.voice-note p {
  margin: 0 0 10px;
}

.lines {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.line {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.line.is-known {
  box-shadow: inset 4px 0 0 var(--pine), var(--shadow);
}

.line.is-active {
  border-color: var(--ink);
  background: #fff;
}

.line.is-repeat {
  border-color: var(--pine);
  background: var(--good-bg);
}

.listen-btn,
.en-btn {
  width: 100%;
  min-height: 76px;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  padding: 10px 12px;
}

.line.is-active .listen-btn {
  background: var(--ink);
  color: var(--bg);
}

.listen-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 800;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  border: 1.5px solid var(--line);
  font-size: 0.95rem;
}

.line.is-active .role-pill {
  background: transparent;
  color: inherit;
  border-color: currentColor;
}

.en {
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  font-size: 1.72rem;
  line-height: 1.28;
  font-weight: 600;
}

.icon-bubble {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--pine);
  color: #f7f3ea;
  display: flex;
  align-items: center;
  justify-content: center;
}

.line.is-active .icon-bubble {
  background: var(--cinnabar);
  color: #fff;
}

.line.is-active .listen-btn .icon-bubble {
  background: var(--bg);
  color: var(--ink);
}

.speaker {
  display: block;
}

.zh {
  margin: 10px 2px 4px;
  font-size: 1.08rem;
}

.zh-cue {
  font-size: 1.42rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.35;
  margin: 4px 2px 12px;
}

.line-tools {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.line-tools.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.repeat-flag {
  display: none;
  margin: 10px 2px 0;
  font-weight: 800;
  color: var(--pine);
  font-size: 1.08rem;
}

.line.is-repeat .repeat-flag {
  display: block;
}

.mark[aria-pressed="true"] {
  background: var(--pine);
  color: #f7f3ea;
  border-color: var(--pine-deep);
}

.note {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.note h2 {
  font-size: 1.08rem;
}

.week-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.week-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 14px 12px;
  min-height: 92px;
  box-shadow: var(--shadow);
}

.week-card:active {
  transform: translateY(1px);
}

.week-num {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 1.55rem;
  color: var(--cinnabar);
  min-width: 1.6em;
  text-align: center;
}

.week-title {
  display: block;
  font-size: 1.18rem;
  font-weight: 800;
}

.week-focus,
.week-meta {
  display: block;
  margin-top: 2px;
}

.week-meta {
  font-size: 0.95rem;
}

.tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--good-bg);
  color: var(--pine);
  font-size: 0.82rem;
  font-weight: 800;
  vertical-align: 2px;
}

.chevron {
  width: 10px;
  height: 10px;
  border-right: 2.5px solid var(--ink);
  border-bottom: 2.5px solid var(--ink);
  transform: rotate(-45deg);
  margin-right: 4px;
}

.progress-line {
  margin: 0 0 12px;
  font-weight: 700;
}

.noscript {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px;
}

.voice-status {
  margin-top: 16px;
  font-size: 0.95rem;
}

@media (min-width: 480px) {
  .en {
    font-size: 2rem;
  }

  .wrap {
    padding-left: 22px;
    padding-right: 22px;
  }

  .sticky {
    padding-left: 22px;
    padding-right: 22px;
  }
}

@media (min-width: 840px) {
  body {
    background: var(--bg-desk);
  }

  .frame {
    border-left: 1px solid #d2c3ae;
    border-right: 1px solid #d2c3ae;
    box-shadow: 0 0 40px rgba(48, 30, 12, 0.05);
  }
}

@media (hover: hover) {
  .btn-primary:hover {
    background: var(--pine-deep);
  }

  .btn-ghost:hover,
  .week-card:hover,
  .listen-btn:hover,
  .choice:hover,
  .day:hover {
    border-color: var(--pine);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }

  .btn-primary:active,
  .btn-ghost:active,
  .listen-btn:active,
  .choice:active,
  .day:active,
  .week-card:active {
    transform: none;
  }
}

@media (max-width: 359px) {
  html {
    font-size: 106%;
  }

  .segment button {
    font-size: 0.98rem;
  }

  .days {
    gap: 4px;
  }
}
