/* d-srt 玻璃箱 — 設計系統 v2（2026-09）
   方向：暖紙底、墨字、單一朱砂強調；襯線只用喺品牌字同大數字；等寬字畀提示詞／數字。
   禁：紫漸變、Inter 獨大、圓角 pill 堆、多層陰影、玻璃擬態、Google Fonts 拉中文字體。 */

/* ── 字體（自 host，Latin 子集，共 73KB；中文全部用系統字，零下載） ── */
@font-face {
  font-family: "Instrument Serif";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("/assets/fonts/instrument-serif-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Instrument Serif";
  font-style: italic; font-weight: 400; font-display: swap;
  src: url("/assets/fonts/instrument-serif-italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("/assets/fonts/ibm-plex-mono-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal; font-weight: 500; font-display: swap;
  src: url("/assets/fonts/ibm-plex-mono-500-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ── Tokens ── */
:root {
  --paper: #f5f1e8;
  --paper-2: #fcfaf5;
  --paper-3: #ece6d8;
  --paper-4: #e2dac9;
  --ink: #17150f;
  --ink-2: #45403a;
  --ink-3: #6b655c;
  --ink-4: #a09889;
  --line: #e2dbcb;
  --line-2: #cdc4b0;

  --accent: #c8451f;
  --accent-ink: #a53716;
  --accent-soft: #f8e7df;
  --accent-line: #ebbca8;

  --ok: #2c6e49;      --ok-soft: #e2efe5;
  --warn: #9a6b0d;    --warn-soft: #f7ebd0;
  --err: #a8213a;     --err-soft: #f7dfe3;
  --info: #3b5b8f;    --info-soft: #e2e8f2;

  --font-sans: "PingFang TC", "Microsoft JhengHei UI", "Microsoft JhengHei", "Noto Sans CJK TC", "Source Han Sans TC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;

  --r-1: 6px; --r-2: 10px; --r-3: 16px;
  --sh-1: 0 1px 2px rgba(23, 21, 15, .06), 0 1px 1px rgba(23, 21, 15, .04);
  --sh-2: 0 1px 2px rgba(23, 21, 15, .05), 0 14px 36px -18px rgba(23, 21, 15, .22);
  --sh-3: 0 2px 4px rgba(23, 21, 15, .06), 0 28px 72px -28px rgba(23, 21, 15, .32);

  --max: 1180px;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --t-fast: 140ms; --t: 220ms;
  --topbar-h: 60px;
  color-scheme: light;
}

/* ── Reset / base ── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "palt" 1;
  min-height: 100dvh;
  display: flex; flex-direction: column;
}
/* 紙紋：極淡顆粒，印刷感 */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  opacity: .045; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
main { flex: 1; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent-ink); text-decoration: none; text-underline-offset: .18em; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code, pre, kbd, .mono { font-family: var(--font-mono); }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
::selection { background: var(--accent-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
.muted { color: var(--ink-3); }
.skip { position: absolute; left: 1rem; top: -3rem; background: var(--ink); color: var(--paper); padding: .5rem .9rem; border-radius: var(--r-1); z-index: 100; transition: top var(--t-fast); }
.skip:focus { top: .75rem; }

.wrap { width: min(var(--max), 100% - 2 * var(--gutter)); margin-inline: auto; }

/* ── Topbar ── */
.topbar {
  position: sticky; top: 0; z-index: 50; height: var(--topbar-h);
  background: color-mix(in oklab, var(--paper) 86%, transparent);
  backdrop-filter: saturate(1.2) blur(12px); -webkit-backdrop-filter: saturate(1.2) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { height: 100%; display: flex; align-items: center; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .7rem; color: var(--ink); text-decoration: none !important; white-space: nowrap; flex: none; }
.seal {
  width: 30px; height: 30px; border-radius: 6px; background: var(--accent); color: #fbf3ea;
  display: grid; place-items: center; font-weight: 700; font-size: 15px; line-height: 1;
  box-shadow: inset 0 0 0 1.5px rgba(251, 243, 234, .55), inset 0 0 0 4px var(--accent);
}
.wordmark { font-family: var(--font-serif); font-style: italic; font-size: 1.5rem; letter-spacing: .01em; line-height: 1; padding-top: 2px; }
.brand-sub { font-size: .95rem; color: var(--ink-2); padding-left: .7rem; border-left: 1px solid var(--line-2); line-height: 1; }
.nav { margin-left: auto; display: flex; gap: .25rem; flex: none; }
.nav a {
  position: relative; color: var(--ink-2); font-size: .95rem; padding: .45rem .7rem; border-radius: var(--r-1);
  text-decoration: none !important; transition: color var(--t-fast), background var(--t-fast); white-space: nowrap;
}
@media (max-width: 560px) {
  .brand-sub { display: none; }
  .wordmark { font-size: 1.35rem; }
  .nav a { padding: .4rem .5rem; font-size: .9rem; }
}
.nav a:hover { color: var(--ink); background: color-mix(in oklab, var(--ink) 5%, transparent); }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.nav a[aria-current="page"]::after {
  content: ""; position: absolute; left: .7rem; right: .7rem; bottom: .15rem; height: 2px; background: var(--accent); border-radius: 2px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  height: 44px; padding: 0 1.15rem; border-radius: var(--r-1); border: 1px solid transparent;
  font-size: .95rem; font-weight: 600; letter-spacing: .005em; white-space: nowrap; text-decoration: none !important;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: #fff7f2; box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, var(--sh-1); }
.btn-primary:hover:not(:disabled) { background: var(--accent-ink); }
.btn-secondary { background: var(--paper-2); color: var(--ink); border-color: var(--line-2); box-shadow: var(--sh-1); }
.btn-secondary:hover:not(:disabled) { border-color: var(--ink-4); background: #fff; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: color-mix(in oklab, var(--ink) 6%, transparent); color: var(--ink); }
.btn-danger { background: var(--paper-2); color: var(--err); border-color: color-mix(in oklab, var(--err) 35%, var(--line-2)); }
.btn-danger:hover:not(:disabled) { background: var(--err-soft); }
.btn-sm { height: 34px; padding: 0 .8rem; font-size: .85rem; }
.btn-lg { height: 52px; padding: 0 1.5rem; font-size: 1.05rem; }
.btn-block { width: 100%; }
.iconbtn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-1);
  border: 1px solid var(--line); background: var(--paper-2); color: var(--ink-2); transition: all var(--t-fast);
}
.iconbtn:hover { color: var(--ink); border-color: var(--line-2); background: #fff; }
.iconbtn svg { width: 16px; height: 16px; }
.btn svg { width: 16px; height: 16px; flex: none; }

/* ── Fields ── */
.field { display: grid; gap: .4rem; }
.field-label { font-size: .875rem; font-weight: 600; color: var(--ink-2); display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.field-label .opt { font-weight: 400; color: var(--ink-3); font-size: .8rem; }
.field-help { font-size: .8125rem; color: var(--ink-3); line-height: 1.5; }
.input, .select, .textarea {
  width: 100%; background: var(--paper-2); border: 1px solid var(--line-2); border-radius: var(--r-1);
  padding: .7rem .9rem; font-size: 1rem; line-height: 1.5; color: var(--ink);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  box-shadow: var(--sh-1);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-4); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: #fff; }
.textarea { resize: vertical; min-height: 3.4rem; }
.select {
  appearance: none; padding-right: 2.4rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2345403a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .8rem center;
}
.input-lg { padding: .9rem 1rem; font-size: 1.1rem; }

/* Segmented control */
.seg { display: flex; padding: 3px; background: var(--paper-3); border-radius: calc(var(--r-1) + 3px); border: 1px solid var(--line); gap: 2px; flex-wrap: wrap; }
.seg label { position: relative; flex: 1 1 auto; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg span {
  display: flex; align-items: center; justify-content: center; height: 34px; padding: 0 .7rem; border-radius: var(--r-1);
  font-size: .875rem; color: var(--ink-2); transition: all var(--t-fast); white-space: nowrap;
}
.seg input:checked + span { background: var(--paper-2); color: var(--ink); font-weight: 600; box-shadow: var(--sh-1); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg input:hover:not(:checked) + span { color: var(--ink); }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: .7rem; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  width: 42px; height: 24px; border-radius: 12px; background: var(--paper-4); border: 1px solid var(--line-2); position: relative;
  transition: background var(--t-fast), border-color var(--t-fast); flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform var(--t) var(--ease);
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent-ink); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch .sw-text { display: grid; line-height: 1.35; }
.switch .sw-text b { font-weight: 600; font-size: .95rem; }
.switch .sw-text small { color: var(--ink-3); font-size: .8rem; }

/* ── Cards / surfaces ── */
.card { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r-2); box-shadow: var(--sh-1); }
.card-pad { padding: 1.25rem; }
.card-lift { box-shadow: var(--sh-2); }
.inset { background: var(--paper-3); border: 1px solid var(--line); border-radius: var(--r-1); }

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: .35rem; height: 22px; padding: 0 .55rem; border-radius: 5px;
  font-size: .75rem; font-weight: 600; line-height: 1; white-space: nowrap; letter-spacing: .01em;
  background: var(--paper-3); color: var(--ink-2); border: 1px solid var(--line);
}
.chip svg { width: 11px; height: 11px; }
.chip-accent { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent-line); }
.chip-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in oklab, var(--ok) 30%, var(--line)); }
.chip-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in oklab, var(--warn) 30%, var(--line)); }
.chip-err { background: var(--err-soft); color: var(--err); border-color: color-mix(in oklab, var(--err) 30%, var(--line)); }
.chip-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in oklab, var(--info) 30%, var(--line)); }
.chip-ink { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip-mono { font-family: var(--font-mono); font-weight: 500; }

/* Banner */
.banner { display: flex; gap: .75rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--r-1); border: 1px solid; font-size: .9rem; line-height: 1.5; }
.banner svg { width: 18px; height: 18px; flex: none; margin-top: .1rem; }
.banner-info { background: var(--info-soft); border-color: color-mix(in oklab, var(--info) 30%, var(--line)); color: var(--info); }
.banner-warn { background: var(--warn-soft); border-color: color-mix(in oklab, var(--warn) 35%, var(--line)); color: var(--warn); }
.banner-err { background: var(--err-soft); border-color: color-mix(in oklab, var(--err) 35%, var(--line)); color: var(--err); }
.banner-ok { background: var(--ok-soft); border-color: color-mix(in oklab, var(--ok) 35%, var(--line)); color: var(--ok); }
.banner b { color: inherit; }

/* Section titles */
.eyebrow { font-family: var(--font-mono); font-size: .75rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); }
.sec-title { font-size: .8125rem; font-weight: 600; color: var(--ink-3); letter-spacing: .02em; display: flex; align-items: center; gap: .75rem; }
.sec-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Code block */
.codeblock { border: 1px solid var(--line); border-radius: var(--r-1); background: var(--paper-3); overflow: hidden; }
.codeblock-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .4rem .5rem .4rem .8rem; border-bottom: 1px solid var(--line); background: color-mix(in oklab, var(--paper-3) 60%, var(--paper-2)); }
.codeblock-head .lbl { font-size: .75rem; font-weight: 600; color: var(--ink-3); letter-spacing: .02em; }
.codeblock pre {
  margin: 0; padding: .85rem 1rem; font-size: .8125rem; line-height: 1.6; color: var(--ink-2);
  white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2; max-height: 480px; overflow: auto;
}
.codeblock pre.lang-json .k { color: var(--accent-ink); }
.copybtn { display: inline-flex; align-items: center; gap: .35rem; height: 26px; padding: 0 .55rem; border-radius: 5px; border: 1px solid var(--line-2); background: var(--paper-2); color: var(--ink-2); font-size: .75rem; font-weight: 600; transition: all var(--t-fast); }
.copybtn:hover { color: var(--ink); background: #fff; }
.copybtn svg { width: 12px; height: 12px; }
.copybtn.is-ok { color: var(--ok); border-color: color-mix(in oklab, var(--ok) 40%, var(--line-2)); }

/* Disclosure */
.disc { border: 1px solid var(--line); border-radius: var(--r-1); background: var(--paper-2); }
.disc + .disc { margin-top: .6rem; }
.disc > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: .6rem; padding: .75rem .9rem;
  font-weight: 600; font-size: .925rem; color: var(--ink); user-select: none; border-radius: var(--r-1);
}
.disc > summary::-webkit-details-marker { display: none; }
.disc > summary:hover { background: color-mix(in oklab, var(--ink) 3%, transparent); }
.disc > summary .chev { width: 16px; height: 16px; color: var(--ink-3); transition: transform var(--t) var(--ease); flex: none; }
.disc[open] > summary .chev { transform: rotate(90deg); }
.disc > summary .hint { margin-left: auto; font-weight: 400; font-size: .8rem; color: var(--ink-3); }
.disc-body { padding: 0 .9rem .9rem; display: grid; gap: .75rem; }
.disc-l3 { background: transparent; border-style: dashed; }
.disc-l3 > summary { color: var(--ink-2); font-weight: 500; }

.plainlist { margin: 0; padding-left: 1.25rem; display: grid; gap: .4rem; font-size: .925rem; line-height: 1.55; }
.plainlist li::marker { color: var(--ink-4); font-family: var(--font-mono); font-size: .8rem; }
.hist-row { display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: start; }
.detail-back { padding: .75rem 1.1rem 0; }

/* KV grid */
.kv { display: grid; grid-template-columns: minmax(7.5rem, max-content) 1fr; gap: .45rem 1.25rem; font-size: .925rem; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.kv dd .num { font-size: .9rem; }

/* Table */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r-1); }
.table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.table th, .table td { padding: .55rem .75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { background: var(--paper-3); color: var(--ink-3); font-weight: 600; font-size: .775rem; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tr.is-hit td { background: var(--accent-soft); }
.table td.mono { font-size: .8rem; }

/* Provenance chain */
.chain { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.chain li { position: relative; display: grid; grid-template-columns: 20px 1fr; gap: .75rem; padding: .35rem 0; }
.chain li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin: .5rem auto 0; box-shadow: 0 0 0 3px var(--accent-soft); }
.chain li:not(:last-child)::after { content: ""; position: absolute; left: 9.5px; top: 1.4rem; bottom: -.4rem; width: 1px; background: var(--line-2); }
.chain .c-text { font-size: .925rem; line-height: 1.45; }
.chain .c-code { font-size: .75rem; color: var(--ink-3); }

/* Stats */
.stat { display: grid; gap: .1rem; }
.stat .k { font-size: .75rem; color: var(--ink-3); font-weight: 600; letter-spacing: .02em; }
.stat .v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 1.05rem; color: var(--ink); font-weight: 500; line-height: 1.2; }
.stat .v small { font-size: .75rem; color: var(--ink-3); font-weight: 400; margin-left: .25rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.stat-tile { padding: .9rem 1rem; border: 1px solid var(--line); border-radius: var(--r-1); background: var(--paper-2); }
.stat-tile .v { font-size: 1.35rem; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 0); z-index: 200;
  background: var(--ink); color: var(--paper); padding: .7rem 1.1rem; border-radius: var(--r-1); font-size: .9rem; box-shadow: var(--sh-3);
  opacity: 0; translate: 0 8px; pointer-events: none; transition: opacity var(--t), translate var(--t) var(--ease);
  max-width: min(90vw, 480px); text-align: center;
}
.toast.is-on { opacity: 1; translate: 0 0; }

/* Dialog / drawer */
dialog { border: 0; padding: 0; background: transparent; color: inherit; max-width: none; max-height: none; }
dialog::backdrop { background: rgba(23, 21, 15, .45); backdrop-filter: blur(2px); }
.dlg { width: min(92vw, 440px); background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r-3); box-shadow: var(--sh-3); padding: 1.5rem; margin: auto; }
.dlg h3 { font-size: 1.15rem; margin-bottom: .5rem; }
.dlg p { color: var(--ink-2); font-size: .95rem; }
.dlg-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.25rem; }
.drawer {
  position: fixed; inset: 0 0 0 auto; width: min(92vw, 420px); height: 100dvh; margin: 0; background: var(--paper-2);
  border-left: 1px solid var(--line); box-shadow: var(--sh-3); grid-template-rows: auto 1fr; border-radius: 0;
}
.drawer[open] { display: grid; animation: slideIn var(--t) var(--ease); }
@keyframes slideIn { from { translate: 24px 0; opacity: 0; } to { translate: 0 0; opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.drawer-head h3 { font-size: 1rem; }
.drawer-head .acts { display: flex; gap: .5rem; align-items: center; }
.drawer-body { overflow: auto; padding: 1rem 1.25rem; display: grid; gap: .6rem; align-content: start; }
.hist-item { display: grid; gap: .25rem; padding: .75rem .9rem; border: 1px solid var(--line); border-radius: var(--r-1); background: var(--paper); text-align: left; transition: all var(--t-fast); width: 100%; }
.hist-item:hover { border-color: var(--line-2); background: #fff; }
.hist-item .t { font-weight: 600; font-size: .925rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hist-item .m { font-size: .775rem; color: var(--ink-3); display: flex; gap: .6rem; flex-wrap: wrap; }
.hist-empty { color: var(--ink-3); font-size: .9rem; text-align: center; padding: 2rem 0; }

/* Skeleton */
.skel { position: relative; overflow: hidden; background: var(--paper-3); border-radius: 4px; color: transparent !important; }
.skel::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .55), transparent); translate: -100% 0; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { translate: 100% 0; } }

/* ── Footer ── */
.footer { border-top: 1px solid var(--line); margin-top: 4rem; padding: 2rem 0 2.5rem; color: var(--ink-3); font-size: .85rem; }
.footer .wrap { display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between; align-items: center; }
.footer .wordmark { font-size: 1.15rem; color: var(--ink-2); }

/* ═══════════════════════ 首頁 ═══════════════════════ */
.hero { padding: clamp(2.5rem, 7vw, 5.5rem) 0 clamp(2rem, 5vw, 3.5rem); }
.hero-grid { display: grid; gap: 2.5rem; align-items: start; }
@media (min-width: 980px) { .hero-grid { grid-template-columns: 1.05fr .95fr; gap: 4rem; } }
.hero h1 { font-size: clamp(2.1rem, 4.6vw, 3.5rem); line-height: 1.15; letter-spacing: -.02em; font-weight: 700; margin: .9rem 0 1.1rem; text-wrap: balance; }
.hero h1 em { font-family: var(--font-serif); font-style: italic; font-weight: 400; color: var(--accent); letter-spacing: 0; }
.hero .lede { font-size: clamp(1.05rem, 1.6vw, 1.2rem); color: var(--ink-2); max-width: 34em; line-height: 1.7; text-wrap: pretty; }
.hero-facts { display: flex; gap: 1.75rem; flex-wrap: wrap; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.hero-facts .stat .v { font-family: var(--font-serif); font-size: 2rem; font-weight: 400; font-variant-numeric: normal; letter-spacing: -.01em; }
.hero-facts .stat .v .cjk { font-family: var(--font-sans); font-size: 1rem; font-weight: 600; margin-left: .15rem; }

.runcard { padding: 1.5rem; display: grid; gap: 1.1rem; }
.runcard-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.runcard-head h2 { font-size: 1.05rem; }
.runcard-foot { display: grid; gap: .6rem; }
.runcard-foot .cost { font-size: .85rem; color: var(--ink-3); display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.runcard-foot .cost .num { color: var(--ink); font-weight: 500; }
.or { display: flex; align-items: center; gap: .75rem; color: var(--ink-4); font-size: .8rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.demo-link { display: flex; align-items: center; gap: .9rem; padding: .9rem 1rem; border: 1px dashed var(--line-2); border-radius: var(--r-1); color: var(--ink); text-decoration: none !important; transition: all var(--t-fast); background: var(--paper); }
.demo-link:hover { border-color: var(--accent); background: var(--accent-soft); }
.demo-link .ico { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; background: var(--paper-2); border: 1px solid var(--line); color: var(--accent); flex: none; }
.demo-link .ico svg { width: 18px; height: 18px; }
.demo-link b { display: block; font-size: .95rem; }
.demo-link small { color: var(--ink-3); font-size: .8rem; }

.section { padding: clamp(2rem, 5vw, 3.5rem) 0; }
.section-head { display: grid; gap: .5rem; margin-bottom: 1.75rem; max-width: 40em; }
.section-head h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); letter-spacing: -.015em; }
.section-head p { color: var(--ink-2); }

.stepstrip { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-2); overflow: hidden; }
@media (min-width: 720px) { .stepstrip { grid-template-columns: repeat(4, 1fr); } }
.stepstrip .s { background: var(--paper-2); padding: 1.1rem 1.1rem 1.25rem; display: grid; gap: .45rem; align-content: start; min-height: 150px; transition: background var(--t-fast); }
.stepstrip .s:hover { background: #fff; }
.stepstrip .n { font-family: var(--font-serif); font-size: 1.9rem; line-height: 1; color: var(--accent); }
.stepstrip .t { font-weight: 600; font-size: 1rem; }
.stepstrip .b { font-size: .825rem; color: var(--ink-3); line-height: 1.5; }
.stepstrip .s .chip { justify-self: start; margin-top: auto; }

.actions-row { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.25rem; }
.vstrip .s { min-height: 120px; }
.why { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.why li { display: grid; grid-template-columns: 3.5rem 1fr; gap: 1rem; padding: 1.35rem 0; border-bottom: 1px solid var(--line); align-items: start; }
.why .n { font-family: var(--font-serif); font-size: 1.75rem; color: var(--ink-4); line-height: 1; padding-top: .15rem; }
.why h3 { font-size: 1.1rem; margin-bottom: .3rem; }
.why p { color: var(--ink-2); max-width: 46em; }
@media (min-width: 900px) { .why li { grid-template-columns: 3.5rem 18rem 1fr; } .why h3 { margin: 0; } }

/* ═══════════════════════ 玻璃箱 ═══════════════════════ */
.taskbar { position: sticky; top: var(--topbar-h); z-index: 40; background: color-mix(in oklab, var(--paper) 90%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.taskbar .wrap { display: flex; align-items: center; gap: 1rem 1.5rem; min-height: 56px; padding-block: .5rem; flex-wrap: wrap; }
.task-state { display: flex; align-items: center; gap: .7rem; min-width: 0; flex: 1 1 260px; }
.task-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--ink-4); flex: none; position: relative; }
.task-dot[data-s="idle"] { background: var(--ink-4); }
.task-dot[data-s="running"] { background: var(--accent); }
.task-dot[data-s="running"]::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--accent); opacity: .6; animation: pulse 1.2s ease-out infinite; }
.task-dot[data-s="done"] { background: var(--ok); }
.task-dot[data-s="error"] { background: var(--err); }
.task-dot[data-s="warn"] { background: var(--warn); }
.task-dot[data-s="demo"] { background: var(--info); }
@keyframes pulse { from { transform: scale(.7); opacity: .7; } to { transform: scale(1.6); opacity: 0; } }
.task-text { display: grid; line-height: 1.3; min-width: 0; }
.task-text b { font-size: .95rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-text small { color: var(--ink-3); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-stats { display: flex; gap: 1.25rem; }
.task-stats .stat .v { font-size: .95rem; }
.task-actions { display: flex; gap: .5rem; margin-left: auto; }

.gb { display: grid; gap: 1.5rem; padding: 1.5rem 0 3rem; }
@media (min-width: 1024px) { .gb { grid-template-columns: 380px minmax(0, 1fr); gap: 2rem; align-items: start; } }
.gb-left { display: grid; gap: 1rem; align-content: start; }
#banner-slot { display: grid; gap: .6rem; }
#banner-slot:empty { display: none; }

/* form panel */
.setup { padding: 1.25rem; display: grid; gap: 1rem; }
.setup-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.setup-head h2 { font-size: 1rem; }
.grid2 { display: grid; gap: 1rem; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) { .setup .grid2 { grid-template-columns: 1fr; } }
.setup .seg span { padding: 0 .5rem; font-size: .8125rem; }
.setup-summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 1.1rem; }
.setup-summary .t { font-size: .925rem; min-width: 0; }
.setup-summary .t b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.setup-summary .t small { color: var(--ink-3); }

/* rail */
.rail { display: grid; gap: .35rem; margin: 0; padding: 0; list-style: none; }
.rail-item {
  position: relative; display: grid; grid-template-columns: 28px 1fr; gap: .8rem; width: 100%; text-align: left;
  padding: .75rem .9rem .75rem .75rem; border-radius: var(--r-2); border: 1px solid transparent; background: transparent;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
.rail-item:hover { background: color-mix(in oklab, var(--paper-2) 70%, transparent); border-color: var(--line); }
.rail-item[aria-current="step"] { background: var(--paper-2); border-color: var(--line-2); box-shadow: var(--sh-1); }
.rail-item[aria-current="step"]::before { content: ""; position: absolute; left: -1px; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--accent); }
.rail-item:not(:last-child) .rail-dot::after { content: ""; position: absolute; left: 50%; top: 30px; height: calc(100% + .35rem + .75rem); width: 1px; background: var(--line-2); translate: -50% 0; }
.rail-item:last-child .rail-dot::after { display: none; }
.rail-dot { position: relative; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--paper-2); border: 1.5px solid var(--line-2); color: var(--ink-3); font-family: var(--font-mono); font-size: .75rem; font-weight: 500; z-index: 1; }
.rail-dot svg { width: 14px; height: 14px; }
.rail-item[data-status="done"] .rail-dot { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.rail-item[data-status="reference"] .rail-dot { background: var(--paper-3); border-color: var(--line-2); color: var(--ink-2); }
.rail-item[data-status="active"] .rail-dot { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.rail-item[data-status="active"] .rail-dot::before { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--accent); opacity: .5; animation: pulse 1.2s ease-out infinite; }
.rail-item[data-status="error"] .rail-dot { background: var(--err); border-color: var(--err); color: #fff; border-radius: 6px; }
.rail-item[data-status="skipped"] .rail-dot { border-style: dashed; color: var(--ink-4); }
.rail-item[data-status="pending"] .rail-dot, .rail-item[data-status="preview"] .rail-dot { color: var(--ink-3); background: transparent; }
.rail-item[data-status="pending"] .rail-dot::before, .rail-item[data-status="preview"] .rail-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); }
.rail-item[data-status="disabled"] { opacity: .5; }
.rail-body { display: grid; gap: .25rem; min-width: 0; }
.rail-title { display: flex; align-items: center; gap: .5rem; font-weight: 600; font-size: .95rem; }
.rail-title .chip { margin-left: auto; }
.rail-sum { font-size: .8125rem; color: var(--ink-3); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rail-item[data-status="error"] .rail-sum { color: var(--err); }
.rail-meta { display: flex; gap: .75rem; font-size: .75rem; color: var(--ink-3); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* detail */
.detail { min-width: 0; }
.detail-head { display: grid; grid-template-columns: auto 1fr; gap: 1rem 1.25rem; align-items: start; padding: 1.35rem 1.5rem 1.15rem; border-bottom: 1px solid var(--line); }
.detail-n { font-family: var(--font-serif); font-size: 3rem; line-height: .9; color: var(--accent); min-width: 2ch; }
.detail-title { display: grid; gap: .45rem; min-width: 0; }
.detail-title h2 { font-size: 1.35rem; letter-spacing: -.015em; }
.detail-title .blurb { color: var(--ink-3); font-size: .9rem; line-height: 1.5; }
.detail-chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.detail-body { padding: 1.25rem 1.5rem 1.5rem; display: grid; gap: 1.25rem; }
.l1 { display: grid; gap: .9rem; }
.l1 .conclusion { font-size: 1.05rem; line-height: 1.55; color: var(--ink); padding: .9rem 1.1rem; border-left: 3px solid var(--accent); background: var(--paper); border-radius: 0 var(--r-1) var(--r-1) 0; }
.l1 .conclusion.is-err { border-color: var(--err); color: var(--err); }
.l1 .conclusion.is-muted { border-color: var(--line-2); color: var(--ink-2); }
.l1 .conclusion.is-pending { border-color: var(--line-2); color: var(--ink-3); }
.detail-meta { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .8rem; color: var(--ink-3); }
.detail-meta .num { color: var(--ink-2); }
.detail-empty { text-align: center; padding: 4rem 1rem; color: var(--ink-3); display: grid; gap: .5rem; justify-items: center; }
.detail-empty svg { width: 44px; height: 44px; color: var(--ink-4); }
.detail-nav { display: flex; justify-content: space-between; gap: .5rem; padding: 0 1.5rem 1.25rem; }

.prompt-src { display: flex; gap: .5rem; align-items: center; font-size: .8rem; color: var(--ink-3); flex-wrap: wrap; }
.prompt-pane { display: grid; gap: .6rem; }
.varmark { background: var(--accent-soft); color: var(--accent-ink); border-radius: 3px; padding: 0 .2em; }

/* mobile detail: inline under rail item */
@media (max-width: 1023px) {
  .gb-right { display: none; }
  .gb-right.is-mobile-open { display: block; }
  .detail-head { padding: 1.1rem 1.1rem .9rem; }
  .detail-body { padding: 1rem 1.1rem 1.25rem; }
  .detail-n { font-size: 2.4rem; }
  .task-stats { display: none; }
}

/* ═══════════════════════ 行業包 ═══════════════════════ */
.vpage { padding: 2.5rem 0 3rem; display: grid; gap: 1.5rem; }
.vpage .section-head h1 { font-size: clamp(1.8rem, 3vw, 2.4rem); letter-spacing: -.02em; }
.vgrid { display: grid; gap: 1.5rem; align-items: start; }
@media (min-width: 980px) { .vgrid { grid-template-columns: 220px minmax(0, 1fr); } .vindex { position: sticky; top: calc(var(--topbar-h) + 1rem); } }
.vindex { padding: 1rem; display: grid; gap: .15rem; }
.vindex-link { display: flex; justify-content: space-between; gap: .5rem; padding: .4rem .5rem; border-radius: var(--r-1); color: var(--ink); text-decoration: none !important; font-size: .925rem; }
.vindex-link:hover { background: var(--paper-3); }
.vindex-link small { font-size: .7rem; }
.vlist { display: grid; gap: 1.25rem; }
.vcard { padding: 1.5rem; display: grid; gap: 1rem; scroll-margin-top: calc(var(--topbar-h) + 1rem); }
.vcard-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.vcard-head h2 { font-size: 1.35rem; letter-spacing: -.015em; }
.vcard-alias { font-size: .85rem; }
.vcard-grid { display: grid; gap: 1.25rem; }
@media (min-width: 800px) { .vcard-grid { grid-template-columns: 1.2fr .8fr; } }
.table td.is-extra { background: var(--accent-soft); }

/* ═══════════════════════ 整客戶卡 ═══════════════════════ */
.ncgrid { display: grid; gap: 1.5rem; align-items: start; }
@media (min-width: 1024px) { .ncgrid { grid-template-columns: minmax(0, 1fr) 420px; } .ncgrid .nc-side { position: sticky; top: calc(var(--topbar-h) + 1rem); } }
.cpm-result { display: grid; gap: .75rem; }
.cpm-result .stat-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }

/* ═══════════════════════ 後台 ═══════════════════════ */
.admin { padding: 2.5rem 0 3rem; display: grid; gap: 1.5rem; }
.login { width: min(100%, 420px); margin: 3rem auto; padding: 1.75rem; display: grid; gap: 1rem; }
.login h1 { font-size: 1.35rem; }
.login p { color: var(--ink-2); font-size: .925rem; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.admin-head h1 { font-size: 1.6rem; letter-spacing: -.015em; }
.admin-grid { display: grid; gap: 1.25rem; }
@media (min-width: 900px) { .admin-grid { grid-template-columns: 1fr 1fr; } .admin-grid .span2 { grid-column: 1 / -1; } }
.panel { padding: 1.35rem; display: grid; gap: 1rem; }
.panel h2 { font-size: 1.05rem; display: flex; align-items: center; gap: .6rem; }
.panel .desc { color: var(--ink-3); font-size: .875rem; line-height: 1.5; }
.toggle-list { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--r-1); overflow: hidden; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem .9rem; background: var(--paper-2); border-bottom: 1px solid var(--line); }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row .t { display: grid; gap: .1rem; min-width: 0; }
.toggle-row .t b { font-size: .925rem; font-weight: 600; display: flex; gap: .5rem; align-items: center; }
.toggle-row .t small { color: var(--ink-3); font-size: .8rem; }
.savebar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 1rem 1.25rem; }
.savebar .msg { font-size: .9rem; color: var(--ink-2); flex: 1; min-width: 200px; }
.savebar .msg.is-err { color: var(--err); }
.savebar .msg.is-ok { color: var(--ok); }
.count { font-family: var(--font-mono); font-size: .75rem; color: var(--ink-3); }

/* ═══════════════════════ 404 ═══════════════════════ */
.nf { text-align: center; padding: 6rem 0; display: grid; gap: 1rem; justify-items: center; }
.nf .big { font-family: var(--font-serif); font-size: 6rem; line-height: 1; color: var(--accent); }

/* ── Motion preferences ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
@media print {
  .topbar, .taskbar, .footer, .task-actions, .copybtn { display: none !important; }
  body::before { display: none; }
  .gb { grid-template-columns: 1fr; }
}
