:root {
  --bg:#fbfaf8; --card:#ffffff; --ink:#1b1b1b; --title:#0e2f3a;
  --brand:#0e4d64; --brand-hover:#13718f; --accent:#f0b350;
  /* accent-ink：淺底上的琥珀「文字」用色。#f0b350 在白底只有 1.86:1 對比，
     文字一律用這個深琥珀（5.0:1）；#f0b350 保留給深色橫幅上的字與裝飾 */
  --accent-ink:#96650a;
  --line:#e6e2da; --muted:#646f79;
  --radius:12px; --radius-sm:8px;
  --shadow:0 1px 3px rgba(14,47,58,.08); --shadow-hover:0 6px 18px rgba(14,47,58,.14);
  --font:"Noto Sans TC",system-ui,sans-serif;
}
[data-theme="dark"] {
  --bg:#0c171c; --card:#12222a; --ink:#d8dee2; --title:#e8eef1;
  --brand:#7fc4dd; --brand-hover:#a5d8ea; --accent:#f0b350;
  --accent-ink:#f0b350; /* 深底上原琥珀就有 8.7:1，不必變暗 */
  --line:#1e333d; --muted:#8fa0aa;
  --shadow:0 1px 3px rgba(0,0,0,.35); --shadow-hover:0 6px 18px rgba(0,0,0,.5);
}

/* ============ reset ============ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* overflow-x 安全網用 clip 不用 hidden：hidden 會把 html/body 變成捲動容器，
   殺死子孫的 position:sticky（本頁目錄）；clip 只裁切、不建立捲動容器 */
html { overflow-x: hidden; overflow-x: clip; }
/* 關掉行動瀏覽器的字體自動放大（font boosting）：寬表格橫向捲動區
   會被強制放大字體，看起來比內文大 */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  /* safety net: any unforeseen wide element (table, mermaid svg, long code
     line, etc.) should scroll within itself, not blow out the whole page
     and push it past the mobile media-query breakpoints.
     clip 不用 hidden — hidden 會建立捲動容器、殺死 position:sticky */
  overflow-x: hidden;
  overflow-x: clip;
  width: 100%;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }
img { max-width: 100%; }
.tabular { font-variant-numeric: tabular-nums; }
strong, b, .stat-pill strong, .entry-card .t, .chip strong { font-variant-numeric: tabular-nums; }

/* ============ layout shell ============ */
.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.4rem;
}

/* ============ top bar ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0.65rem 1.4rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 900;
  color: var(--title);
  font-size: 1.05rem;
  white-space: nowrap;
}
.brand .logo {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #0e2f3a, #0e4d64);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.95rem;
}

.navlinks {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: 1;
}
.navlinks a {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.navlinks a:hover {
  color: var(--title);
  background: rgba(14, 77, 100, 0.07);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.search-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  color: var(--muted);
  font-size: 0.84rem;
  min-width: 200px;
}
.search-box input {
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font);
  font-size: 0.86rem;
  color: var(--ink);
  flex: 1;
  min-width: 0;
}
.search-box kbd {
  font-family: monospace;
  font-size: 0.68rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 5px;
  color: var(--muted);
}

/* ============ search: kind badges (shared by dropdown + overlay) ============ */
.kind-badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  font-size: 0.66rem;
  font-weight: 700;
}
.kind-badge.k-company { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); }
.kind-badge.k-tech { background: color-mix(in srgb, #2f9e8f 16%, transparent); color: #2f9e8f; }
.kind-badge.k-supply { background: color-mix(in srgb, #35a06a 16%, transparent); color: #35a06a; }
.kind-badge.k-analyze { background: color-mix(in srgb, #c2447a 16%, transparent); color: #c2447a; }
.kind-badge.k-schedule { background: color-mix(in srgb, #f0b350 25%, transparent); color: #9a6b16; }
.kind-badge.k-report { background: color-mix(in srgb, #2b7fd1 16%, transparent); color: #2b7fd1; }
.kind-badge.k-db { background: color-mix(in srgb, #7a8a90 20%, transparent); color: #5c6a70; }
[data-theme="dark"] .kind-badge.k-company { background: color-mix(in srgb, var(--brand) 22%, transparent); color: var(--brand); }
[data-theme="dark"] .kind-badge.k-tech { background: color-mix(in srgb, #5fc2cf 22%, transparent); color: #5fc2cf; }
[data-theme="dark"] .kind-badge.k-supply { background: color-mix(in srgb, #5fcf98 22%, transparent); color: #5fcf98; }
[data-theme="dark"] .kind-badge.k-analyze { background: color-mix(in srgb, #e07aa8 22%, transparent); color: #e07aa8; }
[data-theme="dark"] .kind-badge.k-schedule { background: color-mix(in srgb, #f0b350 28%, transparent); color: #f0b350; }
[data-theme="dark"] .kind-badge.k-report { background: color-mix(in srgb, #5b9fe0 22%, transparent); color: #5b9fe0; }
[data-theme="dark"] .kind-badge.k-db { background: color-mix(in srgb, #9fb0b8 22%, transparent); color: #9fb0b8; }

/* ============ search: instant-suggest dropdown ============ */
.search-suggest {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 60;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-hover);
  max-height: 70vh;
  overflow-y: auto;
  padding: 0.3rem;
}
.search-suggest-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--ink);
}
.search-suggest-row:hover,
.search-suggest-row.active {
  background: color-mix(in srgb, var(--brand) 10%, transparent);
}
.search-suggest-row .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-suggest-row .code {
  flex: 0 0 auto;
  color: var(--accent-ink);
  font-family: "SFMono-Regular", ui-monospace, Menlo, monospace;
  font-size: 0.72rem;
  font-weight: 700;
}
.search-suggest-row .updated {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.68rem;
}
.search-suggest-row.search-suggest-fulltext {
  margin-top: 0.2rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line);
  color: var(--brand);
  font-weight: 700;
}
[data-theme="dark"] .search-suggest-row.search-suggest-fulltext { color: var(--brand-hover); }
.search-suggest-empty {
  padding: 0.55rem 0.6rem;
  color: var(--muted);
  font-size: 0.8rem;
}

/* ============ search: full-text overlay ============ */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 1rem;
  background: rgba(10, 18, 22, 0.5);
}
.search-overlay[hidden] { display: none; }
.search-overlay-panel {
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  overflow: hidden;
}
.search-overlay-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}
.search-overlay-head input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  background: var(--card);
  color: var(--ink);
  font-family: var(--font);
  font-size: 0.88rem;
  outline: none;
}
.search-overlay-head input:focus { border-color: var(--brand-hover); }
.search-overlay-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
}
.search-overlay-close:hover { color: var(--brand-hover); background: color-mix(in srgb, var(--brand) 8%, transparent); }
.search-overlay-body {
  overflow-y: auto;
  padding: 0.4rem 0.9rem 1.1rem;
}
.search-overlay-meta {
  color: var(--muted);
  font-size: 0.78rem;
  padding: 0.5rem 0 0.6rem;
}
.search-result {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}
.search-result:last-child { border-bottom: none; }
.search-result .row-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}
.search-result .row-title a {
  color: var(--title);
  font-weight: 700;
  font-size: 0.88rem;
}
.search-result .row-title a:hover { color: var(--brand-hover); }
.search-result .snippet {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.55;
}
.search-result .snippet mark {
  background: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--ink);
  padding: 0 2px;
  border-radius: 2px;
}
.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--ink);
  flex: 0 0 auto;
}
.icon-btn:hover { border-color: var(--brand-hover); color: var(--brand-hover); }

.hamburger {
  display: none;
  cursor: pointer;
}
/* checkbox 不能 display:none — 會被踢出 tab 順序，鍵盤使用者就打不開
   手機選單；改成視覺隱藏但可聚焦，space 鍵可切換 */
#nav-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
#nav-toggle:focus-visible ~ .topbar-inner .hamburger {
  outline: 2px solid var(--brand-hover);
  outline-offset: 2px;
}

/* ============ breadcrumb ============ */
.breadcrumb {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0.85rem 1.4rem 0;
  font-size: 0.82rem;
  color: var(--muted);
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--brand-hover); }
.breadcrumb .sep { margin: 0 0.35rem; }
.breadcrumb:empty { display: none; }

/* ============ main / footer ============ */
main.container {
  padding-top: 1.4rem;
  padding-bottom: 3rem;
  min-height: 60vh;
}
.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.4rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
}

/* ============ section title ============ */
.section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 2.1rem 0 0.9rem;
  color: var(--title);
  font-size: 1.05rem;
  font-weight: 700;
}
.section-title::before {
  content: "";
  width: 4px;
  height: 1.1em;
  background: var(--accent);
  border-radius: 999px;
}
.section-title:first-child { margin-top: 0; }

/* ============ hero ============ */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  padding: 2rem 2.2rem;
  background: linear-gradient(135deg, #0e2f3a, #0e4d64);
  box-shadow: var(--shadow-hover);
}
.hero .kicker {
  margin: 0;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.hero h1 {
  margin: 0.35rem 0 0;
  color: #fff;
  font-size: 1.9rem;
  line-height: 1.25;
}
.hero p.sub {
  max-width: 40rem;
  margin: 0.6rem 0 0;
  color: rgba(238, 244, 244, 0.8);
  font-size: 0.95rem;
}
.stat-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.3rem;
}
.stat-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(12, 23, 28, 0.5);
}
.stat-pill strong {
  color: var(--accent);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}
.stat-pill span {
  color: #aebcc0;
  font-size: 0.78rem;
}

/* ============ quick entry grid ============ */
.entry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  gap: 0.6rem;
}
.entry-card {
  display: block;
  padding: 0.7rem 0.75rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.15s;
}
.entry-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand-hover);
}
.entry-card .ic {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-bottom: 0.45rem;
  border-radius: var(--radius-sm);
  background: rgba(14, 77, 100, 0.08);
  color: var(--accent-ink);
  font-size: 1rem;
}
.entry-card .ic svg { width: 16px; height: 16px; }
.entry-card .t {
  display: block;
  color: var(--title);
  font-weight: 700;
  font-size: 0.92rem;
}
.entry-card .d {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

/* ============ recent chips ============ */
.recent-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.84rem;
  color: var(--ink);
}
.chip:hover { border-color: var(--brand-hover); color: var(--brand-hover); }
.chip .date {
  color: var(--muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

/* ============ report cards ============ */
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.9rem;
}
.report-card {
  display: block;
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.15s;
}
.report-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand-hover);
}
.report-card .t {
  display: block;
  color: var(--title);
  font-weight: 700;
  font-size: 0.94rem;
  line-height: 1.4;
}
.report-card .d {
  display: block;
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
}
.report-card .date {
  display: block;
  margin-top: 0.65rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}
/* /reports/ 列表：一橫排一份、橫向小卡（標題左、日期右） */
.report-rows { display: flex; flex-direction: column; gap: 0.4rem; }
.report-row {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  padding: 0.5rem 0.75rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s;
}
.report-row:hover { border-color: var(--accent); }
.report-row .t {
  flex: 1;
  min-width: 0;
  color: var(--title);
  font-weight: 700;
  font-size: 0.88rem;
  line-height: 1.45;
}
.report-row .date {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.74rem;
}

/* ============ list pages (company/tech/supply/analyze/schedule) ============ */
.list-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.list-title {
  margin: 0;
  color: var(--title);
  font-size: 1.45rem;
}
.list-count {
  color: var(--muted);
  font-size: 0.82rem;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.9rem;
}
.pill {
  font-family: var(--font);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.38rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s, color 0.15s, background 0.15s;
}
.pill:hover { border-color: var(--brand-hover); color: var(--brand-hover); }
.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #211405;
}

.list-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.9rem;
  color: var(--muted);
  margin-bottom: 1.2rem;
  max-width: 26rem;
}
.list-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font);
  font-size: 0.88rem;
  color: var(--ink);
}

.list-group + .list-group { margin-top: 1.6rem; }
.group-title {
  margin: 0 0 0.7rem;
  color: var(--title);
  font-size: 0.92rem;
  font-weight: 700;
  padding-left: 0.6rem;
  border-left: 3px solid var(--accent);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.7rem;
}
.list-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.9rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  min-width: 0;
}
.list-card[hidden],
.list-group[hidden] { display: none; }
/* 短名稱區（公司/技術/供應鏈/時程）：高密度小卡，代碼放大在前（認數字找股票）。
   multi-column 直向排序：上到下、再左到右，欄數由瀏覽器依寬度自動平衡 */
.card-grid.compact {
  display: block;
  columns: 146px;
  column-gap: 0.4rem;
}
.card-grid.compact .list-card {
  break-inside: avoid;
  margin-bottom: 0.4rem;
  padding: 0.4rem 0.55rem;
  gap: 0.05rem;
}
.group-divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0.5rem 0 0.9rem;
}
.card-grid.compact .list-card .name { font-size: 0.83rem; gap: 0.32rem; }
.card-grid.compact .list-card .name .code { font-size: 0.95rem; }
.card-grid.compact .list-card .sector { font-size: 0.65rem; }
/* 長名稱區（分析）：一排兩張、名稱換行 */
.card-grid.two {
  grid-template-columns: repeat(2, 1fr);
  gap: 0.55rem;
}
.card-grid.two .list-card { padding: 0.6rem 0.8rem; gap: 0.2rem; }
.card-grid.two .list-card .name {
  white-space: normal;
  font-size: 0.88rem;
  line-height: 1.4;
}
.list-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-hover);
}
.list-card .name {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  color: var(--title);
  font-weight: 700;
  font-size: 0.94rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-card .name .code {
  flex: 0 0 auto;
  color: var(--accent-ink);
  font-family: "SFMono-Regular", ui-monospace, Menlo, monospace;
  font-size: 0.72rem;
  font-weight: 700;
}
.list-card .sector {
  color: var(--muted);
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-card .updated {
  margin-top: auto;
  padding-top: 0.15rem;
  color: var(--muted);
  font-size: 0.72rem;
}
.ext-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 2.2rem;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--brand);
  font-family: "SFMono-Regular", ui-monospace, Menlo, monospace;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
}
[data-theme="dark"] .ext-badge { color: var(--accent); }
.list-empty {
  color: var(--muted);
  font-size: 0.88rem;
  padding: 1.5rem 0;
}

/* ============ generic page (fallback) ============ */
.page-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem 1.6rem;
  box-shadow: var(--shadow);
}
.backlinks {
  margin-top: 2rem;
}
.backlinks h2 {
  font-size: 1rem;
  color: var(--title);
}

/* ============ content page (company / tech / supply / analyze / schedule) ============ */
.content-hero {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  margin-bottom: 1.2rem;
}
.hero-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
}
.hero-title {
  margin: 0;
  color: var(--title);
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1.3;
}
.content-hero-simple .hero-title { font-size: 1.3rem; }
.hero-code {
  color: var(--accent-ink);
  font-family: "SFMono-Regular", ui-monospace, Menlo, monospace;
  font-size: 1.15rem;
  font-weight: 700;
}
.pill.market-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(14, 77, 100, 0.1);
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 700;
}
[data-theme="dark"] .pill.market-pill {
  background: rgba(127, 196, 221, 0.14);
}
.hero-updated {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.78rem;
}
.hero-sector {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}
.hero-actions { margin-top: 0.75rem; }
.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: var(--accent);
  color: #211405;
  font-size: 0.85rem;
  font-weight: 700;
}
.btn-download:hover { background: var(--brand-hover); color: #fff; }
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
}
.chip-row:first-of-type { margin-top: 0.75rem; }
.tag-chip {
  color: var(--brand);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.related-chip.topic-chip {
  color: var(--muted);
}

/* hero/backlinks chips: body-text scale, not the bigger home-page chip */
.content-hero .chip,
.backlinks .chip {
  padding: 0.1rem 0.5rem;
  font-size: 0.8rem;
}

/* related-meta: Wikipedia-infobox-style rows, one per target kind
   (相關公司/技術/供應鏈/分析/報告/時程/其他), used both in the hero and
   in the 被誰引用 backlinks section. */
.related-meta {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0.75rem 0 0;
}
.related-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0;
}
.related-meta-row dt {
  flex: 0 0 auto;
  min-width: 4.4rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}
/* hero related-meta collapse: on mobile the 相關公司/技術/供應鏈/分析/...
   chip groups can push the whole hero past the first screen before any
   real body content appears. Cap it and offer a plain checkbox-driven
   "展開全部" toggle (no JS needed). Desktop is unaffected. */
.hero-expand-toggle { position: absolute; opacity: 0; pointer-events: none; }
.hero-expand-btn { display: none; }
@media (max-width: 768px) {
  .hero-related-wrap {
    position: relative;
    max-height: 9.5rem;
    overflow: hidden;
  }
  .hero-related-wrap::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2.4rem;
    background: linear-gradient(to bottom, transparent, var(--card));
    pointer-events: none;
  }
  .hero-expand-toggle:checked ~ .hero-related-wrap {
    max-height: none;
  }
  .hero-expand-toggle:checked ~ .hero-related-wrap::after { display: none; }
  .hero-expand-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 0.6rem;
    padding: 0.6rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg);
    color: var(--brand);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    min-height: 40px;
  }
  .hero-expand-btn .show-less { display: none; }
  .hero-expand-toggle:checked ~ .hero-expand-btn .show-more { display: none; }
  .hero-expand-toggle:checked ~ .hero-expand-btn .show-less { display: inline; }
}
.related-meta-row dd {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.backlinks .related-meta { margin-top: 0.8rem; }

/* main column + sticky TOC */
.content-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 2rem;
  align-items: start;
}
.page-body {
  max-width: 52rem;
  min-width: 0;
  font-size: 0.95rem;
  line-height: 1.75;
}
.page-body > *:first-child { margin-top: 0; }
.page-body p { margin: 0.8rem 0; }
.page-body ul, .page-body ol { margin: 0.8rem 0; padding-left: 1.4rem; }
.page-body li { margin: 0.3rem 0; }
.page-body hr { border: none; border-top: 1px solid var(--line); margin: 2rem 0; }
.page-body strong { color: var(--title); }
.page-body code {
  background: color-mix(in srgb, var(--line) 55%, transparent);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: "SFMono-Regular", ui-monospace, Menlo, monospace;
}
.page-body pre {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  overflow-x: auto;
}
.page-body pre code { background: none; padding: 0; }
.page-body .mermaid {
  margin: 1.2rem auto;
  text-align: center;
  overflow-x: auto;
}
.page-body .mermaid svg { max-width: 100%; height: auto; }
.page-body blockquote {
  margin: 0.4rem 0 1.2rem;
  padding: 0.5rem 0.9rem;
  border-left: 3px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}

/* h2/h3 section titles: amber left border like .section-title */
.page-body h2 {
  margin: 1.65rem 0 0.75rem;
  padding-left: 0.65rem;
  border-left: 4px solid var(--accent);
  color: var(--title);
  font-size: 1.15rem;
  line-height: 1.4;
}
.page-body h3 {
  margin: 1.2rem 0 0.55rem;
  color: var(--title);
  font-size: 1rem;
}
/* Defensive: a handful of source pages contain inline "#1 foo｜#2 bar" ranking
   text that python-markdown's legacy ATX parser (no required space after #)
   misreads as a genuine mid-document <h1>. build.py only strips the leading
   hero-duplicate <h1>; any further stray <h1> is styled like <h2> here so it
   doesn't render as an oversized second title. */
.page-body h1 {
  margin: 1.65rem 0 0.75rem;
  padding-left: 0.65rem;
  border-left: 4px solid var(--accent);
  color: var(--title);
  font-size: 1.15rem;
  line-height: 1.4;
}

/* tables: zebra + tabular-nums */
.page-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.1rem 0;
  font-size: inherit; /* 與內文同字級 */
}
.page-body th, .page-body td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-variant-numeric: tabular-nums;
}
.page-body thead th {
  color: var(--title);
  font-weight: 700;
  border-bottom: 2px solid var(--line);
}
.page-body tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--line) 35%, transparent);
}

/* figures / embeds / wikilinks */
.page-body figure.fig {
  margin: 1.3rem auto;
  max-width: 100%;
  text-align: center;
}
.page-body figure.fig img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  cursor: zoom-in;
}
.page-body .pdf-embed { margin: 1.2rem 0; }
.page-body .pdf-embed iframe {
  width: 100%;
  height: 80vh;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.page-body a.wl {
  color: var(--brand);
  border-bottom: 1px dashed color-mix(in srgb, var(--brand) 50%, transparent);
}
.page-body a.wl:hover { color: var(--brand-hover); }
.page-body .wl-broken {
  color: var(--muted);
  border-bottom: 1px dashed var(--muted);
  cursor: not-allowed;
}
.page-body .embed-link { margin: 0.6rem 0; }

/* callouts: 7 types, teal-ink base + distinct accent colors */
.callout {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 1.1rem 0;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  border-left: 4px solid var(--co-color, var(--accent));
  background: color-mix(in srgb, var(--co-color, var(--accent)) 8%, var(--card));
}
.callout .co-title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--co-color, var(--accent));
  font-weight: 700;
  font-size: 0.92rem;
}
.callout .co-title::before {
  content: "";
  flex: 0 0 auto;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--co-color, var(--accent));
}
.callout .co-body { margin: 0; font-size: 0.92rem; color: var(--ink); }
.callout .co-body > *:first-child { margin-top: 0; }
.callout .co-body > *:last-child { margin-bottom: 0; }

.co-warning { --co-color: #f0b350; }
.co-note { --co-color: #2f9e8f; }
.co-tip { --co-color: #35a06a; }
.co-info { --co-color: #2b7fd1; }
.co-todo { --co-color: #7a8a90; }
.co-important { --co-color: #c2447a; }
.co-quote { --co-color: #8a97a0; }
[data-theme="dark"] .co-warning { --co-color: #f0b350; }
[data-theme="dark"] .co-note { --co-color: #5fc2cf; }
[data-theme="dark"] .co-tip { --co-color: #5fcf98; }
[data-theme="dark"] .co-info { --co-color: #5b9fe0; }
[data-theme="dark"] .co-todo { --co-color: #9fb0b8; }
[data-theme="dark"] .co-important { --co-color: #e07aa8; }
[data-theme="dark"] .co-quote { --co-color: #a9b6bd; }

/* 時間軸 (timeline) list: vertical teal line + amber dots */
.page-body ul.timeline {
  list-style: none;
  margin: 1.2rem 0;
  padding-left: 1.5rem;
  position: relative;
}
.page-body ul.timeline::before {
  content: "";
  position: absolute;
  left: 0.28rem;
  top: 0.4rem;
  bottom: 0.4rem;
  width: 2px;
  background: var(--brand);
  opacity: 0.45;
}
.page-body ul.timeline li {
  position: relative;
  padding: 0 0 1rem 0.7rem;
  margin: 0;
}
.page-body ul.timeline li:last-child { padding-bottom: 0; }
.page-body ul.timeline li::before {
  content: "";
  position: absolute;
  left: -1.22rem;
  top: 0.4rem;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--card);
}

/* sticky page TOC */
.page-toc {
  align-self: start;
  position: sticky;
  top: 5rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}
.page-toc .toc-label {
  margin: 0 0 0.6rem;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.page-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.page-toc a {
  display: block;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}
.page-toc a:hover {
  color: var(--brand-hover);
  background: rgba(14, 77, 100, 0.06);
}

/* backlinks */
.backlinks-title {
  margin: 0 0 0.8rem;
  padding-left: 0.65rem;
  border-left: 4px solid var(--accent);
  color: var(--title);
  font-size: 1.05rem;
}

@media (max-width: 1024px) {
  /* desktop rule sets align-items:start for the grid's row-axis alignment;
     reset to stretch here so flex children (.page-body / .page-toc) are
     clamped to the column's width instead of fit-content-sizing to their
     widest descendant (e.g. a wide table), which forced .page-body past
     the viewport. */
  .content-layout { display: flex; flex-direction: column; align-items: stretch; gap: 1rem; min-width: 0; }
  .page-body { max-width: none; min-width: 0; }
  .page-toc {
    order: -1;
    position: static;
    max-height: none;
    padding: 0.7rem 0.8rem;
    /* flex items default to a content-based automatic minimum size, which
       lets a row of nowrap TOC chips force this (and every ancestor up to
       <html>) wider than the viewport. Pin it to the container width so the
       chip row scrolls internally instead of blowing out the whole page. */
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }
  .page-toc ul {
    flex-direction: row;
    overflow-x: auto;
    min-width: 0;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }
  .page-toc li { flex: 0 0 auto; }
  .page-toc a {
    white-space: nowrap;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
  }
}

@media (max-width: 768px) {
  .page-body table { display: block; overflow-x: auto; white-space: nowrap; }
  .content-hero { padding: 0.9rem 1rem; }
  .hero-title { font-size: 1.3rem; }
  .hero-updated { margin-left: 0; }
  .related-meta-row { flex-direction: column; align-items: flex-start; gap: 0.25rem; }
}

/* ============ mobile ============ */
@media (max-width: 768px) {
  .topbar-inner { flex-wrap: wrap; }
  .navlinks {
    display: none;
    flex: 0 0 100%;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    order: 3;
    padding-top: 0.5rem;
    border-top: 1px solid var(--line);
    margin-top: 0.6rem;
  }
  .navlinks a { padding: 0.6rem 0.4rem; }
  #nav-toggle:checked ~ .topbar-inner .navlinks { display: flex; }
  .hamburger { display: grid; }
  .topbar-actions { flex: 1; justify-content: flex-end; }
  /* icon buttons (theme toggle / hamburger) are 36px at desktop density;
     bump to a 40px tap target on touch screens. */
  .icon-btn { width: 40px; height: 40px; }
  .search-box { flex: 1 1 auto; min-width: 0; max-width: 220px; padding: 0.5rem 0.7rem; }
  .search-box kbd { display: none; }
  /* dropdown stays anchored to (and thus as wide as) the search box itself
     rather than the viewport, so it never overflows the screen edge; trade
     the "updated" column for width at this size. */
  .search-suggest-row .updated { display: none; }
  .hero { padding: 1.5rem 1.2rem; border-radius: 12px; }
  .hero h1 { font-size: 1.5rem; }
  .entry-grid { grid-template-columns: repeat(2, 1fr); }
  .report-grid { grid-template-columns: 1fr; }
  main.container { padding-top: 1rem; }
  .card-grid { grid-template-columns: repeat(2, 1fr); gap: 0.55rem; }
  .card-grid.compact { columns: 3; column-gap: 0.3rem; }
  /* 3-col compact cards traded padding for density; give back a little
     vertical padding so each card clears the ~40px touch-target guideline
     without dropping to 2 columns. */
  .card-grid.compact .list-card { padding: 0.52rem 0.42rem; margin-bottom: 0.32rem; }
  .card-grid.compact .list-card .name { font-size: 0.76rem; gap: 0.25rem; }
  .card-grid.compact .list-card .name .code { font-size: 0.86rem; }
  .card-grid.compact .list-card .sector { display: none; }
  .list-search { max-width: none; }
  .filter-pills { gap: 0.5rem; }
  .pill { padding: 0.62rem 0.9rem; }
  .search-overlay { padding: 0; align-items: stretch; }
  .search-overlay-panel { max-width: none; max-height: none; height: 100%; border-radius: 0; }
  .search-overlay-close { padding: 0.7rem; min-width: 40px; min-height: 40px; }
  /* hero/backlinks reference chips default to a very compact 0.1rem
     vertical padding for information density; too small to tap reliably
     on touch, so give them more breathing room on mobile only. */
  .content-hero .chip,
  .backlinks .chip {
    padding: 0.35rem 0.65rem;
  }
}

@media (max-width: 480px) {
  .card-grid { grid-template-columns: 1fr; }
  .card-grid.compact { columns: 3; }
  .card-grid.two { grid-template-columns: 1fr; }
}

/* ============ lightbox (figure.fig img → fullscreen) ============ */
body.lightbox-open { overflow: hidden; }
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3vh 3vw;
  background: rgba(6, 12, 15, 0.88);
}
.lightbox-overlay[hidden] { display: none; }
.lightbox-figure {
  margin: 0;
  max-width: 92vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
}
.lightbox-img {
  display: block;
  max-width: 92vw;
  max-height: 92vh;
  width: auto;
  height: auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-hover);
}
.lightbox-caption {
  color: #eef3f5;
  font-size: 0.85rem;
  text-align: center;
  max-width: 80vw;
}
.lightbox-close {
  position: absolute;
  top: max(0.8rem, env(safe-area-inset-top));
  right: max(0.8rem, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.22); }

/* ============ accessibility & interaction polish（2026-07-03 稽核） ============ */

/* 鍵盤聚焦一律有可見 ring；滑鼠點擊（非 :focus-visible）不顯示 */
:focus-visible {
  outline: 2px solid var(--brand-hover);
  outline-offset: 2px;
  border-radius: 4px;
}
/* 搜尋輸入框本身 outline:none，改由外框容器顯示聚焦狀態 */
.search-box:focus-within,
.list-search:focus-within {
  border-color: var(--brand-hover);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-hover) 25%, transparent);
}

/* 跳到主要內容（鍵盤/讀屏用；聚焦前完全隱藏） */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0.6rem;
  z-index: 100;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}
.skip-link:focus {
  top: 0.6rem;
  color: #fff;
}

/* 消除行動端 300ms 點擊延遲、防雙擊縮放誤觸 */
a, button, input, label, summary { touch-action: manipulation; }

/* 目前所在分區在導覽列高亮 */
.navlinks a[aria-current="page"] {
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 9%, transparent);
}
[data-theme="dark"] .navlinks a[aria-current="page"] {
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 14%, transparent);
}

/* sticky 目錄跟隨捲動高亮目前章節 */
.page-toc a.current {
  color: var(--brand);
  font-weight: 700;
  background: color-mix(in srgb, var(--brand) 8%, transparent);
  box-shadow: inset 3px 0 0 var(--accent);
}
[data-theme="dark"] .page-toc a.current {
  background: color-mix(in srgb, var(--brand) 14%, transparent);
}

/* 卡片/按鈕按下的細微回饋 */
.list-card:active,
.entry-card:active,
.icon-btn:active,
.pill:active {
  transform: scale(0.985);
}

/* 尊重使用者的減少動態偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
  .list-card:active,
  .entry-card:active,
  .icon-btn:active,
  .pill:active {
    transform: none;
  }
}

/* ============ 複製此頁連結 ============ */
.copy-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: auto;
  padding: 0.28rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.74rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
.copy-link-btn:hover {
  border-color: var(--brand-hover);
  color: var(--brand-hover);
}
.copy-link-btn.copied {
  border-color: #2e8b57;
  color: #2e8b57;
}
[data-theme="dark"] .copy-link-btn.copied {
  border-color: #6fcf97;
  color: #6fcf97;
}
@media (max-width: 768px) {
  /* 手機 hero 換行時別佔滿一行，跟在更新日期後面即可 */
  .copy-link-btn { margin-left: 0; }
}
