/*
 * Symbogan -- 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: #19a79a;
  --neg: #f2553d;
  --flip: #4b8ff0;
  --pos-dim: #0d4a44;
  --neg-dim: #5c2217;
  --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; }
.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; } }
