/* TaiLexi AI U.S. Case Law — 版面與字體
   原則：資訊密度高但好讀；判決內文用襯線字、像印刷版判決彙編；命中字詞用螢光筆黃；深色模式完整。 */

:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f0ece4;
  --surface-3: #e9e3d8;
  --ink: #161e2b;
  --ink-2: #364153;
  --muted: #687284;
  --line: #e2ddd2;
  --line-2: #cfc7b8;
  --navy: #1b2f4e;
  --navy-2: #2a4a78;
  --navy-ink: #f4efe2;
  --link: #1f4b99;
  --visited: #5a3d8a;
  --brass: #9a742a;
  --brass-soft: #f3e6c4;
  --mark: #ffe27a;
  --mark-cur: #ffb340;
  --sep: #8a2f2f;
  --conc: #3d5a80;
  --warn: #8a5a00;
  --warn-bg: #fff4d6;
  --ok: #2f6b4f;
  --shadow: 0 1px 2px rgba(22, 30, 43, .06), 0 6px 20px rgba(22, 30, 43, .06);
  --shadow-lg: 0 2px 6px rgba(22, 30, 43, .08), 0 18px 48px rgba(22, 30, 43, .12);
  --radius: 10px;
  --read-size: 18px;
  --ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1219; --surface: #131a24; --surface-2: #19222f; --surface-3: #212c3b;
    --ink: #e8ebf1; --ink-2: #c4cbd7; --muted: #8e98aa; --line: #232e3e; --line-2: #2e3b50;
    --navy: #0a1220; --navy-2: #7ea2d9; --navy-ink: #efe6cf; --link: #8db4ff; --visited: #c4a8f0;
    --brass: #d8b665; --brass-soft: #3a3020; --mark: rgba(250, 204, 21, .34); --mark-cur: rgba(251, 146, 60, .62);
    --sep: #f0a3a3; --conc: #9db8e0; --warn: #f0c36a; --warn-bg: #2f2612; --ok: #8fd1b0;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .5), 0 18px 48px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1219; --surface: #131a24; --surface-2: #19222f; --surface-3: #212c3b;
  --ink: #e8ebf1; --ink-2: #c4cbd7; --muted: #8e98aa; --line: #232e3e; --line-2: #2e3b50;
  --navy: #0a1220; --navy-2: #7ea2d9; --navy-ink: #efe6cf; --link: #8db4ff; --visited: #c4a8f0;
  --brass: #d8b665; --brass-soft: #3a3020; --mark: rgba(250, 204, 21, .34); --mark-cur: rgba(251, 146, 60, .62);
  --sep: #f0a3a3; --conc: #9db8e0; --warn: #f0c36a; --warn-bg: #2f2612; --ok: #8fd1b0;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .5), 0 18px 48px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 84px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--ui); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  min-height: 100vh; display: flex; flex-direction: column;
}
main { flex: 1; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
code, kbd { font: 0.88em/1.3 ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace; }
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; color: var(--ink); white-space: nowrap; }
kbd { background: var(--surface); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; border-radius: 6px; }
.skip:focus { left: 8px; }
.dim { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.fine { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.wrap.narrow { max-width: 820px; }
:focus-visible { outline: 2px solid var(--navy-2); outline-offset: 2px; border-radius: 4px; }

/* ---------- 中文介面：介面字用思源黑體、標題用思源宋體；判決本文（lang="en"）維持英文字型 ---------- */
body.lang-zh { --ui: "Inter", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif; }
body.lang-zh h1, body.lang-zh h2, body.lang-zh .lede, body.lang-zh .feat h2 { font-family: "Source Serif 4", "Noto Serif TC", "Songti TC", "PMingLiU", serif; }
body.lang-zh [lang="en"] { font-family: inherit; }
body.lang-zh .case-title, body.lang-zh .case, body.lang-zh .op-body, body.lang-zh .snips, body.lang-zh .parens, body.lang-zh .mini-list a,
body.lang-zh .auth-table td, body.lang-zh .cite-line .bb, body.lang-zh .citing-of { font-family: var(--serif); }

/* ---------- 頂列 ---------- */
.topbar { position: sticky; top: 0; z-index: 40; background: var(--navy); color: var(--navy-ink); box-shadow: 0 1px 0 rgba(0, 0, 0, .2); }
.topbar-in { max-width: 1400px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 22px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--navy-ink); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: rgba(233, 216, 166, .14); color: #e9d8a6; font: 600 21px/1 var(--serif); }
.brand-name { font-weight: 650; letter-spacing: .01em; }
.brand-product { font: 400 15px/1 var(--serif); font-style: italic; color: #d9cfb7; border-left: 1px solid rgba(255, 255, 255, .2); padding-left: 10px; }
.toplinks { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.toplinks a { color: #e8e2d2; font-size: 14px; padding: 6px 10px; border-radius: 6px; }
.toplinks a:hover { background: rgba(255, 255, 255, .08); text-decoration: none; }
.langbtn { font-weight: 600; border: 1px solid rgba(255, 255, 255, .25); border-radius: 7px; padding: 4px 9px !important; font-size: 13px !important; }
.endpoint { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 18px 0 8px; }
.endpoint code { flex: 1; font-size: 15px; background: none; border: 0; padding: 0; color: var(--navy-2); white-space: normal; word-break: break-all; }
.iconbtn { background: transparent; border: 0; color: #e8e2d2; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; font-size: 16px; }
.iconbtn:hover { background: rgba(255, 255, 255, .1); }
.iconbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* ---------- 搜尋框 ---------- */
.searchbox { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; flex: 1; max-width: 760px; position: relative; transition: box-shadow .15s, border-color .15s; }
.topbar .searchbox { border-color: transparent; }
.searchbox:focus-within { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(42, 74, 120, .18); }
.searchbox input[type="search"] { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: 15.5px/1.3 var(--ui); padding: 10px 14px; outline: none; }
.searchbox input::-webkit-search-cancel-button { cursor: pointer; }
.searchbox button[type="submit"] { display: flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--navy-2); padding: 8px 14px; cursor: pointer; font: 600 14px var(--ui); border-left: 1px solid var(--line); border-radius: 0 10px 10px 0; align-self: stretch; }
.searchbox button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.searchbox button span { display: none; }
.searchbox.big { flex-wrap: wrap; max-width: 820px; margin: 28px auto 0; border-radius: 14px; box-shadow: var(--shadow-lg); border-color: var(--line); }
.searchbox.big input[type="search"] { font-size: 18px; padding: 18px 20px; }
.searchbox.big button[type="submit"] { background: var(--navy); color: var(--navy-ink); border-radius: 0 13px 0 0; padding: 0 22px; border: 0; }
.searchbox.big button span { display: inline; }
.searchbox.big button:hover { background: var(--navy-2); }
.scope { flex-basis: 100%; border: 0; border-top: 1px solid var(--line); margin: 0; padding: 10px 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 13.5px; color: var(--ink-2); }
.scope-label { float: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; padding: 0; margin-right: 4px; }
.scope label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; padding: 4px 10px; border-radius: 99px; border: 1px solid transparent; }
.scope label:has(input:checked) { background: var(--brass-soft); border-color: color-mix(in srgb, var(--brass) 45%, transparent); color: var(--ink); }
.scope input { accent-color: var(--navy-2); margin: 0; }

/* ---------- 首頁 ---------- */
.hero { max-width: 980px; margin: 0 auto; padding: 72px 24px 40px; text-align: center; }
.hero h1 { font: 600 clamp(30px, 4.6vw, 48px)/1.12 var(--serif); letter-spacing: -.012em; margin: 0; color: var(--ink); }
.hero h1 .num { color: var(--brass); font-variant-numeric: lining-nums; white-space: nowrap; }
.lede { font: 400 18px/1.55 var(--serif); color: var(--ink-2); max-width: 720px; margin: 16px auto 0; }
.examples { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 26px auto 0; max-width: 900px; align-items: center; }
.ex-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-right: 4px; }
.examples a { display: inline-flex; align-items: baseline; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 7px 11px; color: var(--ink); box-shadow: 0 1px 1px rgba(0, 0, 0, .03); }
.examples a:hover { border-color: var(--line-2); text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); }
.examples code { background: none; border: 0; padding: 0; font-size: 13px; color: var(--navy-2); }
.examples small { color: var(--muted); font-size: 11.5px; }
.coverage { max-width: 1040px; margin: 24px auto 0; padding: 0 24px; }
.cov-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.cov { background: var(--surface); padding: 18px 20px; color: var(--ink); display: flex; flex-direction: column; gap: 4px; }
.cov:hover { background: var(--surface-2); text-decoration: none; }
.cov-n { font: 600 26px/1.1 var(--serif); font-variant-numeric: tabular-nums lining-nums; }
.cov-l { font-size: 13px; color: var(--muted); }
.fresh { display: inline-flex; align-items: center; gap: 0; margin: 0 0 20px; padding: 5px 14px 5px 12px; border: 1px solid var(--line-2);
  border-radius: 999px; font: 500 13px/1.4 var(--ui); color: var(--ink-2); background: var(--surface, transparent); }
.fresh .dot { width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--ok); flex: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); animation: fresh-pulse 2.4s ease-in-out infinite; }
@keyframes fresh-pulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--ok) 8%, transparent); } }
@media (prefers-reduced-motion: reduce) { .fresh .dot { animation: none; } }
.cov-note { text-align: center; color: var(--muted); font-size: 13px; margin: 12px 0 0; }
.features { max-width: 1120px; margin: 56px auto 72px; padding: 0 24px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 28px; }
.feat h2 { font: 600 19px/1.3 var(--serif); margin: 0 0 8px; }
.feat p { margin: 0; color: var(--ink-2); font-size: 14.5px; line-height: 1.6; }
.feat code { font-size: 12px; display: inline-block; }
.feat .chips-line { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }

/* ---------- 結果頁 ---------- */
.results-layout { max-width: 1320px; margin: 0 auto; padding: 24px 24px 64px; display: grid; grid-template-columns: 272px minmax(0, 1fr); gap: 36px; align-items: start; }
.facets { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; padding-right: 4px; scrollbar-width: thin; }
.facets-box > summary { display: none; }
.facet { padding: 14px 0; border-bottom: 1px solid var(--line); }
.facet:first-of-type { padding-top: 0; }
.facet h3 { margin: 0 0 8px; font: 600 11.5px/1.2 var(--ui); text-transform: uppercase; letter-spacing: .09em; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.hint { cursor: help; font-weight: 400; color: var(--muted); }
.facet-list { list-style: none; margin: 0; padding: 0; }
.facet-list li.extra { display: none; }
.facet-list.expanded li.extra { display: block; }
.facet-list a { display: grid; grid-template-columns: 16px 1fr auto; gap: 9px; align-items: center; padding: 4px 6px; margin: 0 -6px; border-radius: 6px; color: var(--ink-2); font-size: 13.5px; line-height: 1.3; }
.facet-list a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.facet-list .box { width: 14px; height: 14px; border: 1.5px solid var(--line-2); border-radius: 3.5px; background: var(--surface); }
.facet-list li.on .box { background: var(--navy-2); border-color: var(--navy-2); box-shadow: inset 0 0 0 2px var(--surface); }
.facet-list li.on a { color: var(--ink); font-weight: 550; }
.facet-list .n { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.facet-filter { width: 100%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 7px; padding: 6px 9px; font: 13px var(--ui); margin-bottom: 6px; }
.more { background: none; border: 0; color: var(--link); font: 500 12.5px var(--ui); padding: 6px 0 0; cursor: pointer; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; gap: 2px; }
.seg a { padding: 5px 12px; border-radius: 6px; font-size: 13px; color: var(--ink-2); }
.seg a:hover { text-decoration: none; color: var(--ink); }
.seg a.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.decades { display: flex; align-items: flex-end; gap: 2px; height: 46px; margin: 4px 0 2px; }
.decades a { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.decades a span { display: block; width: 100%; height: var(--h); min-height: 2px; background: color-mix(in srgb, var(--navy-2) 55%, transparent); border-radius: 2px 2px 0 0; }
.decades a:hover span { background: var(--brass); }
.decade-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.years { display: flex; align-items: center; gap: 6px; }
.years input { width: 66px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 7px; padding: 5px 8px; font: 13px var(--ui); font-variant-numeric: tabular-nums; }
.quick-years { display: flex; gap: 10px; margin-top: 8px; font-size: 12.5px; }
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 13px; font: 500 13.5px var(--ui); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }

.results-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.count { font-size: 14px; color: var(--ink-2); }
.count strong { font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }
.controls { display: flex; align-items: center; gap: 16px; font-size: 13.5px; color: var(--ink-2); }
.controls select { border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); border-radius: 7px; padding: 5px 8px; font: 13.5px var(--ui); margin-left: 6px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.toggle input { accent-color: var(--navy-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 0 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--brass-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--brass) 35%, transparent); border-radius: 99px; padding: 3px 10px; font-size: 12.5px; }
.chip:hover { text-decoration: none; filter: brightness(.97); }
.chip span { color: var(--muted); }
.chip.clear { background: transparent; border-color: var(--line-2); color: var(--muted); }

.hits { list-style: none; margin: 0; padding: 0; counter-reset: none; }
li.hit { position: relative; padding: 18px 12px 18px 40px; margin: 0 -12px; border-bottom: 1px solid var(--line); border-radius: 8px; transition: background .12s; }
li.hit::before { content: counter(list-item); position: absolute; left: 12px; top: 21px; font: 500 12px var(--ui); color: var(--muted); font-variant-numeric: tabular-nums; }
li.hit:hover, li.hit.focus { background: var(--surface); }
li.hit.focus { box-shadow: inset 3px 0 0 var(--navy-2); }
.hits.citing li.hit { padding-left: 40px; }
.hit-head { display: flex; align-items: baseline; gap: 10px; }
.hit-head .depth { flex: none; position: relative; top: 1px; }
.case { font: 600 19px/1.3 var(--serif); color: var(--link); }
.case:visited { color: var(--visited); }
.case mark { background: none; color: inherit; text-decoration: underline; text-decoration-color: var(--brass); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.hit-head .copy { margin-left: auto; opacity: 0; }
li.hit:hover .copy, li.hit.focus .copy, li.hit .copy:focus { opacity: 1; }
@media (hover: none) { .hit-head .copy { opacity: 1; } }
.hit-cite { margin-top: 4px; font-size: 13.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 0 0; }
.hit-cite > span + span::before { content: "·"; margin: 0 7px; color: var(--line-2); }
.hit-cite .rep { color: var(--ink-2); font-weight: 550; font-variant-numeric: tabular-nums; }
.hit-cite .court.lv-scotus { color: var(--brass); font-weight: 600; }
.hit-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.citedby { font-size: 12.5px; font-weight: 550; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: 2px 9px; font-variant-numeric: tabular-nums; }
.citedby:hover { text-decoration: none; border-color: var(--line-2); color: var(--ink); }
.citedby.none { color: var(--muted); font-weight: 400; background: none; }
.badge { font-size: 11.5px; font-weight: 600; letter-spacing: .02em; border-radius: 5px; padding: 2px 7px; border: 1px solid; white-space: nowrap; }
.b-unpublished, .b-errata, .b-unknown, .b-relating-to, .b-in-chambers { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-bg); }
.b-separate { color: var(--conc); border-color: color-mix(in srgb, var(--conc) 40%, transparent); }
.b-sep { color: var(--sep); border-color: color-mix(in srgb, var(--sep) 40%, transparent); background: color-mix(in srgb, var(--sep) 6%, transparent); }
.snips { margin-top: 9px; font: 15.5px/1.6 var(--serif); color: var(--ink-2); }
.snips p { margin: 0 0 5px; padding-left: 12px; border-left: 2px solid var(--line); }
.snips p::before { content: "… "; color: var(--muted); }
.snips p::after { content: " …"; color: var(--muted); }
mark { background: linear-gradient(180deg, transparent 8%, var(--mark) 8%, var(--mark) 92%, transparent 92%); color: inherit; padding: 0 1px; border-radius: 2px; }
.notice { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 26px; margin: 24px 0; }
.overruled-banner { background: color-mix(in srgb, var(--sep) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--sep) 45%, transparent);
  border-left: 4px solid var(--sep); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 18px; }
.overruled-banner p { margin: 0 0 4px; font-size: 15px; }
.overruled-banner strong { color: var(--sep); }
.later-history { margin: 6px 0 0; font-size: 14.5px; }
.later-history i { font-style: italic; }
.overruled-banner.soft { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.overruled-banner.soft strong { color: var(--warn); }
.overruled-banner .src { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }
.badge.b-overruled { color: var(--sep); border-color: color-mix(in srgb, var(--sep) 55%, transparent); background: color-mix(in srgb, var(--sep) 8%, transparent); }
.landmark { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; border: 1px solid var(--line-2); border-left: 4px solid var(--brass);
  background: var(--surface); border-radius: var(--radius); padding: 10px 14px; margin: 0 0 14px; }
.landmark .lm-label { font: 600 11.5px var(--ui); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); width: 100%; }
.landmark .case { font: 600 17px var(--serif); }
.landmark .hit-cite { font-size: 13.5px; color: var(--ink-2); }
.badge.b-weakneg { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 55%, transparent); background: var(--warn-bg); }
.chip.neg-chip { background: transparent; color: var(--sep); border-color: color-mix(in srgb, var(--sep) 45%, transparent); font-weight: 600; }
.chip.neg-chip.on { background: color-mix(in srgb, var(--sep) 12%, transparent); }
.neg-btn { border-color: color-mix(in srgb, var(--sep) 45%, transparent); color: var(--sep); }
.neg-note { border-left: 4px solid var(--sep); }
.notice.slim { padding: 10px 14px; margin: 0 0 12px; font-size: 14px; }
.notice.warn { background: var(--warn-bg); border-color: var(--warn); color: var(--ink); padding: 12px 16px; margin: 0 0 14px; font-size: 14.5px; }
.notice h1, .notice h2 { font: 600 22px/1.3 var(--serif); margin: 0 0 8px; }
.notice.error { border-left: 4px solid var(--sep); margin-top: 48px; }
.pager { display: flex; justify-content: center; gap: 4px; margin: 28px 0 8px; flex-wrap: wrap; }
.pager a, .pager span { min-width: 36px; text-align: center; padding: 6px 10px; border-radius: 7px; font-size: 14px; font-variant-numeric: tabular-nums; }
.pager a:hover { background: var(--surface); text-decoration: none; }
.pager .cur { background: var(--navy); color: var(--navy-ink); font-weight: 600; }

.copy { display: inline-flex; align-items: center; gap: 5px; background: var(--surface); border: 1px solid var(--line-2); color: var(--ink-2); font: 500 12.5px var(--ui); border-radius: 7px; padding: 4px 9px; cursor: pointer; white-space: nowrap; transition: opacity .12s, background .12s; }
.copy:hover { background: var(--surface-2); color: var(--ink); }
.copy svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.copy.done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }

/* ---------- 引用深度條（KeyCite 式四格） ---------- */
.depth { display: inline-flex; gap: 2px; align-items: flex-end; vertical-align: middle; }
.depth i { width: 4px; height: 12px; border-radius: 1.5px; background: var(--line-2); display: block; }
.depth.d1 i:nth-child(-n+1), .depth.d2 i:nth-child(-n+2), .depth.d3 i:nth-child(-n+3), .depth.d4 i { background: var(--navy-2); }
.depth-legend { font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ---------- 判決頁 ---------- */
.case-layout { max-width: 1240px; margin: 0 auto; padding: 24px 24px 80px; display: grid; grid-template-columns: 240px minmax(0, 780px); gap: 48px; justify-content: center; }
.case-side { order: 0; }
.side-sticky { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 18px; max-height: calc(100vh - 96px); overflow: auto; scrollbar-width: thin; }
.hitnav { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.hitnav-q { font: italic 14px/1.35 var(--serif); color: var(--ink); margin-bottom: 8px; word-break: break-word; }
.hitnav-ctl { display: flex; align-items: center; justify-content: space-between; font-size: 13.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.hitnav-ctl button { width: 34px; height: 30px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink); cursor: pointer; font-size: 15px; }
.hitnav-ctl button:hover { background: var(--surface-3); }
.toc h2 { margin: 0 0 8px; font: 600 11.5px/1.2 var(--ui); text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.toc a { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0 5px 12px; margin-left: -2px; border-left: 2px solid transparent; color: var(--ink-2); font-size: 13.5px; line-height: 1.35; }
.toc a:hover { color: var(--ink); text-decoration: none; }
.toc a.active { border-left-color: var(--navy-2); color: var(--ink); font-weight: 600; }
.toc .n { color: var(--muted); font-size: 12px; font-weight: 400; font-variant-numeric: tabular-nums; }
.toc a.toc-op { flex-direction: column; gap: 0; }
.toc a.toc-op small { color: var(--muted); font-size: 12px; font-weight: 400; }
html:has(body.page-case) { scroll-padding-top: 150px; }
.reader-ctl { display: flex; gap: 6px; }
.reader-ctl button { flex: 1; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 7px; padding: 6px 0; font: 500 12.5px var(--ui); cursor: pointer; }
.reader-ctl button:hover { background: var(--surface-2); color: var(--ink); }

.crumbs { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--ink); }
.case-head { padding: 14px 0 22px; border-bottom: 1px solid var(--line); }
.case-title { font: 600 clamp(26px, 3.4vw, 36px)/1.18 var(--serif); letter-spacing: -.01em; margin: 6px 0 6px; }
.caption { font: italic 16px/1.45 var(--serif); color: var(--muted); margin: 0 0 10px; }
.cite-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 12px 0 16px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.cite-line .bb { font: 17px/1.4 var(--serif); color: var(--ink); flex: 1; min-width: 240px; }
.meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 28px; margin: 0; }
.meta > div { display: grid; grid-template-columns: 82px 1fr; gap: 10px; align-items: baseline; }
.meta > div.wide { grid-column: 1 / -1; }
.meta dt { font: 600 11px/1.6 var(--ui); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.meta dd { margin: 0; font-size: 14px; color: var(--ink); }
.cites { display: flex; flex-wrap: wrap; gap: 6px; }
.cite-chip { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 8px; font-size: 13px; font-variant-numeric: tabular-nums; }
.case-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line-2); color: var(--ink-2); font-size: 13px; font-weight: 500; }
.pill:hover { text-decoration: none; color: var(--ink); background: var(--surface-2); }
.pill.strong { background: var(--navy); color: var(--navy-ink); border-color: var(--navy); }
.pill.strong:hover { background: var(--navy-2); color: #fff; }
.pill.ext::after, a.cite.ext::after { content: "↗"; font-size: .8em; opacity: .7; margin-left: 2px; }

.summary { margin-top: 22px; display: flex; flex-direction: column; gap: 8px; }
.summary details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.summary summary { cursor: pointer; padding: 11px 16px; font: 600 15px var(--serif); list-style: none; display: flex; justify-content: space-between; }
.summary summary::after { content: "+"; color: var(--muted); font-weight: 400; }
.summary details[open] summary::after { content: "−"; }
.summary .prose { padding: 0 16px 14px; font: 15.5px/1.65 var(--serif); color: var(--ink-2); white-space: pre-line; }

.op-tabs { position: sticky; top: 60px; z-index: 20; display: flex; gap: 4px; overflow-x: auto; margin: 26px 0 0; padding: 8px 0; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.op-tab { display: flex; flex-direction: column; padding: 6px 12px; border-radius: 8px; color: var(--ink-2); font-size: 13px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; position: relative; }
.op-tab small { font-weight: 400; color: var(--muted); font-size: 12px; }
.op-tab:hover { background: var(--surface); text-decoration: none; }
.op-tab.active { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow); color: var(--ink); }
.op-tab.t-040dissent { color: var(--sep); }
.op-tab.t-030concurrence, .op-tab.t-035concurrenceinpart { color: var(--conc); }
.pg.pg-hit { background: var(--mark); border-radius: 4px; outline: 2px solid var(--mark-cur); }
.hitcount { position: static; align-self: flex-start; margin-top: 3px; font-style: normal; font-size: 10px; background: var(--mark); color: var(--ink); border-radius: 99px; padding: 0 5px; font-weight: 600; }
.opinion { margin-top: 30px; }
.op-head { border-top: 3px double var(--line-2); padding-top: 16px; margin-bottom: 14px; }
.opinion.t-040dissent .op-head { border-top-color: color-mix(in srgb, var(--sep) 50%, transparent); }
.opinion.t-030concurrence .op-head, .opinion.t-035concurrenceinpart .op-head { border-top-color: color-mix(in srgb, var(--conc) 50%, transparent); }
.op-head h2 { font: 600 20px/1.3 var(--serif); margin: 0; font-variant: small-caps; letter-spacing: .03em; }
.op-author { font-variant: normal; font-weight: 400; color: var(--ink-2); letter-spacing: 0; }
.op-body { font: var(--read-size)/1.74 var(--serif); color: var(--ink); max-width: 70ch; hyphens: auto; -webkit-hyphens: auto; overflow-wrap: anywhere; }
.case-main, .results { min-width: 0; }
.combined { margin-top: 36px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.combined > summary { cursor: pointer; padding: 12px 16px; font: 600 15px var(--serif); }
.combined > .op-body { padding: 0 18px 12px; max-width: none; }
.op-body p { margin: 0 0 1em; }
.op-body ::selection { background: color-mix(in srgb, var(--navy-2) 28%, transparent); }
.pg { display: inline-block; font: 600 10.5px/1.5 var(--ui); color: var(--brass); background: var(--brass-soft); border-radius: 4px; padding: 0 4px; margin: 0 2px; vertical-align: 2px; font-variant-numeric: tabular-nums; user-select: none; -webkit-user-select: none; }
.pg-demo { font: 600 10.5px var(--ui); color: var(--brass); background: var(--brass-soft); border-radius: 4px; padding: 0 4px; }
a.cite { color: var(--link); text-decoration: underline; text-decoration-style: dotted; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a.cite:hover { text-decoration-style: solid; }
a.cite.ext { color: var(--muted); }
mark.qh { scroll-margin: 140px; }
mark.qh.current { background: var(--mark-cur); box-shadow: 0 0 0 2px var(--mark-cur); }

.panel { margin-top: 56px; padding-top: 22px; border-top: 1px solid var(--line-2); }
.panel h2 { font: 600 24px/1.25 var(--serif); margin: 0 0 6px; }
.panel h3 { font: 600 12px var(--ui); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 0 10px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; }
.big-n { color: var(--brass); font-variant-numeric: tabular-nums; }
.parens { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.parens li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.parens blockquote { margin: 0; font: italic 16.5px/1.55 var(--serif); color: var(--ink); }
.parens .by { margin-top: 8px; font: 14px var(--serif); }
.parens .by a { color: var(--ink-2); }
.cite-chart { margin: 14px 0 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 8px; }
.chart { width: 100%; height: 96px; display: block; overflow: visible; }
.chart rect { fill: var(--navy-2); opacity: .82; }
.chart rect:hover { fill: var(--brass); opacity: 1; }
.chart .ax { font: 10px var(--ui); fill: var(--muted); }
.chart .ax.end { text-anchor: end; }
.chart .ax.mid { text-anchor: middle; }
.level-split { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.level-split a { display: inline-flex; gap: 8px; align-items: baseline; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; font-size: 13px; color: var(--ink-2); }
.level-split a:hover { text-decoration: none; border-color: var(--line-2); color: var(--ink); }
.level-split b { font-variant-numeric: tabular-nums; color: var(--ink); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.mini-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.mini-list li { display: grid; grid-template-columns: 26px 1fr; column-gap: 8px; font-size: 14px; }
.mini-list .depth { grid-row: span 2; margin-top: 4px; }
.mini-list a { font: 600 15px/1.35 var(--serif); }
.mini-list .meta-line { color: var(--muted); font-size: 12.5px; grid-column: 2; }
.auth-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.auth-table th { text-align: left; font: 600 11px var(--ui); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line-2); }
.auth-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; font-family: var(--serif); font-size: 15px; }
.auth-table td.d { width: 56px; }
.auth-table .num { text-align: right; font: 13px var(--ui); color: var(--muted); font-variant-numeric: tabular-nums; width: 80px; }
.auth-table tr.extra { display: none; }
.auth-table.expanded tr.extra { display: table-row; }
.auth-table tr:hover td { background: var(--surface); }

.sel-pop { position: absolute; z-index: 60; transform: translate(-50%, -100%); margin-top: -10px; }
.sel-pop button { background: var(--navy); color: var(--navy-ink); border: 0; border-radius: 8px; padding: 7px 12px; font: 600 13px var(--ui); cursor: pointer; box-shadow: var(--shadow-lg); white-space: nowrap; }
.sel-pop button::after { content: ""; position: absolute; left: 50%; bottom: -5px; margin-left: -5px; border: 5px solid transparent; border-top-color: var(--navy); border-bottom: 0; }

/* 被引用清單 */
.page-citing .wrap { padding-top: 22px; }
.citing-head h1 { font: 600 30px/1.2 var(--serif); margin: 10px 0 4px; }
.citing-of { font: 18px/1.4 var(--serif); margin: 0 0 4px; }
.citing-of a { color: var(--ink); }
.within { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.within label { display: block; font: 600 11.5px var(--ui); text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin-bottom: 8px; }
.within-row { display: flex; gap: 6px; }
.within-row input { flex: 1; min-width: 0; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); border-radius: 7px; padding: 6px 9px; font: 13.5px var(--ui); }

/* 說明頁 */
.prose-page { padding-top: 32px; padding-bottom: 72px; }
.prose-page h1 { font: 600 36px/1.2 var(--serif); margin: 0 0 12px; }
.prose-page .lede { margin: 0 0 24px; text-align: left; }
.prose-page h2 { font: 600 22px/1.3 var(--serif); margin: 40px 0 12px; }
.prose-page p, .prose-page li { font-size: 15.5px; line-height: 1.65; color: var(--ink-2); }
.syntax { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: 14px; }
.syntax th { text-align: left; background: var(--surface-2); font: 600 11.5px var(--ui); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 9px 12px; }
.syntax td { padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.syntax code { white-space: nowrap; }
.note { background: var(--surface-2); border-radius: 8px; padding: 10px 14px; font-size: 14px !important; }

/* 浮動提示與對話框 */
#toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--navy); color: var(--navy-ink); padding: 10px 16px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 90; max-width: min(640px, calc(100vw - 32px)); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast i { font-family: var(--serif); }
.modal { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); padding: 22px 26px; box-shadow: var(--shadow-lg); min-width: min(340px, calc(100vw - 32px)); max-width: calc(100vw - 32px); box-sizing: border-box; }
.modal::backdrop { background: rgba(10, 16, 26, .45); }
.modal h2 { font: 600 20px var(--serif); margin: 0 0 12px; }
.modal td { padding: 6px 12px 6px 0; font-size: 14px; }
.modal form { text-align: right; margin-top: 12px; }

.foot { border-top: 1px solid var(--line); background: var(--surface); }
.foot-in { max-width: 1240px; margin: 0 auto; padding: 22px 24px; font-size: 13.5px; color: var(--ink-2); }
.foot p { margin: 0 0 4px; }

/* ---------- 窄螢幕 ---------- */
@media (max-width: 1000px) {
  .results-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; padding-top: 14px; }
  .facets { position: static; max-height: none; }
  .facets-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 14px; }
  .facets-box > summary { display: block; cursor: pointer; padding: 12px 0; font-weight: 600; }
  .case-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  html, body { overflow-x: hidden; }
  .case-side { order: 2; }
  .toc, .reader-ctl { display: none; }
  .hitnav { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 50; display: flex; align-items: center; gap: 12px; }
  .hitnav-q { margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-sticky { position: static; max-height: none; }
  .cov-grid { grid-template-columns: repeat(2, 1fr); }
  .features { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar-in { flex-wrap: wrap; gap: 10px; padding: 8px 16px; }
  .brand-product { display: none; }
  .topbar .searchbox { order: 3; flex-basis: 100%; max-width: none; }
  .toplinks a:not(.langbtn), .toplinks [data-shortcuts] { display: none; }  /* 手機保留語言切換，鍵盤快捷鍵沒用 */
  code { white-space: normal; overflow-wrap: anywhere; }
  .examples a { flex-wrap: wrap; }
  .syntax { display: block; overflow-x: auto; max-width: 100%; }
  .syntax code { white-space: nowrap; }
  .op-tabs { -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); mask-image: linear-gradient(to right, #000 85%, transparent); }
  .facet-list li a { min-height: 38px; align-items: center; }
  .chip { padding-top: 7px; padding-bottom: 7px; }
  .hero { padding: 40px 16px 24px; }
  .wrap, .results-layout, .case-layout, .coverage, .features { padding-left: 16px; padding-right: 16px; }
  .meta { grid-template-columns: 1fr; }
  li.hit { padding-left: 12px; }
  li.hit::before { display: none; }
  .hits.citing li.hit { padding-left: 12px; }
  .examples a { width: 100%; justify-content: space-between; }
  :root { --read-size: 17px; }
  .op-tabs { top: 104px; }
}

/* ---------- 列印 ---------- */
@media print {
  :root { --read-size: 11.5pt; }
  body { background: #fff; color: #000; }
  .topbar, .case-side, .foot, .case-actions, .copy, .op-tabs, .sel-pop, #toast, .panel, .crumbs, .facets { display: none !important; }
  .case-layout { display: block; padding: 0; }
  .cite-line { border: 0; padding: 0; }
  .op-body { max-width: none; color: #000; }
  a, a.cite { color: #000; text-decoration: none; }
  mark { background: #eee; }
  .pg { background: none; color: #555; border: 0; }
}
@media (max-width: 480px) {
  .seg.sorts { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .seg.sorts a { padding: 5px 8px; font-size: 12.5px; white-space: nowrap; }
}
