/* StrikeBench — design system. No build step, CSS variables, light+dark, mobile-first. */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --surface-3: #e3e8f0;
  --text: #17202e;
  --text-dim: #5c6675;
  --text-faint: #8b95a5;
  --border: #dbe1ea;
  --border-strong: #c3ccd9;
  --accent: #2f6bde;
  --accent-soft: #e5edfc;
  --accent-fg: #ffffff;

  /* Risk palette (accessible fg/bg pairs) */
  --risk-danger: #c93c3c;
  --risk-danger-bg: #fdecec;
  --risk-warn: #c26410;
  --risk-warn-bg: #fdf1e3;
  --risk-caution: #96700a;
  --risk-caution-bg: #fbf3cf;
  --risk-ok: #177245;
  --risk-ok-bg: #e5f6ec;

  --gain: #177245;
  --loss: #c93c3c;
  /* Solid fill for danger buttons/banners: always paired with white text */
  --risk-danger-solid: #c93c3c;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 40px rgba(10, 16, 28, .28);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* Dark palette. JS sets html[data-theme] before first paint (system preference or the
   header toggle); components only ever read the variables, so everything follows. */
:root[data-theme="dark"] {
    --bg: #0e1219;
    --surface: #171d28;
    --surface-2: #1f2735;
    --surface-3: #2a3446;
    --text: #e7ecf4;
    --text-dim: #9aa5b6;
    --text-faint: #6d788a;
    --border: #2a3242;
    --border-strong: #3a4557;
    --accent: #6b96ef;
    --accent-soft: #1d2a44;
    --accent-fg: #0b1322;
    --risk-danger: #ef7d7d;
    --risk-danger-bg: #3b1d1d;
    --risk-warn: #eda15b;
    --risk-warn-bg: #382614;
    --risk-caution: #dfc65a;
    --risk-caution-bg: #322d10;
    --risk-ok: #56d391;
    --risk-ok-bg: #123324;
    --gain: #56d391;
    --loss: #ef7d7d;
    --risk-danger-solid: #8f2f2f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 1px 4px rgba(0, 0, 0, .4);
    --shadow-lg: 0 14px 48px rgba(0, 0, 0, .6);
}

.theme-toggle {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.theme-toggle:hover { border-color: var(--border-strong); }

#stale-banner {
  position: sticky; top: 0; z-index: 30; background: var(--risk-danger-solid); color: #fff;
  padding: 10px 16px; font-size: 14px; font-weight: 600; text-align: center;
}
/* When the banner is up, the topbar pins just below it instead of fighting for top:0 */
body.has-stale-banner .topbar { top: var(--stale-banner-h, 42px); }
#stale-banner code { background: rgba(255,255,255,.18); padding: 1px 6px; border-radius: 5px; font-weight: 500; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.55 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 8px 11px;
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  padding: 10px 18px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20; box-shadow: var(--shadow);
}
.brand {
  font-weight: 800; font-size: 16.5px; letter-spacing: -.01em; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.brand:hover { text-decoration: none; }
.brand-mark { display: block; flex: none; border-radius: 6px; }
.nav { display: flex; flex-wrap: wrap; gap: 2px; }
.nav a {
  padding: 6px 11px; border-radius: 8px; color: var(--text-dim); font-weight: 600; font-size: 13.5px;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.topbar-controls { margin-left: auto; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px 12px; min-width: 0; }
.risk-select { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.risk-select select { padding: 4px 8px; font-size: 12.5px; border-radius: 7px; }
/* Experience ladder: segmented control */
.level-switch {
  display: inline-flex; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px; gap: 2px;
}
.level-switch button {
  border: none; background: none; color: var(--text-dim); font-size: 12px; font-weight: 700;
  padding: 4px 11px; border-radius: 999px; transition: background .12s, color .12s;
}
.level-switch button:hover { color: var(--text); }
.level-switch button.active { background: var(--accent); color: var(--accent-fg); }

/* ---------- Layout ---------- */
.app { flex: 1; width: 100%; max-width: 1060px; margin: 0 auto; padding: 20px 16px 40px; }
.disclaimer {
  border-top: 1px solid var(--border); color: var(--text-faint); font-size: 12px;
  padding: 14px 18px; text-align: center; background: var(--surface); line-height: 1.5;
}
.loading { color: var(--text-dim); padding: 32px; text-align: center; font-size: 14px; }
.spin {
  display: inline-block; width: 15px; height: 15px; vertical-align: -2px; margin-right: 6px;
  border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

h1 { font-size: 21px; letter-spacing: -.01em; margin: 2px 0 16px; }
h2 { font-size: 15.5px; margin: 22px 0 10px; letter-spacing: -.005em; }
h3 { font-size: 14.5px; margin: 12px 0 8px; }
.mt0 { margin-top: 0; }
.page-sub { color: var(--text-dim); margin: -10px 0 18px; font-size: 13.5px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }

.grid { display: grid; gap: 12px; }
@media (min-width: 700px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

.stat { padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius-sm); min-width: 0; }
.stat .label { font-size: 11px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-size: 18px; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-hero .value { font-size: 26px; }

/* ---------- Buttons ---------- */
.btn {
  background: var(--accent); color: var(--accent-fg); border: none; border-radius: 9px;
  padding: 9px 16px; font-weight: 650; font-size: 14px; transition: filter .12s, transform .05s;
}
.btn:hover { filter: brightness(1.09); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); }
.btn-danger { background: var(--risk-danger-solid); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 7px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }

/* ---------- Badges & chips ---------- */
.badge {
  display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .05em;
  padding: 2.5px 9px; border-radius: 999px; vertical-align: middle; white-space: nowrap;
}
.badge-ok { background: var(--risk-ok-bg); color: var(--risk-ok); }
.badge-warn { background: var(--risk-warn-bg); color: var(--risk-warn); }
.badge-caution { background: var(--risk-caution-bg); color: var(--risk-caution); }
.badge-danger { background: var(--risk-danger-bg); color: var(--risk-danger); }
.badge-dim { background: var(--surface-3); color: var(--text-dim); }

.chip {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 5px 11px;
  background: var(--surface-2); border-radius: 999px; font-size: 12.5px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chip .chip-label { color: var(--text-dim); font-weight: 600; }
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0; }

.gain { color: var(--gain); font-weight: 650; font-variant-numeric: tabular-nums; }
.loss { color: var(--loss); font-weight: 650; font-variant-numeric: tabular-nums; }
.delta { font-size: 14px; }

/* ---------- Explainers adapt to the ladder ---------- */
.explain {
  display: block; font-size: 12.5px; color: var(--text-dim); background: var(--accent-soft);
  border-left: 3px solid var(--accent); border-radius: 6px; padding: 7px 11px 7px 30px; margin: 8px 0; line-height: 1.45;
  position: relative;
}
.explain .explain-ico {
  position: absolute; left: 9px; top: 8px; color: var(--accent); display: inline-flex;
}
.explain .explain-ico svg { display: block; }
body.lvl-beginner .explain { font-size: 13px; }
body.lvl-expert .explain { display: none; }

/* Level-scoped elements */
body:not(.lvl-beginner) .beginner-only { display: none !important; }
body:not(.lvl-expert) .expert-only { display: none !important; }
body.lvl-expert .not-expert { display: none !important; }

/* Pro density: tighter everything, data first */
/* Levels differ by CONTENT (explainers, columns, features) — NEVER by padding or font
   size alone. Toggling Beginner/Expert must not reflow a screen that shows the same data;
   the old expert "density" overrides did exactly that and are gone. */

/* ---------- Expandable disclosure ---------- */
.xp { border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 8px 0; background: var(--surface); }
.xp-head {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: none; border: none; color: var(--text); font-weight: 650; font-size: 13.5px;
  padding: 10px 12px; border-radius: var(--radius-sm);
}
.xp-head:hover { background: var(--surface-2); }
.xp-chevron { color: var(--text-faint); font-weight: 800; transition: transform .15s; display: inline-block; }
.xp.open .xp-chevron { transform: rotate(90deg); }
.xp-body { display: none; padding: 0 14px 12px 32px; font-size: 13.5px; color: var(--text-dim); line-height: 1.55; }
.xp.open .xp-body { display: block; animation: xp-in .15s ease-out; }
@keyframes xp-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.xp-body ol, .xp-body ul { margin: 6px 0; padding-left: 18px; }
.xp-body li { margin: 3px 0; }
.xp .fact-row { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 6px 0; }

/* Glossary terms + popover */
.term {
  background: none; border: none; padding: 0; font: inherit; color: inherit;
  border-bottom: 1px dotted var(--accent); cursor: help;
}
.popover {
  position: absolute; z-index: 80; max-width: 290px; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow-lg);
  padding: 10px 12px; font-size: 12.5px; line-height: 1.5;
}
.popover-title { font-weight: 800; margin-bottom: 3px; text-transform: capitalize; }
.popover-body { color: var(--text-dim); }

/* Big plain-language facts (Learning candidate cards) */
.fact-grid { display: grid; gap: 8px; grid-template-columns: repeat(3, 1fr); margin: 10px 0 4px; }
@media (max-width: 560px) { .fact-grid { grid-template-columns: 1fr; } }
.fact { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.fact .f-label { font-size: 11px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: .05em; }
.fact .f-value { font-size: 17px; font-weight: 750; margin-top: 2px; font-variant-numeric: tabular-nums; }
.fact.f-danger .f-value { color: var(--loss); }
.fact.f-ok .f-value { color: var(--gain); }

/* Safety checklist (review step) */
.checklist { margin: 10px 0; }
.checklist .ck {
  display: flex; gap: 9px; align-items: baseline; padding: 6px 4px;
  border-bottom: 1px solid var(--border); font-size: 13.5px;
}
.checklist .ck:last-child { border-bottom: none; }
.ck-mark { font-weight: 900; }
.ck-pass .ck-mark { color: var(--risk-ok); }
.ck-warn .ck-mark { color: var(--risk-warn); }
.ck-fail .ck-mark { color: var(--risk-danger); }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius-sm); padding: 10px 13px; margin: 10px 0; font-size: 13.5px; line-height: 1.45; }
.alert-danger { background: var(--risk-danger-bg); color: var(--risk-danger); }
.alert-warn { background: var(--risk-warn-bg); color: var(--risk-warn); }
.alert-ok { background: var(--risk-ok-bg); color: var(--risk-ok); }
.alert ul { margin: 5px 0 0 18px; padding: 0; }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .form-grid { grid-template-columns: repeat(3, 1fr); } }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--text-dim); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select { width: 100%; }
.inline-check { display: flex; gap: 7px; align-items: center; font-size: 13.5px; }
.inline-check input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- Tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.tbl th {
  text-align: left; color: var(--text-faint); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
.tbl tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tr.clickable:hover { background: var(--accent-soft); cursor: pointer; }
.tbl tr.atm td { background: var(--accent-soft); font-weight: 650; }
.tbl td.itm { background: color-mix(in srgb, var(--risk-ok-bg) 55%, transparent); }
.tbl-wrap { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }

/* ---------- Tabs & wizard ---------- */
.tabs { display: flex; gap: 2px; margin-bottom: 14px; border-bottom: 2px solid var(--border); }
.tabs button {
  background: none; border: none; padding: 9px 16px; color: var(--text-dim); font-weight: 650; font-size: 14px;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

.wizard-steps { display: flex; gap: 0; margin-bottom: 18px; overflow-x: auto; padding-bottom: 2px; }
.wizard-steps .step {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 12px; font-weight: 650;
  color: var(--text-faint); white-space: nowrap; position: relative;
}
.wizard-steps .step::after { content: '›'; margin-left: 10px; color: var(--border-strong); }
.wizard-steps .step:last-child::after { content: ''; }
.wizard-steps .step .dot {
  width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-3); color: var(--text-dim); font-size: 11px; font-weight: 800;
}
.wizard-steps .step.active { color: var(--text); }
.wizard-steps .step.active .dot { background: var(--accent); color: var(--accent-fg); }
.wizard-steps .step.done { color: var(--risk-ok); }
.wizard-steps .step.done .dot { background: var(--risk-ok-bg); color: var(--risk-ok); }

.choice-row { display: grid; gap: 10px; margin: 14px 0; grid-template-columns: 1fr; }
@media (min-width: 700px) { .choice-row { grid-template-columns: 1fr 1fr; } }
.choice {
  border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text);
  border-radius: var(--radius-sm); padding: 13px 16px; font-weight: 650; text-align: left;
  transition: border-color .1s, background .1s; font-size: 14px;
}
.choice small { display: block; font-weight: 500; color: var(--text-dim); margin-top: 3px; font-size: 12.5px; }
.choice:hover { border-color: var(--accent); }
.choice.selected { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Candidate cards ---------- */
.candidate {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
  margin-bottom: 14px; background: var(--surface); box-shadow: var(--shadow);
}
.candidate .head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.candidate .head h3 { margin: 0; font-size: 15.5px; }
.candidate .label-line { color: var(--text-dim); font-size: 13px; margin: 3px 0 2px; font-family: var(--mono); }
.score-wrap { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.score-num { font-weight: 800; font-size: 16px; color: var(--text); }
.score-bar { width: 64px; height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; display: inline-block; }
.score-fill { display: block; height: 100%; border-radius: 999px; }
.score-ok { background: var(--risk-ok); }
.score-caution { background: var(--risk-caution); }
.score-danger { background: var(--risk-danger); }

.qa { font-size: 13px; margin: 10px 0 0; }
.qa summary { cursor: pointer; font-weight: 650; color: var(--accent); font-size: 13px; }
.qa dl { margin: 8px 0 0; }
.qa dt { font-weight: 700; margin-top: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); }
.qa dd { margin: 2px 0 0 0; color: var(--text-dim); }

/* ---------- Quote header / dashboard tiles ---------- */
.quote-hero { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 16px; }
.quote-hero .px { font-size: 34px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.quote-hero .sym { font-size: 19px; font-weight: 800; }
.quote-hero .nm { color: var(--text-dim); font-size: 13.5px; }

.tile-row { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) { .tile-row { grid-template-columns: repeat(4, 1fr); } }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; cursor: pointer; transition: border-color .1s, transform .06s;
}
.tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.tile .t-sym { font-weight: 800; font-size: 14px; }
.tile .t-px { font-size: 20px; font-weight: 750; margin: 2px 0; font-variant-numeric: tabular-nums; }
.tile .t-nm { color: var(--text-faint); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sym-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.sym-chip {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-dim);
  border-radius: 999px; padding: 4px 13px; font-weight: 700; font-size: 12.5px;
}
.sym-chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .zero { stroke: var(--text-dim); stroke-dasharray: 4 3; stroke-width: 1.2; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; }
.chart .area-gain { fill: var(--risk-ok); opacity: .14; }
.chart .area-loss { fill: var(--risk-danger); opacity: .14; }
.chart .area-line { fill: var(--accent); opacity: .1; }
.chart text { fill: var(--text-faint); font-size: 10.5px; font-family: var(--font); }
.chart .marker { stroke: var(--risk-warn); stroke-width: 1.6; stroke-dasharray: 3 3; }
.chart .be-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart .be-label { font-weight: 700; fill: var(--text-dim); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(8, 12, 20, .55); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border-radius: var(--radius); max-width: 540px; width: 100%;
  padding: 22px; box-shadow: var(--shadow-lg); max-height: 85vh; overflow-y: auto;
  border: 1px solid var(--border);
}
.modal h3 { margin-top: 0; font-size: 17px; }

/* ---------- Status & lists ---------- */
.status-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 2px;
  border-bottom: 1px solid var(--border); font-size: 13.5px;
}
.status-item:last-child { border-bottom: none; }

.empty { text-align: center; padding: 40px 16px; }
.empty-title { font-weight: 700; font-size: 15.5px; margin-bottom: 5px; }
.empty-hint { color: var(--text-dim); font-size: 13.5px; margin-bottom: 14px; }

.rationale { margin: 8px 0 4px; padding-left: 20px; font-size: 13.5px; color: var(--text-dim); }
.rationale li { margin: 2px 0; }
.pick-card .candidate { margin-top: 8px; box-shadow: none; }

.intent-note { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); border-left: 3px solid var(--accent);
  padding: 7px 10px; border-radius: 0 8px 8px 0; font-size: 13.5px; margin: 4px 0 8px; }
/* Pro: intent chooser collapses from story cards to a dense segmented row */
.intent-compact { display: flex; flex-wrap: wrap; gap: 6px; }
.intent-compact .choice { padding: 6px 12px; flex: 0 0 auto; }
.intent-compact .choice b { display: inline; margin: 0; font-size: 13px; }
/* Confident: blurbs clamp to one line (tap a card to select; the title attr has the rest) */
/* Pro: filters sit inline, no card chrome doubling */
.compact-filters { padding: 10px 14px; margin: 8px 0; }
.compact-filters .form-grid.grid-5 { grid-template-columns: repeat(5, 1fr); gap: 8px; }
@media (max-width: 700px) { .compact-filters .form-grid.grid-5 { grid-template-columns: repeat(2, 1fr); } }
#intent-choices .choice { text-align: left; }
#intent-choices .choice b { display: block; margin-bottom: 2px; }
#holdings-card td .btn-row { flex-wrap: nowrap; }

.compare-detail > td { background: var(--surface-2); padding: 10px 12px; }
.compare-detail .candidate { margin: 0; box-shadow: none; }
.custom-leg select, .custom-leg input { padding: 5px 8px; font-size: 13px; }

.muted { color: var(--text-dim); font-size: 12.5px; }
.spacer { flex: 1; }
.mono { font-family: var(--mono); font-size: 12.5px; }

.bottom-nav { display: none; }

@media (max-width: 640px) {
  .nav { display: none; }
  .topbar { gap: 6px 10px; }
  .topbar-controls { gap: 6px 8px; }
  .level-switch button { padding: 4px 8px; font-size: 11.5px; }
  .app { padding: 14px 10px 84px; }
  .card { padding: 14px; }
  .quote-hero .px { font-size: 28px; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    justify-content: space-around;
  }
  .bottom-nav a {
    display: flex; flex-direction: column; align-items: center; gap: 1px;
    font-size: 10.5px; font-weight: 700; color: var(--text-faint); padding: 3px 10px; border-radius: 8px;
  }
  .bottom-nav a.active { color: var(--accent); }
  .bottom-nav .bn-ico { line-height: 1; }
  .disclaimer { padding-bottom: 76px; }
}

/* ---- Ticker tape: seamless marquee of the active universe ---- */
.tape { display: flex; align-items: center; gap: 4px; background: var(--surface); border-bottom: 1px solid var(--border); padding-left: 8px; }
.tape-sector { flex: 0 0 auto; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-dim); font-size: 11.5px; font-weight: 700; padding: 3px 8px; cursor: pointer;
  border-radius: 999px; max-width: 170px; margin: 4px 0; }
.tape-sector:hover { color: var(--text); border-color: var(--border-strong); }
.tape-scroll { overflow: hidden; white-space: nowrap; flex: 1; min-width: 0; margin-left: 8px;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 56px, #000 calc(100% - 40px), transparent);
  mask-image: linear-gradient(90deg, transparent 0, #000 56px, #000 calc(100% - 40px), transparent); }
.tape-seq { display: inline-flex; }
.tape-strip { display: inline-flex; gap: 0; animation: tape-scroll linear infinite; will-change: transform; }
.tape:hover .tape-strip { animation-play-state: paused; }

#global-search { background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px; width: 150px;
  transition: width .15s ease, border-color .15s ease; }
#global-search:focus { width: 200px; border-color: var(--accent); outline: none; }
@media (max-width: 900px) { #global-search { display: none; } }

.sector-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 10px; }
.sector-chip { border: 1px solid var(--border); background: var(--surface); color: var(--text-dim);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease; }
.sector-chip:hover { border-color: var(--border-strong); color: var(--text); }
.sector-chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.sector-tile { min-width: 150px; }
.welcome-live-card { max-width: 720px; margin: 0 auto; }
.tape-item { display: inline-flex; gap: 7px; align-items: baseline; padding: 6px 14px; border: 0; background: none;
  color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer; border-right: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.tape-item b { font-weight: 700; }
.tape-item:hover { background: var(--surface-2); }
@keyframes tape-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .tape { overflow-x: auto; }
  .tape-strip { animation: none; }
}

/* ---- Chart interactivity ---- */
.chart-wrap { position: relative; }
.chart-tip { position: absolute; pointer-events: none; z-index: 5; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 7px 10px; box-shadow: var(--shadow-lg);
  font-size: 12.5px; line-height: 1.45; min-width: 110px; }
.chart-tip .tt-title { font-weight: 700; margin-bottom: 2px; }
.chart .xhair { stroke: var(--text-faint); stroke-dasharray: 3 3; }
.chart .xhair-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.range-pills { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.range-pills .pill { border: 1px solid var(--border); background: var(--surface); color: var(--text-dim);
  border-radius: 999px; padding: 4px 11px; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease; }
.range-pills .pill:hover { border-color: var(--border-strong); color: var(--text); }
.range-pills .pill.active { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.chart-summary { margin: 2px 0 8px; }
.chart.chart-down .line { stroke: var(--loss); }
.chart.chart-down .area-line { fill: var(--risk-danger-bg); }

/* "Coming up" events: chips are the unit; links stay chip-shaped */
.events-strip { margin: 2px 0 10px; }
#events-card .chip-row a.chip, .events-strip a.chip { text-decoration: none; }
#events-card .chip-row a.chip:hover b, .events-strip a.chip:hover b { color: var(--accent); }

/* ---- Sector rail: THE sector affordance everywhere (home / research / trade) ---- */
.sector-rail-wrap { display: flex; align-items: center; gap: 4px; min-width: 0; }
.sector-rail { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px;
  scrollbar-width: none; flex: 1; min-width: 0; }
.sector-rail::-webkit-scrollbar { display: none; }
/* Fades ONLY where there is actually more to see — paired with the arrows below */
.sector-rail-wrap.can-right .sector-rail { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 34px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 34px), transparent); }
.sector-rail-wrap.can-left .sector-rail { -webkit-mask-image: linear-gradient(90deg, transparent, #000 34px);
  mask-image: linear-gradient(90deg, transparent, #000 34px); }
.sector-rail-wrap.can-left.can-right .sector-rail {
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 34px, #000 calc(100% - 34px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 34px, #000 calc(100% - 34px), transparent); }
.rail-arrow { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-dim); font-size: 17px; line-height: 1; cursor: pointer;
  display: none; align-items: center; justify-content: center; padding: 0 0 2px; }
.rail-arrow:hover { border-color: var(--accent); color: var(--accent); }
.sector-rail-wrap.can-left .rail-arrow-left { display: inline-flex; }
.sector-rail-wrap.can-right .rail-arrow-right { display: inline-flex; }
.sector-rail .sector-chip { flex: none; display: inline-flex; align-items: center; gap: 7px; }
.sr-delta { font-size: 11px; font-weight: 700; }
.sr-delta:empty { display: none; }

/* Explorer tiles open the focus panel above the grid */
.sector-tile.clickable { cursor: pointer; }
.sector-tile.open { border-color: var(--accent); }
.symbol-panel { border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; background: var(--surface-2); }
.sp-quote { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.sp-sym { font-size: 16px; }
.sp-px { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sp-nm { font-size: 12.5px; }
.sp-news { margin-top: 8px; }
#symbol-context { margin: 10px 0; }
#universe-sym-chips { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }

/* Segmented toggle (Active|Closed etc.): one control, card-header friendly */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.seg button { border: none; background: transparent; height: 30px; padding: 0 16px; font-weight: 600;
  font-size: 13px; color: var(--text-dim); cursor: pointer; }
.seg button.active { background: var(--accent-soft); color: var(--accent); }
.card-slim { padding: 10px 16px; }
.card-slim .chip-row { margin: 0; }

/* Explorer focus slot: the tapped symbol's panel opens HERE, above the grid */
.focus-wrap { position: relative; margin-bottom: 12px; animation: xp-in .18s ease; }
.focus-close { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-dim);
  font-size: 16px; line-height: 1; cursor: pointer; z-index: 1; }
.focus-close:hover { border-color: var(--accent); color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .focus-wrap { animation: none; } }

/* Wizard steps are now <button>s; earned steps are live links */
.wizard-steps button.step { background: none; border: 0; font: inherit; padding: 0;
  display: inline-flex; align-items: center; }
.wizard-steps .step-link { cursor: pointer; }
.wizard-steps .step-link:hover { color: var(--accent); }
.wizard-steps .step[disabled] { cursor: not-allowed; opacity: .55; }

/* Fine-tune rows on the builder's Where-you-stand */
.tune-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 0;
  border-bottom: 1px solid var(--border); }
.tune-row:last-child { border-bottom: 0; }
.tune-row select { max-width: 130px; }
.tune-row label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }

/* Draggable strike handles on the payoff chart */
.strike-line { stroke: var(--accent); stroke-dasharray: 4 4; stroke-width: 1.4; opacity: .75; }
.strike-grip { fill: var(--surface); stroke: var(--accent); stroke-width: 2.2; cursor: grab;
  touch-action: none; }
.strike-grip:hover { fill: var(--accent-soft); }
.strike-grip.dragging { cursor: grabbing; fill: var(--accent-soft); r: 10; }
.strike-grip-label { font-size: 10.5px; font-weight: 800; fill: var(--accent); pointer-events: none; }
.xhair, .xhair-dot { pointer-events: none; } /* the crosshair is decoration, never a target */

/* ---- Home hero band: the opening page's DNA folded into the dashboard ---- */
.home-hero { position: relative; overflow: hidden; padding: 18px 20px 14px; margin-bottom: 14px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.home-hero::before { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(900px 320px at 10% -50%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%); }
.home-hero > * { position: relative; }
.home-hero-top { display: flex; gap: 14px 18px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.home-hero-top #home-stats { flex: 1 1 460px; max-width: 560px; margin: 0; }
.home-hero .eyebrow { margin-bottom: 6px; }
.home-hero-title { margin: 0; font-size: clamp(22px, 2.6vw, 30px); line-height: 1.15; letter-spacing: -0.02em; }
.home-hero-title .grad { background: linear-gradient(92deg, var(--accent), #8b5cf6);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.home-hero-sub { margin: 4px 0 0; font-size: 13.5px; color: var(--text-dim); }
.home-hero-ctas { display: flex; gap: 8px; flex-wrap: wrap; }
.home-hero .stat { background: color-mix(in srgb, var(--surface-2) 78%, transparent); }

@media (min-width: 1100px) {
  #app[data-route="home"] .home-hero { padding: 12px 18px; margin-bottom: 12px; }
  #app[data-route="home"] .home-hero-sub { display: none; } /* the title carries it at desktop */
  #app[data-route="home"] .home-hero .eyebrow { margin-bottom: 2px; font-size: 10.5px; }
  #app[data-route="home"] .home-hero-title { font-size: 21px; white-space: nowrap; }
  #app[data-route="home"] .home-hero .stat { padding: 7px 10px; }
  #app[data-route="home"] .home-hero .stat .value { font-size: 14.5px; white-space: nowrap; }
  #app[data-route="home"] .home-hero .stat .label { white-space: nowrap; }
}

/* Welcome hero: brand line + a quiet payoff-tent motif behind the pitch */
.hero-brandline { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.hero-brandline .eyebrow { margin-bottom: 0; }
.hero-deco { position: absolute; right: -30px; bottom: -12px; width: 340px; height: 150px;
  opacity: .10; pointer-events: none; }
.hero-deco path { stroke: var(--accent); stroke-width: 2.5; fill: none;
  stroke-linecap: round; stroke-linejoin: round; }
.hero-deco .deco-zero { stroke: var(--text-faint); stroke-width: 1.2; stroke-dasharray: 3 5; }
/* Door cards: honest doors, not gray boxes */
#welcome-levels .welcome-card { position: relative; border-top: 3px solid var(--accent);
  transition: border-color .15s ease, transform .15s ease; }
#welcome-levels .welcome-card:last-child { border-top-color: #7c4fe0; }
#welcome-levels .welcome-card:hover { transform: translateY(-2px); }
#welcome-levels .welcome-card .btn { align-self: flex-start; }

/* ---- Welcome / opening page: designed, not typed ---- */
.hero { position: relative; padding: 68px 16px 46px; overflow: hidden; }
.hero::before { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(900px 420px at 50% -12%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%); }
.hero-inner { position: relative; max-width: 780px; margin: 0 auto; text-align: center; }
.eyebrow { font-size: 11.5px; font-weight: 800; letter-spacing: 0.14em; color: var(--accent); margin-bottom: 14px; }
.hero-title { font-size: clamp(34px, 5.2vw, 54px); line-height: 1.08; letter-spacing: -0.02em; margin: 0 0 16px; }
.hero-title .grad { background: linear-gradient(92deg, var(--accent), #8b5cf6);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { font-size: 17px; line-height: 1.6; color: var(--text-dim); max-width: 620px; margin: 0 auto 24px; }
.hero-ctas { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 22px; }
.btn-lg { padding: 12px 26px; font-size: 15px; border-radius: 12px; }
.wb-stages button[disabled] { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; border: 1px solid var(--border-strong); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.trust-row { font-size: 13px; color: var(--text-faint); }
.trust-row .dot-sep { margin: 0 10px; }

.welcome-section { max-width: 980px; margin: 0 auto; padding: 34px 8px 6px; text-align: center; }
.welcome-h2 { margin: 0 0 20px; font-size: 26px; letter-spacing: -0.01em; }
.welcome-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; text-align: left; }
.welcome-card { padding: 22px 20px; }
.welcome-card h3 { margin: 12px 0 6px; font-size: 16.5px; }
.welcome-card p { margin: 0 0 14px; color: var(--text-dim); font-size: 13.5px; line-height: 1.55; }
.icon-tile { width: 42px; height: 42px; border-radius: 11px; display: flex; align-items: center;
  justify-content: center; background: var(--accent-soft); color: var(--accent); }
.icon { display: inline-flex; }

.showcase { max-width: 760px; margin: 0 auto; }
.showcase-frame { border: 1px solid var(--border); border-radius: 16px; padding: 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 5%, var(--surface)), var(--surface));
  box-shadow: var(--shadow-lg); text-align: left; }
.showcase-frame .candidate { margin: 0; box-shadow: none; }
.showcase-caption { font-size: 13px; color: var(--text-faint); margin: 12px auto 0; max-width: 560px; }
.showcase-loading { padding: 24px; }

.stepper { display: flex; gap: 0; justify-content: center; flex-wrap: wrap; text-align: left; }
.step-block { display: flex; align-items: flex-start; gap: 12px; padding: 8px 26px 8px 0; position: relative; }
.step-block:not(:last-child)::after { content: ''; position: absolute; right: 6px; top: 26px;
  width: 14px; height: 2px; background: var(--border-strong); }
.step-num { font-family: var(--mono); font-size: 26px; font-weight: 700; line-height: 1.2;
  color: color-mix(in srgb, var(--accent) 55%, var(--text-faint)); }
.step-text { display: flex; flex-direction: column; max-width: 170px; }
.step-text b { font-size: 14.5px; }
.step-text span { font-size: 12.5px; color: var(--text-dim); }

.cta-banner { display: flex; align-items: center; justify-content: space-between; gap: 18px;
  max-width: 900px; margin: 34px auto 0; padding: 20px 24px; border-radius: 16px;
  border: 1px solid var(--border); background: var(--accent-soft); flex-wrap: wrap; }
.cta-banner p { margin: 4px 0 0; font-size: 13.5px; }
.welcome-exit { text-align: center; margin: 26px 0 10px; }

/* ---- Micro-polish: motion that respects the user's settings ---- */
.card { transition: box-shadow .18s ease, transform .18s ease; }
.tile:hover, .pick-card:hover { transform: translateY(-1px); }
.btn { transition: filter .12s ease, transform .05s ease; }
.btn:active { transform: scale(0.98); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  .card, .btn, .tile, .pick-card, .range-pills .pill { transition: none; }
  .tile:hover, .pick-card:hover, .btn:active { transform: none; }
}

/* ---- Intent-native ladders & action cards ---- */
.ladder-sentences { display: flex; flex-direction: column; gap: 8px; }
.ladder-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); flex-wrap: wrap; }
.ladder-row.recommended { border-color: var(--accent); background: var(--accent-soft); }
.ladder-tbl tr.ladder-recommended > td { background: var(--accent-soft); }
.action-grid .action-card { text-align: left; padding: 14px; }
.action-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.action-line { min-height: 38px; }
.scout-group { margin: 18px 0 8px; }
.sym-chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ==================================================================================
   UNIFIED CONTROL SCALE — one design language for every interactive element.
   Standard controls (inputs, selects, date pickers, buttons) share --ctl-h; chips and
   small buttons share --ctl-h-sm; header controls share --ctl-h-xs. Nothing freelances.
   ================================================================================== */
:root { --ctl-h: 38px; --ctl-h-sm: 30px; --ctl-h-xs: 30px; }

.app input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
.app select {
  height: var(--ctl-h); padding: 0 11px; box-sizing: border-box; font-size: 14px;
}
.app select { padding-right: 26px; }
.app textarea { padding: 8px 11px; box-sizing: border-box; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--ctl-h); padding: 0 16px; box-sizing: border-box;
}
.btn-sm { min-height: var(--ctl-h-sm); padding: 0 12px; }
.btn-lg { min-height: 46px; padding: 0 26px; }

/* Chips are one scale, whatever they select. */
.sym-chip, .sector-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: var(--ctl-h-sm); padding: 0 12px; box-sizing: border-box;
}

/* Header controls: intentionally compact, but identical to EACH OTHER. */
.topbar-controls #global-search, .risk-select select, .theme-toggle {
  height: var(--ctl-h-xs); box-sizing: border-box;
}
.theme-toggle { display: inline-flex; align-items: center; gap: 5px; }
.theme-toggle .icon { display: inline-flex; }
.theme-toggle .icon svg { display: block; }

/* ---------- Scout goal selector (single choice, radio semantics) ---------- */
.field-label {
  font-size: 12px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .04em; margin: 2px 0 6px;
}
.goal-row { display: flex; flex-wrap: wrap; gap: 8px; }
.goal-chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: var(--ctl-h); padding: 0 15px; box-sizing: border-box; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-dim);
  font-weight: 650; font-size: 13.5px; transition: border-color .12s, color .12s, background .12s;
}
.goal-chip .icon { display: inline-flex; }
.goal-chip .icon svg { display: block; }
.goal-chip:hover { border-color: var(--accent); color: var(--accent); }
.goal-chip.selected { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.goal-blurb { margin: 8px 2px 14px; font-size: 13px; min-height: 1.2em; }

/* ---------- Icon plumbing (SVG everywhere; emoji are banned) ---------- */
.choice-head { display: flex; align-items: center; gap: 8px; }
.choice-head .icon { display: inline-flex; color: var(--accent); }
.choice-head .icon svg { display: block; }
.icon-tile-sm { width: 34px; height: 34px; border-radius: 9px; flex: none; }
.icon-tile-sm .icon svg { width: 18px; height: 18px; }
.action-head { display: flex; align-items: center; gap: 10px; }
.bn-ico svg { width: 18px; height: 18px; display: block; margin: 0 auto 1px; }
#stale-banner .icon { display: inline-flex; vertical-align: -2px; margin-right: 3px; }
#stale-banner .icon svg { display: block; }

/* ---------- Sector explorer: every tile actionable, even without a quote ---------- */
.tile-nodata { opacity: .8; }
.tile-nodata .t-px { color: var(--text-dim); }

/* ---------- Overflow hygiene: grids and flex rows must never push the page wide ---------- */
.form-grid .field, .grid > *, .compact-filters .field { min-width: 0; }
.field input, .field select { max-width: 100%; }
.btn-row { min-width: 0; }
#app { overflow-x: clip; }

/* ==================================================================================
   SMOOTH RENDER PIPELINE — skeletons, route crossfade, progressive card arrival.
   ================================================================================== */

/* Route crossfade: only #app participates; header/tape/footer swap instantly so the
   marquee never appears frozen inside a transition snapshot. */
#app { view-transition-name: app-main; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
::view-transition-old(app-main) { animation: sb-fade-out .14s ease both; }
::view-transition-new(app-main) { animation: sb-fade-in .16s ease both; }
@keyframes sb-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes sb-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Skeleton: a quiet placeholder, never a blank void. */
.skel-screen { padding-top: 4px; }
.skel {
  border-radius: var(--radius-sm);
  background: linear-gradient(100deg, var(--surface-2) 40%, var(--surface-3) 50%, var(--surface-2) 60%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.3s ease-in-out infinite;
}
.skel-title { height: 30px; width: 240px; max-width: 60%; margin: 8px 0 16px; }
.skel-row { display: grid; gap: 12px; grid-template-columns: repeat(4, 1fr); margin-bottom: 16px; }
@media (max-width: 700px) { .skel-row { grid-template-columns: 1fr 1fr; } }
.skel-stat { height: 72px; }
.skel-card { height: 180px; margin-bottom: 16px; }
.skel-card-short { height: 110px; }
@keyframes skel-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Progressive arrival: cards fade-rise as views append them, so async fills read as
   content arriving rather than the page snapping. */
#app .card, #app .candidate, #app .tile {
  animation: card-in .18s ease both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; }
  #app .card, #app .candidate, #app .tile { animation: none; }
  ::view-transition-old(app-main), ::view-transition-new(app-main) { animation: none; }
}

/* ==================================================================================
   STRATEGY BUILDER — template catalog, leg editor, live "where you stand" panel.
   ================================================================================== */
.builder-cols { display: grid; gap: 16px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 1000px) {
  .builder-cols { grid-template-columns: minmax(0, 1fr) 400px; }
  .builder-panel { position: sticky; top: 74px; max-height: calc(100vh - 90px); overflow-y: auto; }
}

.tpl-group-label {
  font-size: 11.5px; font-weight: 700; color: var(--text-faint); text-transform: uppercase;
  letter-spacing: .05em; margin: 12px 0 6px;
}
.tpl-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.tpl-grid.compact { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.tpl {
  text-align: left; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); padding: 9px 11px; display: flex; flex-direction: column; gap: 4px;
  transition: border-color .12s, background .12s; min-width: 0;
}
.tpl:hover { border-color: var(--accent); }
.tpl.selected { border-color: var(--accent); background: var(--accent-soft); }
.tpl-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tpl-head b { font-size: 13.5px; }
.tpl-blurb { font-size: 12px; line-height: 1.4; }

.leg-row {
  border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px;
  background: var(--surface); transition: border-color .12s;
}
.leg-row:hover { border-color: var(--border-strong); }
.leg-row.open { border-color: var(--accent); }
.leg-controls { display: flex; gap: 7px; padding: 8px 10px; align-items: center; flex-wrap: wrap; cursor: pointer; }
.leg-controls select, .leg-controls input { min-width: 0; }
.leg-action { width: 76px; }
.leg-type { width: 110px; }
.leg-exp { flex: 1 1 120px; }
.leg-strike { width: 96px; }
.leg-ratio { width: 62px; }
.leg-info { margin-left: auto; }
.leg-remove { flex: none; }
.leg-detail { padding: 2px 12px 10px; border-top: 1px dashed var(--border); }
.leg-impact { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; margin-top: 4px; }
.impact-bit b { font-variant-numeric: tabular-nums; }

/* Hover tip: fixed-position insight, zero layout shift (same look as chart tips). */
.leg-pop {
  position: absolute; z-index: 40; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 11px;
  box-shadow: var(--shadow-lg); font-size: 12.5px; line-height: 1.5; min-width: 220px; max-width: 300px;
  pointer-events: none;
}
.leg-pop .tt-title { font-weight: 700; margin-bottom: 3px; }

.builder-panel.updating { opacity: .65; transition: opacity .15s; }
.panel-stats { margin: 10px 0; }
.tpl-selected {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  border: 1px solid var(--accent); background: var(--accent-soft);
  border-radius: var(--radius-sm); padding: 9px 12px;
}
.tpl-selected .tpl-blurb { font-size: 12.5px; }

/* ---------- Desktop home: everything important on ONE screen ---------- */
.home-cols { display: grid; gap: 0 16px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 1100px) {
  .home-cols { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
  /* Tighter dashboard rhythm on large screens so the fold never hides an action */
  #app[data-route="home"] .stat .explain { margin: 4px 0 0; }
  #app[data-route="home"] h1 { margin-bottom: 10px; }
}
.home-actions { display: grid; gap: 12px; grid-template-columns: 1fr; margin-bottom: 16px; }
@media (min-width: 640px) and (max-width: 1099px) {
  .home-actions { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Builder v2: shape glyphs, expert bar, leg toggles ---------- */
.tpl-shape { flex: none; display: inline-flex; }
.tpl-shape svg { display: block; }
.tpl-shape-zero { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 2 3; }
.tpl-shape-line { stroke: var(--accent); stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.tpl-shape-risky { stroke: var(--risk-danger-solid); }
.builder-bar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.builder-bar .field { min-width: 0; }
.builder-bar-grow { flex: 1 1 180px; }
.builder-bar-end { margin-left: auto; }
.leg-on { accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.leg-off { opacity: .5; }
.leg-off .leg-mkt { text-decoration: line-through; }
.leg-mkt { font-size: 12px; white-space: nowrap; }
#builder-catalog .tpl-grid { margin-bottom: 4px; }

/* Home desktop: one screen through layout, not shrinkage — columns do the fitting. */
@media (min-width: 1100px) {
  #app[data-route="home"] .stat .explain { display: none; } /* dashboard numbers self-explain */
  #app[data-route="home"] #sector-pulse .explain,
  #app[data-route="home"] .home-col .card .explain { display: none; } /* chips + tiles self-explain */
  #app[data-route="home"] .grid.grid-4 { margin-bottom: 14px; }
  #app[data-route="home"] .home-actions { gap: 10px; }
  #app[data-route="home"] .home-actions .card { margin-bottom: 0; }
  #app[data-route="home"].app { padding-bottom: 14px; }
}
.qa-head { display: flex; gap: 11px; align-items: flex-start; }
.qa-head .icon-tile-sm { flex: none; margin-top: 1px; }
.qa-hint { font-size: 12.5px; margin-top: 2px; line-height: 1.4; }
@media (min-width: 1100px) {
  /* The nav highlight IS the headline on a dashboard */
  #app[data-route="home"] > h1 { display: none; }
}

/* ---------- Candlestick chart (D3-scaled, vendored — no CDN) ---------- */
.candles .candle-wick { stroke: var(--text-faint); stroke-width: 1; }
.candles .candle-up { fill: var(--gain); }
.candles .candle-down { fill: var(--loss); }
.candles .grid { stroke: var(--border); stroke-width: 1; }
.candles .tick { fill: var(--text-faint); font-size: 11px; }
.tabs .tabs-aside { margin-left: auto; align-self: center; font-size: 12.5px; padding: 6px 4px; }

/* ---------- Welcome: the whole pitch on ONE desktop screen — comfortable, not crammed ---------- */
.welcome-top { display: grid; gap: 20px; grid-template-columns: 1fr; align-items: stretch; }
/* SYMMETRY: both top-fold columns share one frame — same border, radius, padding, height.
   The hero keeps its gradient fill; the live column keeps a calm surface. */
.welcome-top > * { border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); position: relative; overflow: hidden; margin: 0; }
.welcome-top .welcome-live-col { padding: 14px 22px 16px; text-align: left; }
.welcome-top .live-head { min-height: 30px; align-items: center; margin-bottom: 10px; }
.welcome-top .welcome-live-col .showcase-frame { border: 0; background: none; padding: 0; }
.welcome-top .showcase { max-width: none; }
.welcome-top .showcase-caption { text-align: left; margin: 10px 0 0; max-width: none; }
.live-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.btn-link { background: none; border: none; color: var(--text-dim); font-size: 12.5px;
  padding: 2px 4px; text-decoration: underline; text-underline-offset: 3px; }
.btn-link:hover { color: var(--accent); }
.welcome-footer { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.welcome-footer .cta-banner { flex: 1 1 420px; margin: 0; }
@media (min-width: 1100px) {
  .welcome-top { grid-template-columns: 1fr 1fr; }
  #app:has(.welcome-page) .hero { padding: 14px 22px 16px; margin: 0; }
  #app:has(.welcome-page) .hero-inner { text-align: left; margin: 0; max-width: none; }
  #app:has(.welcome-page) .hero-ctas { justify-content: flex-start; }
  #app:has(.welcome-page) .trust-row { text-align: left; }
  #app:has(.welcome-page) .hero-title { font-size: clamp(27px, 2.3vw, 31px); margin: 8px 0 0; }
  #app:has(.welcome-page) .hero-ctas .btn-lg { min-height: 42px; }
  #app:has(.welcome-page) .hero-sub { margin: 12px 0 16px; max-width: none;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  #app:has(.welcome-page) .welcome-section { margin: 12px 0 0; }
  #app:has(.welcome-page) .welcome-top > .welcome-section { margin: 0; } /* grid rows align */
  #app:has(.welcome-page) .welcome-section .eyebrow { display: none; } /* the h2 carries it */
  #app:has(.welcome-page) .welcome-live-col .eyebrow { display: block; } /* except the live label */
  #app:has(.welcome-page) .welcome-h2 { font-size: 17px; margin: 0 0 8px; }
  /* Altitude doors: two horizontal cards — icon, title + blurb, one button. Calm, quick. */
  #app:has(.welcome-page) #welcome-levels.welcome-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
  #app:has(.welcome-page) .welcome-card { margin-bottom: 0; display: grid;
    grid-template-columns: 42px 1fr auto; gap: 4px 14px; align-items: center; padding: 14px 18px; }
  #app:has(.welcome-page) .welcome-card h3 { margin: 0; grid-column: 2; }
  #app:has(.welcome-page) .welcome-card p { margin: 0; grid-column: 2; grid-row: 2; font-size: 13px; }
  #app:has(.welcome-page) .welcome-card .btn { grid-column: 3; grid-row: 1 / span 2; }
  #app:has(.welcome-page) .welcome-card .icon-tile { grid-row: 1 / span 2; }
  /* Steps: four IDENTICAL columns — ghost numeral + verb, detail beneath. A grid, not a rag. */
  #app:has(.welcome-page) .stepper { display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 14px; text-align: left; }
  #app:has(.welcome-page) .step-block { flex-direction: row; align-items: baseline; gap: 10px; padding: 0; }
  #app:has(.welcome-page) .step-block::after { display: none; }
  #app:has(.welcome-page) .step-num { font-size: 21px; }
  #app:has(.welcome-page) .step-text { display: block; }
  #app:has(.welcome-page) .step-text b { display: block; font-size: 14px; white-space: nowrap; }
  #app:has(.welcome-page) .step-text span { font-size: 12.5px; }
  /* The live candidate is proof, not reading material — clamp it and fade the tail */
  .welcome-top .welcome-section { margin: 0; } /* grid children align to the hero top */
  #app:has(.welcome-page) .showcase-caption {
    display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
  #app:has(.welcome-page) .trust-row { font-size: 12px; white-space: nowrap; }
  .welcome-live-col .showcase-frame { max-height: 250px; overflow: hidden; position: relative;
    -webkit-mask-image: linear-gradient(to bottom, #000 78%, transparent 100%);
            mask-image: linear-gradient(to bottom, #000 78%, transparent 100%); }
  #app:has(.welcome-page) .welcome-footer { margin-top: 14px; flex-wrap: nowrap; }
  #app:has(.welcome-page) .cta-banner { padding: 9px 16px; }
  #app:has(.welcome-page) .cta-banner p { display: none; } /* the bold line carries it */
  #app.app:has(.welcome-page) { padding-top: 12px; padding-bottom: 16px; }
}
/* Laptop band (1100-1365): same design, gentler proportions — never tiny type */
@media (min-width: 1100px) and (max-width: 1365px) {
  #app:has(.welcome-page) .hero { padding: 10px 18px 12px; }
  #app:has(.welcome-page) .hero-title { font-size: 26px; }
  #app:has(.welcome-page) .hero-ctas .btn-lg { min-height: 38px; padding: 0 20px; }
  #app:has(.welcome-page) .hero-ctas { margin-bottom: 8px; }
  #app:has(.welcome-page) .hero-sub {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .welcome-live-col .showcase-frame { max-height: 215px; }
  #app:has(.welcome-page) .welcome-top { gap: 14px; }
  #app:has(.welcome-page) .welcome-section { margin: 10px 0 0; }
  #app:has(.welcome-page) .welcome-h2 { margin: 0 0 6px; }
  /* The step strip speaks for itself at laptop width — the numerals ARE the heading */
  #app:has(.welcome-page) #how-it-works .welcome-h2 { display: none; }
  #app:has(.welcome-page) .step-text span { display: none; }
  #app:has(.welcome-page) .welcome-card { padding: 10px 14px; }
  #app:has(.welcome-page) #welcome-levels.welcome-grid { gap: 10px; }
  #app:has(.welcome-page) .cta-banner { padding: 7px 14px; }
  #app:has(.welcome-page) .welcome-footer { margin-top: 6px; }
  #app.app:has(.welcome-page) { padding-top: 8px; padding-bottom: 6px; }
}


/* Contextual ticker: market context on Home + Research, absent elsewhere */
.tape.tape-offroute { display: none; }

/* ---------- Trade workbench: stage pills + the working-idea bar ---------- */
.wb-stages .wb-num { color: var(--accent); font-variant-numeric: tabular-nums; margin-right: 2px; }
.idea-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  padding: 7px 12px; margin: 0 0 14px; background: var(--surface);
}
.idea-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; }
.idea-chip .icon { color: var(--accent); display: inline-flex; }
