/* =============================================================================
   STOCKSAATHI — Component styles
   Scoped, namespaced, theme-aware.
   ============================================================================= */

/* ============================== NAV ================================= */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--divider);
  height: var(--nav-h);
  padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
}
[data-theme="dark"] .nav { background: rgba(10, 11, 15, 0.85); }

.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  height: 100%;
  padding: 0 var(--sp-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-5);
}
.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--text-strong);
  letter-spacing: -0.02em;
}
.brand-logo:hover { color: var(--text-strong); }
.logo-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: grid; place-items: center;
  color: white;
  font-weight: 800;
  font-size: 14px;
  box-shadow: var(--sh-sm);
}
.nav-links {
  display: flex;
  gap: var(--sp-1);
  align-items: center;
}
.nav-link {
  padding: 8px 14px;
  color: var(--text-muted);
  font-size: var(--text-md);
  font-weight: 500;
  border-radius: var(--r);
  transition: color var(--dur-1), background var(--dur-1);
}
.nav-link:hover { color: var(--text-strong); background: var(--bg-soft); }
.nav-link.active { color: var(--text-strong); background: var(--brand-soft); }
.nav-right {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.nav-cash {
  font-family: var(--font-mono);
  padding: 6px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r);
  display: flex; flex-direction: column;
  line-height: 1.15;
}
.nav-cash .label { font-size: 9px; color: var(--text-dim); margin-bottom: 0; letter-spacing: 0.06em; text-transform: uppercase; }
.nav-cash .val { font-weight: 700; font-size: var(--text-md); color: var(--text-strong); }
.nav-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--saffron), #E06B00);
  color: white;
  font-weight: 700;
  font-size: 13px;
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform var(--dur-1);
}
.nav-avatar:hover { transform: scale(1.05); }

@media (max-width: 820px) {
  .nav-inner { padding: 0 var(--sp-3); gap: var(--sp-2); }
  .nav-links { display: none; }
  .nav-cash { display: none; }
  .market-status { display: none; }
}

/* Hamburger button — only visible on mobile */
.nav-burger {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: var(--r);
  background: transparent;
  color: var(--text);
  place-items: center;
  border: 1px solid transparent;
  transition: background var(--dur-1);
}
.nav-burger:hover, .nav-burger:focus-visible {
  background: var(--bg-soft);
  border-color: var(--border);
}
.nav-burger svg { display: block; width: 22px; height: 22px; }
@media (max-width: 820px) {
  .nav-burger { display: grid; }
}

/* Site-wide theme toggle in the nav. Same subtle shape as the burger so
   it reads as "controls" rather than content. Shown on every page. */
.nav-theme-toggle {
  display: grid;
  width: 36px;
  height: 36px;
  border-radius: var(--r);
  background: transparent;
  color: var(--text-muted);
  place-items: center;
  border: 1px solid transparent;
  transition: background var(--dur-1), color var(--dur-1), border-color var(--dur-1);
  cursor: pointer;
}
.nav-theme-toggle:hover, .nav-theme-toggle:focus-visible {
  background: var(--bg-soft);
  border-color: var(--border);
  color: var(--text);
}
.nav-theme-toggle svg { display: block; }

/* Mobile drawer — slides in from the right when burger is tapped */
.nav-drawer {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: none;
  pointer-events: none;
}
.nav-drawer.open {
  display: block;
  pointer-events: auto;
}
.nav-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 26, 0.45);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity var(--dur-2) var(--ease);
}
.nav-drawer.open .nav-drawer-backdrop { opacity: 1; }
.nav-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 88vw);
  background: var(--surface);
  box-shadow: var(--sh-lg);
  padding: var(--sp-5);
  padding-top: calc(var(--sp-5) + env(safe-area-inset-top));
  padding-bottom: calc(var(--sp-5) + env(safe-area-inset-bottom));
  padding-right: calc(var(--sp-5) + env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  transform: translateX(100%);
  transition: transform var(--dur-2) var(--ease);
  overflow-y: auto;
}
.nav-drawer.open .nav-drawer-panel { transform: translateX(0); }
.nav-drawer-panel .drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}
.nav-drawer-panel .drawer-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--sp-3);
  border-radius: var(--r);
  color: var(--text);
  font-size: var(--text-base);
  font-weight: 500;
  min-height: 48px;
  transition: background var(--dur-1);
}
.nav-drawer-panel .drawer-link:hover,
.nav-drawer-panel .drawer-link:active,
.nav-drawer-panel .drawer-link.active {
  background: var(--bg-soft);
  color: var(--text-strong);
}
.nav-drawer-panel .drawer-link.active {
  background: var(--brand-soft);
}
.nav-drawer-panel .drawer-divider {
  height: 1px;
  background: var(--divider);
  margin: var(--sp-2) 0;
}
.nav-drawer-panel .drawer-section {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--sp-2) var(--sp-3) 4px;
}
.nav-drawer-panel .drawer-stat {
  padding: var(--sp-3);
  background: var(--bg-soft);
  border-radius: var(--r);
  margin-bottom: var(--sp-2);
}
.nav-drawer-panel .drawer-stat .val {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--text-strong);
  letter-spacing: -0.02em;
}

/* ============================== COACH PANEL ========================= */
.coach-panel {
  position: fixed;
  top: var(--nav-h);
  right: 0;
  bottom: 0;
  width: var(--coach-w);
  background: var(--surface);
  border-left: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transform: translateX(100%);
  transition: transform var(--dur-2) var(--ease);
  box-shadow: var(--sh-md);
}
.coach-panel.open { transform: translateX(0); }
body.coach-docked .coach-panel { transform: translateX(0); box-shadow: none; border-left-color: var(--divider); }

.coach-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--divider);
}
.coach-header-title {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-weight: 600;
  font-size: var(--text-md);
}
.coach-avatar-sm {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: grid; place-items: center;
  color: white;
  font-weight: 800;
  font-size: 13px;
}
.coach-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.coach-message {
  display: flex;
  flex-direction: column;
  animation: slideUp 320ms var(--ease);
}
.coach-bubble {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-md);
  line-height: 1.55;
  color: var(--text);
}
.coach-bubble.strong-caution {
  border-color: var(--negative);
  background: var(--negative-soft);
}
.coach-bubble.caution {
  border-color: var(--warning);
  background: var(--warning-soft);
}
.coach-bubble-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-2);
  font-size: var(--text-xs);
  color: var(--text-dim);
}
.coach-context {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px dashed var(--border);
  font-style: italic;
}
.coach-question {
  margin-top: var(--sp-2);
  font-weight: 500;
  color: var(--text-strong);
  font-size: var(--text-md);
}
.coach-citations {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: var(--sp-2);
}
.coach-citation {
  font-size: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
}
.coach-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  gap: var(--sp-3);
  color: var(--text-muted);
  padding: var(--sp-8);
}
.coach-empty .emoji { font-size: 40px; }
.coach-footer {
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--divider);
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}

.coach-fab {
  position: fixed;
  bottom: calc(var(--sp-5) + env(safe-area-inset-bottom));
  right: calc(var(--sp-5) + env(safe-area-inset-right));
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  box-shadow: var(--sh-md);
  z-index: 39;
  display: grid;
  place-items: center;
  font-size: 22px;
  transition: transform var(--dur-2) var(--ease);
}
.coach-fab:hover, .coach-fab:focus-visible { transform: scale(1.08); background: var(--brand-dark); }
.coach-fab:active { transform: scale(0.95); }
.coach-fab .dot {
  position: absolute;
  top: 8px; right: 8px;
  width: 10px; height: 10px;
  background: var(--negative);
  border-radius: 50%;
  border: 2px solid var(--surface);
}

@media (min-width: 1280px) { .coach-fab { display: none; } }
@media (max-width: 1279px) {
  body.coach-docked { padding-right: 0; }
  .coach-panel {
    top: 0;
    width: min(420px, 100vw);
    height: 100vh;
    height: 100dvh;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-right: env(safe-area-inset-right);
  }
}
@media (max-width: 480px) {
  .coach-panel {
    width: 100vw;
    border-left: none;
  }
  .coach-fab {
    width: 52px; height: 52px;
    font-size: 20px;
  }
}

/* ============================== MODAL =============================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 20, 0.55);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  animation: fadeIn var(--dur-2) var(--ease);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  max-width: 520px;
  width: 100%;
  box-shadow: var(--sh-lg);
  animation: slideUp var(--dur-2) var(--ease);
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 520px) {
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    max-height: 88vh;
    max-height: 88dvh;
    padding: var(--sp-5) var(--sp-4) calc(var(--sp-5) + env(safe-area-inset-bottom));
    animation: slideUpSheet 260ms var(--ease);
  }
  @keyframes slideUpSheet {
    from { opacity: 0; transform: translateY(20%); }
    to { opacity: 1; transform: translateY(0); }
  }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
}
.modal-head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.modal-icon {
  width: 48px; height: 48px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  font-size: 22px;
  flex-shrink: 0;
}
.modal-icon.warn { background: var(--warning-soft); color: var(--warning); }
.modal-icon.danger { background: var(--negative-soft); color: var(--negative); }
.modal-icon.info { background: var(--accent-soft); color: var(--accent); }
.modal-icon.success { background: var(--positive-soft); color: var(--positive); }
.modal h2 { font-size: var(--text-xl); margin: 0; }
.modal-body { color: var(--text-muted); line-height: 1.65; font-size: var(--text-md); }
.modal-body p + p { margin-top: var(--sp-3); }
.modal-foot {
  display: flex;
  gap: var(--sp-3);
  justify-content: flex-end;
  margin-top: var(--sp-5);
  flex-wrap: wrap;
}

.intervention-data {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: var(--sp-4);
  margin: var(--sp-4) 0;
}
.intervention-data .big-num {
  font-family: var(--font-mono);
  font-size: var(--text-4xl);
  font-weight: 700;
  color: var(--positive);
  line-height: 1;
  letter-spacing: -0.03em;
}
.intervention-data .big-num.red { color: var(--negative); }
.intervention-data .sublabel {
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin-top: var(--sp-2);
}

/* ============================== TOAST =============================== */
.toast-root {
  position: fixed;
  bottom: calc(var(--sp-6) + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--sp-2);
  pointer-events: none;
  width: calc(100vw - var(--sp-6));
  max-width: 480px;
  padding: 0 var(--sp-2);
}
@media (max-width: 420px) {
  .toast-root { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .toast { min-width: 0; width: 100%; }
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--r);
  box-shadow: var(--sh-md);
  font-size: var(--text-md);
  min-width: 260px;
  max-width: 420px;
  animation: slideUp var(--dur-2) var(--ease);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  pointer-events: auto;
  font-weight: 500;
}
.toast.success { border-left: 3px solid var(--positive); }
.toast.error { border-left: 3px solid var(--negative); }
.toast.warn { border-left: 3px solid var(--warning); }
.toast.info { border-left: 3px solid var(--accent); }
.toast .toast-icon {
  font-size: var(--text-lg);
  line-height: 1;
  flex-shrink: 0;
}
.toast.leaving { animation: toastOut 220ms var(--ease) forwards; }
@keyframes toastOut {
  to { opacity: 0; transform: translateY(8px); }
}

/* ============================== CHART primitives ==================== */
.chart-svg { display: block; width: 100%; height: auto; font-family: var(--font-mono); }
.chart-axis-label { fill: var(--text-strong); font-size: 11px; font-weight: 600; }
.chart-grid line { stroke: var(--divider); stroke-dasharray: 2 3; }
.chart-line { fill: none; stroke-width: 2; }
.chart-area { fill-opacity: 0.12; }
.chart-tooltip {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  padding: 8px 12px;
  font-size: var(--text-xs);
  box-shadow: var(--sh-md);
  pointer-events: none;
  z-index: 10;
  font-family: var(--font-mono);
  white-space: nowrap;
}
.chart-candle-up { fill: var(--positive); stroke: var(--positive); }
.chart-candle-down { fill: var(--negative); stroke: var(--negative); }

/* Today's market mood — AI one-paragraph summary at top of /#/stocks */
.market-mood-card {
  padding: var(--sp-4);
  border-radius: var(--r-lg, var(--r));
  background: var(--bg-soft);
  border: 1px solid var(--divider);
  margin-bottom: var(--sp-4);
}
.market-mood-card.mood-hot   { border-top: 3px solid var(--negative); }
.market-mood-card.mood-warm  { border-top: 3px solid var(--brand); }
.market-mood-card.mood-mild  { border-top: 3px solid var(--text-muted); }
.market-mood-card.mood-cold  { border-top: 3px solid var(--positive); opacity: 0.95; }
.mood-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.mood-pill {
  font-size: var(--text-10);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 10px;
  border-radius: var(--r-full);
}
.mood-pill.mood-hot  { background: var(--negative-soft); color: var(--negative); }
.mood-pill.mood-warm { background: color-mix(in srgb, var(--brand) 15%, transparent); color: var(--brand); }
.mood-pill.mood-mild { background: var(--bg-soft); color: var(--text-muted); }
.mood-pill.mood-cold { background: var(--positive-soft); color: var(--positive); }
.mood-body { line-height: 1.55; color: var(--text-strong); font-size: var(--text-md); }

.ai-search-result-card {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r);
  background: color-mix(in srgb, var(--brand) 6%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--brand) 25%, var(--border));
  margin-bottom: var(--sp-3);
}

/* Stock "Why is this moving?" AI card on the detail page */
.stock-why-card {
  border-left: 3px solid var(--brand);
}
.stock-why-card .card-head h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-md);
}
#stock-why-body {
  font-size: var(--text-md);
  line-height: 1.6;
  color: var(--text-strong);
}

/* Portfolio daily digest card — one-paragraph AI take at the top of
   /#/portfolio, tinted subtly by day mood. Loads async then fades in. */
.pf-digest-card {
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-lg, var(--r));
  background: var(--bg-soft);
  border: 1px solid var(--divider);
  margin-bottom: var(--sp-4);
  position: relative;
  overflow: hidden;
}
.pf-digest-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--brand);
  opacity: 0.7;
}
.pf-digest-card.mood-up::before   { background: var(--positive); }
.pf-digest-card.mood-down::before { background: var(--negative); }
.pf-digest-card.mood-flat::before { background: var(--text-muted); }
.pf-digest-card.mood-empty::before { background: var(--brand); }
.pf-digest-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.pf-digest-label {
  font-size: var(--text-10);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--brand);
  padding: 3px 8px;
  border-radius: var(--r-full);
  background: color-mix(in srgb, var(--brand) 12%, transparent);
}
.pf-digest-body {
  font-size: var(--text-md);
  line-height: 1.6;
  color: var(--text-strong);
}

/* AI term wrapper — subtle dotted underline on terms that have an AI
   hover explainer wired. Doesn't look clickable; looks like a hint.
   Tooltip pops on :hover / :focus and fetches the definition lazily. */
.ai-term {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  text-decoration-color: var(--text-muted);
  text-decoration-thickness: 1px;
  cursor: help;
  font-style: normal;
}
.ai-term:hover, .ai-term:focus-visible {
  text-decoration-color: var(--brand);
  color: var(--text-strong);
  outline: none;
}
.ai-term-tooltip {
  position: absolute;
  z-index: 999;
  max-width: 280px;
  background: var(--surface-elev, var(--surface));
  color: var(--text);
  border: 1px solid var(--border-strong, var(--border));
  border-radius: var(--r);
  padding: 10px 12px;
  font-size: var(--text-sm);
  line-height: 1.45;
  box-shadow: var(--sh-lg, var(--sh-md));
  pointer-events: none;
  animation: ai-tip-in 140ms var(--ease, ease-out);
}
.ai-term-tooltip-head {
  font-weight: 700;
  font-size: var(--text-xs);
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.ai-term-tooltip-body { color: var(--text); }
@keyframes ai-tip-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Hover cursor: single vertical guide line + breathing price-dot. The
   line tracks cursor X; the dot bar-snaps to the nearest candle's close
   (matches the numbers in the tooltip) and colour-flips green/red vs the
   range's first close.
   Animation technique: animate SVG `r` + `opacity` DIRECTLY, never
   `transform: scale()` with transform-box:fill-box — that combo was what
   made the halo "drift" during mousemove on some browsers (the fill-box
   origin doesn't always resolve consistently during attribute updates,
   so the scale centre decoupled from the moving cx/cy and you saw
   jitter). Animating r is a pure radial expand from the true centre
   defined by cx/cy, immune to that issue. */
.chart-cursor-x { pointer-events: none; }
.chart-dot-halo, .chart-dot-core { pointer-events: none; }
.chart-dot-halo.breathing {
  animation: chart-dot-pulse 1.8s ease-in-out infinite;
}
.chart-dot-core.breathing {
  animation: chart-dot-shimmer 1.8s ease-in-out infinite;
}
@keyframes chart-dot-pulse {
  0%, 100% { r: 8;  opacity: 0.18; }
  50%      { r: 12; opacity: 0.38; }
}
@keyframes chart-dot-shimmer {
  0%, 100% { r: 4.5; opacity: 1;    }
  50%      { r: 5;   opacity: 0.92; }
}
@media (prefers-reduced-motion: reduce) {
  .chart-dot-halo.breathing, .chart-dot-core.breathing { animation: none; }
  .chart-dot-halo { opacity: 0.22; }
}

/* ============================== LANDING / HERO ====================== */
.hero {
  text-align: center;
  padding: var(--sp-20) var(--sp-4) var(--sp-16);
  max-width: 920px;
  margin: 0 auto;
}
@media (max-width: 640px) {
  .hero { padding: var(--sp-10) var(--sp-3) var(--sp-8); }
  .hero .tagline { font-size: var(--text-base); }
  .hero .cta-row { flex-direction: column; width: 100%; }
  .hero .cta-row .btn { width: 100%; }
  .hero .stat-row { margin-top: var(--sp-6); grid-template-columns: 1fr; }
  .hero .stat { padding: var(--sp-4); }
}
.hero h1 {
  font-size: clamp(2.2rem, 6vw, 4.25rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
  margin-bottom: var(--sp-5);
  color: var(--text-strong);
}
.hero .grad-accent { color: var(--brand); }
.hero .tagline {
  font-size: var(--text-lg);
  color: var(--text-muted);
  margin-bottom: var(--sp-6);
  max-width: 680px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.55;
}
.hero .cta-row {
  display: flex;
  gap: var(--sp-3);
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: var(--sp-8);
}
.hero .stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-4);
  max-width: 820px;
  margin: var(--sp-10) auto 0;
}
.hero .stat {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  background: var(--surface);
  transition: transform var(--dur-2) var(--ease), border-color var(--dur-1);
}
.hero .stat:hover { transform: translateY(-2px); border-color: var(--brand); }
.hero .stat .n {
  font-family: var(--font-mono);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--brand);
  letter-spacing: -0.03em;
  display: block;
  line-height: 1;
}
.hero .stat .l {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--sp-2);
}
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--sp-4);
  margin: var(--sp-16) 0;
}
.feature-card {
  padding: var(--sp-5);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  transition: transform var(--dur-2) var(--ease), border-color var(--dur-1);
}
.feature-card:hover {
  transform: translateY(-3px);
  border-color: var(--brand);
  box-shadow: var(--sh-sm);
}
.feature-card .icon {
  font-size: 26px;
  display: inline-grid;
  place-items: center;
  width: 48px; height: 48px;
  border-radius: var(--r-md);
  background: var(--brand-soft);
  margin-bottom: var(--sp-3);
}
.feature-card h3 {
  font-size: var(--text-lg);
  margin-bottom: var(--sp-2);
}
.feature-card p {
  color: var(--text-muted);
  font-size: var(--text-md);
  line-height: 1.65;
}

/* ============================== PORTFOLIO =========================== */
.portfolio-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--sp-5);
  align-items: end;
  margin-bottom: var(--sp-5);
}
@media (max-width: 600px) {
  .portfolio-hero { grid-template-columns: 1fr; }
}
.pf-value {
  font-family: var(--font-mono);
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text-strong);
}
.pf-delta {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  margin-top: 6px;
  font-weight: 600;
}
.portfolio-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.stat-tile {
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.stat-tile .l {
  font-size: var(--text-10);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.stat-tile .v {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-strong);
}

.portfolio-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-5);
}
@media (min-width: 1024px) {
  .portfolio-grid { grid-template-columns: 2fr 1fr; }
}
/* Compact holdings table on phones */
@media (max-width: 600px) {
  .table-wrap { font-size: var(--text-sm); }
  .table th, .table td { padding: 10px 12px; }
  .pf-value { font-size: clamp(1.75rem, 9vw, 2.25rem); }
  .portfolio-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ============================== STOCKS LIST ========================= */
.stocks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--sp-4);
}
@media (max-width: 480px) {
  .stocks-grid { grid-template-columns: 1fr; }
}
.stock-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  cursor: pointer;
  transition: transform var(--dur-2) var(--ease), border-color var(--dur-1), box-shadow var(--dur-1);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.stock-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
  box-shadow: var(--sh-sm);
}
.stock-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-2);
}
.stock-avatar {
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  display: grid; place-items: center;
  font-weight: 700;
  font-size: var(--text-xs);
  flex-shrink: 0;
}
.stock-title { flex: 1; min-width: 0; }
.stock-title .name {
  font-weight: 600;
  font-size: var(--text-md);
  color: var(--text-strong);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stock-title .sym {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-dim);
  margin-top: 2px;
}
.stock-price {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.02em;
}
.stock-change {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
}
.stock-sparkline { height: 40px; width: 100%; margin-top: auto; }

.stocks-toolbar {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}
.stocks-toolbar .input-prefix { max-width: 360px; flex: 1; }

.filter-pills {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.filter-pill {
  padding: 7px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--r-full);
  transition: all var(--dur-1);
}
.filter-pill.active {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}
.filter-pill:hover:not(.active) {
  color: var(--text-strong);
  border-color: var(--border-strong);
}

.risk-pill {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  background: var(--bg-soft);
  color: var(--text-muted);
}
.risk-pill.low { background: var(--positive-soft); color: var(--positive); }
.risk-pill.med { background: var(--warning-soft); color: var(--warning); }
.risk-pill.high { background: var(--negative-soft); color: var(--negative); }

.data-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-dim);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  background: var(--bg-soft);
}
.data-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--positive); animation: pulse-dot 2s infinite; }
.data-badge .dot.offline { background: var(--text-faint); animation: none; }

/* ============================== STOCK DETAIL ======================== */
.stock-detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-5);
}
@media (min-width: 960px) {
  .stock-detail-grid { grid-template-columns: 1.55fr 1fr; align-items: start; }
}
/* On phones, trade box jumps above the chart so it's immediately reachable */
@media (max-width: 640px) {
  .stock-detail-grid { gap: var(--sp-4); }
  .price-block { flex-direction: column; align-items: flex-start; gap: var(--sp-2); }
  .price-block .price { font-size: clamp(1.8rem, 9vw, 2.4rem); }
  .tf-buttons { width: 100%; overflow-x: auto; justify-content: flex-start; flex-wrap: nowrap; }
}

.price-block {
  display: flex;
  align-items: baseline;
  gap: var(--sp-4);
  flex-wrap: wrap;
}
.price-block .price {
  font-family: var(--font-mono);
  font-size: clamp(2.2rem, 5vw, 2.85rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text-strong);
}
.price-block .change {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 600;
}
.tf-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin: var(--sp-4) 0;
  padding: 4px;
  background: var(--bg-soft);
  border-radius: var(--r);
  width: fit-content;
}
.tf-btn {
  padding: 6px 14px;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--r-sm);
  transition: all var(--dur-1);
}
.tf-btn.active {
  background: var(--surface);
  color: var(--text-strong);
  box-shadow: var(--sh-xs);
}
.tf-btn:hover:not(.active) {
  color: var(--text-strong);
}

.trade-box {
  position: sticky;
  top: calc(var(--nav-h) + var(--sp-4));
}
@media (max-width: 960px) {
  .trade-box { position: static; }
}
.trade-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: var(--sp-4);
  background: var(--bg-soft);
  padding: 4px;
  border-radius: var(--r);
}
.trade-tab {
  padding: 10px;
  text-align: center;
  font-weight: 700;
  font-size: var(--text-md);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  transition: all var(--dur-1);
}
.trade-tab.active.buy {
  background: var(--positive);
  color: white;
  box-shadow: var(--sh-xs);
}
.trade-tab.active.sell {
  background: var(--negative);
  color: white;
  box-shadow: var(--sh-xs);
}

.qty-stepper {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.qty-stepper button {
  width: 40px; height: 44px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-md);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
  transition: background var(--dur-1);
}
.qty-stepper button:hover { background: var(--bg-soft); border-color: var(--border-strong); }
.qty-stepper .input { text-align: center; font-family: var(--font-mono); font-weight: 700; }

.qty-quick-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}
.qty-quick {
  padding: 7px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 700;
  border-radius: var(--r-sm);
  transition: all var(--dur-1);
}
.qty-quick:hover { color: var(--text-strong); border-color: var(--border-strong); }
.qty-quick.active { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }

.qty-slider-wrap {
  margin: var(--sp-3) 0;
}
.qty-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 4px;
  background: var(--bg-soft);
  cursor: pointer;
  outline: none;
}
.qty-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--surface);
  box-shadow: var(--sh-sm);
  cursor: grab;
}
.qty-slider::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--surface);
  box-shadow: var(--sh-sm);
  cursor: grab;
}

.order-summary {
  background: var(--bg-soft);
  padding: var(--sp-4);
  border-radius: var(--r);
  margin: var(--sp-4) 0;
  font-size: var(--text-md);
}
.order-summary .row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  color: var(--text-muted);
}
.order-summary .row.total {
  border-top: 1px solid var(--border);
  margin-top: var(--sp-2);
  padding-top: var(--sp-3);
  font-weight: 700;
  font-size: var(--text-base);
  color: var(--text-strong);
}
.order-summary .num { font-family: var(--font-mono); color: var(--text-strong); font-weight: 600; }

.fundamentals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--sp-3);
}
.fundamentals .item {
  padding: var(--sp-3);
  background: var(--bg-soft);
  border-radius: var(--r);
}
.fundamentals .l {
  font-size: var(--text-10);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}
.fundamentals .v {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--text-md);
  color: var(--text-strong);
}

/* ============================== CRASH REPLAY ======================== */
.crash-hero {
  text-align: center;
  padding: var(--sp-5) 0 var(--sp-6);
}
.crash-hero h1 {
  font-size: clamp(1.9rem, 4.5vw, 3rem);
  letter-spacing: -0.035em;
  margin-bottom: var(--sp-3);
}
.crash-scenarios {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}
.crash-scenario {
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: all var(--dur-2) var(--ease);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  font-family: inherit;
}
.crash-scenario:hover {
  border-color: var(--brand);
  transform: translateY(-3px);
  box-shadow: var(--sh-sm);
}
.crash-scenario h4 { font-size: var(--text-lg); color: var(--text-strong); }
.crash-scenario .desc { font-size: var(--text-md); color: var(--text-muted); line-height: 1.55; }
.crash-scenario .meta { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-dim); margin-top: auto; }

.replay-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  position: relative;
  overflow: hidden;
  box-shadow: var(--sh-xs);
}

.replay-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}
@media (max-width: 640px) {
  .replay-stats { grid-template-columns: 1fr; gap: var(--sp-3); }
  .replay-stat { padding: var(--sp-4); }
  .replay-panel { padding: var(--sp-4); }
  .replay-slider-wrap { padding: var(--sp-3) var(--sp-4); }
  .replay-controls .btn-sm { flex: 1 0 auto; }
}
.replay-stat {
  padding: var(--sp-5);
  border-radius: var(--r-lg);
  border: 1.5px solid var(--border);
  background: var(--surface);
  transition: border-color var(--dur-2) var(--ease);
}
.replay-stat.held { border-color: var(--positive); background: linear-gradient(180deg, var(--positive-soft), transparent 60%); }
.replay-stat.panic { border-color: var(--negative); background: linear-gradient(180deg, var(--negative-soft), transparent 60%); }
.replay-stat .header { display: flex; justify-content: space-between; margin-bottom: var(--sp-3); font-size: var(--text-sm); color: var(--text-muted); font-weight: 600; }
.replay-stat .big { font-family: var(--font-mono); font-size: clamp(1.6rem, 4vw, 2.35rem); font-weight: 700; letter-spacing: -0.03em; line-height: 1; color: var(--text-strong); }
.replay-stat .delta { font-family: var(--font-mono); font-size: var(--text-md); margin-top: var(--sp-2); font-weight: 700; }
.replay-stat.held .delta { color: var(--positive); }
.replay-stat.panic .delta { color: var(--negative); }
.replay-stat.held .header > span:first-child { color: var(--positive); }
.replay-stat.panic .header > span:first-child { color: var(--negative); }

.replay-slider-wrap {
  background: var(--bg-soft);
  padding: var(--sp-4) var(--sp-6);
  border-radius: var(--r-lg);
  margin: var(--sp-5) 0;
}
.replay-slider-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
}
.replay-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--positive) 0%, var(--warning) 50%, var(--negative) 100%);
  outline: none;
  cursor: pointer;
}
.replay-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--brand);
  box-shadow: var(--sh-md);
  cursor: grab;
}
.replay-slider::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--brand);
  cursor: grab;
}

.replay-controls {
  display: flex;
  gap: var(--sp-2);
  justify-content: center;
  margin: var(--sp-4) 0;
  flex-wrap: wrap;
}

/* Sticky top-of-page bar: back link + inline title + playback controls.
   Keeps the play / slow / reset / bottom / end buttons above the fold
   on every resolution so users can start the replay without scrolling. */
.replay-topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: var(--sp-3) 0;
  margin-bottom: var(--sp-3);
  position: sticky;
  top: 60px;
  z-index: 40;
  background: var(--bg);
  border-bottom: 1px solid var(--divider);
}
.replay-title-inline {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  flex: 1 1 auto;
  min-width: 0;
}
.replay-title-inline strong {
  font-size: var(--text-lg);
  color: var(--text-strong);
}
.replay-controls-top {
  margin: 0;
  justify-content: flex-end;
}
.replay-context-details {
  margin-top: var(--sp-5);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-soft);
  border: 1px solid var(--divider);
  border-radius: var(--r);
}
.replay-context-details summary {
  cursor: pointer;
  font-size: var(--text-sm);
  user-select: none;
}
@media (max-width: 680px) {
  .replay-topbar { top: 56px; flex-direction: column; align-items: stretch; }
  .replay-controls-top { justify-content: center; }
  .replay-controls-top .btn-sm { flex: 1 0 auto; }
  .replay-title-inline strong { font-size: var(--text-md); }
}
.replay-narration {
  background: var(--bg-soft);
  border-left: 3px solid var(--brand);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r);
  font-size: var(--text-md);
  line-height: 1.6;
  color: var(--text);
  min-height: 80px;
  transition: opacity 0.25s;
}
.replay-narration.fading { opacity: 0; }

.replay-final-banner {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: white;
  padding: var(--sp-5);
  border-radius: var(--r-lg);
  text-align: center;
  margin-top: var(--sp-4);
  font-weight: 600;
  font-size: var(--text-lg);
  animation: slideUp 400ms var(--ease);
  box-shadow: var(--sh-md);
}
.replay-final-banner .num {
  font-family: var(--font-mono);
  font-size: var(--text-3xl);
  font-weight: 700;
  display: block;
  margin-top: var(--sp-1);
  letter-spacing: -0.02em;
}

/* ============================== LEADERBOARD ========================= */
.lb-tabs {
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--bg-soft);
  border-radius: var(--r);
  width: fit-content;
}
.lb-tab {
  padding: 7px 14px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--r-sm);
  transition: all var(--dur-1);
}
.lb-tab.active {
  background: var(--surface);
  color: var(--text-strong);
  box-shadow: var(--sh-xs);
}
.lb-row-user {
  background: var(--brand-soft) !important;
}
.lb-rank {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--text-md);
  width: 32px;
  display: inline-block;
  text-align: center;
  color: var(--text-muted);
}
.lb-rank.top3 {
  background: var(--brand);
  color: white;
  border-radius: 50%;
  height: 28px;
  line-height: 28px;
}
.lb-name { font-weight: 600; color: var(--text-strong); }
.lb-school { font-size: var(--text-xs); color: var(--text-dim); }

/* ============================== REPORT CARD ========================= */
.report-grade {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  padding: var(--sp-6);
  background: linear-gradient(135deg, var(--brand-soft), transparent);
  border: 1px solid var(--brand);
  border-radius: var(--r-xl);
  margin-bottom: var(--sp-5);
}
@media (max-width: 640px) { .report-grade { flex-direction: column; text-align: center; } }
.report-grade-circle {
  width: 110px; height: 110px;
  border-radius: 50%;
  background: conic-gradient(var(--brand) calc(var(--pct, 70) * 1%), var(--bg-soft) 0);
  display: grid; place-items: center;
  flex-shrink: 0;
  position: relative;
}
.report-grade-circle::before {
  content: "";
  position: absolute;
  inset: 7px;
  background: var(--surface);
  border-radius: 50%;
}
.report-grade-circle .letter {
  position: relative;
  font-size: var(--text-4xl);
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.05em;
}

.behavior-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.behavior-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--sp-4);
  align-items: center;
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-soft);
  border-radius: var(--r);
}
.behavior-row .icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: var(--text-md);
  font-weight: 700;
}
.behavior-row .icon.good { background: var(--positive-soft); color: var(--positive); }
.behavior-row .icon.warn { background: var(--warning-soft); color: var(--warning); }
.behavior-row .icon.bad { background: var(--negative-soft); color: var(--negative); }
.behavior-row .name { font-weight: 600; font-size: var(--text-md); color: var(--text-strong); }
.behavior-row .desc { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }
.behavior-row .count { font-family: var(--font-mono); font-size: var(--text-xl); font-weight: 700; }

.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--sp-3);
}
.badge-card {
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  text-align: center;
  transition: all var(--dur-2) var(--ease);
}
.badge-card.earned {
  border-color: var(--brand);
  background: linear-gradient(180deg, var(--brand-soft), var(--surface));
}
.badge-card .emoji { font-size: 30px; }
.badge-card .title { font-weight: 600; font-size: var(--text-sm); margin-top: var(--sp-1); color: var(--text-strong); }
.badge-card .desc { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; line-height: 1.45; }
.badge-card.locked { opacity: 0.35; filter: grayscale(1); }

/* ============================== ONBOARDING ========================== */
.onboard-wrap {
  max-width: 480px;
  margin: var(--sp-10) auto;
  padding: 0 var(--sp-4);
}
.onboard-steps {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
  position: relative;
}
.onboard-steps::before {
  content: "";
  position: absolute;
  top: 15px;
  left: 18px;
  right: 18px;
  height: 2px;
  background: var(--border);
}
.onboard-step {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  background: var(--bg);
  padding: 0 var(--sp-2);
}
.onboard-step .dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
  display: grid; place-items: center;
  font-weight: 700;
  font-size: var(--text-sm);
  border: 2px solid var(--border);
  transition: all var(--dur-2) var(--ease);
}
.onboard-step.active .dot {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
  transform: scale(1.08);
}
.onboard-step.done .dot {
  background: var(--positive);
  color: white;
  border-color: var(--positive);
}
.onboard-step .label {
  font-size: var(--text-11);
  color: var(--text-dim);
  text-align: center;
  font-weight: 500;
}
.onboard-step.active .label { color: var(--text-strong); font-weight: 600; }

/* FIXED: Risk quiz options no longer stretch full-width awkwardly; they are
   compact rows with tight padding, left-aligned radio + body, consistent */
.quiz-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin: var(--sp-4) 0;
}
.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--dur-1);
  position: relative;
}
.quiz-option:hover {
  border-color: var(--border-strong);
  background: var(--bg-soft);
}
.quiz-option.selected {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.quiz-option input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--brand);
  flex-shrink: 0;
  cursor: pointer;
}
.quiz-option .body { flex: 1; min-width: 0; }
.quiz-option .main { font-weight: 600; color: var(--text-strong); font-size: var(--text-md); line-height: 1.3; }
.quiz-option .desc { font-size: var(--text-sm); color: var(--text-muted); margin-top: 3px; line-height: 1.45; }

/* ============================== RISK CARDS (onboarding) ============ */
.risk-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
  margin: var(--sp-4) 0;
}
@media (max-width: 600px) {
  .risk-cards { grid-template-columns: 1fr; gap: var(--sp-2); }
  .risk-card { flex-direction: row; text-align: left; padding: var(--sp-3) var(--sp-4); align-items: center; gap: var(--sp-3); }
  .risk-card .risk-icon { font-size: 22px; }
}
.risk-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4) var(--sp-3);
  text-align: center;
  cursor: pointer;
  transition: all var(--dur-1) var(--ease);
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}
.risk-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-soft);
  transform: translateY(-2px);
}
.risk-card.selected {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: var(--sh-xs);
}
.risk-icon { font-size: 26px; line-height: 1; }
.risk-title { font-weight: 700; color: var(--text-strong); font-size: var(--text-md); }
.risk-desc { font-size: var(--text-xs); color: var(--text-muted); line-height: 1.45; }

/* ============================== COACH CHAT (panel) ================= */
.coach-chat-input {
  display: flex;
  gap: 6px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--divider);
  background: var(--surface);
}
.coach-chat-input input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 8px 12px;
  font-size: var(--text-sm);
  outline: none;
  background: var(--bg-soft);
}
.coach-chat-input input:focus {
  border-color: var(--brand);
  background: var(--surface);
}
.coach-chat-input button {
  background: var(--brand);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: var(--r);
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
}
.coach-chat-input button:hover { background: var(--brand-dark); }
.coach-chat-input button:disabled { opacity: 0.5; cursor: not-allowed; }
.coach-user-msg {
  align-self: flex-end;
  max-width: 82%;
  background: var(--brand);
  color: white;
  padding: 8px 12px;
  border-radius: 14px 14px 4px 14px;
  font-size: var(--text-sm);
  line-height: 1.5;
  box-shadow: var(--sh-xs);
  animation: slideUp 280ms var(--ease);
}

/* ============================== CRASH CALLOUTS ===================== */
.replay-callout {
  background: linear-gradient(135deg, var(--saffron-soft), transparent);
  border: 1px solid var(--saffron);
  border-radius: var(--r);
  padding: 10px 14px;
  margin-top: var(--sp-3);
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--text);
  animation: slideUp 320ms var(--ease);
}
.replay-callout strong { color: var(--saffron); }

.replay-markers {
  position: relative;
  height: 22px;
  margin: 4px 0 -6px;
}
.replay-marker {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  padding: 1px 6px;
  border-radius: 4px;
  transition: color var(--dur-1);
}
.replay-marker::before {
  content: "";
  display: block;
  width: 2px;
  height: 6px;
  background: var(--text-faint);
  margin: 0 auto 2px;
}
.replay-marker:hover { color: var(--brand); }
.replay-marker.active { color: var(--brand); }
.replay-marker.active::before { background: var(--brand); }

.crash-mood {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  margin-top: 6px;
  color: var(--text-muted);
}
.mood-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: 700;
}
.mood-indicator.calm { background: var(--positive-soft); color: var(--positive); }
.mood-indicator.nervous { background: var(--warning-soft); color: var(--warning); }
.mood-indicator.panic { background: var(--negative-soft); color: var(--negative); }
.mood-indicator.euphoric { background: var(--accent-soft); color: var(--accent); }

/* ============================== SETTINGS =========================== */
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--divider);
  gap: var(--sp-4);
}
.settings-row:last-child { border-bottom: none; }
.settings-row .label-wrap { flex: 1; min-width: 0; }
.settings-row .label-wrap .title { font-weight: 600; color: var(--text-strong); margin-bottom: 2px; font-size: var(--text-md); }
.settings-row .label-wrap .desc { font-size: var(--text-xs); color: var(--text-muted); line-height: 1.55; }

.switch {
  position: relative;
  display: inline-block;
  /* Visible track stays compact, but the hit area reaches 44×44 for WCAG
     touch-target compliance (expanded via padding on the clickable label
     elsewhere + this invisible pseudo below). */
  width: 44px; height: 24px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
/* Invisible expanded hit area — makes the whole 44×44 tappable even though
   the toggle itself is smaller. */
.switch::after {
  content: "";
  position: absolute;
  inset: -10px -6px;
  border-radius: var(--r);
  pointer-events: none;
}
.slider {
  position: absolute; inset: 0;
  background: var(--border-strong);
  border-radius: 24px;
  cursor: pointer;
  transition: background var(--dur-1);
}
.slider::before {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--dur-1);
  box-shadow: var(--sh-xs);
}
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ============================== EMPTY STATE ========================= */
.empty-state {
  text-align: center;
  padding: var(--sp-16) var(--sp-4);
  color: var(--text-muted);
}
.empty-state .emoji { font-size: 56px; margin-bottom: var(--sp-3); display: block; }
.empty-state h3 { margin-bottom: var(--sp-2); color: var(--text-strong); }
.empty-state p { margin-bottom: var(--sp-4); max-width: 400px; margin-left: auto; margin-right: auto; }

/* ============================== MARKET STATUS ====================== */
.market-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 500;
}
.market-status .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--positive);
  animation: pulse-dot 2s ease-in-out infinite;
}
.market-status .dot.closed { background: var(--text-faint); animation: none; }

/* ============================== NEWS ================================ */
.news-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-3);
}
@media (min-width: 900px) {
  .news-grid.compact { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .news-item { padding: var(--sp-3); }
  .news-item .headline { font-size: var(--text-sm); line-height: 1.45; }
}
.news-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: var(--sp-4);
  transition: border-color var(--dur-1);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.news-item:hover { border-color: var(--border-strong); box-shadow: var(--sh-xs); }
.news-item .headline {
  font-weight: 600;
  color: var(--text-strong);
  font-size: var(--text-md);
  line-height: 1.4;
}
.news-item .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-xs);
  color: var(--text-dim);
}
.news-item .summary {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.55;
}
.news-source {
  font-size: var(--text-10);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-muted);
}
.sentiment {
  font-size: var(--text-10);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--r-full);
}
.sentiment.bull, .sentiment.bullish { background: var(--positive-soft); color: var(--positive); }
.sentiment.bear, .sentiment.bearish { background: var(--negative-soft); color: var(--negative); }
.sentiment.neutral { background: var(--bg-soft); color: var(--text-muted); }

/* Saathi-take row — subtle AI-tagged retail-relevance one-liner below
   the headline. Loads async; shows a skeleton shimmer until the tag
   returns from /api/news-tldr. */
.news-ai-take {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: var(--text-sm);
  line-height: 1.45;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--divider);
  color: var(--text);
}
.news-ai-take.loading .news-ai-body { font-style: italic; opacity: 0.7; }
.news-ai-take.sentiment-bullish { border-top-color: var(--positive); }
.news-ai-take.sentiment-bearish { border-top-color: var(--negative); }
.news-ai-label {
  font-size: var(--text-10);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--brand);
  white-space: nowrap;
  padding: 2px 6px;
  border-radius: var(--r);
  background: color-mix(in srgb, var(--brand) 10%, transparent);
}
.news-ai-body { flex: 1; }

/* ============================== FRIENDS / TRANSFERS ================ */
.friend-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  transition: border-color var(--dur-1);
}
.friend-row:hover { border-color: var(--border-strong); }
.friend-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #3A47CF);
  color: white;
  font-weight: 700;
  font-size: 13px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.friend-avatar.saffron { background: linear-gradient(135deg, var(--saffron), #E06B00); }
.friend-avatar.green { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); }
.friend-avatar.purple { background: linear-gradient(135deg, #A855F7, #7E3EDB); }
.friend-name { font-weight: 600; color: var(--text-strong); }
.friend-handle { font-size: var(--text-xs); color: var(--text-dim); margin-top: 2px; }

.transfer-code {
  display: inline-flex;
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 10px 18px;
  background: var(--bg-soft);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r);
  color: var(--text-strong);
  user-select: all;
}

/* ============================== LOGIN / REGISTER =================== */
.auth-wrap {
  max-width: 420px;
  margin: var(--sp-12) auto;
  padding: 0 var(--sp-4);
}
.auth-card {
  padding: var(--sp-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-sm);
}
.auth-card h1 { font-size: var(--text-2xl); margin-bottom: var(--sp-2); }
.auth-card .sub { color: var(--text-muted); font-size: var(--text-md); margin-bottom: var(--sp-5); }
.auth-form { display: flex; flex-direction: column; gap: var(--sp-3); }
.auth-form > .field > .label { margin-bottom: 4px; }

.auth-switch {
  text-align: center;
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--divider);
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.error-msg {
  background: var(--negative-soft);
  color: var(--negative);
  padding: 10px 14px;
  border-radius: var(--r);
  font-size: var(--text-sm);
  font-weight: 500;
}
.info-msg {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 10px 14px;
  border-radius: var(--r);
  font-size: var(--text-sm);
  font-weight: 500;
}
.success-msg {
  background: var(--positive-soft);
  color: var(--positive);
  padding: 10px 14px;
  border-radius: var(--r);
  font-size: var(--text-sm);
  font-weight: 500;
}

/* ============================== DROPDOWN =========================== */
.dropdown {
  position: relative;
  display: inline-block;
}
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-md);
  padding: 6px;
  min-width: 220px;
  z-index: 45;
  display: none;
  animation: fadeIn var(--dur-1) var(--ease);
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: var(--text-md);
  cursor: pointer;
  transition: background var(--dur-1);
  width: 100%;
  text-align: left;
}
.dropdown-item:hover { background: var(--bg-soft); }
.dropdown-item.danger { color: var(--negative); }
.dropdown-divider { height: 1px; background: var(--divider); margin: 4px 0; }
