/* Vasconomics — Market Overlay Charts.
   The design system of the Vasconomics Spinoff Researcher: a black masthead band,
   a single research-desk column (max 1180px), hairline cards, Observable Plot
   charts. Every colour in this file is a token defined in the first three
   blocks; nothing below them names a colour. Root size is 17px (the app was
   raised from 15 deliberately), so rem-based sizes scale with it, and text that
   carries a qualification never drops under 0.88rem (about 15px). */

:root {
  --paper: #f5f6f8;
  --surface: #ffffff;
  --sunk: #eef0f3;
  --ink: #141920;
  --ink-2: #4f5966;
  --line: #dce0e6;
  --navy: #1f3a5f;
  --link: #1f5d99;
  --signal: #c8553d;
  --good: #1b7a49;
  --bad: #b3432b;
  /* Series colours. 1-3 are the design system's category colours; 4-6 extend
     them for a comparison of up to six windows. Order is the order rows take
     them in, and server/palette.py carries the same list. */
  --cat-1: #0b6fa8;
  --cat-2: #a8740a;
  --cat-3: #b14d86;
  --cat-4: #1c944f;
  --cat-5: #872110;
  --cat-6: #444936;
  --proj: #5b6b7f;
  --focus: var(--cat-1);
  /* The masthead band is black in both themes. */
  --mast: #0b0d10;
  --mast-ink: #f2f4f7;
  --mast-ink-2: #9aa3ae;
  --mast-line: #1d232b;
  --mast-hover: #161b22;
  --mast-btn-line: #2a313a;
  --hero-lede: #b6bec8;
  --hero-lab: #97a1ad;
  --hero-rule: #262d36;
  --hero-big: #ffffff;
  --hero-em: #b9c6d6;
  --signal-on-dark: #e3826a;
  --shadow-ink: rgba(10, 20, 35, 0.45);
  --scrim: rgba(20, 25, 32, 0.55);
  --font-display: "Newsreader", "Iowan Old Style", Georgia, serif;
  --font-body: "Public Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --wrap: 1180px;
  --radius: 6px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0d1116; --surface: #151a21; --sunk: #1b222b; --ink: #e8ecf1; --ink-2: #9ba5b2; --line: #28303a;
    --navy: #9dbbe0; --link: #7fb2e6; --signal: #e3826a; --good: #4cc489; --bad: #ef8a6f;
    --cat-1: #4aa6e0; --cat-2: #e1a83c; --cat-3: #e08abb; --cat-4: #75e296; --cat-5: #db6a50; --cat-6: #888e79;
    --proj: #8c9cb0;
    --mast: #05070a; --mast-ink-2: #8d97a3;
    --shadow-ink: rgba(0, 0, 0, 0.6);
    --scrim: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0d1116; --surface: #151a21; --sunk: #1b222b; --ink: #e8ecf1; --ink-2: #9ba5b2; --line: #28303a;
  --navy: #9dbbe0; --link: #7fb2e6; --signal: #e3826a; --good: #4cc489; --bad: #ef8a6f;
  --cat-1: #4aa6e0; --cat-2: #e1a83c; --cat-3: #e08abb; --cat-4: #75e296; --cat-5: #db6a50; --cat-6: #888e79;
  --proj: #8c9cb0;
  --mast: #05070a; --mast-ink-2: #8d97a3;
  --shadow-ink: rgba(0, 0, 0, 0.6);
  --scrim: rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: 17px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font-body); font-size: 1rem; line-height: 1.55; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--mast); }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
h1, h2, h3 { margin: 0; text-wrap: balance; }
h1, h2 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 1.65rem; line-height: 1.2; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0; }
code, .mono { font-family: var(--font-data); font-size: 0.9em; }
.num { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.eyebrow { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--signal); }
.muted { color: var(--ink-2); }
.small { font-size: 0.88rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* masthead */
.mast { background: var(--mast); color: var(--mast-ink); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; border-bottom: 1px solid var(--mast-line); }
.mast .wrap { display: flex; align-items: center; gap: 24px; padding-block: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.brand a { color: inherit; text-decoration: none; }
.brand .v { font-family: var(--font-display); font-size: 1.32rem; font-weight: 600; letter-spacing: 0.01em; }
.brand .t { font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--mast-ink-2); font-weight: 600; }
.brand .t:hover { color: var(--mast-ink); }
nav.tabs { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; }
nav.tabs a { color: var(--mast-ink-2); text-decoration: none; font-size: 0.9rem; font-weight: 600; padding: 7px 12px; border-radius: 4px; }
nav.tabs a:hover { color: var(--mast-ink); background: var(--mast-hover); }
nav.tabs a[aria-current="page"] { color: var(--mast-ink); box-shadow: inset 0 -2px 0 var(--mast-ink); border-radius: 0; }
.theme-btn { background: none; border: 1px solid var(--mast-btn-line); color: var(--mast-ink-2); border-radius: 4px; padding: 5px 9px; font: inherit; font-size: 0.8rem; cursor: pointer; }
.theme-btn:hover { color: var(--mast-ink); }
@media (max-width: 720px) {
  .mast .wrap { gap: 8px 12px; }
  nav.tabs { margin-left: 0; width: 100%; order: 3; overflow-x: auto; flex-wrap: nowrap; }
  .theme-btn { margin-left: auto; }
}

main { padding-block: 0 72px; }
.tab[hidden] { display: none; }

/* hero: slim, so the chart starts right under the console */
.hero { background: var(--mast); color: var(--mast-ink); }
.hero .wrap { padding-block: 22px 70px; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 10px 32px; align-items: start; }
.hero .wrap > div:first-child { grid-row: 1 / span 2; }
.hero .eyebrow { color: var(--signal-on-dark); }
.hero h1 { font-size: clamp(1.45rem, 2.9vw, 2rem); line-height: 1.12; font-weight: 500; margin-top: 8px; }
.hero h1 em { font-style: italic; color: var(--hero-em); }
.hero-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--hero-rule); }
.hero-stats > div { padding: 12px 12px 0 0; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hero-stats .big { font-family: var(--font-data); font-size: 1.55rem; color: var(--hero-big); font-variant-numeric: tabular-nums; line-height: 1.2; }
.hero-stats .lab { font-size: 0.88rem; color: var(--hero-lab); line-height: 1.35; }
.hero-stats .lab b { display: block; color: var(--mast-ink); font-weight: 600; }
.hero-foot { grid-column: 2; display: flex; gap: 6px 12px; flex-wrap: wrap; align-items: center; font-size: 0.88rem; color: var(--hero-lab); }
.hero-foot select { font: inherit; font-size: 0.88rem; max-width: 100%; background: var(--mast-hover); color: var(--mast-ink); border: 1px solid var(--mast-btn-line); border-radius: 4px; padding: 3px 6px; }
.hero .pill { color: var(--hero-lab); }
@media (max-width: 860px) {
  .hero .wrap { grid-template-columns: minmax(0, 1fr); padding-block: 22px 72px; gap: 18px; }
  .hero-foot { grid-column: 1; }
  .hero .wrap > div:first-child { grid-row: auto; }
  .hero-stats .big { font-size: 1.3rem; }
}

/* console */
.console { margin-top: -52px; position: relative; z-index: 2; }
.console-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 14px 40px -24px var(--shadow-ink); display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr); }
.console-main { padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; border-right: 1px solid var(--line); min-width: 0; }
.console-side { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
@media (max-width: 960px) { .console-card { grid-template-columns: minmax(0, 1fr); } .console-main { border-right: 0; border-bottom: 1px solid var(--line); } }
@media (max-width: 520px) { .console-main, .console-side { padding: 16px; } }
.console.is-waking .console-main > *:not(.wake), .console.is-waking .console-side .live { opacity: 0.55; pointer-events: none; }

/* series rows */
.row-head, .srow { display: grid; grid-template-columns: minmax(70px, 0.9fr) minmax(90px, 1.5fr) minmax(128px, 1.2fr) minmax(128px, 1.2fr) 58px 58px 38px; gap: 8px; align-items: center; }
.row-head { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); padding: 0 0 6px; border-bottom: 1px solid var(--line); }
.srow-wrap { display: flex; flex-direction: column; gap: 3px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.srow-wrap:last-of-type { border-bottom: 0; }
.srow input[type="text"], .srow input[type="date"], .hero-foot select, .field-select {
  font: inherit; font-size: 0.95rem; width: 100%; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); color: var(--ink);
}
.srow input[name="symbol"] { font-family: var(--font-data); font-size: 0.92rem; text-transform: none; }
.srow input[type="date"] { font-family: var(--font-data); font-size: 0.8rem; padding: 7px 6px; }
.srow input:disabled { opacity: 0.6; }
.swatch { position: relative; display: block; width: 38px; height: 34px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; justify-self: center; }
.swatch input { position: absolute; inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px); opacity: 0; cursor: pointer; }
.switch { position: relative; width: 40px; height: 22px; justify-self: center; display: block; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 11px; background: var(--sunk); border: 1px solid var(--line); transition: background 0.12s ease; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--ink-2); transition: transform 0.12s ease, background 0.12s ease; }
.switch input:checked + span { background: var(--navy); border-color: var(--navy); }
.switch input:checked + span::after { transform: translateX(18px); background: var(--surface); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.icon-btn { width: 36px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--radius); background: none; color: var(--ink-2); cursor: pointer; padding: 0; }
.icon-btn:hover:not(:disabled) { color: var(--bad); border-color: var(--bad); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.row-note { font-size: 0.88rem; color: var(--ink-2); padding-left: 2px; min-height: 1.3em; overflow-wrap: anywhere; }
.row-note.err { color: var(--bad); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
@media (max-width: 860px) {
  .row-head { display: none; }
  .srow { grid-template-columns: repeat(6, minmax(0, 1fr)); grid-template-areas: "sym sym sym sym sym sym" "lbl lbl lbl lbl lbl lbl" "sd sd sd ed ed ed" "col col vis vis del del"; }
  .srow > [data-f="symbol"] { grid-area: sym; } .srow > [data-f="label"] { grid-area: lbl; }
  .srow > [data-f="start"] { grid-area: sd; } .srow > [data-f="end"] { grid-area: ed; }
  .srow > [data-f="color"] { grid-area: col; justify-self: start; } .srow > [data-f="visible"] { grid-area: vis; } .srow > [data-f="delete"] { grid-area: del; justify-self: end; }
}

/* buttons, segmented controls, pills, chips */
.btn { font: inherit; font-weight: 700; font-size: 0.92rem; padding: 9px 16px; border-radius: var(--radius); border: 1px solid var(--navy); background: var(--navy); color: var(--surface); cursor: pointer; white-space: nowrap; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover:not(:disabled) { border-color: var(--ink-2); }
.btn.small { padding: 6px 12px; font-size: 0.88rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); flex-wrap: wrap; }
.seg button { font: inherit; font-size: 0.88rem; font-weight: 600; padding: 7px 12px; background: none; border: 0; border-right: 1px solid var(--line); color: var(--ink-2); cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg button:disabled { cursor: not-allowed; opacity: 0.6; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 0.72rem; letter-spacing: 0.09em; text-transform: uppercase; padding: 3px 8px; border-radius: 3px; border: 1px solid currentColor; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pos { color: var(--good); } .neg { color: var(--bad); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cat-2); flex: none; }
.dot.on { background: var(--good); }
.engine { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; font-size: 0.88rem; margin: 0; }
.kv dt { color: var(--ink-2); } .kv dd { margin: 0; }
.notice { border-left: 3px solid var(--cat-2); background: var(--sunk); padding: 10px 12px; border-radius: 0 var(--radius) var(--radius) 0; font-size: 0.88rem; }
.notice.bad { border-left-color: var(--bad); }
.empty { padding: 28px; text-align: center; color: var(--ink-2); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); display: flex; flex-direction: column; gap: 8px; align-items: center; }

/* side panel */
.examples { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.examples button { text-align: left; background: var(--surface); border: 0; border-bottom: 1px solid var(--line); padding: 8px 12px; font: inherit; color: var(--ink); cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.examples button:last-child { border-bottom: 0; }
.examples button:hover:not(:disabled) { background: var(--sunk); }
.examples button b { font-size: 0.92rem; font-weight: 600; }
.examples button span { display: none; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.92rem; cursor: pointer; }
.check input { margin-top: 4px; accent-color: var(--navy); }
.check small { display: block; color: var(--ink-2); font-size: 0.88rem; line-height: 1.4; }

/* waking the engine */
.wake[hidden] { display: none; }
.wake { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sunk); }
.wake strong { font-size: 0.95rem; }
.wake p { font-size: 0.88rem; color: var(--ink-2); }
.bar { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--navy); border-radius: 3px; transition: width 0.6s ease; }
.wake-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* blocks and the chart figure */
.stack { display: flex; flex-direction: column; gap: 40px; margin-top: 36px; }
.block-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid var(--ink); margin-bottom: 18px; }
.block-head h2 { margin-top: 4px; }
.block-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 14px 24px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.ctl { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ctl > .eyebrow { color: var(--ink-2); }
.toggle { display: flex; align-items: center; gap: 9px; font-size: 0.92rem; min-height: 33px; }
.toggle .switch { justify-self: auto; }
.toggle[aria-disabled="true"] { opacity: 0.55; }
.help-line { font-size: 0.88rem; color: var(--ink-2); margin: -4px 0 14px; max-width: 80ch; }
.fig { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 24px; position: relative; }
@media (max-width: 960px) { .fig { grid-template-columns: minmax(0, 1fr); gap: 18px; } }
@media (max-width: 520px) { .fig { padding: 14px 12px; } }
.fig .chart { min-width: 0; position: relative; }
.fig .txt { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.fig .txt h3 { font-family: var(--font-display); font-size: 1.25rem; line-height: 1.25; font-weight: 600; }
.fig ul { margin: 0; padding-left: 1.1em; display: flex; flex-direction: column; gap: 8px; font-size: 0.92rem; }
.fig.is-loading::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--navy), transparent); background-size: 40% 100%; background-repeat: no-repeat; animation: sweep 1.1s linear infinite; }
@keyframes sweep { from { background-position: -40% 0; } to { background-position: 140% 0; } }
.fig.is-stale .chart { opacity: 0.7; }
.legend { display: flex; gap: 6px 18px; flex-wrap: wrap; font-size: 0.88rem; color: var(--ink); margin-bottom: 4px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 18px; height: 0; border-top: 3px solid; display: inline-block; }
.legend i.dash { border-top-style: dashed; }
.y-title { font-size: 0.8rem; color: var(--ink-2); margin-bottom: 2px; }
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; max-width: 100%; height: auto; }
.tip { position: absolute; pointer-events: none; z-index: 5; background: var(--surface); border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius); box-shadow: 0 10px 30px -18px var(--shadow-ink); padding: 7px 10px; font-size: 0.82rem; line-height: 1.45; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tip b { display: block; font-weight: 700; }
.tip[hidden] { display: none; }
.snap-note { font-size: 0.88rem; color: var(--ink-2); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 9px 16px; border-radius: var(--radius); font-size: 0.9rem; z-index: 40; }
.toast[hidden] { display: none; }

/* placeholder tabs */
.soon { padding-block: 40px; display: flex; flex-direction: column; gap: 18px; }

footer { border-top: 1px solid var(--line); padding-block: 24px 40px; color: var(--ink-2); font-size: 0.88rem; }
footer .wrap { display: flex; flex-direction: column; gap: 6px; }
@media (prefers-reduced-motion: no-preference) { .btn, .examples button, .seg button { transition: background 0.12s ease, border-color 0.12s ease; } }
@media (prefers-reduced-motion: reduce) { .fig.is-loading::before { animation: none; } .bar i { transition: none; } }
