:root {
  color-scheme: light dark;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #16202b;
  --text-2: #4a5665;
  --muted: #6b7684;
  --border: #dde3ea;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --line: #1f6feb;
  --line-proj: #1f6feb;
  --band: rgba(31, 111, 235, 0.14);
  --grid: #e6eaf0;
  --good: #1a7f4b;
  --good-bg: #e6f5ec;
  --warn: #9a6700;
  --warn-bg: #fff4d6;
  --bad: #c0392b;
  --bad-bg: #fde8e6;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 8px rgba(16, 24, 40, 0.04);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a;
    --surface: #171d25;
    --surface-2: #1f2731;
    --text: #e8edf3;
    --text-2: #b7c1cc;
    --muted: #8e99a6;
    --border: #2a3441;
    --accent: #5b9dff;
    --accent-ink: #0b1220;
    --line: #6fa8ff;
    --line-proj: #6fa8ff;
    --band: rgba(111, 168, 255, 0.18);
    --grid: #243040;
    --good: #4cc97e;
    --good-bg: #123322;
    --warn: #e5b243;
    --warn-bg: #3a2c0a;
    --bad: #ff7b6b;
    --bad-bg: #40191a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 1.25rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); font-size: .9rem; }
.wrap { width: min(1040px, 100% - 2rem); margin-inline: auto; }
[hidden] { display: none !important; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-row { display: flex; align-items: baseline; gap: 1rem; padding: .9rem 0; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--text); font-weight: 700; font-size: 1.25rem; }
.brand-icon { font-size: 1.4rem; }
.tagline { margin: 0; color: var(--muted); font-size: .95rem; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-top: 1rem;
}
.card-head { margin-bottom: .5rem; }

/* Controls */
.controls { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: end; }
.control { display: flex; flex-direction: column; gap: .3rem; flex: 1 1 260px; }
.control-label { font-size: .85rem; font-weight: 600; color: var(--text-2); }
select, .btn {
  font: inherit;
  padding: .6rem .8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  min-height: 44px;
}
select { width: 100%; }
.btn { cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .6; cursor: progress; }
.control-grade { flex: 0 1 auto; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; min-height: 44px; }
.segmented button {
  font: inherit; font-weight: 600; font-size: .9rem; border: 0; background: transparent; color: var(--text-2);
  padding: .4rem .8rem; border-radius: 8px; cursor: pointer; min-width: 44px;
}
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.segmented button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.segmented button:disabled { opacity: .45; cursor: not-allowed; }
.note { flex-basis: 100%; margin: 0; font-size: .9rem; color: var(--text-2); }

/* Status */
.status:empty { display: none; }
.status { margin-top: 1rem; padding: .8rem 1rem; border-radius: 10px; background: var(--warn-bg); color: var(--text); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.status.error { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.status.info { background: var(--surface); border-color: var(--border); color: var(--muted); }

/* Verdict */
.verdict { border-left: 6px solid var(--verdict, var(--accent)); }
.verdict[data-verdict="now"]  { --verdict: var(--good); --verdict-bg: var(--good-bg); }
.verdict[data-verdict="ok"]   { --verdict: var(--warn); --verdict-bg: var(--warn-bg); }
.verdict[data-verdict="wait"] { --verdict: var(--bad);  --verdict-bg: var(--bad-bg); }
.eyebrow { margin: 0 0 .25rem; font-size: .9rem; color: var(--muted); }
.verdict h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); color: var(--verdict); }
.why { margin: -.25rem 0 .5rem; font-weight: 600; color: var(--verdict); }
.reason { font-size: 1.05rem; color: var(--text-2); }
.asof { margin: 0; font-size: .85rem; color: var(--muted); }
.stale-flag { color: var(--bad); font-weight: 600; }


/* Price strip */
.strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-top: 1rem; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .9rem 1rem; display: flex; flex-direction: column; gap: .15rem; box-shadow: var(--shadow);
}
.tile-label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.tile-label small { font-weight: 400; }
.tile-value { font-size: 1.7rem; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.tile-delta { font-size: .85rem; color: var(--muted); }
.tile-delta.up { color: var(--bad); }
.tile-delta.down { color: var(--good); }
.tile-note { font-size: .78rem; color: var(--muted); margin-top: .15rem; }

/* Chart */
.chart-wrap { position: relative; height: 300px; }
.legend { list-style: none; padding: 0; margin: .75rem 0 0; display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; font-size: .85rem; color: var(--text-2); }
.legend li { display: inline-flex; align-items: center; gap: .4rem; }
.swatch { display: inline-block; width: 22px; height: 0; border-top: 2px solid var(--line); }
.swatch-proj { border-top-style: dashed; }
.swatch-band { height: 12px; border: 0; background: var(--band); border-radius: 3px; }
.table-details { margin-top: .75rem; font-size: .9rem; }
.table-details summary { cursor: pointer; color: var(--accent); }
.table-scroll { overflow-x: auto; margin-top: .5rem; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: .8rem; }

/* Drivers / range */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid2 .card { margin-top: 1rem; }
.drivers, .outlook { list-style: none; margin: 0; padding: 0; }
.drivers li { display: flex; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.drivers li:last-child { border-bottom: 0; }
.drivers .ico { font-size: 1.2rem; line-height: 1.3; }
.drivers .t { font-weight: 600; }
.drivers .d { color: var(--text-2); font-size: .9rem; }
.chip { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--surface-2); color: var(--text-2); }
.chip.up { background: var(--bad-bg); color: var(--bad); }
.chip.down { background: var(--good-bg); color: var(--good); }
.range { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 0 0 .5rem; }
.range div { background: var(--surface-2); border-radius: 10px; padding: .5rem .75rem; }
.range dt { font-size: .75rem; color: var(--muted); font-weight: 600; }
.range dd { margin: 0; font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.range-bar { position: relative; height: 8px; border-radius: 4px; margin: .75rem .5rem .5rem; background: linear-gradient(90deg, var(--good), var(--warn), var(--bad)); }
.range-marker {
  position: absolute; top: 50%; width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--text); transform: translate(-50%, -50%);
  transition: left .5s ease;
}
.outlook li { display: flex; justify-content: space-between; padding: .35rem 0; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.outlook li:last-child { border-bottom: 0; }
.outlook .m { color: var(--text-2); }

/* How / footer */
.how p { color: var(--text-2); }
.tip { background: var(--surface-2); padding: .75rem 1rem; border-radius: 10px; }
.site-footer { margin-top: 2rem; padding: 1.5rem 0 2.5rem; border-top: 1px solid var(--border); }
.disclaimer { font-size: .9rem; color: var(--text-2); }

/* Skeleton */
.skeleton .tile-value { opacity: .3; }

@media (max-width: 760px) {
  .control-grade { flex-basis: 100%; }
  .segmented { display: flex; }
  .segmented button { flex: 1; padding-inline: .3rem; }
  .strip { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .chart-wrap { height: 240px; }
}
@media (max-width: 400px) {
  .tile { padding: .75rem .8rem; }
  .tile-value { font-size: 1.45rem; }
  .card { padding: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  .range-marker { transition: none; }
}
