:root {
  --paper: #f3ecdf;
  --card: #fffaf1;
  --ink: #241c12;
  --mute: #999999;
  --line: #e2d5c0;
  --clay: #b4452b;
  --clay-deep: #8e2f1b;
  --moss: #2f4a3a;
  --moss-soft: #dce8df;
  --gold: #c4a46a;
  --hi: #f3d27a;
  --shadow: 0 6px 16px rgba(48, 32, 14, 0.06);
  --app-max: 1100px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

body {
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #fff8ea 0%, transparent 50%),
    linear-gradient(180deg, #f7f0e4 0%, var(--paper) 100%);
  font-family: "Noto Sans SC", "Songti SC", sans-serif;
}

.app {
  position: relative;
  display: none;
  grid-template-columns: 232px 1fr;
  width: min(100%, var(--app-max));
  max-width: var(--app-max);
  height: 100%;
  min-height: 0;
  margin: 0 auto;
}

.app.is-on,
body[data-page="nce"] .app,
body[data-page="practice"] .app {
  display: grid;
}

@media (min-width: 1101px) {
  .app {
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    background: rgba(255, 250, 241, 0.55);
    box-shadow: var(--shadow);
  }
}

.rail {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  padding: 14px 12px 16px;
  border-right: 1px solid var(--line);
  background: rgba(255, 250, 241, 0.72);
}

.brand {
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 20px;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.brand-kicker {
  margin: 0 0 2px;
  color: var(--clay);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand-sub,
.copyright-note,
.lesson-summary,
.title-zh,
.crumb,
.player-hint,
.word-zh,
.note-body,
.sent-zh {
  color: var(--mute);
}

.brand-sub {
  margin: 4px 0 12px;
  font-size: 12px;
  line-height: 1.4;
}

.lesson-list {
  flex: 1 1 auto;
  min-height: 0;
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.list-label {
  margin: 10px 0 4px;
  padding: 0 8px;
  color: var(--gold);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  list-style: none;
}

.list-label:first-child {
  margin-top: 0;
}

.badge {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: #f3e2c8;
  color: var(--clay-deep);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.04em;
  vertical-align: 1px;
}

.lesson-list button {
  width: 100%;
  margin-bottom: 2px;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.lesson-list button:hover,
.lesson-list button.is-on {
  background: #fff;
  box-shadow: var(--shadow);
}

.lesson-list .num {
  display: inline-block;
  min-width: 1.6em;
  color: var(--clay);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
}

.lesson-list .en {
  display: block;
  margin-top: 1px;
  font-family: "Fraunces", Georgia, serif;
  font-size: 13px;
  line-height: 1.25;
}

.lesson-list .zh {
  display: block;
  color: var(--mute);
  font-size: 11px;
  line-height: 1.3;
}

.copyright-note {
  margin-top: 12px;
  font-size: 11px;
  line-height: 1.45;
}

.license-note {
  flex-shrink: 0;
  margin-top: 8px;
  color: var(--mute);
}

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  padding: 0 20px 16px;
}

.topbar,
.page-header {
  display: flex;
  flex-shrink: 0;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
}

.page-header {
  z-index: 6;
  margin: 0 -20px 10px;
  padding: 6px 20px;
  background: #eadfc8;
  border-bottom: 1px solid #d9cbb3;
  box-shadow: 0 6px 14px rgba(48, 32, 14, 0.08);
}

.page-heading {
  flex: 1;
  min-width: 0;
}

.page-heading .brand-kicker {
  display: none;
}

.page-heading h1 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 18px;
  letter-spacing: -0.03em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-btn {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.header-btn svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.header-btn:focus-visible {
  outline: none;
  border-color: var(--gold);
}

.header-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.menu-btn,
.rail-close {
  display: none;
}

.home-btn {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}

.home-btn.top-home {
  display: none;
}

.rail-home {
  margin: 0 0 12px;
}

.settings {
  position: relative;
  margin-left: auto;
}

.settings-btn {
  display: inline-flex;
}

.settings-panel {
  position: absolute;
  z-index: 7;
  top: calc(100% + 6px);
  right: 0;
  display: none;
  width: min(300px, calc(100vw - 24px));
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.settings-panel.is-on {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--mute);
  font-size: 12px;
}

.setting-field select {
  max-width: none;
  width: 100%;
  min-height: 34px;
}

.rail-mask {
  display: none;
}

.crumb {
  min-width: 0;
  overflow: hidden;
  color: var(--mute);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.dot {
  margin: 0 4px;
}

select {
  max-width: 200px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
}

.lesson-head {
  flex-shrink: 0;
  width: 100%;
  max-width: 40rem;
  margin: 10px auto 8px;
}

.lesson-index {
  margin: 0 0 2px;
  color: var(--gold);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.lesson-head h2 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(22px, 2.4vw, 28px);
  font-weight: 620;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.title-zh {
  margin: 2px 0 0;
  font-size: 14px;
}

.lesson-summary {
  margin: 2px 0 0;
  font-size: 12px;
}

.tabs {
  display: flex;
  flex-shrink: 0;
  gap: 4px;
  width: 100%;
  max-width: 40rem;
  margin: 0 auto 8px;
}

.tab,
.icon-btn,
.play-btn,
.menu-btn,
.rail-close {
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.tab {
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--mute);
  font-size: 13px;
}

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

.panel {
  display: none;
}

.panel.is-on {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

#panel-text.is-on {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  width: 100%;
  max-width: 40rem;
  margin-inline: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}

.sent {
  display: grid;
  grid-template-columns: 2.8em 1fr;
  gap: 0 8px;
  width: 100%;
  margin: 0;
  padding: 5px 10px;
  border: 0;
  border-bottom: 1px solid #efe4d3;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.sent:last-child {
  border-bottom: 0;
}

.sent:hover,
.sent:active,
.sent:focus {
  background: transparent;
  outline: none;
}

.sent.is-current,
.sent.is-current:hover,
.sent.is-current:active {
  background: #fff6e4;
}

.sent-n {
  color: var(--gold);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  line-height: 1.4;
  padding-top: 2px;
}

.sent-en {
  font-family: "Fraunces", Georgia, serif;
  font-size: 16px;
  line-height: 1.28;
}

.sent-zh {
  margin: 0;
  font-size: 12px;
  line-height: 1.3;
}

.word {
  display: inline-block;
  padding: 0 1px;
  border-radius: 4px;
  transition: background 0.12s ease;
}

.word.is-on {
  background: var(--hi);
}

.word-card {
  max-width: 40rem;
  margin: 0 auto 6px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.ipa-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.word-en {
  font-family: "Fraunces", Georgia, serif;
  font-size: 18px;
  line-height: 1.2;
}

.ipa {
  color: var(--moss);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
}

.pos {
  margin-left: 6px;
  color: var(--clay);
  font-size: 11px;
}

.word-zh,
.word-hint {
  margin: 2px 0 0;
  font-size: 13px;
  line-height: 1.4;
}

.word-hint {
  color: #7a5a32;
}

.say-word {
  padding: 2px 8px;
  border: 0;
  border-radius: 999px;
  background: var(--moss-soft);
  color: var(--moss);
  font-size: 11px;
  cursor: pointer;
}

.note {
  max-width: 40rem;
  margin: 0 auto 8px;
  padding: 8px 12px;
  border-left: 3px solid var(--clay);
  border-radius: 0 10px 10px 0;
  background: var(--card);
}

.note h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.note-body {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
}

.player {
  display: none;
  position: absolute;
  z-index: 7;
  top: 50%;
  right: 10px;
  left: auto;
  bottom: auto;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 5px;
  border: 0;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: 0 8px 24px rgba(36, 28, 18, 0.12);
  transform: translateY(-50%);
  opacity: 0.38;
  transition: opacity 0.45s ease;
}

.player.is-on {
  display: flex;
}

.player.is-awake,
.player:hover,
.player:focus-within {
  opacity: 0.92;
}

.touch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}

.touch-btn svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.touch-btn:disabled {
  opacity: 0.32;
  cursor: default;
}

.play-btn {
  width: 46px;
  height: 46px;
  background: rgba(180, 69, 43, 0.86);
  color: #fff;
}

.play-btn.is-playing {
  background: rgba(47, 74, 58, 0.86);
}

.play-btn .icon-pause {
  display: none;
}

.play-btn[data-mode="pause"] .icon-play {
  display: none;
}

.play-btn[data-mode="pause"] .icon-pause {
  display: block;
}

body[data-lang="en"] .sent-zh,
body[data-lang="en"] .title-zh,
body[data-lang="en"] .lesson-list .zh {
  display: none;
}

body[data-memory="on"]:not([data-lang="zh"]) .sent-zh,
body[data-memory="on"]:not([data-lang="zh"]) .title-zh {
  visibility: hidden;
}

body[data-memory="on"] .sent.is-current .sent-zh {
  visibility: visible;
}

body[data-lang="zh"] .sent-en,
body[data-lang="zh"] #titleEn,
body[data-lang="zh"] .lesson-list .en {
  display: none;
}

body[data-lang="zh"] .title-zh {
  color: var(--ink);
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(20px, 2.4vw, 28px);
  font-weight: 620;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

body[data-lang="zh"] .sent-zh {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.4;
}

.player-hint {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.home,
.drill {
  display: none;
  flex-direction: column;
  width: min(100%, var(--app-max));
  max-width: var(--app-max);
  height: 100%;
  margin: 0 auto;
  min-height: 0;
}

.home.is-on,
.drill.is-on,
body[data-page="home"] .home,
body[data-page="words"] .drill {
  display: flex;
}

.home {
  padding: 36px 24px 24px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.home-head h1 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(28px, 4vw, 40px);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.home-head .brand-sub {
  margin: 8px 0 0;
  max-width: 28rem;
  font-size: 14px;
  line-height: 1.5;
}

.today {
  margin-top: 28px;
  padding: 18px 20px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.today-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 14px;
}

.today-head h2 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 24px;
  letter-spacing: -0.03em;
}

.today-day {
  margin: 0 0 0 auto;
  color: var(--gold);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
}

.today-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.today-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 92px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
}

.today-item:hover,
.today-item:focus-visible {
  border-color: var(--gold);
  outline: none;
}

.today-item h3 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 18px;
  letter-spacing: -0.03em;
}

.today-item p {
  margin: 0;
  color: var(--mute);
  font-size: 13px;
  line-height: 1.45;
}

.today-nav {
  margin-top: 12px;
  justify-content: flex-end;
}

.sync {
  margin-top: 28px;
  padding: 18px 20px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.sync-lead,
.sync-status {
  margin: 8px 0 0;
  color: var(--mute);
  font-size: 13px;
  line-height: 1.45;
}

.sync-code-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.sync-code-row code,
.sync-box code {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f3ecdf;
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: 14px;
  letter-spacing: 0.06em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-code-row button,
.sync-form button,
.sync-box button {
  flex-shrink: 0;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}

.sync-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.sync-form input,
.sync-box .sync-input {
  flex: 1;
  min-width: 0;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf1;
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: 14px;
}

.sync-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  color: var(--mute);
  font-size: 12px;
}

.sync-box .sync-code-row {
  margin-top: 0;
}

.sync-box .sync-status {
  margin: 0;
  font-size: 12px;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 28px;
}

.home-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 200px;
  padding: 20px 20px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  color: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.home-card:hover,
.home-card:focus-visible {
  border-color: var(--gold);
  outline: none;
}

.home-kicker {
  margin: 0 0 8px;
  color: var(--clay);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.home-card h2 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 24px;
  letter-spacing: -0.03em;
}

.home-desc {
  margin: 8px 0 0;
  color: var(--mute);
  font-size: 13px;
  line-height: 1.5;
}

.home-count {
  margin-top: auto;
  padding-top: 18px;
  color: var(--gold);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
}

.home-license {
  margin-top: 28px;
}

.drill {
  padding: 0 20px 24px;
  overflow: hidden;
}

.drill-bar {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
}

.drill-filter {
  display: block;
  flex-shrink: 0;
  width: auto;
  min-width: 7.2rem;
  margin: 0;
}

.page-header .drill-filter select {
  width: 100%;
  min-height: 32px;
  font-size: 13px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.drill-progress {
  margin: 0;
  color: var(--gold);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
}

.plan-toolbar {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 12px;
  margin: 14px 0 10px;
}

.plan-nav {
  display: flex;
  flex-shrink: 0;
  flex-wrap: nowrap;
  gap: 8px;
}

.plan-quiz-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.plan-list {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
  -webkit-overflow-scrolling: touch;
}

.plan-list.is-on {
  display: block;
}

.plan-row {
  display: grid;
  grid-template-columns: 2.8em 1fr;
  gap: 0 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #efe4d3;
  line-height: 1.45;
  cursor: pointer;
}

.plan-row:last-child {
  border-bottom: 0;
}

.plan-row:hover .plan-en,
.plan-row:focus-visible .plan-en {
  color: var(--clay);
}

.plan-row:focus-visible {
  outline: none;
}

.plan-row.is-known .plan-en {
  color: var(--moss);
}

.plan-row.is-current,
.plan-row.is-current:hover {
  background: #fff3d1;
  box-shadow: inset 3px 0 0 var(--gold);
}

.plan-n {
  color: var(--gold);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  line-height: 1.45;
  padding-top: 4px;
}

.plan-en-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 10px;
}

.plan-en {
  color: var(--ink);
  font-family: "Fraunces", Georgia, serif;
  font-size: 17px;
  font-weight: 620;
}

.plan-ipa {
  color: var(--moss);
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
}

.plan-zh {
  margin: 2px 0 0;
  color: var(--mute);
  font-size: 14px;
}

.plan-quiz {
  display: none;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: stretch;
  width: min(100%, 28rem);
  margin: 0 auto;
  min-height: 0;
}

.plan-quiz.is-on {
  display: flex;
}

.word-flash {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  min-height: 220px;
  margin: 8px 0 16px;
  padding: 20px 22px 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  color: inherit;
}

.word-flash.is-ok {
  border-color: var(--moss);
  background: #f4f8f5;
}

.flash-head {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.flash-n {
  color: var(--gold);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
}

.flash-peek {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}

.flash-peek:focus-visible {
  outline: none;
  border-color: var(--gold);
}

.flash-peek svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.flash-peek .icon-eye-off {
  display: none;
}

.flash-peek.is-on {
  color: var(--clay);
  border-color: var(--gold);
  background: #fff6e4;
}

.flash-peek.is-on .icon-eye {
  display: none;
}

.flash-peek.is-on .icon-eye-off {
  display: block;
}

.flash-zh {
  margin: 18px 0 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.45;
}

.flash-en-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
  margin-top: 14px;
}

.flash-en-line.is-off {
  display: none;
}

.flash-en {
  color: var(--ink);
  font-family: "Fraunces", Georgia, serif;
  font-size: 28px;
  font-weight: 620;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.flash-ipa {
  color: var(--moss);
  font-family: "IBM Plex Mono", monospace;
  font-size: 15px;
}

.flash-form {
  margin-top: 32px;
}

.flash-form input {
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
}

.flash-form input:focus {
  outline: none;
  border-color: var(--gold);
}

.flash-form input.is-ok {
  border-color: var(--moss);
  background: var(--moss-soft);
}

.flash-form input.is-bad {
  border-color: var(--clay);
}

.flash-feedback {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: var(--mute);
  font-size: 14px;
}

.flash-feedback.is-ok {
  color: var(--moss);
}

.flash-feedback.is-bad {
  color: var(--clay);
}

.flash-nav {
  flex-shrink: 0;
  justify-content: center;
  gap: 16px;
}

.flash-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}

.flash-nav-btn:focus-visible {
  outline: none;
  border-color: var(--gold);
}

.flash-nav-btn svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.flash-nav-btn:disabled {
  opacity: 0.32;
  cursor: default;
}

.is-hidden {
  display: none !important;
}

.drill-know {
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--moss);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

.drill-know:disabled,
.home-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

@media (max-width: 860px) {
  body.rail-open {
    overflow: hidden;
  }

  .app {
    grid-template-columns: 1fr;
  }

  .rail-mask.is-on {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 8;
    background: rgba(36, 28, 18, 0.4);
  }

  .rail {
    position: fixed;
    z-index: 9;
    top: 0;
    left: 0;
    width: min(86vw, 320px);
    height: 100dvh;
    padding: calc(12px + env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom));
    background: var(--card);
    transform: translateX(-105%);
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.22s ease, visibility 0.22s ease;
    box-shadow: 8px 0 24px rgba(48, 32, 14, 0.12);
    overflow: hidden;
  }

  .rail.is-open {
    transform: none;
    visibility: visible;
    pointer-events: auto;
  }

  .brand {
    position: relative;
    padding-right: 52px;
  }

  .menu-btn,
  .rail-close,
  .home-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font-size: 13px;
  }

  .header-btn.menu-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
  }

  .rail-close {
    position: absolute;
    top: 0;
    right: 0;
  }

  .stage {
    padding: 0 12px calc(16px + env(safe-area-inset-bottom));
  }

  .home {
    padding: calc(16px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
  }

  .home-grid,
  .today-actions {
    grid-template-columns: 1fr;
  }

  .home-card {
    min-height: 0;
  }

  .drill {
    padding: 0 14px calc(20px + env(safe-area-inset-bottom));
  }

  .home-btn.top-home {
    display: inline-flex;
  }

  .topbar,
  .page-header {
    position: sticky;
    top: 0;
    z-index: 6;
    gap: 8px;
    margin: 0 -12px 0;
    padding: calc(6px + env(safe-area-inset-top)) 12px 6px;
    background: #eadfc8;
    border-bottom: 1px solid #d9cbb3;
    box-shadow: 0 6px 14px rgba(48, 32, 14, 0.08);
  }

  body[data-page="words"] .page-header {
    margin: 0 -14px 0;
    padding: calc(6px + env(safe-area-inset-top)) 14px 6px;
  }

  .page-header .drill-filter select {
    min-height: 32px;
    font-size: 16px;
  }

  .settings {
    margin-left: auto;
  }

  .setting-field select {
    min-height: 36px;
    font-size: 16px;
  }

  .crumb {
    min-width: 0;
    line-height: 1.35;
  }

  select {
    flex: 1;
    max-width: none;
    min-height: 36px;
    font-size: 16px;
  }

  .lesson-head {
    margin: 8px 0 6px;
  }

  .lesson-head h2 {
    font-size: clamp(20px, 6.2vw, 26px);
  }

  .tabs {
    gap: 2px;
    margin: 0 -4px 8px;
  }

  .tab {
    flex: 1;
    min-height: 36px;
    padding: 6px 8px;
    font-size: 13px;
  }

  #panel-text.is-on,
  .lesson-head,
  .tabs,
  .word-card,
  .note {
    max-width: none;
  }

  .sent {
    padding: 8px 10px;
    scroll-margin: 12px;
  }

  .sent-en {
    font-size: 16px;
  }

  .plan-row {
    grid-template-columns: 2.4em 1fr;
    padding: 8px;
  }

  .flash-en {
    font-size: 26px;
  }

  .lesson-list button {
    padding: 8px 10px;
  }

  .player {
    right: calc(8px + env(safe-area-inset-right));
    top: 50%;
    bottom: auto;
    left: auto;
    transform: translateY(-50%);
  }
}

@media (max-width: 420px) {
  .stage {
    padding-left: 10px;
    padding-right: 10px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .topbar,
  .page-header {
    margin-left: -10px;
    margin-right: -10px;
  }

  body[data-page="words"] .page-header {
    margin-left: -14px;
    margin-right: -14px;
  }

  .brand-sub,
  .copyright-note {
    font-size: 11px;
  }

  .title-zh {
    font-size: 13px;
  }

  .lesson-summary {
    font-size: 11px;
  }

  .sent {
    grid-template-columns: 2.4em 1fr;
    padding: 8px;
  }

  .word-en {
    font-size: 16px;
  }
}
