:root {
  --ink: #070a12;
  --midnight: #0b1020;
  --navy: #111a30;
  --slate: #1b2538;
  --graphite: #2a3140;
  --silver: #a9b2c3;
  --mist: #d8dee8;
  --ivory: #f4f0e8;
  --plum: #5a294f;
  --plum-light: #8e5a82;
  --gain: #42c486;
  --loss: #f06b78;

  --display: "Cormorant Garamond", Georgia, serif;
  --sans: "Manrope", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", Consolas, monospace;

  --border: rgba(169, 178, 195, 0.17);
  --border-strong: rgba(169, 178, 195, 0.28);
  --gain-bg: rgba(66, 196, 134, 0.1);
  --loss-bg: rgba(240, 107, 120, 0.1);
  --plum-bg: rgba(142, 90, 130, 0.1);
}

* {
  box-sizing: border-box;
  /* Beta feedback: a white flash on every single navigation, which four
     separate native WKWebView background fixes never touched — a strong
     sign the actual cause was never the webview's background at all.
     WebKit shows this translucent gray/white highlight on any tapped
     link/button by default; over a dark page it reads as a bright flash,
     and it's consistent with every symptom reported (every navigation,
     full-screen on a large tapped element like a table row, gone the
     instant the tap ends) while being invisible to any native code. */
  -webkit-tap-highlight-color: transparent;
}

html { scroll-behavior: smooth; }

/* Painted from inside the page itself, right before it navigates away —
   see nav-transition.js for why that matters more than a native overlay. */
.nav-transition-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--ink);
  opacity: 0;
  pointer-events: none;
}

.nav-transition-overlay.active { opacity: 1; }

body {
  margin: 0;
  color: var(--mist);
  background: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
::selection { background: var(--plum-light); color: var(--ivory); }
:focus-visible { outline: 2px solid var(--plum-light); outline-offset: 3px; box-shadow: 0 0 0 5px rgba(244, 240, 232, 0.15); }

/* Header */

.site-header {
  height: calc(168px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 32px;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(circle at 50% 120%, rgba(90, 41, 79, 0.35), transparent 60%),
    linear-gradient(180deg, var(--midnight), var(--ink));
  position: relative;
  overflow: hidden;
}

/* The lockup's own background is fully transparent now (see the asset
   itself), but at the base size it still reads as a small island in a
   much wider bar on desktop — scale it up past tablet width so it
   actually fills a proportionate share of the header. */
@media (min-width: 1024px) {
  .site-header { height: calc(196px + env(safe-area-inset-top)); }
  .lockup-image { height: 164px; }
}

.brand-lockup { display: inline-flex; align-items: center; gap: 9px; position: relative; z-index: 1; }
.brand-lockup img { object-fit: contain; object-position: 50% 18%; }
.lockup-image {
  height: 136px;
  width: auto;
  aspect-ratio: 1774 / 887;
  object-position: 50% 50%;
  filter: drop-shadow(0 8px 28px rgba(0, 0, 0, 0.55));
}
.wordmark { display: flex; align-items: baseline; gap: 7px; color: var(--ivory); line-height: 1; }
.wordmark strong { font-family: var(--display); font-weight: 600; font-size: 21px; letter-spacing: -0.02em; }
.wordmark small {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 18px;
  padding: 0 5px;
  border-radius: 20px;
  color: var(--ivory);
  background: var(--plum);
  font: 600 9px/1 var(--mono);
}

/* Ticker strip */

.ticker-strip {
  height: 40px;
  display: flex;
  align-items: center;
  overflow: hidden;
  background: var(--midnight);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.ticker-track {
  display: inline-flex;
  align-items: center;
  animation: ticker-scroll 55s linear infinite;
  will-change: transform;
}

.ticker-strip:hover .ticker-track { animation-play-state: paused; }

.ticker-item {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 0 20px;
  border-right: 1px solid var(--border);
  font: 500 11px/1 var(--mono);
  color: var(--silver);
}

.ticker-item b { color: var(--ivory); font-weight: 700; }
.ticker-item .ticker-pct { font-weight: 600; }
.ticker-item .ticker-pct.at-low-text { color: var(--loss); }
.ticker-item .ticker-pct.near-low-text { color: var(--plum-light); }

.ticker-empty { padding: 0 20px; font: 500 11px/1 var(--mono); color: var(--silver); }

@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* Page heading */

/* Fluid rather than a fixed 1100px cap — the data table has ten nowrap
   columns, and a fixed cap left real desktop width unused while the table
   itself scrolled horizontally inside .table-wrap. Grows with the viewport
   up to 1500px so it still reads comfortably on very wide monitors. */
main { max-width: min(1500px, 94vw); margin: 0 auto; padding: 48px 32px 96px; }

.page-heading { margin-bottom: 32px; }

.page-heading h1 {
  margin: 0 0 12px;
  color: var(--ivory);
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(38px, 5vw, 58px);
  line-height: 0.98;
  letter-spacing: -0.03em;
}

.page-heading h1 em { color: var(--plum-light); font-style: normal; }

.subtitle { margin: 0; max-width: 46em; color: var(--silver); font-size: 15px; }

.dali-score-explainer {
  margin: 10px 0 0;
  max-width: 46em;
  color: #7c8496;
  font-size: 13.5px;
  line-height: 1.6;
}

.dali-score-explainer strong { color: var(--plum-light); font-weight: 600; }

.dali-score-legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 12px 0 0;
  padding: 0;
}

.dali-score-legend li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: #7c8496;
}

.dali-score-legend .dali-score-pill { flex-shrink: 0; }

.dali-score-info { position: relative; }

.dali-score-info summary {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  color: var(--silver);
  font: 700 12px/1 var(--mono);
  cursor: pointer;
  list-style: none;
}

.dali-score-info summary::-webkit-details-marker { display: none; }
.dali-score-info summary:hover,
.dali-score-info[open] summary { border-color: var(--plum-light); color: var(--plum-light); }

.dali-score-popover {
  position: absolute;
  z-index: 5;
  top: calc(100% + 8px);
  left: 0;
  width: max-content;
  max-width: min(300px, calc(100vw - 48px));
  padding: 12px 14px;
  background: var(--navy);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  color: var(--mist);
  font-size: 12.5px;
  line-height: 1.55;
}

.dali-score-nav-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 0;
}

.dali-score-nav-pill {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--plum-light);
  color: var(--ivory);
  font: 700 12px/1 var(--mono);
  text-decoration: none;
  transition: background 160ms ease;
}

.dali-score-nav-pill:hover,
.dali-score-nav-pill:focus-visible { background: var(--plum-bg); }

/* On the Tracker/About pages this row follows .back-link (which already
   carries its own 24px margin-bottom) rather than the homepage's score
   legend, so the row's default top margin just stacks on top of that and
   leaves nothing below it before the heading — override both sides here. */
.tracker-page .dali-score-nav-row,
.about-page .dali-score-nav-row { margin: 0 0 24px; }

.dali-score-disclaimer {
  margin: 10px 0 0;
  max-width: 46em;
  color: #7c8496;
  font-size: 11.5px;
  font-style: italic;
}

/* Signup */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.signup-honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.signup-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-top: 32px;
  margin-bottom: 0;
  padding: 24px 28px;
  border: 1px solid rgba(142, 90, 130, 0.32);
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(90, 41, 79, 0.16), rgba(17, 26, 48, 0.3));
}

.signup-copy h2 {
  margin: 0 0 4px;
  color: var(--ivory);
  font-family: var(--display);
  font-weight: 600;
  font-size: 22px;
}

.signup-copy p { margin: 0; color: var(--silver); font-size: 13px; }

.signup-controls { display: flex; gap: 10px; flex-wrap: wrap; }

.signup-field input[type="email"] {
  height: 44px;
  min-width: 240px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  /* iOS Safari applies its own native white styling to inputs (email
     fields especially) unless appearance is reset explicitly — without
     this, the background/color below get silently ignored on iPhone. */
  -webkit-appearance: none;
  appearance: none;
  background: var(--navy);
  color: var(--ivory);
  font: 500 13px/1 var(--sans);
}

.signup-field input[type="email"]::placeholder { color: #5c6577; }
.signup-field input[type="email"]:focus { border-color: var(--plum-light); outline: none; }

/* Chromium and WebKit both force a white/yellow autofill background that
   ignores author CSS unless overridden this way. */
.signup-field input[type="email"]:-webkit-autofill,
.signup-field input[type="email"]:-webkit-autofill:hover,
.signup-field input[type="email"]:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--navy) inset;
  -webkit-text-fill-color: var(--ivory);
  caret-color: var(--ivory);
  transition: background-color 9999s ease-in-out 0s;
}

.signup-controls .button-primary {
  height: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: 6px;
  background: var(--plum);
  color: var(--ivory);
  font: 600 13px/1 var(--sans);
  cursor: pointer;
  transition: background 160ms ease;
}

.signup-controls .button-primary:hover { background: #68345e; }
.signup-controls .button-primary:disabled { opacity: 0.6; cursor: default; }

.signup-message { flex-basis: 100%; margin: 4px 0 0; font: 500 12px/1.5 var(--sans); color: var(--silver); }
.signup-message.success { color: var(--gain); }
.signup-message.error { color: var(--loss); }

/* Controls */

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.segmented {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  /* Five-plus pills don't reliably fit a narrow phone's width — scroll
     rather than silently clip a button (or several) off-screen. */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.filter-btn {
  background: transparent;
  border: 0;
  border-right: 1px solid var(--border);
  color: var(--silver);
  padding: 10px 16px;
  cursor: pointer;
  font: 500 12px/1 var(--sans);
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 160ms ease, color 160ms ease;
}

.filter-btn:last-child { border-right: 0; }

.filter-btn.active { background: var(--plum); color: var(--ivory); }
.filter-btn:not(.active):hover { background: var(--navy); color: var(--mist); }

.status { color: var(--silver); font: 500 11px/1.5 var(--mono); text-align: right; }

/* Pull-to-refresh (touch only — desktop mouse input never fires the touch
   events that move this, so it stays offscreen and inert there). */
.pull-refresh {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  transform: translateY(-56px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: var(--midnight);
  border-bottom: 1px solid var(--border);
  color: var(--silver);
  font: 600 10.5px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  z-index: 50;
}

.pull-refresh-spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--plum-light);
}

.pull-refresh.refreshing .pull-refresh-spinner { animation: pull-refresh-spin 0.7s linear infinite; }

@keyframes pull-refresh-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .pull-refresh.refreshing .pull-refresh-spinner { animation: none; }
}

/* Table */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--navy);
  box-shadow: 0 24px 48px rgba(4, 6, 12, 0.4);
}

.show-more-row { display: flex; justify-content: center; margin-top: 20px; }

.show-more-btn {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 18px;
  border: 1px solid var(--plum-light);
  border-radius: 8px;
  background: transparent;
  color: var(--ivory);
  font: 700 12px/1 var(--mono);
  cursor: pointer;
  transition: background 160ms ease;
}

.show-more-btn:hover,
.show-more-btn:focus-visible { background: var(--plum-bg); }

table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 680px; }

th, td { padding: 14px 18px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }

th {
  color: var(--silver);
  font: 600 10px/1 var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--ivory); }
th[data-sort]::after { content: ""; display: inline-block; width: 9px; }
th[data-sort][aria-sort="ascending"]::after { content: "\2191"; color: var(--plum-light); margin-left: 3px; }
th[data-sort][aria-sort="descending"]::after { content: "\2193"; color: var(--plum-light); margin-left: 3px; }

td { color: var(--mist); }
td:first-child { color: var(--ivory); font: 600 13px/1 var(--mono); }

.symbol-link { border-bottom: 1px solid transparent; transition: border-color 160ms ease, color 160ms ease; }
.symbol-link:hover, .symbol-link:focus-visible { color: var(--plum-light); border-bottom-color: currentColor; }

.num, td.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }

tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 160ms ease; }

tbody tr.at-low { background: var(--loss-bg); }
tbody tr.near-low { background: var(--plum-bg); }

.pct { font-weight: 600; }
.pct.at-low-text { color: var(--loss); }
.pct.near-low-text { color: var(--plum-light); }

/* The core Dali metric — deliberately the most visually prominent number
   in the table, not just one column among many. */
.pct-hero { font-size: 15px; font-weight: 700; }

.dali-score-pill {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  font: 700 12px/1 var(--mono);
  border: 1px solid currentColor;
}

.dali-score-extreme { color: var(--loss); }
.dali-score-high { color: var(--plum-light); }
.dali-score-mid { color: var(--silver); }
.dali-score-low { color: #4a5164; border-color: var(--border); }

.dali-score-pill-link { display: inline-flex; border-radius: 6px; }
.dali-score-pill-link:hover .dali-score-pill,
.dali-score-pill-link:focus-visible .dali-score-pill { background: var(--loss-bg); }

.skeleton-row td { padding: 16px 18px; }
.skeleton-bar {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--slate) 25%, var(--graphite) 50%, var(--slate) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.6s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.at-low-flag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  border: 1px solid currentColor;
  border-radius: 4px;
  color: var(--loss);
  font: 600 8px/1.4 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  vertical-align: middle;
}

.badge {
  display: inline-block;
  font: 500 9px/1 var(--mono);
  padding: 4px 7px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  color: var(--silver);
  margin-right: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.industry { color: var(--silver); font-size: 12px; }

.sentiment-badge {
  display: inline-block;
  font: 600 9px/1 var(--mono);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid currentColor;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sentiment-badge.sentiment-bullish { color: var(--gain); }
.sentiment-badge.sentiment-bearish { color: var(--loss); }
.sentiment-badge.sentiment-neutral { color: var(--silver); }
.sentiment-badge.sentiment-none { color: #4a5164; border-color: var(--border); }

.empty { text-align: center; color: var(--silver); padding: 48px; white-space: normal; }

/* Footer */

footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
}

footer .brand-lockup { opacity: 0.85; }

footer p { margin: 0; color: #687489; font: 500 11px/1.5 var(--sans); }

footer a[href*="finnhub"] { color: var(--plum-light); }

.footer-text { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.footer-disclaimer { font-style: italic; }

/* Stock detail page */

.stock-page { max-width: 900px; }

.back-link {
  display: inline-block;
  margin-bottom: 24px;
  color: var(--silver);
  font: 700 16px/1 var(--sans);
}

.back-link:hover { color: var(--ivory); }

.stock-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 12px;
}

.stock-title-row h1 {
  margin: 0;
  color: var(--ivory);
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(28px, 4vw, 40px);
  letter-spacing: -0.02em;
}

.stock-name {
  color: var(--silver);
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.5em;
  display: block;
  margin-top: 4px;
}

.stock-badges { margin-top: 10px; }

.dali-score-badge {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 2px solid var(--plum-light);
  background: radial-gradient(circle at 50% 30%, rgba(142, 90, 130, 0.25), transparent 70%);
}

.dali-score-value { color: var(--ivory); font-family: var(--display); font-weight: 700; font-size: 30px; line-height: 1; }
.dali-score-label { color: var(--plum-light); font: 600 8px/1 var(--mono); letter-spacing: 0.06em; margin-top: 4px; }

.stock-price-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  margin: 24px 0;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.stock-price { color: var(--ivory); font: 600 40px/1 var(--mono); letter-spacing: -0.02em; }
.stock-pct { font: 600 14px/1 var(--sans); color: var(--mist); }
.stock-pct.at-low-text { color: var(--loss); }
.stock-pct.near-low-text { color: var(--plum-light); }
.stock-asof { color: var(--silver); font: 500 11px/1 var(--mono); margin-left: auto; }

.chart-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--navy);
  padding: 16px;
  margin-bottom: 32px;
}

.stock-chart { width: 100%; height: auto; overflow: visible; }
.chart-low-line { stroke: var(--loss); stroke-width: 1.5; }
.chart-area { fill: rgba(142, 90, 130, 0.14); stroke: none; }
.chart-line { fill: none; stroke: var(--plum-light); stroke-width: 2; }
.chart-today-dot { fill: var(--ivory); stroke: var(--plum-light); stroke-width: 2; }
.chart-axis-label { fill: var(--silver); font: 500 12px var(--mono); }
.chart-grid-label { fill: var(--silver); font: 500 12px var(--mono); }
.chart-grid-line { stroke: var(--border); stroke-width: 1; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 24px;
}

.stat-grid div { background: var(--navy); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }

/* 4 stats, not the base grid's 3 — a leftover empty cell (no div to give it
   the tile background) would otherwise show the grid container's own
   border-color background as a stray, oddly-colored gray box. */
.about-stat-grid { grid-template-columns: repeat(4, 1fr); }
.stat-grid span { color: var(--silver); font: 600 9px/1 var(--sans); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-grid b { color: var(--ivory); font: 600 16px/1 var(--mono); }
.stat-grid small { color: var(--silver); font: 500 10px/1 var(--mono); }

.sentiment-row {
  display: flex;
  gap: 32px;
  margin-bottom: 24px;
}

.sentiment-row div { display: flex; align-items: center; gap: 10px; }
.sentiment-row span { color: var(--silver); font: 600 10px/1 var(--sans); text-transform: uppercase; letter-spacing: 0.06em; }

.fidelity-link {
  display: inline-block;
  color: var(--plum-light);
  font: 500 12px/1 var(--sans);
  border-bottom: 1px solid transparent;
}

.fidelity-link:hover { border-bottom-color: currentColor; }

/* About page */

.about-page { max-width: 720px; }

.about-intro { margin-bottom: 48px; }

.about-eyebrow {
  margin: 0 0 12px;
  color: var(--plum-light);
  font: 600 11px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.about-intro h1 {
  margin: 0 0 14px;
  color: var(--ivory);
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(28px, 4.5vw, 38px);
  line-height: 1.12;
}

.about-dek { margin: 0 0 28px; max-width: 56ch; color: var(--mist); font-size: 15.5px; }

.about-stat-grid { margin-bottom: 0; }

.about-phases { margin-top: 8px; }

.about-phase {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 0 24px;
}

.about-phase-rail { display: flex; flex-direction: column; align-items: center; }

.about-phase-num {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--navy);
  color: var(--plum-light);
  font-family: var(--display);
  font-weight: 700;
  font-size: 17px;
}

.about-phase-line { width: 1px; flex: 1; margin-top: 6px; background: var(--border-strong); }

.about-phase-body { padding-bottom: 44px; }

.about-phase h2 {
  margin: 4px 0 8px;
  color: var(--ivory);
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
}

.about-phase-sub {
  margin: 0 0 4px;
  color: var(--silver);
  font: 600 10.5px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.about-phase p { margin: 0 0 12px; max-width: 58ch; color: var(--mist); font-size: 14.5px; }

.about-did { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }

.about-did li {
  position: relative;
  padding-left: 20px;
  max-width: 56ch;
  color: var(--mist);
  font-size: 14px;
}

.about-did li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--plum-light);
  transform: rotate(45deg);
}

.about-did code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--navy);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--ivory);
}

.about-snag {
  margin-top: 4px;
  padding: 14px 18px 16px;
  border: 1px solid rgba(142, 90, 130, 0.32);
  border-radius: 10px;
  background: var(--plum-bg);
}

.about-snag-label {
  margin: 0 0 6px;
  color: var(--plum-light);
  font: 600 10.5px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.about-snag p { margin: 0; font-size: 13.5px; color: var(--mist); }
.about-snag p + p { margin-top: 8px; }
.about-snag strong { color: var(--ivory); font-weight: 600; }

.about-origin {
  margin: 8px 0 44px;
  padding: 22px 24px 24px;
  border: 1px solid rgba(142, 90, 130, 0.32);
  border-radius: 10px;
  background: var(--plum-bg);
}

.about-origin h2 {
  margin: 0 0 10px;
  color: var(--ivory);
  font-family: var(--display);
  font-weight: 700;
  font-size: 20px;
}

.about-origin p { margin: 0 0 12px; max-width: 58ch; color: var(--mist); font-size: 14.5px; }
.about-origin p:last-of-type { margin-bottom: 0; }
.about-origin em { color: var(--ivory); font-style: italic; }
.about-origin em a { color: var(--plum-light); border-bottom: 1px solid transparent; }
.about-origin em a:hover { border-bottom-color: currentColor; }

.about-origin-signature { color: var(--silver); font-size: 13px; font-style: italic; }

.about-closing { margin-top: 4px; }

.about-closing h2 {
  margin: 0 0 16px;
  color: var(--ivory);
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
}

.about-next-list { list-style: none; margin: 0 0 40px; padding: 0; display: grid; gap: 10px; }

.about-next-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--navy);
  color: var(--mist);
  font-size: 14px;
}

.about-next-list .dot {
  width: 7px;
  height: 7px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--plum-light);
}

.about-next-list a { display: block; flex: 1; color: inherit; transition: color 160ms ease; }
.about-next-list li:hover a { color: var(--plum-light); }

.about-back-bottom { margin-bottom: 0; }

/* DALI Tracker page */

.tracker-page { max-width: 900px; }

.tracker-intro { margin-bottom: 40px; }

.tracker-intro h1 {
  margin: 12px 0 14px;
  color: var(--ivory);
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(28px, 4.5vw, 38px);
  line-height: 1.12;
}

.tracker-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  background: var(--midnight);
}

.tracker-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.tracker-card-head h2 {
  margin: 0;
  color: var(--ivory);
  font-family: var(--display);
  font-weight: 700;
  font-size: 24px;
}

.tracker-name { display: block; color: var(--silver); font-size: 13px; margin-top: 2px; }

.tracker-trigger-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--silver);
  font: 500 12px/1 var(--mono);
}

.tracker-reasoning { margin: 0 0 8px; color: var(--mist); font-size: 13.5px; max-width: 62ch; }

.tracker-news { margin: 0 0 20px; font-size: 13px; max-width: 62ch; }
.tracker-news a { color: var(--silver); border-bottom: 1px solid transparent; transition: border-color 160ms ease, color 160ms ease; }
.tracker-news a:hover, .tracker-news a:focus-visible { color: var(--plum-light); border-bottom-color: currentColor; }

.tracker-stat-grid { margin-bottom: 20px; }

.tracker-stat-highlight { grid-column: span 2; }
.tracker-stat-highlight.tracker-gain { background: var(--gain-bg); }
.tracker-stat-highlight.tracker-loss { background: var(--loss-bg); }
.tracker-stat-highlight b { font-size: 22px; }
.tracker-stat-highlight.tracker-gain b { color: var(--gain); }
.tracker-stat-highlight.tracker-loss b { color: var(--loss); }

.tracker-gain { color: var(--gain); }
.tracker-loss { color: var(--loss); }

.tracker-chart-area-gain { fill: rgba(66, 196, 134, 0.14); stroke: none; }
.tracker-chart-area-loss { fill: rgba(240, 107, 120, 0.14); stroke: none; }
.tracker-chart-line-gain { fill: none; stroke: var(--gain); stroke-width: 2; }
.tracker-chart-line-loss { fill: none; stroke: var(--loss); stroke-width: 2; }

.tracker-summary {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 36px;
  background: var(--midnight);
}

.tracker-summary-headline {
  margin: 0 0 20px;
  color: var(--mist);
  font-size: 17px;
  line-height: 1.5;
}

.tracker-summary-headline b { color: var(--ivory); font-weight: 700; }

.tracker-chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }

.tracker-summary-invested-line { fill: none; stroke: var(--silver); stroke-width: 1.5; }

.tracker-summary-legend {
  display: flex;
  gap: 32px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.tracker-summary-legend-item { display: flex; flex-direction: column; gap: 6px; }

/* The other two legend items sit directly on the card's own background;
   this one gets the same tinted-box treatment as a card's $ Gain/Loss
   tile so the portfolio-wide total reads with the same at-a-glance
   emphasis as each individual position's. */
.tracker-summary-legend-item.tracker-stat-highlight { padding: 12px 16px; border-radius: 10px; justify-content: center; }

.tracker-summary-legend-item > span {
  display: inline-flex;
  align-items: center;
  color: var(--silver);
  font: 600 10.5px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* The hypothetical $ total is the number that actually matters here — the
   legend swatches just say which line on the chart it belongs to. */
.tracker-summary-legend-value { font: 700 16px/1 var(--mono); color: var(--ivory); }
.tracker-summary-legend-value-hero { font-size: 26px; }
/* Higher specificity than the plain .tracker-gain/.tracker-loss color rules
   (which come earlier in the file) so the hero number's color always wins
   regardless of source order. */
.tracker-summary-legend-value.tracker-gain { color: var(--gain); }
.tracker-summary-legend-value.tracker-loss { color: var(--loss); }

.legend-swatch { display: inline-block; width: 14px; height: 2px; margin-right: 6px; vertical-align: middle; }
.legend-swatch-invested { background: var(--silver); }
.legend-swatch-gain { background: var(--gain); }
.legend-swatch-loss { background: var(--loss); }

.tracker-empty { text-align: center; color: var(--silver); padding: 48px; max-width: 56ch; margin: 0 auto; }

/* Trade Challenge */

.league-section-title {
  margin: 40px 0 16px;
  color: var(--ivory);
  font-family: var(--display);
  font-weight: 600;
  font-size: 22px;
}

.league-account-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 32px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--navy);
}

.league-account-bar p { margin: 0; color: var(--mist); font-size: 13px; }
.league-account-bar b { color: var(--ivory); }

.league-cta-link {
  display: inline-flex;
  align-items: center;
  height: 44px;
  padding: 0 22px;
  text-decoration: none;
}

.league-positions-table { margin-top: 20px; }
.league-leaderboard-section { margin-top: 8px; }
.league-leaderboard-section .tracker-summary-headline { margin: 0 0 16px; }

.league-leaderboard-you { background: var(--plum-bg); }
.league-leaderboard-you td:first-child { color: var(--ivory); font-weight: 700; }

/* Picks page */

.league-search-field { display: block; margin-bottom: 8px; }
.league-search-field input { width: 100%; }

.league-search-results {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 20px;
}

.league-search-result {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--navy);
  color: var(--mist);
  font: 500 13px/1.4 var(--sans);
  text-align: left;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.league-search-result:hover,
.league-search-result:focus-visible { background: var(--plum-bg); border-color: var(--plum-light); }
.league-search-result b { color: var(--ivory); font-family: var(--mono); }
.league-search-result span:not(.num) { color: var(--silver); flex: 1; }
.league-search-result .num { color: var(--mist); font-family: var(--mono); }

.league-picks-table { margin-bottom: 20px; }

.league-allocate-input {
  width: 110px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--slate);
  color: var(--ivory);
  font: 600 13px/1 var(--mono);
  text-align: right;
}
.league-allocate-input:focus { border-color: var(--plum-light); outline: none; }

.league-remove-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: transparent;
  color: var(--silver);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}
.league-remove-btn:hover { background: var(--loss-bg); color: var(--loss); border-color: var(--loss); }

.league-picks-summary {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--navy);
}

.league-picks-summary div { display: flex; flex-direction: column; gap: 4px; }
.league-picks-summary span { color: var(--silver); font: 600 9px/1 var(--sans); text-transform: uppercase; letter-spacing: 0.06em; }
.league-picks-summary b { color: var(--ivory); font: 600 16px/1 var(--mono); }

.league-submit-btn { width: 100%; height: 48px; }
.league-submit-btn:disabled { opacity: 0.5; cursor: default; }

@media (max-width: 640px) {
  main { padding: 32px 20px 64px; }
  .site-header { height: calc(108px + env(safe-area-inset-top)); padding: 0 20px; padding-top: env(safe-area-inset-top); }
  .lockup-image { height: 84px; }
  .controls { flex-direction: column; align-items: flex-start; }
  .status { text-align: left; }
  .footer-text { align-items: flex-start; text-align: left; }
  .signup-card { flex-direction: column; align-items: stretch; }
  .league-account-bar { flex-direction: column; align-items: stretch; }
  .league-picks-summary { flex-direction: column; gap: 12px; }
  .signup-field input[type="email"] { min-width: 0; width: 100%; }
  .stock-title-row { flex-direction: column; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stock-asof { margin-left: 0; }
  .about-phase { grid-template-columns: 34px 1fr; gap: 0 14px; }
  .about-phase-num { width: 28px; height: 28px; font-size: 14px; }
  .tracker-card { padding: 18px; }
  /* SVG text is measured in the same viewBox units as the chart's own
     900-wide coordinate space, so on a ~280px-wide phone the whole graphic
     (text included) scales down by roughly 1/3 — a 12-13px label built for
     desktop renders at ~4px on screen. Bumping the viewBox-unit font size
     here (rather than the shared desktop rule above) restores it to a
     legible size once that scale-down is applied. chart-grid-label (the
     Y-axis dollar figures) is a separate class from chart-axis-label (the
     bottom-row dates) so it can grow this much on its own — every chart
     that uses it also gives it a dedicated right-hand margin (see
     tracker.js and stock.js) wide enough for this size, rather than
     fighting the plotted line for room. */
  .chart-axis-label { font-size: 46px; }
  .chart-grid-label { font-size: 56px; }
  .chart-grid-line { stroke-width: 3px; }
  .chart-low-line { stroke-width: 4px; }
  /* Same content crosses a much narrower screen far more often per minute
     at the same animation-duration, so it reads as scrolling faster than
     on desktop even though the CSS value is identical. Slow it down here
     specifically — tune this value directly based on feedback. */
  .ticker-track { animation-duration: 110s; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
  .ticker-track { animation: none; }
  .skeleton-bar { animation: none; }
}
