:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --ink: #111113;
  --ink-2: #3f3f46;   /* 10.3:1 on bg */
  --ink-3: #52525b;   /* 7.5:1 on bg  */
  --line: #e4e4e7;
  --line-2: #d4d4d8;
  --mid: #cfcfd4;
  --accent: #1d4ed8;  /* 6.6:1 on white */
  --accent-soft: #e8eefc;
  --down: #18181b;
  --radius: 14px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 var(--font); font-feature-settings: "tnum" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
}
.skip { position: absolute; left: -9999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.page {
  max-width: 1180px; margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 40px max(20px, env(safe-area-inset-left));
}

/* masthead */
.masthead { padding: 28px 0 24px; max-width: 760px; }
.eyebrow { margin: 0 0 14px; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
h1 { margin: 0; font-size: clamp(32px, 5.2vw, 56px); line-height: 1.04; letter-spacing: -0.035em; font-weight: 700; }
h1 em { font-style: normal; color: var(--accent); }
.lede { margin: 18px 0 0; font-size: clamp(16px, 1.6vw, 18px); color: var(--ink-2); max-width: 640px; }

/* controls */
.controls {
  display: grid; grid-template-columns: minmax(220px, 1.3fr) auto auto auto; gap: 20px 28px; align-items: end;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin: 8px 0 28px;
  position: sticky; top: 0; z-index: 5; box-shadow: 0 1px 0 rgba(0,0,0,.02), 0 8px 24px -18px rgba(0,0,0,.25);
}
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field > label, legend { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); padding: 0; margin-bottom: 8px; }
.field > label { margin-bottom: 0; }
.select-wrap { position: relative; }
.select-wrap::after { content: ""; position: absolute; right: 14px; top: 50%; width: 8px; height: 8px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
select {
  width: 100%; appearance: none; -webkit-appearance: none; font: 600 16px/1.2 var(--font); color: var(--ink);
  background: var(--bg); border: 1px solid var(--line-2); border-radius: 10px; padding: 11px 38px 11px 12px; min-height: 44px; cursor: pointer;
}
select:hover { border-color: var(--ink-3); }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg-opt { position: relative; display: block; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-opt span {
  display: flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 11px; border-radius: 7px;
  font-size: 14px; font-weight: 600; color: var(--ink-2); white-space: nowrap; transition: background .15s, color .15s;
}
.seg-opt input:hover + span { color: var(--ink); background: #f0f0f1; }
.seg-opt input:checked + span { background: var(--ink); color: #fff; }
.seg-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* answer */
main { outline: none; }
.answer { margin-bottom: 28px; }
.sentence { margin: 0 0 22px; font-size: clamp(21px, 2.5vw, 30px); line-height: 1.32; letter-spacing: -0.018em; font-weight: 500; max-width: 980px; }
.sentence strong { font-weight: 700; }
.sentence .soft { color: var(--ink-3); }
.up-ink { color: var(--accent); font-weight: 700; }
.down-ink { color: var(--down); font-weight: 700; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
td.down-ink { text-decoration: none; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--line-2); }
.stat.up::before { background: var(--accent); }
.stat.down::before { background: var(--down); }
.stat-label { margin: 0; font-size: 13px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.stat-big { margin: 4px 0 8px; font-size: clamp(34px, 4vw, 46px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; }
.stat.up .stat-big { color: var(--accent); }
.stat-line { margin: 0; font-size: 14px; color: var(--ink-2); }
.stat-line:empty { display: none; }

/* panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 22px 18px; margin-bottom: 18px; min-width: 0; }
.panel-head { margin-bottom: 14px; }
h2 { margin: 0 0 4px; font-size: 19px; letter-spacing: -0.01em; }
.note { margin: 0; font-size: 14px; color: var(--ink-3); max-width: 760px; }
.note.tight { margin-top: 12px; }
.two { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; }
.two .panel { margin-bottom: 18px; }

/* chart */
.chart { margin: 0; width: 100%; }
.chart svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.b-mid { fill: var(--mid); }
.b-up { fill: var(--accent); }
.b-down { fill: var(--down); }
.baseline { stroke: var(--line-2); }
.tick { stroke: var(--ink-3); }
.axis { font-size: 12px; fill: var(--ink-3); font-family: var(--font); }
.thr { stroke-width: 1.5; stroke-dasharray: 4 4; }
.thr.up { stroke: var(--accent); } .thr.down { stroke: var(--down); }
.thr-label { font-size: 13px; font-weight: 700; font-family: var(--font); }
.thr-label.up { fill: var(--accent); } .thr-label.down { fill: var(--down); }
.latest line { stroke: #b45309; stroke-width: 2; }
.latest circle { fill: #b45309; stroke: #fff; stroke-width: 2; }
figcaption { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin-top: 12px; font-size: 14px; color: var(--ink-2); }
.key { display: inline-flex; align-items: center; gap: 7px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw.b-up { background: var(--accent); } .sw.b-down { background: var(--down); }
.sw.latest-dot { background: #b45309; border-radius: 50%; }
.link-btn { margin-left: auto; font: 600 14px var(--font); color: var(--accent); background: none; border: 1px solid var(--line-2); border-radius: 999px; padding: 8px 14px; cursor: pointer; min-height: 36px; }
.link-btn:hover { background: var(--accent-soft); border-color: var(--accent); }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: right; padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
thead th { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); padding-top: 0; }
tbody tr:last-child > * { border-bottom: 0; }
tbody th { font-weight: 600; }
.next tbody th { max-width: 200px; }
.next tr.up th { box-shadow: inset 3px 0 0 var(--accent); padding-left: 12px; }
.next tr.down th { box-shadow: inset 3px 0 0 var(--down); padding-left: 12px; }
.next tr.base th { padding-left: 12px; color: var(--ink-2); }
.next tr.base td, .next tr.base th { background: #f6f6f5; }
.num { font-weight: 600; white-space: nowrap; }
.sub { display: block; font-size: 13px; font-weight: 400; color: var(--ink-3); margin-top: 2px; white-space: nowrap; }
.sub.warn { color: #92400e; }
.na { color: var(--ink-3); font-weight: 400; font-size: 14px; }
.recent td:first-child { white-space: nowrap; }
.empty { margin: 0; padding: 18px; background: var(--bg); border-radius: 10px; color: var(--ink-2); }

/* caveats */
.caveats ul { margin: 12px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 32px; }
.caveats li { font-size: 15px; color: var(--ink-2); padding-left: 16px; position: relative; }
.caveats li::before { content: ""; position: absolute; left: 0; top: .7em; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); }
.caveats strong { color: var(--ink); }

.foot { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-3); }
.foot p { margin: 0 0 6px; max-width: 820px; }

@media (max-width: 1000px) {
  .controls { grid-template-columns: 1fr 1fr; }
  .two { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .page { padding-top: 12px; }
  .masthead { padding: 16px 0 18px; }
  .controls { grid-template-columns: 1fr; gap: 14px; padding: 14px; position: static; }
  .seg { display: flex; width: 100%; }
  .seg-opt { flex: 1; }
  .seg-opt span { padding: 0 4px; font-size: 14px; min-height: 40px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px 14px 14px 16px; }
  .stat.now { grid-column: 1 / -1; }
  .stat-line { font-size: 13px; }
  .panel { padding: 18px 14px 14px; border-radius: 12px; }
  .caveats ul { grid-template-columns: 1fr; }
  table { font-size: 14px; }
  th, td { padding: 10px 5px; }
  .next tbody th { font-size: 14px; }
  .sub { white-space: normal; }
  .link-btn { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
