:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #16202c;
  --text-2: #4b5563;
  --muted: #6b7280;
  --line: #e3e7ed;
  --grid: #eceff3;
  --brand: #2a5d8f;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --shadow: 0 1px 2px rgb(0 0 0 / 5%), 0 2px 10px rgb(0 0 0 / 4%);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #12161d;
    --surface: #1c2230;
    --text: #e8ecf2;
    --text-2: #c2c9d4;
    --muted: #98a2b3;
    --line: #2c3444;
    --grid: #263041;
    --brand: #8bb7e6;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12161d; --surface: #1c2230; --text: #e8ecf2; --text-2: #c2c9d4; --muted: #98a2b3; --line: #2c3444; --grid: #263041;
  --brand: #8bb7e6; --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --shadow: none;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif; }
a { color: var(--brand); }
h1 { font-size: 26px; line-height: 1.3; margin: 0 0 6px; }
h2 { font-size: 20px; margin: 0 0 4px; }
h3 { font-size: 16px; margin: 0 0 8px; }
p { margin: 6px 0; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.top { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 0; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand b { display: block; font-size: 16px; }
.brand span { display: block; font-size: 12px; color: var(--muted); }
.nav { display: flex; gap: 4px; overflow-x: auto; }
.nav a { padding: 5px 10px; border-radius: 8px; text-decoration: none; color: var(--text-2); white-space: nowrap; font-size: 14px; }
.nav a:hover { background: var(--bg); }

main { display: grid; gap: 18px; padding-top: 18px; padding-bottom: 30px; }
section { scroll-margin-top: 70px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.lead { color: var(--text-2); max-width: 760px; }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--bg); color: var(--text-2); border: 1px solid var(--line); }
.badge.warn { border-color: #e0b04a; color: #8a5a00; background: #fff7e0; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .badge.warn { background: #3a2e12; color: #f0c86a; } }

.heroes { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.hero { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); }
.hero .v { font-size: 30px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.hero .v small { font-size: 15px; font-weight: 600; margin-left: 2px; }
.hero .l { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.hero .s { color: var(--muted); font-size: 12px; margin-top: 4px; }

.grid2 { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr)); }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.chart-head .t { font-weight: 600; }
.chart-head .d { color: var(--muted); font-size: 13px; }
.toggle { font-size: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); border-radius: 8px; padding: 3px 8px; cursor: pointer; white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--text-2); margin: 8px 0 2px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend i.line { height: 3px; border-radius: 2px; vertical-align: 3px; }
.legend i.ghost { opacity: .45; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
svg.chart text.lbl { fill: var(--text-2); font-size: 11px; font-weight: 600; }
svg.chart .grid { stroke: var(--grid); }
svg.chart .axis { stroke: var(--line); }
svg.chart .now { stroke: var(--muted); stroke-dasharray: 3 3; }
svg.chart .cross { stroke: var(--muted); }
.tablebox { overflow-x: auto; margin-top: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 500; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 13px; box-shadow: 0 6px 20px rgb(0 0 0 / 15%); min-width: 150px; }
.tip b { display: block; margin-bottom: 3px; }
.tip .r { display: flex; justify-content: space-between; gap: 14px; }
.tip .r span:first-child i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

.bars { display: grid; gap: 7px; }
.bars .b { display: grid; grid-template-columns: 6.5em minmax(0, 1fr) 4.5em; gap: 8px; align-items: center; font-size: 14px; }
.bars .track { height: 12px; background: var(--grid); border-radius: 4px; overflow: hidden; }
.bars .fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.bars .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--text-2); padding: 6px 12px; font: inherit; font-size: 14px; cursor: pointer; border-left: 1px solid var(--line); }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .seg button.on { color: #0f1621; } }

.assume { display: grid; gap: 14px 22px; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.assume fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 12px; margin: 0; min-width: 0; }
.assume legend { font-weight: 600; padding: 0 6px; }
.f { display: grid; grid-template-columns: minmax(0, 1fr) 5.5em; gap: 2px 10px; align-items: center; margin: 9px 0; }
.f label { font-size: 14px; color: var(--text-2); }
.f input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--brand); }
.f output { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.grads { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.grads label { font-size: 12px; color: var(--muted); display: grid; gap: 2px; }
.grads input { width: 100%; font: inherit; padding: 4px 6px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text); text-align: right; }
.btn { font: inherit; font-size: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 9px; padding: 6px 12px; cursor: pointer; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }

.note { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; color: var(--text-2); font-size: 14px; }
.foot { color: var(--muted); font-size: 12px; padding-bottom: 30px; }

@media (max-width: 640px) {
  h1 { font-size: 22px; }
  .hero .v { font-size: 26px; }
  .grads { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .nav { width: 100%; }
}
@media print {
  .top, .toggle, #assume .btn { display: none; }
  body { background: #fff; }
}
