/* ─────────────────────────────────────────────────────────────
   Bullflow Dashboard — design system

   Apple's system language: SF type ramp, an 8pt spacing grid, layered
   translucent surfaces, restrained depth, and motion that eases rather than
   bounces. Light and dark are both first-class. Numbers use tabular figures
   everywhere so columns of prices line up.
   ───────────────────────────────────────────────────────────── */

:root {
  /* Type */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  /* Spacing — 8pt grid */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  /* Radii */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px; --r-full: 999px;

  /* Motion */
  --ease: cubic-bezier(.32, .72, 0, 1);
  --fast: .18s var(--ease);
  --med: .3s var(--ease);

  /* Light palette */
  --bg: #f2f2f7;
  --bg-elevated: #ffffff;
  --surface: rgba(255, 255, 255, .82);
  --surface-solid: #ffffff;
  --surface-2: #f7f7fa;
  --hairline: rgba(60, 60, 67, .13);
  --hairline-strong: rgba(60, 60, 67, .24);

  --text: #1d1d1f;
  --text-2: #48484a;
  --text-3: #8e8e93;
  --text-4: #aeaeb2;

  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, .12);
  --up: #1a7f43;
  --up-soft: rgba(26, 127, 67, .12);
  --down: #c0392b;
  --down-soft: rgba(192, 57, 43, .12);
  --warn: #b25000;
  --warn-soft: rgba(178, 80, 0, .12);

  --shadow-1: 0 1px 2px rgba(0,0,0,.05), 0 1px 1px rgba(0,0,0,.03);
  --shadow-2: 0 4px 16px rgba(0,0,0,.07), 0 1px 3px rgba(0,0,0,.05);
  --shadow-3: 0 12px 40px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.06);

  --sidebar-w: 232px;
  --tabbar-h: calc(56px + env(safe-area-inset-bottom, 0px));
  color-scheme: light;
}

/* Dark palette — applied by the toggle or by system preference */
:root[data-theme="dark"] {
  --bg: #000000;
  --bg-elevated: #1c1c1e;
  --surface: rgba(28, 28, 30, .78);
  --surface-solid: #1c1c1e;
  --surface-2: #2c2c2e;
  --hairline: rgba(84, 84, 88, .42);
  --hairline-strong: rgba(120, 120, 128, .5);

  --text: #f5f5f7;
  --text-2: #d1d1d6;
  --text-3: #8e8e93;
  --text-4: #636366;

  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, .18);
  --up: #30d158;
  --up-soft: rgba(48, 209, 88, .16);
  --down: #ff453a;
  --down-soft: rgba(255, 69, 58, .16);
  --warn: #ff9f0a;
  --warn-soft: rgba(255, 159, 10, .16);

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 4px 18px rgba(0,0,0,.5);
  --shadow-3: 0 14px 44px rgba(0,0,0,.62);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --bg-elevated: #1c1c1e;
    --surface: rgba(28, 28, 30, .78);
    --surface-solid: #1c1c1e;
    --surface-2: #2c2c2e;
    --hairline: rgba(84, 84, 88, .42);
    --hairline-strong: rgba(120, 120, 128, .5);
    --text: #f5f5f7;
    --text-2: #d1d1d6;
    --text-3: #8e8e93;
    --text-4: #636366;
    --accent: #0a84ff;
    --accent-soft: rgba(10, 132, 255, .18);
    --up: #30d158;
    --up-soft: rgba(48, 209, 88, .16);
    --down: #ff453a;
    --down-soft: rgba(255, 69, 58, .16);
    --warn: #ff9f0a;
    --warn-soft: rgba(255, 159, 10, .16);
    --shadow-1: 0 1px 2px rgba(0,0,0,.4);
    --shadow-2: 0 4px 18px rgba(0,0,0,.5);
    --shadow-3: 0 14px 44px rgba(0,0,0,.62);
    color-scheme: dark;
  }
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 28px; letter-spacing: -.022em; }
h2 { font-size: 20px; letter-spacing: -.018em; }
h3 { font-size: 16px; }
p  { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--accent); text-decoration: none; }
table { border-collapse: collapse; width: 100%; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ── App shell ───────────────────────────────────────────── */
#app { min-height: 100dvh; }

.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: var(--s2);
  padding: var(--s5) var(--s3);
  background: var(--surface);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-right: 1px solid var(--hairline);
}
.brand {
  display: flex; align-items: center; gap: var(--s2);
  padding: 0 var(--s2) var(--s4);
  font-size: 17px; font-weight: 650; letter-spacing: -.02em;
}
.brand-dot {
  width: 10px; height: 10px; border-radius: var(--r-full);
  background: var(--up); box-shadow: 0 0 0 3px var(--up-soft);
  flex: none;
}
.brand-dot.stale { background: var(--text-4); box-shadow: 0 0 0 3px rgba(142,142,147,.16); }

.nav-item {
  display: flex; align-items: center; gap: var(--s3);
  padding: 9px var(--s3); border-radius: var(--r-md);
  color: var(--text-2); font-size: 14.5px; font-weight: 500;
  transition: background var(--fast), color var(--fast);
  width: 100%; text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .ico { width: 20px; text-align: center; font-size: 16px; flex: none; }
.nav-spacer { flex: 1; }

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

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4) var(--s5);
  background: var(--surface);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-bottom: 1px solid var(--hairline);
}
.topbar h1 { font-size: 22px; flex: none; }
.topbar-spacer { flex: 1; }

.content { padding: var(--s5); flex: 1; }
.content.narrow { max-width: 1400px; margin: 0 auto; width: 100%; }

/* ── Controls ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 0 var(--s4);
  border-radius: var(--r-full); font-size: 14px; font-weight: 550;
  background: var(--surface-2); color: var(--text);
  transition: transform var(--fast), background var(--fast), opacity var(--fast);
}
.btn:hover { background: var(--hairline); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--down-soft); color: var(--down); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.sm { min-height: 28px; padding: 0 var(--s3); font-size: 13px; }
.btn.block { width: 100%; }

.input, .select {
  min-height: 38px; padding: 0 var(--s3);
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  background: var(--surface-solid); color: var(--text);
  transition: border-color var(--fast), box-shadow var(--fast);
  width: 100%; font-size: 15px;
}
.input:focus, .select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}
.input::placeholder { color: var(--text-4); }

.segmented {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--surface-2); border-radius: var(--r-md);
}
.segmented button {
  padding: 5px var(--s3); border-radius: 10px;
  font-size: 13.5px; font-weight: 550; color: var(--text-2);
  transition: background var(--fast), color var(--fast);
  white-space: nowrap;
}
.segmented button.active {
  background: var(--surface-solid); color: var(--text);
  box-shadow: var(--shadow-1);
}

.switch {
  position: relative; width: 46px; height: 28px; flex: none;
  background: var(--hairline-strong); border-radius: var(--r-full);
  transition: background var(--med);
}
.switch.on { background: var(--up); }
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 24px; height: 24px; border-radius: var(--r-full);
  background: #fff; box-shadow: var(--shadow-1);
  transition: transform var(--med);
}
.switch.on::after { transform: translateX(18px); }

/* ── Surfaces ────────────────────────────────────────────── */
.card {
  background: var(--surface-solid);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4) var(--s4) var(--s3);
  border-bottom: 1px solid var(--hairline);
}
.card-head h3 { flex: none; }
.card-body { padding: var(--s4); }

.grid { display: grid; gap: var(--s4); }
.row { display: flex; align-items: center; gap: var(--s3); }
.wrap { flex-wrap: wrap; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 600; letter-spacing: .01em;
  background: var(--surface-2); color: var(--text-2);
  white-space: nowrap;
}
.pill.up { background: var(--up-soft); color: var(--up); }
.pill.down { background: var(--down-soft); color: var(--down); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

.label { font-size: 11.5px; font-weight: 600; letter-spacing: .04em;
         text-transform: uppercase; color: var(--text-3); }
.muted { color: var(--text-3); }
.small { font-size: 13px; }
.up { color: var(--up); }
.down { color: var(--down); }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { font-size: 14px; }
table.data th {
  position: sticky; top: 0; z-index: 2;
  padding: 10px var(--s3); text-align: right; white-space: nowrap;
  font-size: 11.5px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-3);
  background: var(--surface-solid);
  border-bottom: 1px solid var(--hairline);
}
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--text); }
table.data td {
  padding: 10px var(--s3); text-align: right; white-space: nowrap;
  border-bottom: 1px solid var(--hairline);
  font-variant-numeric: tabular-nums;
}
table.data tbody tr { transition: background var(--fast); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr.clickable { cursor: pointer; }
.tick { font-weight: 650; letter-spacing: -.01em; }

/* ── Heatseeker ──────────────────────────────────────────── */
.heat-grid {
  display: grid; gap: var(--s2);
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
}
.heat-cell {
  position: relative; padding: var(--s3);
  border-radius: var(--r-md); border: 1px solid var(--hairline);
  background: var(--surface-solid); overflow: hidden;
  text-align: left; transition: transform var(--fast), box-shadow var(--fast);
  min-height: 92px;
}
.heat-cell:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.heat-cell::before {
  content: ""; position: absolute; inset: 0;
  background: var(--heat, transparent); opacity: var(--heat-a, 0);
  pointer-events: none;
}
.heat-cell > * { position: relative; }
.heat-tick { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.heat-price { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.heat-chg { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.heat-walls {
  margin-top: 6px; font-size: 11.5px; color: var(--text-3);
  font-variant-numeric: tabular-nums; display: flex; gap: 8px;
}

/* Position bar: where price sits between the put and call wall */
.posbar { height: 4px; border-radius: 2px; background: var(--surface-2);
          position: relative; margin-top: 7px; overflow: hidden; }
.posbar i { position: absolute; top: 0; bottom: 0; width: 3px;
            border-radius: 2px; background: var(--accent); }

/* ── Charts ──────────────────────────────────────────────── */
.chart-box { position: relative; width: 100%; }
.chart-box canvas { display: block; width: 100%; height: 100%; }
.legend { display: flex; gap: var(--s4); flex-wrap: wrap; font-size: 12.5px;
          color: var(--text-2); }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px;
            margin-right: 6px; vertical-align: middle; }

/* ── Compare grid ────────────────────────────────────────── */
.compare-grid {
  display: grid; gap: var(--s4);
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
}
.chip-row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 6px 5px 11px; border-radius: var(--r-full);
  background: var(--surface-2); font-size: 13.5px; font-weight: 600;
}
.chip button {
  width: 19px; height: 19px; border-radius: var(--r-full);
  background: var(--hairline-strong); color: var(--surface-solid);
  font-size: 12px; line-height: 1; display: grid; place-items: center;
}
.chip button:hover { background: var(--down); color: #fff; }

/* ── Flow ────────────────────────────────────────────────── */
.flow-list { display: flex; flex-direction: column; }
.flow-row {
  display: grid; align-items: center; gap: var(--s3);
  grid-template-columns: 62px 1fr auto auto;
  padding: 11px var(--s4); border-bottom: 1px solid var(--hairline);
  animation: slide-in .34s var(--ease);
}
@keyframes slide-in { from { opacity: 0; transform: translateY(-7px); } }
.flow-side {
  width: 26px; height: 26px; border-radius: var(--r-sm);
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  flex: none;
}
.flow-side.C { background: var(--up-soft); color: var(--up); }
.flow-side.P { background: var(--down-soft); color: var(--down); }
.flow-prem { font-weight: 650; font-variant-numeric: tabular-nums; }

/* ── Login ───────────────────────────────────────────────── */
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: var(--s5); }
.auth-card {
  width: 100%; max-width: 400px; padding: var(--s6) var(--s5);
  background: var(--surface-solid); border: 1px solid var(--hairline);
  border-radius: var(--r-xl); box-shadow: var(--shadow-3);
  animation: rise .45s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } }
.auth-card h1 { font-size: 24px; text-align: center; margin-bottom: 6px; }
.auth-sub { text-align: center; color: var(--text-3); font-size: 14px;
            margin-bottom: var(--s5); }
.field { margin-bottom: var(--s4); }
.field label { display: block; margin-bottom: 6px; font-size: 13px;
               font-weight: 550; color: var(--text-2); }

.otp-inputs { display: flex; gap: var(--s2); justify-content: center;
              margin: var(--s4) 0 var(--s5); }
.otp-inputs input {
  width: 46px; height: 56px; text-align: center;
  font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums;
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text);
  transition: border-color var(--fast), box-shadow var(--fast), background var(--fast);
}
.otp-inputs input:focus {
  outline: none; border-color: var(--accent); background: var(--surface-solid);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}

.alert {
  padding: 11px var(--s3); border-radius: var(--r-md);
  font-size: 13.5px; line-height: 1.5; margin-bottom: var(--s4);
}
.alert.error { background: var(--down-soft); color: var(--down); }
.alert.info { background: var(--accent-soft); color: var(--accent); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }

/* ── Feedback ────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%,
              var(--hairline) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; border-radius: var(--r-sm);
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.empty { padding: var(--s7) var(--s4); text-align: center; color: var(--text-3); }
.empty .big { font-size: 34px; margin-bottom: var(--s3); opacity: .5; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--s5) + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 20px); z-index: 200;
  padding: 11px var(--s4); border-radius: var(--r-full);
  background: var(--text); color: var(--bg-elevated);
  font-size: 14px; font-weight: 550; box-shadow: var(--shadow-3);
  opacity: 0; pointer-events: none; transition: opacity var(--med), transform var(--med);
  max-width: min(92vw, 460px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.mobile-only { display: none; }

/* ── Tablet ──────────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 76px; }
  .nav-item { justify-content: center; padding: 11px 0; }
  .nav-item .lbl, .brand .txt { display: none; }
  .brand { justify-content: center; padding-left: 0; padding-right: 0; }
  .compare-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}

/* ── Phone ───────────────────────────────────────────────── */
@media (max-width: 700px) {
  body { font-size: 16px; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-only { display: flex; }

  .topbar { padding: var(--s3) var(--s4); }
  .topbar h1 { font-size: 19px; }
  .content { padding: var(--s4) var(--s3);
             padding-bottom: calc(var(--tabbar-h) + var(--s4)); }

  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    height: var(--tabbar-h); padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--surface);
    backdrop-filter: saturate(180%) blur(24px);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    border-top: 1px solid var(--hairline);
  }
  .tabbar button {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 2px; min-height: 44px;
    font-size: 10.5px; font-weight: 550; color: var(--text-3);
    transition: color var(--fast);
  }
  .tabbar button .ico { font-size: 19px; }
  .tabbar button.active { color: var(--accent); }

  .heat-grid { grid-template-columns: 1fr 1fr; }
  .compare-grid { grid-template-columns: 1fr; }
  .flow-row { grid-template-columns: 46px 1fr auto; row-gap: 4px; }
  .flow-row .flow-when { grid-column: 2 / -1; }
  .otp-inputs input { width: 42px; height: 52px; font-size: 22px; }
  .auth-card { padding: var(--s5) var(--s4); }
  table.data th, table.data td { padding: 9px var(--s2); font-size: 13.5px; }
}

@media (min-width: 701px) { .tabbar { display: none; } }

/* ── Heatseeker matrix ─────────────────────────────────────
   A dense strike x expiration grid. Both axes stick while scrolling,
   because a number in the middle of the grid is meaningless without the
   strike and the expiry still visible.                                     */

.ticker-bar { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.ticker-scroll {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin;
  padding: 2px; flex: 1; scroll-behavior: smooth;
}
.ticker-scroll::-webkit-scrollbar { height: 5px; }
.ticker-scroll::-webkit-scrollbar-thumb {
  background: var(--hairline-strong); border-radius: 3px;
}
.ticker-chip {
  flex: none; padding: 5px 11px; border-radius: var(--r-sm);
  font-size: 12.5px; font-weight: 600; letter-spacing: -.01em;
  color: var(--text-3); background: var(--surface-2);
  transition: background var(--fast), color var(--fast);
}
.ticker-chip:hover { color: var(--text); background: var(--hairline); }
.ticker-chip.active { background: var(--accent); color: #fff; }

/* Pinned favourites read a shade warmer than the rest of the watchlist, and
   the first non-favourite carries a rule so the two groups stay legible even
   when the bar is scrolled. */
.ticker-chip.fav { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.ticker-chip.fav:hover { color: var(--warn); background: color-mix(in srgb, var(--warn) 20%, transparent); }
.ticker-chip.fav.active { background: var(--accent); color: #fff; }
.ticker-chip.after-favs { margin-left: 12px; box-shadow: -7px 0 0 -6px var(--hairline); }

.matrix-wrap {
  overflow: auto; max-height: min(74vh, 900px);
  -webkit-overflow-scrolling: touch;
}
table.matrix {
  border-collapse: separate; border-spacing: 0;
  font-size: 11.5px; font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  white-space: nowrap;
}
table.matrix thead th {
  position: sticky; top: 0; z-index: 3;
  padding: 7px 10px; text-align: center; font-weight: 600; font-size: 11px;
  font-family: var(--font); letter-spacing: .01em;
  background: var(--surface-solid); color: var(--text-2);
  border-bottom: 1px solid var(--hairline);
}
table.matrix thead th.sticky-corner {
  left: 0; z-index: 5; text-align: left;
  border-right: 1px solid var(--hairline);
}
.sticky-strike {
  position: sticky; left: 0; z-index: 2;
  padding: 0 10px; text-align: right; font-weight: 600;
  background: var(--surface-solid); color: var(--text-2);
  border-right: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}
table.matrix td.cell {
  padding: 0 9px; height: 22px; text-align: right;
  border-bottom: 1px solid rgba(0,0,0,.14);
  border-right: 1px solid rgba(0,0,0,.14);
  transition: outline-color var(--fast);
  outline: 2px solid transparent; outline-offset: -2px;
}
table.matrix td.cell:hover { outline-color: var(--text); }
table.matrix td.row-total,
table.matrix tfoot td {
  padding: 0 10px; text-align: right; font-weight: 600;
  background: var(--surface-2);
  border-bottom: 1px solid var(--hairline);
}
table.matrix tfoot th, table.matrix tfoot td {
  position: sticky; bottom: 0; z-index: 3;
  background: var(--surface-solid);
  border-top: 1px solid var(--hairline-strong);
}
table.matrix tfoot th { z-index: 4; }

.wall-tag {
  display: inline-block; margin-left: 5px; padding: 0 4px;
  border-radius: 4px; font-size: 9px; font-weight: 700;
  font-family: var(--font); vertical-align: middle;
}
.wall-tag.call { background: var(--up-soft); color: var(--up); }
.wall-tag.put { background: var(--down-soft); color: var(--down); }

.spot-row th, .spot-row td { padding: 0; height: 0; border: none; background: none; }
.sticky-strike.spot {
  height: 18px; color: var(--accent); font-size: 10.5px;
  background: var(--surface-solid);
}
.spot-line { position: relative; height: 18px; }
.spot-line::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%;
  border-top: 1.5px dashed var(--accent); opacity: .85;
}
.spot-line span {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  padding: 1px 6px; border-radius: var(--r-full);
  background: var(--accent); color: #fff;
  font-size: 9.5px; font-weight: 700; font-family: var(--font);
  letter-spacing: .02em;
}

/* ── Popover (View controls) ─────────────────────────────── */
.popover-wrap { position: relative; }
.popover {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60;
  width: 264px; padding: var(--s4);
  background: var(--surface-solid);
  border: 1px solid var(--hairline); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  animation: pop-in .16s var(--ease);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.pop-title { font-size: 13px; font-weight: 650; margin-bottom: var(--s3); }
.pop-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-3);
  margin: var(--s3) 0 6px; display: block;
}
.pop-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s2); margin: var(--s3) 0 6px;
}
.pop-row .pop-label { margin: 0; }
.pop-value { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

input.range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 2px; margin: 2px 0 4px;
  background: var(--hairline-strong); cursor: pointer;
}
input.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 17px; height: 17px; border-radius: var(--r-full);
  background: #fff; border: 1px solid var(--hairline-strong);
  box-shadow: var(--shadow-1); cursor: grab;
}
input.range::-moz-range-thumb {
  width: 17px; height: 17px; border-radius: var(--r-full);
  background: #fff; border: 1px solid var(--hairline-strong);
  box-shadow: var(--shadow-1); cursor: grab;
}
input.range:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

@media (max-width: 700px) {
  table.matrix { font-size: 10.5px; }
  table.matrix td.cell { padding: 0 6px; height: 24px; }
  .sticky-strike { padding: 0 7px; }
  .matrix-wrap { max-height: 66vh; }
  .popover { position: fixed; left: var(--s3); right: var(--s3);
             top: auto; bottom: calc(var(--tabbar-h) + var(--s3)); width: auto; }
}

/* Strikes close to spot get a faint tint so the money area stays findable
   while scrolling a long ladder. */
table.matrix tr.near-spot .sticky-strike {
  color: var(--text); font-weight: 700;
  box-shadow: inset 2px 0 0 var(--accent);
}

@media (max-width: 1024px) {
  /* The strike/expiration counts also live inside View controls, so on
     narrower screens they only cost a toolbar row. */
  .hide-sm { display: none !important; }
}

@media (max-width: 700px) {
  /* Keep the matrix toolbar on one line: the counts move into View controls. */
  .ticker-bar .btn { min-width: 34px; padding: 0 8px; }
}

/* ── Structural nodes ────────────────────────────────────── */
.node-strip {
  display: grid; gap: var(--s2); margin-bottom: var(--s3);
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
}
.node-tile {
  display: flex; flex-direction: column; gap: 3px;
  padding: 10px var(--s3); text-align: left;
  background: var(--surface-solid); border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  transition: border-color var(--fast), transform var(--fast);
}
button.node-tile:hover {
  border-color: var(--accent); transform: translateY(-1px);
}
.node-tile.static { cursor: default; }

.wall-tag.king {
  background: linear-gradient(135deg, #f5c518, #e0a500);
  color: #241c00; font-size: 10px;
}
.wall-tag.ceiling { background: var(--up-soft); color: var(--up); }
.wall-tag.floor { background: var(--down-soft); color: var(--down); }
.wall-tag.gate { background: var(--accent-soft); color: var(--accent); }

table.matrix tr.flash td { animation: flash-row 1.2s var(--ease); }
@keyframes flash-row {
  0%, 100% { box-shadow: inset 0 0 0 0 transparent; }
  25% { box-shadow: inset 0 0 0 2px var(--accent); }
}

/* ── Guide ───────────────────────────────────────────────── */
.doc-layout {
  display: grid; grid-template-columns: 210px 1fr; gap: var(--s5);
  align-items: start;
}
.doc-nav {
  position: sticky; top: 90px; display: flex; flex-direction: column; gap: 2px;
}
.doc-link {
  padding: 8px var(--s3); border-radius: var(--r-sm); text-align: left;
  font-size: 13.5px; font-weight: 500; color: var(--text-3); line-height: 1.35;
  transition: background var(--fast), color var(--fast);
}
.doc-link:hover { background: var(--surface-2); color: var(--text); }
.doc-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.doc-body { font-size: 15px; max-width: 760px; }
.doc-body h2 { font-size: 21px; letter-spacing: -.018em; }
.doc-body code {
  font-family: var(--font-mono); font-size: .88em;
  padding: 1px 5px; border-radius: 5px; background: var(--surface-2);
}
.doc-body b, .doc-body strong { font-weight: 650; }
pre.doc-code {
  font-family: var(--font-mono); font-size: 13px; line-height: 1.7;
  padding: var(--s3) var(--s4); margin: 0 0 14px;
  background: var(--surface-2); border-radius: var(--r-md);
  border: 1px solid var(--hairline); overflow-x: auto; white-space: pre;
}
ul.doc-list { margin: 0 0 12px; padding-left: 20px; line-height: 1.65; }
ul.doc-list li { margin-bottom: 5px; }

.doc-callout {
  padding: var(--s3) var(--s4); border-radius: var(--r-md);
  margin: 0 0 14px; font-size: 14px;
  background: var(--accent-soft); border-left: 3px solid var(--accent);
}
.doc-callout.warn {
  background: var(--warn-soft); border-left-color: var(--warn);
}

.doc-two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3);
           margin: 0 0 14px; }
.doc-col {
  padding: var(--s3) var(--s4); border-radius: var(--r-md);
  border: 1px solid var(--hairline); background: var(--surface-2);
}
.doc-col.pika { border-left: 3px solid var(--warn); }
.doc-col.barney { border-left: 3px solid var(--accent); }
.doc-col ul.doc-list { margin: 0; font-size: 13.5px; }

@media (max-width: 900px) {
  .doc-layout { grid-template-columns: 1fr; gap: var(--s3); }
  .doc-nav { position: static; flex-direction: row; overflow-x: auto;
             padding-bottom: 4px; }
  .doc-link { white-space: nowrap; flex: none; }
  .doc-two { grid-template-columns: 1fr; }
}

/* ── King Node & top nodes ───────────────────────────────── */
.node-tile.king-tile {
  border-color: rgba(245, 197, 24, .55);
  background: linear-gradient(180deg, rgba(245,197,24,.09), transparent 62%),
              var(--surface-solid);
}
.node-tile.king-tile:hover { border-color: #f5c518; }

.top-nodes {
  display: flex; align-items: center; gap: var(--s3);
  margin-bottom: var(--s3); min-width: 0;
}
.top-scroll {
  display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 5px;
  flex: 1; scrollbar-width: thin;
}
.top-scroll::-webkit-scrollbar { height: 5px; }
.top-scroll::-webkit-scrollbar-thumb {
  background: var(--hairline-strong); border-radius: 3px;
}
.top-chip {
  flex: none; display: flex; align-items: baseline; gap: 6px;
  padding: 5px 11px; border-radius: var(--r-sm);
  border: 1px solid var(--hairline); background: var(--surface-solid);
  font-size: 12.5px; white-space: nowrap;
  transition: transform var(--fast), border-color var(--fast);
}
.top-chip:hover { transform: translateY(-1px); border-color: var(--accent); }
.top-chip.pika { border-left: 3px solid var(--warn); }
.top-chip.barney { border-left: 3px solid var(--accent); }
.top-chip .crown { color: #f5c518; font-size: 13px; }
.top-chip .top-exp { color: var(--text-3); font-size: 11.5px; }

/* The King cell keeps a permanent gold ring so it is findable while scrolling. */
table.matrix td.cell.king-cell {
  outline: 2px solid #f5c518;
  outline-offset: -2px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .45);
  font-weight: 700;
}
table.matrix td.cell.cell-flash { animation: cell-pulse 1.4s var(--ease); }
@keyframes cell-pulse {
  0%, 100% { outline: 2px solid transparent; outline-offset: -2px; }
  30% { outline: 3px solid var(--accent); outline-offset: -1px; }
}

@media (max-width: 700px) {
  .top-nodes > .label { display: none; }
}

/* Skylit marks the King Node's figure itself with a star. Kept inside the
   cell so it travels with the number when the grid scrolls. Gold with a dark
   halo so it stays legible on any part of the colour ramp. */
.king-star {
  margin-left: 4px;
  color: #ffd34d;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  vertical-align: -1px;
  text-shadow: 0 0 3px rgba(0,0,0,.95), 0 0 6px rgba(0,0,0,.7);
}

/* ── Brand ───────────────────────────────────────────────── */
.brand-word {
  font-weight: 800; letter-spacing: -.02em; font-size: 15px;
  white-space: nowrap;
}
.brand { gap: var(--s2); }
