:root {
  color-scheme: light;
  --ink: #17302b;
  --muted: #66736d;
  --paper: #f4f1e9;
  --card: #fffdf8;
  --green: #173f35;
  --green-2: #235e4e;
  --mint: #d8efe4;
  --coral: #f27550;
  --coral-soft: #ffe1d6;
  --gold: #f4bd4f;
  --gold-soft: #fff0c9;
  --blue: #3c6b92;
  --line: rgba(23, 48, 43, 0.12);
  --shadow: 0 18px 55px rgba(31, 54, 48, 0.1);
  --radius: 24px;
  font-family: Inter, ui-rounded, "SF Pro Rounded", "PingFang HK", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(242, 117, 80, 0.45);
  outline-offset: 3px;
}
[hidden] { display: none !important; }

.skip-link { position: fixed; left: 12px; top: -60px; z-index: 99; padding: 10px 14px; color: white; background: var(--green); border-radius: 10px; }
.skip-link:focus { top: 12px; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between;
  min-height: 70px; padding: 10px max(18px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 15px; color: white; background: var(--green); font-weight: 900; font-size: 22px; transform: rotate(-3deg); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 18px; letter-spacing: 0.03em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }

.icon-button, .text-button, .chip-button { border: 0; color: var(--green); background: transparent; cursor: pointer; }
.icon-button { min-width: 44px; min-height: 44px; padding: 9px; border: 1px solid var(--line); border-radius: 14px; }
.text-button { padding: 8px 0; font-weight: 760; }
.chip-button { padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); font-size: 13px; font-weight: 740; }

.gate-shell { max-width: 1080px; min-height: calc(100vh - 71px); margin: 0 auto; padding: 34px 20px 70px; display: grid; align-items: center; gap: 28px; }
.gate-art { position: relative; min-height: 230px; border-radius: 34px; overflow: hidden; background: var(--green); box-shadow: var(--shadow); }
.gate-art::before, .gate-art::after { content: ""; position: absolute; border-radius: 50%; }
.gate-art::before { width: 240px; height: 240px; right: -45px; top: -75px; background: var(--gold); }
.gate-art::after { width: 210px; height: 210px; left: -65px; bottom: -105px; background: var(--coral); }
.gate-art span { position: absolute; z-index: 1; display: grid; place-items: center; width: 105px; height: 105px; border-radius: 34px; color: var(--green); background: #fff9ed; font-size: 46px; font-weight: 900; box-shadow: 0 16px 30px rgba(0,0,0,.15); }
.gate-art span:nth-child(1) { left: 10%; top: 13%; transform: rotate(-9deg); }
.gate-art span:nth-child(2) { left: 39%; top: 39%; transform: rotate(4deg); }
.gate-art span:nth-child(3) { right: 10%; bottom: 11%; transform: rotate(-4deg); }
.eyebrow { margin: 0 0 8px; color: var(--green-2); font-size: 12px; line-height: 1.2; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.eyebrow.coral { color: #b23c22; }
.eyebrow.teal { color: #176b61; }
.eyebrow.gold { color: #8b5b00; }
.eyebrow.light { color: #bce6d7; }
.gate-copy h1, .page-heading h1, .route-hero h1 { margin: 0; letter-spacing: -.045em; }
.gate-copy h1 { font-size: clamp(38px, 10vw, 64px); line-height: .98; }
.lead { font-size: 18px; line-height: 1.7; color: #455751; }
.trust-list { margin: 22px 0; padding: 0; display: grid; gap: 12px; list-style: none; }
.trust-list li { position: relative; padding-left: 28px; color: #40524c; line-height: 1.55; }
.trust-list li::before { content: "✓"; position: absolute; left: 0; display: grid; place-items: center; width: 20px; height: 20px; color: white; background: var(--green-2); border-radius: 50%; font-size: 12px; font-weight: 900; }
.consent-row { display: flex; gap: 11px; align-items: flex-start; margin: 24px 0 16px; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; line-height: 1.5; }
.consent-row input, .check-card input, .setting-row input { width: 20px; height: 20px; accent-color: var(--green); flex: 0 0 auto; }

.primary-button, .secondary-button, .danger-button, .next-button {
  border: 0; border-radius: 16px; min-height: 48px; padding: 12px 18px; font-weight: 800; cursor: pointer; transition: transform .16s ease, filter .16s ease;
}
.primary-button { color: white; background: var(--green); box-shadow: 0 8px 20px rgba(23,63,53,.2); }
.primary-button:hover, .secondary-button:hover, .next-button:hover { transform: translateY(-1px); filter: brightness(1.04); }
.primary-button:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.secondary-button { color: var(--green); background: var(--mint); }
.secondary-button:disabled { opacity: .45; cursor: not-allowed; }
.danger-button { color: #a42e20; background: #fff0ec; border: 1px solid #f3c2b7; }
.wide { width: 100%; }

.route-shell, .content-shell { width: min(940px, 100%); margin: 0 auto; padding: 32px 18px 110px; }
.page-heading { max-width: 680px; margin-bottom: 28px; }
.page-heading h1 { font-size: clamp(34px, 8vw, 56px); }
.page-heading p:last-child { color: var(--muted); line-height: 1.65; }
.route-grid { display: grid; gap: 16px; }
.route-card { position: relative; overflow: hidden; min-height: 190px; padding: 24px; border: 1px solid var(--line); border-radius: 26px; color: var(--ink); background: var(--card); box-shadow: 0 8px 28px rgba(31,54,48,.07); cursor: pointer; text-align: left; }
.route-card::after { content: ""; position: absolute; right: -40px; bottom: -55px; width: 160px; height: 160px; border-radius: 50%; background: var(--route-color, var(--mint)); opacity: .75; }
.route-card .route-icon { display: block; margin-bottom: 22px; font-size: 36px; }
.route-card h2 { max-width: 80%; margin: 0 0 10px; font-size: 25px; line-height: 1.1; }
.route-card p { max-width: 78%; margin: 0; color: var(--muted); line-height: 1.55; }
.route-card .route-meta { display: inline-flex; margin-top: 18px; padding: 6px 10px; border-radius: 999px; color: var(--green); background: var(--mint); font-size: 12px; font-weight: 800; }

.route-hero { padding: 20px max(18px, env(safe-area-inset-left)) 24px; color: white; background: var(--green); }
.route-hero > * { width: min(940px, 100%); margin-left: auto; margin-right: auto; }
.route-hero .text-button { color: #d7ede5; }
.hero-grid { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; margin-top: 16px; }
.route-hero h1 { max-width: 680px; font-size: clamp(30px, 7.5vw, 50px); line-height: 1.03; }
.hero-promise { max-width: 680px; margin: 14px 0 0; color: #d8e8e2; line-height: 1.55; }
.route-orb { display: none; place-items: center; width: 112px; height: 112px; border-radius: 38px; background: var(--gold); transform: rotate(5deg); font-size: 52px; }
.progress-wrap { margin-top: 24px; }
.progress-wrap > div:first-child { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; color: #bed5cc; font-size: 12px; }
.progress-wrap #progressLabel { color: white; font-weight: 850; }
.progress-track { height: 8px; overflow: hidden; background: rgba(255,255,255,.15); border-radius: 999px; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--gold); border-radius: inherit; transition: width .25s ease; }

.stage-tabs { position: sticky; top: 70px; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr); padding: 9px max(8px, env(safe-area-inset-left)); background: rgba(255,253,248,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px); }
.stage-tab { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 50px; padding: 5px; border: 0; color: #82908a; background: transparent; font-size: 11px; font-weight: 750; cursor: pointer; }
.stage-tab span { display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid #b8c3be; border-radius: 50%; }
.stage-tab.active { color: var(--green); }
.stage-tab.active span { color: white; background: var(--green); border-color: var(--green); }
.stage { display: none; animation: lift .25s ease both; }
.stage.active { display: block; }
@keyframes lift { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.section-heading { margin: 0 0 20px; }
.section-heading.compact { margin-bottom: 14px; }
.section-heading.split { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.section-heading h2, .section-heading h3 { margin: 0; letter-spacing: -.025em; }
.section-heading h2 { font-size: clamp(28px, 6.5vw, 40px); }
.section-heading h3 { font-size: 22px; }
.section-heading > p:last-child { color: var(--muted); line-height: 1.55; }
.mission-card, .roadmap-card, .audio-feature-card, .check-card, .vocab-card, .record-card, .micro-card, .feedback-summary-card, .ability-card, .version-card, .data-card {
  margin-bottom: 18px; padding: 21px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: 0 8px 28px rgba(31,54,48,.05);
}
.mission-card { display: grid; gap: 20px; }
.mission-card > div:first-child { padding: 20px; border-radius: 18px; background: var(--mint); }
.mission-card p { margin: 8px 0 0; font-size: 20px; line-height: 1.5; font-weight: 760; }
.roadmap-card { background: linear-gradient(145deg, #f8fffb, #edf7f2); }
.roadmap-promise { margin: 0 0 16px; color: var(--muted); line-height: 1.6; }
.course-count { flex: 0 0 auto; padding: 7px 10px; border-radius: 999px; color: var(--green); background: var(--mint); font-size: 12px; font-weight: 850; }
.course-unit-list { display: grid; gap: 10px; }
.course-unit { display: grid; grid-template-columns: 38px 1fr; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.82); }
.course-unit-index { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; color: var(--green); background: var(--mint); font-size: 12px; font-weight: 900; }
.course-unit.playable_candidate { border-color: #82b7a4; background: #f4fff9; }
.course-unit.next_production_blueprint { border-color: #edc56a; background: #fffaf0; }
.course-unit-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.course-unit-head strong { font-size: 15px; line-height: 1.4; }
.course-unit-head span { flex: 0 0 auto; padding: 4px 7px; border-radius: 999px; color: var(--muted); background: #f1f3ef; font-size: 9px; font-weight: 850; }
.course-open-button { margin-top: 10px; border: 0; border-radius: 999px; padding: 9px 14px; background: var(--green); color: #fff; font: inherit; font-size: 12px; font-weight: 850; cursor: pointer; }
.course-open-button:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.course-unit.playable_candidate .course-unit-head span { color: #176b61; background: #dff3ea; }
.course-unit.next_production_blueprint .course-unit-head span { color: #80531c; background: #fff0c6; }
.course-unit p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.course-unit details { margin-top: 9px; }
.course-unit summary { color: var(--green); font-size: 12px; font-weight: 800; cursor: pointer; }
.course-unit dl { margin: 10px 0 0; display: grid; gap: 7px; }
.course-unit dl div { display: grid; grid-template-columns: 65px 1fr; gap: 8px; font-size: 11px; line-height: 1.5; }
.course-unit dt { color: var(--muted); font-weight: 780; }
.course-unit dd { margin: 0; color: #384a44; }
.mini-label { color: var(--green-2); font-size: 12px; font-weight: 850; letter-spacing: .08em; }
.scope-grid { display: grid; gap: 16px; }
.scope-grid strong { display: block; margin-bottom: 8px; }
.scope-grid ul { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.7; }
.audio-feature-card { background: linear-gradient(145deg, #fffdf8 20%, #fff1d1); }
.audio-feature-card h3, .record-card h3, .micro-card h3, .data-card h3 { margin: 0 0 8px; font-size: 23px; }
.audio-feature-card p, .record-card p, .micro-card p { color: var(--muted); line-height: 1.55; }
.audio-actions, .record-actions, .data-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.dialogue-details { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.dialogue-details summary { color: var(--green); font-weight: 800; cursor: pointer; }
.dialogue-list { display: grid; gap: 10px; margin-top: 14px; }
.dialogue-row { max-width: 86%; padding: 12px 14px; border-radius: 5px 18px 18px 18px; background: #ecf3ef; line-height: 1.5; }
.dialogue-row.mine { justify-self: end; border-radius: 18px 5px 18px 18px; background: var(--coral-soft); }
.dialogue-row strong { display: block; margin-bottom: 3px; color: var(--muted); font-size: 11px; }
.check-card { display: grid; gap: 12px; background: #eaf5ef; }
.check-card label { display: flex; align-items: flex-start; gap: 11px; line-height: 1.5; font-weight: 680; }
.next-button { width: 100%; color: var(--green); background: transparent; border: 1px dashed var(--green-2); }

.phrase-list { display: grid; gap: 16px; }
.phrase-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: 0 8px 28px rgba(31,54,48,.05); }
.phrase-top { padding: 18px 20px 16px; }
.phrase-kind { display: inline-flex; padding: 5px 9px; border-radius: 999px; color: #8d321e; background: var(--coral-soft); font-size: 11px; font-weight: 850; }
.phrase-card h3 { margin: 14px 0 8px; font-family: "PingFang HK", "Noto Sans CJK TC", sans-serif; font-size: clamp(27px, 7.5vw, 38px); line-height: 1.28; letter-spacing: .015em; }
.phrase-card .jyutping { margin: 0 0 6px; color: var(--blue); font-size: 16px; line-height: 1.55; font-weight: 720; }
.phrase-card .mandarin { margin: 0; color: var(--muted); line-height: 1.5; }
.phrase-when { margin: 15px 0 0; padding-top: 12px; border-top: 1px solid var(--line); color: #44534e; font-size: 13px; line-height: 1.55; }
.phrase-actions { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; padding: 12px; background: #f7f6f1; border-top: 1px solid var(--line); }
.phrase-actions button { min-height: 44px; padding: 8px 11px; border-radius: 13px; border: 0; font-weight: 760; cursor: pointer; }
.play-button { color: white; background: var(--green); }
.slow-button { color: var(--green); background: var(--mint); }
.feedback-button { color: #8d321e; background: var(--coral-soft); }
.vocab-card { margin-top: 20px; }
.vocab-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.vocab-item { padding: 13px 8px; border: 0; border-radius: 16px; color: var(--green); background: var(--mint); text-align: center; cursor: pointer; }
.vocab-item strong, .vocab-item small { display: block; }
.vocab-item strong { font-size: 18px; }
.vocab-item small { margin-top: 4px; color: var(--green-2); font-size: 11px; }
.record-card { background: linear-gradient(145deg, #e7f4ee, #f8fff9); }
.status-text { color: var(--muted); font-size: 13px; line-height: 1.55; }

.branch-list { display: grid; gap: 18px; }
.branch-card { padding: 20px; border-radius: var(--radius); background: var(--green); color: white; box-shadow: var(--shadow); }
.branch-number { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; color: var(--green); background: var(--gold); font-weight: 900; }
.branch-card .counterpart { margin: 16px 0 4px; color: #b9d6cd; font-size: 12px; font-weight: 800; }
.branch-card blockquote { margin: 0; font-family: "PingFang HK", sans-serif; font-size: 24px; line-height: 1.45; font-weight: 760; }
.branch-card .branch-jyutping { color: #bce6d7; line-height: 1.55; }
.branch-card .branch-meaning { color: #e0ebe7; }
.branch-move { margin-top: 16px; padding: 14px; border-radius: 16px; color: var(--ink); background: white; line-height: 1.55; }
.branch-actions { display: flex; gap: 8px; margin-top: 12px; }
.branch-actions button { min-height: 42px; border-radius: 12px; border: 0; padding: 8px 12px; font-weight: 760; cursor: pointer; }
.micro-card { margin-top: 22px; background: var(--gold-soft); }
.micro-list details { margin-top: 10px; padding: 13px 0; border-top: 1px solid rgba(110,75,12,.16); }
.micro-list summary { font-weight: 820; cursor: pointer; }
.micro-list p { margin-bottom: 0; color: #604a20; }

.feedback-summary-card { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; background: var(--green); color: white; }
.feedback-summary-card div { padding: 10px 5px; }
.feedback-summary-card strong, .feedback-summary-card span { display: block; }
.feedback-summary-card strong { font-size: 25px; }
.feedback-summary-card span { margin-top: 4px; color: #bad4cb; font-size: 10px; }
.switch-row { display: flex; gap: 7px; align-items: center; color: var(--green); font-weight: 760; }
.switch-row input { width: 38px; height: 22px; accent-color: var(--green); }
.ability-choice-list { display: grid; gap: 10px; }
.ability-choice { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; }
.ability-choice strong { font-size: 15px; }
.ability-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ability-buttons button { min-height: 40px; border: 1px solid var(--line); border-radius: 12px; background: #f5f6f2; color: var(--ink); font-size: 12px; font-weight: 760; cursor: pointer; }
.ability-buttons button.active { color: white; background: var(--green); }
.ability-records { margin-top: 14px; }
.ability-record { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 13px; }
.ability-record button { border: 0; color: #9f3021; background: transparent; cursor: pointer; }
.feedback-records { display: grid; gap: 10px; }
.feedback-record { padding: 13px; border: 1px solid var(--line); border-radius: 15px; background: #faf9f5; }
.feedback-record header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.feedback-record strong { font-size: 13px; }
.feedback-record .feedback-status { padding: 4px 7px; border-radius: 999px; color: #80531c; background: var(--gold-soft); font-size: 10px; font-weight: 820; }
.feedback-record p { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.feedback-record button { margin-top: 8px; padding: 0; border: 0; color: #9f3021; background: transparent; font-size: 12px; cursor: pointer; }
.empty-state { padding: 14px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); font-size: 13px; text-align: center; }
.version-list { margin: 0; padding-left: 24px; }
.version-list li { padding: 5px 0; color: var(--muted); line-height: 1.5; }
.completion-status { min-height: 22px; color: var(--green); text-align: center; line-height: 1.55; font-weight: 760; }
.handoff-card { margin: 18px 0; padding: 18px; border: 1px solid #f1c9bc; border-radius: 20px; background: #fff8f4; }
.handoff-card h3 { margin: 0; font-size: 22px; }
.handoff-card > p, .handoff-scope { color: var(--muted); font-size: 13px; line-height: 1.65; }
.handoff-scope { padding-left: 20px; }
.consent-row.compact { margin: 14px 0; padding: 12px; font-size: 13px; }
.handoff-records { display: grid; gap: 9px; margin-top: 12px; }
.handoff-record { padding: 11px; border: 1px solid var(--line); border-radius: 13px; background: white; font-size: 12px; }
.handoff-record strong, .handoff-record span { display: block; }
.handoff-record span { margin: 4px 0 8px; color: var(--muted); overflow-wrap: anywhere; }
.handoff-record button { padding: 0; border: 0; color: #9f3021; background: transparent; cursor: pointer; }
.data-actions > * { flex: 1 1 160px; }
.product-footer { padding: 25px 18px calc(34px + env(safe-area-inset-bottom)); color: var(--muted); text-align: center; font-size: 12px; }

.sheet-dialog { width: min(620px, calc(100% - 22px)); max-height: 90vh; margin: auto auto 8px; padding: 0; overflow: auto; border: 0; border-radius: 28px 28px 18px 18px; color: var(--ink); background: var(--card); box-shadow: 0 25px 70px rgba(0,0,0,.28); }
.sheet-dialog::backdrop { background: rgba(12,27,23,.58); backdrop-filter: blur(4px); }
.sheet-dialog form { padding: 22px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.dialog-head h2 { margin: 0; font-size: 27px; }
.sheet-dialog label { display: grid; gap: 8px; margin: 15px 0; color: #3d4c47; font-weight: 740; }
.sheet-dialog select, .sheet-dialog textarea { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 12px; color: var(--ink); background: white; }
.sheet-dialog textarea { min-height: 110px; resize: vertical; }
.dialog-note { color: var(--muted); font-size: 12px; line-height: 1.55; }
.privacy-list { padding-left: 20px; color: #42534d; line-height: 1.65; }
.privacy-list li { margin-bottom: 10px; }
.setting-row { display: flex !important; grid-template-columns: auto 1fr; align-items: flex-start; gap: 12px !important; padding: 14px; border: 1px solid var(--line); border-radius: 16px; }
.setting-row span strong, .setting-row span small { display: block; }
.setting-row span small { margin-top: 3px; color: var(--muted); font-weight: 500; }
.is-hidden-support { display: none !important; }

@media (min-width: 720px) {
  .gate-shell { grid-template-columns: minmax(300px, .9fr) minmax(360px, 1.1fr); padding: 55px 34px 90px; }
  .gate-art { min-height: 560px; }
  .gate-art span { width: 130px; height: 130px; font-size: 56px; }
  .route-grid { grid-template-columns: repeat(3, 1fr); }
  .route-card { min-height: 260px; }
  .route-card h2 { font-size: 29px; }
  .route-orb { display: grid; }
  .scope-grid { grid-template-columns: 1fr 1fr; }
  .course-unit-list { grid-template-columns: 1fr 1fr; }
  .phrase-list { grid-template-columns: 1fr 1fr; }
  .branch-list { grid-template-columns: repeat(3, 1fr); }
  .branch-card blockquote { font-size: 21px; }
  .sheet-dialog { margin: auto; border-radius: 28px; }
}

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