:root {
  --ink: #16342d;
  --ink-soft: #52635d;
  --paper: #f4efe5;
  --card: #fffaf1;
  --line: #d9d0c1;
  --green: #173f36;
  --coral: #e87859;
  --gold: #f0c75e;
  --blue: #c6dce0;
  --font-scale: 1;
  --shadow: 0 18px 50px rgba(42, 55, 48, 0.1);
}

* { box-sizing: border-box; }
html { background: var(--paper); scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 9% 7%, rgba(240, 199, 94, .15), transparent 24rem),
    radial-gradient(circle at 92% 22%, rgba(232, 120, 89, .11), transparent 26rem),
    var(--paper);
  color: var(--ink);
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: calc(16px * var(--font-scale));
}
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible {
  outline: 4px solid rgba(232, 120, 89, .28);
  outline-offset: 2px;
}

.app-shell { min-height: 100dvh; padding-bottom: 86px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: max(12px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left));
  border-bottom: 1px solid rgba(197, 186, 169, .82);
  background: rgba(244, 239, 229, .92);
  backdrop-filter: blur(18px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: var(--gold);
  font: 700 14px Georgia, serif;
  box-shadow: inset 0 0 0 2px rgba(240, 199, 94, .35);
}
.brand > span:last-child { display: flex; flex-direction: column; gap: 1px; }
.brand strong { font-size: 16px; letter-spacing: .02em; }
.brand small { color: var(--ink-soft); font: 12px "PingFang SC", sans-serif; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.quiet-button, .progress-pill {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 241, .78);
  cursor: pointer;
}
.quiet-button { padding: 0 13px; font: 700 12px "PingFang SC", sans-serif; }
.progress-pill { width: 66px; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 0 11px; }
.progress-pill span { font: 700 11px Georgia, serif; }
.progress-pill i { height: 3px; overflow: hidden; border-radius: 3px; background: #d9d1c4; }
.progress-pill b { display: block; width: 0; height: 100%; background: var(--coral); transition: width .35s ease; }

main { width: min(100%, 1100px); margin: 0 auto; }
.view { padding: 28px 18px 48px; animation: reveal .3s ease both; }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } }
.eyebrow {
  margin: 0;
  color: #997041;
  font: 700 11px/1.4 "PingFang SC", sans-serif;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.hero { position: relative; overflow: hidden; padding: 34px 27px 30px; border-radius: 28px; background: var(--green); color: #fffaf1; box-shadow: var(--shadow); }
.hero::before, .hero::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(240, 199, 94, .28);
  border-radius: 50%;
}
.hero::before { width: 230px; height: 230px; right: -105px; top: -123px; box-shadow: 0 0 0 28px rgba(240,199,94,.04), 0 0 0 58px rgba(240,199,94,.025); }
.hero::after { width: 74px; height: 74px; left: -28px; bottom: -38px; }
.hero .eyebrow { color: var(--gold); }
.hero h1 { position: relative; z-index: 1; max-width: 720px; margin: 13px 0 12px; font-size: clamp(34px, 8vw, 62px); line-height: 1.04; letter-spacing: -.035em; }
.hero h1 em { color: #ef8c70; font-style: normal; }
.hero > p:not(.eyebrow) { position: relative; z-index: 1; max-width: 600px; margin: 0; color: #c8d6d1; font-family: "PingFang SC", sans-serif; font-size: 15px; line-height: 1.75; }
.hero-stats { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 25px; }
.hero-stats span { padding: 8px 11px; border: 1px solid rgba(255,255,255,.13); border-radius: 999px; background: rgba(255,255,255,.07); font: 13px "PingFang SC", sans-serif; }

.section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 34px 2px 16px; }
.section-head h2 { margin: 5px 0 0; font-size: clamp(25px, 5vw, 34px); }
.text-link { border: 0; background: transparent; color: #9c5544; padding: 8px 0; font: 700 13px "PingFang SC", sans-serif; cursor: pointer; }
.continue-card {
  width: 100%;
  display: grid;
  grid-template-columns: 54px 1fr auto;
  align-items: center;
  gap: 15px;
  min-height: 100px;
  padding: 17px;
  border: 1px solid #cfc4b4;
  border-radius: 22px;
  background: var(--card);
  box-shadow: 0 12px 32px rgba(48, 59, 53, .07);
  text-align: left;
  cursor: pointer;
}
.continue-number { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 17px; background: var(--coral); color: white; font: 700 18px Georgia, serif; }
.continue-card > span:nth-child(2) { display: flex; flex-direction: column; gap: 5px; }
.continue-card small { color: #8e6654; font: 12px "PingFang SC", sans-serif; }
.continue-card strong { font-size: 19px; line-height: 1.3; }
.continue-card i { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: var(--gold); font-style: normal; }

.quick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 11px; }
.quick-card { min-height: 132px; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: #fffaf2; text-align: left; cursor: pointer; }
.quick-card:nth-child(2) { background: #dbe8e3; }
.quick-card:nth-child(3) { background: #f0dfb7; }
.quick-card:nth-child(4) { background: #ead8d1; }
.quick-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: var(--gold); font: 20px Georgia, serif; }
.quick-card strong { display: block; margin-top: 16px; font-size: 17px; }
.quick-card small { display: block; margin-top: 3px; color: #596761; font: 12px/1.5 "PingFang SC", sans-serif; }

.search-box { position: relative; margin: 2px 0 19px; }
.search-box span { position: absolute; left: 17px; top: 50%; transform: translateY(-50%); color: #7c827d; }
.search-box input { width: 100%; min-height: 56px; padding: 0 18px 0 49px; border: 1px solid #cfc5b5; border-radius: 18px; background: rgba(255,250,241,.86); color: var(--ink); font-family: "PingFang SC", sans-serif; font-size: 16px; }
.chapter-grid { display: grid; gap: 11px; }
.chapter-card { width: 100%; display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 13px; min-height: 82px; padding: 14px; border: 1px solid var(--line); border-radius: 19px; background: rgba(255,250,241,.83); text-align: left; cursor: pointer; }
.chapter-card:hover { transform: translateY(-1px); border-color: #bba98f; }
.chapter-index { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; background: #dce7e3; color: var(--green); font: 700 14px Georgia, serif; }
.chapter-card:nth-child(3n+2) .chapter-index { background: #f2deae; }
.chapter-card:nth-child(3n) .chapter-index { background: #ead4cd; }
.chapter-card strong { display: block; font-size: 17px; line-height: 1.3; }
.chapter-card small { display: block; margin-top: 4px; color: #6d7772; font: 12px "PingFang SC", sans-serif; }
.chevron { color: #9a6b55; font-size: 22px; }

.back-button { min-height: 42px; display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 0 4px; color: #8e5948; font: 700 14px "PingFang SC", sans-serif; cursor: pointer; }
.chapter-heading { margin: 19px 3px 22px; }
.chapter-heading h1 { margin: 8px 0 8px; font-size: clamp(31px, 7vw, 50px); line-height: 1.08; }
.chapter-heading p:last-child { margin: 0; color: var(--ink-soft); font: 14px/1.65 "PingFang SC", sans-serif; }
.scene-list { display: grid; gap: 10px; }
.scene-card { width: 100%; display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 12px; min-height: 74px; padding: 14px; border: 1px solid var(--line); border-radius: 17px; background: var(--card); text-align: left; cursor: pointer; }
.scene-card.done { background: #e5eee9; border-color: #bfd0c7; }
.scene-card > span:first-child { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: #eee6d8; font: 700 13px Georgia, serif; }
.scene-card.done > span:first-child { background: var(--green); color: white; }
.scene-card strong { display: block; font-size: 17px; line-height: 1.35; }
.scene-card small { display: block; margin-top: 3px; color: #7a7e79; font: 11px "PingFang SC", sans-serif; }

.lesson-view { padding-top: 18px; }
.lesson-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.favorite-button { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--card); color: #a95b4a; font-size: 23px; cursor: pointer; }
.favorite-button.on { background: #f3d7cf; border-color: #e0ad9e; }
.lesson-head { margin: 20px 2px 19px; }
.lesson-head h1 { margin: 8px 0; font-size: clamp(30px, 7vw, 48px); line-height: 1.12; }
.lesson-head p:last-child { margin: 0; color: var(--ink-soft); font: 14px/1.7 "PingFang SC", sans-serif; }
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 5px; border-radius: 15px; background: #e6ded1; }
.mode-tabs button { min-height: 46px; border: 0; border-radius: 11px; background: transparent; color: #69736e; font: 700 14px "PingFang SC", sans-serif; cursor: pointer; }
.mode-tabs button.active { background: var(--card); color: var(--green); box-shadow: 0 4px 12px rgba(35,47,41,.08); }

.practice-card { position: relative; overflow: hidden; margin-top: 14px; padding: 25px 21px 22px; border-radius: 25px; background: var(--green); color: white; box-shadow: var(--shadow); }
.phrase-counter { display: flex; align-items: center; justify-content: space-between; color: #acc0b8; font: 12px "PingFang SC", sans-serif; }
.phrase-counter b { color: var(--gold); font-weight: 700; }
.phrase-word { margin: 32px 0 13px; font: 700 clamp(34px, 9vw, 60px)/1.08 Georgia, serif; letter-spacing: -.025em; overflow-wrap: anywhere; }
.phrase-meaning { min-height: 32px; margin: 0; color: #d3ded9; font: 18px/1.55 "PingFang SC", sans-serif; }
.phrase-meaning.hidden { filter: blur(8px); user-select: none; }
.reveal-button { margin-top: 10px; border: 0; background: transparent; color: var(--gold); padding: 4px 0; font: 700 13px "PingFang SC", sans-serif; cursor: pointer; }
.example-box { margin-top: 25px; padding: 15px; border-left: 3px solid var(--coral); border-radius: 0 12px 12px 0; background: rgba(255,255,255,.07); }
.example-box span { color: #91aaa1; font: 11px "PingFang SC", sans-serif; }
.example-box p { margin: 7px 0 0; font: 18px/1.5 Georgia, serif; }
.audio-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 22px; }
.audio-controls button { min-height: 54px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid rgba(255,255,255,.16); border-radius: 15px; background: rgba(255,255,255,.08); color: white; font: 700 14px "PingFang SC", sans-serif; cursor: pointer; }
.audio-controls .listen-button { background: var(--gold); color: var(--green); border-color: var(--gold); }
.audio-controls button.speaking { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.97); opacity: .82; } }
.speed-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 13px; color: #b4c4be; font: 12px "PingFang SC", sans-serif; }
.speed-row div { display: flex; gap: 5px; }
.speed-row button { min-width: 58px; min-height: 34px; border: 1px solid rgba(255,255,255,.14); border-radius: 999px; background: transparent; color: #c8d4cf; font: 700 12px Georgia, serif; cursor: pointer; }
.speed-row button.active { background: #fffaf1; color: var(--green); }
.record-panel { margin-top: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); }
.record-panel h2 { margin: 0 0 6px; font-size: 20px; }
.record-panel > p { margin: 0; color: #6f7773; font: 13px/1.55 "PingFang SC", sans-serif; }
.record-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 15px; }
.record-actions button { min-height: 52px; border: 1px solid #ccbfae; border-radius: 14px; background: #f1e8da; font: 700 14px "PingFang SC", sans-serif; cursor: pointer; }
.record-actions .record-button { background: var(--coral); color: white; border-color: var(--coral); }
.record-actions .record-button.recording { animation: recordPulse 1.2s ease infinite; }
@keyframes recordPulse { 50% { box-shadow: 0 0 0 7px rgba(232,120,89,.18); } }
.record-actions button:disabled { opacity: .42; cursor: not-allowed; }
.phrase-nav { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 8px; margin-top: 14px; }
.phrase-nav button { min-height: 52px; border: 1px solid #cfc4b5; border-radius: 14px; background: var(--card); font: 700 14px "PingFang SC", sans-serif; cursor: pointer; }
.phrase-nav .done-button { background: var(--green); color: white; border-color: var(--green); }
.phrase-nav .done-button.done { background: #dce9e2; color: #1e5a48; border-color: #a9c4b7; }
.practice-note { margin-top: 15px; padding: 18px; border-radius: 18px; background: #f0dfb5; }
.practice-note strong { color: #8d6623; font: 700 12px "PingFang SC", sans-serif; letter-spacing: .08em; }
.practice-note p { margin: 7px 0 0; font: 14px/1.65 "PingFang SC", sans-serif; }
.aussie-note { margin-top: 10px; padding: 18px; border-radius: 18px; background: #dce9e3; }
.aussie-note strong { color: #2f6756; font: 700 12px "PingFang SC", sans-serif; letter-spacing: .08em; }
.aussie-note p { margin: 7px 0 0; font: 14px/1.65 "PingFang SC", sans-serif; }

.dialogue-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 15px; }
.dialogue-toolbar p { margin: 0; color: #727974; font: 12px "PingFang SC", sans-serif; }
.dialogue-toolbar button { min-height: 43px; border: 0; border-radius: 999px; padding: 0 16px; background: var(--green); color: white; font: 700 13px "PingFang SC", sans-serif; cursor: pointer; }
.dialogue-list { display: grid; gap: 10px; margin-top: 13px; }
.dialogue-line { position: relative; padding: 18px 58px 18px 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); }
.dialogue-line.you { border-color: #bfd1c8; background: #e2ede7; }
.dialogue-role { color: #9b6852; font: 700 11px "PingFang SC", sans-serif; letter-spacing: .08em; }
.dialogue-line p { margin: 7px 0 5px; font: 20px/1.45 Georgia, serif; }
.dialogue-line small { color: #66726c; font: 13px/1.55 "PingFang SC", sans-serif; }
.line-play { position: absolute; right: 13px; top: 50%; width: 38px; height: 38px; transform: translateY(-50%); border: 1px solid #c8bca9; border-radius: 50%; background: #fffaf1; cursor: pointer; }

.empty-state { padding: 50px 24px; border: 1px dashed #c9bca9; border-radius: 24px; text-align: center; background: rgba(255,250,241,.55); }
.empty-state span { width: 60px; height: 60px; display: grid; place-items: center; margin: 0 auto 15px; border-radius: 50%; background: #eee0d2; font-size: 26px; }
.empty-state h2 { margin: 0 0 8px; }
.empty-state p { margin: 0; color: var(--ink-soft); font: 14px/1.6 "PingFang SC", sans-serif; }
.empty-state button { min-height: 46px; margin-top: 18px; padding: 0 20px; border: 0; border-radius: 999px; background: var(--green); color: white; font: 700 14px "PingFang SC", sans-serif; cursor: pointer; }

.plan-list { display: grid; gap: 9px; }
.plan-item { width: 100%; display: grid; grid-template-columns: 48px 1fr 30px; align-items: center; gap: 12px; min-height: 72px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 17px; background: var(--card); text-align: left; cursor: pointer; }
.plan-day { color: #a15d47; font: 700 13px Georgia, serif; }
.plan-item strong { font: 15px/1.45 "PingFang SC", sans-serif; }
.plan-check { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid #c8bba9; border-radius: 50%; }
.plan-item.done { background: #e1ece6; }
.plan-item.done .plan-check { background: var(--green); color: white; border-color: var(--green); }

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 40;
  width: min(calc(100% - 22px), 520px);
  min-height: 66px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  transform: translateX(-50%);
  padding: 6px;
  border: 1px solid rgba(203,192,176,.88);
  border-radius: 21px;
  background: rgba(255,250,242,.94);
  box-shadow: 0 18px 45px rgba(37,48,42,.18);
  backdrop-filter: blur(18px);
}
.bottom-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; border-radius: 15px; background: transparent; color: #747a76; font: 700 10px "PingFang SC", sans-serif; cursor: pointer; }
.bottom-nav button span { font: 21px Georgia, serif; }
.bottom-nav button.active { background: var(--green); color: white; }
.bottom-nav button.active span { color: var(--gold); }
.toast { position: fixed; left: 50%; bottom: 92px; z-index: 80; max-width: calc(100% - 36px); transform: translate(-50%, 14px); padding: 12px 17px; border-radius: 999px; background: #102d26; color: white; opacity: 0; pointer-events: none; font: 13px "PingFang SC", sans-serif; transition: .25s ease; box-shadow: 0 13px 35px rgba(0,0,0,.2); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) {
  .view { padding: 40px 34px 70px; }
  .quick-grid { grid-template-columns: repeat(4, 1fr); }
  .chapter-grid { grid-template-columns: 1fr 1fr; }
  .scene-list { grid-template-columns: 1fr 1fr; }
  .practice-card { padding: 34px; }
  .lesson-view { max-width: 820px; margin: 0 auto; }
  .dialogue-line { padding: 22px 70px 22px 22px; }
}

@media (min-width: 1080px) {
  .app-shell { padding-bottom: 0; }
  .topbar { padding-inline: 38px; }
  .bottom-nav { left: 26px; top: 110px; bottom: auto; width: 102px; min-height: auto; grid-template-columns: 1fr; transform: none; padding: 8px; border-radius: 24px; }
  .bottom-nav button { min-height: 67px; }
  main { padding-left: 110px; }
  .toast { bottom: 28px; }
}

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