/* Strata — a research bench, not a dashboard.
   The palette is sampled from the project header: near-black with a blue cast,
   and an iridescent cyan-violet-magenta range. Those accents carry structure
   and identity; the data surfaces stay plain, because a chart that competes
   with its own styling is harder to read and easier to distrust. Series colours
   remain distinguishable for the common colour-vision deficiencies, and nothing
   relies on colour alone. No shadows; hairline rules do the work. */

:root {
  /* Dark is the default: the header the app sits under is near-black, and this
     is a tool people read tables in for long stretches. Accents are sampled
     from the header's iridescence — cyan through violet to magenta — and are
     used on structure and series, never as decoration over data. */
  --page: #0a0f1a;
  --panel: #121927;
  --panel-sunken: #18202f;
  --ink: #e4eaf6;
  --ink-muted: #a4b3cd;
  --ink-faint: #8a9ab5;
  --rule: #273450;
  --rule-strong: #3a4c73;
  --accent: #35b6f5;
  --accent-far: #8b7cf0;
  --accent-soft: #10243c;
  --gain: #3fd9a4;
  --loss: #ff6188;
  --focus: #56c7ff;
  --sheen: linear-gradient(90deg, #35b6f5 0%, #8b7cf0 55%, #ff7ac6 100%);
  --on-sheen: #04101f;   /* text that sits on the gradient */
  /* The primary action is the calmest thing that still reads as primary: one
     hue, no gradient. The spectrum stays on identity — the masthead rule, the
     wordmark, the progress bar — where it is not competing with a decision. */
  --action: #1d6ba6;
  --on-action: #f2f8ff;

  --s1: #3fc3f5;
  --s2: #a78bfa;
  --s3: #45e0b8;
  --s4: #f5b36b;
  --s5: #ff7ac6;
  --s6: #7fa6ff;
  --benchmark: #8095b8;

  --display: "Sora", "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
  --condensed: var(--display);
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --rail: 336px;
  --gap: 28px;
  color-scheme: dark;
}

/* Light is offered, not assumed: same hues, inverted weight. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --page: #e7ebf2;
    --panel: #f7f9fc;
    --panel-sunken: #edf1f7;
    --ink: #0d1424;
    --ink-muted: #4d5a75;
    --ink-faint: #7d8aa4;
    --rule: #ccd5e4;
    --rule-strong: #aab6cc;
    --accent: #1170b8;
    --accent-far: #6250c8;
    --accent-soft: #dce8f6;
    --gain: #0f7a55;
    --loss: #c33055;
    --focus: #1170b8;
    --s1: #1170b8;
    --s2: #6250c8;
    --s3: #10806a;
    --s4: #a86a12;
    --s5: #c03e8e;
    --s6: #3a5fbd;
    --benchmark: #75849d;
    /* The gradient has to be restated for light: the neon version is unreadable
       on a pale surface and the wordmark, the button and the progress bar all
       draw from this one token. */
    --sheen: linear-gradient(90deg, #0d63ad 0%, #5842bb 55%, #a8327d 100%);
    --on-sheen: #ffffff;
    --action: #12639f;
    --on-action: #ffffff;
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --page: #e7ebf2;
  --panel: #f7f9fc;
  --panel-sunken: #edf1f7;
  --ink: #0d1424;
  --ink-muted: #4d5a75;
  --ink-faint: #7d8aa4;
  --rule: #ccd5e4;
  --rule-strong: #aab6cc;
  --accent: #1170b8;
  --accent-far: #6250c8;
  --accent-soft: #dce8f6;
  --gain: #0f7a55;
  --loss: #c33055;
  --focus: #1170b8;
  --s1: #1170b8;
  --s2: #6250c8;
  --s3: #10806a;
  --s4: #a86a12;
  --s5: #c03e8e;
  --s6: #3a5fbd;
  --benchmark: #75849d;
  --sheen: linear-gradient(90deg, #0d63ad 0%, #5842bb 55%, #a8327d 100%);
  --on-sheen: #ffffff;
  --action: #12639f;
  --on-action: #ffffff;
  color-scheme: light;
}

* { box-sizing: border-box; }

/* The platform scrollbar is a grey slab on a near-black page. Thin, tinted and
   track-less keeps the rail feeling continuous with what it sits on. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--rule-strong) transparent;
}
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--rule-strong);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); background-clip: content-box; }
*::-webkit-scrollbar-corner { background: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; margin: 0; letter-spacing: -0.005em; }
h1 { font-size: 19px; }
h2 { font-size: 16.5px; }
h3 { font-size: 13.5px; }
p { margin: 0 0 10px; }
a { color: var(--accent); }

button, input, select { font: inherit; color: inherit; }

:where(button, input, select, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 13px; }
.muted { color: var(--ink-muted); }
.faint { color: var(--ink-faint); }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.note { font-size: 13px; color: var(--ink-muted); max-width: 74ch; }

/* ---------- shell ---------- */

.masthead {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 13px 22px 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 60%), var(--panel);
  position: sticky;
  top: 0;
  z-index: 40;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--rule);
}
/* One hairline of the header's spectrum, and the only gradient on the page
   that is purely identity rather than information. */
.masthead::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: var(--sheen);
  opacity: 0.85;
}

.wordmark {
  font-family: var(--display);
  font-weight: 300;
  font-size: 19px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  margin: 0;
  padding-right: 2px;
  background: var(--sheen);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}
@supports not (background-clip: text) { .wordmark { color: var(--ink); } }

.wordmark-sub {
  font-family: var(--display);
  font-weight: 300;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
  margin-left: -8px;
}
/* On a narrow masthead the wordmark alone carries the identity. */
@media (max-width: 720px) { .wordmark-sub { display: none; } }
.masthead .lede { font-size: 13px; color: var(--ink-muted); flex: 1 1 260px; }
.masthead .tools { display: flex; gap: 8px; align-items: center; }
.mode {
  font-family: var(--condensed);
  font-size: 12.5px;
  color: var(--ink-muted);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 3px 8px;
  white-space: nowrap;
}
.mode.live { border-color: var(--gain); color: var(--gain); }

.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); align-items: start; }

.rail {
  position: sticky;
  top: 52px;
  max-height: calc(100vh - 52px);
  overflow-y: auto;
  border-right: 1px solid var(--rule);
  background: var(--panel);
  padding: 12px 12px 36px;
}
.results { padding: 24px 28px 80px; min-width: 0; }

/* ---------- rail controls ---------- */

/* The rail is a stack of cards rather than one long column: each decision —
   which portfolios, how they are weighted, over what window, under what
   assumptions — is its own surface, and the ones a person has settled can be
   folded away. */
.card {
  background: var(--panel-sunken);
  border: 1px solid var(--rule);
  border-radius: 6px;
  margin-bottom: 10px;
  overflow: hidden;
}
.card > header {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
}
.card > header h3 {
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  border: none;
  padding: 0;
  margin: 0;
  flex: 1;
  display: block;
}
.card > header .icon { color: var(--ink-faint); flex: none; display: block; }
.card > header .aside { font-size: 12.5px; color: var(--accent); white-space: nowrap; }
.card > header .chev { color: var(--ink-faint); transition: transform 160ms ease; flex: none; }
.card[data-open="false"] > header .chev { transform: rotate(-90deg); }
.card[data-open="false"] .card-body { display: none; }
.card-body { padding: 0 12px 12px; }
@media (prefers-reduced-motion: reduce) { .card > header .chev { transition: none; } }

.rail > section:not(.card) { margin-bottom: 22px; }
.rail h3 {
  font-family: var(--display);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-bottom: 5px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.tabs { display: flex; gap: 5px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--rule);
  background: var(--panel-sunken);
  border-radius: 2px;
  padding: 4px 9px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tab[aria-selected="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.mode.live { border-color: color-mix(in srgb, var(--gain) 60%, transparent); }
.tab .swatch { width: 9px; height: 9px; border-radius: 50%; }
.tab.add { border-style: dashed; color: var(--ink-muted); }

/* Explicit steppers rather than the browser's number spinners: those are hidden
   until hover in most browsers, clipped at this width, and impossible to hit on
   a touch screen. */
.holding {
  display: grid;
  grid-template-columns: 1fr 22px 42px 22px 10px 18px;
  gap: 4px;
  align-items: center;
  margin-bottom: 5px;
}
.holding .unit { font-size: 11.5px; color: var(--ink-faint); font-family: var(--mono); text-align: center; }
.holding input.weight { text-align: center; padding: 5px 2px; }
.holding input.weight::-webkit-outer-spin-button,
.holding input.weight::-webkit-inner-spin-button { appearance: none; margin: 0; }
.holding input.weight { appearance: textfield; -moz-appearance: textfield; }

.step {
  border: 1px solid var(--rule);
  background: var(--panel);
  color: var(--ink-muted);
  border-radius: 3px;
  height: 26px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  font-family: var(--mono);
}
.step:hover:not(:disabled) { color: var(--ink); border-color: var(--rule-strong); }
.step:disabled { opacity: 0.35; cursor: default; }
.holding input {
  background: var(--page);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 5px 7px;
  min-width: 0;
  width: 100%;
}
.holding input.ticker { text-transform: uppercase; font-family: var(--mono); font-size: 13px; }
.holding input.weight { font-family: var(--mono); font-size: 13px; text-align: right; }
.holding .remove {
  border: none;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 2px;
  line-height: 1;
  font-size: 16px;
}
.holding .remove:hover { color: var(--loss); }

/* Each holding's share in its own colour, so the split is readable before the
   analysis runs and the totals line below is a confirmation, not the only cue. */
.weightbar {
  height: 6px;
  background: var(--panel);
  display: flex;
  gap: 2px;
  margin: 10px 0 7px;
  border-radius: 3px;
  overflow: hidden;
}
.weightbar span { height: 100%; border-radius: 2px; min-width: 2px; }

.group-label {
  display: block;
  font-size: 11.5px;
  color: var(--ink-muted);
  margin: 12px 0 6px;
}

.rowline { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.field { display: grid; grid-template-columns: 1fr 108px; gap: 8px; align-items: center; margin-bottom: 8px; font-size: 13px; }
/* Two columns for the settings that are read together, stacked label over
   control so neither is squeezed. */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
  align-items: end;
}
.field-grid label { display: block; font-size: 11.5px; color: var(--ink-muted); margin-bottom: 4px; line-height: 1.3; }
.field-grid input, .field-grid select {
  background: var(--page);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 6px 8px;
  width: 100%;
  font-size: 13px;
}
.field-grid input[type="number"], .field-grid input[type="date"] { font-family: var(--mono); }
.field-grid .span2 { grid-column: 1 / -1; }
.field.wide { grid-template-columns: 1fr; }
.field input, .field select {
  background: var(--page);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 5px 7px;
  width: 100%;
}
.field input[type="number"], .field input[type="date"] { font-family: var(--mono); font-size: 13px; }

.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--rule);
  background: var(--panel-sunken);
  border-radius: 2px;
  padding: 3px 8px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--ink-muted);
}
.chip:hover { border-color: var(--rule-strong); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }

.button.ghost {
  width: 100%;
  margin-top: 2px;
  border-style: dashed;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px;
}
.button.ghost:hover { color: var(--ink); }

.run-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.presets-label { display: block; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); margin: 16px 0 7px; }
.run-row .button { display: flex; align-items: center; justify-content: center; gap: 6px; }
.button.primary { display: flex; align-items: center; justify-content: center; gap: 8px; border-radius: 4px; }

.button {
  border: 1px solid var(--rule-strong);
  background: var(--panel-sunken);
  border-radius: 2px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13.5px;
}
.button:hover:not(:disabled) { border-color: var(--accent); }
.button:disabled { opacity: 0.5; cursor: progress; }
.button.primary {
  background: var(--action);
  border-color: var(--action);
  color: var(--on-action);
  width: 100%;
  padding: 10px;
  font-size: 14px;
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.button.primary:hover:not(:disabled) { filter: brightness(1.14); }

.advanced summary { cursor: pointer; font-size: 13px; color: var(--ink-muted); list-style-position: outside; }
.advanced[open] summary { margin-bottom: 10px; }

/* ---------- results plates ---------- */

.plate { border-top: 1px solid var(--rule); padding-top: 16px; margin-bottom: var(--gap); }
.plate:first-of-type { border-top: none; padding-top: 0; }
.plate > header { margin-bottom: 12px; display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap; }
.plate > header h2 { flex: 0 0 auto; }
.plate > header .method { font-size: 12.5px; color: var(--ink-muted); flex: 1 1 320px; }

.hero {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0) 120px), var(--panel);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 4px 0 0;
}
.legend { display: flex; gap: 14px; flex-wrap: wrap; padding: 10px 14px 4px; font-size: 13px; }
.legend button {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  padding: 2px 0;
  color: var(--ink-muted);
}
.legend button[aria-pressed="true"] { color: var(--ink); border-bottom-color: currentColor; }
.legend .swatch { width: 11px; height: 11px; border-radius: 2px; flex: none; }

table.data { border-collapse: collapse; width: 100%; font-size: 13.5px; }
table.data th {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-align: right;
  padding: 6px 10px 6px 0;
  border-bottom: 1px solid var(--rule-strong);
  white-space: nowrap;
}
table.data th:first-child, table.data td:first-child { text-align: left; padding-left: 8px; }
table.data td {
  text-align: right;
  padding: 7px 10px 7px 0;
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 13px;
}
table.data td.label { font-family: var(--sans); font-size: 13.5px; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover { background: var(--panel-sunken); }
table.data tbody tr[aria-selected="true"] { background: var(--accent-soft); }
table.data td .swatch { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 7px; }
table.data .scroll { overflow-x: auto; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: var(--gap); }

.bars { display: grid; gap: 7px; }
.bars .row { display: grid; grid-template-columns: 150px 1fr 62px; gap: 10px; align-items: center; font-size: 13px; }
.bars .track { height: 13px; background: var(--panel-sunken); border: 1px solid var(--rule); position: relative; }
.bars .fill { position: absolute; top: 0; bottom: 0; }
.bars .value { text-align: right; font-family: var(--mono); font-size: 12.5px; }

.matrix { border-collapse: collapse; font-size: 12px; font-family: var(--mono); }
.matrix th { font-family: var(--condensed); font-weight: 600; padding: 3px 6px; color: var(--ink-muted); font-size: 12px; }
.matrix th.side { text-align: right; }
.matrix td { padding: 5px 7px; text-align: right; border: 1px solid var(--panel); min-width: 46px; }

.callouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); }
.callout {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0)), var(--panel);
  padding: 11px 13px;
}
.callout .k {
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: block;
}
.callout .v { font-family: var(--mono); font-size: 21px; display: block; margin-top: 3px; line-height: 1.2; }
.callout .sub { font-size: 12px; color: var(--ink-faint); }

.rail-error { color: var(--loss); font-size: 12.5px; margin: 0 0 6px; }
.holding input.ticker.unknown { border-color: var(--loss); color: var(--loss); }

.flags { display: grid; gap: 8px; margin-bottom: var(--gap); }
.flag {
  border-left: 3px solid var(--s4);
  background: var(--panel);
  padding: 9px 13px;
  font-size: 13px;
  color: var(--ink-muted);
}
.flag.error { border-left-color: var(--loss); color: var(--ink); }

.assumptions { columns: 2 300px; column-gap: 34px; font-size: 13px; color: var(--ink-muted); }
.assumptions dl { margin: 0; break-inside: avoid; }
.assumptions dt { font-family: var(--condensed); color: var(--ink); margin-top: 9px; }
.assumptions dd { margin: 0 0 2px; }

.empty { max-width: 58ch; padding: 40px 0; }
.empty h2 { margin-bottom: 10px; }

.chart {
  display: block;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.hero .chart { background: none; border: none; border-radius: 0; }
.chart text { font-family: var(--condensed); font-size: 11px; fill: var(--ink-faint); }
.chart .axis line, .chart .axis path { stroke: var(--rule); }
.chart .gridline { stroke: var(--rule); stroke-dasharray: 2 3; }
.chart .zeroline { stroke: var(--rule-strong); }
.chart .seam { stroke: var(--ink-muted); stroke-dasharray: 3 3; }
.chart .seam-label { fill: var(--ink-muted); font-family: var(--condensed); }
.chart .series { fill: none; stroke-width: 1.8; stroke-linejoin: round; }
.chart .series.dim { stroke-width: 1.2; opacity: 0.6; }
.chart .series.bench { stroke-dasharray: 5 3; }
.chart .band { stroke: none; }
.chart .crosshair { stroke: var(--ink-muted); }
.readout {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 6px 14px 12px;
  font-size: 12.5px;
  color: var(--ink-muted);
  min-height: 30px;
}
.readout .k { font-family: var(--mono); color: var(--ink); }

.progress {
  height: 4px;
  background: var(--panel-sunken);
  border: 1px solid var(--rule);
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--sheen);
  transition: width 220ms ease-out;
}
.progress-line { font-size: 12.5px; color: var(--ink-muted); line-height: 1.35; }
@media (prefers-reduced-motion: reduce) { .progress-fill { transition: none; } }

.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--rule-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

.footer { border-top: 1px solid var(--rule-strong); padding-top: 12px; font-size: 12.5px; color: var(--ink-faint); max-width: 80ch; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; max-height: none; border-right: none; border-bottom: 1px solid var(--rule-strong); }
  .results { padding: 20px 16px 60px; }
  .assumptions { columns: 1; }
}
