:root {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --ink: #172033;
  --muted: #64748b;
  --line: #e2e8f0;
  --blue: #2563eb;
  --green: #16a34a;
  --amber: #f59e0b;
  --rose: #e11d48;
  --violet: #7c3aed;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

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

.app-shell {
  max-width: 760px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px 88px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 2px 16px;
}

.eyebrow,
.subtitle {
  margin: 0;
  color: var(--muted);
}

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: 34px;
  line-height: 1;
}

h2 {
  margin-bottom: 8px;
  font-size: 23px;
  line-height: 1.16;
}

.icon-btn,
.text-btn,
.primary-btn,
.learn-actions button,
.filters button,
.detail-card button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 14px;
}

.icon-btn {
  width: 48px;
  padding: 0;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.icon-btn.small {
  width: 40px;
  min-height: 40px;
  font-size: 13px;
}

.icon-btn.speaking,
.detail-card button.speaking {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.text-btn,
.primary-btn {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 750;
}

.hero-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  min-height: 178px;
  padding: 22px;
  border-radius: 8px;
  background: linear-gradient(135deg, #eff6ff 0%, #ffffff 46%, #ecfdf5 100%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.level-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.10);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 14px;
}

.hero-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.progress-ring {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #fff 0 58%, transparent 59%),
    conic-gradient(var(--green) var(--progress, 0%), #dbeafe 0);
}

.progress-ring span {
  font-size: 22px;
  font-weight: 850;
}

.progress-ring small {
  margin-top: -28px;
  color: var(--muted);
  font-size: 11px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0 22px;
}

.stats-row article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stats-row strong {
  display: block;
  font-size: 24px;
}

.stats-row span {
  color: var(--muted);
  font-size: 13px;
}

.tab-view {
  display: none;
}

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

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 12px;
}

.section-title.compact {
  margin-top: 24px;
}

.lesson-path {
  display: grid;
  gap: 10px;
}

.lesson-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 76px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.lesson-node {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--blue);
  font-weight: 850;
}

.lesson-item.done .lesson-node {
  background: #dcfce7;
  color: var(--green);
}

.lesson-item strong,
.review-card strong {
  display: block;
}

.lesson-item span,
.review-card span {
  color: var(--muted);
  font-size: 13px;
}

.review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.review-card {
  min-height: 102px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.learn-card,
.quiz-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.word-display {
  margin: 10px 0 8px;
  font-size: 58px;
  line-height: 1;
  font-weight: 850;
}

.phonetic-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.04em;
}

.meaning {
  margin-bottom: 8px;
  font-size: 20px;
  font-weight: 760;
}

.definition,
.example-zh {
  color: var(--muted);
}

.example-box {
  margin-top: 18px;
  padding: 16px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.example-box p:first-child {
  font-size: 18px;
  font-weight: 720;
}

.learn-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.quiz-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

#quizWord {
  font-size: 54px;
}

.quiz-options {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.quiz-options button {
  min-height: 56px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  text-align: left;
}

.quiz-options button.correct {
  border-color: #86efac;
  background: #dcfce7;
}

.quiz-options button.wrong {
  border-color: #fecdd3;
  background: #ffe4e6;
}

.quiz-feedback {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--muted);
  font-weight: 720;
}

.search-box span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search-box input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 14px;
  outline: none;
}

.search-box input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 14px 0 8px;
}

.filters button {
  white-space: nowrap;
  min-height: 36px;
  border-radius: 999px;
  background: var(--surface);
}

.filters button.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.result-line {
  color: var(--muted);
}

.word-grid {
  display: grid;
  gap: 10px;
}

.word-card {
  display: grid;
  gap: 7px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.word-card[data-cat="op"] { border-left-color: var(--blue); }
.word-card[data-cat="gt"] { border-left-color: var(--green); }
.word-card[data-cat="pt"] { border-left-color: var(--amber); }
.word-card[data-cat="qg"] { border-left-color: var(--violet); }
.word-card[data-cat="qo"] { border-left-color: var(--rose); }

.word-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.word {
  font-size: 26px;
  font-weight: 850;
}

.bottom-tabs {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(760px, 100%);
  transform: translateX(-50%);
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
}

.bottom-tabs button {
  display: grid;
  gap: 3px;
  place-items: center;
  min-height: 64px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.bottom-tabs span {
  font-size: 19px;
  line-height: 1;
}

.bottom-tabs button.active {
  color: var(--blue);
  font-weight: 850;
}

.voice-notice {
  position: fixed;
  left: 50%;
  bottom: 78px;
  z-index: 30;
  width: min(420px, calc(100% - 32px));
  transform: translateX(-50%);
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(23, 32, 51, 0.94);
  color: #fff;
  font-size: 14px;
  line-height: 1.45;
  box-shadow: var(--shadow);
}

.voice-notice[hidden] {
  display: none;
}

.dialog {
  width: min(560px, calc(100vw - 28px));
  border: 0;
  border-radius: 16px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.detail-card {
  padding: 22px;
}

.detail-card .word-display {
  font-size: 48px;
}

.syns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.syns span {
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}

@media (min-width: 720px) {
  .word-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 430px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .hero-panel {
    grid-template-columns: 1fr;
  }

  .progress-ring {
    justify-self: start;
  }

  .word-display,
  #quizWord {
    font-size: 46px;
  }
}
