:root {
  color-scheme: light;
  --background: #f8fafc;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --foreground: #0f172a;
  --muted: #475569;
  --subtle: #64748b;
  --border: #dbe3ee;
  --primary: #075985;
  --primary-soft: #e0f2fe;
  --positive: #047857;
  --positive-soft: #ecfdf5;
  --warning: #a16207;
  --warning-soft: #fffbeb;
  --negative: #b91c1c;
  --negative-soft: #fef2f2;
  --focus: #0284c7;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgb(15 23 42 / 5%), 0 8px 24px rgb(15 23 42 / 5%);
  --nav-height: 68px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 88px; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: var(--background);
  color: var(--foreground);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, a { touch-action: manipulation; }
a { color: inherit; }
button { font: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.shell { width: min(100% - 32px, 1180px); margin-inline: auto; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 1000; padding: 12px 16px; border-radius: 8px; background: var(--foreground); color: #fff; }
.skip-link:focus { top: 12px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.topbar { position: sticky; top: 0; z-index: 40; border-bottom: 1px solid rgb(219 227 238 / 90%); background: rgb(248 250 252 / 94%); backdrop-filter: blur(12px); }
.topbar__inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 48px; text-decoration: none; }
.brand__mark { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 10px; background: var(--foreground); color: white; font-weight: 750; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; line-height: 1.25; }
.brand small { margin-top: 2px; color: var(--subtle); font-size: 12px; }
.state { display: inline-flex; min-height: 36px; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 650; white-space: nowrap; }
.state__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--subtle); box-shadow: 0 0 0 4px rgb(100 116 139 / 12%); }
.state[data-state="live"] .state__dot { background: var(--positive); box-shadow: 0 0 0 4px rgb(4 120 87 / 12%); }
.state[data-state="cache"] .state__dot, .state[data-state="stale"] .state__dot { background: var(--warning); box-shadow: 0 0 0 4px rgb(161 98 7 / 12%); }
.state[data-state="error"] .state__dot { background: var(--negative); box-shadow: 0 0 0 4px rgb(185 28 28 / 12%); }

.main { padding-block: 28px calc(var(--nav-height) + 36px + env(safe-area-inset-bottom)); }
.hero { display: grid; gap: 20px; align-items: end; padding: 12px 0 24px; }
.eyebrow { margin: 0 0 6px; color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .11em; }
h1, h2, p { overflow-wrap: anywhere; }
h1 { max-width: 720px; margin: 0; font-size: clamp(28px, 7vw, 44px); line-height: 1.1; letter-spacing: -.035em; }
h2 { margin: 0; font-size: clamp(22px, 4vw, 28px); line-height: 1.2; letter-spacing: -.02em; }
.hero__copy { max-width: 720px; margin: 14px 0 0; color: var(--muted); }
.snapshot-clock { min-width: 0; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.snapshot-clock span, .snapshot-clock small { display: block; color: var(--subtle); font-size: 12px; }
.snapshot-clock strong { display: block; margin: 4px 0; font-size: 15px; font-variant-numeric: tabular-nums; }

.notice { display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; align-items: start; padding: 14px; border: 1px solid #bae6fd; border-radius: var(--radius); background: #f0f9ff; color: #0c4a6e; }
.notice > svg { margin-top: 2px; }
.notice strong { font-size: 14px; }
.notice p { margin: 2px 0 0; font-size: 13px; }
.notice[data-tone="warning"] { border-color: #fde68a; background: var(--warning-soft); color: #713f12; }
.notice[data-tone="error"] { border-color: #fecaca; background: var(--negative-soft); color: #7f1d1d; }
.text-button { grid-column: 2; justify-self: start; min-height: 44px; padding: 8px 0; border: 0; background: transparent; color: currentColor; font-weight: 750; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.text-button:active { opacity: .65; }

.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.metric-card { min-width: 0; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 1px 2px rgb(15 23 42 / 3%); }
.metric-card span, .metric-card small { display: block; color: var(--subtle); font-size: 12px; }
.metric-card strong { display: block; margin: 5px 0 2px; font-size: clamp(24px, 7vw, 34px); line-height: 1; font-variant-numeric: tabular-nums; }

.section { margin-top: 36px; scroll-margin-top: 88px; }
.section--last { margin-bottom: 16px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.section-heading > p { max-width: 440px; margin: 0; color: var(--subtle); font-size: 13px; text-align: right; }
.watchlist, .mover-list { display: grid; gap: 10px; }
.watch-card, .mover-card, .report-row, .upcoming-row, .health-row { min-width: 0; border: 1px solid var(--border); background: var(--surface); }
.watch-card, .mover-card { padding: 14px; border-radius: var(--radius); }
.card-top { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.identity { min-width: 0; }
.identity strong { display: block; font-size: 16px; }
.identity small { color: var(--subtle); }
.price { flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.price strong { display: block; font-size: 19px; }
.price small { color: var(--subtle); }
.data-line { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.data-point { min-width: 0; }
.data-point span, .data-point small { display: block; color: var(--subtle); font-size: 11px; }
.data-point strong { display: block; margin-top: 2px; font-size: 14px; font-variant-numeric: tabular-nums; }
.positive { color: var(--positive) !important; }
.negative { color: var(--negative) !important; }
.warning { color: var(--warning) !important; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 8px; border-radius: 999px; background: var(--surface-muted); color: var(--muted); font-size: 11px; font-weight: 700; }
.badge--positive { background: var(--positive-soft); color: #065f46; }
.badge--warning { background: var(--warning-soft); color: #854d0e; }
.badge--negative { background: var(--negative-soft); color: #991b1b; }

.disclosure { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: clip; }
.disclosure summary { min-height: 52px; display: flex; align-items: center; padding: 12px 16px; cursor: pointer; font-weight: 750; list-style: none; }
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary::after { content: "+"; margin-left: auto; color: var(--primary); font-size: 20px; }
.disclosure[open] summary::after { content: "−"; }
.disclosure[open] summary { border-bottom: 1px solid var(--border); }
.report-list, .upcoming-list { display: grid; }
.report-row, .upcoming-row { padding: 12px 14px; border: 0; border-bottom: 1px solid var(--border); }
.report-row:last-child, .upcoming-row:last-child { border-bottom: 0; }
.report-row__meta, .upcoming-row__meta { display: flex; flex-wrap: wrap; gap: 6px 10px; color: var(--subtle); font-size: 12px; }
.report-row strong, .upcoming-row strong { display: block; margin: 4px 0 2px; font-size: 14px; }

.cb-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.summary-chip { padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.summary-chip span { display: block; color: var(--subtle); font-size: 11px; }
.summary-chip strong { display: block; margin-top: 2px; font-size: 17px; font-variant-numeric: tabular-nums; }
.mover-card .data-line { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.health-list { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.health-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--border); }
.health-row:last-child { border-bottom: 0; }
.health-row strong { font-size: 14px; }
.disclaimer { margin: 14px 0 0; color: var(--subtle); font-size: 13px; }

.bottom-nav { position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); min-height: calc(var(--nav-height) + env(safe-area-inset-bottom)); padding: 4px max(8px, env(safe-area-inset-left)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-right)); border-top: 1px solid var(--border); background: rgb(255 255 255 / 96%); backdrop-filter: blur(16px); }
.bottom-nav a { min-width: 0; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 10px; color: var(--subtle); font-size: 11px; font-weight: 700; text-decoration: none; transition: color 180ms ease, background 180ms ease; }
.bottom-nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.bottom-nav a:active { background: var(--surface-muted); }
.bottom-nav svg { width: 21px; height: 21px; }
.noscript { margin: 24px; padding: 16px; border: 1px solid var(--border); background: var(--surface); }
.empty { margin: 0; padding: 18px; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--subtle); background: var(--surface); }

@media (min-width: 700px) {
  .shell { width: min(100% - 48px, 1180px); }
  .main { padding-top: 40px; }
  .hero { grid-template-columns: minmax(0, 1.7fr) minmax(240px, .7fr); padding-bottom: 32px; }
  .notice { grid-template-columns: auto 1fr auto; align-items: center; }
  .text-button { grid-column: auto; justify-self: end; }
  .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .watchlist { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mover-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .main { padding-bottom: 52px; }
  .bottom-nav { position: sticky; top: 64px; bottom: auto; width: min(100% - 48px, 1180px); min-height: 52px; margin: -1px auto 0; padding: 6px; grid-template-columns: repeat(4, minmax(120px, 1fr)); border: 1px solid var(--border); border-radius: 0 0 14px 14px; box-shadow: var(--shadow); }
  .bottom-nav a { min-height: 44px; flex-direction: row; gap: 8px; font-size: 13px; }
  .watchlist { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mover-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --background: #080d16;
    --surface: #111827;
    --surface-muted: #1e293b;
    --foreground: #f8fafc;
    --muted: #cbd5e1;
    --subtle: #94a3b8;
    --border: #334155;
    --primary: #7dd3fc;
    --primary-soft: #0c4a6e;
    --positive: #6ee7b7;
    --positive-soft: #064e3b;
    --warning: #fde68a;
    --warning-soft: #713f12;
    --negative: #fca5a5;
    --negative-soft: #7f1d1d;
    --focus: #38bdf8;
  }
  .topbar { background: rgb(8 13 22 / 94%); }
  .bottom-nav { background: rgb(17 24 39 / 96%); }
  .notice { border-color: #075985; background: #082f49; color: #e0f2fe; }
  .notice[data-tone="warning"] { border-color: #a16207; background: #422006; color: #fef3c7; }
  .notice[data-tone="error"] { border-color: #b91c1c; background: #450a0a; color: #fee2e2; }
  .badge--positive { color: #a7f3d0; }
  .badge--warning { color: #fef3c7; }
  .badge--negative { color: #fecaca; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
