:root {
  color-scheme: light;
  --bg: #fbfaf8;
  --panel: #fff;
  --ink: #16181d;
  --muted: #5d6572;
  --line: #e6e4df;
  --accent: #1a56db;
  --accent-bg: #f2f6ff;
  --good: #11684d;
  --good-bg: #e9f6f0;
  --warn: #825300;
  --warn-bg: #fcf2df;
  --bad: #a52235;
  --quiet-bg: #eeedf0;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131417;
  --panel: #1b1d22;
  --ink: #e8e8ea;
  --muted: #a1a7b2;
  --line: #30333b;
  --accent: #80aaff;
  --accent-bg: #1e2a40;
  --good: #78d5b0;
  --good-bg: #1a352f;
  --warn: #f4c86b;
  --warn-bg: #352a18;
  --bad: #ff9ba8;
  --quiet-bg: #292b32;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #131417;
    --panel: #1b1d22;
    --ink: #e8e8ea;
    --muted: #a1a7b2;
    --line: #30333b;
    --accent: #80aaff;
    --accent-bg: #1e2a40;
    --good: #78d5b0;
    --good-bg: #1a352f;
    --warn: #f4c86b;
    --warn-bg: #352a18;
    --bad: #ff9ba8;
    --quiet-bg: #292b32;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, select, input { font: inherit; }
button, select, input[type="checkbox"] { cursor: pointer; }
button:disabled { opacity: .65; cursor: wait; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, p, dl, dd { margin: 0; }
h1 { font-size: clamp(27px, 4vw, 37px); line-height: 1.16; letter-spacing: -.035em; font-weight: 650; }
h2 { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }

.wrap { max-width: 1200px; padding: 28px 24px 48px; margin-inline: auto; }
.site-header, .page-head, .score-head, .history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
}
.site-header { padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.brand { font-size: 20px; color: var(--ink); font-weight: 650; }
.controls, .refresh { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.monitor-link { margin-inline-end: 5px; font-size: 13px; }
.control {
  min-height: 36px;
  max-width: 100%;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font-size: 12px;
}
.control:hover { border-color: var(--accent); }
.theme { min-width: 36px; font-size: 16px; }
.page-head { align-items: flex-end; margin: 30px 0 18px; }
.subhead { color: var(--muted); margin-top: 8px; }
.refresh { gap: 10px; }
.note { color: var(--muted); font-size: 12px; }
.mono, .numeric { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.notice {
  margin: 0 0 16px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 13px;
}

.symbol-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-width: 540px;
  margin-bottom: 12px;
}
.symbol-option {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 2px 8px;
  min-width: 0;
  min-height: 44px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  font: 650 14px/1.4 var(--mono);
  text-align: start;
}
.symbol-option:hover, .symbol-option[aria-pressed="true"] { border-color: var(--accent); }
.symbol-option[aria-pressed="true"] { background: var(--accent-bg); }
.symbol-status { color: var(--muted); font: 500 12px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.symbol-status[data-kind="up"] { color: var(--good); }
.symbol-status[data-kind="unavailable"] { color: var(--warn); }

.panel { border: 1px solid var(--line); border-radius: 9px; background: var(--panel); }
.forecast { display: grid; grid-template-columns: minmax(195px, .82fr) minmax(0, 2.6fr); }
.forecast-overview {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 19px 18px;
  border-inline-end: 1px solid var(--line);
}
.forecast-overview h2 { color: var(--muted); font-size: 12px; }
.target-date { margin: 4px 0 10px; font: 600 22px/1.4 var(--mono); }
.signal-status {
  display: inline-block;
  border-radius: 5px;
  padding: 3px 8px;
  color: var(--muted);
  background: var(--quiet-bg);
  font-weight: 650;
  line-height: 1.45;
}
.signal-status[data-kind="up"] { color: var(--good); background: var(--good-bg); }
.signal-status[data-kind="unavailable"] { color: var(--warn); background: var(--warn-bg); }
#decision-reason { margin-top: 8px; }
#captured-at { margin-top: 6px; }
.rule-inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rule-inputs > div { padding: 19px 16px; min-width: 0; }
.rule-inputs > div + div { border-inline-start: 1px solid var(--line); }
.rule-inputs dt { font-size: 13px; font-weight: 600; }
.metric-value { margin: 12px 0 4px; font: 600 clamp(17px, 2.4vw, 24px)/1.3 var(--mono); overflow-wrap: anywhere; }
.metric-source { margin-top: 10px; overflow-wrap: anywhere; }
.metric-extra { display: block; margin-top: 3px; }
.cadence { margin-top: 9px; }

.section { margin-top: 27px; }
.futures-panel { margin-top: 9px; }
.futures-observation { padding: 9px 16px; }
.futures-panel dl:not([hidden]) + .futures-observation { border-top: 1px solid var(--line); }
.cta-amount { font: 550 clamp(13px, 1.8vw, 16px)/1.4 var(--mono); overflow-wrap: anywhere; }
.cta-context { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; }
.futures-history { margin-top: 8px; }
.futures-history summary { padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer; }
.futures-history-head { padding: 0 16px 6px; }
.history-chart { min-width: 0; padding: 2px 16px 10px; }
.history-chart-controls, .history-chart-dates { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.history-chart-controls { margin-bottom: 8px; }
.history-chart-controls .control, .history-chart-dates input { min-width: 36px; font-family: var(--mono); }
.history-chart-controls .control[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--panel); }
.history-chart-controls .control:disabled { opacity: .45; cursor: default; }
.history-chart-nav { display: flex; gap: 6px; margin-inline-start: auto; }
.history-chart-dates { gap: 6px 12px; margin-bottom: 8px; }
.history-chart-dates input { padding-inline: 7px; }
.history-plot { position: relative; min-width: 0; }
.history-plot svg { display: block; width: 100%; height: 220px; cursor: crosshair; touch-action: pan-y; }
.history-grid, .history-zero { stroke: var(--line); }
.history-zero { stroke: var(--muted); stroke-opacity: .55; }
.history-axis { fill: var(--muted); font: 11px var(--mono); }
.history-line { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.history-area { fill: var(--accent); fill-opacity: .1; }
.history-point { fill: var(--accent); }
.history-cursor { stroke: var(--ink); stroke-dasharray: 3 3; }
.history-cursor-point { stroke: var(--panel); stroke-width: 2; }
.history-selection { fill: var(--accent); fill-opacity: .15; stroke: var(--accent); }
.history-tip { position: absolute; top: 4px; max-width: 100%; z-index: 2; pointer-events: none;
  padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
  box-shadow: 0 2px 12px #0002; font: 12px/1.5 var(--mono); }
.history-tip span { display: block; color: var(--muted); }
.history-tip b { color: var(--ink); }
.history-chart-help { margin-top: 4px; }
@media (max-width: 560px) { .history-chart-nav { margin-inline-start: 0; } }
.futures-history .futures-table { max-height: 270px; border-top: 1px solid var(--line); }
.futures-history .futures-table table { min-width: 535px; }
.futures-history .cta-table table { min-width: 590px; }
.cta-history-controls { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.history-source { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.replay-info { margin-top: 8px; }
.score { margin-top: 9px; padding: 13px 16px; }
.score-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; margin-bottom: 6px; }
.score-metrics dt { color: var(--muted); font-size: 12px; }
.score-metrics dd { font: 600 20px/1.5 var(--mono); }
.score-metrics small { margin-inline-start: 7px; color: var(--muted); font: 12px var(--mono); white-space: nowrap; }

.history-head { margin-bottom: 10px; }
.check { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.check { min-height: 36px; padding-inline: 4px; cursor: pointer; }
.check input { margin: 0; accent-color: var(--accent); width: 15px; height: 15px; }
.table-scroll { max-height: 60dvh; overflow: auto; }
.table-scroll table { width: 100%; min-width: 830px; border-spacing: 0; font-size: 12px; text-align: start; }
.table-scroll thead { position: sticky; top: 0; z-index: 1; background: var(--panel); }
.table-scroll th, .table-scroll td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: start; }
.table-scroll thead th { color: var(--muted); font-size: 11px; font-weight: 600; line-height: 1.35; white-space: nowrap; }
.table-scroll tbody th { font-weight: 550; }
.table-scroll tr:last-child > * { border-bottom: 0; }
.table-scroll thead tr:last-child > * { border-bottom: 1px solid var(--line); }
.table-scroll .numeric { text-align: end; }
.table-scroll .signal-status { padding: 2px 6px; white-space: nowrap; }
.cell-detail { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.cell-detail[data-result="hit"] { color: var(--good); }
.cell-detail[data-result="miss"] { color: var(--bad); }
.cell-detail[data-result="flat"] { color: var(--warn); }
.nowrap { white-space: nowrap; }
.method { border-top: 1px solid var(--line); padding-top: 16px; }
.method p { margin-top: 6px; color: var(--muted); font-size: 13px; max-width: 103ch; }
footer { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 24px; padding-top: 12px; border-top: 1px solid var(--line); }

@media (max-width: 830px) {
  .forecast { grid-template-columns: minmax(0, 1fr); }
  .forecast-overview { border-inline-end: 0; border-bottom: 1px solid var(--line); }
}

@media (max-width: 560px) {
  .wrap { padding: 18px 16px 36px; }
  .site-header { gap: 8px; }
  .page-head { margin-top: 21px; }
  .rule-inputs { grid-template-columns: minmax(0, 1fr); }
  .rule-inputs > div { padding: 13px 15px; }
  .rule-inputs > div + div { border-inline-start: 0; border-top: 1px solid var(--line); }
  .metric-value { margin-top: 5px; }
  .metric-source { margin-top: 4px; }
  .symbol-option { min-height: 52px; }
}
