/* =========================================================================
   Maksimiak Research
   Built on the Triangulum language: light, quiet, precise.
   Cream field, ink type, serif headlines, mono numbers. Night mode is the
   same system after dark, not a different product.
   ========================================================================= */

:root {
  --bg:        #F5F4EF;
  --bg-2:      #EFEDE6;
  --bg-3:      #E8E6DE;
  --surface:   #FFFFFF;
  --surface-2: #FBFAF7;
  --surface-3: #F4F2EC;
  --ink:       #0D1018;
  --ink-2:     #343A46;
  --ink-3:     #565C68;
  --muted:     #737883;
  --faint:     #A4A7AD;
  --line:      #E2E0D8;
  --line-2:    #D3D0C6;
  --accent:    #1C2B4D;
  --accent-2:  #3A4E7E;
  --ok:        #2E6A4E;
  --ok-bg:     #E8F0EA;
  --ok-line:   #BCD3C4;
  --warn:      #8D6418;
  --warn-bg:   #F5EEDD;
  --warn-line: #E2CFA6;
  --bad:       #9A2E2E;
  --bad-bg:    #F6E7E5;
  --bad-line:  #E2C0BB;
  --shadow:    0 1px 0 rgba(13,16,24,.02), 0 18px 40px -22px rgba(13,16,24,.22);
  --shadow-2:  0 1px 0 rgba(13,16,24,.03), 0 26px 60px -24px rgba(13,16,24,.32);
  --scrim:     rgba(13,16,24,.32);
  --glass:     rgba(255,255,255,.86);
  --star:      #1B2233;
  --chart-grid: rgba(13,16,24,.07);

  --serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono:  'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --gutter: clamp(16px, 3.4vw, 40px);
  --radius: 2px;
  --rail-w: 240px;
  --tab-h: 62px;
  --ease: cubic-bezier(.2,.7,.2,1);

  /* names the older pages still use inline */
  --fg: var(--ink); --fg-2: var(--ink-2); --fg-3: var(--ink-3); --fg-4: var(--muted);
  --up: var(--ok); --down: var(--bad); --go: var(--ok); --stop: var(--bad);
  --sky: var(--accent); --lav: var(--accent-2); --mint: var(--ok); --coral: var(--bad); --gold: var(--warn);
  --process: var(--warn); --deep: var(--surface); --panel-2: var(--bg-2);
  --edge: var(--line); --edge-2: var(--line-2); --tint: var(--surface-2); --ink-mute: var(--muted);
  --pale: var(--bg-2); --pale-2: var(--bg-2); --pale-ink: var(--ink); --pale-ink-2: var(--muted);
  color-scheme: light;
}

/* ---- Night: the same field after dark ---------------------------------- */
:root[data-theme="dark"] {
  --bg:        #0A0C11;
  --bg-2:      #0F1218;
  --bg-3:      #151922;
  --surface:   #12161E;
  --surface-2: #161B24;
  --surface-3: #1B212C;
  --ink:       #EDEBE4;
  --ink-2:     #C9CAD0;
  --ink-3:     #A3A7B1;
  --muted:     #858B97;
  --faint:     #5D6371;
  --line:      #222835;
  --line-2:    #2F3646;
  --accent:    #A9BCF0;
  --accent-2:  #8094CC;
  --ok:        #6CC59A;
  --ok-bg:     rgba(108,197,154,.10);
  --ok-line:   rgba(108,197,154,.32);
  --warn:      #DDB56C;
  --warn-bg:   rgba(221,181,108,.10);
  --warn-line: rgba(221,181,108,.32);
  --bad:       #EA8C8C;
  --bad-bg:    rgba(234,140,140,.10);
  --bad-line:  rgba(234,140,140,.32);
  --shadow:    0 1px 0 rgba(0,0,0,.2), 0 18px 40px -22px rgba(0,0,0,.7);
  --shadow-2:  0 1px 0 rgba(0,0,0,.2), 0 26px 60px -24px rgba(0,0,0,.85);
  --scrim:     rgba(0,0,0,.55);
  --glass:     rgba(18,22,30,.88);
  --star:      #DCE3F5;
  --chart-grid: rgba(237,235,228,.07);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  min-height: 100vh; min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11" 1, "ss01" 1;
  transition: background .35s ease, color .35s ease;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
img, svg { display: block; }
h1, h2, h3, h4 { font-weight: 400; }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: var(--bg); }
:focus-visible { outline: 1px solid var(--ink); outline-offset: 3px; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; border: 2px solid var(--bg); }
kbd { font: 500 10px/1 var(--mono); padding: 3px 5px 2px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 3px; color: var(--muted); background: var(--surface); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 40%, transparent); } 100% { box-shadow: 0 0 0 9px transparent; } }
@keyframes shimmer { from { background-position: -200% 0; } to { background-position: 200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes flashUp { 0% { background: var(--ok-bg); } 100% { background: transparent; } }
@keyframes flashDown { 0% { background: var(--bad-bg); } 100% { background: transparent; } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }

.rise { animation: rise .7s var(--ease) both; }
.rise:nth-child(2) { animation-delay: .04s; }
.rise:nth-child(3) { animation-delay: .08s; }
.rise:nth-child(4) { animation-delay: .12s; }
.rise:nth-child(5) { animation-delay: .16s; }
.rise:nth-child(n+6) { animation-delay: .2s; }

/* ---- Star field -------------------------------------------------------- */
#sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

/* =========================================================================
   SHELL
   ========================================================================= */
.shell { position: relative; z-index: 1; display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh;
  background: linear-gradient(to right, var(--bg-2) var(--rail-w), transparent var(--rail-w)); }
.shell::before { content: ""; position: absolute; top: 0; bottom: 0; left: calc(var(--rail-w) - 1px); width: 1px; background: var(--line); pointer-events: none; }

.rail {
  position: sticky; top: 0; align-self: start;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 22px 14px 14px;
  transition: background .35s ease, border-color .35s ease;
}
.brand { display: inline-flex; align-items: center; gap: 10px; padding: 0 10px; }
.brand .mk { width: 24px; height: 24px; flex: none; color: var(--ink); }
.brand b { font: 500 11.5px/1 var(--sans); letter-spacing: .3em; text-transform: uppercase; }
.rail-sub { padding: 0 10px; margin: 8px 0 18px; font: 400 9.5px/1.4 var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }

.search-trigger {
  display: flex; align-items: center; gap: 9px; width: 100%;
  height: 36px; padding: 0 10px; margin-bottom: 8px;
  border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface);
  color: var(--muted); font-size: 12.5px; text-align: left;
  transition: border-color .2s ease, color .2s ease;
}
.search-trigger:hover { border-color: var(--ink-3); color: var(--ink-2); }
.search-trigger svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; flex: none; }
.search-trigger span { flex: 1; }

.menu { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; scrollbar-width: thin; }
.menu .sect { font: 500 9.5px/1 var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--faint); padding: 18px 10px 8px; }
.menu a {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; margin: 1px 0;
  font-size: 13px; color: var(--ink-2);
  border-left: 2px solid transparent;
  transition: background .2s ease, color .2s ease;
}
.menu a svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.6; fill: none; flex: none; opacity: .75; }
.menu a:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); color: var(--ink); }
.menu a.on { border-left-color: var(--ink); background: var(--surface); color: var(--ink); font-weight: 500; }
.menu a.on svg { opacity: 1; }
.menu a .n { margin-left: auto; font: 500 10px/1 var(--mono); background: var(--ink); color: var(--bg); padding: 3px 6px 2px; }
.menu a .live-dot { margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); color: var(--ok); animation: ping 2.4s ease-out infinite; }
.menu a .ext { margin-left: auto; font: 400 10px/1 var(--mono); color: var(--faint); }

.foot { margin-top: 10px; padding: 12px 6px 0; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.foot .id { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border: 1px solid var(--line-2); font: 500 12px/1 var(--mono); color: var(--ink); background: var(--surface); }
.foot .who { min-width: 0; flex: 1; }
.foot .who b { display: block; font-size: 12.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foot .who small { font: 400 9.5px/1.3 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; flex: none; border: 1px solid transparent; color: var(--ink-3); border-radius: var(--radius); transition: color .2s, border-color .2s, background .2s; }
.icon-btn:hover { color: var(--ink); border-color: var(--line-2); background: var(--surface); }
.icon-btn svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.7; fill: none; }
.theme-ico .moon { display: none; }
:root[data-theme="dark"] .theme-ico .sun { display: none; }
:root[data-theme="dark"] .theme-ico .moon { display: block; }

.body { min-width: 0; display: flex; flex-direction: column; }

/* App bar: market clock and the tape. On phones it also carries the brand. */
.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  min-height: 46px; padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.2) blur(12px); backdrop-filter: saturate(1.2) blur(12px);
  border-bottom: 1px solid var(--line);
}
.appbar .brand { display: none; padding: 0; }
.appbar .tools { display: none; gap: 2px; margin-left: auto; }
.clock { display: inline-flex; align-items: center; gap: 8px; flex: none; font: 500 10.5px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.clock i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); flex: none; }
.clock.open { color: var(--ok); }
.clock.open i { background: var(--ok); color: var(--ok); animation: ping 2.4s ease-out infinite; }
.clock.ext { color: var(--warn); }
.clock.ext i { background: var(--warn); }
.clock b { font-weight: 500; color: var(--ink-2); }

.tape { position: relative; flex: 1; min-width: 0; overflow: hidden; height: 46px; display: flex; align-items: center;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent); }
.tape-track { display: flex; gap: 26px; white-space: nowrap; will-change: transform; padding-left: 12px; }
.tape.run .tape-track { animation: tape 60s linear infinite; }
.tape:hover .tape-track { animation-play-state: paused; }
@keyframes tape { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.tk { display: inline-flex; align-items: baseline; gap: 7px; font: 400 11.5px/1 var(--mono); color: var(--ink-2); }
.tk b { font-weight: 500; color: var(--ink); letter-spacing: .04em; }
.tk em { font-style: normal; }
.tk a:hover b { text-decoration: underline; }

.top { padding: clamp(22px, 4vh, 38px) var(--gutter) 6px; display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; }
.top .kicker { display: block; font: 400 10.5px/1.4 var(--mono); letter-spacing: .22em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.top h1 { font: 300 clamp(30px, 4.2vw, 44px)/1.05 var(--serif); letter-spacing: -.012em; }
.top p { font-size: 13.5px; color: var(--ink-3); margin-top: 8px; max-width: 70ch; }
.top .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page { padding: 20px var(--gutter) 64px; width: 100%; max-width: 1480px; }

/* ---- Bottom tabs and the More sheet (phones) --------------------------- */
.tabbar { display: none; }
.sheet-scrim { position: fixed; inset: 0; z-index: 70; background: var(--scrim); animation: fade .2s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 71;
  max-height: 82vh; overflow-y: auto;
  background: var(--bg); border-top: 1px solid var(--line-2);
  padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
  animation: sheetUp .32s var(--ease);
}
.sheet .grip { width: 38px; height: 4px; border-radius: 4px; background: var(--line-2); margin: 2px auto 12px; }
.sheet .menu a { padding: 12px 10px; font-size: 14.5px; }
.sheet .menu .sect { padding-top: 14px; }

/* =========================================================================
   PANELS
   ========================================================================= */
.p { position: relative; background: var(--surface); border: 1px solid var(--line); margin-bottom: 16px; transition: border-color .25s ease, background .35s ease; }
.p:hover { border-color: var(--line-2); }
.p-h { padding: 16px 20px 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.p-h h2 { font: 500 10.5px/1.4 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.p-h h2 b { color: var(--ink); font-weight: 500; }
.p-h .r { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.p-b { padding: 4px 20px 20px; }
.p-b.tight { padding: 0; }
.p-h + .p-b { padding-top: 0; }
.p-sep { border-top: 1px solid var(--line); }

/* the emphasis panel: ink frame, cream field */
.p.hero { background: var(--bg-2); border-color: var(--ink); }

.p.hero .stat { background: var(--bg-2); }
.p.hero .stat:hover { background: var(--bg-3); }
.p.ink { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.p.ink .p-h h2, .p.ink .muted { color: color-mix(in srgb, var(--bg) 62%, transparent); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid-21 { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; align-items: start; }
.grid-12 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.65fr); gap: 16px; margin-bottom: 16px; align-items: start; }
.grid-2 > .p, .grid-3 > .p, .grid-4 > .p, .grid-21 > .p, .grid-12 > .p, .stack > .p { margin-bottom: 0; }
.stack { display: grid; gap: 16px; align-content: start; }

/* =========================================================================
   TYPE
   ========================================================================= */
.lab { font: 500 10px/1.4 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.kicker { display: block; font: 400 10.5px/1.4 var(--mono); letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }
.serif { font-family: var(--serif); }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.up { color: var(--ok); }
.down, .dn { color: var(--bad); }
.warn { color: var(--warn); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.lede { font-size: 15px; color: var(--ink-2); max-width: 62ch; }
.headline { font: 300 clamp(24px, 3vw, 32px)/1.15 var(--serif); letter-spacing: -.01em; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0; border-top: 1px solid var(--line); overflow: hidden; }
.stats > *, .readout > *, .macro > *, .idx > *, .lanes > *, .kv > *, .tilegrid > * { box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line); }
.p > .stats:last-child { border-bottom: 0; }
.stat { background: var(--surface); padding: 16px 20px 17px; transition: background .2s ease; min-width: 0; }
.stat:hover { background: var(--surface-2); }
.stat .k { font: 500 9.5px/1.3 var(--mono); letter-spacing: .15em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.stat .v { font: 400 24px/1.05 var(--mono); letter-spacing: -.03em; color: var(--ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat .v.sm { font-size: 17px; }
.stat .v.word { font: 300 22px/1.1 var(--serif); letter-spacing: -.005em; }
.stat .sub { font: 400 10.5px/1.4 var(--mono); color: var(--muted); margin-top: 7px; }
.stats.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 720px) { .stats.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* =========================================================================
   CONTROLS
   ========================================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 38px; padding: 0 18px;
  border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font: 500 12.5px/1 var(--sans); letter-spacing: .02em; white-space: nowrap;
  cursor: pointer; transition: background .2s ease, color .2s ease, border-color .2s ease;
  -webkit-appearance: none; appearance: none;
}
.btn svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.8; fill: none; flex: none; transition: transform .3s ease; }
.btn:hover { border-color: var(--ink); }
.btn.pri { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.pri:hover { background: var(--accent); border-color: var(--accent); }
.btn.pri:hover svg { transform: translateX(2px); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { border-color: var(--line-2); }
.btn.danger { color: var(--bad); border-color: var(--bad-line); }
.btn.danger:hover { background: var(--bad); border-color: var(--bad); color: var(--bg); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: var(--bg); }
.btn.sm { min-height: 30px; padding: 0 12px; font-size: 11.5px; gap: 7px; }
.btn.sm svg { width: 12px; height: 12px; }
.btn.wide { width: 100%; }
.btn[disabled], .btn.is-busy { opacity: .5; pointer-events: none; }

.tag, .chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px;
  font: 500 10px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
  border: 1px solid var(--line-2); background: var(--bg); color: var(--ink-3);
}
.tag .dot, .chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.tag.go, .chip.go { color: var(--ok); border-color: var(--ok-line); background: var(--ok-bg); }
.tag.no, .chip.no, .chip.stop { color: var(--bad); border-color: var(--bad-line); background: var(--bad-bg); }
.tag.hold, .chip.hold, .chip.wait { color: var(--warn); border-color: var(--warn-line); background: var(--warn-bg); }
.tag.acc, .chip.acc { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, var(--line-2)); background: color-mix(in srgb, var(--accent) 6%, var(--bg)); }
.tag.ink { color: var(--bg); background: var(--ink); border-color: var(--ink); }
a.tag:hover { border-color: var(--ink-3); }
.tag.go .dot, .tag.live .dot { animation: pulse 2.6s ease-in-out infinite; }

.seg { display: inline-flex; border: 1px solid var(--line-2); background: var(--surface); padding: 2px; gap: 2px; width: max-content; max-width: 100%; overflow-x: auto; scrollbar-width: none; flex: 0 0 auto; }
.seg::-webkit-scrollbar { display: none; }
.seg a, .seg button { height: 30px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px; font: 500 11.5px/1 var(--sans); color: var(--ink-3); white-space: nowrap; transition: background .2s, color .2s; }
.seg a:hover, .seg button:hover { color: var(--ink); }
.seg a.on, .seg button.on { background: var(--ink); color: var(--bg); }
.seg.wrap { flex-wrap: wrap; overflow: visible; }

.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field label, .field > .lab { font: 500 9.5px/1.3 var(--mono); letter-spacing: .15em; text-transform: uppercase; color: var(--muted); }
.field input, .field select, .field textarea, .input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font: 400 14px/1.4 var(--sans);
  transition: border-color .2s ease, box-shadow .2s ease, background .35s ease;
  -webkit-appearance: none; appearance: none;
}
.field select {
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23767B85' stroke-width='1.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.field textarea { height: auto; min-height: 90px; padding: 11px 12px; resize: vertical; line-height: 1.6; }
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 7%, transparent); }
.field input.mono, .field .mono { font-family: var(--mono); }
.field .hint { font-size: 11px; color: var(--muted); }
.field input[type=date] { min-width: 0; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row .field { flex: 1; min-width: 110px; }
.row .field:has(.seg), .row .field.snug { flex: 0 0 auto; min-width: 0; }
input[type=range] { accent-color: var(--ink); width: 100%; }
input[type=checkbox], input[type=radio] { accent-color: var(--ink); }

/* =========================================================================
   TABLES
   ========================================================================= */
.scroll, .scrollx { overflow-x: auto; -webkit-overflow-scrolling: touch; position: relative; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: right; padding: 10px 14px; white-space: nowrap;
  font: 500 9.5px/1.3 var(--mono); letter-spacing: .13em; text-transform: uppercase; color: var(--muted);
  background: var(--surface-2); border-bottom: 1px solid var(--line); border-top: 1px solid var(--line);
}
thead th.l { text-align: left; }
tbody td { padding: 11px 14px; text-align: right; border-bottom: 1px solid var(--line); font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; vertical-align: middle; transition: background .15s ease; }
tbody td.l, tbody td.t { text-align: left; font-family: var(--sans); font-size: 13px; color: var(--ink); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td .sym, .sym { font: 500 12.5px/1 var(--mono); letter-spacing: .05em; color: var(--ink); }
a .sym:hover, a.sym:hover { text-decoration: underline; }
tr.flash-up td { animation: flashUp 1.6s ease-out; }
tr.flash-down td { animation: flashDown 1.6s ease-out; }
table.sticky-first td:first-child, table.sticky-first th:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
table.sticky-first thead th:first-child { background: var(--surface-2); }

/* =========================================================================
   NOTES AND STATES
   ========================================================================= */
.note { display: flex; gap: 11px; padding: 12px 15px; border: 1px solid var(--line-2); border-left-width: 3px; background: var(--surface); font-size: 13px; line-height: 1.6; color: var(--ink-2); }
.note svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 1.8; fill: none; flex: none; margin-top: 2px; }
.note.go { border-color: var(--ok-line); border-left-color: var(--ok); background: var(--ok-bg); }
.note.no { border-color: var(--bad-line); border-left-color: var(--bad); background: var(--bad-bg); }
.note.hold, .note.wait { border-color: var(--warn-line); border-left-color: var(--warn); background: var(--warn-bg); }
.note.acc { border-left-color: var(--accent); }
.note b { color: var(--ink); font-weight: 600; }

.src { display: inline-flex; align-items: center; gap: 6px; font: 500 9.5px/1 var(--mono); letter-spacing: .13em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.src i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: block; }
.src.live { color: var(--ok); }
.src.live i { animation: pulse 2.6s ease-in-out infinite; }
.src.partial { color: var(--warn); }
.src.stale { color: var(--accent-2); }
.src.none { color: var(--faint); }

.gate { padding: 34px 22px; text-align: center; border: 1px dashed var(--line-2); background: var(--surface-2); }
.gate .lab { margin-bottom: 10px; }
.gate p { font-size: 13px; color: var(--ink-3); max-width: 46ch; margin: 0 auto 16px; line-height: 1.7; }
.gate p:last-child { margin-bottom: 0; }

.sk { background: linear-gradient(90deg, var(--bg-2) 25%, var(--surface-3) 50%, var(--bg-2) 75%); background-size: 200% 100%; animation: shimmer 1.6s linear infinite; }
.sk-line { height: 12px; margin-bottom: 10px; }
.sk-tile { height: 110px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; display: inline-block; border: 1.5px solid var(--line-2); border-top-color: var(--ink); animation: spin .8s linear infinite; }
.loading-row { display: flex; align-items: center; gap: 11px; color: var(--muted); font-size: 12.5px; padding: 18px 20px; }

.void { padding: 52px 22px; text-align: center; }
.void .glyph { width: 46px; height: 46px; margin: 0 auto 16px; display: grid; place-items: center; border: 1px solid var(--line-2); }
.void .glyph svg { width: 18px; height: 18px; stroke: var(--muted); stroke-width: 1.6; fill: none; }
.void h4 { font: 300 22px/1.2 var(--serif); margin-bottom: 8px; }
.void p { font-size: 13px; color: var(--muted); max-width: 40ch; margin: 0 auto 18px; line-height: 1.7; }

/* =========================================================================
   MARKET MAP: bubbles and tiles
   ========================================================================= */
.bubbles { position: relative; width: 100%; height: 540px; overflow: hidden; background: var(--surface-2); border-top: 1px solid var(--line); cursor: grab; touch-action: pan-y; }
.bubbles.dragging { cursor: grabbing; }
.bubbles canvas { display: block; width: 100%; height: 100%; }
.tilegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0; border-top: 1px solid var(--line); overflow: hidden; }
.tile { display: block; padding: 16px 18px; background: var(--surface); transition: background .2s ease; min-width: 0; }
.tile:hover { background: var(--surface-2); }
.tile .nm { font-size: 13px; font-weight: 500; line-height: 1.25; }
.tile .sb { font: 400 10px/1.3 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }
.tile .vl { font: 400 21px/1 var(--mono); letter-spacing: -.03em; margin-top: 12px; }
.tile.up .vl { color: var(--ok); }
.tile.down .vl { color: var(--bad); }
.tile.flat .vl { color: var(--ink-3); }

/* Treemap heat grid */
.heat { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 3px; padding: 3px; background: var(--surface-2); border-top: 1px solid var(--line); }
.heat a { position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 84px; padding: 10px 11px; color: var(--ink); background: var(--surface); transition: transform .2s var(--ease), box-shadow .2s ease, background .6s ease; }
.heat a:hover { transform: translateY(-1px); box-shadow: var(--shadow); z-index: 1; }
.heat a b { font: 500 12px/1 var(--mono); letter-spacing: .05em; }
.heat a small { font-size: 10.5px; color: var(--ink-3); line-height: 1.25; display: block; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.heat a em { font: 400 16px/1 var(--mono); font-style: normal; letter-spacing: -.02em; }
.heat a.big { grid-column: span 2; grid-row: span 2; min-height: 172px; }
.heat a.big b { font-size: 15px; }
.heat a.big em { font-size: 26px; }
.heat a.flash { animation: fade .6s ease; }

/* Diverging strength bars */
.bars-list { display: grid; gap: 0; }
.bar-row { display: grid; grid-template-columns: minmax(96px, 1.1fr) minmax(0, 2fr) 64px; align-items: center; gap: 12px; padding: 8px 20px; border-top: 1px solid var(--line); font-size: 12.5px; transition: background .15s ease; }
.bar-row:hover { background: var(--surface-2); }
.bar-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .nm small { font: 400 10px/1 var(--mono); color: var(--muted); margin-left: 6px; letter-spacing: .06em; }
.bar-row .track { position: relative; height: 10px; }
.bar-row .track::before { content: ''; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--line-2); }
.bar-row .fill { position: absolute; top: 1px; bottom: 1px; transition: left .8s var(--ease), width .8s var(--ease), background .4s ease; }
.bar-row .fill.up { background: var(--ok); }
.bar-row .fill.down { background: var(--bad); }
.bar-row .val { text-align: right; font: 400 12px/1 var(--mono); }

/* =========================================================================
   RELATIONSHIP WEB
   ========================================================================= */
.web { position: relative; width: 100%; height: 600px; background: var(--surface-2); border-top: 1px solid var(--line); overflow: hidden; touch-action: manipulation; }
.web svg { display: block; width: 100%; height: 100%; overflow: visible; }
.web .ring { fill: none; stroke: var(--line-2); stroke-width: 1; }
.web .ring-lbl { font: 500 9px/1 var(--mono); letter-spacing: .2em; text-transform: uppercase; fill: var(--faint); }
.web .edge { stroke: var(--line-2); stroke-width: 1; transition: stroke .2s ease, stroke-width .2s ease, opacity .3s ease; }
.web .edge.up-edge { stroke: color-mix(in srgb, var(--ink) 55%, transparent); stroke-width: 1.3; }
.web .edge.hi { stroke: var(--ink); stroke-width: 1.6; }
.webnode { cursor: pointer; }
.webnode .ring-o { fill: var(--surface); stroke: var(--line-2); stroke-width: 1; transition: stroke .2s ease, fill .4s ease; }
.webnode.pos .ring-o { stroke: var(--ok); fill: color-mix(in srgb, var(--ok) 9%, var(--surface)); }
.webnode.neg .ring-o { stroke: var(--bad); fill: color-mix(in srgb, var(--bad) 9%, var(--surface)); }
.webnode.core .ring-o { stroke: var(--ink); stroke-width: 1.6; fill: var(--surface); }
.webnode .t1 { font: 500 11.5px/1 var(--mono); fill: var(--ink); letter-spacing: .04em; }
.webnode.core .t1 { font-size: 15px; }
.webnode .t2 { font: 400 10px/1 var(--mono); }
.webnode.pos .t2 { fill: var(--ok); } .webnode.neg .t2 { fill: var(--bad); } .webnode .t2 { fill: var(--muted); }
.webnode .t3 { font: 400 9.5px/1 var(--sans); fill: var(--muted); }
.webnode:hover .ring-o, .webnode:focus .ring-o { stroke: var(--ink); stroke-width: 1.8; }
.webnode:focus { outline: none; }
.web-tip { position: absolute; z-index: 5; pointer-events: none; min-width: 190px; max-width: 260px; padding: 12px 14px; background: var(--glass); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-size: 12px; opacity: 0; transition: opacity .15s ease; }
.web-tip.show { opacity: 1; }
.web-tip b { font: 500 13px/1 var(--mono); letter-spacing: .05em; }
.web-tip .row2 { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; font: 400 11px/1.3 var(--mono); color: var(--ink-2); }
.web-tip .nm { color: var(--muted); font-size: 11.5px; margin-top: 4px; }
.crumbs { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font: 400 11px/1.4 var(--mono); letter-spacing: .06em; color: var(--muted); }
.crumbs a { color: var(--ink-3); border-bottom: 1px solid transparent; }
.crumbs a:hover { color: var(--ink); border-bottom-color: var(--ink); }
.crumbs b { color: var(--ink); font-weight: 500; }
.chain-path { display: flex; align-items: center; gap: 0; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--line); }
.chain-path a { display: inline-flex; flex-direction: column; gap: 3px; padding: 8px 12px; border: 1px solid var(--line-2); background: var(--surface); min-width: 0; transition: border-color .2s ease; }
.chain-path a:hover { border-color: var(--ink); }
.chain-path a b { font: 500 12px/1 var(--mono); letter-spacing: .05em; }
.chain-path a small { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.chain-path a.here { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.chain-path a.here small { color: color-mix(in srgb, var(--bg) 65%, transparent); }
.chain-path .arr { width: 22px; height: 1px; background: var(--line-2); flex: none; position: relative; }
.chain-path .arr::after { content: ''; position: absolute; right: 0; top: -3px; border: 3.5px solid transparent; border-left: 5px solid var(--line-2); border-right: 0; }

/* =========================================================================
   CHARTS
   ========================================================================= */
.chart { width: 100%; display: block; overflow: visible; }
.chart .grid-l { stroke: var(--chart-grid); stroke-width: 1; }
.curve { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.curve.a { stroke: var(--ok); }
.curve.b { stroke: var(--bad); }
.curve-draw { stroke-dasharray: 3000; stroke-dashoffset: 3000; animation: draw 1.6s var(--ease) .2s forwards; }
.curve.b.curve-draw { animation-delay: .4s; }
.legend { display: flex; gap: 20px; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); }
.legend span { display: flex; align-items: center; gap: 8px; }
.legend i { width: 14px; height: 2px; display: block; }
.cv-wrap { position: relative; width: 100%; }
.cv-wrap canvas { display: block; width: 100%; }
.cv-tip { position: absolute; top: 8px; left: 8px; pointer-events: none; padding: 7px 10px; background: var(--glass); border: 1px solid var(--line-2); font: 400 11px/1.5 var(--mono); color: var(--ink-2); white-space: nowrap; opacity: 0; transition: opacity .12s ease; z-index: 2; }
.cv-tip.show { opacity: 1; }
.cv-tip b { color: var(--ink); font-weight: 500; }

.streak { display: flex; gap: 4px; flex-wrap: wrap; }
.streak i { width: 12px; height: 12px; background: var(--bg-3); display: block; transition: transform .2s var(--ease); }
.streak i:hover { transform: scale(1.3); }
.streak i.good { background: var(--ok); }
.streak i.bad { background: var(--bad); }

.meter { margin-bottom: 14px; }
.meter:last-child { margin-bottom: 0; }
.meter .mh { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; font-size: 12px; color: var(--ink-3); gap: 10px; }
.meter .mh b { font: 400 13px/1 var(--mono); color: var(--ink); }
.meter .bar { height: 6px; background: var(--bg-3); overflow: hidden; display: flex; }
.meter .bar i { display: block; height: 100%; background: var(--ink); transition: width .8s var(--ease); }
.meter .bar i.add { background: var(--warn); }
.meter .bar i.over { background: var(--bad); }

/* range bar: 52 week, analyst targets, expected move */
.range { position: relative; height: 34px; margin: 6px 0 2px; }
.range .rail-l { position: absolute; left: 0; right: 0; top: 15px; height: 4px; background: var(--bg-3); }
.range .band { position: absolute; top: 13px; height: 8px; background: color-mix(in srgb, var(--accent) 22%, transparent); }
.range .pin { position: absolute; top: 6px; width: 2px; height: 22px; background: var(--ink); transform: translateX(-1px); }
.range .pin::after { content: attr(data-l); position: absolute; top: -14px; left: 50%; transform: translateX(-50%); font: 500 10px/1 var(--mono); color: var(--ink); white-space: nowrap; }
.range .tick { position: absolute; top: 12px; width: 1px; height: 10px; background: var(--muted); }
.range-lbls { display: flex; justify-content: space-between; font: 400 10.5px/1.3 var(--mono); color: var(--muted); }

/* =========================================================================
   CALENDAR
   ========================================================================= */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.cal .dow { padding: 8px; text-align: center; font: 500 9.5px/1 var(--mono); letter-spacing: .15em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); }
.cal .day { min-height: 74px; padding: 9px 10px; position: relative; background: var(--surface); transition: background .2s ease; min-width: 0; }
.cal .day:hover { background: var(--surface-2); }
.cal .day.off { background: var(--surface-2); }
.cal .day .d { font: 400 10.5px/1 var(--mono); color: var(--muted); }
.cal .day .amt { font: 400 13px/1 var(--mono); margin-top: 10px; letter-spacing: -.02em; overflow-wrap: anywhere; }
.cal .day.win { background: var(--ok-bg); }
.cal .day.win .amt { color: var(--ok); }
.cal .day.loss { background: var(--bad-bg); }
.cal .day.loss .amt { color: var(--bad); }
.cal .day .ct { position: absolute; bottom: 7px; right: 9px; font: 400 9.5px/1 var(--mono); color: var(--muted); }

/* earnings week strip */
.week { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.week .col { background: var(--surface); padding: 12px 12px 14px; min-width: 0; }
.week .col.today { background: var(--surface-2); box-shadow: inset 0 2px 0 var(--ink); }
.week .col h4 { font: 500 9.5px/1.3 var(--mono); letter-spacing: .15em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.week .col h4 b { color: var(--ink); font-weight: 500; }
.week .er { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; padding: 5px 0; border-top: 1px solid var(--line); font: 400 11.5px/1.2 var(--mono); }
.week .er:first-of-type { border-top: 0; }
.week .er b { font-weight: 500; letter-spacing: .04em; }
.week .er small { color: var(--muted); font-size: 10px; }
.week .er.mine b { text-decoration: underline; text-underline-offset: 3px; }

/* =========================================================================
   ANALYZE: chain, verdict, expanders
   ========================================================================= */
.chain { display: flex; overflow-x: auto; padding: 22px 14px 20px; scrollbar-width: thin; }
.ck { flex: 1; min-width: 88px; text-align: center; position: relative; padding: 0 6px; }
.ck .link { position: absolute; top: 18px; left: -50%; width: 100%; height: 1px; background: var(--line-2); z-index: 0; }
.ck:first-child .link { display: none; }
.ck .bub { width: 36px; height: 36px; margin: 0 auto 10px; position: relative; z-index: 1; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line-2); transition: transform .2s var(--ease); }
.ck:hover .bub { transform: translateY(-2px); }
.ck .bub svg { width: 15px; height: 15px; stroke: var(--muted); stroke-width: 1.9; fill: none; }
.ck[data-s="go"] .bub { border-color: var(--ok); background: var(--ok-bg); }
.ck[data-s="go"] .bub svg { stroke: var(--ok); }
.ck[data-s="wait"] .bub { border-color: var(--warn); background: var(--warn-bg); }
.ck[data-s="wait"] .bub svg { stroke: var(--warn); }
.ck[data-s="stop"] .bub { border-color: var(--bad); background: var(--bad-bg); }
.ck[data-s="stop"] .bub svg { stroke: var(--bad); }
.ck[data-s="dead"] { opacity: .3; }
.ck.cut .link { background: var(--bad); }
.ck .t { font-size: 11px; font-weight: 500; color: var(--ink-2); }
.ck .u { font: 400 10px/1.3 var(--mono); color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.verdict { display: flex; gap: 18px; padding: 24px 22px; align-items: flex-start; }
.verdict .mk { width: 50px; height: 50px; flex: none; display: grid; place-items: center; border: 1px solid var(--line-2); }
.verdict .mk svg { width: 22px; height: 22px; stroke: var(--muted); stroke-width: 1.8; fill: none; }
.verdict.go .mk { border-color: var(--ok); background: var(--ok-bg); }
.verdict.go .mk svg { stroke: var(--ok); }
.verdict.hold .mk { border-color: var(--warn); background: var(--warn-bg); }
.verdict.hold .mk svg { stroke: var(--warn); }
.verdict.no .mk { border-color: var(--bad); background: var(--bad-bg); }
.verdict.no .mk svg { stroke: var(--bad); }
.verdict h3 { font: 300 clamp(22px, 2.6vw, 28px)/1.2 var(--serif); letter-spacing: -.01em; }
.verdict p { font-size: 13.5px; color: var(--ink-3); margin-top: 8px; line-height: 1.7; max-width: 70ch; }
.verdict .meta { display: flex; gap: 7px; margin-top: 15px; flex-wrap: wrap; }

.exp { border-top: 1px solid var(--line); }
.exp:first-child { border-top: 0; }
.exp > button { width: 100%; display: flex; align-items: center; gap: 14px; padding: 14px 20px; text-align: left; transition: background .15s ease; }
.exp > button:hover { background: var(--surface-2); }
.exp .pip { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.exp .pip.go { background: var(--ok); }
.exp .pip.wait { background: var(--warn); }
.exp .pip.stop { background: var(--bad); }
.exp .nm { font-size: 13px; font-weight: 500; width: 130px; flex: none; }
.exp .sy { font-size: 12.5px; color: var(--ink-3); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exp .bars { display: flex; gap: 3px; flex: none; }
.exp .bars i { width: 14px; height: 4px; background: var(--bg-3); }
.exp .bars i.f { background: var(--ink); }
.exp .cv { width: 14px; height: 14px; stroke: var(--muted); stroke-width: 2; fill: none; flex: none; transition: transform .25s var(--ease); }
.exp.open .cv { transform: rotate(90deg); }
.exp .drop { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .32s var(--ease); }
.exp.open .drop { grid-template-rows: 1fr; }
.exp .drop > .inner { overflow: hidden; }
.exp .drop .pad { padding: 0 20px 18px 42px; }
.exp .drop .full { font-size: 13px; color: var(--ink-2); line-height: 1.75; margin-bottom: 14px; max-width: 70ch; }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.kv > div { background: var(--surface); padding: 12px 14px; min-width: 0; }
.kv .k { font: 500 9.5px/1.3 var(--mono); letter-spacing: .13em; text-transform: uppercase; color: var(--muted); }
.kv .v { font: 400 14px/1.3 var(--mono); margin-top: 6px; color: var(--ink); overflow-wrap: anywhere; }

/* plain key/value rows */
.dl { display: grid; margin: 0; }
.dl > div { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.dl > div:last-child { border-bottom: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; text-align: right; font-family: var(--mono); font-size: 12.5px; color: var(--ink); }

.setrow { display: flex; align-items: center; gap: 16px; padding: 13px 20px; border-top: 1px solid var(--line); transition: background .15s ease; }
.setrow:hover { background: var(--surface-2); }
.setlab { flex: 1; min-width: 0; }
.setlab b { display: block; font-size: 13px; font-weight: 500; }
.setlab small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.setrow input[type=number] { width: 104px; height: 36px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface); padding: 0 11px; font: 400 13px/1 var(--mono); text-align: right; flex: none; }
.setrow input[type=number]:focus { outline: none; border-color: var(--ink); }
.hidden-block { display: none; }
.hidden-block.show { display: block; animation: rise .4s var(--ease); }

/* =========================================================================
   PULSE
   ========================================================================= */
.idx { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--line); margin-bottom: 16px; overflow: hidden; }
.idx a, .idx div.q { position: relative; display: block; background: var(--surface); padding: 14px 16px 12px; min-width: 0; transition: background .2s ease; }
.idx a:hover { background: var(--surface-2); }
.idx .nm { display: flex; justify-content: space-between; gap: 8px; font: 500 10px/1.3 var(--mono); letter-spacing: .13em; text-transform: uppercase; color: var(--muted); }
.idx .px { font: 400 21px/1.1 var(--mono); letter-spacing: -.03em; margin-top: 8px; color: var(--ink); }
.idx .ch { font: 400 11.5px/1 var(--mono); margin-top: 6px; }
.idx svg.spark { width: 100%; height: 30px; margin-top: 8px; overflow: visible; }
.idx svg.spark path { fill: none; stroke-width: 1.3; vector-effect: non-scaling-stroke; }
.idx svg.spark .area { stroke: none; opacity: .08; }
.idx .q.flash, .idx a.flash { animation: fade .5s ease; }

.gauge { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 22px; align-items: center; padding: 6px 20px 20px; }
.gauge svg { width: 100%; height: auto; overflow: visible; }
.gauge .arc-bg { fill: none; stroke: var(--bg-3); stroke-width: 10; }
.gauge .arc { fill: none; stroke-width: 10; transition: stroke-dashoffset 1.2s var(--ease); }
.gauge .needle { stroke: var(--ink); stroke-width: 2; transition: transform 1.2s var(--ease); transform-origin: 100px 100px; }
.gauge .score { font: 300 34px/1 var(--serif); fill: var(--ink); text-anchor: middle; }
.gauge .glbl { font: 500 8.5px/1 var(--mono); letter-spacing: .18em; fill: var(--muted); text-anchor: middle; text-transform: uppercase; }
.factors { display: grid; gap: 0; }
.factor { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 7px 0; border-top: 1px solid var(--line); font-size: 12.5px; }
.factor:first-child { border-top: 0; }
.factor i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); align-self: center; }
.factor.pos i { background: var(--ok); } .factor.neg i { background: var(--bad); } .factor.mid i { background: var(--warn); }
.factor span { color: var(--ink-2); }
.factor b { font: 400 11.5px/1 var(--mono); color: var(--ink); }

.mv { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.mv .col { min-width: 0; }
.mv .col + .col { border-left: 1px solid var(--line); }
.mv a { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; gap: 8px; align-items: baseline; padding: 8px 16px; border-top: 1px solid var(--line); font-size: 12px; transition: background .15s; }
.mv a:hover { background: var(--surface-2); }
.mv a b { font: 500 11.5px/1 var(--mono); letter-spacing: .04em; }
.mv a span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }
.mv a em { font: 400 11.5px/1 var(--mono); font-style: normal; }

.macro { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; border-top: 1px solid var(--line); overflow: hidden; }
.macro > div { background: var(--surface); padding: 13px 16px; min-width: 0; }
.macro .k { font: 500 9.5px/1.3 var(--mono); letter-spacing: .13em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
.macro .v { font: 400 18px/1.1 var(--mono); margin-top: 8px; letter-spacing: -.02em; }
.macro .d { font: 400 10.5px/1 var(--mono); margin-top: 5px; color: var(--muted); }
.macro svg { width: 100%; height: 24px; margin-top: 8px; overflow: visible; }
.macro svg path { fill: none; stroke: var(--ink-3); stroke-width: 1.2; vector-effect: non-scaling-stroke; }

.watch-add { display: flex; gap: 8px; padding: 0 20px 14px; }
.watch-add input { flex: 1; min-width: 0; height: 34px; border: 1px solid var(--line-2); background: var(--surface); padding: 0 11px; font: 400 13px/1 var(--mono); text-transform: uppercase; border-radius: var(--radius); }
.watch-add input:focus { outline: none; border-color: var(--ink); }
.x-btn { width: 24px; height: 24px; display: inline-grid; place-items: center; color: var(--faint); border: 1px solid transparent; }
.x-btn:hover { color: var(--bad); border-color: var(--bad-line); }
.x-btn svg { width: 11px; height: 11px; stroke: currentColor; stroke-width: 2; fill: none; }

/* =========================================================================
   OPTIONS LAB and the Kelly bot
   ========================================================================= */
.lab-grid { display: grid; grid-template-columns: minmax(270px, 340px) minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 16px; }
.lab-grid > .p { margin-bottom: 0; }
.ctl { display: grid; gap: 14px; }
.ctl .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.slider { display: grid; gap: 6px; }
.slider .top-l { display: flex; justify-content: space-between; align-items: baseline; }
.slider .top-l label { font: 500 9.5px/1.3 var(--mono); letter-spacing: .15em; text-transform: uppercase; color: var(--muted); }
.slider .top-l output, .slider .top-l input.out { font: 400 13px/1 var(--mono); color: var(--ink); text-align: right; width: 92px; border: 0; background: transparent; padding: 0; }
.slider .top-l input.out:focus { outline: none; border-bottom: 1px solid var(--ink); }
input[type=range] { -webkit-appearance: none; appearance: none; height: 22px; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 2px; background: var(--line-2); }
input[type=range]::-moz-range-track { height: 2px; background: var(--line-2); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -7px; border-radius: 50%; background: var(--ink); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--ink); }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--ink); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--ink); }
.readout { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow: hidden; }
.readout > div { background: var(--surface); padding: 12px 14px; min-width: 0; }
.readout .k { font: 500 9.5px/1.3 var(--mono); letter-spacing: .13em; text-transform: uppercase; color: var(--muted); }
.readout .v { font: 400 17px/1.15 var(--mono); margin-top: 6px; letter-spacing: -.02em; overflow-wrap: anywhere; }
.readout .s { font: 400 10.5px/1.3 var(--mono); color: var(--muted); margin-top: 4px; }

.kelly-stage { position: relative; background: var(--surface-2); border-top: 1px solid var(--line); }
.kelly-stage canvas { display: block; width: 100%; height: 420px; }
.kelly-banner { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%) scale(.96); pointer-events: none; text-align: center; opacity: 0; transition: opacity .18s ease, transform .18s ease; }
.kelly-banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.kelly-banner b { display: block; font: 300 clamp(34px, 6vw, 64px)/1 var(--serif); letter-spacing: -.02em; color: var(--bad); }
.kelly-banner small { display: block; margin-top: 8px; font: 500 10.5px/1 var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.kelly-banner.win b { color: var(--ok); }
.lanes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--line); overflow: hidden; }
.lane { background: var(--surface); padding: 12px 14px; min-width: 0; }
.lane .k { display: flex; justify-content: space-between; font: 500 9.5px/1.3 var(--mono); letter-spacing: .13em; text-transform: uppercase; color: var(--muted); }
.lane .k i { width: 14px; height: 2px; align-self: center; }
.lane .v { font: 400 17px/1.15 var(--mono); margin-top: 6px; overflow-wrap: anywhere; }
.lane .s { font: 400 10.5px/1.4 var(--mono); color: var(--muted); margin-top: 3px; }
.big-go { min-height: 46px; font-size: 13.5px; }
.tickbox { display: flex; gap: 10px; align-items: center; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.tickbox input { width: 15px; height: 15px; }

/* =========================================================================
   COMMAND PALETTE
   ========================================================================= */
.pal-scrim { position: fixed; inset: 0; z-index: 80; background: var(--scrim); animation: fade .15s ease; }
.pal { position: fixed; z-index: 81; left: 50%; top: 12vh; transform: translateX(-50%); width: min(620px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow-2); animation: rise .22s var(--ease); }
.pal-in { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.pal-in svg { width: 16px; height: 16px; stroke: var(--muted); stroke-width: 1.8; fill: none; flex: none; }
.pal-in input { flex: 1; height: 54px; border: 0; background: transparent; font: 400 16px/1 var(--sans); color: var(--ink); min-width: 0; }
.pal-in input:focus { outline: none; }
.pal-list { max-height: min(56vh, 460px); overflow-y: auto; padding: 6px 0; }
.pal-sect { padding: 10px 16px 6px; font: 500 9.5px/1 var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--faint); }
.pal-item { display: flex; align-items: center; gap: 12px; padding: 10px 16px; cursor: pointer; font-size: 13.5px; color: var(--ink-2); }
.pal-item svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 1.7; fill: none; flex: none; opacity: .7; }
.pal-item b { font: 500 12.5px/1 var(--mono); letter-spacing: .05em; color: var(--ink); }
.pal-item small { margin-left: auto; font: 400 10.5px/1 var(--mono); color: var(--faint); }
.pal-item.sel { background: var(--surface-3); color: var(--ink); box-shadow: inset 2px 0 0 var(--ink); }
.pal-foot { display: flex; gap: 16px; padding: 9px 16px; border-top: 1px solid var(--line); font: 400 10.5px/1 var(--mono); color: var(--faint); }

/* =========================================================================
   AUTH: the Triangulum landing, rebuilt for the research desk
   ========================================================================= */
body.auth-page { display: flex; flex-direction: column; }
body.auth-page::before { content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none; background: radial-gradient(ellipse 70% 60% at 50% 38%, color-mix(in srgb, var(--surface) 75%, transparent), transparent 70%); }
.auth-top { position: relative; z-index: 5; display: flex; justify-content: space-between; align-items: center; padding: 22px var(--gutter); }
.auth-top .brand { padding: 0; }
.auth-top .access { display: flex; gap: 6px; align-items: center; }
.auth { position: relative; z-index: 2; flex: 1; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(320px, 400px); gap: clamp(24px, 6vw, 90px); align-items: center; max-width: 1180px; width: 100%; margin: 0 auto; padding: 10px var(--gutter) 48px; }
.auth.solo { grid-template-columns: minmax(0, 400px); justify-content: center; }
.emblem-wrap { display: flex; flex-direction: column; align-items: center; text-align: center; }
.emblem { position: relative; width: min(430px, 70vw, 48vh); aspect-ratio: 1; animation: rise 1.6s var(--ease) both; }
#logo { width: 100%; height: 100%; overflow: visible; }
#logo line { stroke: var(--ink); stroke-width: .55; vector-effect: non-scaling-stroke; stroke-linecap: round; }
#logo .tri-0 line { stroke-opacity: .55; }
#logo .tri-1 line { stroke-opacity: .28; }
.star { cursor: pointer; outline: none; }
.star-hit { fill: transparent; }
.star-clear { fill: var(--bg); }
.star-core { fill: var(--ink); transition: r .3s ease; }
.star-ring { fill: none; stroke: var(--ink); stroke-width: .8; stroke-opacity: .35; transform-box: fill-box; transform-origin: center; animation: starPulse 4.8s ease-in-out infinite; }
.star:nth-child(2) .star-ring { animation-delay: -1.2s; }
.star:nth-child(3) .star-ring { animation-delay: -2.4s; }
.star:nth-child(4) .star-ring { animation-delay: -3.6s; }
.star:hover .star-core, .star.is-active .star-core, .star:focus-visible .star-core { r: 5; }
.star:hover .star-ring, .star.is-active .star-ring { stroke-opacity: .7; animation-play-state: paused; }
@keyframes starPulse { 0%, 100% { transform: scale(.85); opacity: .5; } 50% { transform: scale(1.25); opacity: 1; } }
.star-card { position: absolute; left: 0; top: 0; z-index: 10; width: 250px; padding: 15px 17px 14px; text-align: left; background: var(--glass); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border: 1px solid var(--line); box-shadow: var(--shadow); opacity: 0; transition: opacity .22s ease; }
.star-card.show { opacity: 1; }
.sc-head { display: flex; align-items: baseline; gap: 8px; }
.sc-sym { font: 400 21px/1 var(--serif); }
.sc-name { font: 500 10px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.sc-title { margin-top: 10px; font: 400 20px/1.15 var(--serif); }
.sc-text { margin: 6px 0 0; font-size: 12.5px; line-height: 1.55; color: var(--ink-2); }
.wordmark { font: 300 clamp(36px, 5.6vw, 66px)/1.02 var(--serif); letter-spacing: -.015em; margin-top: 8px; animation: rise 1.6s .15s var(--ease) both; }
.eyebrow { margin: 14px 0 0; font: 400 10.5px/1.4 var(--mono); letter-spacing: .22em; text-transform: uppercase; color: var(--muted); animation: rise 1.6s .3s var(--ease) both; }
.auth form { width: 100%; padding: 30px 28px; background: var(--glass); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border: 1px solid var(--line); box-shadow: var(--shadow); animation: rise 1.2s .25s var(--ease) both; }
.auth form .kicker { margin-bottom: 12px; }
.auth form h1 { font: 300 34px/1.05 var(--serif); letter-spacing: -.01em; }
.auth .sub { font-size: 13px; color: var(--muted); margin: 8px 0 24px; }
.auth .field { margin-bottom: 16px; }
.auth .err { padding: 11px 14px; margin-bottom: 16px; font-size: 13px; border: 1px solid var(--bad-line); border-left: 3px solid var(--bad); background: var(--bad-bg); color: var(--ink); }
.auth .alt { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.auth .alt a { color: var(--ink); border-bottom: 1px solid var(--ink); }
.auth-foot { position: relative; z-index: 2; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 16px var(--gutter) calc(18px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.auth-foot .coords { font: 400 10.5px/1 var(--mono); letter-spacing: .1em; }

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lanes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: none; }
  .shell::before { display: none; }
  .rail { display: none; }
  .appbar { padding: 0 12px 0 16px; padding-top: env(safe-area-inset-top); gap: 10px; }
  .appbar .brand { display: inline-flex; }
  .appbar .brand b { display: none; }
  .appbar .tools { display: flex; }
  .appbar { flex-wrap: wrap; row-gap: 0; }
  .appbar .tape { order: 5; flex: 0 0 calc(100% + 28px); height: 32px; margin: 0 -12px 0 -16px; border-top: 1px solid var(--line); }
  .appbar .tape-track { padding-left: 16px; }
  .appbar > .brand, .appbar > .clock, .appbar > .tools { min-height: 48px; }
  .grid-2, .grid-3, .grid-21, .grid-12, .lab-grid { grid-template-columns: minmax(0, 1fr); }
  .gauge { grid-template-columns: 160px minmax(0, 1fr); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    -webkit-backdrop-filter: saturate(1.2) blur(14px); backdrop-filter: saturate(1.2) blur(14px);
    border-top: 1px solid var(--line);
  }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; font: 500 9.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); position: relative; }
  .tabbar svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.6; fill: none; }
  .tabbar .on { color: var(--ink); }
  .tabbar .on::before { content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; background: var(--ink); }
  .page { padding-bottom: calc(var(--tab-h) + 40px + env(safe-area-inset-bottom)); }
  .auth { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .emblem { width: min(260px, 58vw, 32vh); }
  .wordmark { font-size: clamp(32px, 9vw, 44px); }
  .eyebrow { letter-spacing: .16em; font-size: 9.5px; }
}
@media (max-width: 720px) {
  body { font-size: 14px; }
  .top { padding-top: 22px; gap: 12px; }
  .top .actions { margin-left: 0; width: 100%; }
  .top .actions form { flex: 1; }
  .page { padding-left: 12px; padding-right: 12px; }
  .p-h { padding: 14px 16px 12px; }
  .p-b { padding: 4px 16px 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 14px 16px; }
  .stat .v { font-size: 20px; }
  .stat .v.sm { font-size: 15px; }
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .idx { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .idx .px { font-size: 17px; }
  .bubbles { height: 440px; }
  .web { height: 520px; }
  .heat { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .heat a.big { grid-column: span 2; grid-row: span 1; min-height: 96px; }
  .heat a.big em { font-size: 20px; }
  .exp .nm { width: auto; flex: 1; }
  .exp .sy { display: none; }
  .exp .drop .pad { padding-left: 20px; }
  .cal .day { min-height: 56px; padding: 6px; }
  .cal .day .amt { font-size: 10.5px; }
  .week { grid-template-columns: repeat(5, minmax(150px, 1fr)); overflow-x: auto; }
  .mv { grid-template-columns: minmax(0, 1fr); }
  .mv .col + .col { border-left: 0; }
  .gauge { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .gauge svg { max-width: 220px; }
  .gauge .factors { width: 100%; }
  .bar-row { grid-template-columns: minmax(80px, 1fr) minmax(0, 1.4fr) 58px; padding: 8px 16px; }
  .verdict { padding: 20px 16px; gap: 14px; }
  .verdict .mk { width: 42px; height: 42px; }
  .chain-path { padding: 12px 16px; }
  .chain-path .arr { width: 12px; }
  .kelly-stage canvas { height: 320px; }
  /* 16px keeps iOS from zooming into every input */
  .field input, .field select, .field textarea, .input, .watch-add input, .pal-in input, .setrow input[type=number] { font-size: 16px; }
  thead th, tbody td { padding: 10px 11px; }
  .ctl .pair { grid-template-columns: 1fr 1fr; }
  .auth form { padding: 24px 20px; }
  .auth-top { padding-top: calc(16px + env(safe-area-inset-top)); }
}
@media (max-width: 420px) {
  .stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .lanes { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .btn { padding: 0 14px; }
}
@media (hover: none) {
  .p:hover { border-color: var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .rise { opacity: 1; }
  .curve-draw { stroke-dashoffset: 0; }
  .tape.run .tape-track { animation: none; }
}
@media print {
  .rail, .appbar, .tabbar, .no-print { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
}
