/* =========================================================
   HanTown · pixel-flavoured learning game UI
   Palette: ink / rice paper / vermilion / jade / brass
   ========================================================= */
:root {
  --night: #0b0f15;
  --night-2: #111722;
  --night-3: #1a2230;
  --ink: #1c2028;
  --ink-2: #2b313d;
  --paper: #f7f0e2;
  --paper-2: #efe4cf;
  --paper-3: #e5d6ba;
  --line: #c8b99f;
  --red: #d8563f;
  --red-dark: #a83a28;
  --jade: #3f9f86;
  --jade-dark: #2b7864;
  --gold: #e7b75e;
  --muted: #7d7566;
  --white: #fffaf0;
  --shadow: 4px 4px 0 rgba(12, 15, 20, .9);
  --shadow-soft: 4px 4px 0 rgba(12, 15, 20, .28);
  --radius: 3px;
  --font-ui: "Inter", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-zh: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Songti SC", serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--paper);
  font-family: var(--font-ui);
  background:
    radial-gradient(1200px 700px at 78% -10%, rgba(216, 86, 63, .16), transparent 60%),
    radial-gradient(900px 600px at 8% 110%, rgba(63, 159, 134, .12), transparent 60%),
    var(--night);
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.022) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: linear-gradient(180deg, #000, rgba(0,0,0,.4));
}
img, canvas { display: block; }
button { font: inherit; }
a { color: inherit; }
.hidden { display: none !important; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; fill: currentColor; flex: 0 0 auto; }

/* ---------------- topbar ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 12px clamp(16px, 4vw, 44px);
  background: rgba(11, 15, 21, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(247, 240, 226, .14);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.seal {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: var(--red);
  color: var(--white);
  font-family: var(--font-zh);
  font-size: 26px;
  font-weight: 800;
  border: 2px solid #7d2719;
  box-shadow: inset 0 0 0 2px rgba(255, 250, 240, .22), 2px 2px 0 rgba(0,0,0,.5);
  clip-path: polygon(0 6px, 6px 6px, 6px 0, calc(100% - 6px) 0, calc(100% - 6px) 6px, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 6px calc(100% - 6px), 0 calc(100% - 6px));
  flex: 0 0 auto;
}
.seal.small { width: 34px; height: 34px; font-size: 20px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 18px; letter-spacing: .08em; }
.brand-text small { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: rgba(247,240,226,.55); margin-top: 3px; }

.nav { display: flex; gap: 4px; margin-left: 6px; }
.nav-item {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 9px 13px;
  background: transparent;
  border: 1px solid transparent;
  color: rgba(247, 240, 226, .66);
  cursor: pointer;
  border-radius: 2px;
  letter-spacing: .02em;
}
.nav-item em { font-style: normal; font-family: var(--font-zh); font-size: 11px; opacity: .55; }
.nav-item:hover { color: var(--paper); border-color: rgba(247,240,226,.2); }
.nav-item.is-active { color: var(--white); background: rgba(247,240,226,.09); border-color: rgba(247,240,226,.22); }
.nav-item.is-active em { color: var(--gold); opacity: 1; }

.topstats { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.stat-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 11px;
  border: 1px solid rgba(247,240,226,.2);
  background: rgba(247,240,226,.05);
  font-size: 13px;
  color: var(--gold);
}
.stat-pill b { color: var(--paper); font-variant-numeric: tabular-nums; }
.icon-btn {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border: 1px solid rgba(247,240,226,.22);
  background: rgba(247,240,226,.06);
  color: var(--paper);
  cursor: pointer;
  border-radius: 2px;
}
.icon-btn:hover { background: rgba(247,240,226,.14); }
.icon-btn.on-dark { background: rgba(12,15,20,.72); border-color: rgba(247,240,226,.3); }

/* ---------------- layout ---------------- */
.view {
  position: relative;
  z-index: 1;
  width: min(1180px, 92vw);
  margin: 0 auto;
  padding: clamp(22px, 4vw, 44px) 0 30px;
  outline: none;
}
.view-enter { animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.footer {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  justify-content: space-between;
  padding: 26px clamp(16px, 4vw, 44px) 34px;
  border-top: 1px solid rgba(247,240,226,.1);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: rgba(247,240,226,.38);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 10px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--red);
  font-weight: 700;
}
.muted { color: var(--muted); }
.fine { font-size: 11px; line-height: 1.55; color: var(--muted); margin: 12px 0 0; }
h1, h2, h3 { margin: 0; line-height: 1.12; letter-spacing: -.01em; }
h1 { font-size: clamp(30px, 4.4vw, 52px); font-weight: 800; }
h2 { font-size: clamp(22px, 2.6vw, 32px); font-weight: 800; }
h3 { font-size: 17px; font-weight: 750; }
.lead { color: rgba(247,240,226,.7); font-size: 15px; line-height: 1.65; max-width: 54ch; }

.paper {
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}
.paper h2, .paper h3, .paper h1 { color: var(--ink); }
.paper .muted { color: var(--muted); }
.paper .eyebrow { color: var(--red-dark); }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 18px;
  min-height: 44px;
  border: 2px solid var(--ink);
  border-radius: 2px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 750;
  letter-spacing: .01em;
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(12,15,20,.85);
  transition: transform .08s ease, box-shadow .08s ease, background .15s;
  text-decoration: none;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 rgba(12,15,20,.85); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(12,15,20,.85); }
.btn.primary { background: var(--red); border-color: #762617; color: var(--white); box-shadow: 3px 3px 0 #762617; }
.btn.primary:hover { background: #e2634b; box-shadow: 4px 4px 0 #762617; }
.btn.jade { background: var(--jade); border-color: var(--jade-dark); color: var(--white); box-shadow: 3px 3px 0 var(--jade-dark); }
.btn.dark { background: var(--ink); border-color: #05070a; color: var(--paper); box-shadow: 3px 3px 0 #05070a; }
.btn.ghost { background: transparent; box-shadow: none; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: rgba(28,32,40,.06); transform: none; }
.btn.on-dark.ghost { color: var(--paper); border-color: rgba(247,240,226,.35); }
.btn.small { padding: 8px 12px; min-height: 36px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn.danger { background: #f7e0da; border-color: var(--red-dark); color: var(--red-dark); box-shadow: 3px 3px 0 var(--red-dark); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: 3px 3px 0 rgba(12,15,20,.4); }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.icon-inline { display: inline-flex; align-items: center; gap: 8px; }

/* ---------------- dashboard ---------------- */
.hello { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 26px; }
.hello .today-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 11px; margin-bottom: 12px;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  border: 1px solid rgba(247,240,226,.25); color: rgba(247,240,226,.7);
}
.hello .today-chip b { color: var(--gold); }
.hello h1 span { color: var(--gold); }
.quick-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.qstat {
  min-width: 108px;
  padding: 10px 14px;
  border-left: 2px solid var(--red);
  background: rgba(247,240,226,.05);
}
.qstat b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; line-height: 1; color: var(--white); }
.qstat span { display: block; margin-top: 5px; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: rgba(247,240,226,.5); }

.hero { display: grid; grid-template-columns: 1.02fr .98fr; gap: 22px; align-items: stretch; margin-bottom: 28px; }
.hero-card { padding: clamp(20px, 3vw, 30px); display: flex; flex-direction: column; gap: 16px; position: relative; overflow: hidden; }
.hero-card::after {
  content: "汉";
  position: absolute; right: -8px; bottom: -34px;
  font-family: var(--font-zh); font-size: 150px; font-weight: 900;
  color: rgba(28,32,40,.05); line-height: 1; pointer-events: none;
}
.hero-card .meta-row { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; position: relative; z-index: 1; }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px;
  font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  border: 1px solid var(--ink); background: transparent; color: var(--ink);
  white-space: nowrap;
}
.tag.solid { background: var(--ink); color: var(--paper); }
.tag.red { background: var(--red); border-color: var(--red-dark); color: var(--white); }
.tag.jade { background: var(--jade); border-color: var(--jade-dark); color: var(--white); }
.tag.gold { background: var(--gold); border-color: #a97c2e; color: var(--ink); }
.hero-card h2 { position: relative; z-index: 1; }
.hero-card .zh-title { font-family: var(--font-zh); font-size: 19px; color: var(--red-dark); margin-top: -6px; position: relative; z-index: 1; }
.hero-card .goal { font-size: 14px; line-height: 1.6; color: #4d4a42; position: relative; z-index: 1; }
.hero-card .btn-row { margin-top: auto; position: relative; z-index: 1; }
.hero-mini { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); position: relative; z-index: 1; }
.hero-mini b { color: var(--ink); }

.scene-frame {
  position: relative;
  background: #080a0e;
  border: 2px solid #05070a;
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 240px;
  display: flex;
}
.scene-frame canvas { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.scene-frame::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0,0,0,.22), transparent 22%, transparent 74%, rgba(0,0,0,.42)),
    repeating-linear-gradient(0deg, rgba(0,0,0,.16) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
.scene-tag {
  position: absolute; left: 12px; bottom: 12px; z-index: 2;
  padding: 6px 10px;
  background: rgba(11,15,21,.8);
  border: 1px solid rgba(247,240,226,.25);
  color: var(--paper);
  font-size: 11px; letter-spacing: .08em;
}
.scene-tag b { font-family: var(--font-zh); color: var(--gold); margin-right: 7px; }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 34px 0 14px; }
.section-head h2 { font-size: 20px; }
.section-head .link {
  background: none; border: 0; color: var(--gold); cursor: pointer;
  font-size: 12px; letter-spacing: .06em; text-transform: uppercase; text-decoration: none;
  border-bottom: 1px solid rgba(231,183,94,.4); padding-bottom: 2px;
}
.section-head .link:hover { color: var(--paper); }

.plan-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.plan-mini {
  padding: 14px;
  border: 1px solid rgba(247,240,226,.14);
  background: rgba(247,240,226,.04);
  display: flex; flex-direction: column; gap: 7px;
  min-height: 116px;
}
.plan-mini.is-done { background: rgba(63,159,134,.1); border-color: rgba(63,159,134,.4); }
.plan-mini.is-today { background: rgba(216,86,63,.12); border-color: rgba(216,86,63,.5); }
.plan-mini .d { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: rgba(247,240,226,.5); }
.plan-mini b { font-size: 14px; line-height: 1.35; }
.plan-mini span { font-size: 11px; color: rgba(247,240,226,.55); }
.plan-mini .done-mark { color: var(--jade); display: inline-flex; align-items: center; gap: 4px; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }

/* ---------------- scene grid / archive / plan ---------------- */
.scene-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 16px; }
.scene-card {
  background: var(--paper); color: var(--ink); border: 2px solid var(--ink);
  box-shadow: var(--shadow); display: flex; flex-direction: column;
  transition: transform .12s ease, box-shadow .12s ease;
}
.scene-card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 rgba(12,15,20,.9); }
.scene-card .thumb { height: 128px; background: #080a0e; position: relative; overflow: hidden; border-bottom: 2px solid var(--ink); }
.scene-card .thumb canvas { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.scene-card .thumb .no { position: absolute; left: 8px; top: 8px; padding: 3px 6px; background: rgba(11,15,21,.75); color: var(--paper); font-size: 10px; letter-spacing: .1em; }
.scene-card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.scene-card h3 { display: flex; align-items: baseline; gap: 8px; }
.scene-card h3 em { font-style: normal; font-family: var(--font-zh); font-size: 15px; color: var(--red-dark); }
.scene-card p { margin: 0; font-size: 12px; line-height: 1.55; color: var(--muted); }
.scene-card .btn { margin-top: auto; }
.scene-card .lesson-line { font-size: 11px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 9px; }

.archive-list { display: flex; flex-direction: column; gap: 10px; }
.archive-row {
  display: grid;
  grid-template-columns: 78px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(12,15,20,.75);
}
.archive-row .date { border-right: 1px solid var(--line); padding-right: 12px; }
.archive-row .date b { display: block; font-size: 24px; line-height: 1; font-variant-numeric: tabular-nums; }
.archive-row .date span { display: block; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.archive-row .what { min-width: 0; }
.archive-row .what h3 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.archive-row .what h3 em { font-style: normal; font-family: var(--font-zh); font-size: 14px; color: var(--red-dark); }
.archive-row .what p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.archive-row .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.archive-row .result { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.archive-row .result .score { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.archive-row .result .score small { font-size: 10px; font-weight: 600; color: var(--muted); }
.archive-row .result .new { color: var(--red-dark); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; font-weight: 800; }

.filter-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.filter {
  padding: 7px 12px; border: 1px solid rgba(247,240,226,.25);
  background: transparent; color: rgba(247,240,226,.65); cursor: pointer;
  font-size: 12px; letter-spacing: .04em;
}
.filter:hover { border-color: rgba(247,240,226,.55); color: var(--paper); }
.filter.is-on { background: var(--paper); color: var(--ink); border-color: var(--paper); font-weight: 700; }

.plan-layout { display: grid; grid-template-columns: 1.3fr .7fr; gap: 22px; align-items: start; }
.plan-days { display: flex; flex-direction: column; gap: 10px; }
.plan-day {
  display: grid; grid-template-columns: 54px 1fr; gap: 14px;
  padding: 14px 16px;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 3px 3px 0 rgba(12,15,20,.75);
}
.plan-day.is-done { background: #eaf3ea; }
.plan-day .idx {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-right: 1px solid var(--line);
  padding-right: 10px;
}
.plan-day .idx b { font-size: 22px; line-height: 1; font-variant-numeric: tabular-nums; }
.plan-day .idx span { font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.plan-day h3 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 7px; font-size: 15px; }
.plan-day h3 em { font-style: normal; font-family: var(--font-zh); font-size: 13px; color: var(--red-dark); font-weight: 600; }
.plan-day .tasks { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; }
.task { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #555248; }
.task .box { width: 14px; height: 14px; border: 1.5px solid var(--ink); display: grid; place-items: center; background: transparent; }
.task .box .icon { width: 11px; height: 11px; }
.task.done { color: var(--jade-dark); text-decoration: line-through; }
.task.done .box { background: var(--jade); border-color: var(--jade-dark); color: #fff; }
.plan-day .btn { justify-self: start; margin-top: 10px; }
.plan-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 88px; }
.side-card { padding: 18px; }
.side-card h3 { display: flex; align-items: center; gap: 8px; }
.radar-wrap { display: grid; place-items: center; padding: 8px 0 0; }
.radar-wrap canvas { width: 100%; max-width: 280px; height: auto; }
.coach-tip { display: flex; gap: 10px; padding: 10px 0; border-top: 1px dashed var(--line); font-size: 12.5px; line-height: 1.55; }
.coach-tip:first-of-type { border-top: 0; }
.coach-tip .dot { width: 7px; height: 7px; background: var(--red); margin-top: 6px; flex: 0 0 auto; }
.coach-tip b { display: block; color: var(--ink); margin-bottom: 2px; }
.coach-tip span { color: var(--muted); }
.skill-line { margin-top: 10px; font-size: 11px; color: var(--muted); }
.skill-line .track { height: 6px; background: rgba(28,32,40,.12); margin-top: 5px; overflow: hidden; }
.skill-line .track i { display: block; height: 100%; background: var(--jade); }
.goal-note { padding: 14px; border: 1px dashed var(--line); background: rgba(28,32,40,.03); font-size: 12px; line-height: 1.6; color: #555248; }

/* ---------------- modals ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center;
  padding: 18px;
  background: rgba(5, 8, 12, .78);
  backdrop-filter: blur(5px);
  animation: fade .2s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: min(720px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 8px 8px 0 rgba(0,0,0,.55);
  padding: clamp(20px, 3vw, 30px);
  animation: pop .25s ease both;
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-card h2 { font-size: 25px; }
.onboard-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 22px; }
.onboard-head .eyebrow { margin-bottom: 6px; }
.field { margin-bottom: 18px; }
.field > label { display: block; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; font-weight: 750; color: var(--muted); margin-bottom: 9px; }
.field.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 10px 13px;
  border: 1.5px solid var(--line);
  background: #fbf6ea;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.chip b { font-size: 13px; }
.chip span { font-family: var(--font-zh); font-size: 11px; color: var(--muted); }
.chip:hover { border-color: var(--ink); }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip.is-on span { color: rgba(247,240,226,.6); }

.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-head .icon-btn { border-color: var(--ink); background: transparent; color: var(--ink); }
.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 14px 0; border-top: 1px dashed var(--line);
}
.setting-row b { display: block; font-size: 14px; }
.setting-row span.muted { display: block; font-size: 12px; margin-top: 3px; }
.setting-row input[type=range] { width: 160px; accent-color: var(--red); }
.setting-row.danger { border-top: 1px solid var(--red-dark); }
.switch { position: relative; width: 48px; height: 26px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: #cfc3ad; border: 2px solid var(--ink); transition: background .15s; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: var(--paper); border: 1.5px solid var(--ink); transition: transform .15s; }
.switch input:checked + span { background: var(--jade); }
.switch input:checked + span::after { transform: translateX(22px); }

/* ---------------- toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 120;
  transform: translate(-50%, 20px);
  opacity: 0; pointer-events: none;
  padding: 11px 18px;
  background: var(--ink); color: var(--paper);
  border: 1px solid rgba(247,240,226,.25);
  box-shadow: 4px 4px 0 rgba(0,0,0,.4);
  font-size: 13px;
  transition: opacity .2s, transform .2s;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- lesson ---------------- */
.lesson {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(5, 8, 12, .94);
  display: grid;
  place-items: center;
  padding: clamp(8px, 2vw, 22px);
  overflow: auto;
}
.lesson-frame {
  width: min(1060px, 100%);
  max-height: calc(100vh - 24px);
  display: flex; flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid #05070a;
  box-shadow: 8px 8px 0 rgba(0,0,0,.55);
  overflow: hidden;
}
.stage { position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: 54vh; background: #05070a; overflow: hidden; flex: 0 0 auto; }
.stage canvas { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.stage-scan {
  position: absolute; inset: 0; pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,.14) 0 1px, transparent 1px 3px),
    radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(0,0,0,.45));
  mix-blend-mode: multiply;
}
.stage-hud {
  position: absolute; left: 0; right: 0; top: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(5,8,12,.82), rgba(5,8,12,0));
}
.stage-meta { display: flex; flex-direction: column; min-width: 0; color: var(--paper); }
.stage-meta b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-meta span { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: rgba(247,240,226,.6); margin-top: 2px; }
.stage-score { margin-left: auto; display: flex; align-items: center; gap: 9px; color: var(--paper); font-size: 11px; font-variant-numeric: tabular-nums; }
.pbar { width: 92px; height: 7px; border: 1px solid rgba(247,240,226,.4); background: rgba(5,8,12,.5); }
.pbar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .3s ease; }
.stage-caption {
  position: absolute; left: 12px; bottom: 10px;
  padding: 5px 9px;
  background: rgba(5,8,12,.7);
  border: 1px solid rgba(247,240,226,.2);
  color: rgba(247,240,226,.85);
  font-size: 10px; letter-spacing: .06em;
}
.stage-caption b { font-family: var(--font-zh); color: var(--gold); margin-right: 6px; }
.stage-caption .spk { color: var(--jade); }

.panel { padding: clamp(16px, 2.4vw, 24px) clamp(16px, 3vw, 30px) clamp(18px, 2.6vw, 26px); overflow: auto; flex: 1 1 auto; min-height: 0; }
.panel-in { max-width: 820px; margin: 0 auto; animation: rise .25s ease both; }
.panel-topline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 12px; }
.panel-topline .step-label { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.panel h2 { font-size: clamp(24px, 3vw, 34px); margin-bottom: 6px; }
.panel h2.zh { font-family: var(--font-zh); font-size: clamp(28px, 4vw, 40px); line-height: 1.2; }
.panel .pinyin { color: var(--red-dark); font-size: 14px; letter-spacing: .02em; margin: 2px 0 0; }
.panel .translation { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.panel .prompt { font-size: 15px; color: #4a473f; margin: 0 0 14px; }
.panel .quote-line {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px;
  border-left: 3px solid var(--jade);
  background: rgba(63,159,134,.08);
  margin: 0 0 16px;
  font-size: 13px; color: #4a473f;
}
.panel .quote-line b { display: block; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--jade-dark); margin-bottom: 3px; }

.audio-btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border: 2px solid var(--ink); background: var(--ink); color: var(--paper);
  cursor: pointer; box-shadow: 3px 3px 0 rgba(12,15,20,.35);
  font-weight: 700; font-size: 13px;
}
.audio-btn:hover { background: #2c3340; }
.audio-btn.small { padding: 7px 11px; font-size: 12px; box-shadow: 2px 2px 0 rgba(12,15,20,.3); }
.audio-btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); box-shadow: none; }
.audio-btn .icon { width: 16px; height: 16px; }

.options { display: flex; flex-direction: column; gap: 9px; }
.option {
  display: flex; align-items: center; gap: 13px;
  width: 100%; padding: 12px 14px;
  border: 2px solid #d3c6ae; background: #fcf7ec;
  color: var(--ink); text-align: left; cursor: pointer;
  transition: border-color .12s, background .12s, transform .08s;
}
.option:hover { border-color: var(--ink); }
.option:active { transform: translateY(1px); }
.option .key {
  width: 24px; height: 24px; display: grid; place-items: center;
  border: 1.5px solid var(--ink); font-size: 11px; font-weight: 800;
  flex: 0 0 auto; background: var(--paper-2);
}
.option .txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.option .zh { font-family: var(--font-zh); font-size: 18px; line-height: 1.35; }
.option .en { font-size: 12px; color: var(--muted); }
.option.is-correct { border-color: var(--jade); background: #e3f3ea; }
.option.is-correct .key { background: var(--jade); border-color: var(--jade-dark); color: #fff; }
.option.is-wrong { border-color: var(--red); background: #fae3dd; }
.option.is-wrong .key { background: var(--red); border-color: var(--red-dark); color: #fff; }
.option:disabled { cursor: default; opacity: 1; }

.feedback {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-top: 14px; padding: 11px 14px;
  border: 2px solid var(--ink);
  font-size: 13px; font-weight: 650;
}
.feedback.good { background: #e3f3ea; border-color: var(--jade-dark); color: var(--jade-dark); }
.feedback.bad { background: #fae3dd; border-color: var(--red-dark); color: var(--red-dark); }
.feedback .score-big { font-size: 22px; font-weight: 850; }
.feedback .sub { font-weight: 500; color: #555248; flex: 1 1 200px; }

.say-target {
  padding: 16px;
  border: 2px solid var(--ink);
  background: #fcf7ec;
  margin-bottom: 14px;
}
.say-target .zh { font-family: var(--font-zh); font-size: clamp(24px, 3.2vw, 34px); line-height: 1.35; }
.say-target .pinyin { margin-top: 4px; }
.say-target .translation { margin-top: 4px; }
.say-target .hidden-hint { font-size: 12px; color: var(--muted); }

.mic-zone { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 6px 0 2px; }
.mic-btn {
  position: relative;
  width: 68px; height: 68px; border-radius: 50%;
  border: 3px solid #7d2719;
  background: var(--red);
  color: var(--white);
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(0,0,0,.25);
  flex: 0 0 auto;
}
.mic-btn .icon { width: 28px; height: 28px; }
.mic-btn:hover { background: #e2634b; }
.mic-btn.listening { animation: micpulse 1.2s infinite; background: var(--jade); border-color: var(--jade-dark); }
.mic-btn:disabled { opacity: .5; cursor: not-allowed; animation: none; }
@keyframes micpulse {
  0% { box-shadow: 0 0 0 0 rgba(63,159,134,.55), 0 5px 0 rgba(0,0,0,.25); }
  70% { box-shadow: 0 0 0 18px rgba(63,159,134,0), 0 5px 0 rgba(0,0,0,.25); }
  100% { box-shadow: 0 0 0 0 rgba(63,159,134,0), 0 5px 0 rgba(0,0,0,.25); }
}
.mic-copy { display: flex; flex-direction: column; gap: 4px; min-width: 180px; }
.mic-copy b { font-size: 14px; }
.mic-copy span { font-size: 12px; color: var(--muted); line-height: 1.5; }
.transcript {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px dashed var(--line);
  background: #fbf6ea;
  font-size: 13px; color: #555248;
  margin-top: 8px;
}
.transcript b { font-family: var(--font-zh); font-size: 16px; color: var(--ink); }
.wave { display: inline-flex; align-items: center; gap: 3px; height: 20px; }
.wave i { width: 3px; height: 6px; background: var(--jade); animation: wave 0.8s infinite ease-in-out; }
.wave i:nth-child(2) { animation-delay: .1s; }
.wave i:nth-child(3) { animation-delay: .2s; }
.wave i:nth-child(4) { animation-delay: .3s; }
.wave i:nth-child(5) { animation-delay: .4s; }
@keyframes wave { 0%,100% { height: 5px; } 50% { height: 18px; } }

.lesson-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; }
.lesson-footer .spacer { flex: 1; }
.kbd-hint { font-size: 11px; color: var(--muted); }
.grammar-card, .culture-card {
  margin-top: 14px; padding: 13px 15px;
  border: 1px solid var(--line); background: #fbf6ea;
  font-size: 13px; line-height: 1.65; color: #4d4a42;
}
.grammar-card b, .culture-card b { display: block; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--red-dark); margin-bottom: 5px; }
.grammar-card .ex { margin-top: 7px; font-family: var(--font-zh); color: var(--ink); }
.grammar-card .ex span { font-family: var(--font-ui); color: var(--muted); font-size: 12px; display: block; }

.score-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }
.score-tile { border: 2px solid var(--ink); background: #fbf6ea; padding: 14px; }
.score-tile b { display: block; font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
.score-tile span { display: block; margin-top: 6px; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.score-tile.good { border-color: var(--jade-dark); background: #e8f4ec; }
.score-tile.warn { border-color: var(--red-dark); background: #fbeae5; }
.xp-burst { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 750; color: var(--gold); margin: 6px 0 0; }
.xp-burst .icon { fill: currentColor; }
.word-list { display: grid; gap: 6px; margin-top: 12px; }
.word-row { display: grid; grid-template-columns: 1.2fr 1fr auto; gap: 10px; align-items: baseline; padding: 7px 0; border-top: 1px dashed var(--line); font-size: 13px; }
.word-row .zh { font-family: var(--font-zh); font-size: 16px; }
.word-row .py { color: var(--red-dark); font-size: 12px; }
.word-row .en { color: var(--muted); font-size: 12px; text-align: right; }
.review-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .scene-frame { min-height: 260px; }
  .plan-layout { grid-template-columns: 1fr; }
  .plan-side { position: static; }
  .plan-strip { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 10px 12px; }
  .brand-text small { display: none; }
  .nav { order: 3; width: 100%; overflow-x: auto; gap: 2px; margin: 0; padding-bottom: 2px; }
  .nav-item { padding: 8px 10px; white-space: nowrap; }
  .topstats { margin-left: auto; }
  .stat-pill { padding: 6px 8px; }
  .view { width: calc(100% - 24px); padding-top: 20px; }
  .hello h1 { font-size: 34px; }
  .quick-stats { width: 100%; }
  .qstat { flex: 1; min-width: 0; }
  .qstat b { font-size: 20px; }
  .archive-row { grid-template-columns: 54px 1fr; gap: 12px; padding: 12px; }
  .archive-row .result { grid-column: 2; flex-direction: row; align-items: center; justify-content: flex-start; }
  .archive-row .date b { font-size: 20px; }
  .field.two { grid-template-columns: 1fr; }
  .stage { max-height: 40vh; }
  .lesson { padding: 0; place-items: start center; }
  .lesson-frame { max-height: 100vh; min-height: 100vh; width: 100%; border-left: 0; border-right: 0; box-shadow: none; }
  .panel { padding: 16px 14px 26px; }
  .stage-hud { padding: 8px; gap: 8px; }
  .stage-score .pbar { display: none; }
  .score-grid { grid-template-columns: 1fr 1fr; }
  .word-row { grid-template-columns: 1.1fr 1fr; }
  .word-row .en { grid-column: 1 / -1; text-align: left; }
  .mic-btn { width: 60px; height: 60px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
