:root {
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --accent: #2a78d6;
  --up: #0ca30c;
  --up-text: #006300;
  --down: #d03b3b;
  --down-text: #b42828;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.1); --accent: #3987e5;
    --up-text: #0ca30c; --down-text: #e86060; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.1); --accent: #3987e5;
  --up-text: #0ca30c; --down-text: #e86060; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
h2 { font-size: 17px; margin: 0 0 12px; letter-spacing: -0.01em; }
h3.sub-h { font-size: 14px; color: var(--ink-2); margin: 20px 0 8px; font-weight: 600; }
section { margin: 28px 0; }

.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.top-row { display: flex; align-items: center; justify-content: space-between; height: 52px; gap: 12px; }
.brand { font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; letter-spacing: -0.02em; }
.brand span { color: var(--down); }
.top-meta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; min-width: 0; }
#updated { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--ink); cursor: pointer; font-size: 15px; flex: none; }
.icon-btn:hover { border-color: var(--axis); }
.icon-btn.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.hero { text-align: center; margin: 36px 0 24px; }
.hero-q { margin: 0; color: var(--ink-2); font-size: 15px; }
.hero-a { margin: 4px 0; font-size: clamp(48px, 11vw, 88px); font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.hero-a.up { color: var(--up-text); }
.hero-a.down { color: var(--down-text); }
#verdict-sub { margin: 6px 0 0; }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.grid-idx { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px 10px;
  box-shadow: var(--shadow); cursor: pointer; text-align: left; color: inherit; font: inherit; width: 100%;
  display: flex; flex-direction: column; gap: 2px; min-width: 0; transition: border-color 0.15s; }
.card:hover { border-color: var(--axis); }
.card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; min-width: 0; }
.card .sym { font-weight: 700; display: flex; align-items: center; gap: 6px; min-width: 0; }
.card .sym img { width: 18px; height: 18px; border-radius: 50%; }
.card .name { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .price { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }
.card .err { color: var(--muted); font-size: 13px; padding: 14px 0; }
.chg { font-size: 13px; font-weight: 600; white-space: nowrap; }
.chg.up { color: var(--up-text); }
.chg.down { color: var(--down-text); }
.chg.flat { color: var(--muted); }
.spark { width: 100%; height: 40px; display: block; margin-top: 6px; }
.skeleton { min-height: 118px; background: linear-gradient(90deg, var(--surface), var(--grid), var(--surface));
  background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); margin-bottom: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.tile .k { font-size: 12.5px; color: var(--muted); }
.tile .v { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.panel-head p { margin: 2px 0 0; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: none; color: var(--ink-2); font: inherit; font-size: 13px; padding: 5px 9px;
  border-radius: 7px; cursor: pointer; }
.seg button.on { background: var(--page); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }
.chart { position: relative; height: 300px; margin: 12px 0 4px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.axis-label { fill: var(--muted); font-size: 11px; }
.gridline { stroke: var(--grid); stroke-width: 1; }

.bars { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; }
.bar-row { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 10px; height: 26px; cursor: default; }
.bar-row .lbl { font-size: 12.5px; font-weight: 600; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { position: relative; height: 100%; }
.bar-track .mid { position: absolute; left: 50%; top: 2px; bottom: 2px; width: 1px; background: var(--axis); }
.bar { position: absolute; top: 7px; height: 12px; }
.bar.up { background: var(--up); border-radius: 0 4px 4px 0; }
.bar.down { background: var(--down); border-radius: 4px 0 0 4px; }
.bar-val { position: absolute; top: 4px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.bar-row:hover .lbl { color: var(--ink); }

.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; font-size: 12.5px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); white-space: nowrap; }
.tip b { font-weight: 650; }
.foot { padding: 24px 16px 40px; border-top: 1px solid var(--border); margin-top: 40px; }

@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .card { padding: 10px; }
  .card .price { font-size: 17px; }
  .chart { height: 240px; }
  .seg button { padding: 5px 7px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
