:root {
  --bg: #f3f5f8;
  --ink: #1c1e21;
  --mute: #8b919a;
  --line: rgba(28, 30, 33, 0.08);
  --paper: #ffffff;
  --paper-ink: #1c1e21;
  --paper-mute: #8b919a;
  --lilac: #efe4f6;
  --yellow: #f8efc4;
  --mint: #dff0ea;
  --pink: #f8e3ec;
  --violet: #6a6278;
  --coral: #e7a8bc;
  --peach: #f8efc4;
  --shadow: 0 18px 40px rgba(40, 52, 74, 0.08);
  font-family: "Figtree", "Noto Sans SC", "PingFang SC", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }

html, body, #root {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(720px 480px at -12% -8%, rgba(214, 226, 246, 0.95), transparent 62%),
    radial-gradient(480px 360px at 108% 0%, rgba(248, 227, 236, 0.7), transparent 58%),
    #f3f5f8;
}

button, input {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

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

.app {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.app.practice {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px 8px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand b {
  font-size: 15px;
  letter-spacing: 0.14em;
  font-weight: 650;
}

.brand span, .quiet {
  color: var(--mute);
  font-size: 13px;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.nav button, .ghost, .auth-switch button {
  border: 1px solid transparent;
  background: #ffffff;
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 44px;
  box-shadow: 0 8px 20px rgba(40, 52, 74, 0.05);
}

.nav button {
  width: auto;
  height: auto;
  padding: 8px 14px 8px 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav button span {
  font-size: 14px;
  line-height: 1;
}

.nav button svg,
.tool svg,
.corner-toggle svg,
.icon-chip svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool svg.is-filled path,
.icon-chip svg.is-filled path,
.corner-toggle .pupil {
  fill: currentColor;
}

.nav button[aria-current="page"], .auth-switch button[aria-current="page"] {
  background: #1c1e21;
  color: #ffffff;
  border-color: transparent;
  box-shadow: none;
}

.stage {
  width: min(880px, calc(100% - 28px));
  margin: 0 auto;
  padding: 8px 0 40px;
  display: grid;
  align-content: center;
  gap: 18px;
}

.stage.top { align-content: start; padding-top: 12px; }

.stage.fit {
  height: 100%;
  min-height: 0;
  align-content: stretch;
  padding-bottom: 12px;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
}

.progress {
  height: 3px;
  background: rgba(36, 31, 28, 0.1);
  border-radius: 99px;
  overflow: hidden;
}

.progress i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #f8efc4, #b7ddd0);
  width: 0;
}

.cup-wrap {
  display: grid;
  justify-items: center;
  gap: 14px;
}

.app.listen-open { cursor: pointer; }
.app.listen-open button,
.app.listen-open input { cursor: pointer; }

.cup-wrap.listen-tap {
  min-height: min(62vh, 520px);
  align-content: center;
}

.cup {
  width: min(38vw, 188px);
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background:
    radial-gradient(circle at 32% 28%, #ffffff 0%, #f8efc4 30%, #efe4f6 62%, #dff0ea 100%);
  box-shadow: var(--shadow), inset 0 0 0 12px rgba(255, 255, 255, 0.55);
  display: grid;
  place-items: center;
  position: relative;
}

.cup canvas {
  width: 74%;
  height: 28%;
}

.cup small {
  position: absolute;
  bottom: 14%;
  color: #1c1e21;
  letter-spacing: 0;
  font-size: 28px;
  font-weight: 700;
}

.cup-wrap .choices { justify-content: center; }

.hint {
  text-align: center;
  color: var(--mute);
  font-size: 16px;
}

.sheet {
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 28px;
  padding: 28px 28px 22px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.sheet.lilac {
  background: #efe4f6;
}

.sheet.mint {
  background: var(--mint);
}

.sheet.yellow {
  background: var(--yellow);
}

.browse-stage { padding-bottom: 96px; }

.browse-foot {
  display: flex;
  align-items: center;
}

.corner-toggle {
  position: fixed;
  left: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 30;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  border: 1.5px solid rgba(28, 30, 33, 0.16);
  background: #ffffff;
  color: #1c1e21;
  box-shadow: 0 12px 28px rgba(40, 52, 74, 0.18);
  display: grid;
  place-items: center;
  padding: 0;
}

.corner-toggle.is-on {
  background: #1c1e21;
  color: #ffffff;
  border-color: #1c1e21;
}

.tool {
  width: 40px;
  height: 40px;
  min-height: 40px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: #1c1e21;
  box-shadow: none;
  display: grid;
  place-items: center;
  padding: 0;
}

.tool:hover { background: rgba(28, 30, 33, 0.06); }
.tool:active { background: #1c1e21; color: #ffffff; }
.tool.is-on { background: #1c1e21; color: #ffffff; }
.tool.is-on.warm { background: var(--yellow); color: #1c1e21; }
.tool.is-on.soft { background: var(--pink); color: #1c1e21; }
.tool.is-on.warm:active,
.tool.is-on.soft:active { background: #1c1e21; color: #ffffff; }

.list-tool {
  border: 1px solid rgba(28, 30, 33, 0.12);
  background: #ffffff;
}

.auth-switch button.icon-chip {
  width: 44px;
  min-width: 44px;
  padding: 0;
  display: grid;
  place-items: center;
}

.kicker {
  margin: 0;
  color: var(--violet);
  letter-spacing: 0.16em;
  font-size: 12px;
}

.sheet h1, .book-row h2 {
  margin: 0;
  font-family: "Source Serif 4", "Noto Serif SC", serif;
  font-weight: 650;
  line-height: 1.15;
}

.sheet h1 { font-size: clamp(32px, 5vw, 54px); font-weight: 700; }

.word-head h1 { font-weight: 700; }

.ipa {
  min-height: 1.45em;
  margin: 6px 0 0;
  color: var(--violet);
  font-size: 18px;
  line-height: 1.45;
}

.word-pending { color: var(--paper-mute); font-weight: 600; }

.speak-sheet {
  height: min(640px, 100%);
  min-height: 0;
  align-self: center;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.speak-sheet .word-head h1 {
  height: 3.7em;
  overflow: auto;
  font-size: clamp(22px, 3.4vw, 36px);
  line-height: 1.2;
}

.speak-sheet .ipa {
  height: 2.9em;
  overflow: auto;
  flex: none;
  font-size: 16px;
  line-height: 1.4;
}

.speak-sheet .game-slot {
  height: 32px;
  flex: none;
  display: flex;
  align-items: center;
}

.speak-sheet .gloss {
  height: 2.6em;
  overflow: auto;
  flex: none;
  font-size: 22px;
  line-height: 1.3;
}

.speak-sheet .explain {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.speak-sheet .feedback {
  height: 84px;
  overflow: hidden;
  flex: none;
}

.speak-sheet .feedback .explain {
  flex: none;
  overflow: hidden;
}

.speak-sheet .speak-actions {
  flex: none;
  flex-wrap: nowrap;
  margin-top: 4px;
}

.book-row h2 { font-weight: 700; }
.book-row .ipa { margin-top: 4px; font-size: 14px; min-height: 0; }

.book-row h2 { font-size: 26px; }

.gloss {
  margin: 0;
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 650;
  line-height: 1.25;
}

.book-row .gloss {
  font-size: 16px;
  font-weight: 500;
  color: var(--paper-mute);
}

.explain {
  margin: 0;
  font-size: 17px;
  line-height: 1.65;
  color: #4e5560;
}

.choices, .speak-actions, .done-actions, .book-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.speak-actions svg, .book-actions svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.choices button, .primary, .speak-actions button, .done-actions button {
  min-height: 48px;
  border-radius: 999px;
  padding: 10px 18px;
  border: 1px solid transparent;
}

.know { background: #1c1e21; color: #ffffff; }
.vague { background: var(--yellow); color: #1c1e21; }
.forgot { background: var(--pink); color: #1c1e21; }

.primary {
  background: #1c1e21;
  color: #ffffff;
  font-weight: 700;
}

.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: #ffffff;
  color: #1c1e21;
  box-shadow: 0 8px 20px rgba(40, 52, 74, 0.06);
  display: grid;
  place-items: center;
  padding: 0;
}

.icon-btn.is-on, .replay.is-on, .word-speak.is-on {
  background: #1c1e21;
  color: #ffffff;
}

.icon-btn svg, .replay svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.replay {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 0;
  background: #ffffff;
  color: #1c1e21;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 24px rgba(40, 52, 74, 0.08);
}

.plan {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  background: #f4f6f9;
  border: 1px solid transparent;
  border-radius: 18px;
  padding: 14px 16px;
  display: grid;
  gap: 8px;
}

.field span { color: var(--mute); font-size: 13px; }

.field input {
  background: transparent;
  border: 0;
  font-size: 32px;
  font-weight: 650;
  width: 100%;
  padding: 0;
  color: var(--ink);
  color-scheme: light;
}

.field.compact input { font-size: 18px; font-weight: 600; }

.cal-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.cal-stats p {
  margin: 0;
  background: #ffffff;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
}
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.cal-nav b { font-size: 16px; }
.cal-week, .cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  text-align: center;
}
.cal-week span {
  color: var(--mute);
  font-size: 12px;
  letter-spacing: 0.08em;
}
.cal-day {
  aspect-ratio: 1;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.62);
  min-height: 36px;
  padding: 0;
  font-size: 14px;
  box-shadow: none;
}
.cal-day.on { background: #1c1e21; color: #ffffff; }
.cal-day.today { box-shadow: inset 0 0 0 2px #1c1e21; }
.cal-day.on.today { box-shadow: inset 0 0 0 2px #f8efc4; }
.cal-day[aria-current="date"] { background: var(--yellow); color: #1c1e21; }
.cal-day.on[aria-current="date"] {
  background: #1c1e21;
  color: #ffffff;
  box-shadow: inset 0 0 0 2px #f8efc4;
}
.cal-detail { display: grid; gap: 4px; }
.cal-detail p { margin: 0; }

.auth, .me-stats { display: grid; gap: 12px; }
.auth-switch { display: flex; gap: 8px; }
.me-stats p, .bank-meta { margin: 0; color: var(--paper-mute); }

.bank-card {
  background: var(--paper);
  border-radius: 22px;
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.bank-card:nth-child(4n + 1) { background: var(--yellow); }
.bank-card:nth-child(4n + 2) { background: var(--mint); }
.bank-card:nth-child(4n + 3) { background: var(--lilac); }
.bank-card:nth-child(4n + 4) { background: var(--pink); }
.bank-card.current { outline: 2px solid #1c1e21; }
.bank-card.next { outline: 2px solid #1c1e21; }
.bank-card.locked { opacity: 0.55; }
.bank-card h2 {
  margin: 0;
  font-family: "Source Serif 4", "Noto Serif SC", serif;
  font-size: 28px;
}

.verdict {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.verdict b { font-size: 22px; }

.heard {
  margin: 0;
  color: var(--paper-mute);
}

.ok { color: #3d6b4f; }
.near { color: #9a6414; }
.bad { color: #d4533c; }

.mic-live {
  background: #1c1e21;
  color: white;
  border-color: transparent;
}

.book-list {
  display: grid;
  gap: 12px;
}

.book-row {
  background: var(--paper);
  border-radius: 22px;
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
}

.tag {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.tag.game { background: var(--mint); color: #1c1e21; }
.tag.pm { background: #e7eaf0; color: #1c1e21; }

.bank-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }

.word-line {
  background: var(--paper);
  border-radius: 18px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.word-speak {
  width: 36px;
  height: 36px;
  flex: none;
  margin-top: 2px;
  background: var(--yellow);
  box-shadow: none;
}

.word-speak svg {
  width: 16px;
  height: 16px;
}

.word-line.is-hidden { opacity: 0.5; }

.line-main {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 4px;
  align-items: flex-start;
  min-width: 0;
  flex: 1;
}

.word-line h2 {
  margin: 0;
  font-size: 18px;
  font-family: "Source Serif 4", "Noto Serif SC", serif;
}

.word-line.zh-only h2 {
  font-size: 22px;
  font-weight: 700;
}

.word-line .ipa-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  margin: 0;
}

.word-line .ipa {
  margin: 0;
  min-height: 0;
  font-size: 14px;
  line-height: 1.4;
}

.word-line .gloss {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.4;
  color: var(--ink);
}

.word-line .explain {
  margin: 2px 0 0;
  font-size: 14px;
  line-height: 1.55;
}

.word-line .tags, .word-line .tag { margin: 0; }
.tag.vague { background: var(--yellow); color: #1c1e21; }
.tag.forgot { background: var(--pink); color: #1c1e21; }
.tag.speak { background: var(--mint); color: #1c1e21; }

@media (max-width: 720px) {
  .plan { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .nav { justify-content: flex-start; }
  .sheet { padding: 22px 18px; }
  .book-row, .bank-card, .word-line { align-items: flex-start; flex-direction: column; }
  .speak-actions button { padding: 10px 12px; }
  .cup { width: min(32vw, 148px); }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
