:root {
  --paper: #eef0eb;
  --sheet: #f8f9f6;
  --ink: #16211c;
  --ink-2: #4c5a53;
  --rule: #c9d0c8;
  --cell: #d9dfd8;
  --guide: #e3b4ae;
  --held: #1a472a;
  --held-2: #3d7a52;
  --held-wash: #dbe7de;
  --seal: #b3302a;
  --seal-wash: #f4dedb;
  --on-dark: #ffffff;
  --ph0: #cfd8d1; --ph1: #c3d3c8; --ph2: #d3d6cc; --ph3: #dcdcd8;
  --serif-zh: "Noto Serif TC", "Songti TC", "PMingLiU", "Source Han Serif TC", serif;
  --sans: "Libre Franklin", "Franklin Gothic Medium", "Arial Narrow", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #101814; --sheet: #17211c; --ink: #e3e9e2; --ink-2: #9aa89f; --rule: #2d3b34; --cell: #24312a;
    --guide: #5a2f2b; --held: #63b07f; --held-2: #4a8f63; --held-wash: #1d3326; --seal: #e3695c; --seal-wash: #3a1f1c;
    --on-dark: #0f1612; --ph0: #23302a; --ph1: #263a2e; --ph2: #2b302a; --ph3: #2a2c2a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #101814; --sheet: #17211c; --ink: #e3e9e2; --ink-2: #9aa89f; --rule: #2d3b34; --cell: #24312a;
  --guide: #5a2f2b; --held: #63b07f; --held-2: #4a8f63; --held-wash: #1d3326; --seal: #e3695c; --seal-wash: #3a1f1c;
  --on-dark: #0f1612; --ph0: #23302a; --ph1: #263a2e; --ph2: #2b302a; --ph3: #2a2c2a; color-scheme: dark;
}
:root { box-sizing: border-box; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
html { scroll-padding-top: calc(env(safe-area-inset-top, 0px) + 64px); }
*, *::before, *::after { box-sizing: inherit; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
img, svg { max-width: 100%; }
a { color: var(--held); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--seal); outline-offset: 2px; border-radius: 2px; }
.zh { font-family: var(--serif-zh); font-weight: 400; }
.num { font-variant-numeric: tabular-nums lining-nums; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* shell */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--paper); border-bottom: 1px solid var(--rule); }
.top-in { max-width: 1120px; margin: 0 auto; display: flex; align-items: center; gap: 20px; padding: 10px 20px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.seal { display: inline-grid; place-items: center; width: 30px; height: 30px; background: var(--seal); color: #fff; font-family: var(--serif-zh); font-weight: 700; font-size: 19px; border-radius: 3px; line-height: 1; }
.nav { display: flex; gap: 2px; margin-left: auto; }
.nav a { color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 15px; padding: 8px 12px; border-radius: 6px; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -3px 0 var(--seal); border-radius: 0; }
.sync { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
main { max-width: 1120px; margin: 0 auto; padding: 24px 20px 96px; outline: none; }
@media (max-width: 760px) {
  .nav { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; z-index: 30; background: var(--sheet); border-top: 1px solid var(--rule);
    justify-content: space-around; padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px)); }
  .nav a { font-size: 13px; padding: 10px 6px; min-height: 44px; display: grid; place-items: center; }
  .nav a[aria-current="page"] { box-shadow: inset 0 3px 0 var(--seal); }
  .sync { margin-left: auto; }
  main { padding: 16px 14px 110px; }
}

/* type */
h1 { font-size: clamp(28px, 4.2vw, 44px); line-height: 1.08; letter-spacing: -.02em; font-weight: 800; margin: 0 0 12px; max-width: 22ch; }
h2 { font-size: 22px; line-height: 1.2; letter-spacing: -.01em; font-weight: 800; margin: 40px 0 12px; }
h3 { font-size: 17px; line-height: 1.3; font-weight: 700; margin: 0 0 6px; }
p { margin: 0 0 12px; max-width: 68ch; }
.lede { font-size: 18px; color: var(--ink-2); max-width: 60ch; }

/* honest progress headline */
.claim { font-size: clamp(30px, 5vw, 56px); line-height: 1.05; letter-spacing: -.025em; font-weight: 800; margin: 4px 0 6px; max-width: 18ch; }
.claim b { color: var(--held); font-weight: 800; }
.claim .of { color: var(--ink-2); font-weight: 600; }

/* controls */
.btn { font: 600 15px/1.2 var(--sans); min-height: 44px; padding: 10px 16px; border-radius: 6px; border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:hover { background: var(--sheet); }
.btn.go { background: var(--seal); border-color: var(--seal); color: #fff; }
.btn.go:hover { filter: brightness(1.07); background: var(--seal); }
.btn.quiet { border-color: var(--rule); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.seg { display: inline-flex; border: 1.5px solid var(--rule); border-radius: 6px; overflow: hidden; }
.seg button { font: 600 14px var(--sans); border: 0; background: transparent; color: var(--ink-2); padding: 9px 12px; min-height: 40px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
input[type="search"], input[type="text"], textarea { font: 16px var(--sans); color: var(--ink); background: var(--sheet); border: 1.5px solid var(--rule); border-radius: 6px; padding: 10px 12px; min-height: 44px; width: 100%; }
textarea { min-height: 120px; font-family: var(--serif-zh); font-size: 20px; }

/* surfaces: sheets are flat paper with a rule, not floating cards */
.sheet { background: var(--sheet); border: 1px solid var(--rule); border-radius: 4px; padding: 20px; }
.split { display: grid; gap: 24px; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

/* phase strip */
.phases { display: grid; gap: 3px; margin: 18px 0 6px; }
.phase { position: relative; padding: 8px 10px 10px; background: var(--cell); min-height: 64px; overflow: hidden; }
.phase .fill { position: absolute; inset: 0 auto 0 0; background: var(--held-wash); }
.phase > * { position: relative; }
.phase .nm { font-weight: 700; font-size: 14px; }
.phase .meta { font-size: 12.5px; color: var(--ink-2); }
.phase.now { box-shadow: inset 0 -3px 0 var(--seal); }
.phase.done .nm::after { content: " ✓"; color: var(--held); }

/* theater map */
.theater { margin: 10px 0 0; }
.theater svg { display: block; width: 100%; height: auto; }
.theater .k { fill: var(--held); }
.theater .u { fill: var(--cell); }
.theater .r { fill: var(--seal); }
.theater .f { fill: none; stroke: var(--seal); stroke-width: 1.5; }
.theater .lev { fill: var(--ink-2); opacity: .55; }
.theater .lev.peak { fill: var(--seal); opacity: 1; }
.theater text { font: 600 11px var(--sans); fill: var(--ink-2); }
.theater .hit { fill: transparent; cursor: pointer; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: var(--paper); padding: 8px 10px; border-radius: 4px; font-size: 13px; line-height: 1.3; max-width: 220px; }
.tip .zh { font-size: 34px; display: block; line-height: 1.1; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--ink-2); margin-top: 8px; }
.legend i { display: inline-block; width: 11px; height: 11px; vertical-align: -1px; margin-right: 6px; }

/* operation picks */
.picks { display: grid; gap: 10px; }
.pick { display: grid; grid-template-columns: 72px 1fr auto; gap: 14px; align-items: center; padding: 12px 14px; background: var(--sheet); border: 1px solid var(--rule); border-left: 4px solid var(--seal); border-radius: 3px; color: var(--ink); text-decoration: none; }
.pick:hover { border-color: var(--ink-2); border-left-color: var(--seal); }
.pick .g { font-family: var(--serif-zh); font-size: 52px; line-height: 1; text-align: center; }
.pick .py { font-weight: 700; }
.pick .why { display: block; font-size: 13.5px; color: var(--ink-2); margin-top: 2px; }
.pick .why strong { color: var(--ink); font-weight: 600; }
.pick .gain { text-align: right; font-weight: 800; font-size: 26px; line-height: 1; color: var(--held); }
.pick .gain small { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); }

/* character tiles */
.tiles { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
.tile { position: relative; display: grid; place-items: center; aspect-ratio: 1; background: var(--sheet); border: 1px solid var(--rule); border-radius: 3px; color: var(--ink); text-decoration: none;
  font-family: var(--serif-zh); font-size: 34px; line-height: 1; cursor: pointer; }
.tile small { position: absolute; left: 5px; top: 3px; font: 600 10px var(--sans); color: var(--ink-2); }
.tile.k { background: var(--held); color: #fff; border-color: var(--held); }
.tile.k small { color: rgba(255,255,255,.75); }
:root[data-theme="dark"] .tile.k, .dark-k .tile.k { color: var(--on-dark); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tile.k { color: var(--on-dark); } :root:not([data-theme="light"]) .tile.k small { color: var(--on-dark); opacity: .7; } }
.tile.rv { box-shadow: inset 0 0 0 2px var(--seal); }

/* practice grid card (米字格) */
.drill { display: grid; grid-template-columns: minmax(220px, 320px) 1fr; gap: 28px; align-items: start; }
@media (max-width: 720px) { .drill { grid-template-columns: 1fr; } }
.grid-box { position: relative; aspect-ratio: 1; width: 100%; background: var(--sheet); border: 2px solid var(--seal); }
.grid-box svg.guide { position: absolute; inset: 0; width: 100%; height: 100%; }
.grid-box svg.guide line { stroke: var(--guide); stroke-width: 1; stroke-dasharray: 4 4; }
.grid-box .glyph { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--serif-zh); font-size: clamp(140px, 22vw, 210px); line-height: 1; }
.reading { font-size: 34px; font-weight: 800; letter-spacing: -.01em; }
.gloss { font-size: 19px; color: var(--ink-2); margin-bottom: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px 6px 8px; min-height: 40px; border: 1.5px solid var(--rule); border-radius: 4px; background: var(--sheet); color: var(--ink); text-decoration: none; font-size: 14px; }
.chip .zh { font-size: 24px; line-height: 1; }
.chip.k { border-color: var(--held); }
.chip.k .zh { color: var(--held); }
.chip.p { border-style: dashed; border-color: var(--held-2); }
.chip.x { border-style: dashed; border-color: var(--seal); }
.dots { display: flex; flex-wrap: wrap; gap: 4px; margin: 12px 0 18px; }
.dots button { width: 22px; height: 22px; border: 1px solid var(--rule); background: var(--sheet); border-radius: 2px; padding: 0; cursor: pointer; font-size: 0; }
.dots button.seen { background: var(--held-wash); }
.dots button[aria-current="step"] { background: var(--seal); border-color: var(--seal); }

/* words */
.words { display: flex; flex-wrap: wrap; gap: 6px; }
.w { display: inline-flex; flex-direction: column; padding: 6px 10px 7px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 3px; min-width: 64px; }
.w .zh { font-size: 24px; line-height: 1.15; }
.w .py { font-size: 12.5px; color: var(--ink-2); }
.w .gl { font-size: 12.5px; max-width: 22ch; line-height: 1.3; }
.w.new { border-color: var(--held); background: var(--held-wash); }
.away { display: grid; gap: 10px; }
.away-row { display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: start; padding: 10px 0; border-top: 1px solid var(--rule); }
.away-row a.g { font-family: var(--serif-zh); font-size: 44px; line-height: 1; color: var(--seal); text-decoration: none; text-align: center; }

/* check */
.q { text-align: center; padding: 10px 0 0; }
.q .glyph { font-family: var(--serif-zh); font-size: clamp(110px, 18vw, 160px); line-height: 1.05; }
.opts { display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 640px; margin: 18px auto 0; }
@media (max-width: 520px) { .opts { grid-template-columns: 1fr; } }
.opt { font: 500 16px/1.3 var(--sans); text-align: left; min-height: 56px; padding: 12px 14px; border: 1.5px solid var(--rule); background: var(--sheet); color: var(--ink); border-radius: 4px; cursor: pointer; }
.opt .zh { font-size: 34px; }
.opt:hover:not(:disabled) { border-color: var(--ink); }
.opt.right { border-color: var(--held); background: var(--held-wash); }
.opt.wrong { border-color: var(--seal); background: var(--seal-wash); }
.meter { height: 6px; background: var(--cell); margin: 6px 0 4px; }
.meter i { display: block; height: 100%; background: var(--held); }
.meter.seal i { background: var(--seal); }

/* campaigns list */
.camps { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.camp { display: block; padding: 10px 12px 12px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 3px; color: var(--ink); text-decoration: none; }
.camp .n { font-weight: 800; font-size: 15px; }
.camp .c { font-family: var(--serif-zh); font-size: 20px; letter-spacing: .04em; color: var(--ink-2); white-space: nowrap; overflow: hidden; }
.camp .s { font-size: 12.5px; color: var(--ink-2); }
.camp.done { border-color: var(--held); }
.camp.ver { border-color: var(--held); box-shadow: inset 4px 0 0 var(--held); }
.camp.now { border-color: var(--seal); box-shadow: inset 4px 0 0 var(--seal); }
.phase-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin: 34px 0 10px; }
.phase-h h2 { margin: 0; }

/* lineage tree */
.tree-wrap { overflow-x: auto; background: var(--sheet); border: 1px solid var(--rule); border-radius: 4px; padding: 12px; }
.tree-wrap svg { display: block; margin: 0 auto; max-width: none; }
.tree .edge { fill: none; stroke: var(--rule); stroke-width: 1.5; }
.tree .node rect { stroke-width: 1.5; }
.tree .node text { font-family: var(--serif-zh); font-size: 30px; text-anchor: middle; dominant-baseline: central; }
.tree .node text.lb { font-family: var(--sans); font-size: 11px; fill: var(--ink-2); }
.tree .char rect { fill: var(--sheet); stroke: var(--ink); }
.tree .char.k rect, .tree .keystone.k rect { fill: var(--held); stroke: var(--held); }
.tree .char.k text.g, .tree .keystone.k text.g { fill: #fff; }
.tree .keystone rect { fill: var(--sheet); stroke: var(--ink); stroke-width: 2.5; }
.tree .part rect { fill: var(--sheet); stroke: var(--held-2); stroke-dasharray: 4 3; }
.tree .part.k rect { fill: var(--held-wash); }
.tree .primitive rect { fill: var(--cell); stroke: none; }
.tree .node text.g { fill: var(--ink); }
.tree a { cursor: pointer; }
.tree a:focus-visible rect { stroke: var(--seal); stroke-width: 3; }

/* record */
.ladder { display: grid; gap: 0; border-top: 1px solid var(--rule); }
.rung { display: grid; grid-template-columns: 1fr 120px 80px; gap: 16px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.rung .cr { text-align: right; font-weight: 800; }
.rung.done h3::after { content: " ✓"; color: var(--held); }
@media (max-width: 560px) { .rung { grid-template-columns: 1fr 70px; } .rung .meter { grid-column: 1 / -1; } }
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(18px, 1fr)); gap: 3px; max-width: 760px; }
.vgrid a { aspect-ratio: 1; background: var(--cell); display: block; border-radius: 1px; }
.vgrid a.d { background: var(--held-2); opacity: .55; }
.vgrid a.v { background: var(--held); opacity: 1; }

/* entry point mockups */
.mock { border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; background: var(--sheet); }
.mock-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--cell); font-size: 12.5px; color: var(--ink-2); }
.mock-bar i { width: 9px; height: 9px; border-radius: 50%; background: var(--rule); display: inline-block; }
.mock-bar span { margin-left: 8px; background: var(--sheet); padding: 2px 10px; border-radius: 10px; }
.us { background: #f8f8f8; color: #2c2c2c; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding: 26px 24px; }
.us .band { border-left: 5px solid #1a472a; padding-left: 16px; }
.us h4 { font-size: 24px; margin: 0 0 8px; color: #1a472a; line-height: 1.2; }
.us p { color: #2c2c2c; font-size: 15px; }
.us .cta { display: inline-block; background: #c41e3a; color: #fff; padding: 10px 16px; border-radius: 4px; font-weight: 700; text-decoration: none; font-size: 15px; }
.us .mini { display: grid; grid-template-columns: repeat(25, 1fr); gap: 2px; margin: 14px 0; max-width: 420px; }
.us .mini i { aspect-ratio: 1; background: #e0e0e0; }
.us .mini i.k { background: #1a472a; }
.ac { background: #fff; color: #1b1b1b; padding: 24px; font-family: Georgia, "Times New Roman", serif; }
.ac .code { font-family: var(--sans); font-weight: 800; font-size: 13px; color: #6b2b23; }
.ac h4 { font-size: 23px; margin: 2px 0 10px; font-weight: 400; line-height: 1.2; }
.ac table { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 14px; margin: 12px 0; }
.ac td, .ac th { text-align: left; padding: 7px 4px; border-bottom: 1px solid #ddd; }
.ac .cta { display: inline-block; border: 1.5px solid #1b1b1b; color: #1b1b1b; padding: 9px 14px; text-decoration: none; font-family: var(--sans); font-weight: 700; font-size: 14px; }
table.spec { width: 100%; border-collapse: collapse; font-size: 14px; }
table.spec th, table.spec td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.spec code { font-size: 13px; }
.scroll { overflow-x: auto; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 4px; font-weight: 600; z-index: 60; }
.count { display: inline-block; }
@media (prefers-reduced-motion: no-preference) {
  .count.pop { animation: pop .5s ease-out; }
  @keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }
}
footer.foot { max-width: 1120px; margin: 0 auto; padding: 0 20px 110px; font-size: 13.5px; color: var(--ink-2); }
footer.foot a { color: var(--ink-2); }
main:focus, main:focus-visible { outline: none; }

#find input { flex: 1; width: auto; min-width: 0; }
@media (max-width: 760px) {
  .phases { grid-template-columns: 1fr 1fr !important; margin-left: 0 !important; margin-right: 0 !important; }
  .phase { min-height: 0; }
  .theater svg { min-width: 760px; }
  .pick { grid-template-columns: 52px 1fr auto; gap: 10px; padding: 10px; }
  .pick .g { font-size: 40px; }
}
[hidden] { display: none !important; }
.q p { margin-left: auto; margin-right: auto; }
.split.even { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .split.even { grid-template-columns: 1fr; } }
