/* rating-kb — Trust & Authority + Swiss 極簡。淺色為主，深色跟系統或手動切換。 */
:root {
  --bg: #F8FAFC; --card: #FFFFFF; --card2: #F1F5F9;
  --ink: #0F172A; --ink2: #334155; --muted: #475569; --faint: #94A3B8;
  --line: #CBD5E1; --line2: #E2E8F0;
  --primary: #1E3A8A; --primary-h: #1E40AF; --primary-soft: #E0E7FF; --on-primary: #FFFFFF;
  --accent: #B45309; --accent-soft: #FEF3C7;
  --ok: #15803D; --ok-soft: #DCFCE7; --warn: #B45309; --warn-soft: #FEF3C7; --bad: #B91C1C; --bad-soft: #FEE2E2;
  --ring: rgba(30, 58, 138, .35);
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .06);
  --r: 12px; --r-s: 8px;
  /* 2026-10-10 字體跟 GitHub：系統字體（Windows Segoe UI＋微軟正黑體、Mac San Francisco＋蘋方），唔再下載 Google Fonts；原文頁亦唔再用襯線字 */
  /* 中文字體排喺 Noto Sans／Helvetica／Arial 之前：中文同全形標點一律用本機中文字體（Windows 正黑體嘅標點置中，係正體慣例） */
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang HK", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --serif: var(--sans);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1220; --card: #111A2E; --card2: #16213A;
    --ink: #E5EAF3; --ink2: #C3CCDC; --muted: #9AA7BD; --faint: #6B7A93;
    --line: #2A3650; --line2: #1F2A42;
    --primary: #8FA8F5; --primary-h: #A9BCF8; --primary-soft: #1C2A54; --on-primary: #0B1220;
    --accent: #F2B84B; --accent-soft: #3A2A0E;
    --ok: #4ADE80; --ok-soft: #12321E; --warn: #FBBF24; --warn-soft: #3A2A0E; --bad: #F87171; --bad-soft: #3B1515;
    --ring: rgba(143, 168, 245, .45);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B1220; --card: #111A2E; --card2: #16213A;
  --ink: #E5EAF3; --ink2: #C3CCDC; --muted: #9AA7BD; --faint: #6B7A93;
  --line: #2A3650; --line2: #1F2A42;
  --primary: #8FA8F5; --primary-h: #A9BCF8; --primary-soft: #1C2A54; --on-primary: #0B1220;
  --accent: #F2B84B; --accent-soft: #3A2A0E;
  --ok: #4ADE80; --ok-soft: #12321E; --warn: #FBBF24; --warn-soft: #3A2A0E; --bad: #F87171; --bad-soft: #3B1515;
  --ring: rgba(143, 168, 245, .45);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.65 var(--sans); }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--primary-h); }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--bad); background: var(--bad-soft); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); padding: 10px 14px; border-radius: var(--r-s); margin-top: 12px; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 20px 16px 48px; }
h1, h2, h3 { line-height: 1.3; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 26px 0 10px; }

/* ---- 頂欄 ---- */
.topbar { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--line2); }
.nav { max-width: 1040px; margin: 0 auto; display: flex; align-items: center; gap: 6px; padding: 8px 12px; min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--primary); text-decoration: none; padding: 8px 10px; border-radius: var(--r-s); margin-right: 6px; letter-spacing: -.01em; }
.links { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.links::-webkit-scrollbar { display: none; }
.links a { display: inline-flex; align-items: center; gap: 6px; padding: 10px 12px; min-height: 44px; border-radius: var(--r-s); color: var(--ink2); text-decoration: none; font-weight: 500; white-space: nowrap; transition: background .18s, color .18s; }
.links a:hover { background: var(--card2); color: var(--ink); }
.links a.active { background: var(--primary-soft); color: var(--primary); }
.navright { display: flex; align-items: center; gap: 6px; }
.iconbtn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; background: transparent; color: var(--ink2); border: 1px solid transparent; border-radius: var(--r-s); cursor: pointer; transition: background .18s; padding: 0; }
.iconbtn:hover { background: var(--card2); }
.iconbtn .ic-moon { display: none; }
:root[data-theme="dark"] .iconbtn .ic-sun { display: none; } :root[data-theme="dark"] .iconbtn .ic-moon { display: block; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .iconbtn .ic-sun { display: none; } :root:not([data-theme="light"]) .iconbtn .ic-moon { display: block; } }
.logout { margin: 0; }
.whoami { display: inline-flex; align-items: center; gap: 6px; padding: 10px; min-height: 44px; border-radius: var(--r-s); color: var(--ink2); text-decoration: none; font-weight: 500; max-width: 160px; }
.whoami span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whoami:hover, .whoami.active { background: var(--card2); color: var(--ink); }

/* ---- 表單元件 ---- */
button, .btn { font: inherit; font-weight: 600; font-size: 15px; background: var(--primary); color: var(--on-primary); border: 1px solid transparent; border-radius: var(--r-s); padding: 0 16px; min-height: 44px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background .18s, color .18s, border-color .18s, box-shadow .18s; }
button:hover { background: var(--primary-h); }
button:disabled { opacity: .55; cursor: default; }
button.secondary, button.ghost, .btn.secondary { background: var(--card); color: var(--ink2); border-color: var(--line); }
button.secondary:hover, button.ghost:hover, .btn.secondary:hover { background: var(--card2); color: var(--ink); }
a.btn { text-decoration: none; }
button.ghost { border-color: transparent; }
button.danger { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
button.danger:hover { background: var(--bad-soft); }
button.small, .btn.small { min-height: 34px; padding: 0 10px; font-size: 13px; font-weight: 500; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 12px; min-height: 44px; transition: border-color .18s, box-shadow .18s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
textarea { width: 100%; resize: vertical; line-height: 1.6; }
select { appearance: none; -webkit-appearance: none; padding-right: 34px; 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='%23475569' 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 10px center; }
label { color: var(--ink2); }
.toggle { display: inline-flex; gap: 8px; align-items: center; min-height: 44px; padding: 0 6px; cursor: pointer; user-select: none; }
.toggle input { width: 18px; height: 18px; min-height: 0; accent-color: var(--primary); margin: 0; }
.card { background: var(--card); border: 1px solid var(--line2); border-radius: var(--r); box-shadow: var(--shadow); }

/* ---- 登入 ---- */
.login { max-width: 380px; margin: 14vh auto; background: var(--card); padding: 32px 28px; border-radius: var(--r); border: 1px solid var(--line2); box-shadow: var(--shadow); }
.login h1 { margin: 0 0 4px; font-size: 1.5rem; color: var(--primary); display: flex; align-items: center; gap: 10px; }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.login .err { margin: 12px 0 0; }
.login .brand-en { margin: 2px 0 0 36px; letter-spacing: .04em; font-weight: 500; } /* 英文名，對齊標題文字（避開圖示） */
.login.terms { max-width: 640px; margin: 8vh auto; }
.login.terms ol { padding-left: 1.3em; line-height: 1.75; }
.login.terms li { margin-bottom: 8px; }
.docnotice { margin: 0; padding: 14px 16px; border-radius: var(--r-s); background: var(--card2); color: var(--ink2); }
.pwform { display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.quota { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink2); }
.quota.low { color: var(--warn, #B45309); font-weight: 600; }
.reviewlist { list-style: none; padding: 0; margin: 10px 0; display: flex; flex-direction: column; gap: 10px; }
.reviewlist li { padding: 12px 14px; }
.reviewlist .q { font-weight: 600; }
.reviewlist .note { white-space: pre-wrap; margin: 6px 0; padding: 8px 10px; background: var(--card2); border-radius: var(--r-s); }
/* 2026-10-12 法律關係網待核實：候選案件逐個一行，撳完淡出 */
.graphcands { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.graphcand { align-items: flex-start; gap: 8px; }
.graphcand input { margin-top: 3px; }
.reviewlist li.done { opacity: .55; }
.invitebox { margin-top: 10px; padding: 12px 14px; }
.invitebox input[readonly] { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
table.users td, table.users th { white-space: nowrap; }
table.users td.grow { white-space: normal; }

/* ---- 問答 ---- */
.askbox { background: var(--card); border: 2px solid var(--line); transition: border-color .18s; border-radius: var(--r); box-shadow: var(--shadow); padding: 14px; }
.askbox textarea { border: 0; padding: 6px 4px; min-height: 84px; font-size: 17px; background: transparent; }
.askbox textarea:focus { box-shadow: none; }
.askbox:focus-within { border-color: var(--primary); } /* 打字時外框變主色 */
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line2); }
.controls select, .controls input { max-width: 100%; min-height: 40px; padding-top: 6px; padding-bottom: 6px; font-size: 14px; }
.controls .yr { width: 96px; }
.controls .grow { flex: 1; min-width: 160px; }
.controls button[type=submit] { margin-left: auto; min-width: 88px; }
.tips { margin: 12px 4px; font-size: 14px; color: var(--muted); }
.tips summary { cursor: pointer; list-style: none; display: inline-flex; gap: 6px; align-items: center; min-height: 32px; }
.tips summary::-webkit-details-marker { display: none; }
.tips ul { margin: 8px 0; padding-left: 18px; }
.samples a { margin-right: 4px; }
/* 2026-10-12 等待體驗：進度條＋已用時間＋停止掣 */
.askprog { margin: 14px 4px 0; padding: 10px 14px; background: var(--card); border: 1px solid var(--line2); border-radius: var(--r); }
.askprog .bar { height: 6px; background: var(--line2); border-radius: 999px; overflow: hidden; }
.askprog .bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .8s ease; }
.askprog .row { display: flex; align-items: center; gap: 12px; margin: 8px 0 4px; flex-wrap: wrap; }
.askprog #askElapsed { font-variant-numeric: tabular-nums; font-weight: 600; }
.askprog #askStop { margin-left: auto; }
@media (prefers-reduced-motion: reduce) { .askprog .bar span { transition: none; } }
.timeline { list-style: none; padding: 0; margin: 14px 4px 0; font-size: 14px; }
.timeline li { padding: 5px 0 5px 24px; position: relative; color: var(--muted); }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 13px; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.timeline li::after { content: ""; position: absolute; left: 9.5px; top: 21px; bottom: -6px; width: 1px; background: var(--line2); }
.timeline li:last-child::after { display: none; }
.timeline li.active { color: var(--ink); } .timeline li.active::before { background: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); animation: pulse 1.2s ease-in-out infinite; }
.timeline li.done::before { background: var(--primary); }
@keyframes pulse { 50% { opacity: .35; } }
.answer { background: var(--card); border: 1px solid var(--line2); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px 22px; margin-top: 14px; }
.md { font-size: 16.5px; line-height: 1.75; }
.wrap:has(.ask) { max-width: 1240px; } body:has(.ask) .nav { max-width: 1240px; }
.md table { border-collapse: collapse; width: 100%; margin: .8em 0; font-size: .92em; line-height: 1.55; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line2); padding: 6px 10px; vertical-align: top; text-align: left; }
.md th { background: var(--card2); color: var(--ink2); font-weight: 600; }
.md hr { border: 0; border-top: 1px solid var(--line2); margin: 1.4em 0; }
.md.streaming > :last-child::after { content: ""; display: inline-block; width: .5em; height: 1em; margin-left: 2px; vertical-align: -2px; background: var(--primary); opacity: .6; animation: pulse 1s ease-in-out infinite; }
.md h1 { font-size: 1.35em; margin: 0 0 .6em; } .md h2 { font-size: 1.12em; margin: 1.4em 0 .5em; padding-bottom: 5px; border-bottom: 1px solid var(--line2); color: var(--primary); } .md h3 { font-size: 1.02em; margin: 1.1em 0 .4em; }
.md p { margin: .55em 0; } .md ul, .md ol { padding-left: 1.4em; } .md li { margin: .25em 0; }
.md blockquote { margin: .8em 0; padding: .4em 1em; border-left: 3px solid var(--accent); background: var(--card2); border-radius: 0 var(--r-s) var(--r-s) 0; }
.md .cite { display: inline; background: var(--primary-soft); color: var(--primary); border-radius: 6px; padding: 1px 6px; margin: 0 2px; font-size: .8em; font-weight: 500; line-height: 1.5; white-space: nowrap; font-variant-numeric: tabular-nums; }
.md .cite a { color: inherit; text-decoration: none; border-bottom: 1px dotted currentColor; }
.md .cite a:hover { color: var(--primary-h); border-bottom-style: solid; }
.md .cite a.bad, .md .cite.bad { color: var(--bad); } .md .cite.bad { background: var(--bad-soft); }
.md .cite.live { opacity: .75; }
.loa { margin-top: 18px; border-top: 1px solid var(--line2); padding-top: 12px; font-size: 14.5px; }
.loa h3 { margin: 0 0 8px; font-size: 1em; color: var(--ink2); }
.loa ol { padding-left: 1.6em; margin: 0; } .loa li { margin-bottom: 10px; padding-left: 2px; }
.loa li::marker { color: var(--faint); font-variant-numeric: tabular-nums; }
.loa .k { font-weight: 600; white-space: nowrap; margin-right: 4px; } .loa .t { color: var(--ink); }
.loa .sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; } .loa .sub a { white-space: nowrap; }
.meta { font-size: 13px; color: var(--muted); margin-top: 12px; }
.feedback { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line2); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px; }
.feedback button { background: var(--card); color: var(--ink2); border-color: var(--line); min-height: 38px; padding: 0 12px; font-weight: 500; }
.feedback button.on { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
#fbNote { width: 100%; margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--card2) 25%, var(--line2) 50%, var(--card2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; margin: 10px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---- 上網搵 ---- */
.discover .dhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.discover h3 { margin: 0; font-size: 1.05em; flex: 1; }
.dlist { list-style: none; padding: 0; margin: 8px 0 0; }
.dlist li { padding: 10px 0; border-top: 1px solid var(--line2); }
.dtitle { font-weight: 500; }
.dact { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.dact select { min-height: 34px; padding: 4px 30px 4px 8px; font-size: 13px; }

/* ---- 表格 ---- */
.filterbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filterbar input[type=search] { flex: 1; min-width: 200px; }
/* 管理員專用元素：成員頁面隱藏（伺服器亦會擋） */
body:not(.is-admin) .adminonly { display: none !important; }
.tablewrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line2); border-radius: var(--r); box-shadow: var(--shadow); }
.table { border-collapse: collapse; width: 100%; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line2); vertical-align: top; }
.table th { background: var(--card2); color: var(--ink2); font-weight: 600; position: sticky; top: 0; white-space: nowrap; font-size: 13px; }
.table tbody tr { transition: background .15s; } .table tbody tr:hover { background: var(--card2); }
.table td.small { font-size: 12.5px; color: var(--muted); max-width: 280px; }
/* 通用欄位：nw 唔摺行（短欄收到最窄）；grow 食晒剩餘闊度；ell 太長就省略號；doccol／msg 長文字欄 */
.table .nw { white-space: nowrap; } .table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.grow, .table th.grow { width: 100%; }
.table td.ell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#logTable td.doccol, #logTable th.doccol { min-width: 240px; } #logTable td.msg, #logTable th.msg { min-width: 150px; max-width: 360px; } #logTable td.ell { max-width: 170px; }
.wrap:has(.feed), .wrap:has(.history) { max-width: 1400px; } body:has(.feed) .nav, body:has(.history) .nav { max-width: 1400px; }
@media (max-width: 760px) { #logTable td.doccol, #logTable th.doccol { min-width: 200px; } #logTable td.msg, #logTable th.msg { min-width: 120px; } }
.table .chk { width: 28px; padding-right: 0; } .table .chk input { width: 18px; height: 18px; margin: 2px 0 0; min-height: 0; }
.bulkbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; padding: 8px 12px; background: var(--card2); border: 1px solid var(--line2); border-radius: var(--r); font-size: 14px; }
.bulkbar[hidden] { display: none; }
/* 文件清單：12 欄唔好迫——頁面放闊、短欄唔換行、標題有最少闊度、太窄就橫向捲，唔會一隻字一行 */
.wrap:has(.docs) { max-width: 1400px; } body:has(.docs) .nav { max-width: 1400px; }
#docTable td, #docTable th { white-space: nowrap; }
#docTable td.wrap, #docTable th.wrap { white-space: normal; min-width: 260px; }
#docTable td, #docTable th { padding: 9px 10px; }
#docTable td.ell { max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
#docTable td.ell.c3 { max-width: 150px; }
#docTable td.num, #docTable th.num { text-align: right; }
@media (max-width: 1000px) { .table .c3 { display: none; } #docTable td.wrap, #docTable th.wrap { min-width: 200px; } #docTable td.ell { max-width: 130px; } }
@media (max-width: 520px) { .table .c2 { display: none; } #docTable td.wrap, #docTable th.wrap { min-width: 0; } }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill.gold { background: var(--accent-soft); color: var(--accent); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.err { background: var(--bad-soft); color: var(--bad); } .badge.warn { background: var(--warn-soft); color: var(--warn); } .badge.run { background: var(--primary-soft); color: var(--primary); } .badge.off { background: var(--card2); color: var(--muted); }

/* ---- 原文 ---- */
.dochead { background: var(--card); border: 1px solid var(--line2); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px 22px; }
.dochead h1 { font-size: 1.3rem; margin: 0 0 6px; font-family: var(--serif); font-weight: 600; }
.dochead .line { color: var(--muted); font-size: 14px; }
.dochead p { margin: 10px 0 0; color: var(--ink2); }
.docmeta { margin: 12px 0; } .docmeta summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; color: var(--ink2); font-weight: 500; }
#metaForm { display: grid; grid-template-columns: 150px 1fr; gap: 8px 12px; font-size: 14px; align-items: center; background: var(--card); border: 1px solid var(--line2); border-radius: var(--r); padding: 14px; }
#metaForm input, #metaForm select, #metaForm textarea { width: 100%; min-height: 40px; }
.appeal { background: var(--card); border: 1px solid var(--line2); border-left: 3px solid var(--accent); border-radius: var(--r); padding: 12px 16px; margin: 12px 0; font-size: 14.5px; }
.appeal ul { margin: 6px 0; padding-left: 18px; }
.paras { background: var(--card); border: 1px solid var(--line2); border-radius: var(--r); box-shadow: var(--shadow); padding: 8px 20px; font-family: var(--serif); font-size: 17px; line-height: 1.8; }
.para { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line2); scroll-margin-top: 80px; }
.para:last-child { border-bottom: 0; }
.para.hit, .para:target { background: var(--accent-soft); margin: 0 -12px; padding-left: 12px; padding-right: 12px; border-radius: var(--r-s); }
.para .pref { font-family: var(--sans); color: var(--faint); font-size: 12.5px; text-decoration: none; padding-top: 5px; }
.para .pref:hover { color: var(--primary); }
.ptext { max-width: 78ch; }

/* ---- 餵料／設定 ---- */
.tabs { display: flex; gap: 4px; margin-bottom: 10px; flex-wrap: wrap; }
.tabs label { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border-radius: var(--r-s); cursor: pointer; color: var(--ink2); }
.tabs label:has(input:checked) { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.tabs input { accent-color: var(--primary); margin: 0; }
.srcpane input[type=url], .srcpane input[type=file] { width: 100%; }
.srcpane p { margin: 6px 0 0; }
.metagrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 16px; font-size: 14px; margin: 10px 0; }
/* 設定頁體檢格 */
.statsgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; padding: 14px; margin: 10px 0; }
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; color: var(--primary); }
.stat .n small { font-size: 13px; font-weight: 500; color: var(--muted); }
.stat .l { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stat.warn .n { color: var(--warn); } .stat.bad .n { color: var(--bad); }
.stat.wide { grid-column: 1 / -1; border-top: 1px solid var(--line2); padding-top: 10px; }
.stat .types { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.metagrid b { color: var(--ink2); font-weight: 600; margin-right: 6px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.settings textarea { font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Noto Sans TC", monospace; font-size: 14px; }
#feedStatus { margin-top: 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 24px; }

/* ---- 響應 ---- */
@media (max-width: 720px) {
  .wrap { padding: 14px 12px 40px; }
  .nav { padding: 6px 8px; }
  .brand { display: none; } /* 手機淨係留側邊欄掣，唔好兩個圖示並排 */
  .links a span { display: none; }
  .links a { padding: 10px; }
  .whoami span { display: none; }
  .answer, .askbox, .dochead { padding: 14px; }
  .para { grid-template-columns: 44px 1fr; gap: 8px; }
  .paras { padding: 6px 12px; font-size: 16.5px; }
  #metaForm { grid-template-columns: 1fr; }
  .controls button[type=submit] { width: 100%; margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* 語音輸入 */
.micgroup { display: inline-flex; align-items: center; gap: 4px; }
.micgroup select { width: auto; }
.micbtn { width: 40px; height: 40px; border: 1px solid var(--line); }
.micbtn.rec { color: var(--bad); border-color: var(--bad); background: var(--bad-soft); animation: pulse 1.2s ease-in-out infinite; }

/* 答案工具列（複製／匯出） */
.answertools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; margin: -6px 0 8px; }
.answertools button { display: inline-flex; align-items: center; gap: 5px; }
/* 列印／另存 PDF：只印答案、引用清單同頁尾資料 */
@media print {
  :root { --bg: #fff; --card: #fff; --card2: #f3f4f6; --ink: #000; --ink2: #222; --muted: #444; --primary: #1E3A8A; --primary-soft: #eef2ff; --line2: #ccc; }
  body { background: #fff; color: #000; }
  .topbar, .askbox, .tips, .timeline, #skeleton, #discover, .feedback, .answertools, #err { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .answer { border: 0; box-shadow: none; padding: 0; margin: 0; }
  .md { font-size: 11pt; line-height: 1.55; }
  .md .cite { background: none; padding: 0; font-size: 8.5pt; }
  .md .cite a { border-bottom: 0; }
  .md table { display: table; overflow: visible; }
  .loa { font-size: 9.5pt; break-before: auto; }
  .meta { font-size: 8.5pt; color: #555; }
  a { color: #1E3A8A; text-decoration: none; }
  h2, h3 { break-after: avoid; }
}

/* 對話（追問） */
.thread .turn { margin-top: 14px; }
.turnq { font-weight: 600; margin: 0 0 10px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.turnbody > summary { cursor: pointer; margin-bottom: 6px; }
.turn details.loa > summary { cursor: pointer; }
.followbox { margin-top: 14px; }
.followbox textarea { min-height: 64px; font-size: 16px; }
/* 有追問建議：提示字（建議＋「按 Tab 採用」）要夠位顯示，窄畫面唔好捲 */
.followbox textarea[data-suggested] { min-height: 96px; }
@media (max-width: 600px) { .followbox textarea[data-suggested] { min-height: 128px; } }
.followbox .controls button[type=submit] { margin-left: 0; }
#turnInfo { margin-right: auto; }
@media print { .thread .turn { break-inside: auto; } .turnbody > summary { display: none; } }

/* 引用預覽 */
.citepop { position: absolute; z-index: 50; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-s); box-shadow: 0 8px 28px rgba(15, 23, 42, .22); padding: 10px 12px; font-size: 14px; line-height: 1.6; max-height: 60vh; overflow: auto; }
.citepop .citetext { white-space: pre-wrap; margin: 6px 0; }
@media print { .citepop { display: none !important; } }

/* hidden 屬性一律唔顯示（有 display 設定嘅 class 會蓋過瀏覽器預設，例如 .turnq 用 flex） */
[hidden] { display: none !important; }

/* ===== 方案 A：法院／結果分色、結論摘要框、分段圖示、首頁 ===== */
:root {
  --court-cfa-bg: #EEEDFE; --court-cfa-fg: #3C3489;
  --court-ca-bg: #E6F1FB;  --court-ca-fg: #0C447C;
  --court-cfi-bg: #E1F5EE; --court-cfi-fg: #085041;
  --court-lt-bg: #F1EFE8;  --court-lt-fg: #444441;
  --court-uk-bg: #FAECE7;  --court-uk-fg: #712B13;
  --out-win-bg: #EAF3DE;   --out-win-fg: #27500A;
  --out-lose-bg: #FCEBEB;  --out-lose-fg: #791F1F;
  --out-part-bg: #FAEEDA;  --out-part-fg: #633806;
  --out-proc-bg: #F1EFE8;  --out-proc-fg: #5F5E5A;
  --summary-bg: #EEF2FF;   --summary-bd: #1E3A8A;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --court-cfa-bg: #3C3489; --court-cfa-fg: #CECBF6;
    --court-ca-bg: #0C447C;  --court-ca-fg: #B5D4F4;
    --court-cfi-bg: #085041; --court-cfi-fg: #9FE1CB;
    --court-lt-bg: #444441;  --court-lt-fg: #D3D1C7;
    --court-uk-bg: #712B13;  --court-uk-fg: #F5C4B3;
    --out-win-bg: #27500A;   --out-win-fg: #C0DD97;
    --out-lose-bg: #791F1F;  --out-lose-fg: #F7C1C1;
    --out-part-bg: #633806;  --out-part-fg: #FAC775;
    --out-proc-bg: #444441;  --out-proc-fg: #D3D1C7;
    --summary-bg: #16213A;   --summary-bd: #8FA8F5;
  }
}
:root[data-theme="dark"] {
  --court-cfa-bg: #3C3489; --court-cfa-fg: #CECBF6;
  --court-ca-bg: #0C447C;  --court-ca-fg: #B5D4F4;
  --court-cfi-bg: #085041; --court-cfi-fg: #9FE1CB;
  --court-lt-bg: #444441;  --court-lt-fg: #D3D1C7;
  --court-uk-bg: #712B13;  --court-uk-fg: #F5C4B3;
  --out-win-bg: #27500A;   --out-win-fg: #C0DD97;
  --out-lose-bg: #791F1F;  --out-lose-fg: #F7C1C1;
  --out-part-bg: #633806;  --out-part-fg: #FAC775;
  --out-proc-bg: #444441;  --out-proc-fg: #D3D1C7;
  --summary-bg: #16213A;   --summary-bd: #8FA8F5;
}
.cpill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; line-height: 1.6; white-space: nowrap; vertical-align: 1px; }
.court-cfa { background: var(--court-cfa-bg); color: var(--court-cfa-fg); }
.court-ca { background: var(--court-ca-bg); color: var(--court-ca-fg); }
.court-cfi { background: var(--court-cfi-bg); color: var(--court-cfi-fg); }
.court-lt, .court-other { background: var(--court-lt-bg); color: var(--court-lt-fg); }
.court-uk { background: var(--court-uk-bg); color: var(--court-uk-fg); }
.out-win { background: var(--out-win-bg); color: var(--out-win-fg); }
.out-lose { background: var(--out-lose-bg); color: var(--out-lose-fg); }
.out-part { background: var(--out-part-bg); color: var(--out-part-fg); }
.out-proc { background: var(--out-proc-bg); color: var(--out-proc-fg); }

/* 答案分段：標題加圖示；結論摘要做醒目框 */
.md .sec > h2 { display: flex; align-items: center; gap: 8px; }
.md .secicon { flex: none; color: var(--primary); }
.md .sec-extra > h2, .md .sec-extra .secicon { color: var(--accent); }
.md .sec-extra > h2 { margin-bottom: .15em; }
.md .seccap { margin: 0 0 .7em; font-size: 12.5px; color: var(--muted); }
.md .sec-gap > h2, .md .sec-gap .secicon { color: var(--muted); }
.md .sec-summary { background: var(--summary-bg); border-left: 4px solid var(--summary-bd); border-radius: 0; padding: 4px 18px 10px; margin: 0 0 1.2em; }
.md .sec-summary > h2 { border-bottom: 0; margin-top: .7em; }
.md .sec-summary ol, .md .sec-summary ul { margin-bottom: .2em; }
.md h3 .secicon { vertical-align: -3px; margin-right: 6px; }

/* 首頁：未問問題時嘅標題同示例 */
.hero { text-align: center; padding: 28px 12px 18px; }

.hero h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: .01em; }
.hero p { margin: 0 auto 14px; max-width: 40em; text-wrap: balance; }
#answer, #answerQ { scroll-margin-top: 72px; } /* 捲到答案時唔好俾頂欄遮住 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { display: inline-flex; align-items: center; min-height: 36px; padding: 4px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink2); text-decoration: none; font-size: 14px; transition: border-color .18s, background .18s, transform .18s; }
.chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); transform: translateY(-1px); }

/* 細節動態 */
.loa li { border-radius: var(--r-s); padding: 6px 8px; margin-left: -8px; transition: background .18s; }
.loa li:hover { background: var(--card2); }
.thread .turn { transition: box-shadow .2s; }
.thread .turn:hover { box-shadow: 0 2px 4px rgba(15,23,42,.06), 0 10px 24px rgba(15,23,42,.08); }
@media (prefers-reduced-motion: reduce) { .chip, .loa li, .thread .turn { transition: none; } .chip:hover { transform: none; } }
@media (max-width: 640px) { .hero { padding: 16px 4px 10px; } .hero h1 { font-size: 21px; } }
@media print { .hero { display: none !important; } .md .sec-summary { background: none; border-left: 3px solid #1E3A8A; } .cpill { background: none !important; color: #000 !important; border: 1px solid #999; } }

/* ===== 原文頁（方案 A 延伸） ===== */
.crumb { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.crumb a { color: var(--muted); text-decoration: none; } .crumb a:hover { color: var(--primary); }
.dochead h1 { font-size: 1.45rem; line-height: 1.35; margin: 0 0 10px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; font-size: 14px; }
.citeline { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.docactions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.docactions .btn { text-decoration: none; }
.docsummary { margin-top: 14px; padding: 10px 14px; background: var(--card2); border-radius: var(--r-s); }
.docsummary .lbl, .tagrow .lbl, .appealhead { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
.docsummary p { margin: 4px 0 0; line-height: 1.7; }
.tagrow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.tagrow .lbl { margin-right: 4px; }
.tag { display: inline-block; padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 12.5px; color: var(--ink2); background: var(--card); }
/* 2026-10-12 法律關係網：條文標籤連去條文頁；文件頁「引用關係」、條文頁清單 */
a.tag.link { color: var(--accent); text-decoration: none; }
a.tag.link:hover { border-color: var(--accent); }
.relsec { margin: 8px 0; }
.relsec > summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.rellist { margin: 6px 0; padding-left: 18px; }
.rellist li { margin: 4px 0; }
.provlist { list-style: none; padding-left: 0; }
.provlist li { padding: 6px 0; border-bottom: 1px solid var(--line2); }
.provlist .facts { margin-top: 2px; }
/* 2026-10-12 引用性質標籤（階段 3）：推翻紅、區分橙、質疑黃、跟從綠、討論灰 */
.tlabel { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 12px; line-height: 1.7; border: 1px solid; }
.t-overruled { color: #B42318; border-color: #F1A9A3; background: #FEF3F2; }
.t-distinguished { color: #B54708; border-color: #F7C59F; background: #FFF6ED; }
.t-doubted { color: #8A6100; border-color: #EBD48A; background: #FFFBEB; }
.t-followed { color: #1A7F37; border-color: #9DD6AE; background: #EEFBF2; }
.t-considered { color: var(--muted); border-color: var(--line); background: var(--card2); }
:root[data-theme="dark"] .t-overruled { color: #FDA29B; background: transparent; }
:root[data-theme="dark"] .t-distinguished { color: #FDB36E; background: transparent; }
:root[data-theme="dark"] .t-doubted { color: #F5D36A; background: transparent; }
:root[data-theme="dark"] .t-followed { color: #75D99A; background: transparent; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .t-overruled { color: #FDA29B; background: transparent; }
  :root:not([data-theme="light"]) .t-distinguished { color: #FDB36E; background: transparent; }
  :root:not([data-theme="light"]) .t-doubted { color: #F5D36A; background: transparent; }
  :root:not([data-theme="light"]) .t-followed { color: #75D99A; background: transparent; }
}
details.tq { display: inline; margin-left: 6px; }
details.tq > summary { display: inline; cursor: pointer; list-style: none; }
details.tq > summary::-webkit-details-marker { display: none; }
details.tq[open] .tqbody { display: block; margin: 4px 0 2px; padding: 6px 10px; background: var(--card2); border-radius: var(--r-s); }
.tsum { margin: 4px 0 2px; }
.warnbox { margin: 10px 0 4px; padding: 8px 12px; border: 1px solid #F1A9A3; border-left: 3px solid #D92D20; border-radius: 0; background: #FEF3F2; color: #7A271A; font-size: 14px; }
.warnbox a { color: inherit; }
:root[data-theme="dark"] .warnbox { background: transparent; color: #FDA29B; border-color: #7A271A; border-left-color: #F04438; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .warnbox { background: transparent; color: #FDA29B; border-color: #7A271A; border-left-color: #F04438; } }

/* 類型標籤：前面一粒色點分類別（判詞／法例／出版物／書籍準則／筆記） */
.tpill { display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px 1px 7px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; font-weight: 500; color: var(--ink2); background: var(--card); white-space: nowrap; }
.tpill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.type-judg::before { background: #534AB7; } .type-law::before { background: #185FA5; } .type-pub::before { background: #0F6E56; } .type-book::before { background: #BA7517; } .type-note::before { background: #D4537E; }

/* 上訴鏈階梯 */
.appeal { border-left: 1px solid var(--line2); padding: 14px 18px; }
.ladder { list-style: none; margin: 8px 0 4px; padding: 0; display: grid; gap: 0; }
.ladder .step { position: relative; padding: 8px 0 8px 22px; }
.ladder .step::before { content: ""; position: absolute; left: 6px; top: 16px; width: 10px; height: 10px; border-radius: 50%; background: var(--card); border: 2px solid var(--line); }
.ladder .step:not(:last-child)::after { content: ""; position: absolute; left: 11px; top: 28px; bottom: -8px; width: 2px; background: var(--line2); }
.ladder .step.here::before { border-color: var(--primary); background: var(--primary); }
.stephead { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ladder .step ul { list-style: none; margin: 4px 0 0; padding: 0; font-size: 14px; }
.ladder .step li { padding: 2px 0; } .ladder .step li .d { font-variant-numeric: tabular-nums; }
.ladder .step li.cur { font-weight: 600; }

/* 跳到段落 */
.jump { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0 8px; }
.jump input { width: 110px; min-height: 36px; }
@media print { .docactions, .jump, .docmeta { display: none !important; } .docsummary { background: none; border: 1px solid #ccc; } }

/* ---- 側邊欄：對話紀錄（左上角掣） ---- */
#drawerBtn { margin-right: 2px; }
.drawer-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 49; opacity: 0; transition: opacity .2s; }
.drawer-back.open { opacity: 1; }
.drawer { position: fixed; top: 0; left: 0; bottom: 0; width: min(320px, 86vw); z-index: 50; background: var(--card); border-right: 1px solid var(--line2); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; padding: 12px; transform: translateX(-100%); transition: transform .2s ease; }
.drawer.open { transform: translateX(0); }
.dwhead { display: flex; align-items: center; gap: 8px; }
.dwnew { flex: 1; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border-radius: var(--r-s); color: var(--ink); text-decoration: none; font-weight: 600; }
.dwnew:hover { background: var(--card2); }
.dwsearch { width: 100%; }
.dwlist { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.dwlist a { display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; border-radius: var(--r-s); color: var(--ink); text-decoration: none; }
.dwlist a:hover { background: var(--card2); }
.dwlist a[aria-current] { background: var(--primary-soft); }
.dwlist .q { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.dwlist .m { font-size: 12px; color: var(--ink2); }
.dwfoot { border-top: 1px solid var(--line2); padding-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.dwusage .row0 { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink2); margin-bottom: 6px; }
.dwusage .bar { height: 6px; border-radius: 999px; background: var(--card2); overflow: hidden; }
.dwusage .bar i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.dwme { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: var(--r-s); color: var(--ink); text-decoration: none; }
.dwme:hover { background: var(--card2); }
.dwme .av { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.dwme > span:last-child { display: flex; flex-direction: column; min-width: 0; }
@media print { .drawer, .drawer-back, #drawerBtn { display: none !important; } }
.dwlist > li.muted, .dwlist > li.err { padding: 8px 12px; }

/* ---- 語言切換 ---- */
.langbtn { font-size: 13px; font-weight: 700; letter-spacing: .02em; }
.langswitch { margin: 10px 0 0; text-align: center; }
.linkbtn { background: none; border: 0; padding: 4px 6px; min-height: 0; color: var(--primary); font-weight: 500; font-size: 13px; cursor: pointer; text-decoration: underline; }
.login h1 svg { flex: none; } /* 英文標題長、會摺行：圖示唔好被壓細 */
html[lang="en"] .controls .yr { width: 116px; } /* 「From year」提示字唔好被截 */
.linkbtn:disabled { opacity: .5; cursor: default; }
/* 英文字長過中文：頂欄唔夠位就逐步收（先收用戶名，再收網站名同選單文字，淨留圖示） */
@media (max-width: 1100px) { html[lang="en"] .whoami span { display: none; } }
@media (max-width: 1020px) { html[lang="en"] .brand span, html[lang="en"] .links a span { display: none; } html[lang="en"] .links a { padding: 10px; } }

/* 手機：語言掣搬去側邊欄底部；登出掣收窄（英文「Log out」長過中文） */
@media (max-width: 720px) { .langbtn { display: none; } .logout .ghost { padding: 0 8px; } }
.dwlang { align-self: flex-start; }

/* ===== 2026-10-10 介面精簡（參考 GitHub Primer）：篩選／匯出彈出選單、答案闊度＋右邊目錄、引用清單收起、返回頂部 ===== */
.pop { position: relative; display: inline-block; }
.pop > summary { list-style: none; cursor: pointer; user-select: none; }
.pop > summary::-webkit-details-marker { display: none; }
.controls .pop > summary { min-height: 40px; font-size: 14px; font-weight: 600; padding: 0 12px; }
.pop .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); display: inline-block; }
.poppanel { position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; min-width: 220px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-s); box-shadow: 0 8px 28px rgba(15, 23, 42, .18); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.popright .poppanel { left: auto; right: 0; min-width: 180px; }
.poppanel .yrrow { display: flex; align-items: center; gap: 6px; }
.poppanel .yr { width: 96px; min-height: 38px; font-size: 14px; }
.poppanel #yclear { align-self: flex-start; padding: 0; }
.poppanel.menu { padding: 6px; gap: 2px; }
.poppanel.menu button { justify-content: flex-start; width: 100%; min-height: 38px; color: var(--ink); font-size: 14px; }
.poppanel.menu button:hover { background: var(--card2); }
/* 答案內文唔好太闊：一行大約 45 個中文字；闊畫面右邊放目錄 */
.answer > :not(.toc):not(.answertools) { max-width: 56em; } /* 10-10 用戶：48em 太窄，放闊少少 */
.answer > .answertools { max-width: none; }
.toc { display: none; }
@media (min-width: 1100px) {
  .answer.has-toc { display: grid; grid-template-columns: minmax(0, 1fr) 230px; column-gap: 36px; align-items: start; }
  .answer.has-toc > * { grid-column: 1; }
  .answer.has-toc > .answertools { grid-column: 1 / -1; }
  .answer.has-toc > .toc:not([hidden]) { display: block; grid-column: 2; grid-row: 2 / span 6; position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; font-size: 13.5px; border-left: 1px solid var(--line2); padding-left: 14px; }
}
.tochead { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .04em; margin-bottom: 6px; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li a { display: block; padding: 4px 8px; margin-left: -8px; border-radius: 6px; color: var(--ink2); text-decoration: none; line-height: 1.45; }
.toc li.sub a { padding-left: 20px; font-size: 13px; color: var(--muted); }
.toc li a:hover { background: var(--card2); color: var(--ink); }
.toc li a.on { color: var(--primary); font-weight: 600; background: var(--primary-soft); }
.md h2, .md h3, #loa { scroll-margin-top: 76px; }
.loa ol.folded > li:nth-child(n+6) { display: none; }
.loamore { margin: 2px 0 0 2px; font-size: 13.5px; }
.totop { position: fixed; right: 18px; bottom: 18px; z-index: 35; width: 44px; height: 44px; padding: 0; border-radius: 50%; box-shadow: var(--shadow); }
@media (max-width: 720px) {
  .controls .lbl { display: none; } /* 手機：網上搜尋、篩選淨留圖示 */
  .controls .pop > summary, #discoverBtn { padding: 0 10px; }
  .controls .micgroup select, .controls #tier { padding-right: 24px; padding-left: 8px; background-position: right 5px center; }
  .controls .micgroup { gap: 2px; }
  .controls #tier { flex: 1 1 80px; min-width: 0; } /* 思考深度食剩餘闊度，成行掣排得落一行 */
}
/* 列印／PDF：問題框唔印，所以第一問都要喺答案頂部印返原本問題（10-10 用戶反映 PDF 冇問題） */
@media print { #answerQ[hidden] { display: flex !important; } .turnq { font-size: 12pt; margin-bottom: 8pt; } }
@media print { .toc, .totop, .loamore { display: none !important; } .loa ol.folded > li { display: list-item !important; }
  /* 2026-10-13：列印冇左邊留白，第 10 項起編號第一個數字印唔到；清單留夠兩位數位置 */
  .loa ol { padding-left: 2.4em; } .loa li { margin-left: 0; padding-left: 2px; } .md ol { padding-left: 2em; } .answer > * { max-width: none !important; } .answer.has-toc { display: block; } }

/* ===== 2026-10-10 第二批：文件清單（GitHub Issues 式兩行＋分類列）、問答紀錄（按日分組＋相對時間） ===== */
.wrap:has(.docs), .wrap:has(.history) { max-width: 1120px; } body:has(.docs) .nav, body:has(.history) .nav { max-width: 1120px; }
.docpanel { min-width: 240px; }
.docpanel select { width: 100%; min-height: 38px; font-size: 14px; }
.docpanel .toggle { min-height: 36px; padding: 0; font-size: 14px; }
.filterbar .pop > summary { min-height: 44px; }
.typetabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 10px; margin-bottom: 4px; }
@media (max-width: 720px) { .typetabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; } .typetabs::-webkit-scrollbar { display: none; } } /* 手機：一行左右碌 */
.ttab { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 10px; font-size: 13px; font-weight: 500; background: var(--card); color: var(--ink2); border: 1px solid var(--line2); border-radius: 999px; }
.ttab:hover { background: var(--card2); color: var(--ink); }
.ttab.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.ttab .n { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.ttab.on .n { color: var(--primary); }
.tpill.bare { border: 0; padding: 0; background: none; font-size: inherit; color: inherit; }
#docTable.doclist td, #docTable.doclist th { white-space: normal; }
#docTable.doclist th { font-weight: 500; }
#docTable.doclist td.adminonly, #docTable.doclist th.adminonly { white-space: nowrap; width: 1%; }
/* 刪除掣：有滑鼠嘅電腦淨係移到嗰行先出（GitHub 式，減少紅色雜訊）；手機照常顯示 */
@media (hover: hover) { #docTable.doclist .rowdel { opacity: 0; } #docTable.doclist tr:hover .rowdel, #docTable.doclist .rowdel:focus-visible { opacity: 1; } }
.doccell { padding-top: 11px !important; padding-bottom: 11px !important; }
.doccell .dt { font-weight: 600; line-height: 1.45; }
.doccell .dt a { color: var(--ink); text-decoration: none; }
.doccell .dt a:hover { color: var(--primary); text-decoration: underline; }
.doccell .dm { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 4px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.doccell .dm.hist { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; } /* 後續太長只顯示一行（唔用 nowrap，會撐闊成個表） */
.faint { color: var(--faint); }
.qalist { margin-top: 4px; }
.qgroup { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink2); margin: 18px 0 6px; }
.qgroup .n { font-weight: 500; color: var(--muted); background: var(--card2); border-radius: 999px; padding: 0 8px; font-size: 12px; }
.qitems { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line2); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.qrow { display: flex; gap: 14px; align-items: flex-start; padding: 11px 16px; border-top: 1px solid var(--line2); transition: background .15s; }
.qrow:first-child { border-top: 0; }
.qrow:hover { background: var(--card2); }
.qmain { flex: 1; min-width: 0; }
.qq { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--ink); text-decoration: none; font-weight: 500; line-height: 1.5; }
.qq:hover { color: var(--primary); text-decoration: underline; }
.qm { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.qm .warnt { color: var(--warn); }
.pill.soft { background: var(--card2); color: var(--ink2); }
.qt { flex: none; font-size: 12.5px; color: var(--muted); white-space: nowrap; padding-top: 2px; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .qrow { flex-direction: column; gap: 2px; padding: 10px 12px; } .qt { order: -1; padding: 0; font-size: 12px; } }
@media (max-width: 720px) { .docs .filterbar a[href="/api/listing.html"] { display: none; } } /* 全庫一覽係電腦用嘅長頁，手機收起慳一行 */

/* ===== 2026-10-10 第三批：快速跳轉（Ctrl+K）、快捷鍵說明、原文頁固定標題列 ===== */
.jumpbtn { width: auto; gap: 8px; padding: 0 8px 0 10px; height: 36px; border: 1px solid var(--line2); color: var(--muted); font-size: 13px; font-weight: 500; margin-right: 4px; }
.jumpbtn:hover { color: var(--ink); }
kbd { display: inline-block; font: 11px/1.2 var(--mono); padding: 2px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--card2); color: var(--ink2); white-space: nowrap; }
@media (max-width: 720px) { .jumpbtn { display: none; } } /* 手機冇鍵盤，收起 */
dialog.kdlg { border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); box-shadow: 0 16px 48px rgba(0, 0, 0, .3); padding: 0; width: min(640px, calc(100vw - 32px)); }
dialog.kdlg::backdrop { background: rgba(0, 0, 0, .45); }
dialog.palette { margin-top: 12vh; }
.palette #palQ { width: 100%; border: 0; border-bottom: 1px solid var(--line2); border-radius: 12px 12px 0 0; font-size: 16px; padding: 14px 16px; min-height: 54px; background: transparent; }
.palette #palQ:focus { box-shadow: none; }
.pallist { list-style: none; margin: 0; padding: 6px; max-height: 56vh; overflow-y: auto; }
.palgrp { font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px 4px; }
.palitem a { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.palitem.on a { background: var(--primary-soft); }
.palitem .pt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palitem .ps { font-size: 12px; color: var(--muted); }
.palempty { padding: 14px 12px; color: var(--muted); font-size: 14px; }
.palfoot { display: flex; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--line2); }
.palfoot kbd { margin-right: 3px; }
dialog.helpdlg { padding: 18px 22px; width: min(460px, calc(100vw - 32px)); }
.helpdlg h3 { margin: 0 0 10px; font-size: 1.05rem; }
.helpdlg table { width: 100%; border-collapse: collapse; font-size: 14px; }
.helpdlg td { padding: 8px 0; border-top: 1px solid var(--line2); }
.helpdlg td:first-child { width: 110px; white-space: nowrap; }
.helpdlg .row { justify-content: flex-end; margin-top: 12px; }
.docbar { position: fixed; left: 0; right: 0; z-index: 29; background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line2); box-shadow: 0 2px 10px rgba(0, 0, 0, .08); }
.dbin { max-width: 1040px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 6px 16px; min-height: 48px; }
.dbt { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.dbt b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.dbt span { white-space: nowrap; }
.dbjump input { width: 110px; min-height: 34px; padding: 4px 10px; font-size: 14px; }
.para { scroll-margin-top: 124px; } /* 跳段落時唔好俾頂欄＋固定標題列遮住 */
@media (max-width: 600px) { .dbt span, .dbtop { display: none; } }
@media print { .docbar, dialog.kdlg, .jumpbtn { display: none !important; } }

/* ===== 2026-10-10 新用戶流程：邀請頁一頁完成、歡迎指引、邀請訊息 ===== */
.login.invite { max-width: 440px; }
.login .hint { margin: -4px 0 4px; }
.pwrow { display: flex; gap: 6px; }
.pwrow input { flex: 1; min-width: 0; }
.pwmeter { height: 4px; border-radius: 999px; background: var(--line2); overflow: hidden; margin-top: -4px; }
.pwmeter i { display: block; height: 100%; width: 0; background: var(--bad); transition: width .2s, background .2s; }
.pwmeter i[data-score="2"] { background: var(--warn); } .pwmeter i[data-score="3"], .pwmeter i[data-score="4"] { background: var(--ok); }
.termsbox { border: 1px solid var(--line2); border-radius: var(--r-s); padding: 8px 12px; background: var(--card2); }
.termsbox summary { cursor: pointer; font-weight: 500; color: var(--ink2); }
.termsbox ol { padding-left: 1.3em; margin: 8px 0 0; font-size: 14px; line-height: 1.7; }
.settings #inviteMsg { width: 100%; font: 14px/1.6 var(--sans); margin: 8px 0; min-height: 0; } /* 設定頁 textarea 預設等寬字，訊息用返正常字體 */

/* ===== 2026-10-10 柔和深色（參考 GitHub Dark dimmed）＝深色預設；「我的帳戶」可揀返舊深藍（localStorage rkb_dark=standard → data-dark="standard"）
   用戶要求底色再深少少、同卡片對比大啲：背景 #1C2128，卡片 #2D333B ===== */
:root[data-theme="dark"]:not([data-dark="standard"]) {
  --bg: #1C2128; --card: #2D333B; --card2: #373E47;
  --ink: #F0F6FC; --ink2: #E1E7EE; --muted: #B4BFCB; --faint: #95A1AF; /* 10-10 用戶兩次話灰底上啲字唔夠白 → 內文用 GitHub 最亮嘅前景色 */
  --line: #545D68; --line2: #444C56;
  --primary: #6CB6FF; --primary-h: #96D0FF; --primary-soft: #2B4366; --on-primary: #1C2128;
  --accent: #DAAA3F; --accent-soft: #3B3220;
  --ok: #57AB5A; --ok-soft: #1F3324; --warn: #C69026; --warn-soft: #3B3220; --bad: #F47067; --bad-soft: #3D2425;
  --ring: rgba(108, 182, 255, .4);
  --shadow: 0 1px 2px rgba(0,0,0,.25), 0 4px 14px rgba(0,0,0,.2);
  --summary-bg: #373E47; --summary-bd: #6CB6FF;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-dark="standard"]) {
    --bg: #1C2128; --card: #2D333B; --card2: #373E47;
    --ink: #F0F6FC; --ink2: #E1E7EE; --muted: #B4BFCB; --faint: #95A1AF; /* 10-10 用戶兩次話灰底上啲字唔夠白 → 內文用 GitHub 最亮嘅前景色 */
    --line: #545D68; --line2: #444C56;
    --primary: #6CB6FF; --primary-h: #96D0FF; --primary-soft: #2B4366; --on-primary: #1C2128;
    --accent: #DAAA3F; --accent-soft: #3B3220;
    --ok: #57AB5A; --ok-soft: #1F3324; --warn: #C69026; --warn-soft: #3B3220; --bad: #F47067; --bad-soft: #3D2425;
    --ring: rgba(108, 182, 255, .4);
    --shadow: 0 1px 2px rgba(0,0,0,.25), 0 4px 14px rgba(0,0,0,.2);
    --summary-bg: #373E47; --summary-bd: #6CB6FF;
  }
}
.darkpick { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px; }
.darkpick label { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 14px 6px 8px; border: 1px solid var(--line); border-radius: var(--r-s); cursor: pointer; }
.darkpick label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.darkpick input { accent-color: var(--primary); margin: 0; }
.darkpick .sw { width: 34px; height: 24px; border-radius: 6px; border: 1px solid rgba(255,255,255,.18); flex: none; }

/* 2026-10-08 新標誌 K1：深色模式深藍圓同背景太近，加一圈幼香檳金邊 */
.logo-mark { flex: none; border-radius: 50%; }
:root[data-theme="dark"] .logo-mark { box-shadow: 0 0 0 1px rgba(233, 196, 106, .55); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-mark { box-shadow: 0 0 0 1px rgba(233, 196, 106, .55); } }

/* 2026-10-14 列印品牌頁首（第 1 頁；第 2 頁起由 app.js 嘅 @page 頁邊方格負責） */
.printhead { display: none; }
@media print {
  .printhead { display: block; margin: 0 0 14px; }
  .printhead .ph-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
  .printhead img { display: block; }
  .printhead .ph-meta { font: 8pt "Segoe UI", Arial, sans-serif; color: #777; white-space: nowrap; }
  .printhead .ph-rule { border-top: 2.6px solid #E9C46A; border-bottom: 1px solid #E9C46A; height: 1.8px; margin-top: 6px; }
}
/* 2026-10-14：列印只印主要內容——瀏覽器擴充功能喺頁面加嘅浮動掣（例如紅色 RSS 圖示）會逐頁印出嚟 */
@media print { body > :not(main), html > :not(head):not(body) { display: none !important; } }
/* 2026-10-15 法律關係網圖（/graph，管理員） */
.graphpage .gstats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0 16px; }
.graphpage .gstat { background: var(--card2); border-radius: var(--r-s); padding: 10px 12px; }
.graphpage .gnum { font-size: 22px; font-weight: 700; color: var(--ink); }
.graphpage .gctl { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 8px; }
.graphpage .gctl input[type=search] { flex: 1; min-width: 200px; }
.graphpage .gctl label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.graphpage .gchips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.graphpage .gchip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); border: 1px solid var(--line); border-radius: var(--r-s); padding: 3px 8px; cursor: pointer; user-select: none; }
.graphpage .gchip input { margin: 0; }
.graphpage .gdot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.graphpage .gline { width: 16px; height: 3px; display: inline-block; }
/* 2026-10-17 用戶要求：圖要闊啲、右邊資料欄唔使長期佔位 → 頁面放闊到 1600px，圖佔全寬；資料欄平時收埋，撳點先浮喺圖右上角 */
.wrap:has(.graphpage) { max-width: 1600px; } body:has(.graphpage) .nav { max-width: 1600px; }
.graphpage .gwrap { position: relative; margin: 8px 0 20px; }
.graphpage #gSvg { width: 100%; height: 80vh; min-height: 520px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); touch-action: none; display: block; }
.graphpage #gInfo { position: absolute; top: 10px; right: 10px; width: 300px; max-height: calc(80vh - 20px); overflow-y: auto; overflow-x: hidden; overflow-wrap: anywhere; margin: 0; box-shadow: var(--shadow); }
.graphpage #gInfo[hidden] { display: none; }
.graphpage .gclose { position: sticky; top: 0; float: right; margin: -4px -4px 0 6px; padding: 0 8px; min-height: 28px; line-height: 1; font-size: 18px; }
.graphpage #gInfo ul { padding-left: 18px; margin: 4px 0 8px; }
.graphpage .gtitle { font-weight: 700; margin-bottom: 2px; }
.graphpage .ghead { margin-top: 8px; font-weight: 600; color: var(--ink); }
.graphpage .glabel { font-size: 11px; fill: var(--ink); pointer-events: none; }
@media (max-width: 900px) { .graphpage #gSvg { height: 62vh; min-height: 380px; } .graphpage #gInfo { position: static; width: auto; max-height: none; margin-top: 10px; box-shadow: none; } }

/* 2026-11-07 管理員訊息：頂欄未讀紅點、訊息內文保留換行 */
.whoami { position: relative; }
.navdot { position: absolute; top: 8px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px var(--bg, #fff); }
.navdot[hidden] { display: none; }
.msgbody { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; margin-top: 6px; }
.reviewlist li.unread { border-left: 3px solid var(--primary); }
.msgform { padding: 14px; }
.msgform textarea { width: 100%; box-sizing: border-box; margin: 8px 0; }

/* 2026-11-07 最新消息 */
.newslink { position: relative; }
.newspost { padding: 14px 16px; margin: 12px 0; }
.newspost.unread { border-left: 3px solid var(--primary); }
.newspost h3 { margin: 6px 0 4px; }
.newsdocs { list-style: none; padding: 0; margin: 6px 0 0; }
.newsdocs li { padding: 10px 0; border-top: 1px solid var(--line, #e5e7eb); }
.newsdocs li > a:first-child { font-weight: 600; }
.newssum { margin: 4px 0; color: var(--ink2); line-height: 1.6; }
.newsdocs-h { margin-top: 10px; }
/* 2026-11-08 最新消息：發佈前預覽 */
dialog.newsprev { width: min(760px, calc(100vw - 32px)); max-height: 88vh; display: none; flex-direction: column; }
dialog.newsprev[open] { display: flex; }
dialog.newsprev .newsprev-h { padding: 16px 20px 4px; border-bottom: 1px solid var(--line); }
dialog.newsprev .newsprev-h h3 { margin: 0 0 4px; }
dialog.newsprev .newsprev-b { padding: 12px 20px; overflow: auto; flex: 1; }
dialog.newsprev .newsprev-f { padding: 12px 20px; border-top: 1px solid var(--line); margin: 0; }
