:root {
  --paper: #F7F8FA;
  --surface: #FFFFFF;
  --surface-subtle: #F1F4F8;
  --ink: #132238;
  --ink-muted: #516075;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --cobalt: #1D4ED8;
  --cobalt-soft: #EFF4FF;
  --cobalt-dark: #1E40AF;
  --jade: #0F766E;
  --jade-soft: #ECFDF5;
  --amber: #B45309;
  --amber-soft: #FFFBEB;
  --danger: #B91C1C;
  --danger-soft: #FEF2F2;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Segoe UI", sans-serif;
  --font-en: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

html,
body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--cobalt);
  outline-offset: 2px;
}

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

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

/* App Shell */
.app-shell {
  max-width: 540px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  padding-bottom: calc(74px + env(safe-area-inset-bottom));
}

/* Top Bar */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(247, 248, 250, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: #FFFFFF;
  font-family: var(--font-en);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: -0.02em;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ink-muted);
}

.icon-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.icon-pill[aria-pressed="true"] {
  background: var(--cobalt);
  border-color: var(--cobalt);
  color: #FFFFFF;
}

.pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cobalt);
}

.icon-pill[aria-pressed="true"] .pill-dot {
  background: #FFFFFF;
  animation: pulseDot 1.1s infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 14px 16px 24px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

/* Day Strip */
.day-strip-wrap {
  margin-bottom: 12px;
}

.day-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}

.day-strip::-webkit-scrollbar {
  display: none;
}

.day-chip {
  flex-shrink: 0;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.day-chip.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #FFFFFF;
}

.day-chip-progress {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.85;
}

.day-chip.is-complete:not(.is-active) {
  border-color: var(--jade);
  color: var(--jade);
}

.day-theme {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-muted);
}

/* 3-Sentence Tabs */
.sentence-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.sentence-tab {
  padding: 10px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.sentence-tab-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
}

.sentence-tab-scene {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sentence-tab.is-active {
  border-color: var(--cobalt);
  background: var(--cobalt-soft);
}

.sentence-tab.is-active .sentence-tab-top {
  color: var(--cobalt);
}

.sentence-tab.is-daily.is-active {
  border-color: var(--jade);
  background: var(--jade-soft);
}

.sentence-tab.is-daily.is-active .sentence-tab-top {
  color: var(--jade);
}

.tab-done-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--jade);
}

/* Study Desk */
.study-desk {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 18px 18px;
}

.desk-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
}

.scene-tag {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}

.scene-tag.is-business {
  background: var(--cobalt-soft);
  color: var(--cobalt);
}

.scene-tag.is-daily {
  background: var(--jade-soft);
  color: var(--jade);
}

.pattern-badge {
  font-size: 12px;
  color: var(--ink-muted);
  font-weight: 500;
}

/* Hero English Sentence */
.hero-sentence-wrap {
  margin-bottom: 18px;
}

.hero-en {
  margin: 0 0 10px;
  font-family: var(--font-en);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.38;
  letter-spacing: -0.015em;
  color: var(--ink);
  transition: filter 0.18s ease, opacity 0.18s ease;
}

.hero-en.is-masked {
  filter: blur(8px);
  opacity: 0.35;
  user-select: none;
}

.hero-zh {
  margin: 0 0 12px;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink-muted);
  transition: filter 0.18s ease, opacity 0.18s ease;
}

.hero-zh.is-masked {
  filter: blur(7px);
  opacity: 0.3;
  user-select: none;
}

.mask-controls {
  display: flex;
  gap: 14px;
}

.text-toggle {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  padding: 2px 0;
  border-bottom: 1px dashed var(--border-strong);
}

.text-toggle[aria-pressed="true"] {
  color: var(--cobalt);
  border-bottom-color: var(--cobalt);
}

/* Audio Bar */
.audio-bar {
  display: grid;
  grid-template-columns: 1.5fr 1fr auto;
  gap: 8px;
}

.btn-primary,
.btn-secondary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}

.btn-primary {
  background: var(--cobalt);
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--cobalt-dark);
}

.btn-primary:active,
.btn-secondary:active,
.btn-ghost:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--surface-subtle);
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn-secondary.is-playing {
  border-color: var(--cobalt);
  background: var(--cobalt-soft);
  color: var(--cobalt);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-muted);
  border: 1px solid var(--border);
  padding: 0 12px;
}

.btn-ghost[aria-pressed="true"] {
  border-color: var(--cobalt);
  color: var(--cobalt);
  background: var(--cobalt-soft);
}

.audio-icon {
  font-size: 11px;
}

.audio-status {
  min-height: 18px;
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--ink-muted);
}

/* 3-Step Practice Tabs */
.practice-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 16px -18px 0;
  padding: 0 18px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--paper);
}

.practice-tab {
  padding: 12px 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.practice-tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.practice-panel {
  display: none;
  padding-top: 18px;
}

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

/* Mode 1: Decode */
.info-block {
  margin-bottom: 16px;
}

.info-block:last-child {
  margin-bottom: 4px;
}

.block-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.block-label {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-muted);
}

.block-hint {
  font-size: 12px;
  color: var(--ink-muted);
}

.pattern-formula {
  margin: 0;
  padding: 12px 14px;
  background: var(--surface-subtle);
  border-left: 3px solid var(--cobalt);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-family: var(--font-en);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--ink);
}

.pattern-slot {
  display: inline-block;
  padding: 1px 6px;
  margin: 0 2px;
  border-radius: 4px;
  background: var(--cobalt-soft);
  color: var(--cobalt);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
}

.note-body {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink);
}

.pron-body {
  padding: 10px 12px;
  background: var(--amber-soft);
  border-radius: var(--radius-sm);
  color: #78350F;
}

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

.swap-item-btn {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.swap-item-btn:hover {
  border-color: var(--cobalt);
  background: var(--cobalt-soft);
}

.swap-en {
  font-family: var(--font-en);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.swap-zh {
  font-size: 12px;
  color: var(--ink-muted);
}

/* Mode 2: Shadowing */
.shadow-tip {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-muted);
}

.record-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.btn-record {
  flex: 1;
  min-height: 48px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  background: var(--ink);
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.btn-record[aria-pressed="true"] {
  background: var(--amber);
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #F87171;
}

.btn-record[aria-pressed="true"] .rec-dot {
  background: #FFFFFF;
  animation: pulseDot 0.9s infinite;
}

.rec-timer {
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-muted);
  min-width: 48px;
  text-align: right;
}

.playback-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.speech-result {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: var(--paper);
  margin-bottom: 10px;
}

.speech-score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.score-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--jade-soft);
  color: var(--jade);
}

.score-pill.is-warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.word-diff {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.diff-word {
  font-family: var(--font-en);
  font-size: 14px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 5px;
}

.diff-word.is-ok {
  background: var(--jade-soft);
  color: var(--jade);
}

.diff-word.is-miss {
  background: var(--amber-soft);
  color: var(--amber);
}

.recognized-raw {
  margin: 0;
  font-size: 12px;
  color: var(--ink-muted);
}

.shadow-status {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-muted);
}

/* Mode 3: Dictation */
.dictate-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.sub-pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
}

.sub-pill.is-active {
  border-color: var(--ink);
  background: var(--ink);
  color: #FFFFFF;
}

.dictate-switch .text-toggle {
  margin-left: auto;
}

.cloze-prompt {
  margin: 0 0 12px;
  padding: 12px 14px;
  background: var(--surface-subtle);
  border-radius: var(--radius-sm);
  font-family: var(--font-en);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
}

.cloze-blank {
  display: inline-block;
  min-width: 68px;
  padding: 0 6px;
  margin: 0 2px;
  border-bottom: 2px solid var(--cobalt);
  color: var(--cobalt);
  font-weight: 700;
  text-align: center;
}

.cloze-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.cloze-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cloze-idx {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--cobalt-soft);
  color: var(--cobalt);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cloze-input,
.dictate-textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-en);
  font-size: 15px;
  background: var(--surface);
}

.cloze-input.is-correct {
  border-color: var(--jade);
  background: var(--jade-soft);
}

.cloze-input.is-wrong {
  border-color: var(--amber);
  background: var(--amber-soft);
}

.dictate-textarea {
  resize: vertical;
  margin-bottom: 12px;
  line-height: 1.5;
}

.dictate-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dictate-actions .btn-primary {
  flex: 1;
}

.dictate-feedback {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid var(--border);
  background: var(--paper);
}

.dictate-feedback.is-pass {
  border-color: var(--jade);
  background: var(--jade-soft);
  color: #065F46;
}

/* Mastery Footer */
.mastery-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.mastery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.mastery-head .block-label {
  margin: 0;
}

.mastery-next {
  font-size: 12px;
  color: var(--ink-muted);
}

.mastery-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.rate-btn {
  min-height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.rate-btn.is-selected.rate-hard {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.rate-btn.is-selected.rate-mid {
  background: var(--amber-soft);
  border-color: var(--amber);
  color: var(--amber);
}

.rate-btn.is-selected.rate-easy {
  background: var(--jade-soft);
  border-color: var(--jade);
  color: var(--jade);
}

/* View 2: Review */
.section-intro {
  margin-bottom: 14px;
}

.section-title {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 700;
}

.section-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-muted);
}

.review-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  font-size: 13px;
}

.review-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 18px;
}

.review-empty {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  text-align: center;
}

.review-empty p {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--ink-muted);
  line-height: 1.6;
}

.review-reveal-box {
  margin: 14px 0;
  padding: 14px;
  background: var(--paper);
  border-radius: var(--radius-md);
}

/* View 3: Roadmap */
.progress-banner {
  background: var(--ink);
  color: #FFFFFF;
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
}

.progress-numbers {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.progress-big {
  font-family: var(--font-en);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.progress-unit {
  font-size: 13px;
  color: #CBD5E1;
  margin-left: 4px;
}

.streak-chip {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  background: #38BDF8;
  border-radius: 999px;
  transition: width 0.25s ease;
}

.progress-caption {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: #CBD5E1;
}

.roadmap-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.stage-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.stage-card.is-current {
  border-color: var(--cobalt);
}

.stage-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.stage-days {
  font-size: 12px;
  font-weight: 700;
  color: var(--cobalt);
}

.stage-count {
  font-size: 12px;
  color: var(--ink-muted);
}

.stage-title {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 700;
}

.stage-detail {
  margin: 0 0 4px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-muted);
}

.stage-detail strong {
  color: var(--ink);
  font-weight: 600;
}

.data-tools {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.data-btn-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 540px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  z-index: 30;
}

.nav-item {
  min-height: 44px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.nav-item.is-active {
  background: var(--ink);
  color: #FFFFFF;
}

.nav-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--amber);
  color: #FFFFFF;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
