/*
 * Zanshin -- chrome modelled on Sierra Chart: flat grey control bar, black
 * chart windows with thin title bars, chartbook tabs along the bottom, small
 * type everywhere and monospace for anything that lines up in a column.
 *
 * Colour jobs (validated for CVD on #000, see README):
 *   --pos   long gamma / bullish / call wall
 *   --neg   short gamma / bearish / put wall
 *   --flip  the zero-gamma level, the one line that changes the regime
 * Everything else is neutral ink and carries a text label.
 */
:root {
  --bg: #000;
  --chrome: #262626;
  --chrome-hi: #333;
  --chrome-lo: #161616;
  --title: #1b1b1b;
  --title-act: #203048;
  --rule: #2e2e2e;
  --grid: #161616;
  --ink: #d6d6d6;
  --ink-2: #9a9a9a;
  --ink-3: #616161;
  --pos: #a77bff;
  --neg: #d4d4dc;
  --flip: #8a8a94;
  --pos-dim: #33245a;
  --neg-dim: #3a3a40;
  --warn: #d9a400;
  --row-hi: #101a26;
  --sans: Tahoma, Verdana, "Segoe UI", sans-serif;
  --mono: Consolas, Menlo, "DejaVu Sans Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: var(--fs, 11px)/1.35 var(--sans); overflow: hidden; }
.num, td.n, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
button { font: inherit; color: inherit; }

/* ---- control bar -------------------------------------------------------- */
#bar { height: 26px; display: flex; align-items: stretch; gap: 0; background: var(--chrome); white-space: nowrap; overflow: hidden;
  border-bottom: 1px solid #000; box-shadow: inset 0 -1px 0 var(--chrome-hi); padding: 0 4px; }
#bar .grp { flex: none; display: flex; align-items: center; gap: 2px; padding: 0 6px;
  border-right: 1px solid var(--chrome-lo); box-shadow: 1px 0 0 var(--chrome-hi); }
#bar .grp:last-child { border-right: 0; box-shadow: none; }
#bar .lbl { color: var(--ink-3); margin-right: 3px; }
.btn { height: 18px; min-width: 18px; padding: 0 6px; background: var(--chrome-hi);
  border: 1px solid; border-color: #4a4a4a #111 #111 #4a4a4a; cursor: pointer; line-height: 16px; }
.btn:active, .btn.on { border-color: #111 #4a4a4a #4a4a4a #111; background: #1d1d1d; color: #fff; }
.btn.on { box-shadow: inset 0 0 0 1px var(--flip); }
#bar .spacer { flex: 1; }
#bar .val { font-family: var(--mono); color: var(--ink); }

/* ---- workspace ---------------------------------------------------------- */
#ws { position: absolute; top: 26px; bottom: 40px; left: 0; right: 0; padding: 2px;
  display: grid; gap: 2px; background: #0a0a0a; overflow: auto; }
.win { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--bg); border: 1px solid var(--rule); }
.win.max { position: fixed !important; top: 28px !important; left: 2px !important; width: auto !important; height: auto !important; bottom: 42px; right: 2px; z-index: 900 !important; }
.win > .tb { cursor: default; user-select: none; flex: none; height: 16px; display: flex; align-items: center; gap: 8px; padding: 0 4px;
  background: var(--title); border-bottom: 1px solid var(--rule); color: var(--ink-2); white-space: nowrap; overflow: hidden; }
.win:hover > .tb { background: var(--title-act); color: var(--ink); }
.win > .tb .no { color: var(--ink-3); }
.win > .tb .sub { color: var(--ink-3); margin-left: auto; overflow: hidden; text-overflow: ellipsis; }
.win > .body { position: relative; flex: 1; min-height: 0; overflow: auto; }
.win > .body.fill { overflow: hidden; }
.win canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.body::-webkit-scrollbar { width: 10px; height: 10px; }
.body::-webkit-scrollbar-track { background: #0c0c0c; }
.body::-webkit-scrollbar-thumb { background: #2c2c2c; border: 1px solid #0c0c0c; }

/* ---- chartbook tabs + status ------------------------------------------- */
#tabs { position: absolute; left: 0; right: 0; bottom: 20px; height: 20px; display: flex; gap: 1px; white-space: nowrap; overflow: hidden;
  background: var(--chrome); border-top: 1px solid #000; padding: 0 4px; }
#tabs .tab { padding: 0 12px; line-height: 18px; margin-top: 1px; color: var(--ink-2); cursor: pointer;
  background: var(--chrome-lo); border: 1px solid #000; border-top: 0; }
#tabs .tab.on { background: #000; color: #fff; }
#tabs .tab .k { color: var(--ink-3); margin-left: 6px; font-family: var(--mono); }
#status { position: absolute; left: 0; right: 0; bottom: 0; height: 20px; display: flex; align-items: center;
  background: var(--chrome); border-top: 1px solid var(--chrome-lo); padding: 0 6px; gap: 14px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; }
#status > span { flex: none; }
#status .ok::before, #status .bad::before, #status .stale::before { content: "■ "; }
#status .ok::before { color: var(--pos); }
#status .bad::before { color: var(--neg); }
#status .stale::before { color: var(--warn); }
#status .right { margin-left: auto; }

/* ---- tables ------------------------------------------------------------- */
table.t { width: 100%; border-collapse: collapse; }
table.t th { position: sticky; top: 0; z-index: 1; background: #111; color: var(--ink-3); font-weight: normal;
  text-align: right; padding: 1px 5px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
table.t th.l, table.t td.l { text-align: left; }
table.t td { padding: 0 5px; height: 15px; text-align: right; white-space: nowrap; border-bottom: 1px solid #0d0d0d; }
table.t tr:hover td { background: #0f0f0f; }
table.t td.n { font-size: var(--fs, 11px); }
table.t .dim { color: var(--ink-3); }
table.t .mid { color: var(--ink-2); }
tr.spot td { background: var(--row-hi) !important; }
tr.spot td.k { color: #fff; }
tr.flipline td { border-bottom: 1px solid var(--flip); }
.mk { display: inline-block; width: 7px; height: 7px; margin-right: 4px; vertical-align: 0; }
.mk.pos { background: var(--pos); } .mk.neg { background: var(--neg); } .mk.flip { background: var(--flip); }
.mk.nil { background: #3a3a3a; }
.tag { display: inline-block; padding: 0 3px; margin-left: 3px; border: 1px solid #3a3a3a; color: var(--ink-2);
  font-family: var(--mono); font-size: 10px; line-height: 12px; }
.tag.pos { border-color: var(--pos); } .tag.neg { border-color: var(--neg); } .tag.flip { border-color: var(--flip); }

/* in-cell bars (ladder) */
.bar2 { position: relative; height: 11px; min-width: 120px; }
.bar2 .z { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: #333; }
.bar2 .b { position: absolute; top: 2px; height: 7px; }
.bar2 .b.pos { background: var(--pos); } .bar2 .b.neg { background: var(--neg); }
.bar1 { position: relative; height: 11px; min-width: 60px; }
.bar1 .b { position: absolute; left: 0; top: 2px; height: 7px; background: #4d4d4d; }

/* ---- text regions (Sierra "region data" blocks) -------------------------- */
.rg { padding: 4px 6px; }
.rg .row { display: grid; grid-template-columns: 18px 92px 1fr; gap: 6px; padding: 2px 0; border-bottom: 1px solid #0e0e0e; }
.rg .row .i { color: var(--ink-3); font-family: var(--mono); }
.rg .row .k { color: var(--ink-2); }
.rg .row .v { color: var(--ink); }
.rg .row .v b { font-weight: normal; color: #fff; font-family: var(--mono); }
.rg .row .v .s { color: var(--ink-2); }
.rg h4 { margin: 6px 0 2px; font-weight: normal; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; font-size: 10px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 1px 10px; padding: 4px 6px; }
.kv .k { color: var(--ink-3); } .kv .v { font-family: var(--mono); }
.note { color: var(--ink-3); padding: 4px 6px; }
.warn { color: var(--warn); }
.hdl { color: #fff; }
p.tx { margin: 2px 6px 6px; color: var(--ink-2); max-width: 70ch; }

/* matrices (regime grids from the guide) */
table.mx { border-collapse: collapse; margin: 4px 6px; }
table.mx td, table.mx th { border: 1px solid var(--rule); padding: 2px 6px; text-align: left; vertical-align: top; }
table.mx th { color: var(--ink-3); font-weight: normal; background: #0d0d0d; }
table.mx td.cur { background: var(--row-hi); box-shadow: inset 0 0 0 1px var(--flip); color: #fff; }
table.mx td { color: var(--ink-2); }

/* checklist */
.ck { display: grid; grid-template-columns: 22px 150px 1fr; gap: 6px; padding: 2px 6px; border-bottom: 1px solid #0e0e0e; }
.ck .st { font-family: var(--mono); }
.ck .st.y { color: var(--pos); } .ck .st.n { color: var(--neg); } .ck .st.q { color: var(--ink-3); }

/* clock strip */
.clock { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 1px; margin: 4px 6px; }
.clock div { background: #0d0d0d; border: 1px solid var(--rule); padding: 3px 5px; color: var(--ink-2); min-height: 64px; }
.clock div.cur { border-color: var(--flip); color: var(--ink); background: var(--row-hi); }
.clock div .h { font-family: var(--mono); color: var(--ink-3); display: block; }
.clock div.cur .h { color: #fff; }

/* tooltip */
#tip { position: fixed; z-index: 50; pointer-events: none; display: none; background: #0c0c0c; border: 1px solid #555;
  padding: 3px 6px; font: 11px/1.4 var(--mono); color: var(--ink); white-space: pre; max-width: 520px; }

.empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--ink-3); }
.hold { opacity: .55; }

/* ---- Regime page: large type, read at a glance mid-trade ----------------- */
.rgm { padding: 10px 14px; }
.rgm .mode { font: 700 34px/1.1 var(--sans); letter-spacing: .02em; }
.rgm .mode.pos { color: var(--pos); } .rgm .mode.neg { color: var(--neg); } .rgm .mode.flip { color: var(--flip); }
.rgm .why { font-size: 15px; color: var(--ink); margin: 6px 0 10px; max-width: 110ch; }
.rgm .stats { display: flex; flex-wrap: wrap; gap: 6px 26px; font: 15px var(--mono); color: #fff; }
.rgm .stats em { font: 11px var(--sans); font-style: normal; color: var(--ink-3); margin-right: 6px; }
.rgm .stats i { font-style: normal; color: var(--ink-2); }
table.lv td { height: 22px; font-size: 13px; }
table.lv td.big { font-size: 15px; color: #fff; }
table.lv tr.spot td { border-top: 1px solid #f0f0f0; border-bottom: 1px solid #f0f0f0; }
td.wrap, span.wrap { white-space: normal; }
.plan { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--rule); font-size: 12px; }
.plan .btn { height: 22px; line-height: 20px; padding: 0 12px; font-size: 12px; }
.tcs { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--rule); }
.tc { background: var(--bg); padding: 6px 0 8px; }
.tc .tch { font: 700 15px var(--sans); color: #fff; padding: 0 8px 4px; }
.tc .ck { grid-template-columns: 22px 80px 1fr; font-size: 12px; }
.tc .verdict { margin: 8px 8px 0; padding: 6px 8px; font: 700 15px var(--sans); border: 1px solid; }
.verdict.pos { color: var(--pos); border-color: var(--pos); } .verdict.neg { color: var(--neg); border-color: var(--neg); }
.verdict.half { color: #fff; border-color: #777; }
.rule { padding: 8px 10px; font-size: 12px; color: var(--ink); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.rule b { color: #fff; }
#bar .brand { font: 700 12px var(--sans); letter-spacing: .12em; color: #fff; padding: 0 10px 0 4px; display: flex; align-items: center; }
.stalebar { background: var(--neg); color: #000; font: 700 15px var(--sans); padding: 8px 14px; }

/* ---- phones / narrow windows: stack the chartbook vertically ------------- */
@media (max-width: 900px) {
  #ws, #ws.board { display: block !important; overflow-y: auto; }
  #ws > .win, #ws.board > .win { position: relative !important; left: auto !important; top: auto !important; width: auto !important; height: 70vh !important; margin: 0 0 2px; }
  #ws.board > .win .rz { display: none; }
  #ws.board > .win:has(.tile) { height: auto !important; }
  #ws > .win:has(.rgm) { height: auto; }
  #ws > .win.max { height: auto; }
  #bar .grp.keys { display: none; }
  .tcs { grid-template-columns: 1fr; }
  .rgm .mode { font-size: 26px; }
}

/* ---- simple mode: hide the specialist numbers ---------------------------- */
body.simple .adv { display: none !important; }
body.simple table.lad th:nth-child(n+5):nth-child(-n+9), body.simple table.lad td:nth-child(n+5):nth-child(-n+9),
body.simple table.lad th:nth-child(n+13), body.simple table.lad td:nth-child(n+13) { display: none; }
body.simple table.tape th:nth-child(4), body.simple table.tape td:nth-child(4),
body.simple table.tape th:nth-child(7), body.simple table.tape td:nth-child(7),
body.simple table.tape th:nth-child(8), body.simple table.tape td:nth-child(8) { display: none; }
body.simple table.clus th:nth-child(n+7), body.simple table.clus td:nth-child(n+7) { display: none; }

/* ---- customise drawer --------------------------------------------------- */
#tabs .tab.tabedit { margin-left: auto; color: var(--ink); background: var(--chrome-hi); }
#drawer { position: fixed; top: 26px; right: 0; bottom: 40px; width: 380px; max-width: 100vw; z-index: 60; overflow-y: auto;
  background: #0b0b0b; border-left: 1px solid #444; box-shadow: -8px 0 24px rgba(0,0,0,.6); font-size: 12px; }
#drawer .dh { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; background: #0b0b0b; z-index: 1; }
#drawer .dh b { font: 700 13px var(--sans); color: #fff; letter-spacing: .06em; }
#drawer .ds { padding: 8px 10px; border-bottom: 1px solid var(--rule); }
#drawer .dl { color: var(--ink-3); font-size: 10px; letter-spacing: .06em; margin-bottom: 6px; }
#drawer .btn { height: 20px; line-height: 18px; }
#drawer .btn:disabled { opacity: .35; cursor: default; }
#drawer .btn.danger { color: var(--neg); }
#drawer .pages { display: flex; flex-wrap: wrap; gap: 4px; }
#drawer .row2 { display: flex; gap: 6px; margin-top: 6px; }
#drawer input:not([type]), #drawer input[type=text], #drawer select { height: 22px; background: #0d0d0d; color: #fff; border: 1px solid #444; padding: 0 6px; font: 12px var(--mono); }
#drawer .row2 input { flex: 1; }
#drawer .wrow { display: grid; grid-template-columns: 1fr auto auto auto auto auto; gap: 4px; align-items: center; padding: 3px 0; }
#drawer .wrow .wn { color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#drawer .sz { display: inline-flex; align-items: center; gap: 3px; font-family: var(--mono); color: var(--ink-2); }
#drawer .sz .btn { min-width: 18px; padding: 0 4px; }
#drawer .grpn { color: var(--ink-2); margin: 8px 0 4px; font-weight: bold; }
#drawer .add { display: grid; grid-template-columns: 64px 1fr; gap: 8px; align-items: start; padding: 4px 0; }
#drawer .add.used { opacity: .5; }
#drawer .add b { color: #fff; font-weight: normal; }
#drawer .tgl { display: flex; gap: 8px; align-items: center; color: #fff; }
#drawer .dim { color: var(--ink-3); }
body.editing .win { outline: 1px dashed #3a4f6d; outline-offset: -1px; }
.eff { font: 700 11px var(--sans); letter-spacing: .04em; }
.eff.pos { color: var(--pos); } .eff.neg { color: var(--neg); } .eff.flip { color: var(--flip); } .eff.nil { color: var(--ink-3); }
table.lv .bar1 { min-width: 40px; }
table.lv .bar1 .b.pos { background: var(--pos); } table.lv .bar1 .b.neg { background: var(--neg); }

/* ---- free-form board ---------------------------------------------------- */
#ws.board { display: block; }
#ws.board > .win { position: absolute; margin: 1px; }
#ws.board > .empty { position: absolute; }
.win > .tb { cursor: grab; }
.win.dragging { opacity: .85; box-shadow: 0 0 0 1px var(--flip); }
.win.dragging > .tb { cursor: grabbing; }
.win .gear { margin-left: 6px; height: 14px; line-height: 12px; padding: 0 4px; font-size: 11px; background: transparent; color: var(--ink-2);
  border: 1px solid transparent; cursor: pointer; }
.win .gear:hover { border-color: #555; color: #fff; }
.win .rz { position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; cursor: nwse-resize; z-index: 2;
  background: linear-gradient(135deg, transparent 50%, #555 50%, #555 60%, transparent 60%, transparent 72%, #555 72%, #555 82%, transparent 82%); opacity: .5; }
.win:hover .rz { opacity: 1; }

#wset { position: fixed; z-index: 1000; min-width: 240px; background: #0b0b0b; border: 1px solid #555; box-shadow: 0 6px 20px rgba(0,0,0,.6); font-size: 12px; }
#wset .dh { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--rule); }
#wset .dh b { color: #fff; }
#wset .srow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 8px; color: var(--ink-2); }
#wset select { height: 22px; background: #0d0d0d; color: #fff; border: 1px solid #444; font: 12px var(--mono); }
#drawer .tip { color: var(--ink-2); margin-bottom: 8px; line-height: 1.45; }
#drawer .wrow2 { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; }
#drawer .wrow2 .wn { color: #fff; }
#drawer .theme { display: grid; grid-template-columns: 1fr; gap: 6px; }
#drawer .theme label { display: flex; justify-content: space-between; align-items: center; color: var(--ink-2); }
#drawer input[type=color] { width: 44px; height: 22px; padding: 0; border: 1px solid #444; background: #0d0d0d; }

/* ---- home tiles ---------------------------------------------------------- */
.tile { padding: 10px 14px; }
.tile .big { font: 700 calc(var(--fs, 11px) * 2.6)/1.05 var(--sans); letter-spacing: .02em; color: #fff; }
.tile .big.pos { color: var(--pos); } .tile .big.neg { color: var(--neg); } .tile .big.flip { color: var(--flip); } .tile .big.mid { color: #e8e8e8; }
.tile .sub { color: var(--ink); font-size: calc(var(--fs, 11px) * 1.18); margin: 6px 0 10px; line-height: 1.4; }
.tile .why { display: grid; grid-template-columns: 16px minmax(110px, auto) 1fr; gap: 6px; padding: 3px 0; border-top: 1px solid #111; font-size: calc(var(--fs, 11px) * 1.09); }
.tile .why:not(:has(> span:nth-child(3))) { grid-template-columns: minmax(110px, auto) 1fr; }
.tile .why .k { color: var(--ink-2); }
.tile .why .v { color: #fff; font-family: var(--mono); }
.tile .up { color: var(--pos); } .tile .dn { color: var(--neg); }
.tile .gauge { position: relative; height: 10px; margin: 2px 0 2px; border: 1px solid var(--rule);
  background: linear-gradient(90deg, color-mix(in srgb, var(--neg) 35%, #000), #111 50%, color-mix(in srgb, var(--pos) 35%, #000)); }
.tile .gauge .gz { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: #666; }
.tile .gauge .gm { position: absolute; top: -3px; bottom: -3px; width: 6px; background: #fff; }
.tile .gauge .gm.pos { background: var(--pos); } .tile .gauge .gm.neg { background: var(--neg); }
.tile .gl { display: flex; justify-content: space-between; color: var(--ink-3); font-size: 10px; margin-bottom: 8px; }
table.kl td { height: 22px; font-size: calc(var(--fs, 11px) * 1.18); }
.story { display: grid; grid-template-columns: 86px 1fr; gap: 8px; align-items: start; padding: 6px 0; border-top: 1px solid #111; font-size: calc(var(--fs, 11px) * 1.18); line-height: 1.4; color: #fff; }
.story:first-child { border-top: 0; }
.tag2 { display: inline-block; text-align: center; font: 700 10px var(--sans); letter-spacing: .05em; padding: 2px 0; border: 1px solid #555; color: var(--ink); }
.tag2.pos { border-color: var(--pos); color: var(--pos); } .tag2.neg { border-color: var(--neg); color: var(--neg); }
.tag2.flip { border-color: var(--flip); color: var(--flip); } .tag2.mid { border-color: #777; color: #ddd; }

/* ---- Guide ---------------------------------------------------------------- */
#ws.guide { display: grid !important; grid-template-columns: 230px 1fr; gap: 0; padding: 0; overflow: hidden; background: var(--bg); }
#ws.guide .toc { overflow-y: auto; border-right: 1px solid var(--rule); padding: 10px 0; background: #070707; }
#ws.guide .toc .tt { font: 700 12px var(--sans); letter-spacing: .12em; color: #fff; padding: 0 14px 8px; }
#ws.guide .toc .tg { color: var(--ink-3); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; padding: 10px 14px 3px; }
#ws.guide .toc a { display: block; padding: 3px 14px; color: var(--ink-2); text-decoration: none; }
#ws.guide .toc a:hover { color: #fff; background: #111; }
#ws.guide .docbody { overflow-y: auto; padding: 16px 28px 80px; font-size: calc(var(--fs, 11px) * 1.18); line-height: 1.55; color: var(--ink); }
#ws.guide .docbody > * { max-width: 860px; }
#ws.guide h2 { font: 700 18px var(--sans); color: #fff; margin: 26px 0 8px; }
#ws.guide h2.gh { border-bottom: 1px solid var(--rule); padding-bottom: 6px; margin-top: 36px; color: var(--flip); }
#ws.guide h3 { font: 700 15px var(--sans); color: #fff; margin: 0 0 6px; }
#ws.guide h3 .dim { font-weight: normal; font-size: 11px; color: var(--ink-3); margin-left: 8px; }
#ws.guide h4 { color: #fff; margin: 14px 0 4px; font-size: 13px; }
#ws.guide .doc { padding: 12px 0 14px; border-bottom: 1px solid #141414; scroll-margin-top: 10px; }
#ws.guide .doc.hl { box-shadow: -6px 0 0 var(--flip); padding-left: 10px; }
#ws.guide .doc p { margin: 6px 0; }
#ws.guide .lab { display: inline-block; min-width: 150px; color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; margin-right: 8px; }
#ws.guide ul, #ws.guide ol { margin: 4px 0 8px 18px; padding: 0; }
#ws.guide li { margin: 3px 0; }
#ws.guide kbd { font-family: var(--mono); background: #1d1d1d; border: 1px solid #444; padding: 0 4px; }
#tabs .tab.tabguide { margin-left: auto; }
#tabs .tab.tabedit { margin-left: 0; }
.win .gear.help { margin-left: 2px; font-weight: bold; }
@media (max-width: 900px) { #ws.guide { grid-template-columns: 1fr; } #ws.guide .toc { display: none; } }
.dk .up { color: var(--pos); } .dk .dn { color: var(--neg); }
.needs { padding: 4px 2px 0; font-size: 0.92em; }
/* Options Say: one row per factor, a centre-out bar, a word for how hard it pulls */
.tile .why.wf { grid-template-columns: 54px minmax(110px, auto) 1fr auto; align-items: center; }
.tile .pm { position: relative; height: 8px; border: 1px solid var(--rule); background: #0b0b0b; }
.tile .pm .pz { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: #555; }
.tile .pm .pf { position: absolute; top: 0; bottom: 0; }
.tile .pm .pf.pos { background: var(--pos); } .tile .pm .pf.neg { background: var(--neg); }
.tile .pw { font-size: .9em; white-space: nowrap; } .tile .pw.mid { color: var(--ink-3); }
.tile .gauge .gm.ghost { background: transparent; border: 1px dashed #999; }
/* Walls */
.wl .wb { display: inline-block; vertical-align: middle; width: 60px; height: 8px; background: #0b0b0b; border: 1px solid var(--rule); position: relative; }
.wl .wf { position: absolute; left: 0; top: 0; bottom: 0; } .wl .wf.pos { background: var(--pos); } .wl .wf.neg { background: var(--neg); }
.wl .pos { color: var(--pos); } .wl .neg { color: var(--neg); }
.wl .tagm { font-size: .85em; color: var(--ink); border: 1px solid var(--rule); padding: 0 3px; }
.eff.big, .wl .big { color: #fff; font-weight: 700; }
/* Premium by Time: tape of the clicked 5-minute bar */
.win > .body.fill { position: relative; }
.btape { position: absolute; right: 8px; top: 22px; width: min(620px, calc(100% - 16px)); max-height: calc(100% - 44px); display: flex; flex-direction: column;
  background: rgba(8,8,8,.97); border: 1px solid var(--rule); box-shadow: 0 4px 18px rgba(0,0,0,.6); z-index: 5; }
.btape .bh { display: flex; gap: 10px; align-items: baseline; padding: 5px 8px; border-bottom: 1px solid var(--rule); }
.btape .bh .up { color: var(--pos); } .btape .bh .dn { color: var(--neg); }
.btape .bx { margin-left: auto; cursor: pointer; color: var(--ink-2); padding: 0 4px; } .btape .bx:hover { color: #fff; }
.btape .bb { overflow: auto; }
/* Big Trades */
.bt .bts { padding: 5px 8px; border-bottom: 1px solid var(--rule); } .bt .up { color: var(--pos); } .bt .dn { color: var(--neg); }
.bt tr.hg td { opacity: .55; }
/* Key Trades */
.kts .kt { padding: 6px 10px; border-bottom: 1px solid #111; }
.kts .kt1 { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.kts .kt2 { color: var(--ink-2); padding-top: 2px; }
.kts .up { color: var(--pos); } .kts .dn { color: var(--neg); }
.kts .dp { opacity: .8; }

#downBanner { display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 50; padding: 4px 10px; background: var(--neg); color: #000; font: 600 12px Consolas, Menlo, monospace; text-align: center; }

/* replay bar: sits above the page tabs while replay is on */
#replay { display: none; position: absolute; left: 0; right: 0; bottom: 40px; height: 26px; align-items: center; gap: 4px; padding: 0 8px;
  background: var(--chrome-lo); border-top: 1px solid var(--chrome-hi); font: 12px var(--mono); color: var(--ink); z-index: 20; }
#replay button { background: var(--chrome); color: var(--ink); border: 1px solid #444; height: 20px; min-width: 28px; padding: 0 6px; font: 12px var(--mono); cursor: pointer; }
#replay button:hover { color: #fff; border-color: #777; }
#replay .rp { min-width: 36px; color: #fff; }
#replay select { height: 20px; background: #0d0d0d; color: #fff; border: 1px solid #444; font: 11px var(--mono); }
#replay input[type=range] { flex: 1; min-width: 120px; accent-color: var(--warn); }
#replay .rt { color: var(--warn); white-space: nowrap; min-width: 330px; }
body.replaying #ws { bottom: 66px; }
#tabs .tab.tabreplay { margin-left: auto; color: var(--warn); }
#tabs .tab.tabreplay.on { background: var(--warn); color: #000; }
#tabs .tab.tabreplay ~ .tabguide { margin-left: 0; }


/* ========================================================================
 * TERMINAL (v4 redesign): black board, hard white window rules, uppercase
 * monospace, purple for the one thing that matters. Layered over the Sierra
 * chrome above, so older rules keep working and this only restyles them.
 * ======================================================================== */
:root {
  --bg: #000; --chrome: #000; --chrome-hi: #1c1c1c; --chrome-lo: #000;
  --title: #000; --title-act: #000; --rule: #262626; --grid: #151515;
  --ink: #f2f2f2; --ink-2: #a8a8a8; --ink-3: #6b6b6b; --warn: #ffb020; --row-hi: #150f24;
  --edge: #d9d9d9;
  --sans: "JetBrains Mono", Consolas, Menlo, monospace;
  --mono: "JetBrains Mono", Consolas, Menlo, monospace;
  --display: "Martian Mono", "JetBrains Mono", Consolas, monospace;
}
html, body { font-family: var(--mono); letter-spacing: .01em; }

/* top bar */
#bar { height: 32px; background: #000; box-shadow: none; border-bottom: 1px solid var(--edge); padding: 0 8px; }
#bar .grp { border-right: 1px solid #222; box-shadow: none; padding: 0 10px; }
#bar .lbl { letter-spacing: .14em; font-size: 10px; }
#bar .brand { font: 800 13px var(--display); letter-spacing: .32em; padding: 0 16px 0 6px; }
#ws { top: 32px; background: #000; padding: 6px; gap: 6px; }
.win.max { top: 34px !important; }
.btn { height: 22px; line-height: 20px; padding: 0 8px; background: transparent; border: 1px solid #333; font-family: var(--mono); font-weight: 600; letter-spacing: .06em; }
.btn:hover { border-color: #777; color: #fff; }
.btn:active, .btn.on { background: var(--pos); color: #000; border-color: var(--pos); box-shadow: none; }

/* windows */
.win { border: 1px solid var(--edge); }
.win > .tb { height: 22px; gap: 10px; padding: 0 8px; background: #000; border-bottom: 1px solid var(--edge); color: var(--ink); }
.win:hover > .tb { background: #000; color: #fff; }
.win > .tb .no { color: var(--pos); font-weight: 700; }
.win > .tb .nm { font: 800 11px var(--display); letter-spacing: .08em; text-transform: uppercase; }
.win > .tb .sub { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.win.bare > .tb { display: none; }
.body::-webkit-scrollbar-track { background: #000; }
.body::-webkit-scrollbar-thumb { background: #262626; border: 1px solid #000; }

/* state strip */
.strip { height: 100%; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.strip .sc { display: flex; flex-direction: column; justify-content: center; gap: 5px; padding: 0 18px; border-right: 1px solid #262626; min-width: 0; }
.strip .sc:last-child { border-right: 0; }
.strip .k { font: 600 10px var(--mono); letter-spacing: .16em; color: var(--ink-3); }
.strip b { font: 800 20px/1 var(--display); letter-spacing: .02em; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip .n { font-size: 11px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip .sc.hl { background: var(--pos); }
.strip .sc.hl .k, .strip .sc.hl b, .strip .sc.hl .n { color: #000; }

/* home tiles and big words */
.tile .big { font-family: var(--display); font-weight: 800; letter-spacing: .01em; }

/* trade check: one line per check, full reason on hover */
.tc .tch { font: 800 13px var(--display); letter-spacing: .08em; }
.tc .ck { grid-template-columns: 16px 62px minmax(0, 1fr); border-bottom-color: #111; }
.tc .ck .wrap { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc .ck > span:nth-child(2) { text-transform: uppercase; letter-spacing: .08em; font-size: 10px; }
.tc .verdict { font: 800 11px/1.2 var(--display); letter-spacing: .06em; text-transform: uppercase; padding: 7px 9px; }
.verdict.pos { background: var(--pos); color: #000; border-color: var(--pos); }
.verdict.half { color: #fff; border-color: #fff; }
.needs { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 6px 8px 0; }

/* tables */
table.t th { background: #000; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; font-size: 10px; border-bottom-color: #262626; }
table.t td { border-bottom-color: #0e0e0e; }

/* page tabs + status */
#tabs { background: #000; border-top: 1px solid var(--edge); padding: 0; gap: 0; }
#tabs .tab { background: #000; border: 0; border-right: 1px solid #1f1f1f; margin-top: 0; line-height: 19px; text-transform: uppercase; letter-spacing: .1em; font-size: 10px; font-weight: 600; }
#tabs .tab.on { background: var(--ink); color: #000; }
#tabs .tab.on .k { color: #000; opacity: .55; }
#tabs .tab.tabreplay { color: var(--pos); }
#tabs .tab.tabreplay.on { background: var(--pos); color: #000; }
#status { background: #000; border-top: 1px solid #1f1f1f; text-transform: uppercase; letter-spacing: .08em; font-size: 10px; }
#status .ok::before { color: var(--pos); }
#replay { background: #000; border-top: 1px solid var(--edge); }
#replay button { background: #000; border-color: #444; font-family: var(--mono); }
#replay .rt { color: var(--pos); }
#replay input[type=range] { accent-color: var(--pos); }
/* Trade Check keeps LONG and SHORT side by side even in a narrow window: the
 * rows are one line each now, so two columns fit. */
.tcs { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important; }

/* ========================================================================
 * PHONE / SMALL SCREENS (terminal look). Windows stack in one column; charts
 * get a fixed height, text windows size to their content; bars scroll
 * sideways instead of clipping; touch targets grow.
 * ======================================================================== */
@media (max-width: 900px) {
  html, body { font-size: 12px; }
  /* top bar: one row that scrolls sideways */
  #bar { height: 40px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  #bar::-webkit-scrollbar { display: none; }
  #bar .grp { padding: 0 8px; }
  #bar .lbl { display: none; }
  #bar .brand { padding: 0 12px 0 4px; font-size: 12px; }
  .btn { height: 28px; line-height: 26px; min-width: 32px; padding: 0 10px; }
  #ws { top: 40px; bottom: 56px; padding: 6px; }
  body.replaying #ws { bottom: 96px; }
  .win.max { top: 42px !important; bottom: 58px; }

  /* windows: charts a fixed height, everything textual its natural height */
  #ws > .win, #ws.board > .win { height: 62vh !important; margin: 0 0 8px; }
  #ws.board > .win:has(.strip), #ws.board > .win:has(.tcs), #ws.board > .win:has(table.lv), #ws.board > .win:has(table.kl), #ws.board > .win:has(.kts), #ws.board > .win:has(.tile) { height: auto !important; }
  #ws.board > .win:has(.strip) > .body, #ws.board > .win:has(.tcs) > .body, #ws.board > .win:has(table.lv) > .body, #ws.board > .win:has(table.kl) > .body, #ws.board > .win:has(.tile) > .body { overflow: visible; }
  .win > .tb { height: 28px; }
  /* a vertical swipe on a chart scrolls the page; sideways drags pan time, two fingers pinch */
  .win canvas { touch-action: pan-y; }
  #ws.board > .win:has(canvas) { height: 58vh !important; }

  /* state strip: a grid of cells instead of one long row */
  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); height: auto; }
  .strip .sc { padding: 12px 14px; border-right: 1px solid #262626; border-bottom: 1px solid #262626; }
  .strip .sc.hl { grid-column: 1 / -1; }
  .strip b { font-size: 18px; }

  /* trade check: sides stack, rows may wrap */
  .tcs { grid-template-columns: 1fr !important; }
  .tc .ck .wrap { white-space: normal; }

  /* page tabs + status: taller, tabs scroll sideways */
  #tabs { height: 34px; bottom: 22px; overflow-x: auto; scrollbar-width: none; }
  #tabs::-webkit-scrollbar { display: none; }
  #tabs .tab { line-height: 33px; padding: 0 14px; flex: none; }
  #status { height: 22px; gap: 12px; overflow-x: auto; scrollbar-width: none; padding-bottom: env(safe-area-inset-bottom, 0px); }
  #status::-webkit-scrollbar { display: none; }
  #replay { bottom: 56px; height: auto; flex-wrap: wrap; padding: 6px; row-gap: 6px; }
  #replay input[type=range] { order: 9; flex-basis: 100%; }
  #replay .rt { min-width: 0; }

  /* customise drawer and window settings fill the screen width */
  #drawer { top: 40px; bottom: 56px; width: 100vw; }
  #wset { left: 8px !important; right: 8px !important; min-width: 0; }
}
@media (max-width: 560px) {
  .win > .tb .sub { display: none; }
  .strip .n { white-space: normal; }
}
/* the wordmark is a link home (replays the intro) */
a.brand { text-decoration: none; color: #fff; cursor: pointer; }
a.brand:hover { color: var(--accent, #a77bff); }
/* title-bar chips: switch what a window shows (e.g. the Greek on the gamma charts) */
.win > .tb .chips { display: flex; gap: 2px; margin-left: 6px; }
.win > .tb .chip { font: 600 9px/1 var(--mono, monospace); letter-spacing: .08em; padding: 3px 6px; background: transparent; color: var(--ink-3); border: 1px solid #2a2a2a; cursor: pointer; }
.win > .tb .chip:hover { color: #fff; border-color: #555; }
.win > .tb .chip.on { color: #000; background: var(--pos); border-color: var(--pos); }
@media (max-width: 900px) { .win > .tb .chip { padding: 5px 7px; font-size: 10px; } }
@media (max-width: 900px) {
  .win > .tb .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .win > .tb .chips { flex: 0 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; margin-left: auto; }
  .win > .tb .chips::-webkit-scrollbar { display: none; }
  .win > .tb .chip { flex: none; }
  .win > .tb .gear { flex: none; }
}
/* a window with no data for the current view (e.g. a pinned symbol before its first sample in replay) */
.win > .body.nodata > canvas { visibility: hidden; }
/* stacked layout (narrow screens): the corner handle resizes a window's height
   (main.js), and a page with a single window fills the screen */
@media (max-width: 900px) {
  #ws.board > .win .rz { display: block; width: 22px; height: 22px; }
  #ws.board > .win:only-child { height: calc(100% - 4px) !important; }
}
/* short laptop screens (1280x720, 1366x768): the Home strip is two grid rows
   tall there, too short for label + value + note at full size */
@media (min-width: 901px) and (max-height: 820px) {
  .strip .sc { gap: 2px; padding: 0 12px; }
  .strip .k { font-size: 9px; letter-spacing: .12em; }
  .strip b { font-size: 16px; }
  .strip .n { font-size: 10px; }
}
/* tooltips fit a phone screen */
@media (max-width: 900px) { #tip { max-width: calc(100vw - 8px); white-space: pre-wrap; box-sizing: border-box; } }
/* day picker (top bar): a dropdown, styled like the bar's buttons */
#bar .daysel { font: 600 11px var(--mono, monospace); letter-spacing: .06em; color: #fff; background: #000; border: 1px solid #333;
  height: 22px; padding: 0 22px 0 8px; border-radius: 0; cursor: pointer; -webkit-appearance: none; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #9a9a9a 50%), linear-gradient(135deg, #9a9a9a 50%, transparent 50%);
  background-position: calc(100% - 11px) 50%, calc(100% - 7px) 50%; background-size: 4px 4px; background-repeat: no-repeat; }
#bar .daysel.live { color: #000; background-color: var(--pos); border-color: var(--pos); }
#bar .daysel option { color: #fff; background: #111; }
@media (max-width: 900px) { #bar .daysel { height: 28px; font-size: 12px; } }
/* a second chip group in a title bar (e.g. Greek, then expiry) */
.win > .tb .chips + .chips { margin-left: 8px; }
@media (max-width: 900px) { .win > .tb .chips + .chips { margin-left: 6px; } }
/* chart drawing toolbar (canvas.js enableDrawing) */
.drawbar { position: absolute; left: 6px; top: 22px; z-index: 3; display: flex; gap: 2px; align-items: center; opacity: .55; transition: opacity .15s; }
.drawbar:hover, .drawbar:has(.on) { opacity: 1; }
.drawbar button { font: 12px/1 var(--mono, monospace); width: 22px; height: 20px; padding: 0; background: rgba(0,0,0,.75); color: #ddd; border: 1px solid #333; cursor: pointer; }
.drawbar button:hover { border-color: #777; color: #fff; }
.drawbar button.on { background: var(--pos); color: #000; border-color: var(--pos); }
.drawbar input[type=color] { width: 22px; height: 20px; padding: 0; border: 1px solid #333; background: #000; cursor: pointer; }
@media (max-width: 900px) { .drawbar button, .drawbar input[type=color] { width: 28px; height: 26px; } }
