/* =========================================================
   轻英语 · AI English Coach
   Mobile-first styles  ·  soft warm palette, low anxiety
   ========================================================= */

:root {
  --bg: #FAF9F6;
  --surface: #FFFFFF;
  --surface-soft: #F3F1EB;
  --ink: #2A312D;
  --ink-soft: #5A635D;
  --ink-faint: #8A938C;
  --sage: #6E8F79;
  --sage-deep: #4F7159;
  --sage-tint: #E7EFE8;
  --blue: #8FB3C9;
  --blue-tint: #E8F1F6;
  --amber: #E8B87F;
  --amber-tint: #FBF0E2;
  --danger: #C4695E;
  --danger-tint: #FAEAE7;
  --line: #E7E3DA;
  --shadow: 0 2px 8px rgba(42, 49, 45, .05), 0 12px 28px rgba(42, 49, 45, .05);
  --shadow-lift: 0 6px 18px rgba(42, 49, 45, .09), 0 20px 40px rgba(42, 49, 45, .06);
  --radius: 20px;
  --radius-sm: 14px;
  --tap: 46px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", Roboto, "Helvetica Neue", sans-serif;
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  overscroll-behavior-y: none;
}

body.no-scroll { overflow: hidden; }

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

button {
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}

h1, h2, h3, p, ol, ul { margin: 0; }

svg { width: 22px; height: 22px; fill: currentColor; }

.muted { color: var(--ink-soft); }
.tiny { font-size: 13px; line-height: 1.5; }
[hidden] { display: none !important; }

/* ---------------- Layout shell ---------------- */
.app-shell {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

@media (min-width: 640px) {
  body { background: #F1EFE9; }
  .app-shell {
    box-shadow: 0 0 0 1px rgba(42, 49, 45, .05), 0 30px 70px rgba(42, 49, 45, .08);
  }
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px 12px;
  background: rgba(250, 249, 246, .88);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid rgba(231, 227, 218, .7);
}

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

.brand-logo {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: linear-gradient(140deg, var(--sage) 0%, var(--sage-deep) 100%);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .5px;
  box-shadow: 0 4px 10px rgba(79, 113, 89, .28);
}

.brand h1 { font-size: 18px; font-weight: 700; letter-spacing: .3px; }
.brand-sub { font-size: 11px; color: var(--ink-faint); letter-spacing: 1.1px; text-transform: uppercase; }

.streak-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--amber-tint);
  color: #9A6A2C;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.streak-pill svg { width: 15px; height: 15px; }

main {
  flex: 1;
  padding: 18px 16px calc(var(--nav-h) + var(--safe-b) + 26px);
}

.view { display: none; animation: fade-up .28s ease both; }
.view.is-active { display: block; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.view-head { margin-bottom: 14px; }
.view-head h2 { font-size: 23px; font-weight: 700; letter-spacing: .2px; }
.view-head .muted { font-size: 13.5px; margin-top: 2px; }

/* ---------------- Cards ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.card-head h3 { font-size: 15.5px; font-weight: 650; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
  transition: transform .15s ease, background .15s ease, opacity .15s ease;
  border: 1px solid transparent;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.primary {
  background: linear-gradient(140deg, var(--sage) 0%, var(--sage-deep) 100%);
  color: #fff;
  box-shadow: 0 6px 16px rgba(79, 113, 89, .24);
}
.btn.ghost { background: transparent; color: var(--sage-deep); }
.btn.ghost:active { background: var(--sage-tint); }
.btn.small { min-height: 36px; padding: 0 13px; font-size: 13px; font-weight: 600; }
.btn.block { width: 100%; }
.btn.danger { background: var(--danger-tint); color: var(--danger); }

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--ink-soft);
  font-size: 17px;
}
.icon-btn:active { background: var(--surface-soft); }

/* ---------------- Banner ---------------- */
.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--blue-tint);
  border: 1px solid #D6E6EF;
  margin-bottom: 14px;
}
.banner-icon { font-size: 20px; }
.banner-body { flex: 1; min-width: 0; }
.banner-body strong { font-size: 14px; display: block; }
.banner-body p { font-size: 12.5px; color: var(--ink-soft); }
.banner .btn.small { background: #fff; color: var(--sage-deep); }

/* ---------------- Stat card ---------------- */
.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(150deg, #FFFFFF 0%, #F6F8F4 100%);
}
.stat-main { flex: 1; min-width: 0; }
.stat-line { display: flex; align-items: baseline; gap: 6px; }
.stat-value { font-size: 34px; font-weight: 750; line-height: 1.1; color: var(--sage-deep); letter-spacing: -1px; }
.stat-total { font-size: 14px; color: var(--ink-faint); font-weight: 600; }

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: #EAE8E1;
  overflow: hidden;
  margin: 10px 0 8px;
}
.progress-track.slim { height: 4px; margin: 14px 0 0; }
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #9DBBA5 0%, var(--sage) 100%);
  transition: width .45s cubic-bezier(.4, 0, .2, 1);
}

.stat-ring {
  width: 74px; height: 74px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-content: center;
  text-align: center;
  background:
    radial-gradient(circle at center, #fff 58%, transparent 59%),
    conic-gradient(var(--blue) 0deg, var(--blue-tint) 0deg);
  border: 1px solid var(--line);
}
.stat-ring span { font-size: 19px; font-weight: 750; line-height: 1.1; color: var(--ink); }
.stat-ring small { font-size: 10.5px; color: var(--ink-faint); }

/* ---------------- Word cards ---------------- */
.word-list { display: flex; flex-direction: column; gap: 12px; }

.word-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  animation: fade-up .3s ease both;
}
.word-card.is-done { background: #FCFCFA; border-style: dashed; }
.word-card.is-done .word-main { opacity: .55; }
.word-card.is-review { border-color: #EAD9C2; background: linear-gradient(160deg, #FFFDF8 0%, #FDF7EC 100%); }

.word-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.word-main { min-width: 0; }
.word-text {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: .2px;
  line-height: 1.25;
  color: var(--ink);
  word-break: break-word;
}
.word-phonetic { font-size: 13px; color: var(--ink-faint); margin-top: 1px; }
.word-tag {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--amber-tint);
  color: #9A6A2C;
}
.word-tag.new { background: var(--sage-tint); color: var(--sage-deep); }

.word-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.reveal-btn {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 600;
}

.grade-row { display: flex; gap: 8px; flex: 1; }
.grade-btn {
  flex: 1;
  min-height: 42px;
  min-width: 62px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 650;
  border: 1px solid transparent;
  transition: transform .15s ease;
}
.grade-btn:active { transform: scale(.96); }
.grade-btn.forgot { background: var(--danger-tint); color: var(--danger); }
.grade-btn.vague { background: var(--amber-tint); color: #9A6A2C; }
.grade-btn.know { background: var(--sage-tint); color: var(--sage-deep); }
.grade-btn.is-picked { outline: 2px solid currentColor; outline-offset: -2px; }

.word-meaning {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 15px;
  color: var(--ink);
  animation: fade-up .25s ease both;
}
.word-example { margin-top: 6px; font-size: 13.5px; color: var(--ink-soft); }
.word-example b { color: var(--sage-deep); font-weight: 600; }

.speak-icon-btn {
  width: 42px; height: 42px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--blue-tint);
  color: #4E7C96;
}
.speak-icon-btn:active { transform: scale(.94); }
.speak-icon-btn svg { width: 19px; height: 19px; }
.speak-icon-btn.is-playing { background: #4E7C96; color: #fff; animation: pulse 1.2s infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(78, 124, 150, .35); }
  50% { box-shadow: 0 0 0 8px rgba(78, 124, 150, 0); }
}

/* ---------------- Story ---------------- */
.story-card { background: linear-gradient(160deg, #FFFEFB 0%, #FBF8F1 100%); }
.story-body { font-size: 16.5px; line-height: 1.85; color: var(--ink); }
.story-body b, .story-body strong { color: var(--sage-deep); font-weight: 700; }
.story-zh {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.8;
}
.story-actions { display: flex; gap: 8px; margin-top: 14px; }

/* ---------------- Topic chips ---------------- */
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 600;
  transition: all .18s ease;
}
.chip.is-active {
  background: var(--sage-deep);
  border-color: var(--sage-deep);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 113, 89, .22);
}

/* ---------------- Player ---------------- */
.player { padding: 16px; }
.player-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.player-sentence {
  font-size: 12.5px;
  color: var(--ink-soft);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.player-controls { display: flex; align-items: center; gap: 8px; }

.round-btn {
  width: var(--tap); height: var(--tap);
  flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--ink);
}
.round-btn:active { transform: scale(.94); }
.round-btn.primary {
  width: 54px; height: 54px;
  background: linear-gradient(140deg, var(--sage) 0%, var(--sage-deep) 100%);
  color: #fff;
  box-shadow: 0 6px 16px rgba(79, 113, 89, .28);
}
.round-btn svg { width: 19px; height: 19px; }
.round-btn.primary svg { width: 22px; height: 22px; }

.pill-btn {
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 650;
  white-space: nowrap;
}
.pill-btn[aria-pressed="true"] {
  background: var(--sage-tint);
  color: var(--sage-deep);
}
.pill-btn.pulse-blue { background: var(--blue-tint); color: #3E7089; }

.player-controls .pill-btn:last-child { margin-left: auto; }

/* ---------------- Passage ---------------- */
.passage-card { padding: 20px 18px; }
.passage-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.4;
}
.passage { font-size: 17.5px; line-height: 2.05; color: var(--ink); }

.sent {
  cursor: pointer;
  border-radius: 6px;
  padding: 2px 1px;
  transition: background .18s ease, color .18s ease;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.sent:active { background: var(--sage-tint); }
.sent.is-active {
  background: #FDF2D9;
  box-shadow: 0 0 0 3px #FDF2D9;
  color: #6E5418;
  font-weight: 600;
}
.sent.is-read { color: var(--ink-faint); }

.tap-hint { margin-top: 14px; }

.skeleton-line {
  display: block;
  height: 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  background: linear-gradient(90deg, #EFEDE7 25%, #F7F5F0 50%, #EFEDE7 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
.skeleton-line.short { width: 62%; }
.skeleton-line:last-child { margin-bottom: 0; }

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.tips-card { background: #FCFBF8; }
.tips-card h3 { font-size: 14.5px; margin-bottom: 8px; }
.tips { padding-left: 20px; font-size: 13.5px; color: var(--ink-soft); line-height: 1.9; }

/* ---------------- Speaking ---------------- */
.speak-intro { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

.chat-log { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }

.bubble-row { display: flex; gap: 8px; align-items: flex-end; animation: fade-up .25s ease both; }
.bubble-row.me { flex-direction: row-reverse; }

.avatar {
  width: 34px; height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 15px;
  background: var(--sage-tint);
}
.bubble {
  max-width: 78%;
  padding: 11px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.6;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  word-break: break-word;
}
.bubble-row.me .bubble {
  background: var(--sage-deep);
  border-color: var(--sage-deep);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.bubble-row.ai .bubble { border-bottom-left-radius: 6px; }
.bubble .zh { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }

.bubble-tools { display: flex; gap: 6px; margin-top: 8px; }
.tool-btn {
  font-size: 12px;
  font-weight: 600;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink-soft);
}
.tool-btn:active { background: var(--sage-tint); }

.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink-faint);
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }

@keyframes blink {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.hint-wrap { margin-bottom: 10px; }
.hint-label { font-size: 12.5px; color: var(--ink-faint); margin-bottom: 7px; }
.hint-chips { display: flex; flex-direction: column; gap: 8px; }

.hint-chip {
  text-align: left;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--blue-tint);
  border: 1px solid #DCEAF2;
  color: #2F5B71;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  animation: fade-up .25s ease both;
}
.hint-chip small { display: block; font-weight: 400; font-size: 12px; color: #6B8B9C; margin-top: 1px; }
.hint-chip:active { background: #D9E9F2; }

.composer {
  position: sticky;
  bottom: calc(var(--nav-h) + var(--safe-b) + 8px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-lift);
  z-index: 5;
}

.composer input {
  flex: 1;
  min-width: 0;
  height: 42px;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 15px;
  padding: 0 4px;
}
.composer input::placeholder { color: var(--ink-faint); }

.mic-btn, .send-btn {
  width: 42px; height: 42px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 50%;
}
.mic-btn { background: var(--blue-tint); color: #4E7C96; }
.mic-btn.is-recording { background: var(--danger); color: #fff; animation: pulse-red 1.4s infinite; }
.send-btn { background: var(--sage-deep); color: #fff; }
.send-btn[disabled] { opacity: .4; }

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(196, 105, 94, .4); }
  50% { box-shadow: 0 0 0 9px rgba(196, 105, 94, 0); }
}

/* ---------------- Tab bar ---------------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 255, 255, .93);
  backdrop-filter: saturate(1.5) blur(18px);
  -webkit-backdrop-filter: saturate(1.5) blur(18px);
  border-top: 1px solid var(--line);
  z-index: 30;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--ink-faint);
  font-size: 10.5px;
  font-weight: 600;
  min-height: 44px;
  padding-top: 4px;
  transition: color .18s ease;
}
.tab svg { width: 23px; height: 23px; opacity: .85; }
.tab.is-active { color: var(--sage-deep); }
.tab.is-active svg { opacity: 1; }

/* ---------------- Sheets ---------------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(33, 38, 34, .38);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 40;
  animation: fade-in .2s ease both;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  z-index: 41;
  box-shadow: 0 -10px 40px rgba(33, 38, 34, .18);
  animation: slide-up .3s cubic-bezier(.32, .72, 0, 1) both;
  padding-bottom: var(--safe-b);
}

@keyframes slide-up {
  from { transform: translate(-50%, 100%); }
  to { transform: translate(-50%, 0); }
}

.sheet-handle {
  width: 40px; height: 4px;
  border-radius: 999px;
  background: #DCD8CE;
  margin: 9px auto 0;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px 6px;
}
.sheet-head h2 { font-size: 18px; font-weight: 700; }

.sheet-body {
  padding: 6px 18px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.sheet-foot {
  padding: 12px 18px calc(14px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: var(--surface);
}

/* ---------------- Form fields ---------------- */
.field { margin-bottom: 20px; }
.field > label {
  display: block;
  font-size: 13.5px;
  font-weight: 650;
  color: var(--ink);
  margin-bottom: 7px;
}
.field > label b { color: var(--sage-deep); }

.field input[type="text"],
.field input[type="password"],
.field input[type="url"] {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  outline: none;
  font-size: 15px;
  transition: border-color .18s ease, background .18s ease;
}
.field input:focus {
  border-color: var(--sage);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(110, 143, 121, .12);
}

.input-row { display: flex; gap: 8px; align-items: center; }
.input-row input { flex: 1; }

.field-hint { font-size: 12px; color: var(--ink-faint); margin-top: 6px; line-height: 1.5; }

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 30px;
  background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: #E9E6DE;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px; height: 26px;
  margin-top: -10px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--sage);
  box-shadow: 0 2px 6px rgba(42, 49, 45, .18);
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 999px; background: #E9E6DE; }
input[type="range"]::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%;
  background: #fff; border: 2px solid var(--sage);
}

.segmented {
  display: flex;
  gap: 6px;
  background: var(--surface-soft);
  padding: 4px;
  border-radius: 14px;
}
.segmented label {
  flex: 1;
  position: relative;
  display: block;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  border-radius: 10px;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 9px 4px; border-radius: 10px; }
.segmented input:checked + span {
  background: #fff;
  color: var(--sage-deep);
  box-shadow: 0 2px 6px rgba(42, 49, 45, .09);
}
.segmented input:focus-visible + span { box-shadow: 0 0 0 3px rgba(110, 143, 121, .25); }

.switch-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  font-weight: 500 !important;
  min-height: 44px;
}
.switch-row input { width: 20px; height: 20px; accent-color: var(--sage-deep); }

.advanced {
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 20px;
}
.advanced summary {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--ink-soft);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.advanced summary::after { content: "＋"; color: var(--ink-faint); }
.advanced[open] summary::after { content: "－"; }
.advanced .field { margin: 14px 0 0; }

.data-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.version {
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-faint);
  margin: 8px 0 4px;
}

/* ---------------- Explain sheet ---------------- */
.sheet-tall { max-height: 84vh; max-height: 84dvh; }

.explain-source {
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--ink);
  padding: 12px 14px;
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--sage);
  margin-bottom: 16px;
}

.explain-body { font-size: 15px; line-height: 1.8; color: var(--ink); }
.explain-body .block { margin-bottom: 16px; animation: fade-up .25s ease both; }
.explain-body .block h4 {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--sage-deep);
  background: var(--sage-tint);
  padding: 3px 10px;
  border-radius: 999px;
  margin: 0 0 8px;
}
.explain-body .block p { margin-bottom: 6px; }
.explain-body .block b { color: var(--sage-deep); }
.explain-body .block .en { color: var(--ink-soft); font-size: 14px; }
.explain-caret {
  display: inline-block;
  width: 7px;
  height: 15px;
  background: var(--sage);
  border-radius: 2px;
  vertical-align: -2px;
  animation: caret 1s steps(2) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

/* ---------------- Toast ---------------- */
.toast-wrap {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--safe-b) + 18px);
  width: min(92%, 420px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(42, 49, 45, .94);
  color: #fff;
  font-size: 13.5px;
  line-height: 1.5;
  box-shadow: 0 10px 30px rgba(42, 49, 45, .25);
  animation: toast-in .28s cubic-bezier(.32, .72, 0, 1) both;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.toast.error { background: rgba(150, 62, 52, .96); }
.toast.ok { background: rgba(63, 98, 74, .96); }
.toast.out { animation: toast-out .25s ease forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(10px) scale(.98); }
}

/* ---------------- Misc ---------------- */
.empty-state {
  text-align: center;
  padding: 26px 16px;
  color: var(--ink-soft);
  font-size: 13.5px;
}

.loading-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 4px;
  color: var(--ink-soft);
  font-size: 13.5px;
}
.spinner {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--sage-tint);
  border-top-color: var(--sage);
  animation: spin .8s linear infinite;
  flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}


/* 抽屉打开时，提示条移到顶部，避免遮住表单 */
body.no-scroll .toast-wrap {
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  bottom: auto;
}

/* ---------------- 小屏适配（iPhone SE 等 320–360px） ---------------- */
@media (max-width: 360px) {
  main { padding-left: 12px; padding-right: 12px; }
  .view-head h2 { font-size: 21px; }

  .card { padding: 15px; }
  .stat-card { gap: 10px; }
  .stat-value { font-size: 30px; }
  .stat-ring { width: 64px; height: 64px; }

  .player { padding: 14px 12px; }
  .player-controls { gap: 6px; }
  .round-btn { width: 40px; height: 40px; }
  .round-btn.primary { width: 48px; height: 48px; }
  .pill-btn { height: 32px; padding: 0 9px; font-size: 11.5px; }

  .word-text { font-size: 22px; }
  .passage { font-size: 16.5px; }
  .bubble { max-width: 84%; }
}

/* =========================================================
   账号：登录 / 注册
   ========================================================= */

body.auth-mode .app-shell { display: none; }
body.auth-mode { background: var(--bg); }

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(env(safe-area-inset-top, 0px) + 8vh) 18px calc(env(safe-area-inset-bottom, 0px) + 32px);
  background:
    radial-gradient(1200px 500px at 15% -10%, #E8F0E9 0%, rgba(232, 240, 233, 0) 60%),
    radial-gradient(900px 460px at 110% 10%, #E6EFF5 0%, rgba(230, 239, 245, 0) 55%),
    var(--bg);
}

.auth-inner {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  animation: fade-up .35s ease both;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}
.auth-brand h1 { font-size: 22px; font-weight: 750; letter-spacing: .3px; }
.auth-brand .brand-sub { font-size: 11px; color: var(--ink-faint); letter-spacing: 1.2px; }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px 20px 20px;
  box-shadow: 0 10px 30px rgba(42, 49, 45, .07), 0 30px 60px rgba(42, 49, 45, .05);
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-soft);
  padding: 4px;
  border-radius: 14px;
  margin-bottom: 20px;
}
.auth-tab {
  flex: 1;
  min-height: 40px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 650;
  color: var(--ink-soft);
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.auth-tab.is-active {
  background: #fff;
  color: var(--sage-deep);
  box-shadow: 0 2px 6px rgba(42, 49, 45, .09);
}

.auth-field { display: block; margin-bottom: 16px; }
.auth-field > span {
  display: block;
  font-size: 13px;
  font-weight: 650;
  color: var(--ink-soft);
  margin-bottom: 7px;
}
.auth-field input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  outline: none;
  font-size: 15px;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.auth-field input:focus {
  border-color: var(--sage);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(110, 143, 121, .12);
}

.auth-error {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 11px;
  background: var(--danger-tint);
  color: var(--danger);
  font-size: 13px;
  line-height: 1.5;
}

.auth-submit { min-height: 48px; font-size: 15.5px; }

.auth-note {
  margin-top: 14px;
  font-size: 12px;
  color: var(--ink-faint);
  line-height: 1.6;
  text-align: center;
}

.auth-foot {
  margin-top: 22px;
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-faint);
}

/* =========================================================
   设置：账号卡片 / Key 状态
   ========================================================= */

.account-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--sage-tint);
  margin-bottom: 20px;
}
.account-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.account-label { font-size: 11.5px; color: var(--sage-deep); opacity: .8; }
.account-info strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-card .btn { background: #fff; color: var(--sage-deep); }

.key-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.key-status {
  font-size: 12px;
  color: var(--sage-deep);
  background: var(--sage-tint);
  padding: 4px 10px;
  border-radius: 999px;
}
.key-actions .btn.danger { margin-left: auto; }


/* ---------------- 语音引擎选择 ---------------- */
.segmented-3 label span { padding: 9px 2px; font-size: 12px; }

.field select.select {
  width: 100%;
  height: 46px;
  padding: 0 38px 0 14px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background-color: var(--surface-soft);
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A938C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  font-size: 15px;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
}
.field select.select:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 4px rgba(110, 143, 121, .12);
}

.tts-preview-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.tts-preview-row .tiny { flex: 1; min-width: 140px; }

.tts-status {
  margin-top: 8px;
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--amber-tint);
  color: #8A5D22;
  font-size: 12px;
  line-height: 1.55;
}
