/* Midnight Network — the visual companion to 0DTE Options Decoded / Engineered. */
:root {
  color-scheme: dark;
  --bg: #03111e;
  --panel: #071d2c;
  --surface: #0a2535;
  --input: #041624;
  --border: #233e50;
  --text: #f5f3eb;
  --muted: #a1b6c5;
  --cyan: #39d9ef;
  --gold: #efbb55;
  --mint: var(--cyan);
  --violet: var(--gold);
  --red: #ff817f;
  --amber: var(--gold);
  --halo: #0a394d;
  --shadow: 0 12px 32px #00000020;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  margin: 0;
  background: radial-gradient(ellipse at 80% 0%, var(--halo), transparent 45rem), var(--bg);
  color: var(--text);
  font: 14px/1.6 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.reversal-active {
  --bg: #210e18;
  --panel: #2c1520;
  --surface: #381c29;
  --input: #210e18;
  --border: #7d414d;
  --halo: #6b2439;
}
button, input, select { font: inherit; }
button, a, input, select, summary { outline-offset: 4px; }
:focus-visible { outline: 2px solid var(--cyan); }
::selection { color: var(--bg); background: var(--cyan); }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: wait; }
[hidden] { display: none !important; }
header {
  position: relative;
  min-height: 88px;
  border-bottom: 1px solid var(--border);
  padding: 18px 4%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--bg);
}
header::after {
  content: "";
  position: absolute;
  height: 1px;
  inset: auto 4% -1px;
  background: linear-gradient(90deg, var(--cyan), transparent 42%, transparent 70%, var(--gold));
  opacity: .7;
}
.brand { display: flex; align-items: center; gap: 12px; font-size: 22px; letter-spacing: 2px; line-height: 1.3; }
.brand b { display: block; margin-top: 3px; font-size: 9px; letter-spacing: 2.2px; font-weight: 500; color: var(--muted); }
.brand-icon { width: 42px; height: 42px; flex: none; }
.brand-icon .cyan { stroke: var(--cyan); fill: var(--cyan); }
.brand-icon .gold { stroke: var(--gold); fill: var(--gold); }
.brand-icon path { fill: none; }
nav { display: flex; gap: 28px; color: var(--muted); font-size: 12px; }
nav a { padding: 10px 0; }
nav a:hover, footer a:hover { color: var(--cyan); }
.research-badge { font-size: 9px; letter-spacing: 1.7px; color: var(--muted); white-space: nowrap; }
.research-badge i { font-style: normal; padding: 4px 7px; margin-left: 6px; color: var(--gold); border: 1px solid var(--border); border-radius: 3px; }
main { max-width: 1600px; padding: 34px 4% 22px; margin: auto; }
.page-heading { position: relative; isolation: isolate; display: flex; align-items: end; justify-content: space-between; gap: 36px; padding: 20px 0 32px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.page-heading > :not(.hero-art) { position: relative; z-index: 1; }
.hero-art { position: absolute; z-index: 0; width: 65%; height: 100%; right: 0; bottom: 0; overflow: hidden; pointer-events: none; opacity: .48; mask-image: linear-gradient(90deg, transparent, #000 40%); }
.hero-art svg { width: 100%; height: 100%; }
.hero-art .wave-cyan { stroke: var(--cyan); }
.hero-art .wave-gold { stroke: var(--gold); }
.hero-art .node-cyan { fill: var(--cyan); }
.hero-art .node-gold { fill: var(--gold); }
.eyebrow { font-size: 10px; letter-spacing: 1.8px; font-weight: 600; color: var(--muted); margin: 0 0 9px; }
.page-heading .eyebrow { color: var(--gold); letter-spacing: 2.4px; }
h1 { font-size: clamp(34px, 3.1vw, 48px); line-height: 1.13; font-weight: 750; letter-spacing: -1.6px; margin: 0; }
h1 span { color: var(--muted); font-weight: 400; letter-spacing: -1.3px; }
h2 { font-size: 18px; line-height: 1.3; margin: 0; font-weight: 600; letter-spacing: -.3px; }
.intro { color: var(--muted); font-size: 12px; max-width: 310px; margin: 0 0 4px; text-shadow: 0 1px 8px var(--bg); }
.toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; box-shadow: var(--shadow); }
.mode-switch { background: var(--input); border: 1px solid var(--border); border-radius: 5px; display: flex; padding: 3px; }
.mode-switch button { background: transparent; color: var(--muted); border: 1px solid transparent; border-radius: 3px; font-size: 12px; padding: 8px 14px; min-height: 40px; }
.mode-switch button:hover { color: var(--text); }
.mode-switch button.selected { background: var(--surface); color: var(--cyan); border-color: var(--border); box-shadow: inset 0 -2px var(--cyan); }
.toolbar label { font-size: 12px; color: var(--muted); }
input, select { background: var(--input); border: 1px solid var(--border); color: var(--text); border-radius: 4px; padding: 8px; min-height: 38px; }
input[type=date] { margin-left: 7px; }
.button, #play { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 8px 12px; min-height: 40px; font-size: 12px; }
.button:hover, #play:hover { border-color: var(--cyan); color: var(--cyan); }
.refresh-note { margin-left: auto; color: var(--muted); font-size: 11px; }
.source-banner { border: 1px solid var(--border); border-left: 3px solid var(--cyan); border-radius: 0 5px 5px 0; background: var(--surface); padding: 11px 14px; margin: 16px 0; color: #adebf3; font-size: 12px; }
.source-banner.demo, .source-banner.unavailable { color: #f5ce86; background: #292416; border-color: #625135; border-left-color: var(--gold); }
.source-banner.replay { color: #b5e8f3; background: #102c3b; border-left-color: var(--cyan); }
.playback { display: flex; align-items: center; gap: 15px; padding: 8px 4px 12px; margin-bottom: 16px; font-size: 12px; color: var(--muted); }
.playback input { flex: 1; accent-color: var(--gold); padding: 0; }
.playback strong { color: var(--text); font-variant-numeric: tabular-nums; }
.error, .reversal { padding: 16px; border: 1px solid var(--red); border-left-width: 4px; background: #421d2b; border-radius: 6px; margin: 16px 0; color: #ffdad4; }
.reversal b { display: block; margin-bottom: 4px; color: #fff2ee; }
body.reversal-active header::after { background: var(--red); opacity: 1; }
body.reversal-active .hero-art { opacity: .18; }
.metrics { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin: 18px 0; }
.metric { min-width: 0; border: 1px solid var(--border); border-radius: 7px; padding: 16px 18px; background: var(--panel); min-height: 112px; box-shadow: var(--shadow); }
.metric:first-child { border-top-color: var(--cyan); }
.metric:last-child { border-top-color: var(--gold); }
.metric .label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; }
.metric .value { overflow-wrap: anywhere; font-size: 25px; line-height: 1.4; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.metric .detail { font-size: 10px; color: var(--muted); margin-top: 2px; }
.up { color: var(--cyan); }
.down { color: var(--red); }
.neutral { color: var(--gold); }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 22px; margin-bottom: 18px; min-width: 0; box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.quiet { font-size: 11px; color: var(--muted); }
.pill { font-size: 10px; padding: 3px 8px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); border-radius: 20px; white-space: nowrap; }
.primary-grid { display: grid; grid-template-columns: 2.25fr 1fr; gap: 18px; }
.triple-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.network-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; }
.chart { min-height: 235px; display: flex; align-items: center; justify-content: center; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart.small { min-height: 145px; }
.empty { color: var(--muted); font-size: 12px; padding: 22px; text-align: center; background: var(--input); border: 1px dashed var(--border); border-radius: 6px; width: 100%; }
.legend { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 20px; color: var(--muted); font-size: 10px; margin: 10px 0; }
.legend span { display: flex; align-items: center; gap: 6px; }
.dot { width: 6px; height: 6px; border-radius: 100%; display: inline-block; }
.mint { background: var(--cyan); }
.violet { background: var(--gold); }
.line { display: inline-block; width: 18px; height: 2px; }
.line.dotted { background: repeating-linear-gradient(to right, var(--gold) 0px, var(--gold) 3px, transparent 3px, transparent 6px); }
.footnote { font-size: 11px; line-height: 1.6; color: var(--muted); margin: 13px 0 0; }
.playbook-code { overflow-wrap: anywhere; font: 500 clamp(20px, 2vw, 28px)/1.3 ui-monospace, monospace; color: var(--cyan); margin: 5px 0; }
.playbook-title { font-size: 16px; margin: 0 0 10px; }
.playbook-panel p { font-size: 12px; color: var(--muted); }
.playbook-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); font-size: 11px; }
.playbook-row span:first-child { color: var(--muted); }
.past-playbook { overflow-wrap: anywhere; border-left: 2px solid var(--gold); padding-left: 12px; margin-top: 16px; font-size: 12px; }
.past-playbook small { display: block; color: var(--muted); }
.ema-number { font-size: 32px; margin: 10px 0; color: var(--gold); font-variant-numeric: tabular-nums; }
.direction-row { padding: 12px 0; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 10px; }
.direction-row b { font-size: 12px; font-weight: 500; }
.network-graph { min-height: 290px; display: flex; align-items: center; justify-content: center; }
.network-graph svg { width: 100%; max-height: 350px; }
.forecast-state { font-size: 24px; color: var(--gold); margin: 14px 0; }
.forecast-probs { display: flex; flex-wrap: wrap; gap: 12px; }
.forecast-probs > div { flex: 1; border: 1px solid var(--border); padding: 15px; border-radius: 4px; }
.forecast-probs b { font-size: 24px; display: block; }
.divider { height: 1px; background: var(--border); margin: 22px 0; }
.news-item { font-size: 12px; margin: 12px 0; padding-left: 12px; border-left: 2px solid var(--gold); }
.news-item a:hover { color: var(--cyan); }
.news-item small { display: block; color: var(--muted); font-size: 10px; margin-top: 4px; }
.lab-grid { display: grid; grid-template-columns: 1fr 1.35fr; gap: 36px; }
.body-note { color: var(--muted); font-size: 12px; margin: 0 0 16px; }
.leg-head, .leg-row { display: grid; grid-template-columns: 1fr 1fr 1fr .7fr; gap: 8px; margin: 9px 0; }
.leg-head { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.leg-row input, .leg-row select { width: 100%; min-width: 0; }
.lab-buttons { display: flex; gap: 8px; margin: 16px 0; }
#risk-totals { font-size: 12px; color: var(--muted); }
#risk-totals strong { color: var(--text); }
.table-scroll { overflow: auto; max-height: 360px; }
table { border-collapse: collapse; font-size: 11px; width: 100%; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
th { text-transform: uppercase; letter-spacing: .7px; font-size: 9px; color: var(--muted); background: var(--panel); position: sticky; top: 0; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; }
tbody tr:hover { background: var(--surface); }
.source-panel summary { cursor: pointer; display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.source-panel summary span { color: var(--muted); font-size: 11px; }
.source-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.source-item { border: 1px solid var(--border); padding: 12px; border-radius: 4px; font-size: 11px; overflow-wrap: anywhere; }
.source-item small { display: block; color: var(--muted); }
footer { display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--border); font-size: 10px; color: var(--muted); padding: 18px 0; }
svg text { font-family: ui-sans-serif, system-ui, sans-serif; }
.loading { opacity: .6; }
.chart-title { font-size: 10px; fill: var(--muted); }
@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .primary-grid { grid-template-columns: 1.5fr 1fr; }
  .triple-grid { grid-template-columns: repeat(2, 1fr); }
  .triple-grid .panel:last-child { grid-column: 1/-1; }
  nav { display: none; }
  .intro { max-width: 240px; }
}
@media (max-width: 760px) {
  header { min-height: 76px; padding-block: 14px; }
  .research-badge { font-size: 8px; letter-spacing: 1px; }
  main { padding: 20px 4% 12px; }
  .page-heading { display: block; padding: 16px 0 26px; margin-bottom: 20px; }
  h1 { font-size: 32px; letter-spacing: -1px; }
  h1 span { letter-spacing: -1px; }
  .intro { max-width: 310px; margin-top: 18px; }
  .hero-art { width: 100%; opacity: .22; }
  .primary-grid, .triple-grid, .network-grid, .lab-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric { padding: 13px; }
  .mode-switch { width: 100%; justify-content: center; }
  .mode-switch button { flex: 1; padding: 8px; min-height: 44px; }
  .button, #play, input, select { min-height: 44px; }
  .refresh-note { margin-left: 0; }
  .toolbar { gap: 12px; }
  .panel { padding: 17px; }
  .panel-heading { align-items: start; }
  .source-list { grid-template-columns: 1fr; }
  .source-panel summary { flex-wrap: wrap; }
  .playback { gap: 8px; flex-wrap: wrap; }
  .playback input { flex-basis: 100%; }
  footer { flex-wrap: wrap; }
  .chart { min-height: 190px; }
  .metric .value { font-size: 23px; }
}
@media (max-width: 400px) {
  .research-badge { display: none; }
  .page-heading .eyebrow { font-size: 9px; letter-spacing: 1.8px; }
  h1 { font-size: 29px; }
  .panel-heading { flex-wrap: wrap; }
  .mode-switch button { font-size: 11px; padding-inline: 6px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

.ladder-scroll { max-height: 620px; }
.ladder-cell { width: 25%; }
.ladder-spot td { border-top: 2px solid var(--gold); border-bottom: 2px solid var(--gold); }
