:root {
  --ink: #14251f;
  --muted: #5d675d;
  --paper: #f5ead8;
  --paper-strong: #fff8ea;
  --line: rgba(20, 37, 31, 0.16);
  --accent: #e46f3c;
  --accent-dark: #a74223;
  --sage: #c7d8b5;
  --sky: #d8e9ed;
  --success: #2f6d52;
  --danger: #a43b31;
  --shadow: 0 18px 45px rgba(20, 37, 31, 0.12);
  --radius: 28px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 92% 8%, rgba(228, 111, 60, 0.28), transparent 30rem),
    radial-gradient(circle at 6% 18%, rgba(199, 216, 181, 0.9), transparent 22rem),
    linear-gradient(135deg, rgba(20, 37, 31, 0.06) 0 2px, transparent 2px 26px),
    var(--paper);
  font-family: "Avenir Next", "Trebuchet MS", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

button:focus-visible,
input:focus-visible {
  outline: 4px solid rgba(228, 111, 60, 0.42);
  outline-offset: 3px;
}

.app-shell {
  min-height: 100svh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) clamp(14px, 4vw, 28px) 12px;
  background: rgba(245, 234, 216, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  color: var(--paper);
  background: var(--ink);
  border-radius: 14px;
  font-size: 18px;
}

.brand span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(47, 109, 82, 0.12);
}

.status-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 0 5px rgba(164, 59, 49, 0.12);
}

.hero {
  position: relative;
  display: grid;
  min-height: min(720px, calc(100svh - 64px));
  overflow: hidden;
  padding: clamp(28px, 8vw, 86px) clamp(18px, 6vw, 84px);
}

.hero::before {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(110deg, rgba(20, 37, 31, 0.98), rgba(20, 37, 31, 0.82) 48%, rgba(20, 37, 31, 0.25)),
    radial-gradient(circle at 82% 28%, rgba(228, 111, 60, 0.68), transparent 16rem),
    radial-gradient(circle at 65% 78%, rgba(199, 216, 181, 0.58), transparent 18rem),
    #14251f;
}

.hero::after {
  position: absolute;
  right: -14vw;
  bottom: -12vh;
  width: min(72vw, 760px);
  height: min(72vw, 760px);
  content: "";
  border: clamp(34px, 8vw, 92px) solid rgba(245, 234, 216, 0.14);
  border-radius: 50%;
  transform: rotate(-14deg);
}

.hero-content {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: center;
  max-width: 780px;
  color: var(--paper-strong);
  animation: rise-in 650ms ease-out both;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--sage);
  font-size: clamp(15px, 2vw, 18px);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  max-width: 12ch;
  margin: 0;
  font-size: clamp(48px, 12vw, 118px);
  line-height: 0.92;
  letter-spacing: -0.08em;
}

.hero-copy {
  max-width: 620px;
  margin: 24px 0 0;
  color: rgba(255, 248, 234, 0.84);
  font-size: clamp(18px, 3.2vw, 26px);
  line-height: 1.52;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 34px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 18px;
  color: var(--ink);
  background: var(--paper-strong);
  border-radius: 999px;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, color 180ms ease;
}

.button:hover {
  transform: translateY(-2px);
}

.button.primary {
  color: var(--paper-strong);
  background: var(--accent);
}

.button.dark {
  color: var(--paper-strong);
  background: var(--ink);
}

.button.ghost {
  color: var(--paper-strong);
  background: rgba(255, 248, 234, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 248, 234, 0.24);
}

.main {
  display: grid;
  gap: clamp(26px, 5vw, 52px);
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(22px, 5vw, 60px) clamp(16px, 5vw, 40px) 80px;
}

.section {
  display: grid;
  gap: 18px;
  scroll-margin-top: 86px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

h2 {
  margin: 0;
  font-size: clamp(30px, 6vw, 54px);
  line-height: 1;
  letter-spacing: -0.06em;
}

.section-note {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.install-panel,
.audio-panel,
.practice-panel,
.phrase-card,
.empty-state {
  background: rgba(255, 248, 234, 0.78);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.install-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 18px;
}

.audio-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  align-items: center;
  gap: 18px;
  padding: 18px;
}

.audio-panel h2,
.audio-panel p {
  margin: 0;
}

.audio-panel h2 {
  font-size: clamp(22px, 5vw, 32px);
}

.audio-panel p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.5;
}

.audio-controls {
  display: grid;
  gap: 10px;
}

.voice-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.install-panel h2,
.install-panel p {
  margin: 0;
}

.install-panel h2 {
  font-size: clamp(22px, 5vw, 32px);
}

.install-panel p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.5;
}

.quick-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.nav-tile {
  display: grid;
  min-height: 94px;
  align-content: space-between;
  padding: 16px;
  color: var(--ink);
  background: rgba(255, 248, 234, 0.66);
  border: 1px solid var(--line);
  border-radius: 24px;
  cursor: pointer;
  text-align: left;
  transition: transform 180ms ease, background 180ms ease;
}

.nav-tile:hover {
  background: var(--paper-strong);
  transform: translateY(-3px);
}

.nav-tile strong {
  font-size: 18px;
  letter-spacing: -0.02em;
}

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

.category-row,
.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.chip {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 9px 14px;
  color: var(--ink);
  background: rgba(255, 248, 234, 0.78);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
}

.chip.active {
  color: var(--paper-strong);
  background: var(--ink);
}

.phrase-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.phrase-card {
  display: grid;
  gap: 14px;
  padding: clamp(16px, 3.5vw, 22px);
}

.phrase-card.learned {
  background: rgba(199, 216, 181, 0.58);
}

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

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  color: var(--accent-dark);
  background: rgba(228, 111, 60, 0.12);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.learned-toggle {
  min-height: 34px;
  padding: 7px 10px;
  color: var(--muted);
  background: rgba(20, 37, 31, 0.06);
  border-radius: 999px;
  cursor: pointer;
}

.learned .learned-toggle {
  color: var(--paper-strong);
  background: var(--success);
}

.english {
  margin: 0;
  font-size: clamp(24px, 5vw, 36px);
  line-height: 1.05;
  letter-spacing: -0.05em;
}

.chinese {
  margin: -4px 0 0;
  color: var(--accent-dark);
  font-size: 19px;
  font-weight: 900;
}

.meta {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.52;
}

.meta b {
  color: var(--ink);
}

.phrase-actions,
.record-actions,
.answer-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.mini-button {
  min-height: 42px;
  padding: 9px 12px;
  color: var(--ink);
  background: var(--sky);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 900;
}

.mini-button.secondary {
  background: rgba(20, 37, 31, 0.08);
}

.mini-button.warn {
  color: var(--paper-strong);
  background: var(--danger);
}

.mini-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.practice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.practice-panel {
  display: grid;
  gap: 16px;
  align-content: start;
  padding: clamp(16px, 3.6vw, 24px);
}

.practice-panel h3 {
  margin: 0;
  font-size: clamp(24px, 5vw, 34px);
  line-height: 1;
  letter-spacing: -0.05em;
}

.prompt-box {
  min-height: 118px;
  padding: 16px;
  background: rgba(20, 37, 31, 0.06);
  border-radius: 22px;
}

.prompt-box p {
  margin: 0;
}

.prompt-main {
  color: var(--ink);
  font-size: 25px;
  font-weight: 900;
  line-height: 1.16;
  letter-spacing: -0.04em;
}

.prompt-sub {
  margin-top: 8px !important;
  color: var(--muted);
  line-height: 1.45;
}

.option-button {
  width: 100%;
  min-height: 48px;
  padding: 12px;
  color: var(--ink);
  background: var(--paper-strong);
  border: 1px solid var(--line);
  border-radius: 16px;
  cursor: pointer;
  font-weight: 900;
  text-align: left;
}

.option-button.correct {
  color: var(--paper-strong);
  background: var(--success);
}

.option-button.wrong {
  color: var(--paper-strong);
  background: var(--danger);
}

.result-line {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

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

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

.sentence-input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  color: var(--ink);
  background: var(--paper-strong);
  border: 1px solid var(--line);
  border-radius: 16px;
  font-weight: 900;
}

.emergency-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  line-height: 1.6;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 40;
  max-width: min(360px, calc(100vw - 36px));
  padding: 14px 16px;
  color: var(--paper-strong);
  background: var(--ink);
  border-radius: 18px;
  box-shadow: var(--shadow);
  animation: toast-in 180ms ease-out both;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 920px) {
  .quick-nav,
  .practice-grid,
  .phrase-grid,
  .emergency-list {
    grid-template-columns: 1fr;
  }

  .quick-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .install-panel,
  .audio-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding-inline: 12px;
  }

  .brand span:last-child {
    max-width: 44vw;
  }

  .hero {
    min-height: calc(100svh - 64px);
    padding: 30px 18px;
  }

  .hero-content {
    align-content: end;
  }

  .hero-copy {
    font-size: 18px;
  }

  .button {
    width: 100%;
  }

  .quick-nav {
    grid-template-columns: 1fr;
  }

  .section-heading {
    display: grid;
  }

  .phrase-actions .mini-button,
  .record-actions .mini-button {
    flex: 1 1 44%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}
