/* ═══════════════════════════════════════════════════════════════════════════
   Law Graph 設計系統（ui-ux-pro-max「Trust & Authority」：象牙白底、權威藏青、信任金）
   ─ 全部顏色／間距／圓角／陰影／動效時長皆由 :root 代幣提供，元件不得寫死 hex。
   ─ 動效 150–300ms、尊重 prefers-reduced-motion；互動元件最小 44px 觸控面積；focus-visible 一律可見。
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
  /* 色彩代幣 */
  --color-bg: #f8f6f0;                 /* 頁面底：暖象牙白 */
  --color-bg-gradient: linear-gradient(180deg, #fbfaf6 0%, #f3efe6 100%);
  --color-surface: #ffffff;            /* 卡片／面板 */
  --color-surface-muted: #f1eee6;      /* 次要區塊、表頭 */
  --color-border: #d9d4c8;             /* 邊框（暖灰） */
  --color-border-strong: #b9b2a3;
  --color-text: #0f172a;               /* 主文字（對白底 17:1） */
  --color-text-sub: #4b5563;           /* 次文字（對白底 7.6:1） */
  --color-heading: #14285c;            /* 標題藏青 */
  --color-primary: #1e3a8a;            /* 主要操作（navy） */
  --color-primary-hover: #172f70;
  --color-on-primary: #ffffff;
  --color-gold: #b8912e;               /* 信任金：邊框、分隔線等裝飾 */
  --color-gold-text: #8a5a12;          /* 金色文字版（對白底 5.6:1） */
  --color-gold-soft: #fbf3df;          /* 金色淡底 */
  --color-ok: #15803d;
  --color-ok-soft: #ecfdf3;
  --color-warn: #a16207;
  --color-warn-soft: #fefce8;
  --color-bad: #b91c1c;
  --color-bad-soft: #fef2f2;
  --color-ring: #1e3a8a;
  --color-canvas: #f6f3ec;             /* 3D 圖底色（graphView 同色） */
  --glow-color: rgba(184, 145, 46, 0.32);

  /* 舊代幣別名：graphView 內嵌樣式沿用 */
  --text-main: var(--color-text);
  --text-sub: var(--color-text-sub);
  --accent: var(--color-primary);
  --gold: var(--color-gold);
  --glass-border: var(--color-border);
  --canvas-bg: var(--color-canvas);
  --panel-bg: rgba(255, 255, 255, 0.86);
  --panel-solid: var(--color-surface);
  --ok: var(--color-ok);
  --bad: var(--color-bad);

  /* 字體 */
  --font-heading: 'EB Garamond', 'Noto Serif TC', 'Songti TC', Georgia, serif;
  --font-body: 'Inter', 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', system-ui, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Code', Consolas, monospace;

  /* 間距（Standard 密度）與幾何 */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;
  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px; --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 6px 18px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.14);
  --dur-fast: 150ms; --dur-base: 200ms; --dur-slow: 300ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --touch: 44px;                       /* 最小觸控尺寸 */
}

/* ── 基礙 ── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  font-family: var(--font-body); font-size: 16px; line-height: 1.5;
  background: var(--color-bg) var(--color-bg-gradient) fixed;
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--font-heading); color: var(--color-heading); letter-spacing: 0.01em; }
button, textarea, select, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }
a { color: var(--color-primary); }

/* 鍵盤焦點：所有互動元件一律可見（2px 主色環＋白色內圈） */
:focus-visible { outline: 2px solid var(--color-ring); outline-offset: 2px; box-shadow: 0 0 0 4px #fff; border-radius: var(--radius-sm); }
:focus:not(:focus-visible) { outline: none; }

/* 跳到主內容（鍵盤使用者） */
.skip-link {
  position: absolute; left: var(--space-4); top: -100px; z-index: 100;
  padding: var(--space-2) var(--space-4); background: var(--color-primary); color: var(--color-on-primary);
  border-radius: var(--radius-md); font-weight: 600; text-decoration: none; transition: top var(--dur-fast) var(--ease);
}
.skip-link:focus { top: var(--space-3); }

/* ── 頂欄 ── */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  background: rgba(255, 255, 255, 0.88); backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--color-gold);
}
.brand { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.brand-mark {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: var(--radius-md);
  background: var(--color-primary); color: var(--color-on-primary);
  display: grid; place-items: center; box-shadow: var(--shadow-sm);
}
.brand-mark svg { width: 24px; height: 24px; }
.topbar h1 { font-size: 1.5rem; font-weight: 700; line-height: 1.2; white-space: nowrap; }
/* 品牌區連結：包住標題回首頁，外觀與純文字一致（不加底線、沿用文字色） */
.brand-link { display: block; min-width: 0; color: inherit; text-decoration: none; }
.brand-link:hover h1 { text-decoration: underline; }
.brand > div, .brand-link > div { min-width: 0; }
.topbar p { font-size: 0.85rem; color: var(--color-text-sub); }
.topbar-right { display: flex; align-items: center; gap: var(--space-3); flex: 0 0 auto; }
/* 選單連結：金色實心膠囊，與狀態徽章區隔，讓 Law Powers 入口一眼可見 */
.nav-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 14px;
  border-radius: var(--radius-pill); background: var(--color-gold); color: var(--color-on-primary, #fff);
  font-size: 0.85rem; font-weight: 600; text-decoration: none; white-space: nowrap; box-shadow: var(--shadow-sm);
}
.nav-link::after { content: '↗'; font-size: 0.8em; }
.nav-link:hover { filter: brightness(1.08); text-decoration: none; }
/* 站內連結（使用統計）：改為次要的描邊樣式且不加外連箭頭，讓頂欄只有一個金色主 CTA（Law Powers） */
.nav-link.internal { background: var(--color-surface); color: var(--color-heading); border: 1px solid var(--color-border); box-shadow: none; }
.nav-link.internal::after { content: none; }
.nav-link.internal:hover { border-color: var(--color-gold); background: var(--color-gold-soft); filter: none; }
@media (max-width: 640px) { .nav-link { font-size: 0.78rem; padding: 4px 10px; } }

/* Agent 狀態徽章：文字前以 ::before 畫狀態點（不加子節點，保持 textContent 純淨） */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: 32px;
  font-size: 0.8rem; font-weight: 500; padding: 4px 12px; border-radius: var(--radius-pill);
  border: 1px solid var(--color-border); color: var(--color-text-sub); background: var(--color-surface);
  white-space: nowrap;
}
.badge::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--color-border-strong); }
.badge.on { color: var(--color-ok); border-color: rgba(21, 128, 61, 0.45); background: var(--color-ok-soft); }
.badge.on::before { background: var(--color-ok); box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.18); }
.badge.warn { color: var(--color-warn); border-color: rgba(180, 83, 9, 0.45); background: var(--color-warn-soft); }
.badge.warn::before { background: var(--color-warn); box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.18); }
.badge a { color: inherit; text-decoration: none; }
.badge a:hover { text-decoration: underline; }

.semantic-auth-banner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: 10px 16px; margin-bottom: var(--space-4); border-radius: var(--radius-md);
  background: var(--color-warn-soft); border: 1px solid rgba(180, 83, 9, 0.35);
  color: var(--color-warn); font-size: 0.88rem;
}
.semantic-auth-banner .auth-icon { display: inline-flex; align-items: center; flex-shrink: 0; }
.semantic-auth-banner .auth-icon svg { width: 20px; height: 20px; }
.semantic-auth-banner .auth-message { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.semantic-auth-banner .auth-message strong { font-weight: 600; color: var(--color-text); }
.semantic-auth-banner .auth-message span { font-size: 0.8rem; color: var(--color-text-sub); }
.semantic-auth-banner .auth-link {
  display: inline-flex; align-items: center; padding: 6px 14px;
  border-radius: var(--radius-pill); background: var(--color-primary);
  color: #fff; text-decoration: none; font-weight: 600; font-size: 0.82rem;
  white-space: nowrap; transition: opacity var(--dur-fast) var(--ease);
}
.semantic-auth-banner .auth-link:hover { opacity: 0.9; }

/* ── 表單控件 ── */
select, textarea, input[type=text] {
  background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 10px 12px;
  min-height: var(--touch);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
select { padding-right: 32px; cursor: pointer; }
textarea { width: 100%; resize: vertical; line-height: 1.6; }
/* 案情輸入框：未聚焦時三行高度，聚焦後放大到 16rem；不參與 flex 收縮 */
#case-text { min-height: 5.5rem; flex: 0 0 auto; transition: min-height var(--dur-fast) var(--ease); }
#case-text.expanded { min-height: 16rem; }
/* 失焦後的三行預覽：以 line-clamp 截斷並以 … 收尾，外觀與輸入框一致，點一下回到編輯 */
.case-preview {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  width: 100%; min-height: 5.5rem; text-align: left; white-space: pre-wrap; word-break: break-word;
  padding: 10px 12px; line-height: 1.6; font: inherit; color: var(--color-text); cursor: text;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md);
}
.case-preview:hover { border-color: var(--color-border-strong); }
select:hover, textarea:hover, input[type=text]:hover { border-color: var(--color-border-strong); }
select:focus-visible, textarea:focus-visible, input[type=text]:focus-visible {
  outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.18);
}
::placeholder { color: #7c8594; opacity: 1; }
label { display: block; }
.field-label { font-weight: 600; color: var(--color-heading); font-family: var(--font-body); }
.field-hint { display: flex; justify-content: space-between; gap: var(--space-3); font-size: 0.82rem; color: var(--color-text-sub); }
.field-hint .count { font-variant-numeric: tabular-nums; }
.field-hint .count.ok { color: var(--color-ok); font-weight: 600; }
/* 每日配額：次數不可折行，說明文字接在後面自然換行 */
.field-hint.quota-note { justify-content: flex-start; flex-wrap: wrap; row-gap: 2px; margin-bottom: var(--space-3); }
.field-hint.quota-note strong { white-space: nowrap; flex: 0 0 auto; color: var(--color-text); }

/* 右上角 Google 登入區 */
.auth-slot { display: flex; align-items: center; }
.login-link {
  display: inline-flex; align-items: center; gap: 8px; min-height: var(--touch); padding: 4px 12px;
  border-radius: var(--radius-pill); border: 1px solid var(--color-border, #cbd5e1); background: var(--color-surface, #fff);
  color: var(--color-text); font-size: 0.85rem; font-weight: 600; text-decoration: none; white-space: nowrap; box-shadow: var(--shadow-sm);
}
.login-link:hover { text-decoration: none; filter: brightness(0.98); }
.login-link .g-mark { width: 18px; height: 18px; flex: 0 0 auto; }
.login-link small { font-weight: 400; color: var(--color-text-sub); }
.auth-user { display: inline-flex; align-items: center; gap: 8px; min-height: var(--touch); padding: 2px 6px 2px 2px; border-radius: var(--radius-pill); background: var(--color-surface, #fff); box-shadow: var(--shadow-sm); }
.avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.avatar-fallback { display: inline-flex; align-items: center; justify-content: center; background: var(--color-primary); color: #fff; font-weight: 700; font-size: 0.85rem; }
.auth-name { font-size: 0.85rem; font-weight: 600; max-width: 10em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-logout { border: 0; background: transparent; color: var(--color-text-sub); font-size: 0.8rem; cursor: pointer; padding: 4px 6px; min-height: 28px; }
.auth-logout:hover { color: var(--color-text); text-decoration: underline; }
@media (max-width: 640px) { .login-link small, .auth-name { display: none; } }
.auth-blocked { background: var(--color-bad-soft, #fee2e2); }
/* 網站已更新橫幅：綠色（正向）淡底，置中與版心同寬；按鈕沿用 primary */
.update-banner { display: flex; align-items: center; gap: var(--space-3); max-width: 960px; margin: var(--space-3) auto 0; padding: 10px 16px; border: 1px solid rgba(21, 128, 61, 0.35); border-radius: var(--radius-md); background: var(--color-ok-soft); box-shadow: var(--shadow-sm); }
.update-banner .update-icon { display: inline-flex; color: var(--color-ok); }
.update-banner .update-icon svg { width: 20px; height: 20px; }
.update-banner .update-message { display: flex; flex-direction: column; gap: 2px; flex: 1; font-size: 0.88rem; }
.update-banner .update-message strong { color: var(--color-text); }
.update-banner .update-message span { font-size: 0.8rem; color: var(--color-text-sub); }
@media (max-width: 720px) { .update-banner { margin: var(--space-3) var(--space-3) 0; } }
.privacy-notice { margin: var(--space-3) auto; max-width: 960px; padding: var(--space-3); border: 1px solid var(--color-border-strong); border-radius: 12px; background: var(--color-warn-soft); }
.privacy-notice p { margin: .25rem 0; }
.auth-delete { margin-left: .25rem; }
.auth-blocked .auth-name { max-width: 24em; color: var(--color-bad, #b91c1c); }
/* 頁面最上方的使用授權橫幅：沿用 law-powers 技能頁的漸層綠帶與白字 */
.license-banner { background: linear-gradient(90deg, var(--color-primary) 0%, #0f9d6e 100%); color: #fff; text-align: center; padding: 10px 16px; font-size: 14px; line-height: 1.6; letter-spacing: 0.02em; }
.license-banner strong { font-weight: 700; }
.license-banner .banner-except { background: rgba(255, 255, 255, 0.18); border-radius: 6px; padding: 1px 7px; font-weight: 700; white-space: nowrap; }
.upload-field { display: flex; flex-direction: column; gap: var(--space-2); }
.upload-input { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.upload-dropzone {
  width: 100%; min-height: 148px; padding: var(--space-4); flex-direction: column;
  border: 1.5px dashed var(--color-border-strong); border-radius: var(--radius-lg);
  background: linear-gradient(145deg, var(--color-surface) 0%, var(--color-surface-muted) 100%);
  color: var(--color-text-sub); text-align: center;
}
.upload-dropzone:hover, .upload-dropzone.is-dragging {
  border-color: var(--color-primary); background: #f3f6ff; color: var(--color-primary); box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}
.upload-dropzone.is-dragging { transform: translateY(-1px); }
.upload-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--color-gold-soft); color: var(--color-gold-text); }
.upload-icon svg { width: 23px; height: 23px; }
.upload-copy { display: flex; flex-direction: column; gap: 2px; }
.upload-copy strong { color: var(--color-heading); font-size: 0.95rem; }
.upload-copy span { font-size: 0.84rem; }
.upload-formats { padding: 3px 10px; border: 1px solid var(--color-border); border-radius: var(--radius-pill); background: rgba(255, 255, 255, 0.72); font-size: 0.76rem; color: var(--color-text-sub); }
.file-list { display: flex; flex-direction: column; gap: var(--space-2); }
.file-list:empty { display: none; }
.file-item { display: grid; grid-template-columns: 44px minmax(0, 1fr) 40px; align-items: center; gap: var(--space-3); min-height: 58px; padding: var(--space-2) var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); box-shadow: var(--shadow-sm); }
.file-extension { display: grid; place-items: center; width: 42px; height: 42px; border-radius: var(--radius-sm); background: var(--color-gold-soft); color: var(--color-gold-text); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em; }
.file-detail { min-width: 0; display: flex; flex-direction: column; gap: 2px; text-align: left; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-heading); font-size: 0.88rem; }
.file-size { color: var(--color-text-sub); font-size: 0.76rem; font-variant-numeric: tabular-nums; }
.file-remove { width: 36px; min-height: 36px; padding: 0; border-color: transparent; border-radius: 50%; color: var(--color-text-sub); }
.file-remove:hover { color: var(--color-bad); border-color: rgba(185, 28, 28, 0.25); background: var(--color-bad-soft); }
.file-status { font-size: 0.82rem; color: var(--color-text-sub); }
.file-status.error { color: var(--color-bad); font-weight: 600; }

/* ── 按鈕：一頁只有一個 primary；secondary／ghost 視覺從屬 ── */
button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--touch); padding: 10px 18px;
  border-radius: var(--radius-md); border: 1px solid var(--color-border);
  background: var(--color-surface); color: var(--color-text); font-weight: 500;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
button:hover { background: var(--color-surface-muted); border-color: var(--color-border-strong); }
button:active { transform: translateY(1px); }
button.primary { background: var(--color-primary); color: var(--color-on-primary); border-color: transparent; font-weight: 600; box-shadow: var(--shadow-sm); }
button.primary:hover { background: var(--color-primary-hover); box-shadow: var(--shadow-md); }
button.ghost { background: transparent; color: var(--color-text-sub); border-style: dashed; }
button.ghost:hover { color: var(--color-bad); border-color: var(--color-bad); background: var(--color-bad-soft); }
button:disabled { cursor: not-allowed; opacity: 0.55; box-shadow: none; transform: none; }
button.primary:disabled { background: var(--color-primary); }
button svg { width: 18px; height: 18px; flex: 0 0 auto; }

/* ── 舞台 ── */
#stage { max-width: 1200px; margin: 0 auto; padding: var(--space-5) var(--space-5) var(--space-8); outline: none; }
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }

/* ── 輸入頁 ── */
.input { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: var(--space-5); align-items: start; }
.input-main { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-5); }
.input-main .field-label { font-size: 1.1rem; }
.input-actions { display: flex; justify-content: flex-end; }
.input-actions .primary { min-width: 160px; }
.input-side { display: flex; flex-direction: column; gap: var(--space-3); }
.input-side h3 { font-size: 1rem; color: var(--color-heading); display: flex; align-items: center; gap: var(--space-2); }
.input-side h3::before { content: ''; width: 3px; height: 1em; background: var(--color-gold); border-radius: 2px; }
.samples { display: grid; grid-template-columns: 1fr; gap: var(--space-3); }
.sample {
  text-align: left; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--space-1) var(--space-3);
  padding: var(--space-3) var(--space-4); border-left: 3px solid var(--color-gold); border-radius: var(--radius-md);
  background: var(--color-surface); min-height: var(--touch);
}
.sample:hover { border-color: var(--color-border-strong); border-left-color: var(--color-primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.sample b { color: var(--color-heading); font-size: 0.98rem; }
.sample span { grid-column: 1; font-size: 0.85rem; color: var(--color-text-sub); line-height: 1.5; }
.sample svg { grid-column: 2; grid-row: 1 / span 2; width: 18px; height: 18px; color: var(--color-text-sub); transition: transform var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
.sample:hover svg { transform: translateX(3px); color: var(--color-primary); }
.disclaimer { font-size: 0.8rem; color: var(--color-text-sub); line-height: 1.6; display: flex; gap: var(--space-2); align-items: flex-start; }
.disclaimer svg { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 2px; color: var(--color-gold-text); }

/* ── 進度列（五步 stepper）與退路 ── */
.progress { list-style: none; padding: 0; margin: 0 0 var(--space-3); display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-2); counter-reset: step; }
.step {
  position: relative; display: flex; align-items: center; gap: var(--space-2);
  min-height: 56px; padding: var(--space-2) var(--space-3); font-size: 0.85rem; line-height: 1.3;
  border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-text-sub); border: 1px solid var(--color-border);
  transition: background var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease);
}
.step-no {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 0.78rem; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--color-surface-muted); color: var(--color-text-sub); border: 1px solid var(--color-border);
}
.step.done { color: var(--color-ok); border-color: rgba(21, 128, 61, 0.4); background: var(--color-ok-soft); }
.step.done .step-no { background: var(--color-ok); color: #fff; border-color: transparent; font-size: 0; }
.step.done .step-no::after { content: ''; width: 7px; height: 12px; border: solid #fff; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.step.active { color: var(--color-heading); font-weight: 600; border-color: var(--color-gold); background: var(--color-gold-soft); animation: pulse 1.6s infinite; }
.step.active .step-no { background: var(--color-primary); color: #fff; border-color: transparent; }
/* 進行中：以旋轉細環表示系統仍在工作（>300ms 的等待需有回饋） */
.step.active[data-busy] .step-no { position: relative; }
.step.active[data-busy] .step-no::before {
  content: ''; position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid transparent; border-top-color: var(--color-primary); animation: spin 0.9s linear infinite;
}
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--glow-color); } 50% { box-shadow: 0 0 14px 2px var(--glow-color); } }
@keyframes spin { to { transform: rotate(360deg); } }
.cancel-row { display: flex; justify-content: flex-end; margin: 0 0 var(--space-4); }

/* ── 進行中／等待回答時的中間成果 ── */
.partials { margin-top: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.partials h2 { font-size: 1.05rem; display: flex; align-items: center; gap: var(--space-2); }
.partials h2::before { content: ''; width: 3px; height: 1em; background: var(--color-gold); border-radius: 2px; }
.partial { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-2) var(--space-4); box-shadow: var(--shadow-sm); }
.partial summary { cursor: pointer; font-weight: 600; color: var(--color-heading); min-height: var(--touch); display: flex; align-items: center; gap: var(--space-2); list-style: none; }
.partial summary::-webkit-details-marker { display: none; }
.partial summary::before { content: ''; width: 8px; height: 8px; border: solid var(--color-text-sub); border-width: 0 2px 2px 0; transform: rotate(-45deg); transition: transform var(--dur-fast) var(--ease); margin-right: 2px; }
.partial[open] summary::before { transform: rotate(45deg); }
.partial h3 { font-family: var(--font-body); font-size: 0.85rem; color: var(--color-text-sub); text-transform: uppercase; letter-spacing: 0.04em; margin: var(--space-3) 0 var(--space-1); }
.partial ul { margin: 0 0 var(--space-2); padding-left: 1.2rem; line-height: 1.7; }

/* ── 提問表單 ── */
.questions { display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-5); }
.questions h2 { font-size: 1.3rem; }
.questions .lead { color: var(--color-text-sub); font-size: 0.92rem; margin-top: calc(-1 * var(--space-2)); }
.q { display: grid; grid-template-columns: auto 1fr; gap: var(--space-1) var(--space-3); padding: var(--space-4); background: var(--color-surface-muted); border-radius: var(--radius-md); border: 1px solid transparent; transition: border-color var(--dur-fast) var(--ease); }
.q:focus-within { border-color: var(--color-primary); background: var(--color-surface); }
.q-no { grid-row: 1 / span 3; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 0.8rem; font-weight: 700; background: var(--color-primary); color: #fff; }
.q-text { font-weight: 600; color: var(--color-heading); }
.q small { color: var(--color-text-sub); font-size: 0.82rem; }
.q textarea { grid-column: 2; margin-top: var(--space-2); }
.questions-actions { display: flex; justify-content: flex-end; }

/* ── 結果頁：分頁採 segmented control ── */
.tabs { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); flex-wrap: wrap; }
.tablist { display: inline-flex; gap: 2px; padding: 3px; background: var(--color-surface-muted); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.tab { min-height: 38px; padding: 6px 16px; border: none; background: transparent; color: var(--color-text-sub); border-radius: var(--radius-sm); }
.tab:hover { background: rgba(255, 255, 255, 0.7); color: var(--color-text); }
.tab.active { background: var(--color-primary); color: var(--color-on-primary); font-weight: 600; box-shadow: var(--shadow-sm); }
.tabs .gen { margin-left: auto; font-size: 0.8rem; color: var(--color-text-sub); }
.panel { padding: var(--space-4) var(--space-5) var(--space-5); }
.panel h3 { font-family: var(--font-body); font-size: 0.95rem; color: var(--color-heading); display: flex; align-items: center; gap: var(--space-2); margin: var(--space-4) 0 var(--space-2); }
.panel h3::before { content: ''; width: 3px; height: 1em; background: var(--color-gold); border-radius: 2px; }
.panel h3:first-child { margin-top: 0; }
.panel ul { margin: 0; padding-left: 1.2rem; line-height: 1.7; }
.panel p { line-height: 1.7; }
.panel .disclaimer { margin-top: var(--space-4); padding-top: var(--space-3); border-top: 1px dashed var(--color-border); }
.panel[data-panel=graph] { padding: 0; background: transparent; border: none; box-shadow: none; }

/* 構成要件涵攝表：符號＋文字＋顏色三重編碼（不只靠顏色傳達） */
.elements { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.el { display: grid; grid-template-columns: auto 1fr; gap: var(--space-1) var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--color-border); border-left-width: 4px; background: var(--color-surface); }
.el-badge { grid-row: 1 / span 2; align-self: start; display: inline-flex; align-items: center; gap: 4px; min-height: 26px; padding: 2px 10px; border-radius: var(--radius-pill); font-size: 0.78rem; font-weight: 700; white-space: nowrap; }
.el-head { font-weight: 600; color: var(--color-heading); }
.el-head .el-law { font-weight: 500; color: var(--color-text-sub); }
.el-basis { grid-column: 2; font-size: 0.9rem; color: var(--color-text); line-height: 1.6; }
.el-yes { border-left-color: var(--color-ok); } .el-yes .el-badge { background: var(--color-ok-soft); color: var(--color-ok); }
.el-no { border-left-color: var(--color-bad); } .el-no .el-badge { background: var(--color-bad-soft); color: var(--color-bad); }
.el-unknown { border-left-color: var(--color-warn); } .el-unknown .el-badge { background: var(--color-warn-soft); color: var(--color-warn); }

/* 涵攝與評估：請求權小結、抗辯表、證據表、風險徽章 */
.claim-summary { list-style: none; padding: 0; margin: 0 0 var(--space-4); display: grid; gap: var(--space-2); }
.claim { display: flex; justify-content: space-between; gap: var(--space-3); padding: 8px 12px; border-radius: var(--radius-md); border: 1px solid var(--color-border); }
.claim-established { border-color: var(--color-ok); background: var(--color-ok-soft); }
.claim-failed { border-color: var(--color-bad); background: var(--color-bad-soft); }
.claim-pending { border-color: var(--color-warn); background: var(--color-warn-soft); }
.claim-status { font-weight: 600; white-space: nowrap; }
.table-wrap { overflow-x: auto; margin-bottom: var(--space-4); }
.assess-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.assess-table th, .assess-table td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--color-border); }
.assess-table th { color: var(--color-text-sub); font-weight: 600; white-space: nowrap; }
.risk { display: inline-block; padding: 2px 8px; border-radius: var(--radius-pill); font-size: 0.8rem; font-weight: 600; }
.risk-high { background: var(--color-bad-soft); color: var(--color-bad); }
.risk-medium { background: var(--color-warn-soft); color: var(--color-warn); }
.risk-low { background: var(--color-ok-soft); color: var(--color-ok); }

/* 契約圖圖例：風險色說明列 */
.legend-risks { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.legend-risk { display: inline-block; padding: 2px 8px; border-radius: var(--radius-pill); font-size: 0.78rem; font-weight: 600; }

/* 當事人準備清單：說明文字、匯出／列印按鈕列、僅列印清單本體 */
.checklist .lead { color: var(--color-text-sub); margin-bottom: var(--space-3); }
.checklist .actions { display: flex; gap: var(--space-2); margin-top: var(--space-3); }
/* 僅在按下「清單列印」按鈕時（body 加上 printing-checklist class）才隱藏其他內容，一般 Ctrl+P 不受影響 */
@media print { body.printing-checklist * { visibility: hidden; } body.printing-checklist #checklist-sheet, body.printing-checklist #checklist-sheet * { visibility: visible; } body.printing-checklist #checklist-sheet { position: absolute; left: 0; top: 0; width: 100%; } body.printing-checklist #checklist-sheet .actions { display: none; } }

/* 失敗頁 */
.failed { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-5); border-left: 4px solid var(--color-bad); max-width: 720px; }
.failed h2 { font-size: 1.3rem; display: flex; align-items: center; gap: var(--space-2); }
.failed h2 svg { width: 24px; height: 24px; color: var(--color-bad); }
.failed .code { color: var(--color-bad); font-family: var(--font-mono); font-size: 0.85rem; background: var(--color-bad-soft); padding: 4px 10px; border-radius: var(--radius-sm); align-self: flex-start; }
.failed .actions { display: flex; gap: var(--space-2); }

/* ── 3D 圖區（law-powers 渲染器骨架） ── */
.graph-wrap { display: grid; grid-template-columns: 240px 1fr; height: 70vh; min-height: 420px; position: relative; overflow: hidden; border-radius: var(--radius-lg); border: 1px solid var(--color-border); background: var(--color-canvas); box-shadow: var(--shadow-sm); }
.control-panel {
  background: var(--panel-bg); backdrop-filter: blur(20px); border-right: 1px solid var(--color-border);
  padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); z-index: 5; overflow-y: auto;
}
.section-title { font-size: 0.85rem; font-weight: 600; color: var(--color-heading); text-transform: uppercase; letter-spacing: 0.04em; display: flex; align-items: center; gap: var(--space-2); }
.section-title::before { content: ''; width: 3px; height: 1em; background: var(--color-gold); border-radius: 2px; }
#filter-box label { display: flex; align-items: center; gap: var(--space-2); min-height: 32px; font-size: 0.88rem; color: var(--color-text); cursor: pointer; }
#filter-box input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--color-primary); margin: 0; }
#search-input { width: 100%; font-size: 0.9rem; }
#network-canvas { min-width: 0; min-height: 0; height: 100%; position: relative; }
.graph-hint { position: absolute; left: 50%; bottom: var(--space-3); transform: translateX(-50%); font-size: 0.75rem; color: var(--color-text-sub); background: rgba(255,255,255,0.8); padding: 2px 10px; border-radius: var(--radius-pill); pointer-events: none; }
.detail-panel {
  position: absolute; right: 0; top: 0; width: 380px; max-width: 92%; height: 100%;
  background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(25px); border-left: 1px solid var(--color-border);
  padding: var(--space-6) var(--space-5) var(--space-5); z-index: 8; display: flex; flex-direction: column; gap: var(--space-4);
  box-shadow: var(--shadow-lg); transform: translateX(100%);
  transition: transform var(--dur-slow) var(--ease); overflow-y: auto;
}
.detail-panel.active { transform: translateX(0); }
.close-btn { position: absolute; top: var(--space-2); right: var(--space-2); width: var(--touch); height: var(--touch); padding: 0; background: transparent; border: none; color: var(--color-text-sub); border-radius: 50%; }
.close-btn:hover { color: var(--color-text); background: var(--color-surface-muted); }
.close-btn svg { width: 20px; height: 20px; }
.detail-header { border-bottom: 1px solid var(--color-border); padding-bottom: var(--space-3); margin-top: var(--space-1); }
.detail-tag { display: inline-block; padding: 3px 10px; border-radius: var(--radius-sm); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: var(--space-2); color: #fff; }
.detail-title { font-size: 1.15rem; font-weight: 700; line-height: 1.4; }
.detail-body { font-size: 0.92rem; line-height: 1.65; color: var(--color-text); white-space: pre-wrap; }
.detail-body a { color: var(--color-primary); font-weight: 500; }

/* ── Tool Inspector（右下角折疊面板） ── */
.inspector { position: fixed; right: var(--space-4); bottom: var(--space-4); width: 380px; max-width: calc(100vw - 2 * var(--space-4)); background: rgba(255, 255, 255, 0.97); border: 1px solid var(--color-border); border-top: 3px solid var(--color-gold); border-radius: var(--radius-lg); padding: var(--space-2); z-index: 20; box-shadow: var(--shadow-md); }
.inspector #insp-toggle { width: 100%; justify-content: space-between; border-color: transparent; background: transparent; font-weight: 600; color: var(--color-heading); }
.inspector #insp-toggle:hover { background: var(--color-surface-muted); }
.inspector #insp-toggle svg { transition: transform var(--dur-base) var(--ease); }
.inspector:not(.collapsed) #insp-toggle svg { transform: rotate(180deg); }
.inspector .insp-body { display: flex; flex-direction: column; gap: var(--space-2); max-height: min(70vh, 600px); overflow-y: auto; margin-top: var(--space-2); padding: 0 var(--space-1) var(--space-1); }
.inspector.collapsed .insp-body { display: none; }
.inspector textarea { font-family: var(--font-mono); font-size: 0.82rem; }
.inspector pre { margin: 0; max-height: 240px; overflow: auto; font-size: 0.78rem; font-family: var(--font-mono); white-space: pre-wrap; word-break: break-all; background: var(--color-surface-muted); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); border: 1px solid var(--color-border); }
.inspector pre:empty { display: none; }
.insp-guide { background: var(--color-surface-muted); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); font-size: 0.84rem; }
.insp-guide p { margin: var(--space-1) 0; color: var(--color-text-sub); line-height: 1.45; }
.insp-guide ol { margin: var(--space-1) 0 0; padding-left: 1.5rem; }
.insp-guide li { margin: 0.35rem 0; line-height: 1.4; }
.insp-guide code { color: var(--color-heading); font-family: var(--font-mono); font-weight: 700; }
.insp-guide small { display: block; color: var(--color-text-sub); }
.question-fill-notice { margin: var(--space-3) 0; padding: var(--space-2) var(--space-3); color: var(--color-heading); background: #e8f5ec; border: 1px solid #78bd8f; border-radius: var(--radius-sm); font-weight: 600; }

/* ── 響應式：768 以下單欄、375 可用 ── */
@media (max-width: 960px) {
  .input { grid-template-columns: 1fr; }
  .progress { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .step { flex-direction: column; text-align: center; font-size: 0.78rem; padding: var(--space-2); }
}
/* 平板以下：右側選單整列換到品牌下方並允許自行換行，避免品牌標題被壓成直排 */
@media (max-width: 1024px) {
  .topbar { flex-wrap: wrap; padding: var(--space-3) var(--space-4); }
  .topbar-right { flex: 1 1 100%; flex-wrap: wrap; row-gap: var(--space-2); justify-content: flex-start; }
  .topbar-right .nav-link { order: -1; }
}
@media (max-width: 720px) {
  .topbar h1 { font-size: 1.25rem; }
  .license-banner { font-size: 12.5px; padding: 8px 12px; }
  #stage { padding: var(--space-4) var(--space-3) var(--space-8); }
  .input-main, .questions, .panel, .failed { padding: var(--space-4); }
  .input-actions .primary { width: 100%; }
  .upload-dropzone { min-height: 132px; padding: var(--space-3); }
  .progress { grid-template-columns: 1fr; gap: var(--space-1); }
  .step { flex-direction: row; text-align: left; min-height: var(--touch); }
  .graph-wrap { grid-template-columns: 1fr; height: 60vh; }
  .control-panel { display: none; }
  .tabs .gen { display: none; }
  .tablist { width: 100%; overflow-x: auto; }
  .tab { flex: 1 0 auto; }
  /* 手機：折疊時只佔按鈕寬度（少遮內容），展開後才滿版 */
  .inspector { right: var(--space-2); bottom: var(--space-2); width: auto; max-width: calc(100vw - 2 * var(--space-2)); padding: var(--space-1); }
  /* 手機：工具檢視器整個隱藏。它是給 Agent host 看的唯讀清單，在手機上只會蓋住全寬的送出鈕（Playwright 也會因此點不到）。 */
  .inspector { display: none; }
  .inspector:not(.collapsed) { left: var(--space-2); }
  .el { grid-template-columns: 1fr; }
  .el-badge { grid-row: auto; justify-self: start; }
  .el-basis { grid-column: 1; }
}

/* ── 減少動態：關閉脈動、旋轉與位移動畫，保留即時狀態切換 ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
  .sample:hover, button:active { transform: none; }
}

/* ── 輸出項目勾選區（輸入頁）─────────────────────────────────────────────── */
.outputs { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4) var(--space-4); margin-top: var(--space-4); background: var(--color-surface); }
.outputs legend { font-weight: 600; color: var(--color-heading); padding: 0 var(--space-2); font-size: 0.92rem; }
.output-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-1) var(--space-3); }
.output-item { display: flex; align-items: center; gap: var(--space-2); min-height: var(--touch); cursor: pointer; font-size: 0.9rem; border-radius: var(--radius-sm); padding: 0 var(--space-2); transition: background var(--dur-fast) var(--ease); }
.output-item:hover { background: var(--color-surface-muted); }
.output-item input { width: 16px; height: 16px; accent-color: var(--color-primary); flex: 0 0 auto; }
.output-item:has(input:checked) { color: var(--color-heading); font-weight: 600; }
.outputs .field-hint { margin-top: var(--space-2); justify-content: flex-start; }

/* ── 公文書狀版面（結果頁 doc-* 分頁）───────────────────────────────────── */
.legal-doc { max-width: 720px; margin: 0 auto; padding: var(--space-6) var(--space-5); background: var(--color-surface); border: 1px solid var(--color-border); border-top: 3px double var(--color-gold); box-shadow: var(--shadow-sm); font-family: var(--font-heading); line-height: 2; color: var(--color-text); }
.legal-doc .doc-title { text-align: center; font-size: 1.5rem; letter-spacing: 0.35em; text-indent: 0.35em; color: var(--color-heading); margin: 0 0 var(--space-5); }
.legal-doc .doc-parties { width: auto; margin: 0 0 var(--space-5); border-collapse: collapse; }
.legal-doc .doc-parties th { text-align: justify; text-align-last: justify; min-width: 5em; padding: var(--space-1) var(--space-4) var(--space-1) 0; font-weight: 600; color: var(--color-heading); vertical-align: top; }
.legal-doc .doc-parties td { padding: var(--space-1) 0; }
.legal-doc .doc-body p { margin: 0 0 var(--space-3); text-align: justify; text-indent: 0; }
.legal-doc .doc-section { margin: var(--space-5) 0 var(--space-2); font-size: 1.02rem; color: var(--color-heading); display: flex; align-items: center; gap: var(--space-2); }
.legal-doc .doc-section::before { content: ''; width: 3px; height: 1em; background: var(--color-gold); border-radius: 2px; }
/* 爭點整理表：實務表格版面，窄螢幕可橫向捲動 */
.legal-doc .issue-toolbar { display: flex; justify-content: flex-end; margin: var(--space-3) 0 var(--space-2); }
.legal-doc .doc-export { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-heading); font-size: 0.9rem; text-decoration: none; }
.legal-doc .doc-export:hover { border-color: var(--color-gold); }
.legal-doc .issue-table-wrap { overflow-x: auto; margin-bottom: var(--space-4); }
.legal-doc .issue-table { width: 100%; min-width: 720px; border-collapse: collapse; font-family: var(--font-body, inherit); font-size: 0.92rem; line-height: 1.55; }
.legal-doc .issue-table th, .legal-doc .issue-table td { border: 1px solid var(--color-border); padding: 8px 10px; text-align: left; vertical-align: top; }
.legal-doc .issue-table th { background: var(--color-warn-soft, #f6efe2); color: var(--color-heading); font-weight: 600; white-space: nowrap; }
.legal-doc .issue-table td:first-child { white-space: nowrap; text-align: center; }
.legal-doc .issue-table tbody tr:nth-child(even) td { background: rgba(0, 0, 0, 0.02); }
.legal-doc .issue-toolbar { justify-content: space-between; align-items: center; }
.legal-doc .issue-toolbar .doc-section { margin: 0; }
/* 聲請事項：只在勾選聲請狀時顯示 */
.motion-field { margin: var(--space-3) 0 0; }
.motion-field input { width: 100%; padding: 10px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-md); font: inherit; background: var(--color-surface); }
.legal-doc .doc-attachments { margin: 0 0 var(--space-4); padding-left: 1.5em; }
.legal-doc .doc-attachments li { margin-bottom: var(--space-1); }
.legal-doc .doc-footer { margin-top: var(--space-6); padding-top: var(--space-4); border-top: 1px solid var(--color-border); display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-3); }
.legal-doc .doc-to { font-weight: 600; color: var(--color-heading); }
.legal-doc .doc-date { text-align: right; margin-left: auto; }
.legal-doc .disclaimer { margin-top: var(--space-4); font-family: var(--font-body); }
.doc-missing { display: flex; gap: var(--space-2); align-items: flex-start; color: var(--color-text-sub); background: var(--color-warn-soft); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-4); }
.doc-missing svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 3px; color: var(--color-warn); }
@media (max-width: 640px) { .legal-doc { padding: var(--space-5) var(--space-4); } }

/* 書狀標題：蓋掉 .panel h3 的小節樣式，恢復置中狀別標題（含 h4 證物節，維持小節條） */
.panel .legal-doc .doc-title { display: block; text-align: center; font-family: var(--font-heading); font-size: 1.5rem; margin: 0 0 var(--space-5); }
.panel .legal-doc .doc-title::before { content: none; }

/* ── 唯讀 Tool Inspector 工具清單 ─────────────────────────────────────────── */
#insp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
#insp-list li { background: var(--color-surface-muted); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); font-size: 0.82rem; line-height: 1.45; }
#insp-list li code { font-family: var(--font-mono); font-weight: 700; color: var(--color-heading); }
#insp-list li small { display: block; margin-top: 2px; color: var(--color-text-sub); }
#insp-list .insp-ro { margin-left: var(--space-2); font-size: 0.7rem; font-weight: 600; color: var(--color-gold-text); background: var(--color-gold-soft); border: 1px solid var(--color-gold); border-radius: var(--radius-pill); padding: 0 var(--space-2); vertical-align: middle; }
#insp-list .insp-empty { color: var(--color-text-sub); border-style: dashed; }
.insp-note { margin: 0; font-size: 0.76rem; color: var(--color-text-sub); line-height: 1.5; }
#insp-state { margin: 0; font-size: 0.84rem; font-weight: 600; color: var(--color-heading); }

/* ── 首頁能力入口 ─────────────────────────────────────────────────────────
   版心收窄到 960px、標題置中，兩張卡等高且「開始」鈕永遠貼齊卡片底部（grid 最後一列 auto，中間 1fr 吃掉高度差）。 */
.home { display: grid; gap: var(--space-5); max-width: 960px; margin: 0 auto; }
.home-title { font-size: 2rem; text-align: center; margin-top: var(--space-4); }
.home-lead { color: var(--color-text-sub); }
.home > .home-lead { text-align: center; margin-top: calc(-1 * var(--space-3)); }
.capabilities { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--space-5); }
.capability { display: grid; grid-template-rows: auto auto 1fr auto auto; gap: var(--space-3); padding: var(--space-5); cursor: pointer; border-top: 3px solid var(--color-gold); transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease); }
.capability:hover, .capability:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--color-primary); outline: none; }
.capability:focus-visible { box-shadow: var(--shadow-md), 0 0 0 3px rgba(30, 58, 138, 0.25); }
.capability .cap-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: var(--radius-md); background: var(--color-gold-soft); color: var(--color-primary); }
.capability .cap-icon svg { width: 28px; height: 28px; }
.capability h2 { font-size: 1.5rem; }
.capability > p { line-height: 1.7; color: var(--color-text); }
.capability .cap-steps { font-size: .8rem; color: var(--color-text-sub); padding-top: var(--space-2); border-top: 1px dashed var(--color-border); letter-spacing: 0.02em; }
.capability button { justify-self: start; min-width: 140px; }
.home .disclaimer { justify-content: center; }
@media (max-width: 640px) { .home-title { font-size: 1.6rem; } .capability { padding: var(--space-4); } }

/* 結果頁合約模式：風險條款清單工具列（篩選鈕＋匯出）與條款原文欄位換行 */
.findings-toolbar { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); flex-wrap: wrap; }
.chip { border: 1px solid var(--color-border-strong); background: transparent; border-radius: 999px; padding: 2px 10px; cursor: pointer; }
.chip.active { background: var(--color-primary, #1e3a8a); color: #fff; border-color: transparent; }
.findings-table td.clause-text { max-width: 22rem; white-space: pre-wrap; }

/* ── 統計頁：今日數字卡、SVG 直條圖與環圈圖（不引入圖表函式庫；顏色全走代幣） ── */
.stats { display: grid; gap: var(--space-4); max-width: 1100px; margin: 0 auto; }
.stats-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-4); flex-wrap: wrap; }
.stats-head h2 { font-size: 1.75rem; margin-bottom: var(--space-1); }
.period-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: var(--radius-pill); background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-text-sub); font-size: 0.82rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); }
.stat-tile { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-4) var(--space-5); border-top: 3px solid var(--color-gold); }
.stat-title { font-size: 0.82rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--color-text-sub); }
.stat-big { font-family: var(--font-heading); font-size: 2.6rem; line-height: 1.05; color: var(--color-heading); font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--color-text-sub); font-size: 0.85rem; line-height: 1.5; }
.delta { margin-top: var(--space-1); font-size: 0.8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--color-ok); }
.delta.down { color: var(--color-bad); }
.delta.flat { color: var(--color-text-sub); font-weight: 500; }
/* 四張圖卡：兩張趨勢圖各佔一半，兩個環圈各佔一半；窄螢幕退成單欄 */
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.chart-card { padding: var(--space-4) var(--space-5) var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.chart-card h3 { font-family: var(--font-body); font-size: 0.95rem; color: var(--color-heading); display: flex; align-items: center; gap: var(--space-2); }
.chart-card h3::before { content: ''; width: 3px; height: 1em; background: var(--color-gold); border-radius: 2px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--color-border); stroke-dasharray: 3 3; }
.chart .tick, .chart .axis { fill: var(--color-text-sub); font-family: var(--font-body); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .empty { fill: var(--color-border-strong); }
.chart rect { transition: opacity var(--dur-fast) var(--ease); }
.chart g:hover rect { opacity: 0.8; }
/* 序列顏色：案件＝藏青、合約＝信任金、prompt＝藏青、completion＝金；完成／失敗沿用狀態色 */
.s-case, .s-prompt { fill: var(--color-primary); stroke: var(--color-primary); }
.s-contract, .s-completion { fill: var(--color-gold); stroke: var(--color-gold); }
.s-ok { fill: var(--color-ok); stroke: var(--color-ok); }
.s-bad { fill: var(--color-bad); stroke: var(--color-bad); }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); font-size: 0.85rem; color: var(--color-text-sub); }
.legend.inline { flex-direction: row; flex-wrap: wrap; gap: var(--space-4); }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend li b { margin-left: auto; color: var(--color-text); font-variant-numeric: tabular-nums; }
.legend.inline li b { margin-left: 4px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: currentColor; flex: 0 0 auto; }
.swatch.s-case, .swatch.s-prompt { background: var(--color-primary); }
.swatch.s-contract, .swatch.s-completion { background: var(--color-gold); }
.swatch.s-ok { background: var(--color-ok); }
.swatch.s-bad { background: var(--color-bad); }
.donut-wrap { display: grid; grid-template-columns: 140px 1fr; align-items: center; gap: var(--space-4); padding: var(--space-2) 0; }
.donut { width: 140px; height: 140px; transform: rotate(-90deg); }
/* 環圈只用描邊畫弧；.s-* 序列色同時設了 fill（給直條圖用），這裡要壓回 none 否則整個圓被填滿 */
.donut circle { fill: none; }
.donut .donut-track { stroke: var(--color-surface-muted); }
.donut circle:not(.donut-track) { stroke-linecap: butt; transition: stroke-dasharray var(--dur-slow) var(--ease); }
.donut .donut-center { transform: rotate(90deg); transform-origin: 60px 60px; font-family: var(--font-heading); font-size: 22px; font-weight: 700; fill: var(--color-heading); }
.donut .donut-center.muted { font-family: var(--font-body); font-size: 12px; font-weight: 500; fill: var(--color-text-sub); }
.stats-details summary { cursor: pointer; font-weight: 600; color: var(--color-heading); padding: var(--space-2) var(--space-1); min-height: var(--touch); display: flex; align-items: center; gap: var(--space-2); }
.stats-details summary::-webkit-details-marker { display: none; }
.stats-details summary::before { content: '▸'; color: var(--color-gold); transition: transform var(--dur-fast) var(--ease); }
.stats-details[open] summary::before { transform: rotate(90deg); }
.stats-details .table-wrap { margin-top: var(--space-2); overflow-x: auto; }
.stats-table td { font-variant-numeric: tabular-nums; }
@media (max-width: 860px) { .stats-grid { grid-template-columns: 1fr; } }
@media (max-width: 480px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } .stat-big { font-size: 2.1rem; } }
