/* Tìm Huyệt — celadon & lacquer, faceted characters */
:root {
  --bg: #e9efe9;
  --bg-2: #dfe7e0;
  --surface: #fbfcf8;
  --surface-2: #f2f5ef;
  --ink: #1d2925;
  --ink-2: #4f5f58;
  --ink-3: #7c8b84;
  --line: #d3dcd5;
  --accent: #2a6f62;
  --accent-ink: #ffffff;
  --accent-soft: #d7e9e2;
  --gold: #b8862a;
  --gold-soft: #f4e7c8;
  --danger: #b23b2b;
  --danger-soft: #fbe6e1;
  --stage-a: #f8faf5;
  --stage-b: #d9e4dc;
  --shadow: 0 1px 2px rgb(20 40 32 / 0.06), 0 8px 24px rgb(20 40 32 / 0.08);
  --radius: 12px;
  --f-display: 'Alegreya', 'Iowan Old Style', Georgia, serif;
  --f-ui: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --f-han: 'Noto Serif TC', 'Songti TC', 'PMingLiU', serif;
  --top: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111816; --bg-2: #0d1311; --surface: #18211e; --surface-2: #1e2925; --ink: #e4ece8; --ink-2: #a6b6af; --ink-3: #7d8e87;
    --line: #2b3733; --accent: #7cc4b1; --accent-ink: #0f1a17; --accent-soft: #20352f; --gold: #e0b764; --gold-soft: #3a3120;
    --danger: #f08a78; --danger-soft: #3a211d; --stage-a: #202b27; --stage-b: #111816; --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111816; --bg-2: #0d1311; --surface: #18211e; --surface-2: #1e2925; --ink: #e4ece8; --ink-2: #a6b6af; --ink-3: #7d8e87;
  --line: #2b3733; --accent: #7cc4b1; --accent-ink: #0f1a17; --accent-soft: #20352f; --gold: #e0b764; --gold-soft: #3a3120;
  --danger: #f08a78; --danger-soft: #3a211d; --stage-a: #202b27; --stage-b: #111816; --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--f-ui); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hz { font-family: var(--f-han); font-weight: 600; }
h1, h2, h3, h4 { font-family: var(--f-display); font-weight: 700; line-height: 1.2; margin: 0; text-wrap: balance; }
[hidden] { display: none !important; }

.app { height: 100%; display: flex; flex-direction: column; }

/* ---------- top bar ---------- */
.topbar { height: var(--top); flex: none; display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: relative; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: none; }
.seal { width: 36px; height: 36px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font: 600 21px/1 var(--f-han); box-shadow: inset 0 0 0 2px rgb(255 255 255 / 0.18); }
.brand b { font: 700 19px/1.1 var(--f-display); display: block; letter-spacing: 0.01em; }
.brand small { color: var(--ink-3); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
.search { position: relative; flex: 1; max-width: 520px; margin: 0 auto; }
.search input { width: 100%; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 14px 0 38px; outline: none; }
.search input:focus { border-color: var(--accent); background: var(--surface); }
.search svg { position: absolute; left: 12px; top: 11px; width: 18px; height: 18px; color: var(--ink-3); pointer-events: none; }
.qres { position: absolute; top: 46px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: min(70vh, 520px); overflow: auto; padding: 6px; z-index: 40; }
.qres h5 { margin: 8px 10px 4px; font: 600 11px/1 var(--f-ui); color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; }
.qres button { display: flex; width: 100%; text-align: left; gap: 10px; align-items: baseline; padding: 8px 10px; border: 0; background: none; border-radius: 8px; }
.qres button:hover, .qres button.active { background: var(--accent-soft); }
.qres .code { font: 600 12px/1 var(--f-ui); color: var(--ink-3); min-width: 54px; font-variant-numeric: tabular-nums; }
.controls { display: flex; align-items: center; gap: 8px; flex: none; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 2px; background: var(--surface-2); }
.seg button { border: 0; background: none; padding: 5px 11px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }
.iconbtn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); display: grid; place-items: center; color: var(--ink-2); }
.iconbtn svg { width: 18px; height: 18px; }

/* character button (top bar) */
.charbtn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 8px 0 4px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font-size: 13.5px; font-weight: 600; max-width: 210px; }
.charbtn:hover { border-color: var(--g, var(--accent)); }
.charbtn .av { width: 32px; height: 32px; border-radius: 50%; flex: none; background: color-mix(in srgb, var(--g, var(--accent)) 22%, var(--surface)) center / cover no-repeat; box-shadow: 0 0 0 2px var(--g, var(--accent)); }
.charbtn .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.charbtn svg { width: 16px; height: 16px; flex: none; color: var(--ink-3); }

/* ---------- main layout ---------- */
.main { flex: 1; min-height: 0; display: grid; grid-template-columns: 360px 1fr auto; }
.panel { background: var(--surface); min-height: 0; display: flex; flex-direction: column; }
.panel.left { border-right: 1px solid var(--line); }
.panel.right { width: 390px; border-left: 1px solid var(--line); overflow: auto; }
.tabs { display: flex; gap: 4px; padding: 10px 12px 0; border-bottom: 1px solid var(--line); flex: none; }
.tabs button { flex: 1; border: 0; background: none; padding: 10px 6px 11px; font-weight: 600; font-size: 14px; color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabpane { flex: 1; min-height: 0; overflow: auto; padding: 16px 16px 28px; display: flex; flex-direction: column; gap: 18px; }
.sheet-handle { display: none; }

/* ---------- stage ---------- */
.stage { position: relative; min-width: 0; overflow: hidden; background: radial-gradient(120% 90% at 50% 38%, var(--stage-a), var(--stage-b)); }
#canvasWrap { position: absolute; inset: 0; }
#canvasWrap canvas { display: block; }
.floor { position: absolute; left: 50%; bottom: 7%; width: 220px; height: 26px; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(closest-side, rgb(30 60 50 / 0.18), transparent); pointer-events: none; }
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lbl { position: absolute; transform: translate(-50%, calc(-100% - 10px)); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 2px 8px; font-size: 12px; font-weight: 600; white-space: nowrap; box-shadow: 0 2px 6px rgb(0 0 0 / 0.12); }
.lbl small { color: var(--ink-3); font-weight: 500; margin-left: 4px; }
.lbl.sel { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.lbl.sel small { color: var(--bg-2); }
.lbl.num { transform: translate(-50%, -50%); width: 22px; height: 22px; padding: 0; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: #fff; border: 2px solid var(--surface); font-size: 11px; box-shadow: 0 2px 6px rgb(0 0 0 / 0.25); }
.lbl.num.now { background: var(--danger); transform: translate(-50%, -50%) scale(1.25); }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--surface); padding: 4px 9px; border-radius: 8px; font-size: 12.5px; font-weight: 600; transform: translate(12px, 12px); white-space: nowrap; z-index: 5; }
.tip small { opacity: 0.7; font-weight: 500; margin-left: 5px; }
.bubble { position: absolute; max-width: 220px; background: var(--surface); border: 2px solid var(--ink); border-radius: 16px; padding: 8px 12px; font-weight: 600; font-size: 13.5px; line-height: 1.35; box-shadow: 3px 3px 0 var(--ink); transition: opacity 0.4s; pointer-events: none; z-index: 4; }
.bubble::after { content: ''; position: absolute; right: -12px; bottom: 10px; border: 7px solid transparent; border-left: 10px solid var(--ink); }
.bubble.right::after { right: auto; left: -12px; border-left-color: transparent; border-right: 10px solid var(--ink); }
.bubble.hide { opacity: 0; }
.viewbar { position: absolute; right: 14px; top: 14px; display: flex; flex-direction: column; gap: 6px; z-index: 6; }
.viewbar .grp { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 2px; box-shadow: var(--shadow); }
.viewbar button { border: 0; background: none; min-width: 40px; height: 32px; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--ink-2); display: grid; place-items: center; padding: 0 8px; }
.viewbar button:hover { background: var(--surface-2); color: var(--ink); }
.viewbar button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.viewbar svg { width: 18px; height: 18px; }
.swatches { display: flex; flex-direction: column; gap: 6px; padding: 6px; align-items: center; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); padding: 0; min-width: 0 !important; height: 22px !important; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--accent); }
.loading { position: absolute; inset: 0; display: grid; place-items: center; z-index: 8; background: radial-gradient(120% 90% at 50% 38%, var(--stage-a), var(--stage-b)); transition: opacity 0.5s; }
.loading.gone { opacity: 0; pointer-events: none; }
.loading .box { text-align: center; display: grid; gap: 12px; justify-items: center; }
.loading .seal { width: 58px; height: 58px; font-size: 32px; border-radius: 14px; animation: breathe 2.2s ease-in-out infinite; }
.loading .bar { width: 180px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.loading .seal { position: relative; overflow: hidden; }
.loading .seal img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--accent-soft); }
.loading .seal:has(img:not([hidden])) { width: 84px; height: 84px; border-radius: 50%; animation: bob 1.1s ease-in-out infinite; }
.loading .bar i { display: block; height: 100%; width: 38%; background: var(--accent); border-radius: 3px; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(270%); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes breathe { 50% { transform: scale(1.08); } }
.stagehint { position: absolute; left: 16px; bottom: 14px; font-size: 12px; color: var(--ink-3); z-index: 3; pointer-events: none; }

/* ---------- shared panel components ---------- */
.eyebrow { font: 600 11.5px/1 var(--f-ui); letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-3); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); cursor: pointer; user-select: none; }
.toggle input { appearance: none; width: 34px; height: 20px; border-radius: 10px; background: var(--line); position: relative; transition: background 0.2s; margin: 0; flex: none; }
.toggle input::after { content: ''; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: left 0.2s; box-shadow: 0 1px 2px rgb(0 0 0 / 0.2); }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { left: 16px; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 14px; font-weight: 600; font-size: 14px; display: inline-flex; gap: 8px; align-items: center; justify-content: center; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: none; color: var(--ink-2); padding-left: 6px; padding-right: 6px; }
.btn svg { width: 16px; height: 16px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); display: inline-block; flex: none; box-shadow: 0 0 0 1.5px rgb(0 0 0 / 0.35); }

/* meridian list */
.mlist { display: grid; gap: 2px; }
.mrow { display: grid; grid-template-columns: 14px 34px 1fr auto; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 9px; border: 0; background: none; text-align: left; width: 100%; }
.mrow:hover { background: var(--surface-2); }
.mrow[aria-pressed="true"] { background: var(--accent-soft); }
.mrow .code { font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.mrow .nm { font-size: 13.5px; line-height: 1.25; }
.mrow .nm small { display: block; color: var(--ink-3); font-size: 11.5px; }
.mrow .cnt { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.plist { display: grid; gap: 1px; }
.prow { display: grid; grid-template-columns: 12px 56px 1fr; gap: 8px; align-items: baseline; padding: 6px 8px; border: 0; background: none; text-align: left; border-radius: 8px; width: 100%; }
.prow:hover { background: var(--surface-2); }
.prow[aria-current="true"] { background: var(--accent-soft); }
.prow .code { font: 600 12.5px/1 var(--f-ui); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.prow .nm { font-size: 13.5px; }
.prow .nm small { color: var(--ink-3); margin-left: 6px; font-size: 12px; }
.prow .dot { align-self: center; }
.mcard { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 6px; background: var(--surface-2); }
.mcard h3 { font-size: 18px; }
.mcard p { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.mcard .meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-3); }

/* detail */
.detail { padding: 18px 20px 32px; display: grid; gap: 16px; }
.dhead { display: grid; gap: 6px; position: relative; }
.dhead .close { position: absolute; right: -6px; top: -6px; }
.dcode { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; color: var(--ink-2); }
.dcode .pill { background: var(--c); color: #102019; padding: 2px 8px; border-radius: 6px; font-size: 12px; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.15); }
.dname { font-size: 30px; }
.dsub { color: var(--ink-2); font-size: 14px; display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.dsub .hz { font-size: 20px; color: var(--ink); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 6px; background: var(--gold-soft); color: var(--ink); }
.tag.warn { background: var(--danger-soft); color: var(--danger); }
.dsec { display: grid; gap: 4px; }
.dsec h4 { font: 600 11.5px/1.2 var(--f-ui); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.dsec p { margin: 0; }
.dsec.find { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; }
.dsec.warn { background: var(--danger-soft); border-radius: 10px; padding: 10px 12px; color: var(--ink); }
.dsec.warn h4 { color: var(--danger); }
.ind { display: flex; flex-wrap: wrap; gap: 5px; }
.ind span { font-size: 13px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); }
.dactions { display: flex; gap: 8px; flex-wrap: wrap; }

/* treat */
.treat-hero { display: grid; gap: 8px; }
.treat-hero h2 { font-size: 24px; }
.treat-hero p { margin: 0; color: var(--ink-2); font-size: 13.5px; }
.ask { display: flex; gap: 8px; }
.ask input { flex: 1; min-width: 0; height: 44px; border-radius: 12px; border: 1.5px solid var(--line); padding: 0 14px; background: var(--surface); outline: none; font-size: 15px; }
.ask input:focus { border-color: var(--accent); }
.found { display: grid; gap: 8px; }
.cgroups { display: grid; gap: 14px; }
.cgroup { display: grid; gap: 7px; }
.cgroup .row { gap: 6px; }
.cond-head { display: grid; gap: 8px; }
.cond-head h2 { font-size: 24px; }
.cond-head p { margin: 0; color: var(--ink-2); font-size: 14px; }
.patterns { display: grid; gap: 8px; }
.pat { border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; text-align: left; background: var(--surface); display: grid; gap: 2px; width: 100%; }
.pat b { font-size: 14px; }
.pat span { font-size: 12.5px; color: var(--ink-2); }
.pat[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.opts { display: grid; gap: 10px; }
.selected-conds { display: flex; gap: 6px; flex-wrap: wrap; }
.selected-conds .chip { display: inline-flex; gap: 6px; align-items: center; }
.selected-conds .chip b { font-weight: 700; }
.plan-head { display: grid; gap: 10px; }
.plan-head h2 { font-size: 24px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; }
.facts dt { color: var(--ink-3); font-weight: 600; }
.facts dd { margin: 0; }
.alert { border-radius: 12px; padding: 12px 14px; background: var(--danger-soft); display: grid; gap: 6px; font-size: 13.5px; }
.alert h4 { color: var(--danger); font: 700 13px/1.2 var(--f-ui); display: flex; gap: 6px; align-items: center; }
.alert ul { margin: 0; padding-left: 18px; }
.note { border-radius: 12px; padding: 10px 14px; background: var(--gold-soft); font-size: 13.5px; }
.steps { display: grid; gap: 10px; counter-reset: s; }
.stepc { display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: left; width: 100%; }
.stepc:hover { border-color: var(--accent); }
.stepc .n { width: 28px; height: 28px; border-radius: 50%; background: var(--gold); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.stepc.prep .n, .stepc.fin .n { background: var(--ink-3); }
.stepc h4 { font: 700 15px/1.3 var(--f-ui); }
.stepc h4 small { font-weight: 500; color: var(--ink-3); margin-left: 6px; font-size: 12.5px; }
.stepc p { margin: 2px 0 0; font-size: 13px; color: var(--ink-2); }
.stepc .how { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; font-size: 12.5px; }
.stepc .how span { background: var(--surface-2); border-radius: 6px; padding: 2px 8px; }
.stepc .how span.t { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.stepc .why { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.plan-actions { display: flex; gap: 8px; flex-wrap: wrap; position: sticky; bottom: -28px; background: linear-gradient(transparent, var(--surface) 30%); padding: 14px 0 10px; }
.tips ul { margin: 6px 0 0; padding-left: 18px; font-size: 13.5px; }

/* guided session */
.guide { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); width: min(560px, calc(100% - 28px)); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 14px 16px; display: grid; grid-template-columns: 96px 1fr; gap: 14px; z-index: 9; }
.ring { width: 96px; height: 96px; position: relative; }
.ring svg { width: 96px; height: 96px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring .bg { stroke: var(--line); }
.ring .fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 0.25s linear; }
.ring .num { position: absolute; inset: 0; display: grid; place-items: center; font: 700 22px/1 var(--f-ui); font-variant-numeric: tabular-nums; }
.ring .pulse { position: absolute; inset: 18px; border-radius: 50%; background: var(--accent-soft); animation: press var(--beat, 1.6s) ease-in-out infinite; z-index: -1; }
@keyframes press { 0%, 100% { transform: scale(0.72); opacity: 0.4; } 45% { transform: scale(1); opacity: 1; } }
.gbody { display: grid; gap: 6px; min-width: 0; }
.gbody .top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--ink-3); font-weight: 600; }
.gbody h3 { font-size: 22px; }
.gbody p { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.gbody .side { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; font-weight: 700; color: var(--accent); }
.gctrl { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.gprog { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.gprog i { display: block; height: 100%; background: var(--gold); width: 0; transition: width 0.3s; }

/* learn */
.learn { display: grid; gap: 8px; }
.learn details { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.learn summary { cursor: pointer; padding: 12px 14px; font: 700 16px/1.3 var(--f-display); list-style: none; display: flex; justify-content: space-between; align-items: center; }
.learn summary::after { content: '+'; font: 500 18px/1 var(--f-ui); color: var(--ink-3); }
.learn details[open] summary::after { content: '–'; }
.learn .lb { padding: 0 14px 14px; font-size: 14px; color: var(--ink-2); }
.learn .lb p { margin: 0 0 8px; }
.learn ul { padding-left: 18px; margin: 6px 0 10px; }
.learn li { margin-bottom: 5px; }
.el-list { list-style: none; padding: 0 !important; }
.el-list li { display: flex; gap: 8px; align-items: baseline; }
.cun-fig { background: var(--surface-2); border-radius: 10px; padding: 10px; margin: 8px 0; }
.cun-fig svg { width: 100%; height: auto; display: block; max-width: 360px; margin: 0 auto; }
.cun-hand rect { fill: #e7b48f; stroke: #2a211d; stroke-width: 2; }
.cun-mark line { stroke: var(--danger); stroke-width: 3; stroke-linecap: round; }
.cun-lab text { font: 700 14px var(--f-ui); fill: var(--ink); text-anchor: middle; }

/* disclaimer */
.disclaimer { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); width: min(620px, calc(100% - 32px)); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 12px; box-shadow: var(--shadow); padding: 12px 16px; display: grid; gap: 6px; z-index: 50; font-size: 13.5px; }
.disclaimer b { font-family: var(--f-display); font-size: 16px; }
.disclaimer p { margin: 0; color: var(--ink-2); }
.disclaimer .btn { justify-self: end; }
.toast { position: fixed; left: 50%; top: calc(var(--top) + 12px); transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: 13.5px; z-index: 60; }

/* ---------- character picker ---------- */
.chardlg { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 24px; }
.chardlg .scrim { position: absolute; inset: 0; background: rgb(15 25 21 / 0.42); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); opacity: 0; transition: opacity 0.2s; }
.chardlg .sheet { position: relative; width: min(1000px, 100%); max-height: 100%; display: flex; flex-direction: column; background: var(--surface); border-radius: 20px; box-shadow: 0 24px 60px rgb(0 0 0 / 0.28); overflow: hidden; transform: translateY(14px) scale(0.985); opacity: 0; transition: transform 0.22s ease, opacity 0.22s ease; }
.chardlg.open .scrim { opacity: 1; }
.chardlg.open .sheet { transform: none; opacity: 1; }
.chardlg header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 22px 6px; }
.chardlg header h2 { font-size: 26px; }
.chardlg header p { margin: 4px 0 0; color: var(--ink-2); font-size: 14px; }
.chardlg .filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 22px 14px; border-bottom: 1px solid var(--line); }
.cgrid { overflow: auto; padding: 16px 22px 26px; display: grid; gap: 22px; overscroll-behavior: contain; }
.cgrp h3 { display: flex; align-items: center; gap: 8px; font-size: 17px; margin-bottom: 10px; color: var(--g); }
.cgrp h3 i { width: 14px; height: 14px; background: var(--g); clip-path: polygon(50% 0, 100% 38%, 82% 100%, 18% 100%, 0 38%); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
.ccard { position: relative; display: flex; flex-direction: column; padding: 0; text-align: left; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); overflow: hidden; transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s; }
.ccard:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--g) 50%, var(--line)); }
.ccard[aria-pressed="true"] { border-color: var(--g); box-shadow: 0 0 0 2px var(--g); }
.ccard .art { position: relative; display: block; aspect-ratio: 3 / 4; background: linear-gradient(180deg, color-mix(in srgb, var(--g) 9%, var(--surface)), color-mix(in srgb, var(--g) 20%, var(--surface))); }
.ccard .hills { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 34%; }
.ccard .hills .h1 { fill: color-mix(in srgb, var(--g) 34%, var(--surface)); }
.ccard .hills .h2 { fill: color-mix(in srgb, var(--g) 55%, var(--surface)); }
.ccard img { position: absolute; inset: 2% 0 0; width: 100%; height: 98%; object-fit: contain; transition: transform 0.2s; }
.ccard:hover img { transform: scale(1.04); }
.ccard .meta { display: grid; gap: 1px; padding: 8px 10px 10px; }
.ccard .meta b { font-size: 14px; line-height: 1.25; }
.ccard .meta small { font-size: 12px; color: var(--ink-3); line-height: 1.3; }
.ccard .badge, .ccard .on { position: absolute; font-size: 10.5px; font-weight: 700; letter-spacing: 0.02em; padding: 2px 7px; border-radius: 999px; }
.ccard .badge { left: 8px; top: 8px; background: #c8322a; color: #fff4c2; }
.ccard .on { right: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 3px; background: #fff; color: var(--g); box-shadow: 0 1px 3px rgb(0 0 0 / 0.18); }
.ccard .on svg { width: 11px; height: 11px; }

/* ---------- small screens: stage fills, panels become bottom sheets ---------- */
@media (max-width: 900px) {
  :root { --top: 56px; }
  .topbar { gap: 10px; padding: 0 12px; }
  .brand small { display: none; }
  .brand b { font-size: 17px; }
  .search { max-width: none; }
  .main { display: block; position: relative; }
  .stage { position: absolute; inset: 0; }
  .panel.left { position: fixed; left: 0; right: 0; bottom: 0; height: var(--sheet, 46%); border: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; box-shadow: 0 -8px 24px rgb(0 0 0 / 0.12); z-index: 20; transition: height 0.3s ease; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .panel.left.min { --sheet: 108px; }
  .panel.left.max { --sheet: calc(100% - var(--top) - 24px); }
  .sheet-handle { display: block; width: 100%; height: 18px; border: 0; background: none; flex: none; position: relative; }
  .sheet-handle::before { content: ''; position: absolute; left: 50%; top: 7px; width: 42px; height: 5px; border-radius: 3px; background: var(--line); transform: translateX(-50%); }
  .tabs { padding-top: 0; }
  .panel.right { position: fixed; left: 0; right: 0; bottom: 0; width: auto; height: 62%; border: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; box-shadow: 0 -8px 24px rgb(0 0 0 / 0.16); z-index: 25; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .viewbar { right: 10px; top: 10px; }
  .viewbar .grp.views { display: none; }
  .guide { bottom: calc(var(--guide-bottom, 118px)); grid-template-columns: 76px 1fr; padding: 12px; gap: 10px; }
  .ring, .ring svg { width: 76px; height: 76px; }
  .ring .pulse { inset: 14px; }
  .gbody h3 { font-size: 19px; }
  .stagehint { display: none; }
  .bubble { font-size: 12px; padding: 6px 10px; }
}
@media (max-width: 560px) {
  .brand > div { display: none; }
  .controls { gap: 6px; }
  .controls .seg button { padding: 5px 8px; }
  .charbtn { padding: 0 4px; gap: 2px; }
  .charbtn .nm { display: none; }
  .chardlg { padding: 0; place-items: end stretch; }
  .chardlg .sheet { width: 100%; max-height: calc(100% - 28px); border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .chardlg header { padding: 16px 16px 4px; }
  .chardlg header h2 { font-size: 22px; }
  .chardlg header p { font-size: 13px; }
  .chardlg .filters { padding: 8px 16px 12px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .chardlg .filters .chip { flex: none; }
  .cgrid { padding: 14px 16px 22px; gap: 18px; }
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .ccard { border-radius: 12px; }
  .ccard .meta { padding: 6px 7px 8px; }
  .ccard .meta b { font-size: 12.5px; }
  .ccard .meta small { font-size: 10.5px; }
  .ccard .badge, .ccard .on { font-size: 9px; padding: 1px 5px; }
  .ccard .badge { left: 5px; top: 5px; }
  .ccard .on { right: 5px; bottom: 5px; }
  .controls #themeBtn { display: none; }
  .search input { padding-left: 34px; padding-right: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
@media (max-width: 900px) {
  .lbl.num { width: 18px; height: 18px; font-size: 10px; border-width: 1.5px; }
  .lbl { font-size: 11px; padding: 1px 6px; }
}
@media (max-width: 900px) {
  .search:focus-within { position: absolute; left: 60px; right: 12px; top: 8px; z-index: 45; }
  .search:focus-within input { height: 40px; }
  .qres { position: fixed; left: 8px; right: 8px; top: calc(var(--top) + 4px); max-height: 60vh; }
}
