@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+TC:wght@400;700;900&family=Karla:wght@400;500;600;700&family=DM+Mono:wght@300;400;500&family=Outfit:wght@300;400;500;600&display=swap');

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

:root {
  --tea-bg: #faf7f2;
  --tea-red: #c94a3a;
  --tea-red-dark: #a83d30;
  --tea-red-light: #f0d4cf;
  --tea-ink: #2d2a26;
  --tea-mid: #6b5e4c;
  --tea-light: #ece6db;
  --tea-card: #fff;
  --tea-border: #e0d8cc;
  --tea-green: #4a8a4a;
  --tea-amber: #b8862a;
  --tea-jp: #9a8a74;
  --nav-height: 56px;
  --header-height: 52px;
  --font-body: 'Karla', sans-serif;
  --font-chinese: 'Noto Serif TC', serif;
  --font-mono: 'DM Mono', monospace;
  --font-heading: 'Outfit', sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--tea-bg);
  color: var(--tea-ink);
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
}

/* ==================== */
/* Header               */
/* ==================== */

#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 16px;
  background: var(--tea-red);
  color: #fff;
  flex-shrink: 0;
}

#app-header h1 {
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
}

#app-header .header-sub {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 1px;
}

#settings-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
}

#settings-btn:hover {
  background: rgba(255,255,255,0.15);
}

/* ==================== */
/* Views                */
/* ==================== */

#view-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.view {
  display: none;
  height: 100%;
  flex-direction: column;
}

.view.active {
  display: flex;
}

/* ==================== */
/* Bottom Nav           */
/* ==================== */

#bottom-nav {
  display: flex;
  background: var(--tea-card);
  border-top: 1px solid var(--tea-border);
  padding: 6px 0 10px;
  flex-shrink: 0;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.nav-item {
  flex: 1;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.5px;
  color: var(--tea-jp);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding-top: 6px;
  text-decoration: none;
  transition: color 0.2s;
}

.nav-item.active {
  color: var(--tea-red);
}

.nav-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-item.active .nav-dot {
  background: var(--tea-red-light);
}

/* ==================== */
/* Tutor Session View   */
/* ==================== */

.tutor-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--tea-bg);
}

/* Session sub-header */
.session-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: var(--tea-red-dark);
  color: #fff;
  font-size: 11px;
}

.session-info .si-topic {
  opacity: 0.8;
}

.session-info .si-timer {
  font-family: var(--font-mono);
  font-size: 13px;
  opacity: 0.8;
}

/* Teaching stage — main scrollable content */
.teaching-stage {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.teaching-stage::-webkit-scrollbar {
  width: 3px;
}

.teaching-stage::-webkit-scrollbar-thumb {
  background: var(--tea-border);
  border-radius: 2px;
}

/* Tutor voice transcript */
.tutor-voice {
  width: 100%;
}

.tutor-voice .tv-label {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--tea-jp);
  margin-bottom: 6px;
}

.tutor-voice .tv-text {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 400;
  color: var(--tea-ink);
  line-height: 1.6;
}

/* Your transcript */
.your-voice {
  width: 100%;
}

.your-voice .yv-label {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--tea-jp);
  margin-bottom: 6px;
  text-align: right;
}

.your-voice .yv-text {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 500;
  color: var(--tea-ink);
  line-height: 1.6;
  text-align: right;
}

/* Hero character card */
.char-stage {
  width: 100%;
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  border-radius: 16px;
  padding: 28px 20px 24px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.char-stage .cs-char {
  font-family: var(--font-chinese);
  font-size: 72px;
  font-weight: 900;
  color: var(--tea-ink);
  line-height: 1;
  margin-bottom: 8px;
}

.char-stage .cs-jyutping {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--tea-red);
  margin-bottom: 4px;
}

.char-stage .cs-english {
  font-size: 14px;
  color: var(--tea-mid);
}

.char-stage .cs-play {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  background: var(--tea-red-light);
  border: none;
  border-radius: 20px;
  padding: 6px 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--tea-red);
  cursor: pointer;
  letter-spacing: 0.5px;
}

/* Teaching note / correction card */
.teaching-note {
  width: 100%;
  background: #fef8f0;
  border: 1px solid #f0dcc4;
  border-left: 4px solid var(--tea-amber);
  border-radius: 0 10px 10px 0;
  padding: 14px 16px;
}

.teaching-note .tn-label {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--tea-amber);
  margin-bottom: 6px;
}

.teaching-note .tn-body {
  font-size: 14px;
  color: var(--tea-ink);
  line-height: 1.6;
}

.teaching-note .wrong {
  text-decoration: line-through;
  color: var(--tea-red);
}

.teaching-note .right {
  color: var(--tea-green);
  font-weight: 600;
}

/* Example sentence card */
.example-card {
  width: 100%;
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  border-radius: 12px;
  padding: 14px 16px;
}

.example-card .ec-cn {
  font-family: var(--font-chinese);
  font-size: 18px;
  font-weight: 700;
  color: var(--tea-ink);
  margin-bottom: 4px;
  line-height: 1.5;
}

.example-card .ec-cn .highlight {
  color: var(--tea-red);
  text-decoration: underline;
  text-decoration-color: var(--tea-red-light);
  text-underline-offset: 4px;
}

.example-card .ec-jp {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--tea-jp);
  margin-bottom: 4px;
  line-height: 1.5;
}

.example-card .ec-en {
  font-size: 13px;
  color: var(--tea-mid);
  font-style: italic;
}

/* System message */
.msg-system {
  text-align: center;
  color: var(--tea-jp);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 8px;
}

/* ==================== */
/* Voice Bar            */
/* ==================== */

.voice-bar {
  padding: 12px 20px 16px;
  background: var(--tea-bg);
  border-top: 1px solid var(--tea-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.vb-status {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--tea-jp);
  height: 14px;
}

.vb-status.active {
  color: var(--tea-red);
}

.vb-controls {
  display: flex;
  align-items: center;
  gap: 20px;
}

.vb-mic {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--tea-red);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(201, 74, 58, 0.3);
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

.vb-mic:hover {
  box-shadow: 0 4px 24px rgba(201, 74, 58, 0.4);
  transform: scale(1.03);
}

.vb-mic.listening {
  background: var(--tea-ink);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.vb-mic.thinking {
  background: var(--tea-amber);
  box-shadow: 0 4px 16px rgba(184, 134, 42, 0.3);
}

.vb-mic.speaking {
  background: var(--tea-green);
  box-shadow: 0 4px 16px rgba(74, 138, 74, 0.3);
}

.pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--tea-red);
  opacity: 0;
  pointer-events: none;
}

.vb-mic.listening .pulse-ring {
  border-color: var(--tea-ink);
  opacity: 0.3;
  animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.3; }
  100% { transform: scale(1.5); opacity: 0; }
}

.vb-side-btn {
  width: auto;
  min-width: 48px;
  padding: 6px 8px;
  border-radius: 10px;
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  color: var(--tea-mid);
  transition: all 0.2s;
}

.vb-side-btn:hover {
  background: var(--tea-light);
}

.vb-btn-label {
  font-family: var(--font-mono);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--tea-jp);
}

/* Type-instead toggle */
.text-toggle {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--tea-jp);
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.text-toggle:hover {
  color: var(--tea-red);
}

/* Waveform animation */
.live-waveform {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 48px;
}

.live-waveform .lw-bar {
  width: 4px;
  background: var(--tea-red);
  border-radius: 2px;
  opacity: 0.7;
  animation: listenBounce 0.6s ease-in-out infinite alternate;
}

.live-waveform .lw-bar:nth-child(1) { animation-delay: 0s; height: 12px; }
.live-waveform .lw-bar:nth-child(2) { animation-delay: 0.08s; height: 20px; }
.live-waveform .lw-bar:nth-child(3) { animation-delay: 0.16s; height: 32px; }
.live-waveform .lw-bar:nth-child(4) { animation-delay: 0.24s; height: 44px; }
.live-waveform .lw-bar:nth-child(5) { animation-delay: 0.32s; height: 36px; }
.live-waveform .lw-bar:nth-child(6) { animation-delay: 0.24s; height: 44px; }
.live-waveform .lw-bar:nth-child(7) { animation-delay: 0.16s; height: 32px; }
.live-waveform .lw-bar:nth-child(8) { animation-delay: 0.08s; height: 20px; }
.live-waveform .lw-bar:nth-child(9) { animation-delay: 0s; height: 12px; }

@keyframes listenBounce {
  0% { height: 6px; }
  100% { height: var(--bar-height, 20px); }
}

/* Text input fallback */
.text-input-row {
  display: flex;
  width: 100%;
  gap: 8px;
}

.text-input {
  flex: 1;
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  border-radius: 24px;
  padding: 10px 16px;
  color: var(--tea-ink);
  font-size: 14px;
  outline: none;
  font-family: var(--font-body);
  transition: border-color 0.2s;
}

.text-input:focus {
  border-color: var(--tea-red-light);
}

.text-input::placeholder {
  color: var(--tea-jp);
}

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--tea-red);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s;
}

.send-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

/* Welcome screen */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  flex: 1;
  gap: 28px;
}

.welcome-greeting {}

.welcome-title {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 600;
  color: var(--tea-ink);
  margin-bottom: 6px;
}

.welcome-subtitle {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--tea-jp);
  letter-spacing: 1px;
}

.welcome-stats {
  display: flex;
  gap: 16px;
}

.welcome-stat {
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  border-radius: 12px;
  padding: 14px 18px;
  text-align: center;
}

.ws-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--tea-ink);
}

.ws-label {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--tea-jp);
  margin-top: 2px;
}

.start-btn {
  background: var(--tea-red);
  color: #fff;
  border: none;
  border-radius: 32px;
  padding: 16px 48px;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(201, 74, 58, 0.3);
  transition: all 0.2s;
}

.start-btn:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 24px rgba(201, 74, 58, 0.4);
}

/* Session start card */
.session-start-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 20px;
  flex: 1;
}

.ssc-title {
  font-family: var(--font-chinese);
  font-size: 28px;
  font-weight: 900;
  color: var(--tea-ink);
  margin-bottom: 4px;
}

.ssc-level {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--tea-jp);
  letter-spacing: 1px;
  margin-bottom: 32px;
}

.ssc-btn {
  background: var(--tea-red);
  color: #fff;
  border: none;
  border-radius: 32px;
  padding: 16px 48px;
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(201, 74, 58, 0.3);
  transition: all 0.2s;
}

.ssc-btn:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 24px rgba(201, 74, 58, 0.4);
}

/* Typing indicator */
.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tea-jp);
  animation: typing 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Jyutping rendering */
ruby {
  font-family: var(--font-chinese);
}

ruby rt {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--tea-red);
  font-weight: 400;
}

.jyutping-inline {
  font-family: var(--font-mono);
  color: var(--tea-red);
  font-size: 0.9em;
}

.hide-jyutping rt {
  display: none;
}

/* ==================== */
/* Homework View        */
/* ==================== */

.hw-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--tea-bg);
}

.hw-tabs {
  display: flex;
  background: var(--tea-red-dark);
  padding: 0 16px;
}

.hw-tab {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 0.2s;
}

.hw-tab.active {
  color: #fff;
  border-bottom-color: #fff;
}

.hw-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hw-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 8px;
  color: var(--tea-jp);
}

.hw-empty-icon { font-size: 40px; opacity: 0.4; }
.hw-empty-hint { font-size: 12px; opacity: 0.6; }

/* Homework Card */
.hw-card {
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  border-radius: 12px;
  overflow: hidden;
}

.hw-card-header {
  display: flex;
  align-items: center;
  padding: 16px;
  cursor: pointer;
  gap: 12px;
  transition: background 0.2s;
}

.hw-card-header:hover {
  background: rgba(0,0,0,0.01);
}

.hw-card-info {
  flex: 1;
}

.hw-card-type {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--tea-jp);
  margin-bottom: 4px;
}

.hw-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--tea-ink);
  margin-bottom: 3px;
}

.hw-card-desc {
  font-size: 13px;
  color: var(--tea-mid);
  line-height: 1.5;
}

.hw-card-due {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--tea-jp);
  margin-top: 4px;
}

.hw-card-chevron {
  transition: transform 0.2s;
  color: var(--tea-jp);
  flex-shrink: 0;
}

.hw-card.expanded .hw-card-chevron {
  transform: rotate(180deg);
}

.hw-card-body {
  display: none;
  padding: 0 16px 16px;
}

.hw-card.expanded .hw-card-body {
  display: block;
}

/* Grade badge */
.hwc-grade {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hwc-grade.grade-a { background: #e8f5e0; color: #3a7d2a; }
.hwc-grade.grade-b { background: #fff4d6; color: #8a6d20; }
.hwc-grade.grade-c { background: #fef0e0; color: var(--tea-red); }
.hwc-grade.grade-d { background: #fde8e0; color: var(--tea-red); }
.hwc-grade.grade-f { background: #fde0e0; color: #a82020; }
.hwc-grade.pending { background: var(--tea-light); color: var(--tea-jp); font-size: 16px; }

/* Task items */
.hw-tasks {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hw-task {
  border-left: 3px solid var(--tea-border);
  padding-left: 12px;
}

.hw-task-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.hw-task-type {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--tea-jp);
}

.hw-task-instructions {
  font-size: 14px;
  color: var(--tea-mid);
  line-height: 1.5;
  margin-bottom: 8px;
}

.hw-task-input {
  width: 100%;
  min-height: 80px;
  background: var(--tea-bg);
  border: 1px solid var(--tea-border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--tea-ink);
  font-size: 14px;
  font-family: var(--font-body);
  resize: vertical;
  outline: none;
}

.hw-task-input:focus {
  border-color: var(--tea-red-light);
}

.hw-task-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.hw-photo-btn {
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--tea-mid);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}

.hw-photo-preview {
  margin-bottom: 8px;
  position: relative;
  display: inline-block;
}

.hw-photo-preview img {
  max-width: 200px;
  max-height: 150px;
  border-radius: 8px;
  border: 1px solid var(--tea-border);
}

.hw-photo-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--tea-red);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
}

.hw-submit-btn {
  display: block;
  width: 100%;
  padding: 12px;
  margin-top: 16px;
  border: none;
  border-radius: 10px;
  background: var(--tea-red);
  color: white;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
}

/* Feedback */
.hw-task-feedback {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--tea-bg);
  border-radius: 8px;
}

.hw-task-score { font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.hw-task-correct { color: var(--tea-green); font-size: 13px; }
.hw-error-what { color: var(--tea-red); }
.hw-error-correction { color: var(--tea-green); font-weight: 500; }
.hw-error-explanation { color: var(--tea-jp); font-size: 12px; }

/* Rubric */
.hw-rubric {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--tea-border);
}

.hw-rubric-title {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--tea-jp);
  margin-bottom: 10px;
}

.hw-rubric-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.hw-rubric-label {
  font-size: 12px;
  color: var(--tea-mid);
  width: 140px;
  flex-shrink: 0;
}

.hw-rubric-bar {
  flex: 1;
  height: 6px;
  background: var(--tea-light);
  border-radius: 3px;
  overflow: hidden;
}

.hw-rubric-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.hw-rubric-fill.grade-a { background: var(--tea-green); }
.hw-rubric-fill.grade-b { background: var(--tea-amber); }
.hw-rubric-fill.grade-c { background: var(--tea-red); }

.hw-rubric-val {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--tea-jp);
  width: 28px;
  text-align: right;
}

.hw-summary {
  margin-top: 12px;
  padding: 12px;
  background: var(--tea-bg);
  border-radius: 8px;
  font-size: 13px;
  color: var(--tea-mid);
  line-height: 1.6;
}

/* ==================== */
/* Progress View        */
/* ==================== */

.progress-container {
  height: 100%;
  overflow: hidden;
  background: var(--tea-bg);
}

.progress-scroll {
  height: 100%;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Stats row */
.stat-row {
  display: flex;
  gap: 10px;
}

.stat-card {
  flex: 1;
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}

.stat-card .sc-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--tea-ink);
  margin-bottom: 2px;
}

.stat-card .sc-value.red { color: var(--tea-red); }

.stat-card .sc-label {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--tea-jp);
}

/* Tone chart — vertical bars */
.tone-chart {
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  border-radius: 12px;
  padding: 16px;
}

.tone-chart .tc-title {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--tea-jp);
  margin-bottom: 14px;
}

.tone-bars-vertical {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  height: 100px;
}

.tone-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.tone-col .tb-fill {
  width: 100%;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.5s ease;
}

.tone-col .tb-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--tea-mid);
}

.tone-col .tb-pct {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--tea-jp);
}

/* Grade history */
.grade-history {
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  border-radius: 12px;
  padding: 16px;
}

.grade-history .gh-title {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--tea-jp);
  margin-bottom: 12px;
}

.grade-row {
  display: flex;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--tea-light);
  gap: 10px;
}

.grade-row:last-child { border-bottom: none; }

.grade-row .gr-grade {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  width: 28px;
  text-align: center;
}

.grade-row .gr-grade.a { color: var(--tea-green); }
.grade-row .gr-grade.b { color: var(--tea-amber); }
.grade-row .gr-grade.c { color: var(--tea-red); }

.grade-row .gr-info { flex: 1; }

.grade-row .gr-name {
  font-size: 13px;
  color: var(--tea-ink);
  font-weight: 500;
}

.grade-row .gr-date {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--tea-jp);
}

.grade-row .gr-pct {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--tea-mid);
}

/* Weak areas */
.weak-areas {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.weak-tag {
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--tea-red-light);
  color: var(--tea-red);
  font-size: 12px;
}

/* Session list */
.session-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.session-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  border-radius: 8px;
  gap: 12px;
}

.session-item-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--tea-jp);
  flex-shrink: 0;
}

.session-item-topics {
  flex: 1;
  font-size: 13px;
  color: var(--tea-mid);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-item-duration {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--tea-jp);
  flex-shrink: 0;
}

.progress-section {
  margin-bottom: 4px;
}

.progress-section h3 {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--tea-jp);
  margin-bottom: 12px;
}

/* ==================== */
/* Placeholder Views    */
/* ==================== */

.placeholder-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--tea-jp);
}

.placeholder-view .placeholder-icon { font-size: 48px; opacity: 0.4; }
.placeholder-view p { font-size: 14px; }

/* ==================== */
/* Writing Studio       */
/* ==================== */

.writing-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--tea-bg);
}

.writing-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.wr-level-bar {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 16px;
}

.wr-level-label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--tea-red);
}

.wr-level-desc {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--tea-jp);
}

/* Character selection grid */
.wr-char-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.wr-char-tile {
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-body);
}

.wr-char-tile:hover {
  border-color: var(--tea-red-light);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.wct-char {
  font-family: var(--font-chinese);
  font-size: 32px;
  font-weight: 900;
  color: var(--tea-ink);
  line-height: 1.1;
  margin-bottom: 4px;
}

.wct-jp {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--tea-red);
  margin-bottom: 6px;
}

.wct-bar {
  height: 3px;
  background: var(--tea-light);
  border-radius: 2px;
  overflow: hidden;
}

.wct-bar-fill {
  height: 100%;
  background: var(--tea-green);
  border-radius: 2px;
  transition: width 0.3s;
}

/* Back button */
.wr-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--tea-mid);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 16px;
  padding: 4px 0;
}

.wr-back:hover { color: var(--tea-red); }

/* Target character display */
.wr-target {
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  border-radius: 14px;
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 16px;
}

.wr-target .wrt-char {
  font-family: var(--font-chinese);
  font-size: 80px;
  font-weight: 900;
  color: var(--tea-ink);
  line-height: 1;
  margin-bottom: 6px;
}

.wr-target .wrt-jp {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--tea-red);
  margin-bottom: 2px;
}

.wr-target .wrt-en {
  font-size: 14px;
  color: var(--tea-mid);
}

/* Metadata chips */
.wr-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.wr-chip {
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--tea-mid);
}

.wr-chip strong {
  color: var(--tea-red);
  font-weight: 600;
}

/* Mi zi ge grid */
.mi-grid {
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  border-radius: 10px;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 16px;
}

.mi-cell {
  aspect-ratio: 1;
  border: 1px solid var(--tea-light);
  border-radius: 2px;
  position: relative;
  background: #fdfcfa;
}

.mi-cell::before,
.mi-cell::after {
  content: '';
  position: absolute;
  background: #f0e8dc;
}

.mi-cell::before {
  width: 100%;
  height: 1px;
  top: 50%;
}

.mi-cell::after {
  width: 1px;
  height: 100%;
  left: 50%;
}

.mi-cell.guide .guide-char {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-chinese);
  font-size: 40px;
  font-weight: 700;
  color: #e8ddd0;
}

/* Action buttons */
.wr-actions {
  display: flex;
  gap: 8px;
}

.wr-btn {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: none;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.wr-btn.primary {
  background: var(--tea-red);
  color: #fff;
}

.wr-btn.secondary {
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  color: var(--tea-ink);
}

/* Evaluation results */
.wr-eval-result {
  margin-top: 20px;
}

.wr-eval-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--tea-jp);
  font-size: 13px;
  padding: 12px;
}

.wr-eval-preview {
  margin-bottom: 12px;
}

.wr-eval-preview img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 10px;
  border: 1px solid var(--tea-border);
}

.wr-eval-score {
  text-align: center;
  margin-bottom: 12px;
}

.wr-eval-score-num {
  font-family: var(--font-mono);
  font-size: 48px;
  font-weight: 700;
}

.wr-eval-score-label {
  font-family: var(--font-mono);
  font-size: 18px;
  opacity: 0.5;
}

.wr-eval-details {
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  border-radius: 12px;
  padding: 16px;
}

.wr-eval-item {
  font-size: 14px;
  color: var(--tea-ink);
  line-height: 1.6;
  padding: 6px 0;
  border-bottom: 1px solid var(--tea-light);
}

.wr-eval-item:last-child { border-bottom: none; }

.wr-eval-item strong {
  color: var(--tea-mid);
  font-weight: 600;
}

.wr-eval-feedback {
  color: var(--tea-mid);
  font-style: italic;
}

.wr-eval-next {
  color: var(--tea-red);
}

/* ==================== */
/* Pronunciation Lab    */
/* ==================== */

.pron-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--tea-bg);
}

.pron-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.pron-section-label {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--tea-jp);
  margin-bottom: 10px;
  margin-top: 8px;
}

/* Tone reference grid */
.tone-ref-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.tone-ref-card {
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  border-radius: 12px;
  padding: 12px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-body);
}

.tone-ref-card:hover {
  border-color: var(--tea-red-light);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.trc-num {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--tea-red);
  margin-bottom: 2px;
}

.trc-contour {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--tea-jp);
  margin-bottom: 2px;
}

.trc-name {
  font-size: 10px;
  color: var(--tea-mid);
  margin-bottom: 6px;
}

/* Pitch contour lines */
.trc-pitch-line {
  height: 20px;
  position: relative;
  margin: 0 8px;
}

.trc-pitch-line::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--tea-red);
  border-radius: 2px;
}

.trc-high::after { top: 0; }
.trc-rising::after { bottom: 0; transform: rotate(-15deg); transform-origin: left; }
.trc-mid::after { top: 50%; transform: translateY(-50%); }
.trc-low-fall::after { top: 60%; transform: rotate(10deg); transform-origin: left; }
.trc-low-rise::after { bottom: 30%; transform: rotate(-8deg); transform-origin: left; }
.trc-low::after { bottom: 2px; }

/* Accuracy row */
.pron-accuracy-row {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
}

.pron-acc-col {
  flex: 1;
  text-align: center;
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  border-radius: 8px;
  padding: 8px 4px;
}

.pron-acc-val {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
}

.pron-acc-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--tea-jp);
  margin-top: 2px;
}

/* Drill cards */
.pron-drill-card {
  display: block;
  width: 100%;
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  margin-bottom: 8px;
  transition: all 0.2s;
  font-family: var(--font-body);
}

.pron-drill-card:hover {
  border-color: var(--tea-red-light);
}

.pdc-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--tea-ink);
  margin-bottom: 2px;
}

.pdc-desc {
  font-size: 12px;
  color: var(--tea-mid);
}

/* Drill hero */
.pron-progress {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--tea-jp);
  text-align: center;
  margin-bottom: 16px;
}

.pron-drill-hero {
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  border-radius: 16px;
  padding: 32px 20px;
  text-align: center;
  margin-bottom: 16px;
}

.pdh-char {
  font-family: var(--font-chinese);
  font-size: 72px;
  font-weight: 900;
  color: var(--tea-ink);
  line-height: 1;
  margin-bottom: 8px;
}

.pdh-jp {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--tea-red);
  margin-bottom: 4px;
}

.pdh-en {
  font-size: 14px;
  color: var(--tea-mid);
}

/* Tone hint */
.pron-tone-hint {
  background: #fef8f0;
  border: 1px solid #f0dcc4;
  border-left: 4px solid var(--tea-amber);
  border-radius: 0 10px 10px 0;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.pth-label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--tea-amber);
  margin-bottom: 4px;
}

.pth-desc {
  font-size: 13px;
  color: var(--tea-mid);
  line-height: 1.5;
}

/* Drill actions */
.pron-drill-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.pron-drill-nav {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.pron-play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Result states */
.pron-result {
  margin-top: 12px;
}

.pron-correct {
  color: var(--tea-green);
  font-size: 14px;
  font-weight: 600;
  padding: 12px;
  background: #e8f5e0;
  border-radius: 10px;
}

.pron-wrong {
  color: var(--tea-red);
  font-size: 14px;
  font-weight: 600;
  padding: 12px;
  background: #fde8e0;
  border-radius: 10px;
}

.pron-tip {
  font-size: 13px;
  color: var(--tea-mid);
  padding: 8px 12px;
  margin-top: 8px;
  background: var(--tea-light);
  border-radius: 8px;
}

.pron-recording {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
}

/* Minimal pair choices */
.pron-pair-prompt {
  font-family: var(--font-heading);
  font-size: 16px;
  color: var(--tea-ink);
  text-align: center;
  margin-bottom: 16px;
}

.pron-pair-choices {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.pron-pair-choice {
  flex: 1;
  background: var(--tea-card);
  border: 2px solid var(--tea-border);
  border-radius: 14px;
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-body);
}

.pron-pair-choice:hover {
  border-color: var(--tea-red-light);
}

.pron-pair-choice.correct {
  border-color: var(--tea-green);
  background: #e8f5e0;
}

.pron-pair-choice.wrong {
  border-color: var(--tea-red);
  background: #fde8e0;
}

.ppc-char {
  font-family: var(--font-chinese);
  font-size: 36px;
  font-weight: 900;
  color: var(--tea-ink);
  margin-bottom: 4px;
}

.ppc-jp {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--tea-red);
  margin-bottom: 2px;
}

.ppc-en {
  font-size: 12px;
  color: var(--tea-mid);
}

/* Drill summary */
.pron-summary {
  text-align: center;
  padding: 40px 20px;
}

.pron-summary-score {
  font-family: var(--font-mono);
  font-size: 64px;
  font-weight: 700;
  margin-bottom: 4px;
}

.pron-summary-detail {
  font-size: 14px;
  color: var(--tea-mid);
  margin-bottom: 24px;
}

.pron-summary-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* ==================== */
/* Jyutping Reference   */
/* ==================== */

.jp-panel {
  position: fixed;
  top: 0;
  right: -320px;
  width: 320px;
  height: 100%;
  background: var(--tea-card);
  border-left: 1px solid var(--tea-border);
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
  z-index: 1000;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
}

.jp-panel.open {
  right: 0;
}

.jp-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--tea-border);
  background: var(--tea-red);
  color: #fff;
}

.jp-panel-header h3 {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
}

.jp-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
}

.jp-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.jp-section {
  margin-bottom: 20px;
}

.jp-section-title {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--tea-jp);
  margin-bottom: 8px;
}

.jp-tone-table {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.jp-tone-row {
  display: grid;
  grid-template-columns: 24px 90px 30px 1fr;
  gap: 8px;
  padding: 6px 8px;
  background: var(--tea-bg);
  border-radius: 6px;
  font-size: 12px;
  align-items: center;
}

.jp-t {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--tea-red);
}

.jp-v {
  font-family: var(--font-mono);
  color: var(--tea-jp);
}

.jp-items {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--tea-ink);
  line-height: 2;
  word-spacing: 8px;
}

/* ==================== */
/* SRS Word List        */
/* ==================== */

.srs-word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.srs-word {
  display: flex;
  align-items: baseline;
  gap: 6px;
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  border-radius: 8px;
  padding: 6px 10px;
}

.srs-char {
  font-family: var(--font-chinese);
  font-size: 16px;
  font-weight: 700;
  color: var(--tea-ink);
}

.srs-jp {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--tea-red);
}

.srs-en {
  font-size: 11px;
  color: var(--tea-mid);
}

.srs-more {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--tea-jp);
  padding: 6px 10px;
}

/* ==================== */
/* Settings Modal       */
/* ==================== */

#settings-modal {
  background: transparent;
  border: none;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  padding: 0;
}

#settings-modal::backdrop {
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--tea-card);
  border: 1px solid var(--tea-border);
  border-radius: 16px;
  padding: 24px;
  max-width: 420px;
  margin: 80px auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
}

.modal-content h2 {
  font-family: var(--font-chinese);
  font-size: 18px;
  color: var(--tea-ink);
  margin-bottom: 20px;
}

.modal-content label {
  display: block;
  margin-bottom: 16px;
}

.modal-content label span {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--tea-jp);
  margin-bottom: 6px;
}

.modal-content input,
.modal-content select {
  width: 100%;
  background: var(--tea-bg);
  border: 1px solid var(--tea-border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--tea-ink);
  font-size: 14px;
  font-family: var(--font-body);
  outline: none;
}

.modal-content input:focus,
.modal-content select:focus {
  border-color: var(--tea-red-light);
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

.modal-actions button {
  padding: 8px 20px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  cursor: pointer;
  font-family: var(--font-body);
}

.modal-actions button[type="button"] {
  background: var(--tea-light);
  color: var(--tea-mid);
}

.modal-actions button[type="submit"] {
  background: var(--tea-red);
  color: white;
}
