/* ABOUTME: Portal design system — dual-brand (TradeOnSports / USSportsLive), dark-first.
   ABOUTME: Tokens per brand+theme; profit/loss colours are semantic and never brand-swapped. */

/* ---------- Fonts (self-hosted) ---------- */
@font-face {
  font-family: 'Space Grotesk';
  src: url('/fonts/SpaceGrotesk-var.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Sans';
  src: url('/fonts/IBMPlexSans-var.woff2') format('woff2');
  font-weight: 100 700;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/fonts/IBMPlexMono-500.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/fonts/IBMPlexMono-600.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --font-display: 'Space Grotesk', 'IBM Plex Sans', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', monospace;

  /* semantic — identical direction in every brand and theme */
  --up: #34d97b;
  --down: #f0655a;
  --gold: #e2b54a;

  /* TradeOnSports dark is the base coat: deep moss-black, not neutral black */
  --field: #0c1210;
  --surface: #121a16;
  --surface-2: #172219;
  --line: rgba(134, 169, 148, 0.16);
  --line-strong: rgba(134, 169, 148, 0.3);
  --text: #e9f0eb;
  --muted: #97ab9f;
  --brand: #34d97b;
  --brand-ink: #06120b;
  --focus: #7fe0ac;
  --tile-glow: rgba(52, 217, 123, 0.07);
}

:root[data-brand='ussl'] {
  --field: #0a0f1b;
  --surface: #111828;
  --surface-2: #16203a;
  --line: rgba(140, 164, 209, 0.16);
  --line-strong: rgba(140, 164, 209, 0.3);
  --text: #e9eef8;
  --muted: #97a5c1;
  --brand: #5b93ff;
  --brand-ink: #071022;
  --focus: #9dbdff;
  --tile-glow: rgba(91, 147, 255, 0.08);
}

:root[data-theme='light'] {
  --field: #f2f6f2;
  --surface: #ffffff;
  --surface-2: #e9f0ea;
  --line: rgba(24, 48, 34, 0.14);
  --line-strong: rgba(24, 48, 34, 0.28);
  --text: #15211a;
  --muted: #58695f;
  --brand: #0f9155;
  --brand-ink: #ffffff;
  --focus: #0f9155;
  --up: #0f9155;
  --down: #c43d33;
  --gold: #a87c1c;
  --tile-glow: rgba(15, 145, 85, 0.06);
}

:root[data-brand='ussl'][data-theme='light'] {
  --field: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #e8edf7;
  --line: rgba(23, 38, 66, 0.14);
  --line-strong: rgba(23, 38, 66, 0.28);
  --text: #141b2b;
  --muted: #5a6780;
  --brand: #2d6be4;
  --brand-ink: #ffffff;
  --focus: #2d6be4;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  background: var(--field);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
svg { display: block; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.container { width: min(1180px, 100% - 48px); margin-inline: auto; }

.mono { font-family: var(--font-mono); }

/* eyebrow — the terminal-flavoured section label */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Top bar ---------- */
.topbar {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--field) 88%, transparent);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-inner { display: flex; align-items: center; gap: 28px; height: 60px; }

.wordmark { display: flex; align-items: baseline; gap: 7px; }
.wordmark-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.wordmark-name em { font-style: normal; color: var(--brand); }
.wordmark-tag {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: 2px 5px;
  transform: translateY(-1px);
}

.mainnav { display: flex; gap: 4px; margin-inline: auto; }
.mainnav a {
  padding: 6px 13px;
  border-radius: 7px;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.mainnav a:hover { color: var(--text); background: var(--surface-2); }
.mainnav a.active { color: var(--text); background: var(--surface-2); }
.soon {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--gold);
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  padding: 1px 4px;
  border-radius: 3px;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

.plan-chip {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 20px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  white-space: nowrap;
}
.plan-chip.elite { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 55%, transparent); }

.iconbtn {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
}
.iconbtn:hover { color: var(--text); border-color: var(--line-strong); }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.logout-form button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  padding: 6px 4px;
}
.logout-form button:hover { color: var(--text); }

/* ---------- Hero ---------- */
.hero { padding: 42px 0 10px; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }

.hero h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(26px, 4vw, 38px);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.hero h1 em { font-style: normal; color: var(--brand); }
.hero-sub { color: var(--muted); margin-top: 8px; max-width: 56ch; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  border-radius: 9px;
  padding: 10px 18px;
  border: 1px solid transparent;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-brand { background: var(--brand); color: var(--brand-ink); }
.btn-brand:hover { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 22%, transparent); }
.btn-ghost { border-color: var(--line-strong); color: var(--text); background: transparent; }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-gold { border-color: color-mix(in srgb, var(--gold) 55%, transparent); color: var(--gold); background: transparent; }
.btn-gold:hover { box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 16%, transparent); }

/* ---------- Top strategies strip ---------- */
.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin: 26px 0 8px; }

.strat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.strat-rank {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  color: var(--muted);
  width: 30px;
  flex-shrink: 0;
}
.strat-rank.r1 { color: var(--gold); }
.strat-main { min-width: 0; flex: 1; }
.strat-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strat-meta { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-top: 2px; }
.strat-pl { text-align: right; flex-shrink: 0; }
.strat-pl .num { font-family: var(--font-mono); font-weight: 600; font-size: 17px; }
.strat-pl .lbl { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase; }

/* ---------- Section headers ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 34px 0 14px; }
.section-head .note { font-size: 12.5px; color: var(--muted); }

/* ---------- P/L colouring (dashboard, journal, portfolio) ---------- */
.pl-up { color: #3ddc84; }
.pl-down { color: #f8716f; }
:root[data-theme='light'] .pl-up { color: #15803d; }
:root[data-theme='light'] .pl-down { color: #dc2626; }

/* ---------- Strategy portfolio cards ---------- */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.book-card {
  background-color: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.14s ease, border-color 0.14s ease;
}
.book-card:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.book-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.book-card-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-desc { font-size: 12.5px; color: var(--muted); margin: -6px 0 0; }
.mode-tag {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 6px;
}
.mode-bot { background: #1d4ed8; color: #fff; }
.mode-manual { background: #3f4a5a; color: #dbe3ee; }
.mode-sim { background: #4a3308; color: #fbbf24; }
.mode-archived { background: transparent; border: 1px solid var(--line-strong); color: var(--muted); }
.book-lines { font-size: 13.5px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.book-lines b { font-weight: 600; color: var(--text); }
.book-stats { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 2px; }
.book-stats > div:last-child { text-align: right; }
.book-stats .lbl {
  display: block;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}
.book-stats .num { font-family: var(--font-mono); font-size: 17px; font-weight: 600; }
.book-cta { width: 100%; text-align: center; }
.book-foot-hint { text-align: center; margin: -4px 0 0; }
.split-card { overflow-x: auto; min-width: 0; }
.split-card .jtable th, .split-card .jtable td { padding: 8px 9px; white-space: nowrap; }

/* ---------- Sport tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }

/* The left side holds copy; the action remains visible across the full right side. */
.tile {
  --tile-photo: none;
  background-color: var(--surface);
  background-image:
    linear-gradient(90deg,
      color-mix(in srgb, var(--field) 95%, transparent) 0%,
      color-mix(in srgb, var(--field) 84%, transparent) 34%,
      color-mix(in srgb, var(--field) 38%, transparent) 72%,
      color-mix(in srgb, var(--field) 12%, transparent) 100%),
    linear-gradient(0deg,
      color-mix(in srgb, var(--field) 54%, transparent) 0%,
      color-mix(in srgb, var(--field) 8%, transparent) 70%),
    var(--tile-photo),
    linear-gradient(160deg, var(--tile-glow), transparent 45%);
  background-position: center, center, 72% center, center;
  background-repeat: no-repeat;
  background-size: cover;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 18px 16px;
  min-height: 304px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 0.14s ease, border-color 0.14s ease;
}
.tile:hover { transform: translateY(-2px); border-color: var(--line-strong); }

.tile[data-sport='TENNIS'] { --tile-photo: url('/images/sport-tiles/tennis-tile-clay-v1.png'); }
.tile[data-sport='FOOTBALL'] { --tile-photo: url('/images/sport-tiles/football-tile-v1.png'); }
.tile[data-sport='HORSE_RACING'] { --tile-photo: url('/images/sport-tiles/horse-racing-tile-v1.png'); }
.tile[data-sport='AMERICAN_SPORTS'] { --tile-photo: url('/images/sport-tiles/american-sports-tile-v1.png'); }

:root[data-theme='light'] .tile {
  background-image:
    linear-gradient(90deg,
      rgba(255, 255, 255, 0.96) 0%,
      rgba(255, 255, 255, 0.85) 34%,
      rgba(255, 255, 255, 0.42) 72%,
      rgba(255, 255, 255, 0.14) 100%),
    linear-gradient(0deg,
      rgba(255, 255, 255, 0.54) 0%,
      rgba(255, 255, 255, 0.08) 70%),
    var(--tile-photo),
    linear-gradient(160deg, var(--tile-glow), transparent 45%);
}

.tile-head { display: flex; align-items: center; gap: 11px; }
.sport-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--brand);
  flex-shrink: 0;
}
.tile-title { font-family: var(--font-display); font-weight: 700; font-size: 16.5px; letter-spacing: -0.01em; }
.tile-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.tile-head .plan-chip { margin-left: auto; }

.pulse { display: flex; align-items: flex-end; gap: 18px; }
.pulse-figs { display: flex; gap: 22px; }
.fig .num { font-family: var(--font-mono); font-weight: 600; font-size: 21px; letter-spacing: -0.01em; }
.fig .lbl { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.spark { margin-left: auto; color: var(--brand); }
.spark svg { overflow: visible; }

.tile-strats { border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 6px; }
.tile-strat { display: flex; align-items: baseline; gap: 9px; font-size: 12.5px; min-width: 0; }
.tile-strat .rk { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); flex-shrink: 0; }
.tile-strat .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.tile-strat .pl { font-family: var(--font-mono); font-weight: 600; font-size: 12px; margin-left: auto; flex-shrink: 0; }
.tile-empty { font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }

.tile-foot { display: flex; align-items: center; gap: 10px; margin-top: auto; }
.tile-foot .hint { font-size: 12px; color: var(--muted); margin-left: auto; }

/* locked variant */
.tile.locked .spark, .tile.locked .pulse-figs { filter: blur(5px) saturate(0.4); opacity: 0.55; pointer-events: none; }
.lock-pitch { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12.5px; }
.lock-pitch svg { color: var(--gold); flex-shrink: 0; }

/* ---------- Lower band ---------- */
.lower { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin: 34px 0 44px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}
.card h3 { font-family: var(--font-display); font-weight: 700; font-size: 15.5px; margin-bottom: 12px; }
.card ul { list-style: none; display: grid; gap: 9px; }
.card li { display: flex; gap: 9px; font-size: 13px; color: var(--muted); align-items: baseline; }
.card li .dot { color: var(--brand); flex-shrink: 0; }
.card li strong { color: var(--text); font-weight: 600; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); margin-top: auto; }
.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0 22px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  flex-wrap: wrap;
}
.footer a:hover { color: var(--text); }

/* ---------- Flash / alerts ---------- */
.alert {
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--down);
  background: var(--surface);
  border-radius: 9px;
  padding: 11px 14px;
  font-size: 13.5px;
  margin: 16px 0 0;
}

/* ---------- Settings / plan pages ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 40px; }
.kv { display: grid; gap: 3px; }
.kv dt {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 10px;
}
.kv dd { font-size: 14px; }
.alert-ok { border-left-color: var(--up); }

.setup-callout {
  background: linear-gradient(160deg, var(--tile-glow), transparent 50%), var(--surface);
  border: 1px solid color-mix(in srgb, var(--brand) 42%, var(--line));
  border-radius: 14px;
  padding: 16px 18px;
  margin: 20px 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.setup-callout h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  margin-top: 3px;
}
.price-line { display: flex; align-items: baseline; gap: 5px; }
.price-line .price { font-weight: 600; font-size: 30px; letter-spacing: -0.02em; }
.price-line .per { color: var(--muted); font-size: 13px; }

/* ---------- Getting started card + tutorial video player ---------- */
.getting-started {
  background: linear-gradient(160deg, var(--tile-glow), transparent 50%), var(--surface);
  border: 1px solid color-mix(in srgb, var(--brand) 42%, var(--line));
  border-radius: 14px;
  padding: 16px 18px;
  margin: 20px 0 8px;
}
.gs-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.gs-head h3 { font-family: var(--font-display); font-weight: 700; font-size: 16px; margin-top: 3px; }
.gs-progress { color: var(--muted); font-size: 13px; margin-top: 2px; }
.gs-steps { list-style: none; margin: 12px 0 0; padding: 0; }
.gs-step {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.gs-mark {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 13px;
}
.gs-step.is-done .gs-mark { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.gs-main { flex: 1 1 auto; min-width: 0; }
.gs-title { font-weight: 600; }
.gs-step.is-done .gs-title { color: var(--muted); }
.gs-blurb { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.gs-actions { flex: none; display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

.video-dialog {
  width: min(1100px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  /* The global reset zeroes every margin; a modal dialog needs auto margins to sit in the middle. */
  margin: auto;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
}
/* Browsers without <dialog> would otherwise show the empty player in the page. */
.video-dialog:not([open]) { display: none; }
/* A page's own "Watch how" link sits under its intro text, at its natural width. */
.watch-how { display: inline-flex; width: fit-content; margin-top: 12px; }
/* Every link that plays a tutorial: brand-tinted outline, round play icon, the length in a quieter tone.
   It stays an outline so the page's solid brand button remains the main action. */
.btn-watch { border-color: color-mix(in srgb, var(--brand) 45%, transparent); gap: 10px; }
.btn-watch:hover { background: color-mix(in srgb, var(--brand) 12%, transparent); }
.btn-watch .play-icon {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-watch .play-icon::before {
  content: "";
  margin-left: 2px;
  border-left: 8px solid var(--brand-ink);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}
.btn-watch .watch-length { color: var(--muted); font-weight: 400; }
.btn-watch:hover .watch-length { color: inherit; }
.video-dialog::backdrop { background: rgba(0, 0, 0, 0.72); }
.video-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
}
.video-dialog-head h3 { font-family: var(--font-display); font-weight: 700; font-size: 16px; }
.video-dialog video { display: block; width: 100%; max-height: calc(100vh - 90px); background: #000; }

/* ---------- Learn ---------- */
.vids { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.vid { margin: 0; }
.vid iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  display: block;
}
.vid figcaption { font-size: 12.5px; color: var(--muted); margin-top: 7px; }
/* A lesson is a picture until clicked; portal.js then swaps in the player (.vid iframe above). */
.vid-play {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}
.vid-play img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vid-play .play-icon {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
}
.vid-play .play-icon::before {
  content: "";
  margin-left: 4px;
  border-left: 18px solid var(--brand-ink);
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
}
.vid-play:hover { border-color: var(--brand); }
.vid-play:hover .play-icon { box-shadow: 0 0 0 6px color-mix(in srgb, var(--brand) 22%, transparent); }

/* Topic tabs. They are plain jump links until portal.js marks the wrapper .is-tabbed. */
.learn-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 4px; }
.learn-tabs a {
  padding: 9px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
}
.learn-tabs a:hover { border-color: var(--brand); color: var(--brand); }
.learn-tabs a[aria-current="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.learn.is-tabbed .learn-panel:not(.is-active) { display: none; }
.learn-panel { margin-bottom: 44px; scroll-margin-top: 80px; }
.learn-note {
  margin: 18px 0 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 13.5px;
  max-width: 82ch;
}
.learn-setup { list-style: none; display: grid; gap: 10px; max-width: 640px; }
.learn-setup li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-weight: 600;
}
.learn-setup .watch-how { margin-top: 0; }
.vid-ext {
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  font-weight: 600;
}
.vid-ext:hover { border-color: var(--brand); }

/* ---------- Toolbox ---------- */
.calc-sub { font-size: 12.5px; color: var(--muted); margin: -6px 0 12px; }
/* .jform.calc-grid2 (0-2-0) must out-specify the later .jform rule (0-1-0), or the calculator
   grids render 4-col and the boxes go ragged. */
.jform.calc-grid2 { grid-template-columns: repeat(2, 1fr); }
.calc-out { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 4px; }
/* keep every calculator card the same height so a grid row's outputs line up */
.settings-grid .calc { align-self: stretch; }

/* ---------- Journal ---------- */
.bank-set { display: flex; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.bank-set label { font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.bank-set input { width: 120px; padding: 7px 10px; }
.bank-set .btn { padding: 7px 14px; }
.bank-hint { font-size: 12px; color: var(--muted); }
.jform {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px 14px;
  margin-top: 4px;
}
.jform label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}
.jform input, .jform select { width: 100%; padding: 9px 11px; }
.jform-wide { grid-column: span 2; }
.jform-submit { grid-column: 1 / -1; }
@media (max-width: 860px) {
  .jform { grid-template-columns: repeat(2, 1fr); }
  .jform-wide { grid-column: span 2; }
}

.jtable-card { padding: 6px 6px 4px; }
.jtable { width: 100%; font-size: 13px; }
.jtable th {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--line);
}
.jtable td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.jtable tr:last-child td { border-bottom: none; }
.jtable .r { text-align: right; }
.jtable .actions { display: flex; gap: 5px; justify-content: flex-end; }
.jtable .actions form { display: inline; }
.mini {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  background: none;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  border-radius: 6px;
  padding: 4px 9px;
}
.mini:hover { color: var(--text); border-color: var(--text); }
.mini-win { color: var(--up); border-color: color-mix(in srgb, var(--up) 50%, transparent); }
.mini-win:hover { color: var(--up); border-color: var(--up); }
.mini-lose { color: var(--down); border-color: color-mix(in srgb, var(--down) 50%, transparent); }
.mini-lose:hover { color: var(--down); border-color: var(--down); }

/* ---------- Telegram rooms ---------- */
.telegram-connect-wrap {
  min-height: calc(100vh - 190px);
  display: grid;
  place-items: center;
  padding: 42px 0;
}
.rooms { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 14px; }
.room {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 15px 16px;
  display: flex;
  /* top-aligned: rows stretch to the tallest card (topic lists), and centred content
     floats oddly in short siblings — titles share a scan line instead */
  align-items: flex-start;
  gap: 14px;
}
.room.member {
  border-color: color-mix(in srgb, var(--brand) 62%, var(--line));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 18%, transparent);
}
.room-main { min-width: 0; flex: 1; display: grid; gap: 5px; }
.room-name { font-weight: 600; font-size: 14px; }
.room-desc { font-size: 12.5px; color: var(--muted); }
.room-tiers { display: flex; flex-wrap: wrap; gap: 4px; }
.tier-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 4px;
  white-space: nowrap;
}
.bot-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--brand);
  border: 1px solid color-mix(in srgb, var(--brand) 40%, transparent);
  border-radius: 3px;
  padding: 1px 4px;
  margin-right: 3px;
}
.room .btn { flex-shrink: 0; }
/* the upgrade label names the unlocking plans and is wider than a card column, so it takes
   its own row under the room text instead of sharing the title line like Join does */
.room { flex-wrap: wrap; }
.room > .btn-gold { flex: 1 1 100%; justify-content: center; text-align: center; }
.room-nolink { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.member-tag {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--up);
  border: 1px solid color-mix(in srgb, var(--up) 55%, transparent);
  border-radius: 20px;
  padding: 5px 9px;
  white-space: nowrap;
  flex-shrink: 0;
}
.telegram-link-card { display: grid; gap: 12px; }
.telegram-link-card-prominent {
  width: min(620px, 100%);
  padding: 28px;
  text-align: center;
  justify-items: center;
  background: linear-gradient(160deg, var(--tile-glow), transparent 46%), var(--surface);
  border-color: color-mix(in srgb, var(--brand) 44%, var(--line));
}
.telegram-link-card-prominent h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 30px;
  line-height: 1.12;
}
.telegram-link-state { display: grid; gap: 12px; align-items: start; }
.telegram-link-state form { margin: 0; }
.telegram-link-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.telegram-link-actions form { display: inline-flex; }
.btn-large { padding: 12px 20px; font-size: 15px; justify-content: center; }
.connected-status { color: var(--up); font-weight: 700; font-size: 15px; }
.telegram-connected-bar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--up);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 20px 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.telegram-connected-bar div {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.telegram-connected-bar strong { color: var(--up); }
.telegram-connected-bar span { color: var(--muted); font-size: 13px; }
.telegram-connected-bar form { margin: 0; }

@media (max-width: 720px) {
  .setup-callout,
  .telegram-connected-bar {
    align-items: stretch;
    flex-direction: column;
  }
  .gs-step { flex-wrap: wrap; }
  .gs-actions { flex: 1 1 100%; justify-content: flex-start; padding-left: 42px; }
  .setup-callout .btn,
  .telegram-connected-bar .btn {
    justify-content: center;
  }
  .room {
    align-items: flex-start;
    flex-direction: column;
    flex-wrap: nowrap;
  }
  .room > .btn-gold { flex: none; align-self: stretch; }
}

/* ---------- Auth pages (login / welcome / set-password) ---------- */
.auth-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 48px 20px;
}
.auth-card {
  width: min(420px, 100%);
  background: linear-gradient(160deg, var(--tile-glow), transparent 45%), var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 34px 34px 28px;
  display: grid;
  gap: 14px;
  justify-items: center;
  text-align: center;
}
.auth-card.auth-wide { width: min(560px, 100%); }
.auth-card h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -0.02em;
  margin-top: 6px;
}
.auth-sub { color: var(--muted); font-size: 14px; max-width: 44ch; }
.auth-form { display: grid; gap: 7px; width: 100%; text-align: left; margin-top: 6px; }
.auth-form label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 8px;
}
.auth-form input { width: 100%; padding: 11px 13px; }
.auth-submit { justify-content: center; margin-top: 16px; width: 100%; }
.auth-alt { font-size: 12.5px; color: var(--muted); }
.auth-alt a { color: var(--brand); }
.auth-card .alert { width: 100%; margin: 0; text-align: left; }

.welcome-steps {
  text-align: left;
  display: grid;
  gap: 12px;
  margin: 10px 0 6px;
  padding-left: 0;
  list-style: none;
  counter-reset: step;
}
.welcome-steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 12px;
  font-size: 14px;
  color: var(--muted);
}
.welcome-steps li strong { color: var(--text); }
.welcome-steps li::before {
  content: counter(step);
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--brand);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
}
.auth-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }

/* ---------- Legacy-page compatibility (subscription/account until their restyle pass) ---------- */
.page-title { font-family: var(--font-display); font-weight: 700; font-size: 26px; margin: 34px 0 18px; }
table { border-collapse: collapse; }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 8px 11px;
}

/* ---------- Responsive ---------- */
/* 1227px = the 1180px container plus its 48px gutters: below it the container narrows and the
   eight nav links no longer fit beside the wordmark and account controls, so the nav takes a
   row of its own (tablets and small laptops) before the phone grid below takes over */
@media (max-width: 1227px) {
  .topbar-inner { justify-content: space-between; flex-wrap: wrap; height: auto; min-height: 60px; padding-block: 10px; row-gap: 6px; }
  .mainnav { order: 3; flex-basis: 100%; flex-wrap: wrap; margin-inline: -13px 0; }
}
@media (max-width: 900px) {
  .topbar { position: static; }
  .topbar-inner { justify-content: space-between; flex-wrap: wrap; height: auto; min-height: 60px; padding-block: 12px; }
  .mainnav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    order: 3;
    flex-basis: 100%;
    gap: 4px;
    margin-inline: 0;
  }
  .mainnav a { padding: 10px 8px; white-space: normal; }
}
.mainnav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.mainnav a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.mobile-column-label { display: none; }
.strategy-code { font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.strategy-code summary { cursor: pointer; }
@media (max-width: 640px) {
  .container { width: calc(100% - 32px); }
  .hero { padding-top: 28px; }
  .pulse-figs { gap: 14px; }
  .fig .num { font-size: 18px; }
  .results-table, .results-table tbody { display: block; width: 100%; }
  .results-table thead {
    position: absolute; width: 1px; height: 1px; padding: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  .results-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding-block: 12px; border-bottom: 1px solid var(--line); }
  .results-table td { min-width: 0; padding: 8px; border: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; }
  .results-table td:first-child { grid-column: 1 / -1; }
  .results-table .mobile-column-label { display: block; margin-bottom: 4px; color: var(--muted); font-family: var(--font-body); font-size: 12px; }
}

@media (max-width: 760px) {
  .tiles { grid-template-columns: 1fr; gap: 14px; }
  .tile { min-height: 286px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
