:root {
  color-scheme: light;
  --paper: #f7f8f4;
  --surface: #ffffff;
  --ink: #20242a;
  --muted: #66706d;
  --line: #d8ded7;
  --jade: #1f8a70;
  --jade-dark: #116653;
  --coral: #e85d4f;
  --gold: #f5b942;
  --sky: #d7ecf7;
  --plum: #7a4d8f;
  --shadow: 0 18px 48px rgba(28, 35, 32, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(215, 236, 247, 0.95), rgba(247, 248, 244, 0.96) 36%),
    var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 260px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-mark svg {
  width: 40px;
  height: 40px;
  fill: none;
  stroke: var(--jade-dark);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

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

h1 {
  font-size: clamp(1.45rem, 2.6vw, 2.25rem);
  line-height: 1.08;
}

.brand-block p {
  margin-top: 4px;
  color: var(--muted);
}

.control-strip {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.control-strip label,
.switch,
.voice-test-button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--muted);
  font-size: 0.92rem;
}

.voice-test-button {
  color: var(--ink);
}

.voice-hint {
  flex: 1 1 100%;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
  text-align: right;
}

.planning-mode .control-strip {
  display: none;
}

select {
  max-width: 230px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.switch input {
  accent-color: var(--jade);
}

.route-ribbon {
  overflow: hidden;
  margin-bottom: 16px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
}

.route-line {
  display: grid;
  grid-template-columns: repeat(8, minmax(86px, 1fr));
  gap: 8px;
  min-width: 720px;
}

.route-stop {
  position: relative;
  display: grid;
  gap: 5px;
  min-height: 58px;
  padding: 9px 10px 9px 34px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.route-stop::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 17px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 5px rgba(232, 93, 79, 0.14);
}

.route-stop strong {
  font-size: 0.92rem;
}

.route-stop span {
  color: var(--muted);
  font-size: 0.78rem;
}

.workspace {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 220px;
  grid-template-areas:
    "tabs tabs tabs"
    "scenarios practice progress";
  gap: 16px;
  align-items: start;
}

.mode-tabs {
  grid-area: tabs;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab,
.primary-button,
.choice-button,
.ghost-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 8px;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.tab {
  min-height: 42px;
  padding: 9px 14px;
  background: rgba(255, 255, 255, 0.76);
  border-color: var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.tab.is-active {
  background: var(--ink);
  color: white;
  box-shadow: 0 10px 24px rgba(32, 36, 42, 0.18);
}

.scenario-panel,
.practice-surface,
.progress-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.scenario-panel {
  grid-area: scenarios;
  padding: 14px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 8px;
  margin-bottom: 12px;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.scenario-list {
  display: grid;
  gap: 8px;
}

.scenario-button {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 9px;
  width: 100%;
  min-height: 58px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
}

.scenario-button.is-active {
  border-color: var(--jade);
  background: rgba(31, 138, 112, 0.08);
}

.scenario-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--sky);
  color: var(--jade-dark);
  font-weight: 800;
}

.scenario-button strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scenario-button span:last-child {
  color: var(--muted);
  font-size: 0.78rem;
}

.practice-surface {
  grid-area: practice;
  min-height: 610px;
  padding: clamp(16px, 2.4vw, 28px);
}

.progress-panel {
  grid-area: progress;
  display: grid;
  gap: 14px;
  padding: 16px;
}

.score-ring {
  display: grid;
  place-items: center;
  width: 142px;
  height: 142px;
  margin: 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--surface) 55%, transparent 56%),
    conic-gradient(var(--gold) calc(var(--scoreArc, 0) * 1%), #e6ece8 0);
}

.score-ring span {
  display: block;
  font-size: 2.6rem;
  font-weight: 850;
}

.score-ring small {
  margin-top: -14px;
  color: var(--muted);
  font-weight: 700;
}

.streak-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(245, 185, 66, 0.16);
}

.passport-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stamp {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px dashed #b5bdb7;
  border-radius: 8px;
  color: #9aa39e;
  font-size: 0.8rem;
  font-weight: 800;
}

.stamp.is-filled {
  border-style: solid;
  border-color: rgba(31, 138, 112, 0.35);
  background: rgba(31, 138, 112, 0.12);
  color: var(--jade-dark);
}

.view-stack {
  display: grid;
  gap: 18px;
}

.lesson-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.lesson-head h2 {
  font-size: clamp(1.55rem, 3vw, 2.45rem);
  line-height: 1.05;
}

.lesson-head p {
  max-width: 58ch;
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.55;
}

.mini-visual {
  width: 112px;
  min-width: 112px;
  height: 92px;
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(31, 138, 112, 0.18), rgba(232, 93, 79, 0.18)),
    var(--surface);
  border: 1px solid var(--line);
  overflow: hidden;
}

.mini-visual svg {
  width: 100%;
  height: 100%;
}

.conversation-card {
  display: grid;
  gap: 16px;
  padding: 18px;
  border-radius: 12px;
  background: linear-gradient(180deg, #fff, #f8fbf8);
  border: 1px solid var(--line);
}

.speaker-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  font-weight: 900;
}

.line-content {
  min-width: 0;
}

.line-content strong {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.pinyin {
  margin-top: 4px;
  font-size: clamp(1.45rem, 3vw, 2.35rem);
  font-weight: 800;
  line-height: 1.12;
}

.hanzi {
  display: none;
  margin-top: 8px;
  color: var(--jade-dark);
  font-size: 1.35rem;
  font-weight: 700;
}

body.show-hanzi .hanzi {
  display: block;
}

.english {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.ghost-button,
.icon-button {
  min-height: 42px;
  padding: 10px 13px;
}

.primary-button {
  background: var(--jade);
  color: white;
  box-shadow: 0 10px 24px rgba(31, 138, 112, 0.2);
}

.ghost-button,
.icon-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

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

.choice-button {
  min-height: 118px;
  padding: 13px;
  background: var(--surface);
  border-color: var(--line);
  text-align: left;
}

.choice-button strong {
  display: block;
  font-size: 1.06rem;
  line-height: 1.25;
}

.choice-button span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.35;
}

.choice-button.is-correct {
  border-color: var(--jade);
  background: rgba(31, 138, 112, 0.12);
}

.choice-button.is-wrong {
  border-color: var(--coral);
  background: rgba(232, 93, 79, 0.11);
}

.feedback {
  min-height: 42px;
  padding: 11px 12px;
  border-radius: 8px;
  background: rgba(215, 236, 247, 0.7);
  color: var(--ink);
}

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

.tone-card,
.phrase-card,
.mic-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.tone-card {
  display: grid;
  gap: 12px;
  min-height: 220px;
}

.tone-card svg {
  width: 100%;
  height: 70px;
}

.tone-card path {
  fill: none;
  stroke: var(--coral);
  stroke-width: 5;
  stroke-linecap: round;
}

.tone-card .tone-number {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tone-card h3 {
  font-size: 1.45rem;
}

.quiz-strip {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 12px;
  background: rgba(245, 185, 66, 0.13);
  border: 1px solid rgba(245, 185, 66, 0.38);
}

.tone-choice-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.phrase-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.phrase-filter {
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.phrase-card {
  display: grid;
  gap: 12px;
  min-height: 190px;
}

.phrase-card h3 {
  font-size: 1.25rem;
}

.mic-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
}

.mic-card {
  display: grid;
  gap: 14px;
}

.transcript {
  min-height: 74px;
  padding: 12px;
  border-radius: 8px;
  background: #f3f6f1;
  color: var(--muted);
  line-height: 1.5;
}

.coach-note {
  padding: 14px;
  border-left: 4px solid var(--coral);
  border-radius: 8px;
  background: rgba(232, 93, 79, 0.09);
  line-height: 1.5;
}

.workspace.is-home,
.workspace.is-itinerary {
  grid-template-columns: 1fr;
  grid-template-areas:
    "tabs"
    "practice";
}

.workspace.is-home .scenario-panel,
.workspace.is-home .progress-panel,
.workspace.is-itinerary .scenario-panel,
.workspace.is-itinerary .progress-panel {
  display: none;
}

.workspace.is-home .practice-surface,
.workspace.is-itinerary .practice-surface {
  min-height: 690px;
}

.home-view {
  display: grid;
  gap: 18px;
}

.home-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding: clamp(16px, 2vw, 22px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #fff, #f7faf7);
}

.home-hero h2 {
  margin-top: 4px;
  font-size: clamp(1.8rem, 3.5vw, 3.1rem);
  line-height: 1.03;
}

.home-hero p {
  max-width: 62ch;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.55;
}

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

.home-choice {
  min-height: 260px;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
  box-shadow: 0 14px 32px rgba(28, 35, 32, 0.09);
}

.home-choice.itinerary-choice {
  border-top: 6px solid var(--jade);
}

.home-choice.practice-choice {
  border-top: 6px solid var(--coral);
}

.choice-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 8px;
  background: rgba(31, 138, 112, 0.1);
  color: var(--jade-dark);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.practice-choice .choice-kicker {
  background: rgba(232, 93, 79, 0.1);
  color: var(--coral);
}

.home-choice strong {
  display: block;
  margin-top: 18px;
  font-size: clamp(1.65rem, 3vw, 2.45rem);
  line-height: 1.05;
}

.home-choice p {
  max-width: 42ch;
  margin-top: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.home-choice small {
  display: block;
  margin-top: 22px;
  color: var(--ink);
  font-weight: 750;
}

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

.home-quick-grid button {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f3f6f1;
  color: var(--ink);
  font-weight: 800;
}

.itinerary-view {
  gap: 16px;
}

.itinerary-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.segmented-control {
  display: inline-flex;
  min-height: 42px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f3f6f1;
}

.segmented-control button {
  min-width: 86px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}

.segmented-control button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(32, 36, 42, 0.1);
}

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

.trip-stats div {
  min-height: 72px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.trip-stats strong,
.trip-stats span {
  display: block;
}

.trip-stats strong {
  font-size: 1.3rem;
  line-height: 1.1;
}

.trip-stats span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.timeline-shell {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0 12px;
  scrollbar-color: #a8b4ad transparent;
}

.timeline-grid {
  display: grid;
  grid-auto-rows: auto;
  gap: 8px;
  min-width: max-content;
}

.stay-band,
.timeline-day {
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: left;
}

.stay-band {
  grid-row: 1;
  min-height: 48px;
  padding: 9px 11px;
  background: rgba(31, 138, 112, 0.12);
  color: var(--jade-dark);
}

.stay-band.family {
  background: rgba(122, 77, 143, 0.12);
  color: var(--plum);
}

.stay-band strong,
.stay-band span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stay-band span {
  margin-top: 2px;
  font-size: 0.8rem;
  color: var(--muted);
}

.timeline-day {
  grid-row: 2;
  width: var(--day-width);
  min-height: 162px;
  padding: 12px;
  background: var(--surface);
  border-top: 4px solid var(--jade);
  color: var(--ink);
}

.timeline-day.family {
  border-top-color: var(--plum);
}

.timeline-day.is-active {
  border-color: var(--coral);
  border-top-color: var(--coral);
  box-shadow: 0 14px 28px rgba(232, 93, 79, 0.16);
}

.timeline-date,
.timeline-day em,
.timeline-day small {
  display: block;
  color: var(--muted);
  font-style: normal;
  font-size: 0.78rem;
  font-weight: 750;
}

.timeline-day strong {
  display: block;
  margin-top: 6px;
  font-size: 1.08rem;
  line-height: 1.15;
}

.timeline-day p {
  display: -webkit-box;
  margin-top: 8px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.38;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.timeline-day small {
  margin-top: 8px;
  color: var(--jade-dark);
}

.zoom-0 .timeline-day {
  min-height: 126px;
}

.zoom-0 .timeline-day p {
  -webkit-line-clamp: 2;
}

.zoom-2 .timeline-day {
  min-height: 222px;
}

.zoom-2 .timeline-day p {
  -webkit-line-clamp: 6;
}

.day-detail {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #fff, #f7faf7);
}

.day-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.day-detail h3 {
  margin-top: 3px;
  font-size: clamp(1.45rem, 2.4vw, 2rem);
}

.day-detail p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.48;
}

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

.detail-block {
  min-height: 116px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.detail-block span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.detail-block p {
  margin-top: 8px;
  color: var(--ink);
  line-height: 1.42;
}

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

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(31, 138, 112, 0.34);
  outline-offset: 2px;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 190px minmax(0, 1fr);
    grid-template-areas:
      "tabs tabs"
      "scenarios practice"
      "progress progress";
  }

  .progress-panel {
    grid-template-columns: 160px minmax(0, 1fr) 120px;
    align-items: center;
  }

  .passport-grid {
    grid-template-columns: repeat(8, 1fr);
  }

  .choice-grid,
  .tone-grid,
  .phrase-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mic-layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .app-header,
  .lesson-head,
  .home-hero {
    flex-direction: column;
    align-items: stretch;
  }

  .control-strip {
    justify-content: stretch;
  }

  .control-strip label,
  .switch,
  .voice-test-button {
    flex: 1 1 145px;
  }

  .voice-hint {
    text-align: left;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "tabs"
      "scenarios"
      "practice"
      "progress";
  }

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

  .practice-surface {
    min-height: auto;
  }

  .choice-grid,
  .tone-grid,
  .phrase-grid,
  .tone-choice-row {
    grid-template-columns: 1fr;
  }

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

  .score-ring {
    width: 126px;
    height: 126px;
  }

  .trip-stats,
  .detail-grid,
  .home-choice-grid,
  .home-quick-grid {
    grid-template-columns: 1fr;
  }

  .segmented-control {
    width: 100%;
  }

  .segmented-control button {
    min-width: 0;
    flex: 1 1 0;
  }
}

@media (max-width: 480px) {
  .scenario-list {
    grid-template-columns: 1fr;
  }

  .brand-block {
    align-items: flex-start;
  }

  .brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 12px;
  }
}
