:root {
  --bg: #0b0e13;
  --card: #131822;
  --card2: #0f141d;
  --line: #232b3a;
  --skip-bg: #131822;
  --skip-fg: #f7f9fc;
  --text: #e6edf3;
  --muted: #8b98a9;
  --gabot: #4ade80;   /* agent = green */
  --human: #f472b6;   /* human = pink  */
  --accent: #7dd3fc;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Accessibility: skip-to-section link. Hidden until keyboard-focused.
   Accessibility review (2026-08-31) noted that the masthead + scoreboard +
   chart + methodology all stack and force keyboard users to tab through
   hero chrome before reaching the data tables. */
.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--skip-bg);
  color: var(--skip-fg);
  padding: 12px 16px;
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
}
.skip:focus {
  left: 16px;
  top: 16px;
  outline: 2px solid var(--human, #f472b6);
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--sans); line-height: 1.55;
}

/* Animated background — floating gradient orbs + universe/bits canvas */
.orbs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
#bgfx { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.orbs i { position: absolute; display: block; border-radius: 50%; filter: blur(70px);
  opacity: .30; will-change: transform; }
.orbs i:nth-child(1) { width: 480px; height: 480px; background: #4ade80;
  top: -140px; left: -120px; animation: drift1 26s ease-in-out infinite alternate; }
.orbs i:nth-child(2) { width: 420px; height: 420px; background: #f472b6;
  top: 20%; right: -160px; animation: drift2 31s ease-in-out infinite alternate; }
.orbs i:nth-child(3) { width: 380px; height: 380px; background: #7dd3fc;
  bottom: 8%; left: 12%; animation: drift3 37s ease-in-out infinite alternate; }
.orbs i:nth-child(4) { width: 300px; height: 300px; background: #a78bfa;
  bottom: -120px; right: 18%; animation: drift1 29s ease-in-out infinite alternate-reverse; }
@keyframes drift1 { to { transform: translate(120px, 90px) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-140px, 60px) scale(0.9); } }
@keyframes drift3 { to { transform: translate(90px, -110px) scale(1.1); } }

.live-note { display: flex; align-items: center; gap: 8px; color: var(--muted);
  font-size: 13px; margin: 14px 0 0; font-family: var(--mono); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gabot);
  box-shadow: 0 0 0 0 rgba(74, 222, 128, .6); animation: livePulse 2s infinite; }
@keyframes livePulse {
  70% { box-shadow: 0 0 0 9px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}
.wrap { max-width: 1060px; margin: 0 auto; padding: 0 20px; }

.masthead { padding: 56px 0 28px; border-bottom: 1px solid var(--line);
  background: radial-gradient(1200px 400px at 50% -100px, #17202e 0%, var(--bg) 70%);
  position: relative; overflow: hidden; }
.masthead .wrap { position: relative; }

/* Animated stock-chart sparkline drifting behind the hero title */
.hero-spark { position: absolute; inset: 0; opacity: .13; pointer-events: none; }
.hero-spark svg { width: 200%; height: 100%; display: block; }
.hero-spark path { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; }
.spark-track { animation: sparkScroll 48s linear infinite; }
@keyframes sparkScroll { to { transform: translateX(-1600px); } }

/* Latest-trade ticker strip */
.ticker { border-bottom: 1px solid var(--line); background: rgba(15, 20, 29, .6);
  overflow: hidden; white-space: nowrap; }
.ticker:empty { display: none; }
.t-track { display: inline-block; padding: 9px 0; font-family: var(--mono);
  font-size: 13px; color: var(--muted); animation: tickerScroll 36s linear infinite; }
.ticker:hover .t-track { animation-play-state: paused; }
.t-item b.BUY { color: var(--gabot); } .t-item b.SELL { color: #f87171; }
.t-item i { font-style: normal; opacity: .6; margin-left: 4px; }
.t-sep { margin: 0 14px; color: #3a4456; }
@keyframes tickerScroll { to { transform: translateX(-50%); } }

/* Day/night accent: cooler hues at night (class set by app.js from local hour) */
body.night { --accent: #a78bfa; }
body.night .orbs i:nth-child(1) { background: #22d3ee; }
body.night .orbs i:nth-child(3) { background: #818cf8; }
body.night .live-dot { background: #a78bfa;
  box-shadow: 0 0 0 0 rgba(167, 139, 250, .6); }
.kicker { color: var(--accent); text-transform: uppercase; letter-spacing: .2em;
  font-size: 12px; margin: 0 0 6px; }
h1 { font-size: clamp(34px, 6vw, 56px); margin: 0; }
h1 .vs { color: var(--muted); font-size: .5em; vertical-align: middle; padding: 0 .3em; }
.sub { color: var(--muted); max-width: 640px; margin: 10px 0 0; }

h2 { font-size: 22px; margin: 48px 0 12px; }
h3 { margin: 0 0 10px; font-size: 17px; }
.side-gabot { color: var(--gabot); }
.side-human { color: var(--human); }
.muted { color: var(--muted); font-size: 14px; }

/* Scoreboard */
.scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px;
  align-items: stretch; margin-top: 28px; }
.score-card { background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 20px;
  transition: transform .25s ease, box-shadow .25s ease; }
.score-card:hover { transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
.score-card.leader { outline: 2px solid currentColor;
  box-shadow: 0 0 34px -12px currentColor; }
.score-card .who { font-size: 13px; text-transform: uppercase; letter-spacing: .12em; }
.score-card .val { font-family: var(--mono); font-size: clamp(22px, 4vw, 34px);
  margin: 6px 0 2px; }
.score-card .ret { font-family: var(--mono); font-size: 15px; }
.score-card .asof { color: var(--muted); font-size: 12px; margin-top: 8px; }
.score-card .live-mark { opacity: .75; font-style: italic; margin-top: 4px; }
.up { color: var(--gabot); } .down { color: #f87171; }
.badge-wrap { display: flex; flex-direction: column; justify-content: center;
  align-items: center; gap: 6px; }
.badge { background: var(--card2); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 16px; font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.badge.gabot { color: var(--gabot); } .badge.human { color: var(--human); }
.badge.pulse { animation: badgePulse 2.6s ease-in-out infinite; }
@keyframes badgePulse { 50% { transform: scale(1.05); } }
.delta { font-family: var(--mono); font-size: 13px; color: var(--muted); }

/* Chart line draw-in on (re)render */
.chart-line { stroke-dashoffset: 2400; animation: drawLine 1.8s ease forwards; }
@keyframes drawLine { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
  .orbs i, .badge.pulse, .live-dot, .chart-line, .spark-track, .t-track {
    animation: none !important; }
  .score-card { transition: none; }
}

/* Stats row */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-top: 14px; }
.stat { background: var(--card2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: .08em; }
.stat .v { font-family: var(--mono); font-size: 20px; margin-top: 2px; }

/* Chart */
#chart svg { width: 100%; height: auto; display: block; background: var(--card2);
  border: 1px solid var(--line); border-radius: 14px; }
.legend { display: flex; gap: 18px; margin-top: 8px; font-size: 13px; }
.legend .sw { display: inline-block; width: 14px; height: 3px; border-radius: 2px;
  vertical-align: middle; margin-right: 6px; }

/* Tables */
.holdings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 12px;
  text-transform: uppercase; letter-spacing: .06em; }
td.num, th.num { text-align: right; font-family: var(--mono); }
tr.cash td { color: var(--muted); font-style: italic; }

/* Biggest position of each portfolio */
tr.top-pos td { background: linear-gradient(90deg, rgba(125, 211, 252, .07), transparent); }
.chip { font-family: var(--mono); font-size: 10px; padding: 1px 7px; border-radius: 8px;
  margin-left: 7px; letter-spacing: .08em; vertical-align: 1px; }
.chip.g { background: rgba(74, 222, 128, .16); color: var(--gabot); }
.chip.h { background: rgba(244, 114, 182, .16); color: var(--human); }
.chip.stale { background: rgba(250, 204, 21, .14); color: #facc15; }

/* Decision log */
details.decision { background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; margin: 10px 0; overflow: hidden; }
details.decision summary { cursor: pointer; padding: 12px 16px; display: flex;
  gap: 12px; align-items: baseline; flex-wrap: wrap; list-style: none; }
details.decision summary::-webkit-details-marker { display: none; }
.d-date { font-family: var(--mono); color: var(--muted); font-size: 13px; }
.d-action { font-family: var(--mono); font-weight: 700; font-size: 13px;
  padding: 2px 8px; border-radius: 6px; }
.d-action.BUY { background: rgba(74, 222, 128, .12); color: var(--gabot); }
.d-action.SELL { background: rgba(248, 113, 113, .12); color: #f87171; }
.d-head { flex: 1; }
.d-body { padding: 0 16px 14px; color: #c7d2de; font-size: 14px;
  border-top: 1px dashed var(--line); }
.d-meta { color: var(--muted); font-size: 12px; font-family: var(--mono);
  margin-top: 8px; }

.method li { margin: 8px 0; }
.footer { margin: 56px auto 40px; padding-top: 18px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 13px; }
.footer .legal a { color: var(--accent); text-decoration: none; }
.footer .legal a:hover { text-decoration: underline; }

@media (max-width: 760px) {
  .scoreboard { grid-template-columns: 1fr; }
  .badge-wrap { order: -1; }
  .holdings-grid { grid-template-columns: 1fr; }
  /* One holding can carry two disclosure chips at once ("BYD Co (ADR) TOP
     STALE PENDING"), which pushed the holdings table to 400px inside a 390px
     viewport and gave the whole page a horizontal scrollbar. The chips ARE the
     disclosure, so they stay and the name cell wraps instead: a chip drops to
     the next line rather than widening the row. */
  table { width: 100%; max-width: 100%; }
  table td:first-child, table th:first-child { white-space: normal; word-break: break-word; }
  table td:first-child .chip { margin-left: 4px; font-size: 9px; padding: 1px 5px; }
}

/* Recently closed positions (shared by both sides — color comes from the
   per-side .closed-name rule below) */
.closed-heading { font-size: 13px; font-weight: 500; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; margin: 24px 0 8px; }
.closed-name { font-weight: 500; color: var(--muted); }
/* Per-side: the parent .human-side / .gabot-side wrapper scopes the
   color to the matching accent. Default stays muted (above) so a stray
   closed-name outside either column does not inherit a misleading hue. */
.human-side .closed-name { color: var(--human); }
.gabot-side .closed-name { color: var(--gabot); }
.closed-meta { color: var(--muted); font-size: 11px; font-family: var(--mono);
  margin-top: 4px; }
/* Held column: a date must never break inside itself ("2026-07-" / "31" on a
   390px phone, 2026-09-05 review). Each date is its own inline-block; on
   narrow screens the range stacks — opened, arrow, closed — one per line. */
.closed-held { font-family: var(--mono); font-size: 12px; color: var(--muted);
  vertical-align: top; }
.closed-held time { white-space: nowrap; display: inline-block; }
.closed-pnl { white-space: nowrap; }
.closed-trade-date { white-space: nowrap; }
@media (max-width: 760px) {
  .closed-held time { display: block; }
  .closed-held .arrow { display: block; }
}
.closed-pnl-pct { color: var(--muted); font-weight: 400; font-size: 12px;
  font-family: var(--mono); margin-left: 4px; }
.pnl-pos { color: var(--gabot); }
.pnl-neg { color: #f87171; }
.closed-details { margin-top: 8px; }
.closed-details summary { font-size: 12px; color: var(--muted);
  cursor: pointer; padding: 4px 0; font-family: var(--mono);
  list-style: none; }
.closed-details summary::-webkit-details-marker { display: none; }
.closed-details summary::before { content: "▸ "; display: inline-block;
  transition: transform .15s ease; margin-right: 4px; }
.closed-details[open] summary::before { content: "▾ "; }
.closed-trades { margin-top: 8px; padding: 8px 12px;
  background: rgba(125, 211, 252, .04); border-radius: 8px;
  border: 1px solid var(--line); }
.closed-trade { display: flex; align-items: baseline; gap: 10px;
  padding: 4px 0; font-size: 13px; }
.closed-trade:not(:last-child) { border-bottom: 1px dashed var(--line); }
.closed-trade-body { font-family: var(--mono); color: #c7d2de; }
.closed-trade-body b { color: white; font-weight: 600; }
.closed-trade-date { color: var(--muted); margin-left: 6px;
  font-style: normal; font-size: 11px; }

/* Trade log (L-002) */
.section-note { color: var(--muted); font-size: 13px; margin: -6px 0 14px; max-width: 70ch; }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
#tradeLog table { min-width: 720px; }
.tl-date { font-family: var(--mono); white-space: nowrap; }
.tl-ticker { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-left: 4px; }
#tradeLog .d-action { font-family: var(--mono); font-size: 11px; font-weight: 600; }
.tl-row .chip { white-space: nowrap; }
