/* Sonar — crimson-on-black trading HUD.
 *
 * Matched to the reference: near-black ground, one crimson primary carrying
 * glow, hairline red panel borders, monospace ALL-CAPS technical labels, dense
 * readouts. Rounding is kept from the earlier brief — the reference rounds its
 * pills fully and its panels softly, so the two are compatible.
 *
 * DARK ONLY, on purpose. A light-mode cyberpunk HUD is a contradiction, and a
 * `prefers-color-scheme: light` variant would have to invent a second palette
 * that matches nothing.
 *
 * Colour discipline, which is what keeps this from becoming noise:
 *   --accent (crimson) is CHROME — borders, focus, the top tier, the price
 *   line. The categorical hues (--gold, --magenta) are DATA ONLY: they mark
 *   tier and horizon, never decoration. Nothing else is coloured.
 *
 * Motion carries meaning: cards stagger so the eye gets a reading order, bars
 * grow from zero so length is felt, the scanline sweeps only while a scan runs.
 * All of it dies under prefers-reduced-motion.
 */

:root {
  color-scheme: dark;

  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-pill: 999px;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  --fs-xs: 0.6875rem;
  --fs-sm: 0.8125rem;
  --fs-md: 0.9375rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.75rem;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.34, 1.4, 0.64, 1);

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo,
    Consolas, monospace;

  /* ground */
  --bg: #050507;
  --surface: #0b0b0f;
  --surface-2: #121218;
  --grid: rgba(255, 42, 61, 0.045);

  /* ink */
  --text: #f2eef0;
  --muted: #9a8f94;
  /* Measured, not eyeballed. The first pass used #6a6069, which is 3.26:1 on
   * the card surface -- and every --faint element is 11px uppercase mono, so
   * it needs 4.5:1, not the 3:1 large-text allowance. #8a8088 gives 5.17:1
   * and still reads as the quietest thing on the page. */
  --faint: #8a8088;

  /* crimson — the only chrome colour */
  --accent: #ff2a3d;
  --accent-dim: #b21226;
  --accent-ink: #120407;
  --accent-wash: rgba(255, 42, 61, 0.10);
  --accent-glow: rgba(255, 42, 61, 0.36);

  --border: rgba(255, 42, 61, 0.16);
  --border-strong: rgba(255, 42, 61, 0.34);

  /* categorical — DATA ONLY, never chrome */
  --gold: #ffb020;
  --magenta: #c548ff;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.6), 0 10px 30px rgba(0, 0, 0, 0.55);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.7),
    0 20px 50px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--border-strong);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--fs-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Faint technical grid + a crimson bloom off the top. Both are pinned at very
 * low opacity: the reference is mostly black, and the glow only reads because
 * almost nothing else competes with it. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 100% 44px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 44px 100%,
    radial-gradient(70% 46% at 50% -6%, rgba(255, 42, 61, 0.16), transparent 72%);
}

.wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 940px;
  margin: 0 auto;
  padding: 0 var(--sp-4);
}

/* Shared treatment for the small technical labels the reference is built from. */
.label,
.funnel-l,
.seg,
.leg-top,
.tier,
.sym-meta,
.tag,
.chart-meta {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.skip { position: absolute; left: -9999px; color: var(--accent); text-decoration: none; }
.skip:focus {
  left: var(--sp-4); top: var(--sp-4); z-index: 20;
  background: var(--surface); color: var(--text);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow);
  outline: 1px solid var(--accent); outline-offset: 2px;
}

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: linear-gradient(180deg, rgba(5, 5, 7, 0.94), rgba(5, 5, 7, 0.78));
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  transition: border-color 0.3s var(--ease);
}
.topbar.is-stuck { border-color: var(--border-strong); }
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); height: 60px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-dot {
  width: 8px; height: 8px; border-radius: var(--r-pill);
  background: var(--accent); flex: none;
  box-shadow: 0 0 10px 2px var(--accent-glow);
}
/* A status light, not an ornament: it only pulses while a scan is running. */
body.is-scanning .brand-dot { animation: ping 1.6s var(--ease) infinite; }
@keyframes ping {
  0%   { box-shadow: 0 0 10px 2px var(--accent-glow), 0 0 0 0 var(--accent-glow); }
  70%  { box-shadow: 0 0 10px 2px var(--accent-glow), 0 0 0 10px transparent; }
  100% { box-shadow: 0 0 10px 2px var(--accent-glow), 0 0 0 0 transparent; }
}
.brand-name {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: var(--fs-sm);
}
.topbar-actions { display: flex; align-items: center; gap: var(--sp-2); }

/* ------------------------------------------------------------ primitives */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: var(--r-pill);
  font-family: var(--mono); font-size: var(--fs-xs);
  letter-spacing: 0.08em; text-transform: uppercase;
  white-space: nowrap; border: 1px solid transparent;
}
.pill-quiet { background: var(--surface-2); color: var(--muted); border-color: var(--border); }

.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: var(--fs-xs); font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: 9px 20px; border-radius: var(--r-pill);
  cursor: pointer; position: relative; overflow: hidden;
  transition: transform 0.16s var(--spring), background 0.18s var(--ease),
    border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), opacity 0.18s var(--ease);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 0 16px -2px var(--accent-glow); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { opacity: 0.6; cursor: default; transform: none; }

.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-dim));
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 18px -4px var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 0 24px -2px var(--accent-glow); }

/* The button is the progress indicator while a scan is in flight. */
.btn.is-busy::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.28) 50%, transparent 80%);
  animation: sweep 1.2s linear infinite;
}
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* --------------------------------------------------------------- banners */
#banners:not(:empty) { margin-top: var(--sp-5); }
.banner {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 2px solid var(--accent);
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-3);
  animation: rise 0.5s var(--ease-out) both;
}
.banner strong { font-weight: 700; letter-spacing: 0.04em; }
.banner p { margin: 2px 0 0; color: var(--muted); }

/* ---------------------------------------------------------------- funnel */
.panel {
  position: relative;
  margin-top: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  animation: rise 0.55s var(--ease-out) both;
  overflow: hidden;
}
/* A scanline crosses the readout only while a scan is actually running. */
.panel::after {
  content: "";
  position: absolute; left: 0; right: 0; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
}
body.is-scanning .panel::after { opacity: 0.9; animation: scanline 2.4s linear infinite; }
@keyframes scanline { from { transform: translateY(0); } to { transform: translateY(78px); } }

.funnel {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  overflow-x: auto; scrollbar-width: none;
}
.funnel::-webkit-scrollbar { display: none; }
.funnel-item { display: flex; flex-direction: column; gap: 2px; min-width: 66px; }
.funnel-n {
  font-family: var(--mono); font-size: var(--fs-lg); font-weight: 700;
  letter-spacing: -0.01em; font-variant-numeric: tabular-nums;
}
.funnel-l { font-size: var(--fs-xs); color: var(--faint); }
.funnel-item.is-final .funnel-n {
  color: var(--accent);
  text-shadow: 0 0 14px var(--accent-glow);
}
.funnel-arrow {
  flex: 1 1 auto; min-width: 16px; height: 1px;
  background: linear-gradient(90deg, var(--border), var(--border-strong));
  transform-origin: left center;
  animation: draw 0.7s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 90ms + 200ms);
}
@keyframes draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* --------------------------------------------------------------- filters */
.filters { margin: var(--sp-5) 0 var(--sp-4); }
.segmented {
  position: relative;
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }

/* One element slides between tabs, so the eye tracks direction. */
.seg-indicator {
  position: absolute; top: 3px; left: 0; height: calc(100% - 6px);
  border-radius: var(--r-pill);
  background: var(--accent-wash);
  border: 1px solid var(--accent);
  box-shadow: 0 0 14px -3px var(--accent-glow);
  transition: transform 0.42s var(--spring), width 0.42s var(--spring);
  pointer-events: none; z-index: 0;
}
.seg {
  position: relative; z-index: 1;
  appearance: none; border: 0; background: transparent;
  color: var(--muted);
  font-size: var(--fs-xs); font-weight: 700;
  padding: 8px 15px; border-radius: var(--r-pill);
  cursor: pointer; white-space: nowrap;
  transition: color 0.22s var(--ease);
}
.seg:hover { color: var(--text); }
.seg:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
.seg.is-active { color: var(--text); text-shadow: 0 0 10px var(--accent-glow); }
.seg .seg-n { margin-left: 6px; font-variant-numeric: tabular-nums; color: var(--faint); }

/* ----------------------------------------------------------------- ideas */
.ideas { display: flex; flex-direction: column; gap: var(--sp-3); padding-bottom: var(--sp-6); }

@keyframes rise {
  from { opacity: 0; transform: translate3d(0, 14px, 0); }
  to   { opacity: 1; transform: none; }
}

.card {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 42, 61, 0.035), transparent 40%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: rise 0.5s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 45ms);
  transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease),
    border-color 0.22s var(--ease);
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lift);
}
/* Horizon is data, so it gets a categorical hue rather than the chrome red. */
.card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--accent);
  opacity: 0.55;
}
.card[data-horizon="intraday"]::before { background: var(--gold); }

.card-head { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); }

.tier {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  min-width: 48px; height: 26px; padding: 0 11px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 700;
  border: 1px solid transparent;
}
.tier-aplus {
  background: linear-gradient(180deg, var(--accent), var(--accent-dim));
  color: #fff; box-shadow: 0 0 16px -3px var(--accent-glow);
}
.tier-a { background: var(--accent-wash); color: var(--accent); border-color: var(--accent); }
.tier-bplus { background: transparent; color: var(--muted); border-color: var(--border-strong); }
.tier-none { background: transparent; color: var(--faint); border-color: var(--border); }

.card-title { flex: 1 1 auto; min-width: 0; }
.sym { display: flex; align-items: baseline; gap: var(--sp-2); flex-wrap: wrap; }
.sym-name {
  font-family: var(--mono); font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  font-size: var(--fs-md);
}
.sym-meta { font-size: var(--fs-xs); color: var(--faint); }

.headline {
  margin: 4px 0 0; color: var(--muted);
  font-size: var(--fs-sm); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}

.score { flex: none; text-align: right; }
.score-n {
  font-family: var(--mono); font-size: var(--fs-xl); font-weight: 700;
  letter-spacing: -0.02em; line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  text-shadow: 0 0 18px var(--accent-glow);
}
.score-l {
  font-family: var(--mono); font-size: var(--fs-xs); color: var(--faint);
  letter-spacing: 0.1em;
}

/* legs */
.legs { display: flex; gap: var(--sp-3); padding: 0 var(--sp-5) var(--sp-4); }
.leg { flex: 1 1 0; min-width: 0; }
.leg-top {
  display: flex; justify-content: space-between; gap: var(--sp-2);
  font-size: var(--fs-xs); color: var(--faint); margin-bottom: 6px;
}
.leg-v { color: var(--muted); font-variant-numeric: tabular-nums; }
.leg-bar {
  height: 4px; border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.06); overflow: hidden;
}
.leg-fill {
  display: block; height: 100%; width: 0;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  box-shadow: 0 0 10px -1px var(--accent-glow);
  transition: width 0.85s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 45ms + 120ms);
}
.leg-fill.is-zero { background: rgba(255, 255, 255, 0.14); box-shadow: none; }

/* details */
.card-more { border-top: 1px solid var(--border); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card-more summary {
  list-style: none; cursor: pointer;
  padding: var(--sp-3) var(--sp-5);
  font-family: var(--mono); font-size: var(--fs-xs);
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.card-more summary::-webkit-details-marker { display: none; }
.card-more summary:hover { color: var(--accent); background: rgba(255, 42, 61, 0.05); }
.card-more summary:focus-visible { outline: 1px solid var(--accent); outline-offset: -2px; }
.chev { transition: transform 0.32s var(--spring); flex: none; }
.card-more[open] .chev { transform: rotate(180deg); }

.more-inner { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.36s var(--ease-out); }
.card-more[open] .more-inner { grid-template-rows: 1fr; }
.more-clip { overflow: hidden; }

.reasons {
  margin: 0; padding: 0 var(--sp-5) var(--sp-3);
  list-style: none; display: flex; flex-direction: column; gap: var(--sp-2);
}
.reasons li {
  position: relative; padding-left: 16px;
  font-size: var(--fs-sm); color: var(--muted);
}
.reasons li::before {
  content: ""; position: absolute; left: 0; top: 8px;
  width: 5px; height: 5px; border-radius: var(--r-pill);
  background: var(--border-strong);
}
.reasons li.is-cap { color: var(--text); }
.reasons li.is-cap::before { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 var(--sp-5) var(--sp-4); }
.tag {
  font-size: var(--fs-xs); color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 4px 10px;
}

/* ------------------------------------------------------------ ticker tape */
.tape {
  position: relative; z-index: 1; overflow: hidden;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 11, 15, 0.7);
  backdrop-filter: blur(8px);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}
.tape.is-empty { display: none; }
/* Two identical copies, translated -50%: that is what makes the loop
 * seamless. Animating one copy to -100% snaps back visibly. */
.tape-track {
  display: flex; gap: var(--sp-2); width: max-content;
  padding: 8px var(--sp-4);
  animation: marquee var(--tape-dur, 40s) linear infinite;
}
.tape:hover .tape-track, .tape:focus-within .tape-track { animation-play-state: paused; }
@keyframes marquee { from { transform: translate3d(0,0,0); } to { transform: translate3d(-50%,0,0); } }

.tape-item {
  appearance: none;
  display: inline-flex; align-items: baseline; gap: 8px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-pill);
  font-family: var(--mono); font-size: var(--fs-xs);
  letter-spacing: 0.08em; color: var(--muted);
  white-space: nowrap; cursor: pointer;
  transition: border-color 0.18s var(--ease), color 0.18s var(--ease),
    transform 0.18s var(--spring), box-shadow 0.18s var(--ease);
}
.tape-item:hover {
  color: var(--text); border-color: var(--accent);
  transform: translateY(-1px); box-shadow: 0 0 14px -4px var(--accent-glow);
}
.tape-item:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
.tape-sym { color: var(--text); font-weight: 700; }
.tape-score { font-variant-numeric: tabular-nums; }
.tape-item[data-tier="A+"] .tape-sym,
.tape-item[data-tier="A"] .tape-sym {
  color: var(--accent); text-shadow: 0 0 10px var(--accent-glow);
}

@keyframes locate {
  0%, 100% { border-color: var(--border); box-shadow: var(--shadow); }
  30%      { border-color: var(--accent); box-shadow: 0 0 30px -6px var(--accent-glow); }
}
.card.is-located { animation: locate 1.4s var(--ease) 1; }

/* ----------------------------------------------------------------- chart */
.chart { position: relative; padding: 0 var(--sp-5) var(--sp-4); }
.chart svg { display: block; width: 100%; height: 66px; overflow: visible; }

/* The PB EMA channel, behind the price — the band the bias layer actually
 * reads. A bare price line invites disagreeing with a score whose basis you
 * cannot see. */
.chart-band { fill: var(--accent); opacity: 0.10; }
.chart-line {
  fill: none; stroke: var(--accent); stroke-width: 1.5;
  stroke-linejoin: round; stroke-linecap: round;
  filter: drop-shadow(0 0 4px var(--accent-glow));
  stroke-dasharray: var(--len); stroke-dashoffset: var(--len);
  animation: trace 1.1s var(--ease-out) forwards;
  animation-delay: calc(var(--i, 0) * 45ms + 180ms);
}
@keyframes trace { to { stroke-dashoffset: 0; } }

.chart-dot { fill: #fff; }
.chart-cross { stroke: var(--accent); stroke-width: 1; opacity: 0; }
.chart:hover .chart-cross { opacity: 0.7; }

.chart-tip {
  position: absolute; top: -6px; left: 0;
  transform: translateX(-50%);
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--accent);
  border-radius: var(--r-pill);
  padding: 3px 10px;
  font-family: var(--mono); font-size: var(--fs-xs);
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity 0.15s var(--ease);
  box-shadow: 0 0 18px -6px var(--accent-glow);
}
.chart.is-hovering .chart-tip { opacity: 1; }

.chart-meta {
  display: flex; justify-content: space-between;
  font-size: var(--fs-xs); color: var(--faint); margin-top: 5px;
}

/* -------------------------------------------------------- empty/skeleton */
.empty {
  text-align: center; padding: var(--sp-7) var(--sp-5);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  animation: rise 0.5s var(--ease-out) both;
}
.empty h2 {
  margin: 0 0 8px; font-family: var(--mono); font-size: var(--fs-md);
  font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
}
.empty p { margin: 0 auto; max-width: 44ch; color: var(--muted); font-size: var(--fs-sm); }
.empty .btn { margin-top: var(--sp-4); }

.skeleton-card {
  height: 148px; border-radius: var(--r-lg);
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s var(--ease) infinite;
  border: 1px solid var(--border);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.footnote {
  color: var(--faint); font-size: var(--fs-xs); text-align: center;
  max-width: 58ch; margin: 0 auto var(--sp-7); line-height: 1.7;
  font-family: var(--mono); letter-spacing: 0.04em;
}

/* ----------------------------------------------------------- responsive */
@media (max-width: 560px) {
  .card-head { flex-wrap: wrap; padding: var(--sp-4); }
  .score { order: 2; margin-left: auto; }
  .card-title { order: 3; flex-basis: 100%; }
  .legs { padding: 0 var(--sp-4) var(--sp-4); gap: var(--sp-2); }
  .chart { padding: 0 var(--sp-4) var(--sp-4); }
  .card-more summary, .reasons, .tags { padding-left: var(--sp-4); padding-right: var(--sp-4); }

  /* The funnel scrolled horizontally behind a hidden scrollbar at 375px,
   * pushing "ideas" -- the one number that matters -- off screen with nothing
   * to indicate it was there. A 2x2 grid shows all four and never scrolls. */
  .funnel {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: var(--sp-4) var(--sp-3); padding: var(--sp-4); overflow: visible;
  }
  .funnel-arrow { display: none; }
  .funnel-item { min-width: 0; }
}

/* Motion is a nicety; legibility is not. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    animation-delay: 0ms !important;
  }
  .tape-track { animation: none; }
  .chart-line { stroke-dasharray: none; stroke-dashoffset: 0; animation: none; }
  .leg-fill { transition: none !important; }
}


/* ------------------------------------------------------------------ gate */
/* Sign-in overlay. `hidden` until /api/config says auth is on, so a server
 * that cannot complete a login never blanks the board behind one. */
.gate {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: var(--sp-4);
  background: radial-gradient(70% 50% at 50% 0%, rgba(255,42,61,0.12), transparent 70%), var(--bg);
}
.gate[hidden] { display: none; }

.gate-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lift);
  padding: var(--sp-6) var(--sp-5);
  display: flex; flex-direction: column; gap: var(--sp-3);
  animation: rise 0.5s var(--ease-out) both;
}
.gate-brand {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--mono); font-size: var(--fs-xs);
  letter-spacing: 0.24em; color: var(--muted);
  margin-bottom: var(--sp-2);
}
.gate-title {
  margin: 0; font-family: var(--mono); font-size: var(--fs-lg);
  font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
}
.gate-sub { margin: 0; color: var(--muted); font-size: var(--fs-sm); line-height: 1.5; }

.gate-input {
  appearance: none; width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  color: var(--text);
  font: inherit; font-size: var(--fs-sm);
  padding: 11px var(--sp-4);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.gate-input::placeholder { color: var(--faint); }
.gate-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
.gate-btn { width: 100%; justify-content: center; }
.gate-msg { margin: 0; min-height: 1.2em; font-size: var(--fs-xs); color: var(--muted); }
.gate-msg.is-error { color: var(--accent); }
