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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #ECEFF1;
  color: #263238;
  min-height: 100vh;
  font-size: 16px;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
}

.card {
  background: #FFFFFF;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 12px;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.7; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: #2979FF; color: #FFFFFF; }
.btn-secondary { background: #ECEFF1; color: #263238; }
.btn-danger { background: #E53935; color: #FFFFFF; }

.nav-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 16px;
}
.nav-back {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #2979FF;
  padding: 4px 8px;
}
.nav-title { font-size: 18px; font-weight: 500; flex: 1; }
.grade-badge {
  text-align: center;
  color: #1565C0;
  font-size: 14px;
  font-weight: 600;
  margin: -8px 0 16px;
  letter-spacing: 0.08em;
}

.label { font-size: 13px; color: #78909C; margin-bottom: 6px; }
.title { font-size: 18px; font-weight: 500; margin-bottom: 4px; }
.sub { font-size: 14px; color: #546E7A; }
.hint { font-size: 13px; color: #78909C; margin-top: 8px; }
.hint.warn { color: #E53935; }

/* Index */
.subject-toggle {
  display: flex;
  background: #FFFFFF;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 16px;
}
.subject-toggle button {
  flex: 1;
  padding: 10px;
  border: none;
  background: none;
  font-size: 15px;
  color: #78909C;
  cursor: pointer;
  border-radius: 10px;
}
.subject-toggle button.active {
  background: #2979FF;
  color: #FFFFFF;
  font-weight: 500;
}

.streak-card {
  background: linear-gradient(135deg, #FF7043, #FF5722);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  color: #FFFFFF;
  margin-bottom: 16px;
}
.streak-num { font-size: 40px; font-weight: 600; line-height: 1; }
.streak-label { font-size: 14px; margin-top: 8px; opacity: 0.9; }
.today-line { font-size: 13px; margin-top: 10px; opacity: 0.85; }

/* Lesson list */
.tabs {
  display: flex;
  background: #FFFFFF;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}
.tab {
  flex: 1;
  text-align: center;
  padding: 12px 0;
  font-size: 15px;
  color: #78909C;
  cursor: pointer;
}
.tab.active {
  color: #2979FF;
  font-weight: 500;
  border-bottom: 2px solid #2979FF;
}

.lesson-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: #FFFFFF;
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
}
.lesson-item:active { background: #F5F5F5; }
.lesson-name { font-size: 15px; color: #263238; }
.lesson-count {
  font-size: 13px;
  color: #2979FF;
  background: #E3F2FD;
  padding: 2px 10px;
  border-radius: 10px;
}

textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  border: 1px solid #CFD8DC;
  border-radius: 8px;
  font-size: 15px;
  resize: vertical;
  font-family: inherit;
}

/* Mode overlay */
.modal-mask {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}
.modal-sheet {
  width: 100%;
  max-width: 640px;
  background: #FFFFFF;
  border-radius: 16px 16px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
.modal-title {
  font-size: 18px;
  font-weight: 500;
  text-align: center;
  margin-bottom: 16px;
}

/* Dictation */
.progress-bar {
  background: #ECEFF1;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-fill {
  background: #2979FF;
  height: 100%;
  transition: width 0.3s;
}
.progress-text {
  text-align: right;
  font-size: 14px;
  color: #546E7A;
}

.status-box {
  background: #FFFFFF;
  border-radius: 12px;
  padding: 40px 16px;
  text-align: center;
  margin-bottom: 16px;
}
.status { font-size: 20px; font-weight: 500; color: #2979FF; }
.countdown { font-size: 14px; color: #78909C; margin-top: 10px; min-height: 20px; }

.speed-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.speed-row.center { justify-content: center; }
.speed-chip {
  padding: 8px 18px;
  background: #ECEFF1;
  border-radius: 16px;
  font-size: 14px;
  color: #546E7A;
  cursor: pointer;
}
.speed-chip.small { padding: 6px 14px; font-size: 13px; }
.speed-chip.active {
  background: #2979FF;
  color: #FFFFFF;
  font-weight: 500;
}

.controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.ctl-btn {
  flex: 1;
  padding: 14px 0;
  border-radius: 10px;
  background: #ECEFF1;
  color: #263238;
  font-size: 14px;
  border: none;
  cursor: pointer;
}
.ctl-btn.primary { background: #2979FF; color: #FFFFFF; }
.ctl-btn:disabled { opacity: 0.4; }

/* Spelling */
.word-box {
  background: #FFFFFF;
  border-radius: 12px;
  padding: 24px 16px;
  text-align: center;
  margin-bottom: 12px;
}
.meaning {
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 16px;
}
.slots {
  font-size: 28px;
  font-family: Menlo, Consolas, monospace;
  color: #2979FF;
  letter-spacing: 6px;
  margin-bottom: 10px;
  min-height: 38px;
}
.hint-msg {
  font-size: 14px;
  min-height: 20px;
  margin-bottom: 10px;
}
.hint-msg.err { color: #E53935; }
.hint-msg.ok { color: #43A047; }
.play-btn {
  background: #ECEFF1;
  color: #2979FF;
  font-size: 13px;
  border: none;
  padding: 8px 20px;
  border-radius: 16px;
  cursor: pointer;
}

.keyboard {
  background: #FFFFFF;
  border-radius: 12px;
  padding: 8px;
  margin-bottom: 16px;
}
.kb-row {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
  justify-content: center;
}
.kb-row:last-child { margin-bottom: 0; }
.kb-key {
  flex: 1;
  background: #ECEFF1;
  color: #263238;
  text-align: center;
  padding: 20px 0;
  border-radius: 8px;
  font-size: 24px;
  font-weight: 600;
  font-family: Menlo, Consolas, monospace;
  cursor: pointer;
  user-select: none;
}
.kb-key:active { background: #CFD8DC; }
.kb-key.hyphen { flex: 2; background: #FFB74D; color: #FFFFFF; font-size: 16px; font-weight: 600; }
.kb-key.wide { flex: 3; background: #546E7A; color: #FFFFFF; font-size: 16px; }
.kb-key.del { flex: 2; background: #E57373; color: #FFFFFF; font-size: 16px; }

.preview-list { max-height: 280px; overflow-y: auto; }
.preview-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #ECEFF1;
}
.pv-word { font-size: 15px; color: #263238; font-weight: 500; }
.pv-meaning { font-size: 13px; color: #78909C; }

/* Result */
.hero {
  background: #FFFFFF;
  border-radius: 12px;
  padding: 28px 16px;
  text-align: center;
  margin-bottom: 16px;
}
.hero.success { background: #E8F5E9; }
.hero .big { font-size: 56px; line-height: 1; margin-bottom: 10px; }
.hero .t { font-size: 22px; font-weight: 500; margin-bottom: 4px; }
.hero .s { font-size: 13px; color: #78909C; margin-top: 2px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.stat {
  background: #FFFFFF;
  padding: 14px 4px;
  border-radius: 10px;
  text-align: center;
}
.stat-num { font-size: 22px; font-weight: 600; }
.stat-label { font-size: 12px; color: #78909C; margin-top: 2px; }
.stat.ok .stat-num { color: #43A047; }
.stat.err .stat-num { color: #E53935; }
.stat.hi .stat-num { color: #2979FF; }

.word-chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.word-chip {
  background: #ECEFF1;
  color: #263238;
  padding: 4px 12px;
  border-radius: 14px;
  font-size: 14px;
}

.wrong-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #ECEFF1;
}
.wrong-item:last-child { border-bottom: none; }
.ww-word { font-size: 15px; color: #E53935; font-weight: 500; }
.ww-meaning { font-size: 13px; color: #78909C; }

/* Progress */
.month-label {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 10px;
  text-align: center;
}
.cal-header, .cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-dow {
  text-align: center;
  font-size: 12px;
  color: #78909C;
  padding: 4px 0;
}
.cal-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  border-radius: 6px;
  background: #F5F5F5;
}
.cal-cell.blank { background: transparent; }
.cal-cell.active { background: #FFCCBC; color: #E64A19; font-weight: 500; }
.cal-cell.today { border: 2px solid #2979FF; }

.lesson-row { padding: 14px 16px; }
.lesson-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.lesson-title { font-size: 15px; font-weight: 500; }
.lesson-subject {
  font-size: 11px;
  color: #2979FF;
  background: #E3F2FD;
  padding: 2px 8px;
  border-radius: 8px;
}
.lesson-stats { display: flex; gap: 12px; font-size: 13px; color: #546E7A; }

.weak-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #ECEFF1;
}
.weak-item:last-child { border-bottom: none; }
.weak-word { font-size: 15px; font-weight: 500; }
.weak-count { font-size: 13px; color: #E53935; }

.empty {
  text-align: center;
  color: #78909C;
  font-size: 14px;
  padding: 24px 0;
}
