:root {
  --bg: #0d0d0d;
  --card: #171717;
  --line: #262626;
  --line2: #333;
  --text: #ffffff;
  --sub: #aaaaaa;
  --dim: #8a8a8a;
  --red: #e03030;
  --blue: #4a9eff;
  --gold: #d4a017;
  --orange: #ff8c00;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --nav-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 14px; line-height: 1.5;
  max-width: 520px; margin: 0 auto; min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
}
button { font-family: inherit; color: inherit; }
a { color: var(--red); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.up { color: var(--red); }
.down { color: var(--blue); }
.flat { color: var(--sub); }

/* header */
.top { padding: 18px 16px 12px; border-bottom: 1px solid #222; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.top .brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top .logo { width: 40px; height: 40px; border-radius: 10px; flex: none; box-shadow: 0 0 0 1px #2a2a2a; }
.top .kicker { font-size: 12px; color: var(--sub); letter-spacing: 2px; }
.top h1 { margin: 2px 0 0; font-size: 24px; font-weight: 900; letter-spacing: .5px; }
.top h1 em { font-style: normal; color: var(--red); }
.top h1 .en { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--sub); letter-spacing: 1px; margin-left: 4px; }
.top .date { font-family: var(--mono); font-size: 12px; color: var(--sub); text-align: right; line-height: 1.4; }

main { padding: 14px 16px 8px; display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--card); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.card.hl { border-top: 2px solid var(--red); }
.card-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-h h2 { margin: 0; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.card-h .note { font-size: 11px; color: var(--sub); white-space: nowrap; }
.expl { margin: 0; font-size: 11.5px; line-height: 1.65; color: var(--dim); }

.info {
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid #555; background: transparent;
  color: var(--sub); font-size: 12px; line-height: 1; cursor: pointer; padding: 0; flex: none;
  position: relative;
}
.info::after { content: ""; position: absolute; inset: -11px; }

.three { margin: 0; padding: 0 0 0 18px; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; line-height: 1.7; color: #dddddd; }
.three strong { color: #fff; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat .k { font-size: 11px; color: var(--sub); }
.stat .v { font-family: var(--mono); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .s { font-family: var(--mono); font-size: 12px; }

/* diverging bars */
.dbar { display: grid; grid-template-columns: 44px minmax(0, 1fr) 92px; gap: 10px; align-items: center; font-size: 13px; }
.dbar .lab { color: var(--sub); }
.dbar .track { height: 10px; background: #242424; position: relative; }
.dbar .track::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: #555; }
.dbar .fill { position: absolute; top: 0; height: 10px; }
.dbar .val { font-family: var(--mono); text-align: right; font-variant-numeric: tabular-nums; }

/* column chart */
.cols { display: grid; gap: 3px; height: 120px; align-items: stretch; }
.cols .c { display: flex; flex-direction: column; }
.cols .half { flex: 1; display: flex; flex-direction: column; }
.cols .half.top { justify-content: flex-end; border-bottom: 1px solid #444; }
.cols .half.bot { justify-content: flex-start; }
.axis { display: flex; justify-content: space-between; font-size: 10px; color: var(--dim); font-family: var(--mono); }

/* tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tab {
  min-height: 40px; padding: 0 14px; border: 1px solid var(--line2); background: var(--card);
  font-size: 13px; cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--red); border-color: var(--red); font-weight: 700; }
.tabs.even { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* lists */
.rows { display: flex; flex-direction: column; }
.row {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) 62px 84px; gap: 8px; align-items: center;
  min-height: 50px; border-top: 1px solid #222; padding: 0 2px;
}
.row.head { min-height: 26px; border-top: none; font-size: 10.5px; color: var(--sub); }
.row .rk { font-family: var(--mono); font-weight: 900; color: #777; }
.row .rk.top3 { color: var(--red); }
.row .nm { display: flex; flex-direction: column; min-width: 0; }
.row .nm b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .nm span { font-family: var(--mono); font-size: 11px; color: var(--sub); }
.row .r { font-family: var(--mono); font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
.row .r.big { font-size: 13.5px; font-weight: 700; }
.rule { background: var(--card); padding: 10px 12px; font-size: 11.5px; line-height: 1.6; color: var(--sub); }
.rule b { color: #fff; }

.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.mini { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.mini h3 { margin: 0; font-size: 12px; }
.mini .it { display: flex; justify-content: space-between; gap: 6px; font-size: 12.5px; border-top: 1px solid #262626; padding-top: 6px; }
.mini .it span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { border: 1px solid var(--red); padding: 6px 12px; font-size: 13px; display: flex; gap: 8px; align-items: baseline; }
.pill.sell { border-color: var(--blue); }

.disc { margin: 4px 0 0; font-size: 10.5px; line-height: 1.7; color: #666; }

/* race */
.race-cap { background: var(--card); padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.race-cap .line { font-size: 12.5px; line-height: 1.7; }
.ctrl { display: flex; align-items: center; gap: 10px; }
.ctrl button { width: 44px; height: 44px; flex: none; border: 1px solid var(--line2); background: var(--bg); font-family: var(--mono); font-weight: 700; cursor: pointer; }
.ctrl button.play { background: var(--red); border-color: var(--red); }
.ctrl label { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 10px; color: var(--dim); }
.ctrl input[type=range] { width: 100%; height: 36px; margin: 0; accent-color: var(--red); touch-action: none; cursor: pointer; }
.lanes.scrubbing .car { transition: none; }
.lanes { display: flex; flex-direction: column; gap: 6px; }
.lane {
  display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 8px; align-items: center;
  width: 100%; min-height: 46px; padding: 0; border: none; background: none; text-align: left; cursor: pointer;
}
.lane .ln { display: flex; flex-direction: column; min-width: 0; }
.lane .ln b { font-size: 12.5px; font-weight: 500; color: #ddd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lane .ln small { font-size: 10px; font-weight: 700; }
.track2 { height: 38px; background: #1b1b1b; border-top: 1px solid #3a3a3a; border-bottom: 1px solid #3a3a3a; position: relative; overflow: hidden; }
.track2 .mid { position: absolute; top: 18px; left: 0; right: 0; border-top: 1px dashed #2c2c2c; }
.track2 .zero { position: absolute; top: 0; bottom: 0; width: 1px; background: #555; }
.track2 .flag { position: absolute; top: 0; bottom: 0; right: 0; width: 8px; background: repeating-conic-gradient(#fff 0 25%, #0d0d0d 0 50%) 0 0 / 8px 8px; opacity: .75; }
.car { position: absolute; top: 9px; width: 44px; height: 20px; transition: left .55s ease; }
.car .trail { position: absolute; right: 42px; top: 9px; width: 30px; height: 2px; background: linear-gradient(to right, transparent, currentColor); opacity: .55; }
.car .amt { position: absolute; top: -9px; left: 0; font-family: var(--mono); font-size: 9.5px; white-space: nowrap; color: #ddd; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 11px; color: var(--sub); }

/* sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--card); border-top: 2px solid var(--red); width: 100%; max-width: 520px;
  max-height: 78vh; overflow-y: auto; padding: 16px 16px calc(20px + var(--safe-b));
  display: flex; flex-direction: column; gap: 10px;
}
.sheet-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sheet-h h2 { margin: 0; font-size: 18px; font-weight: 900; }
.sheet-h .x { width: 44px; height: 44px; flex: none; border: 1px solid var(--line2); background: var(--bg); font-size: 18px; cursor: pointer; }
.sheet p { margin: 0; font-size: 13.5px; line-height: 1.8; color: #ddd; }

/* nav */
nav.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: rgba(13,13,13,.97); border-top: 1px solid #222;
  padding-bottom: var(--safe-b);
}
nav.bottom .in { max-width: 520px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
nav.bottom a {
  min-height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11.5px; color: var(--sub); text-decoration: none; border-top: 2px solid transparent;
}
nav.bottom a svg { width: 20px; height: 20px; }
nav.bottom a[aria-current="page"] { color: var(--red); font-weight: 700; border-top-color: var(--red); }

.loading, .err { padding: 60px 20px; text-align: center; color: var(--sub); }
.err b { color: #fff; display: block; margin-bottom: 6px; }
.empty { font-size: 12.5px; color: var(--dim); padding: 10px 0; }

@media (prefers-reduced-motion: reduce) { .car { transition: none; } }
