/* ============================================================================
   OI Radar - styles.css
   Design system for a dense, terminal-like options analytics dashboard.
   Dark theme only. Plain CSS, no preprocessor, no external fonts, no imports.
   Loaded from a file:// page, so everything here must be self-contained.

   CLASS VOCABULARY (stable API for the JS modules)
   This block is the contract the JS modules code against, so it is kept
   exhaustive on purpose - a class that exists here but not below (or the
   reverse) is a silent rendering failure nobody notices in review.
   ---------------------------------------------------------------------------
   shell      .app .hdr .hdr-brand[>span] .hdr-sym[>small] .hdr-meta[>b]
              .hdr-tools  .rail .rail-sec .rail-tab[.active][disabled]
              .rt-k .rt-d  .main .view[.active]
   layout     .panel .panel-hd .panel-ti .panel-sub .panel-bd[.flush]
              .panel-ft  .spacer (push-right, valid in .panel-hd/.cmt-hd/
              .chart-hd)  .grid .g2 .g3 .g4 .g-2-1 .g-1-2
              .row .col .spread .gap-s .gap-l .divider
   tiles      .tiles .tile[.up .down .warn .info .flat .wide]
              inside a tile: .k (label) .v (value) .u (unit, inside .v)
              .s (sub-line)
   tables     .tbl-wrap[.short .tall .auto]  .tbl[.dense .striped-off]
              thead th[.t .c .ce .pe .strike] th.sortable[aria-sort]
              thead tr.grp  (the CALLS | strike | PUTS group row; the second
                             header row is offset by --grp-h automatically)
              tbody td[.t .n .c .strike .ce-side .pe-side]
              tbody tr[.atm .itm-ce .itm-pe .wall-ce .wall-pe .muted]
              tfoot td, caption
              NOTE .itm-ce / .itm-pe shade only cells that ALSO carry
              .ce-side / .pe-side - the row class alone paints nothing.
              NOTE td.strike and th.strike are position:sticky left:0, so
              their backgrounds must stay fully opaque.
   meters     .meter .meter-fill[.ce .pe .amber .cyan]
              .cellbar .cellbar-fill[.ce .pe] .cellbar>span
   comment    .cmt[.stacked][.lvl-high .lvl-med .lvl-low .lvl-info]
              .cmt-hd .cmt-ti .cmt-meta
              .cmt-beats .beat[.dekha .rule .matlab .galat .stack]
              .beat-k .beat-v   (all four beats are required on every card)
   levels     .lvl-high .lvl-med .lvl-low .lvl-info (card rail + chip + dot)
              .lvl-dot
   chips      .chips .chip[.green .red .amber .blue .purple .cyan .dim
              .solid .sq]  button.chip[aria-pressed]
   charts     .chart .chart-hd[>.ti >.sub >.spacer] .chart-bd .chart-note
              .chart-legend .lg .lg-sw[.ce .pe .amber .cyan .purple .line]
              svg: .ax .gl .axl .lbl .lbl-hi .zero .hitbox
                   .ser-ce .ser-pe .ser-blue .ser-cyan .ser-purple .ser-amber
                   .ln[.ln-cyan .ln-blue .ln-amber .ln-purple]
                   .mark .mark-spot
   academy    .academy .toc .toc-a[.active .sub] .prose[>.lead]
              .callout[.warn .good .note .bad] > .ct
              .ex .kv .kv-k .kv-v
   ref tables .gloss > .term .hin .why
              .rulebook .rb .rb-ti .rb-grid .rb-k .rb-v
              .rb-when .rb-then .rb-fail
              .assume  (REQUIRED wrapper for anything derived from gex_signed)
   controls   .btn[.primary .ghost .sm][disabled|aria-disabled]
              .seg .seg-b[.active|aria-selected]  .sel  .inp
              .sw-wrap > input.sw + .sw-track > .sw-thumb, then .sw-lbl
   status     .conn[.ok .warn .err .idle] .conn-dot  .stale
   states     .sk .sk-line[.w40 .w60 .w80] .sk-tile .sk-row .sk-chart .sk-txt
              .empty[.err .sm] .empty-t .empty-s
              .nodata  (the "baseline abhi ban raha hai" placeholder - use
                        this whenever oi_chg_day / oi_chg_prev is null; the
                        UI must never render a fabricated 0)
   tooltip    .tip[data-tip][.tip-b .tip-l .tip-r]  .tip-i
   utility    .num .mono .sans .dim .faint .up/.pos .dn/.neg .flatv .warnv
              .infov .r .c .nw .hide .trunc .eyebrow .sr-only
   ========================================================================= */


/* ---------------------------------------------------------------------------
   01. TOKENS
   The seven core surface/text tokens and six accents are fixed by the desk
   contract and must not drift - the OI Radar sits next to the existing
   delta-neutral desk and has to look like the same product. Everything else
   here is derived so that a future theme tweak stays in one place.
   ------------------------------------------------------------------------ */
:root{
  /* contract tokens - do not change */
  --bg:#0a0e14;
  --panel:#111823;
  --panel2:#161f2e;
  --line:#1e2a3d;
  --text:#dbe4f0;
  --dim:#8595ab;
  --faint:#5a6a80;
  --green:#3fd68c;
  --red:#ff5d6c;
  --amber:#ffb454;
  --blue:#4aa8ff;
  --purple:#b48ff5;
  --cyan:#3fd6d6;

  /* derived surfaces */
  --panel3:#1b2537;              /* raised: active tab, hovered strike cell */
  --line2:#2a3950;               /* brighter hairline for emphasis borders */
  --sunken:#080b10;              /* inset wells, code blocks, chart bg */
  --hover:rgba(74,168,255,.07);
  --zebra:rgba(255,255,255,.017);
  --scrim:rgba(10,14,20,.86);

  /* tinted washes - accents at low alpha for backgrounds */
  --green-w:rgba(63,214,140,.11);
  --red-w:rgba(255,93,108,.11);
  --amber-w:rgba(255,180,84,.11);
  --blue-w:rgba(74,168,255,.11);
  --purple-w:rgba(180,143,245,.11);
  --cyan-w:rgba(63,214,214,.11);

  /* typography */
  --mono:ui-monospace,'SF Mono',Menlo,Consolas,'Liberation Mono',monospace;
  --sans:system-ui,-apple-system,'Segoe UI',Roboto,'Helvetica Neue',sans-serif;
  --fs:13.5px;          /* base prose size */
  --fs-s:12px;          /* secondary */
  --fs-xs:10.5px;       /* labels, uppercase eyebrows */

  /* metrics */
  --hdr-h:52px;
  --rail-w:186px;
  --rail-w-sm:56px;
  /* Height of the CALLS|strike|PUTS group header row. The second header row
     is offset by exactly this much so both stick without a gap or an overlap,
     so the row's box height is pinned to it rather than left to line-height +
     padding (which differs between .tbl and .tbl.dense). */
  --grp-h:26px;
  --r:6px;              /* standard radius */
  --r-s:4px;
  --r-l:10px;
  --pad:14px;
  --gap:12px;

  /* motion + focus */
  --t:.15s ease;
  --focus:var(--blue);
  --shadow:0 8px 26px rgba(0,0,0,.5);

  color-scheme:dark;
}


/* ---------------------------------------------------------------------------
   02. RESET + BASE
   ------------------------------------------------------------------------ */
*,*::before,*::after{box-sizing:border-box}
html,body{margin:0;padding:0;height:100%}
html{-webkit-text-size-adjust:100%}
body{
  background:var(--bg);
  color:var(--text);
  font-family:var(--sans);
  font-size:var(--fs);
  line-height:1.5;
  /* Requirement: tabular figures everywhere. Inherited by every descendant so
     that live-updating numbers never jitter their column width. */
  font-variant-numeric:tabular-nums;
  font-feature-settings:"tnum" 1,"lnum" 1;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  /* the body itself must NEVER scroll sideways - wide content lives inside
     its own .tbl-wrap / .chart-bd scroller */
  overflow-x:hidden;
}
h1,h2,h3,h4,h5,p,figure,ul,ol,dl,dd,pre{margin:0}
ul,ol{padding-left:1.15em}
img,svg{max-width:100%}
svg{display:block}
a{color:var(--blue);text-decoration:none}
a:hover{text-decoration:underline}
button,input,select,textarea{font:inherit;color:inherit}
hr{border:0;border-top:1px solid var(--line);margin:14px 0}
::selection{background:rgba(74,168,255,.28)}

/* Focus-visible on every interactive element. Uses :where() so it never wins
   a specificity fight with a component's own focus style. */
:where(a,button,select,input,textarea,summary,[tabindex],[role="button"],
       [role="tab"],[role="switch"]):focus-visible{
  outline:2px solid var(--focus);
  outline-offset:2px;
  border-radius:var(--r-s);
}
/* Kill the legacy UA focus ring only where we have replaced it. */
:where(a,button,select,input,textarea,summary,[tabindex]):focus:not(:focus-visible){outline:none}


/* ---------------------------------------------------------------------------
   03. TYPOGRAPHY + UTILITIES
   ------------------------------------------------------------------------ */
.num,.mono{font-family:var(--mono);font-variant-numeric:tabular-nums;letter-spacing:-.02em}
.sans{font-family:var(--sans)}
.dim{color:var(--dim)}
.faint{color:var(--faint)}
.up,.pos{color:var(--green)}
.dn,.neg{color:var(--red)}
.flatv{color:var(--dim)}
.warnv{color:var(--amber)}
.infov{color:var(--blue)}
.r{text-align:right}
.c{text-align:center}
.nw{white-space:nowrap}
.hide{display:none !important}
.trunc{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
.divider{height:1px;background:var(--line);margin:10px 0}
.eyebrow{font-size:var(--fs-xs);font-weight:600;letter-spacing:.09em;
  text-transform:uppercase;color:var(--faint)}
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;
  overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}


/* ---------------------------------------------------------------------------
   04. APP SHELL - fixed header, fixed left tab rail, scrolling main
   ------------------------------------------------------------------------ */
.app{min-height:100%}

.hdr{position:fixed;top:0;left:0;right:0;height:var(--hdr-h);z-index:60;display:flex;
  align-items:center;gap:14px;padding:0 16px;border-bottom:1px solid var(--line);
  background:linear-gradient(180deg,#111a27,#0d141e)}
.hdr-brand{font-family:var(--mono);font-size:13px;font-weight:700;letter-spacing:.14em;
  text-transform:uppercase;color:var(--cyan);white-space:nowrap;
  display:flex;align-items:center;gap:9px}
.hdr-logo{width:40px;height:40px;display:block;flex:none}
.hdr-brand span{color:var(--faint);font-weight:500}
.hdr-sym{font-family:var(--mono);font-size:17px;font-weight:700;letter-spacing:-.01em}
.hdr-sym small{font-size:11px;color:var(--dim);font-weight:500;margin-left:6px}
.hdr-meta{display:flex;align-items:center;gap:16px;min-width:0;
  font-family:var(--mono);font-size:12px;color:var(--dim)}
.hdr-meta b{color:var(--text);font-weight:600}
.hdr-tools{display:flex;align-items:center;gap:8px;margin-left:auto}

/* left rail ------------------------------------------------------------- */
.rail{position:fixed;top:var(--hdr-h);bottom:0;left:0;width:var(--rail-w);z-index:50;
  padding:10px 8px 24px;overflow-y:auto;overflow-x:hidden;
  background:var(--panel);border-right:1px solid var(--line)}
.rail-sec{margin:14px 6px 6px;font-size:var(--fs-xs);font-weight:600;
  letter-spacing:.09em;text-transform:uppercase;color:var(--faint)}
.rail-sec:first-child{margin-top:2px}
.rail-tab{display:block;width:100%;text-align:left;cursor:pointer;
  padding:7px 10px;margin-bottom:2px;border:0;border-radius:var(--r);
  background:transparent;color:var(--dim);transition:background var(--t),color var(--t)}
.rail-tab .rt-k{display:block;font-size:12.5px;font-weight:600;letter-spacing:.01em}
.rail-tab .rt-d{display:block;font-size:10.5px;color:var(--faint);margin-top:1px;line-height:1.35}
.rail-tab:hover{background:var(--panel2);color:var(--text)}
.rail-tab.active{background:var(--panel3);color:var(--text);box-shadow:inset 2px 0 0 var(--cyan)}
.rail-tab.active .rt-d{color:var(--dim)}
.rail-tab[disabled]{opacity:.4;cursor:not-allowed}

/* main scroll area ------------------------------------------------------- */
.main{padding:calc(var(--hdr-h) + 14px) 16px 60px calc(var(--rail-w) + 16px);max-width:2100px}
.view{display:none}
.view.active{display:block;animation:fade .18s ease}
@keyframes fade{from{opacity:0;transform:translateY(3px)}to{opacity:1;transform:none}}


/* ---------------------------------------------------------------------------
   05. PANELS + LAYOUT GRIDS
   ------------------------------------------------------------------------ */
.panel{background:var(--panel);border:1px solid var(--line);border-radius:var(--r-l);
  margin-bottom:var(--gap);overflow:hidden}
.panel-hd{display:flex;align-items:center;gap:10px;flex-wrap:wrap;
  padding:9px var(--pad);background:var(--panel2);border-bottom:1px solid var(--line)}
.panel-ti{font-size:12.5px;font-weight:700;letter-spacing:.03em}
.panel-sub{font-size:11px;color:var(--dim);font-family:var(--mono)}
.panel-hd .spacer{margin-left:auto}
.panel-bd{padding:var(--pad)}
.panel-bd.flush{padding:0}
.panel-ft{padding:8px var(--pad);border-top:1px solid var(--line);
  background:var(--panel2);font-size:11.5px;color:var(--dim)}

.grid{display:grid;gap:var(--gap)}
.g2{grid-template-columns:repeat(2,minmax(0,1fr))}
.g3{grid-template-columns:repeat(3,minmax(0,1fr))}
.g4{grid-template-columns:repeat(4,minmax(0,1fr))}
.g-2-1{grid-template-columns:minmax(0,2fr) minmax(0,1fr)}
.g-1-2{grid-template-columns:minmax(0,1fr) minmax(0,2fr)}
.row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.col{display:flex;flex-direction:column;gap:8px;min-width:0}
.spread{justify-content:space-between}
.gap-s{gap:6px}
.gap-l{gap:18px}


/* ---------------------------------------------------------------------------
   06. STAT TILES
   ------------------------------------------------------------------------ */
.tiles{display:grid;gap:10px;margin-bottom:var(--gap);
  grid-template-columns:repeat(auto-fit,minmax(140px,1fr))}
.tile{background:var(--panel);border:1px solid var(--line);border-radius:var(--r);
  padding:9px 11px;min-width:0;position:relative;overflow:hidden}
.tile::before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--line2)}
.tile .k{font-size:var(--fs-xs);letter-spacing:.07em;text-transform:uppercase;
  color:var(--faint);font-weight:600;display:flex;align-items:center;gap:4px}
.tile .v{font-family:var(--mono);font-size:19px;font-weight:600;line-height:1.15;
  margin-top:3px;letter-spacing:-.02em}
.tile .v .u{font-size:11px;color:var(--dim);font-weight:500;margin-left:3px}
.tile .s{font-family:var(--mono);font-size:11px;color:var(--dim);margin-top:2px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tile.up::before{background:var(--green)}   .tile.up .v{color:var(--green)}
.tile.down::before{background:var(--red)}   .tile.down .v{color:var(--red)}
.tile.warn::before{background:var(--amber)} .tile.warn .v{color:var(--amber)}
.tile.info::before{background:var(--blue)}
.tile.flat::before{background:var(--faint)}
.tile.wide{grid-column:span 2}


/* ---------------------------------------------------------------------------
   07. TABLES - sticky head, zebra rows, right-aligned tabular numerics
   Wide chains live in .tbl-wrap so the page body never scrolls sideways.
   ------------------------------------------------------------------------ */
/* max-height keeps the sticky header useful; override per instance */
.tbl-wrap{overflow:auto;max-width:100%;max-height:72vh;overscroll-behavior:contain}
.tbl-wrap.short{max-height:340px}
.tbl-wrap.tall{max-height:82vh}
.tbl-wrap.auto{max-height:none}

.tbl{border-collapse:separate;border-spacing:0;width:100%;font-size:12px}
/* borders do not paint reliably on sticky cells - use an inset shadow */
.tbl thead th{position:sticky;top:0;z-index:3;background:var(--panel2);color:var(--dim);
  font-family:var(--sans);font-size:10.5px;font-weight:600;
  letter-spacing:.07em;text-transform:uppercase;
  padding:7px 8px;text-align:right;white-space:nowrap;
  box-shadow:inset 0 -1px 0 var(--line),inset 0 1px 0 var(--line)}
.tbl thead th.t,.tbl thead th:first-child{text-align:left}
.tbl thead th.c{text-align:center}
/* grouped header row (CALLS | strike | PUTS).
   The box height is pinned to --grp-h (line-height carries the text, vertical
   padding is zeroed) so that the second header row's `top` offset is exact.
   Deriving the offset from padding + line-height instead would overlap by ~3px
   in the default table and leave a ~1px bleed gap in .tbl.dense. */
.tbl thead tr.grp th{top:0;font-size:10px;letter-spacing:.12em;
  color:var(--faint);background:var(--panel3);
  height:var(--grp-h);padding-top:0;padding-bottom:0;line-height:var(--grp-h)}
.tbl thead tr.grp + tr th{top:var(--grp-h)}
.tbl thead th.ce{color:var(--red)}
.tbl thead th.pe{color:var(--green)}
/* The strike header must pin on BOTH axes or it slides away from its own
   column as soon as the greeks scroll sideways. Sticky supports two axes on
   one element; it just needs to outrank the other header cells (z 3) and the
   sticky body cells (z 2) at the intersection. */
.tbl thead th.strike{left:0;z-index:5;background:var(--panel3);text-align:center}

.tbl td{padding:5px 8px;border-bottom:1px solid var(--line);
  text-align:right;white-space:nowrap;letter-spacing:-.02em;
  font-family:var(--mono);font-variant-numeric:tabular-nums}
.tbl td.t{font-family:var(--sans);text-align:left;letter-spacing:0;white-space:normal}
.tbl td.n{font-family:var(--mono);text-align:right}
.tbl td.c{text-align:center}
/* The strike column is position:sticky, so every background it can ever take
   MUST be fully opaque. A translucent value lets the greek columns scroll
   visibly underneath it, which reads as a rendering glitch on a live chain. */
.tbl td.strike{font-weight:700;background:var(--panel2);color:var(--text);
  text-align:center;position:sticky;left:0;z-index:2}
.tbl tbody tr:nth-child(odd) td{background:var(--zebra)}
.tbl tbody tr:nth-child(odd) td.strike{background:var(--panel3)}
/* Clearing the zebra must not clear the sticky column's opaque backing, or the
   strike cells go see-through and the greeks scroll visibly under them. The
   backing is re-asserted on the next line rather than by adding :not(.strike)
   here, because raising this rule's specificity would make it outrank the
   :hover rules below and kill row hover entirely in striped-off tables. */
.tbl.striped-off tbody tr td{background:transparent}
.tbl.striped-off td.strike{background:var(--panel2)}

/* row emphasis - ATM and moneyness shading.
   NOTE .itm-ce / .itm-pe only shade cells that also carry .ce-side / .pe-side;
   the row class on its own paints nothing. That pairing is documented in the
   vocabulary block at the top of this file. */
.tbl tbody tr.atm td{background:rgba(63,214,214,.09);
  box-shadow:inset 0 1px 0 rgba(63,214,214,.35),inset 0 -1px 0 rgba(63,214,214,.35)}
/* #1d404c is rgba(63,214,214,.18) pre-composited over --panel2, kept opaque
   for the sticky-column reason above. */
.tbl tbody tr.atm td.strike{background:#1d404c;color:var(--cyan)}
.tbl tbody tr.itm-ce td.ce-side{background:rgba(255,93,108,.05)}
.tbl tbody tr.itm-pe td.pe-side{background:rgba(63,214,140,.05)}
.tbl tbody tr.wall-ce td.strike{box-shadow:inset 3px 0 0 var(--red)}
.tbl tbody tr.wall-pe td.strike{box-shadow:inset -3px 0 0 var(--green)}
.tbl tbody tr.muted td{opacity:.5}

/* Hover comes AFTER the emphasis block on purpose. The emphasis rules match at
   the same specificity, so hovering an .atm row would otherwise give no
   feedback at all - and the ATM row is the one a trader mouses over most. */
.tbl tbody tr:hover td{background:var(--hover)}
.tbl tbody tr:hover td.strike{background:#22304a}
.tbl tbody tr.atm:hover td{background:rgba(63,214,214,.16)}
.tbl tbody tr.atm:hover td.strike{background:#26525f}
.tbl tbody tr.itm-ce:hover td.ce-side{background:rgba(255,93,108,.12)}
.tbl tbody tr.itm-pe:hover td.pe-side{background:rgba(63,214,140,.12)}

.tbl.dense td{padding:3px 6px;font-size:11.5px}
.tbl.dense thead th{padding:5px 6px}
/* Sticky totals row. It must outrank the sticky body strike cells (z 2) or the
   strike column paints over it as the chain scrolls past. */
.tbl tfoot td{position:sticky;bottom:0;z-index:3;background:var(--panel2);
  font-weight:600;border-top:1px solid var(--line2)}
.tbl tfoot td.strike{z-index:4;background:var(--panel3)}
.tbl caption{caption-side:top;text-align:left;padding:6px var(--pad);
  font-size:11px;color:var(--dim)}
th.sortable{cursor:pointer;user-select:none}
th.sortable:hover{color:var(--text)}
th.sortable[aria-sort="ascending"]::after{content:" \2191";color:var(--cyan)}
th.sortable[aria-sort="descending"]::after{content:" \2193";color:var(--cyan)}


/* ---------------------------------------------------------------------------
   08. METERS + IN-CELL BARS
   Hand-rolled OI magnitude bars; no charting library involved.
   ------------------------------------------------------------------------ */
.meter{position:relative;height:6px;border-radius:3px;
  background:var(--sunken);overflow:hidden;min-width:40px}
.meter-fill{position:absolute;inset:0 auto 0 0;background:var(--blue);border-radius:3px}
.meter-fill.ce{background:var(--red)} .meter-fill.pe{background:var(--green)}
.meter-fill.amber{background:var(--amber)} .meter-fill.cyan{background:var(--cyan)}

/* bar that lives inside a table cell, anchored to the side facing the strike */
.cellbar{position:relative;display:block;height:12px;min-width:24px}
.cellbar-fill{position:absolute;top:2px;bottom:2px;border-radius:2px;opacity:.42}
.cellbar-fill.ce{right:0;background:var(--red)}
.cellbar-fill.pe{left:0;background:var(--green)}
.cellbar span{position:relative;z-index:1;display:block;line-height:12px;
  font-family:var(--mono);font-size:11.5px}


/* ---------------------------------------------------------------------------
   09. COMMENTARY CARD - the four beats
   dekha / rule / matlab / galat. Each beat carries its own accent rail and
   label so the card is scannable at a glance, and "Galat kab hoga" is
   deliberately set apart (dashed separator, inset well, amber accent) because
   the falsification beat is the whole point of the product.
   ------------------------------------------------------------------------ */
.cmt{background:var(--panel);border:1px solid var(--line);border-radius:var(--r-l);
  margin-bottom:10px;overflow:hidden;border-left:3px solid var(--faint)}
.cmt-hd{display:flex;align-items:center;gap:8px;flex-wrap:wrap;
  padding:8px 12px;background:var(--panel2);border-bottom:1px solid var(--line)}
.cmt-ti{font-size:12.5px;font-weight:700;letter-spacing:.02em}
.cmt-hd .spacer{margin-left:auto}
.cmt-meta{font-family:var(--mono);font-size:11px;color:var(--faint)}

.cmt-beats{padding:4px 0 0}
.beat{display:grid;grid-template-columns:96px minmax(0,1fr);
  gap:10px;padding:7px 12px;align-items:start}
.beat + .beat{border-top:1px solid rgba(30,42,61,.6)}
.beat-k{display:flex;align-items:center;gap:6px;padding-top:2px;white-space:nowrap;
  font-size:var(--fs-xs);font-weight:700;letter-spacing:.08em;text-transform:uppercase}
/* small square marker before each label - gives the four beats a rhythm */
.beat-k::before{content:"";width:6px;height:6px;border-radius:1px;flex:none}
.beat-v{font-size:13px;line-height:1.55;min-width:0}
.beat-v b,.beat-v strong{font-weight:600;color:#fff}
.beat-v .num{font-size:12.5px;color:var(--cyan)}

/* beat 1 - dekha kya: raw observation, cyan (facts) */
.beat.dekha .beat-k{color:var(--cyan)}
.beat.dekha .beat-k::before{background:var(--cyan)}
/* beat 2 - rule: the general principle, purple (theory) */
.beat.rule .beat-k{color:var(--purple)}
.beat.rule .beat-k::before{background:var(--purple)}
.beat.rule .beat-v{color:var(--dim)}
.beat.rule .beat-v em{color:var(--text);font-style:normal;font-weight:600}
/* beat 3 - matlab: implication for right now, blue and slightly louder */
.beat.matlab .beat-k{color:var(--blue)}
.beat.matlab .beat-k::before{background:var(--blue)}
.beat.matlab .beat-v{font-size:13.5px;color:var(--text)}
/* beat 4 - galat kab hoga: the falsifier. Set apart deliberately. */
.beat.galat{margin:6px 8px 8px;padding:9px 11px;border-radius:var(--r);
  grid-template-columns:96px minmax(0,1fr);
  background:var(--amber-w);border:1px dashed rgba(255,180,84,.42)}
.beat.galat + .beat{border-top:0}
.beat.galat .beat-k{color:var(--amber)}
.beat.galat .beat-k::before{background:var(--amber);border-radius:50%}
.beat.galat .beat-v{color:#f3e2c6}

/* stacked variant for narrow columns */
.cmt.stacked .beat,.beat.stack{grid-template-columns:minmax(0,1fr);gap:2px}
.cmt.stacked .beat-k{padding-top:0}

/* level colouring of the card rail + header tint */
.cmt.lvl-high{border-left-color:var(--red)}
.cmt.lvl-high .cmt-hd{background:linear-gradient(90deg,var(--red-w),var(--panel2) 62%)}
.cmt.lvl-med{border-left-color:var(--amber)}
.cmt.lvl-med .cmt-hd{background:linear-gradient(90deg,var(--amber-w),var(--panel2) 62%)}
.cmt.lvl-low{border-left-color:var(--blue)}
.cmt.lvl-low .cmt-hd{background:linear-gradient(90deg,var(--blue-w),var(--panel2) 62%)}
.cmt.lvl-info{border-left-color:var(--faint)}


/* ---------------------------------------------------------------------------
   10. PRIORITY / LEVEL COLOUR CODING (shared by chips, dots, list rows)
   ------------------------------------------------------------------------ */
.lvl-dot{width:7px;height:7px;border-radius:50%;flex:none;background:var(--faint)}
.lvl-high .lvl-dot,.lvl-dot.lvl-high{background:var(--red)}
.lvl-med  .lvl-dot,.lvl-dot.lvl-med{background:var(--amber)}
.lvl-low  .lvl-dot,.lvl-dot.lvl-low{background:var(--blue)}
.lvl-info .lvl-dot,.lvl-dot.lvl-info{background:var(--faint)}

.chip.lvl-high{color:var(--red);border-color:rgba(255,93,108,.4);background:var(--red-w)}
.chip.lvl-med{color:var(--amber);border-color:rgba(255,180,84,.4);background:var(--amber-w)}
.chip.lvl-low{color:var(--blue);border-color:rgba(74,168,255,.4);background:var(--blue-w)}
.chip.lvl-info{color:var(--dim);border-color:var(--line2);background:var(--panel3)}


/* ---------------------------------------------------------------------------
   11. TAG CHIPS
   ------------------------------------------------------------------------ */
.chips{display:flex;flex-wrap:wrap;gap:5px;align-items:center}
.chip{display:inline-flex;align-items:center;gap:5px;padding:2px 8px;border-radius:999px;
  border:1px solid var(--line2);background:var(--panel2);color:var(--dim);
  font-size:10.5px;font-weight:600;letter-spacing:.05em;
  text-transform:uppercase;white-space:nowrap}
.chip.green{color:var(--green);border-color:rgba(63,214,140,.4);background:var(--green-w)}
.chip.red{color:var(--red);border-color:rgba(255,93,108,.4);background:var(--red-w)}
.chip.amber{color:var(--amber);border-color:rgba(255,180,84,.4);background:var(--amber-w)}
.chip.blue{color:var(--blue);border-color:rgba(74,168,255,.4);background:var(--blue-w)}
.chip.purple{color:var(--purple);border-color:rgba(180,143,245,.4);background:var(--purple-w)}
.chip.cyan{color:var(--cyan);border-color:rgba(63,214,214,.4);background:var(--cyan-w)}
.chip.dim{color:var(--faint)}
.chip.solid{background:var(--panel3);border-color:transparent}
.chip.sq{border-radius:var(--r-s);text-transform:none;letter-spacing:.01em;font-size:11px}
button.chip{cursor:pointer;transition:border-color var(--t),color var(--t)}
button.chip:hover{color:var(--text);border-color:var(--dim)}
button.chip[aria-pressed="true"]{background:var(--panel3);color:var(--text);border-color:var(--cyan)}


/* ---------------------------------------------------------------------------
   12. CONTROLS - buttons, segmented, select, input, toggle switch
   ------------------------------------------------------------------------ */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;
  padding:6px 12px;border-radius:var(--r);cursor:pointer;
  background:var(--panel2);border:1px solid var(--line2);color:var(--text);
  font-size:12px;font-weight:600;white-space:nowrap;
  transition:background var(--t),border-color var(--t),color var(--t)}
.btn:hover{background:var(--panel3);border-color:var(--dim)}
.btn:active{transform:translateY(1px)}
.btn.primary{background:rgba(74,168,255,.16);border-color:rgba(74,168,255,.5);color:var(--blue)}
.btn.primary:hover{background:rgba(74,168,255,.24)}
.btn.ghost{background:transparent;border-color:transparent;color:var(--dim)}
.btn.ghost:hover{background:var(--panel2);color:var(--text)}
.btn.sm{padding:3px 8px;font-size:11px}
.btn[disabled],.btn[aria-disabled="true"]{opacity:.42;cursor:not-allowed;transform:none}

/* segmented control (e.g. NIFTY | BANKNIFTY, or 1m | 5m | day) */
.seg{display:inline-flex;border-radius:var(--r);overflow:hidden;
  background:var(--panel2);border:1px solid var(--line2)}
.seg-b{padding:5px 11px;border:0;background:transparent;color:var(--dim);
  font-size:11.5px;font-weight:600;cursor:pointer;white-space:nowrap;
  transition:background var(--t),color var(--t)}
.seg-b + .seg-b{border-left:1px solid var(--line)}
.seg-b:hover{color:var(--text);background:var(--panel3)}
.seg-b.active,.seg-b[aria-selected="true"]{background:var(--panel3);color:var(--cyan)}

/* select - custom caret drawn with an inline data-URI-free gradient trick:
   two rotated background gradients form the chevron, so no image request. */
.sel{
  appearance:none;-webkit-appearance:none;-moz-appearance:none;
  padding:5px 26px 5px 9px;border-radius:var(--r);cursor:pointer;
  background-color:var(--panel2);border:1px solid var(--line2);color:var(--text);
  font-family:var(--mono);font-size:12px;line-height:1.4;
  background-image:
    linear-gradient(45deg,transparent 50%,var(--dim) 50%),
    linear-gradient(135deg,var(--dim) 50%,transparent 50%);
  background-position:calc(100% - 14px) 52%,calc(100% - 9px) 52%;
  background-size:5px 5px,5px 5px;
  background-repeat:no-repeat;
}
.sel:hover{border-color:var(--dim)}
.sel option{background:var(--panel2);color:var(--text)}
.sel[disabled]{opacity:.45;cursor:not-allowed}

.inp{padding:5px 9px;border-radius:var(--r);font-family:var(--mono);font-size:12px;
  background:var(--sunken);border:1px solid var(--line2);color:var(--text)}
.inp:hover{border-color:var(--dim)}
.inp::placeholder{color:var(--faint)}

/* Toggle switch. Required markup (order matters for the sibling selectors):
   <label class="sw-wrap">
     <input type="checkbox" class="sw">
     <span class="sw-track"><span class="sw-thumb"></span></span>
     <span class="sw-lbl">Label</span>
   </label>
   The real checkbox stays in the a11y tree and keeps keyboard behaviour; it
   is only visually hidden, hence opacity:0 rather than display:none. */
.sw-wrap{
  position:relative;                 /* anchor for the absolutely placed input */
  display:inline-flex;align-items:center;gap:8px;cursor:pointer;user-select:none;
}
.sw-wrap .sw-lbl{font-size:11.5px;color:var(--dim);transition:color var(--t)}
.sw{
  position:absolute;left:0;top:50%;transform:translateY(-50%);
  opacity:0;width:34px;height:18px;margin:0;cursor:pointer;
}
.sw-track{position:relative;display:inline-block;width:34px;height:18px;flex:none;
  border-radius:999px;background:var(--panel3);border:1px solid var(--line2);
  transition:background var(--t),border-color var(--t)}
.sw-thumb{position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;
  background:var(--faint);transition:transform var(--t),background var(--t)}
.sw:checked + .sw-track{background:rgba(74,168,255,.28);border-color:rgba(74,168,255,.6)}
.sw:checked + .sw-track .sw-thumb{transform:translateX(16px);background:var(--blue)}
.sw:focus-visible + .sw-track{outline:2px solid var(--focus);outline-offset:2px}
.sw[disabled] + .sw-track{opacity:.42}
.sw:checked + .sw-track + .sw-lbl,.sw-wrap:hover .sw-lbl{color:var(--text)}


/* ---------------------------------------------------------------------------
   13. CONNECTION STATUS PILL
   ------------------------------------------------------------------------ */
.conn{display:inline-flex;align-items:center;gap:6px;padding:3px 10px;border-radius:999px;
  background:var(--panel2);border:1px solid var(--line2);
  font-family:var(--mono);font-size:11px;color:var(--dim);white-space:nowrap}
.conn-dot{width:7px;height:7px;border-radius:50%;background:var(--faint);flex:none}
.conn.ok{color:var(--green);border-color:rgba(63,214,140,.38);background:var(--green-w)}
.conn.ok .conn-dot{background:var(--green);animation:pulse 2.4s ease-in-out infinite}
.conn.warn{color:var(--amber);border-color:rgba(255,180,84,.38);background:var(--amber-w)}
.conn.warn .conn-dot{background:var(--amber)}
.conn.err{color:var(--red);border-color:rgba(255,93,108,.38);background:var(--red-w)}
.conn.err .conn-dot{background:var(--red)}
.conn.idle{color:var(--faint)}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.35}}

/* "data is older than it should be" marker for any timestamped value */
.stale{color:var(--amber)}
.stale::after{content:" \00b7 stale";font-size:10px;letter-spacing:.04em;color:var(--amber)}


/* ---------------------------------------------------------------------------
   14. CHART PANELS + inline SVG element classes
   All charts are hand-rolled SVG strings; these classes are applied inside
   the generated markup so the JS never has to inline colour literals.
   ------------------------------------------------------------------------ */
.chart{background:var(--panel);border:1px solid var(--line);border-radius:var(--r-l);
  margin-bottom:var(--gap);overflow:hidden}
.chart-hd{display:flex;align-items:center;gap:10px;flex-wrap:wrap;
  padding:8px var(--pad);border-bottom:1px solid var(--line);background:var(--panel2)}
.chart-hd .ti{font-size:12.5px;font-weight:700}
.chart-hd .sub{font-size:11px;color:var(--dim);font-family:var(--mono)}
.chart-hd .spacer{margin-left:auto}
/* the SVG can be wider than the panel - it scrolls here, never on <body> */
.chart-bd{padding:10px var(--pad) 12px;overflow-x:auto;overflow-y:hidden;background:var(--panel)}
/* max-width:none overrides the global `img,svg{max-width:100%}` reset. Without
   it a wide chart (a 40-strike OI profile needs ~1400px) gets clamped to the
   panel width and squashed instead of scrolling, so overflow-x:auto and
   min-width:100% here would never actually engage. */
.chart-bd svg{display:block;min-width:100%;max-width:none}
.chart-note{padding:7px var(--pad) 10px;border-top:1px solid var(--line);
  font-size:11.5px;color:var(--dim);line-height:1.5}
.chart-legend{display:flex;flex-wrap:wrap;gap:12px;padding:0 var(--pad) 10px}
.lg{display:inline-flex;align-items:center;gap:5px;font-size:11px;color:var(--dim)}
.lg-sw{width:10px;height:10px;border-radius:2px;background:var(--blue);flex:none}
.lg-sw.ce{background:var(--red)} .lg-sw.pe{background:var(--green)}
.lg-sw.amber{background:var(--amber)} .lg-sw.cyan{background:var(--cyan)}
.lg-sw.purple{background:var(--purple)}
.lg-sw.line{height:2px;border-radius:1px}

svg text{font-family:var(--mono);font-variant-numeric:tabular-nums}
svg .ax{stroke:var(--line2);stroke-width:1}
svg .gl{stroke:var(--line);stroke-width:1;stroke-dasharray:2 4}
svg .axl{fill:var(--faint);font-size:9.5px}
svg .lbl{fill:var(--dim);font-size:10px}
svg .lbl-hi{fill:var(--text);font-size:10.5px;font-weight:600}
svg .ser-ce{fill:var(--red)} svg .ser-pe{fill:var(--green)}
svg .ser-blue{fill:var(--blue)} svg .ser-cyan{fill:var(--cyan)}
svg .ser-purple{fill:var(--purple)} svg .ser-amber{fill:var(--amber)}
svg .ln{fill:none;stroke-width:1.6;stroke-linejoin:round;stroke-linecap:round}
svg .ln-cyan{stroke:var(--cyan)} svg .ln-blue{stroke:var(--blue)}
svg .ln-amber{stroke:var(--amber)} svg .ln-purple{stroke:var(--purple)}
svg .mark{stroke:var(--cyan);stroke-width:1;stroke-dasharray:3 3;fill:none}
svg .mark-spot{stroke:var(--text);stroke-width:1.2;stroke-dasharray:4 3}
svg .zero{stroke:var(--faint);stroke-width:1}
svg .hitbox{fill:transparent;cursor:crosshair}


/* ---------------------------------------------------------------------------
   15. ACADEMY - long-form teaching layout, comfortable measure for prose
   ------------------------------------------------------------------------ */
.academy{display:grid;grid-template-columns:210px minmax(0,1fr);gap:22px;align-items:start}
.toc{position:sticky;top:calc(var(--hdr-h) + 14px);padding:10px;
  background:var(--panel);border:1px solid var(--line);border-radius:var(--r-l);
  max-height:calc(100vh - var(--hdr-h) - 40px);overflow:auto}
.toc .eyebrow{margin:2px 4px 7px}
.toc-a{display:block;padding:5px 8px;border-radius:var(--r-s);
  font-size:12px;color:var(--dim);text-decoration:none}
.toc-a:hover{background:var(--panel2);color:var(--text);text-decoration:none}
.toc-a.active{background:var(--panel3);color:var(--cyan);font-weight:600}
.toc-a.sub{padding-left:18px;font-size:11.5px;color:var(--faint)}

/* 68ch is the comfortable reading measure for the teaching copy */
.prose{max-width:68ch;font-size:14.5px;line-height:1.72;color:#cfd9e8}
.prose > * + *{margin-top:.95em}
.prose h2{font-size:19px;font-weight:700;line-height:1.3;color:var(--text);
  margin-top:1.7em;padding-bottom:6px;border-bottom:1px solid var(--line)}
.prose h3{font-size:15.5px;font-weight:700;color:var(--cyan);margin-top:1.5em}
.prose h4{font-size:13.5px;font-weight:700;color:var(--dim);
  letter-spacing:.05em;text-transform:uppercase;margin-top:1.4em}
.prose p{margin:0}
.prose strong,.prose b{color:#fff;font-weight:600}
.prose em{color:var(--amber);font-style:normal}
.prose ul,.prose ol{padding-left:1.25em}
.prose li + li{margin-top:.35em}
.prose li::marker{color:var(--faint)}
.prose code{font-family:var(--mono);font-size:12.5px;padding:1px 5px;color:var(--cyan);
  background:var(--sunken);border:1px solid var(--line);border-radius:var(--r-s)}
.prose pre{font-family:var(--mono);font-size:12.5px;line-height:1.65;color:var(--cyan);
  background:var(--sunken);border:1px solid var(--line);border-radius:var(--r);
  padding:11px 13px;overflow-x:auto}
.prose pre code{background:none;border:0;padding:0}
.prose blockquote{border-left:2px solid var(--line2);padding:2px 0 2px 13px;color:var(--dim)}
.prose .lead{font-size:15.5px;color:var(--text)}
.prose figure{margin:1.2em 0}
.prose figcaption{font-size:11.5px;color:var(--faint);margin-top:6px}

/* callouts inside teaching copy */
.callout{border:1px solid var(--line2);border-left:3px solid var(--blue);
  background:var(--panel);border-radius:var(--r);padding:10px 13px;
  font-size:13.5px;line-height:1.6}
.callout .ct{display:block;margin-bottom:4px;color:var(--blue);
  font-size:var(--fs-xs);font-weight:700;letter-spacing:.08em;text-transform:uppercase}
.callout.warn{border-left-color:var(--amber);background:var(--amber-w)}
.callout.warn .ct{color:var(--amber)}
.callout.good{border-left-color:var(--green);background:var(--green-w)}
.callout.good .ct{color:var(--green)}
.callout.note{border-left-color:var(--purple)}
.callout.note .ct{color:var(--purple)}
.callout.bad{border-left-color:var(--red);background:var(--red-w)}
.callout.bad .ct{color:var(--red)}

/* worked example block */
.ex{background:var(--sunken);border:1px solid var(--line);border-radius:var(--r);
  padding:10px 13px;font-family:var(--mono);font-size:12.5px;line-height:1.7;
  color:var(--dim);overflow-x:auto}
.ex b{color:var(--text)}

/* key/value definition rows */
.kv{display:grid;grid-template-columns:150px minmax(0,1fr);gap:5px 12px;font-size:13px}
.kv-k{color:var(--faint);font-size:11.5px;font-weight:600;letter-spacing:.04em;padding-top:2px}
.kv-v{color:var(--text);min-width:0}


/* ---------------------------------------------------------------------------
   16. GLOSSARY + RULEBOOK tables
   ------------------------------------------------------------------------ */
.gloss{width:100%;border-collapse:separate;border-spacing:0;font-size:13px}
/* The glossary is long enough to be read scrolled, and unlike .tbl it is often
   dropped straight into a .panel-bd with no scroll wrapper. In that case the
   sticky header's containing scroller is the viewport, so top:0 would park it
   underneath the fixed app header. Default to clearing the header, and reset to
   0 when it IS inside a .tbl-wrap, where the wrapper is the scroller. */
.gloss thead th{position:sticky;top:calc(var(--hdr-h) + 4px);z-index:2;
  background:var(--panel2);color:var(--dim);
  font-size:10.5px;font-weight:600;letter-spacing:.07em;text-transform:uppercase;
  text-align:left;padding:7px 10px;box-shadow:inset 0 -1px 0 var(--line)}
.tbl-wrap .gloss thead th{top:0}
.gloss td{padding:9px 10px;border-bottom:1px solid var(--line);vertical-align:top}
.gloss tbody tr:nth-child(odd) td{background:var(--zebra)}
.gloss tbody tr:hover td{background:var(--hover)}
.gloss .term{width:150px;font-family:var(--mono);font-weight:700;
  color:var(--cyan);white-space:nowrap}
.gloss .hin{color:var(--text);line-height:1.6}
.gloss .why{color:var(--dim);font-size:12.5px;line-height:1.55}

.rulebook{display:flex;flex-direction:column;gap:9px}
.rb{background:var(--panel);border:1px solid var(--line);border-radius:var(--r);
  border-left:3px solid var(--purple);padding:10px 13px}
.rb-ti{font-size:13px;font-weight:700;margin-bottom:6px}
.rb-grid{display:grid;grid-template-columns:78px minmax(0,1fr);gap:4px 11px;font-size:13px}
.rb-k{padding-top:3px;font-size:var(--fs-xs);font-weight:700;
  letter-spacing:.08em;text-transform:uppercase}
.rb-when .rb-k{color:var(--cyan)}
.rb-then .rb-k{color:var(--blue)}
.rb-fail .rb-k{color:var(--amber)}
.rb-fail{margin-top:5px;padding:7px 9px;border-radius:var(--r-s);
  background:var(--amber-w);border:1px dashed rgba(255,180,84,.4)}
.rb-v{line-height:1.55;min-width:0}
.rb-fail .rb-v{color:#f3e2c6}

/* assumption banner - REQUIRED wherever gex_signed or any who-is-short
   inference is displayed. Never render signed gamma without one of these. */
.assume{display:flex;align-items:flex-start;gap:8px;
  padding:8px 11px;border-radius:var(--r);margin-bottom:10px;
  background:var(--purple-w);border:1px solid rgba(180,143,245,.35);
  font-size:12px;line-height:1.55;color:#ddd0f6}
.assume::before{content:"ASSUMPTION";flex:none;padding:1px 5px;margin-top:1px;
  font-family:var(--mono);font-size:9.5px;font-weight:700;letter-spacing:.1em;
  color:var(--purple);border:1px solid rgba(180,143,245,.5);border-radius:var(--r-s)}


/* ---------------------------------------------------------------------------
   17. SKELETON LOADING STATES
   ------------------------------------------------------------------------ */
/* background-size MUST come after the background shorthand - the shorthand
   resets it to auto and the shimmer would not travel. */
.sk{border-radius:var(--r-s);
  background:linear-gradient(90deg,var(--panel2) 25%,var(--panel3) 37%,var(--panel2) 63%);
  background-size:400% 100%;
  animation:shimmer 1.5s linear infinite}
@keyframes shimmer{0%{background-position:100% 0}100%{background-position:0 0}}
.sk-line{height:10px;margin:6px 0}
.sk-line.w40{width:40%} .sk-line.w60{width:60%} .sk-line.w80{width:80%}
.sk-tile{height:58px;border-radius:var(--r)}
.sk-row{height:22px;margin:4px 0}
.sk-chart{height:220px;border-radius:var(--r)}
.sk-txt{color:transparent !important;user-select:none}


/* ---------------------------------------------------------------------------
   18. EMPTY / ERROR STATES
   ------------------------------------------------------------------------ */
.empty{display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:5px;padding:34px 20px;text-align:center;
  border:1px dashed var(--line2);border-radius:var(--r);background:var(--panel)}
.empty-t{font-size:13.5px;font-weight:600;color:var(--dim)}
.empty-s{font-size:12px;color:var(--faint);max-width:48ch;line-height:1.55}
.empty.err{border-color:rgba(255,93,108,.4);background:var(--red-w)}
.empty.err .empty-t{color:var(--red)}
.empty.sm{padding:16px 12px}
.empty .btn{margin-top:6px}
/* inline "no baseline yet" placeholder for a single value - never show 0 */
.nodata{color:var(--faint);font-style:normal;font-family:var(--sans);font-size:11.5px}


/* ---------------------------------------------------------------------------
   19. TOOLTIPS
   Pure CSS, driven by [data-tip]. Shows on hover AND on keyboard focus.
   NOTE: a tooltip inside a scroll container (.tbl-wrap, .chart-bd) will be
   clipped - for those, put the .tip on a header cell or use .tip-b.
   ------------------------------------------------------------------------ */
.tip{position:relative;cursor:help;border-bottom:1px dotted var(--faint)}
.tip[data-tip]::after{
  content:attr(data-tip);
  position:absolute;left:50%;bottom:calc(100% + 8px);transform:translateX(-50%);
  z-index:80;width:max-content;max-width:280px;
  padding:7px 9px;border-radius:var(--r);
  background:#0d141f;border:1px solid var(--line2);box-shadow:var(--shadow);
  color:var(--text);font-family:var(--sans);font-size:11.5px;font-weight:400;
  line-height:1.5;letter-spacing:0;text-transform:none;text-align:left;
  white-space:normal;
  opacity:0;visibility:hidden;pointer-events:none;transition:opacity var(--t);
}
.tip[data-tip]::before{content:"";position:absolute;left:50%;bottom:calc(100% + 3px);
  transform:translateX(-50%) rotate(45deg);width:7px;height:7px;background:#0d141f;
  border-right:1px solid var(--line2);border-bottom:1px solid var(--line2);
  z-index:81;opacity:0;visibility:hidden;transition:opacity var(--t)}
.tip[data-tip]:hover::after,.tip[data-tip]:hover::before,
.tip[data-tip]:focus-visible::after,.tip[data-tip]:focus-visible::before{opacity:1;visibility:visible}
/* below-anchored variant, for tips near the top of the viewport */
.tip.tip-b[data-tip]::after{bottom:auto;top:calc(100% + 8px)}
.tip.tip-b[data-tip]::before{bottom:auto;top:calc(100% + 3px);
  border:0;border-left:1px solid var(--line2);border-top:1px solid var(--line2)}
.tip.tip-l[data-tip]::after{left:0;transform:none}
.tip.tip-r[data-tip]::after{left:auto;right:0;transform:none}
/* small "i" affordance next to a label; border-bottom-style resets the
   dotted underline .tip would otherwise give it */
.tip-i{display:inline-flex;align-items:center;justify-content:center;
  width:12px;height:12px;border-radius:50%;border:1px solid var(--faint);
  color:var(--faint);font-family:var(--mono);font-size:9px;font-weight:700;
  line-height:1;border-bottom-style:solid}
.tip-i:hover{color:var(--text);border-color:var(--dim)}


/* ---------------------------------------------------------------------------
   20. SCROLLBARS (webkit + firefox)
   ------------------------------------------------------------------------ */
*{scrollbar-width:thin;scrollbar-color:#2c3a50 transparent}
::-webkit-scrollbar{width:9px;height:9px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:#2c3a50;border-radius:5px;border:2px solid var(--bg)}
::-webkit-scrollbar-thumb:hover{background:#3b4d68}
::-webkit-scrollbar-corner{background:transparent}


/* ---------------------------------------------------------------------------
   21. RESPONSIVE
   Step 1 at 1100px: narrow the rail to a compact strip, drop dense grids.
   Step 2 at 860px (tablet): rail becomes a horizontal scrolling tab strip
   pinned under the header, everything goes single column.
   ------------------------------------------------------------------------ */
@media (max-width:1400px){
  .g4{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media (max-width:1100px){
  :root{--rail-w:150px;--pad:12px;--gap:10px}
  .rail-tab .rt-d{display:none}          /* keep the label, drop the blurb */
  .rail-tab{padding:8px 9px}
  .g3,.g-2-1,.g-1-2{grid-template-columns:minmax(0,1fr)}
  .g2{grid-template-columns:minmax(0,1fr)}
  .tiles{grid-template-columns:repeat(auto-fit,minmax(126px,1fr))}
  .tile .v{font-size:17px}
  .academy{grid-template-columns:180px minmax(0,1fr);gap:16px}
  .hdr-meta{gap:11px;font-size:11px}
  .beat{grid-template-columns:84px minmax(0,1fr)}
  .beat.galat{grid-template-columns:84px minmax(0,1fr)}
}
@media (max-width:860px){
  :root{--hdr-h:48px}
  .hdr{gap:10px;padding:0 10px}
  .hdr-brand{font-size:11px;letter-spacing:.1em}
  .hdr-brand span{display:none}
  .hdr-meta{display:none}              /* moves into the overview tiles */

  /* rail -> horizontal strip under the fixed header */
  .rail{
    top:var(--hdr-h);bottom:auto;width:100%;height:42px;
    display:flex;align-items:center;gap:6px;
    padding:0 10px;overflow-x:auto;overflow-y:hidden;
    border-right:0;border-bottom:1px solid var(--line);
    scrollbar-width:none;
  }
  .rail::-webkit-scrollbar{display:none}
  .rail-sec{display:none}
  .rail-tab{width:auto;flex:none;margin:0;padding:5px 10px;border-radius:999px}
  .rail-tab.active{box-shadow:inset 0 0 0 1px var(--cyan)}
  .rail-tab .rt-d{display:none}

  .main{padding:calc(var(--hdr-h) + 42px + 12px) 10px 48px 10px}
  /* .g4 steps 4 -> 2 at 1400px; without this it would still be 2 columns on a
     360px phone, which is unreadable for anything but a bare number. */
  .g4{grid-template-columns:minmax(0,1fr)}
  .tiles{grid-template-columns:repeat(auto-fit,minmax(112px,1fr));gap:8px}
  .tile .v{font-size:16px}
  .academy{grid-template-columns:minmax(0,1fr)}
  .toc{position:static;max-height:none;margin-bottom:12px}
  .prose{max-width:none;font-size:14px}
  .kv{grid-template-columns:minmax(0,1fr);gap:2px}
  .kv-k{padding-top:6px}
  /* four beats stack on small screens - label above text */
  .beat,.beat.galat{grid-template-columns:minmax(0,1fr);gap:3px}
  .beat-k{padding-top:0}
  .tbl-wrap{max-height:60vh}
  .tbl td{padding:5px 6px;font-size:11.5px}
  .rb-grid{grid-template-columns:minmax(0,1fr);gap:2px 0}
  .rb-k{padding-top:5px}
  /* the rail is now a 42px strip below the header, so an unwrapped sticky
     glossary header has to clear both */
  .gloss thead th{top:calc(var(--hdr-h) + 42px)}
  .tbl-wrap .gloss thead th{top:0}
  .tip[data-tip]::after{max-width:min(72vw,260px)}
}
@media (max-width:560px){
  .tiles{grid-template-columns:repeat(2,minmax(0,1fr))}
  .tile.wide{grid-column:span 2}
  .panel-hd{gap:6px;padding:8px 10px}
  .hdr-sym{font-size:15px}
}


/* ---------------------------------------------------------------------------
   22. REDUCED MOTION
   The dashboard refreshes on a timer; a user who asks for reduced motion gets
   no shimmer, no pulse, no view transition - values still update, silently.
   ------------------------------------------------------------------------ */
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{
    animation-duration:.001ms !important;animation-iteration-count:1 !important;
    transition-duration:.001ms !important;scroll-behavior:auto !important;
  }
  .sk{animation:none !important;background:var(--panel2)}
  .conn.ok .conn-dot{animation:none !important;opacity:1}
  .view.active{animation:none !important}
  .btn:active{transform:none}
}

/* Higher-contrast preference: strengthen every hairline and lift the two
   muted text tokens. This is the ONE place the contract tokens are allowed to
   move, and only behind an explicit OS accessibility preference - the default
   values above stay byte-identical to the delta-neutral desk. */
@media (prefers-contrast:more){
  :root{--line:#2c3a50;--line2:#3f5170;--dim:#9dabc0;--faint:#7386a0}
}


/* ---------------------------------------------------------------------------
   23. PRINT - the academy pages are worth printing; the live grid is not.
   ------------------------------------------------------------------------ */
@media print{
  .hdr,.rail,.hdr-tools,.btn,.seg,.sw-wrap{display:none !important}
  .main{padding:0}
  body{background:#fff;color:#111}
  .panel,.cmt,.chart{border-color:#ccc;background:#fff;break-inside:avoid}
  .panel-hd,.cmt-hd{background:#f2f2f2;color:#111}
  .prose{max-width:none;color:#111}
  .beat.galat{background:#fff8ec;border-color:#c99}
  .tbl-wrap{max-height:none;overflow:visible}
  /* Dark-theme ink is invisible on white. The commentary cards and the rulebook
     are the pages actually worth printing, so their text has to be forced back
     to a readable colour - including the pale tints used for .galat / .rb-fail
     / .assume, which would otherwise print as near-white on white. */
  .beat-v,.beat.matlab .beat-v,.beat.galat .beat-v,.rb-v,.rb-fail .rb-v,
  .assume,.kv-v,.gloss .hin,.callout,.empty-t,.tbl td,.tbl th,
  .prose strong,.prose b,.beat-v b,.beat-v strong{color:#111}
  .beat.rule .beat-v,.gloss .why,.chart-note,.panel-ft,.empty-s,
  .prose blockquote,.cmt-meta{color:#444}
  .prose em,.beat.galat .beat-k{color:#8a5a00}
  .prose code,.prose pre,.ex{background:#f6f6f6;border-color:#ddd;color:#111}
  .assume,.rb-fail{background:#f6f2fc;border-color:#bbb}
  .beat + .beat{border-top-color:#ddd}
  /* keep a card and its four beats on one page - a truncated falsification
     beat is worse than no printout */
  .cmt,.rb,.callout,.tbl tr{break-inside:avoid}
  a{color:#111;text-decoration:underline}
}
