/* ============================================================
   臺南氣候調適系列 — 共用設計系統 (Design System 2.0)
   ============================================================ */

:root {
  --ink: #142a27;
  --ink-soft: #425853;
  --ink-faint: #6e847f;
  --paper: #f2f5f3;
  --surface: #ffffff;
  --surface-2: #e5ece8;
  --surface-3: #d8e3de;
  --line: #cbdbd4;
  --line-subtle: #e0e9e5;
  
  --accent-key: #0d695e;
  --accent-key-hover: #094d45;
  --accent-key-soft: #d8ede8;
  
  --accent-gap: #a3531b;
  --accent-gap-hover: #7e3e11;
  --accent-gap-soft: #faebd7;

  --accent-alert: #b83232;
  --accent-alert-soft: #fde8e8;
  
  --shadow-sm: 0 1px 3px rgba(15, 36, 32, 0.05);
  --shadow: 0 2px 8px -2px rgba(15, 36, 32, 0.08), 0 12px 28px -8px rgba(15, 36, 32, 0.12);
  --shadow-lg: 0 4px 14px -2px rgba(15, 36, 32, 0.1), 0 20px 40px -10px rgba(15, 36, 32, 0.16);

  --font-display: 'Noto Serif TC', 'PMingLiU', 'Songti TC', serif;
  --font-body: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e2ece8;
    --ink-soft: #a6bcb5;
    --ink-faint: #738a83;
    --paper: #0e1917;
    --surface: #142420;
    --surface-2: #1b302a;
    --surface-3: #233e36;
    --line: #2a443c;
    --line-subtle: #1c322b;
    --accent-key: #5ee2cc;
    --accent-key-hover: #7df5e1;
    --accent-key-soft: #173832;
    --accent-gap: #f0ad6a;
    --accent-gap-hover: #f7c593;
    --accent-gap-soft: #382715;
    --accent-alert: #f87171;
    --accent-alert-soft: #3b1919;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 12px 28px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.5), 0 24px 48px rgba(0, 0, 0, 0.7);
  }
}

:root[data-theme="dark"] {
  --ink: #e2ece8;
  --ink-soft: #a6bcb5;
  --ink-faint: #738a83;
  --paper: #0e1917;
  --surface: #142420;
  --surface-2: #1b302a;
  --surface-3: #233e36;
  --line: #2a443c;
  --line-subtle: #1c322b;
  --accent-key: #5ee2cc;
  --accent-key-hover: #7df5e1;
  --accent-key-soft: #173832;
  --accent-gap: #f0ad6a;
  --accent-gap-hover: #f7c593;
  --accent-gap-soft: #382715;
  --accent-alert: #f87171;
  --accent-alert-soft: #3b1919;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 12px 28px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.5), 0 24px 48px rgba(0, 0, 0, 0.7);
}

:root[data-theme="light"] {
  --ink: #142a27;
  --ink-soft: #425853;
  --ink-faint: #6e847f;
  --paper: #f2f5f3;
  --surface: #ffffff;
  --surface-2: #e5ece8;
  --surface-3: #d8e3de;
  --line: #cbdbd4;
  --line-subtle: #e0e9e5;
  --accent-key: #0d695e;
  --accent-key-hover: #094d45;
  --accent-key-soft: #d8ede8;
  --accent-gap: #a3531b;
  --accent-gap-hover: #7e3e11;
  --accent-gap-soft: #faebd7;
  --accent-alert: #b83232;
  --accent-alert-soft: #fde8e8;
  --shadow-sm: 0 1px 3px rgba(15, 36, 32, 0.05);
  --shadow: 0 2px 8px -2px rgba(15, 36, 32, 0.08), 0 12px 28px -8px rgba(15, 36, 32, 0.12);
  --shadow-lg: 0 4px 14px -2px rgba(15, 36, 32, 0.1), 0 20px 40px -10px rgba(15, 36, 32, 0.16);
}

/* ============================================================
   數字對照頁專用色系 — 冷灰藍／靛紫，區隔於其餘頁面的綠／大地色調
   （資料來源不同：本頁同時涉及草案與核定本兩份文件）
   ============================================================ */
body.compare-page {
  --ink: #1e2532;
  --ink-soft: #4b566b;
  --ink-faint: #7b869c;
  --paper: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #e7e9f0;
  --surface-3: #dadde8;
  --line: #ccd0e0;
  --line-subtle: #e2e4ee;
  --accent-key: #3a4f8f;
  --accent-key-hover: #2c3970;
  --accent-key-soft: #dde1f5;
  --accent-gap: #6b3fa0;
  --accent-gap-hover: #4f2d78;
  --accent-gap-soft: #ece4f7;
  --accent-alert: #a83a4a;
  --accent-alert-soft: #f6e3e6;
  --shadow-sm: 0 1px 3px rgba(20, 25, 40, 0.06);
  --shadow: 0 2px 8px -2px rgba(20, 25, 40, 0.10), 0 12px 28px -8px rgba(20, 25, 40, 0.14);
  --shadow-lg: 0 4px 14px -2px rgba(20, 25, 40, 0.12), 0 20px 40px -10px rgba(20, 25, 40, 0.18);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) body.compare-page {
    --ink: #dde1ee;
    --ink-soft: #a8b0c8;
    --ink-faint: #7d859c;
    --paper: #12141c;
    --surface: #1b1f2b;
    --surface-2: #232838;
    --surface-3: #2e3446;
    --line: #363c52;
    --line-subtle: #262b3a;
    --accent-key: #8b93e8;
    --accent-key-hover: #a8afef;
    --accent-key-soft: #262c4a;
    --accent-gap: #b592e0;
    --accent-gap-hover: #c9adf0;
    --accent-gap-soft: #322a47;
    --accent-alert: #e2727f;
    --accent-alert-soft: #3a1f26;
  }
}

html[data-theme="dark"] body.compare-page {
  --ink: #dde1ee;
  --ink-soft: #a8b0c8;
  --ink-faint: #7d859c;
  --paper: #12141c;
  --surface: #1b1f2b;
  --surface-2: #232838;
  --surface-3: #2e3446;
  --line: #363c52;
  --line-subtle: #262b3a;
  --accent-key: #8b93e8;
  --accent-key-hover: #a8afef;
  --accent-key-soft: #262c4a;
  --accent-gap: #b592e0;
  --accent-gap-hover: #c9adf0;
  --accent-gap-soft: #322a47;
  --accent-alert: #e2727f;
  --accent-alert-soft: #3a1f26;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ---------- site nav ---------- */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.site-nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

@media (max-width: 680px) {
  .site-nav-inner { padding: 10px 16px; }
}

.site-nav-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 9px;
  letter-spacing: 0.02em;
}

.site-nav-brand .mark {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-key);
  display: inline-block;
  box-shadow: 0 0 0 2px var(--accent-key-soft);
}

.site-nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.88rem;
}

.site-nav-links a {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 5px 12px;
  border-radius: 999px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.site-nav-links a:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.site-nav-links a[aria-current="page"] {
  color: var(--accent-key);
  background: var(--accent-key-soft);
  font-weight: 600;
}

.theme-toggle-btn {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: 6px;
  transition: all 0.15s ease;
}

.theme-toggle-btn:hover {
  color: var(--ink);
  border-color: var(--accent-key);
  background: var(--surface);
}

/* ---------- page layout ---------- */

.page {
  max-width: var(--page-max, 960px);
  margin: 0 auto;
  padding: 48px 24px 80px;
}

@media (max-width: 600px) {
  .page { padding: 28px 16px 60px; }
}

/* ---------- headers & typography ---------- */

.masthead, .hero {
  max-width: 800px;
  margin-bottom: 28px;
}

.eyebrow-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-key);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 500;
}

.eyebrow.is-gap { color: var(--accent-gap); }
.eyebrow.is-gap::before { background: var(--accent-gap); }

.eyebrow::before {
  content: '';
  width: 18px;
  height: 2px;
  background: var(--accent-key);
  display: inline-block;
}

.kind-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
}

h1.title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.85rem, 4.5vw, 2.5rem);
  line-height: 1.35;
  margin: 12px 0 12px;
  text-wrap: balance;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.dek {
  font-size: 1.05rem;
  color: var(--ink-soft);
  max-width: 68ch;
  line-height: 1.75;
  margin: 0 0 10px;
}

.source-link {
  font-size: 0.86rem;
  color: var(--ink-faint);
  margin: 8px 0 0;
}

.source-link a {
  color: var(--accent-key);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

/* ---------- dossier summary box ---------- */

.dossier {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 18px 22px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 18px;
  font-size: 0.86rem;
  margin-top: 24px;
}

@media (max-width: 760px) {
  .dossier { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 460px) {
  .dossier { grid-template-columns: 1fr; }
}

.dossier dt {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 3px;
}

.dossier dd {
  margin: 0;
  color: var(--ink);
  font-weight: 500;
}

.dossier a {
  color: var(--accent-key);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

/* ---------- stat strips ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(var(--stat-cols, 4), 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  margin: 28px 0 10px;
  box-shadow: var(--shadow-sm);
}

@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 440px) {
  .stats { grid-template-columns: 1fr; }
}

.stat {
  background: var(--surface);
  padding: 16px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--accent-key);
  line-height: 1.2;
}

.stat .label {
  font-size: 0.76rem;
  color: var(--ink-soft);
  margin-top: 6px;
  line-height: 1.45;
}

.verify-note {
  font-size: 0.78rem;
  color: var(--ink-faint);
  text-align: right;
  margin: 8px 4px 0;
  font-family: var(--font-mono);
}

/* ---------- Table of Contents (TOC) ---------- */

nav.toc {
  margin: 32px 0 12px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

nav.toc .toc-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 8px;
  font-weight: 600;
}

nav.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

nav.toc.toc-columns ol {
  display: block;
  columns: 2;
  column-gap: 24px;
}

@media (max-width: 600px) {
  nav.toc.toc-columns ol { columns: 1; }
}

nav.toc li {
  break-inside: avoid;
  margin-bottom: 6px;
}

nav.toc a {
  color: var(--ink);
  text-decoration: none;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  transition: color 0.15s ease;
}

nav.toc a:hover {
  color: var(--accent-key);
}

nav.toc .n {
  font-family: var(--font-mono);
  color: var(--accent-key);
  font-size: 0.78rem;
  font-weight: 600;
  flex: none;
}

/* ---------- body copy & section styling ---------- */

main { margin-top: 16px; }
section { margin-top: 48px; }

.sec-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.sec-num {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--accent-key);
  line-height: 1;
  flex: none;
  font-weight: 700;
}

h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1.45;
  margin: 0;
  text-wrap: balance;
  color: var(--ink);
}

.sec-note {
  font-size: 0.88rem;
  color: var(--ink-faint);
  margin: 0 0 20px;
}

h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  margin: 26px 0 10px;
  color: var(--ink);
}

p {
  margin: 0 0 16px;
  font-size: 0.98rem;
  color: var(--ink);
}

strong {
  color: var(--ink);
  font-weight: 600;
}

ul.plain, ol.plain {
  margin: 0 0 18px;
  padding-left: 1.25em;
}

ul.plain li, ol.plain li {
  margin-bottom: 10px;
  font-size: 0.95rem;
}

cite {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 0.82em;
  color: var(--ink-soft);
  background: var(--surface-2);
  border: 1px solid var(--line-subtle);
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}

cite.verified::before {
  content: '✓ ';
  color: var(--accent-key);
  font-weight: bold;
}

.tag {
  display: inline-block;
  font-size: 0.76em;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.tag-key { background: var(--accent-key-soft); color: var(--accent-key); }
.tag-gap { background: var(--accent-gap-soft); color: var(--accent-gap); }
.tag-alert { background: var(--accent-alert-soft); color: var(--accent-alert); }

/* ---------- callout boxes ---------- */

.callout {
  border-left: 4px solid var(--accent-gap);
  background: var(--accent-gap-soft);
  padding: 16px 20px;
  border-radius: 0 10px 10px 0;
  margin: 24px 0;
  font-size: 0.96rem;
}

.callout.key {
  border-left-color: var(--accent-key);
  background: var(--accent-key-soft);
}

.callout p:last-child { margin-bottom: 0; }

.callout .callout-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-gap);
  margin-bottom: 6px;
  font-weight: 600;
}

.callout.key .callout-label { color: var(--accent-key); }

/* ---------- interactive tables ---------- */

.fig-table {
  width: 100%;
  overflow-x: auto;
  margin: 12px 0 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 460px;
}

thead th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  position: sticky;
  top: 0;
  z-index: 2;
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

td.num, th.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

td.tag-new {
  color: var(--accent-gap);
  font-weight: 600;
}

table.budget { min-width: 480px; }
table.budget td.amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--accent-key);
  font-weight: 600;
  white-space: nowrap;
  text-align: right;
}

details.data-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 12px 0 24px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

details.data-block > summary {
  cursor: pointer;
  padding: 14px 18px;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  color: var(--ink-soft);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
  font-weight: 500;
}

details.data-block > summary::-webkit-details-marker { display: none; }
details.data-block > summary::before {
  content: '▸';
  color: var(--accent-key);
  transition: transform 0.15s ease;
  font-size: 1rem;
}

details.data-block[open] > summary::before {
  transform: rotate(90deg);
}

details.data-block > summary .count {
  margin-left: auto;
  font-size: 0.76rem;
  color: var(--ink-faint);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 999px;
}

details.data-block .data-body { padding: 0 18px 18px; }
details.data-block .fig-table { border: none; border-top: 1px solid var(--line); border-radius: 0; margin: 0; box-shadow: none; }

/* ---------- hierarchy diagram (央地位階互動圖) ---------- */
.hierarchy-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  margin: 32px 0 12px;
}

.tier-node {
  display: block;
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 24px;
  text-align: center;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.tier-node:hover,
.tier-node:focus-visible {
  box-shadow: var(--shadow);
  border-color: var(--accent-key);
  transform: translateY(-2px);
}

.tier-tag {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-key);
  margin-bottom: 4px;
}

.tier-name {
  display: block;
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--ink);
}

.tier-node .tier-sub {
  display: block;
  font-size: 0.82rem;
  color: var(--ink-faint);
  margin-top: 3px;
}

.tier-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0;
}

.tier-link .arrow {
  font-size: 1.1rem;
  line-height: 1;
  color: var(--ink-faint);
}

.link-status {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.link-status.ok { background: var(--accent-key-soft); color: var(--accent-key); }
.link-status.gap { background: var(--accent-alert-soft); color: var(--accent-alert); }
.link-status.warn { background: var(--accent-gap-soft); color: var(--accent-gap); }

.tier-branch {
  display: flex;
  gap: 20px;
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 900px;
}

.tier-branch .branch-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 260px;
  max-width: 420px;
}

.diagram-hint {
  text-align: center;
  font-size: 0.82rem;
  color: var(--ink-faint);
  margin: 0 0 8px;
}

.tier-detail {
  scroll-margin-top: 96px;
  transition: box-shadow 0.4s ease, border-color 0.4s ease;
  border-radius: 12px;
}

.tier-detail.flash {
  box-shadow: 0 0 0 3px var(--accent-key-soft);
  border-color: var(--accent-key);
}

@media (max-width: 640px) {
  .tier-branch { flex-direction: column; align-items: center; }
}

/* ---------- filter bars & search controls ---------- */

.filter-toolbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 18px;
  margin: 16px 0 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-label {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.filter-select, .filter-input {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.84rem;
  color: var(--ink);
  font-family: inherit;
  outline: none;
}

.filter-select:focus, .filter-input:focus {
  border-color: var(--accent-key);
}

.filter-reset-btn {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.8rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-mono);
}

.filter-reset-btn:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.filter-count-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent-key);
  font-weight: 500;
}

/* ---------- chips & score bars ---------- */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 16px;
}

.chip {
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  border: 1px solid var(--line-subtle);
}

.chip.hi {
  background: var(--accent-gap-soft);
  color: var(--accent-gap);
  border-color: rgba(163, 83, 27, 0.2);
  font-weight: 500;
}

.score-bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 50px;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 0.9rem;
}

@media (max-width: 480px) {
  .score-bar-row {
    grid-template-columns: 110px 1fr 40px;
    font-size: 0.82rem;
  }
}

.score-bar-track {
  background: var(--surface-2);
  border-radius: 5px;
  height: 12px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 5px;
  background: var(--accent-key);
}

.score-bar-fill.sec {
  background: var(--accent-gap);
}

.score-bar-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--ink);
  font-weight: 600;
}

/* ---------- District Inspector UI ---------- */

.district-inspector-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  margin: 20px 0 28px;
}

.district-pill-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px;
}

.district-pill {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.84rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s ease;
}

.district-pill:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.district-pill.active {
  background: var(--accent-key-soft);
  color: var(--accent-key);
  border-color: var(--accent-key);
  font-weight: 600;
}

.district-card-content {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  margin-top: 12px;
}

.district-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.district-name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
}

.district-risk-desc {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.7;
}

/* ---------- verdict scoreboard / columns ---------- */

.scoreboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  margin: 32px 0 12px;
  box-shadow: var(--shadow-sm);
}

@media (max-width: 620px) {
  .scoreboard { grid-template-columns: 1fr; }
}

.score-cell {
  background: var(--surface);
  padding: 20px 22px;
}

.score-cell .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.1;
}

.score-cell.good .num { color: var(--accent-key); }
.score-cell.bad .num { color: var(--accent-gap); }

.score-cell .label {
  font-size: 0.84rem;
  color: var(--ink-soft);
  margin-top: 6px;
  line-height: 1.5;
}

.verdict-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 44px;
  align-items: start;
}

@media (max-width: 760px) {
  .verdict-columns { grid-template-columns: 1fr; gap: 36px; }
}

.col-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--line);
}

.col-head .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: none;
}

.col-good .col-head .dot { background: var(--accent-key); }
.col-bad .col-head .dot { background: var(--accent-gap); }

.col-head h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  margin: 0;
}

.col-good .col-head h2 { color: var(--accent-key); }
.col-bad .col-head h2 { color: var(--accent-gap); }

.verdict-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  margin-bottom: 16px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.verdict-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.verdict-card .card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.verdict-card .idx {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  font-weight: 600;
}

.verdict-card h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 10px;
  line-height: 1.5;
  color: var(--ink);
}

.verdict-card p {
  margin: 0;
  font-size: 0.94rem;
  color: var(--ink);
  line-height: 1.75;
}

.final-verdict {
  margin-top: 48px;
  padding: 28px 30px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  position: relative;
}

.final-verdict::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20px;
  bottom: 20px;
  width: 5px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--accent-key), var(--accent-gap));
}

.final-verdict .fv-label {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 10px;
  font-weight: 600;
}

.final-verdict p {
  font-family: var(--font-display);
  font-size: 1.22rem;
  line-height: 1.7;
  margin: 0;
  text-wrap: balance;
  color: var(--ink);
}

/* ---------- agency action cards ---------- */

.action-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 28px;
}

.action-filter-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.84rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-filter-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.action-filter-btn.active {
  background: var(--accent-key);
  color: #ffffff;
  border-color: var(--accent-key);
  font-weight: 600;
}

.agency {
  margin-top: 36px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.agency-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface-2);
}

.agency-head h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  margin: 0;
  color: var(--ink);
}

.agency-head .role {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--accent-key);
  background: var(--accent-key-soft);
  padding: 3px 12px;
  border-radius: 999px;
  white-space: nowrap;
  font-weight: 500;
}

.rec-list {
  padding: 6px 24px 20px;
}

.rec {
  padding: 18px 0;
  border-bottom: 1px solid var(--line-subtle);
}

.rec:last-child { border-bottom: none; }

.rec-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.rec-num {
  font-family: var(--font-mono);
  color: var(--accent-key);
  font-size: 0.85rem;
  flex: none;
  font-weight: 600;
}

.rec-priority {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 4px;
  font-weight: 600;
}

.rec-priority.p1 { background: var(--accent-alert-soft); color: var(--accent-alert); }
.rec-priority.p2 { background: var(--accent-gap-soft); color: var(--accent-gap); }
.rec-priority.p3 { background: var(--accent-key-soft); color: var(--accent-key); }

.rec h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.5;
  color: var(--ink);
}

.rec p {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--ink);
  line-height: 1.75;
}

.rec-meta-box {
  background: var(--paper);
  border: 1px solid var(--line-subtle);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.82rem;
  color: var(--ink-soft);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 6px 12px;
  margin-top: 8px;
}

/* ---------- home page cards & sections ---------- */

.key-findings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin: 28px 0 40px;
}

@media (max-width: 700px) {
  .key-findings-grid { grid-template-columns: 1fr; }
}

.finding-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}

.finding-card .fc-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-gap);
  font-weight: 600;
  margin-bottom: 6px;
}

.finding-card h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--ink);
}

.finding-card p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-soft);
  line-height: 1.65;
}

.nav-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 36px;
}

@media (max-width: 680px) {
  .nav-cards { grid-template-columns: 1fr; }
}

.nav-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 24px 26px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.nav-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-key);
  box-shadow: var(--shadow);
}

.nav-card .nc-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-key);
  margin: 0 0 6px;
  font-weight: 600;
}

.nav-card.gap .nc-eyebrow { color: var(--accent-gap); }

.nav-card h2 {
  font-family: var(--font-display);
  font-size: 1.28rem;
  margin: 0 0 10px;
  color: var(--ink);
}

.nav-card p {
  font-size: 0.93rem;
  color: var(--ink-soft);
  margin: 0 0 16px;
  line-height: 1.65;
}

.nav-card .nc-go {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  color: var(--accent-key);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.nav-card.gap .nc-go { color: var(--accent-gap); }

/* ---------- Reading Path Cards (首頁導讀路徑) ---------- */

.reading-pathways {
  margin: 40px 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
}

.reading-pathways h3 {
  margin-top: 0;
  font-size: 1.1rem;
}

.pathways-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 14px;
}

@media (max-width: 760px) {
  .pathways-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 440px) {
  .pathways-grid { grid-template-columns: 1fr; }
}

.path-item {
  background: var(--paper);
  border: 1px solid var(--line-subtle);
  border-radius: 8px;
  padding: 12px 14px;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s ease;
}

.path-item:hover {
  background: var(--surface-2);
  border-color: var(--accent-key);
}

.path-role {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent-key);
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}

.path-title {
  font-weight: 600;
  font-size: 0.88rem;
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

.path-desc {
  font-size: 0.78rem;
  color: var(--ink-soft);
  line-height: 1.4;
  margin: 0;
}

/* ---------- chapter / pagination footer ---------- */

.chapter-nav {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 540px) {
  .chapter-nav { grid-template-columns: 1fr; }
}

.chapter-btn {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 18px;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s ease;
}

.chapter-btn:hover {
  border-color: var(--accent-key);
  background: var(--surface-2);
}

.chapter-btn.next { text-align: right; margin-left: auto; width: 100%; }

.chapter-dir {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 2px;
}

.chapter-title {
  font-family: var(--font-display);
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--accent-key);
}

/* ---------- back to top button ---------- */

.back-to-top-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 90;
}

.back-to-top-btn.visible {
  opacity: 1;
  pointer-events: auto;
}

.back-to-top-btn:hover {
  background: var(--accent-key);
  color: #ffffff;
  border-color: var(--accent-key);
  transform: translateY(-2px);
}

/* ---------- site footer ---------- */

hr.div {
  border: none;
  border-top: 1px solid var(--line);
  margin: 48px 0 0;
}

footer.site-footer {
  margin-top: 48px;
  padding: 24px 0 0;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  line-height: 1.7;
}

footer.site-footer a {
  color: var(--ink-soft);
  text-decoration: underline;
}

footer.site-footer a:hover {
  color: var(--accent-key);
}

a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent-key);
  outline-offset: 2px;
}

::selection {
  background: var(--accent-key-soft);
  color: var(--ink);
}
