:root {
  --bg: #000;
  --rule: #333;
  --row: #1a1a1a;
  --amber: #ffa028;
  --text: #f0f0f0;
  --muted: #9a9a9a;
  --yellow: #ffd43b;
  --red: #ff4136;
  --green: #2ecc40;
  --blue: #2b6fd6;
  --cyan: #39c6f0;
  --magenta: #d55bf0;
  --u: min(1vw, 1.78vh); /* 1920 px wide = 19.2 px */
  --sb: calc(var(--u) * 0.8); /* scrollbar width */
  --pad: calc(var(--u) * 0.5);
  font-family: "IBM Plex Mono", Consolas, monospace;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
body {
  font-size: calc(var(--u) * 0.84);
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 3px;
  padding: 3px;
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: -2px; }
kbd { font: inherit; color: var(--yellow); margin-right: .2em; }
b { font-weight: 700; }

/* scrollbars: drawn by the page, so every browser shows the same square bar with arrow buttons */
.scroll { overflow-x: hidden; overflow-y: scroll; scrollbar-width: none; }
.scroll::-webkit-scrollbar { display: none; }
.sbar {
  position: absolute; right: 0; width: var(--sb); display: flex; flex-direction: column;
  background: #141414; border-left: 1px solid var(--rule); user-select: none; touch-action: none;
}
.sbar button { flex: none; height: var(--sb); padding: 0; border: 0; background: #000 center / 62% no-repeat; cursor: pointer; }
.sbar .up { border-bottom: 1px solid var(--rule); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath d='M4 1.5 7.5 6.5H.5z' fill='%23ffa028'/%3E%3C/svg%3E"); }
.sbar .down { border-top: 1px solid var(--rule); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath d='M4 6.5 7.5 1.5H.5z' fill='%23ffa028'/%3E%3C/svg%3E"); }
.sbar button:hover { background-color: #2a2a2a; }
.sbar .track { flex: 1; min-height: 0; position: relative; }
.sbar .thumb { position: absolute; top: 0; left: 1px; right: 0; background: #b9741c; }
.sbar .thumb:hover, .sbar.drag .thumb { background: var(--amber); }
.sbar.off .thumb { display: none; }
.sbar.off button { opacity: .35; cursor: default; }

/* tooltip */
.tip {
  position: fixed; inset: auto; top: 0; left: 0; margin: 0; z-index: 10;
  max-width: 34em; padding: .15em .5em;
  background: #000; color: var(--text); border: 1px solid var(--amber);
  font: inherit; font-size: calc(var(--u) * 0.8); line-height: 1.35;
  pointer-events: none; white-space: normal;
}

/* top bar */
.bar { display: flex; gap: 3px; font-weight: 500; }
.bar > * { padding: 3px calc(var(--u) * 0.7); display: flex; align-items: center; white-space: nowrap; }
.cmd { background: var(--amber); color: #000; font-weight: 700; }
.cmd b { background: #000; color: var(--amber); padding: 0 .4em; margin-left: .7em; }
.bar .fill { flex: 1; min-width: 0; overflow: hidden; border: 1px solid var(--rule); color: var(--muted); gap: calc(var(--u) * 1.6); }
.bar .fill span { min-width: 13em; }
.bar .fill #conn { min-width: 7em; color: var(--text); }
.clocks { border: 1px solid var(--rule); color: var(--amber); gap: calc(var(--u) * 1.2); }
.key-btn { font: inherit; font-weight: 500; background: #000; color: var(--text); border: 1px solid var(--rule); cursor: pointer; }
.key-btn:hover { border-color: var(--amber); }
.live::before { content: "■ "; color: var(--green); }
.live.pending::before, .live.stale::before { color: var(--yellow); }
.live.down::before { color: var(--red); }

/* layout */
/* Panels share one 1 px line: the gaps show the rule color behind them. */
.grid { display: grid; grid-template-columns: 45fr 21fr 34fr; grid-template-rows: minmax(0, 31fr) minmax(0, 69fr); gap: 1px; min-height: 0; background: var(--rule); border: 1px solid var(--rule); }
.top { grid-column: 1 / -1; display: grid; grid-template-columns: 19fr 31fr 18fr 32fr; gap: 1px; min-height: 0; background: var(--rule); }
.lists, .side { display: grid; gap: 1px; min-height: 0; min-width: 0; background: var(--rule); }
.lists { grid-template-rows: minmax(0, 36fr) minmax(0, 34fr) minmax(0, 30fr); }
.side { grid-template-rows: minmax(0, 70fr) minmax(0, 30fr); }

.panel { position: relative; background: var(--bg); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.ph {
  display: flex; justify-content: space-between; gap: 1em; flex: none;
  background: var(--amber); color: #000; font-weight: 700;
  padding: 1px var(--pad); white-space: nowrap; overflow: hidden;
}
.ph span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ph span:last-child { font-weight: 500; flex: none; }
.pb { flex: 1; min-height: 0; min-width: 0; overflow: hidden; padding: calc(var(--u) * 0.4) var(--pad); }
.pb.scroll { overflow-y: scroll; padding-right: calc(var(--sb) + var(--pad)); }
.note { color: var(--muted); }
[hidden] { display: none !important; }

/* badges: one solid block style for every status word */
.badge { display: inline-block; padding: 0 .55em; font-weight: 700; letter-spacing: .04em; background: #000; color: var(--text); white-space: nowrap; }
.badge.ok { background: var(--green); color: #000; }
.badge.warn { background: var(--yellow); color: #000; }
.badge.bad { background: var(--red); color: #fff; }
.badge.info { background: var(--blue); color: #fff; }
.ph .badge { margin: -1px calc(var(--pad) * -1) -1px 0; padding: 1px .8em; border-left: 2px solid #000; }
.ph .badge.warn { background: #000; color: var(--yellow); }
.ph .badge.ok { background: #000; color: var(--green); }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* value colors. Up means worse, so up is red. */
.up { color: var(--red); } .dn { color: var(--green); } .flat { color: var(--muted); }
.v-hi { color: var(--red); } .v-mid { color: var(--amber); } .v-lo { color: var(--green); }

/* index panel */
.quote .pb { display: flex; flex-direction: column; justify-content: space-between; gap: calc(var(--u) * 0.3); }
.q-big { display: grid; grid-template-columns: 1fr 1fr; gap: var(--pad); }
.q-big > div { display: flex; flex-direction: column; min-width: 0; }
.q-big .k { color: var(--amber); }
.q-val { font-size: calc(var(--u) * 2.9); font-weight: 700; line-height: 1.05; white-space: nowrap; }
.q-val small { font-size: .38em; font-weight: 500; color: var(--muted); margin-left: .15em; }
.q-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0 calc(var(--u) * 1); }
.q-stats > div { display: flex; justify-content: space-between; border-top: 1px solid var(--row); padding: calc(var(--u) * 0.08) 0; white-space: nowrap; }
.q-stats dt { color: var(--amber); }
.q-stats dd { font-weight: 700; }

/* tables */
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { color: var(--amber); font-weight: 500; text-align: left; border-bottom: 1px solid var(--rule); white-space: nowrap; }
td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-bottom: 1px solid var(--row); }
td + td, th + th { padding-left: calc(var(--u) * 0.7); }
.num { text-align: right; }
.t-areas td, .t-areas th { padding-top: calc(var(--u) * 0.36); padding-bottom: calc(var(--u) * 0.36); }
.t-areas .area { width: 4.6em; color: var(--yellow); font-weight: 700; }
.t-areas .last { width: 2.6em; font-weight: 700; font-size: 1.3em; }
.t-areas .chg { width: 3em; }
.t-areas .cnt { width: 3.4em; }
.t-areas .sig { width: 3.6em; color: var(--cyan); }
.t-areas tr:last-child td, .r-out tr:last-child td { border-bottom: 0; }
.t-areas .trend { width: 5.4em; }

/* story lists */
.blotter .pb, .chat .pb, .sigs .pb { padding: 0 var(--sb) 0 0; }
.rows .r:last-child { border-bottom: 0; }
.rows { display: flex; flex-direction: column; }
.r {
  display: grid;
  grid-template-columns: 2.2em 2.8em 4.4em 7.4em minmax(0, 1fr) 2.6em 3.6em;
  gap: calc(var(--u) * 0.7);
  padding: calc(var(--u) * 0.2) var(--pad);
  border-bottom: 1px solid var(--row);
  white-space: nowrap; cursor: pointer;
  scroll-margin-top: 2em;
}
.r > span { overflow: hidden; text-overflow: ellipsis; }
.r.head { position: sticky; top: 0; z-index: 1; background: #000; color: var(--amber); border-bottom-color: var(--rule); cursor: default; }
.r:not(.head):hover { background: #1c1c1c; }
/* sortable column names */
.r.head > span { overflow: visible; }
[data-sort] { cursor: pointer; }
[data-sort]:hover { color: var(--text); }
[data-sort].sorted { color: var(--yellow); font-weight: 700; }
[data-sort].sorted::after { content: "▼"; }
[data-sort].sorted.asc::after { content: "▲"; }

/* live signals */
.sigs .r { grid-template-columns: 6.4em 2.2em minmax(0, 1fr) 2.2em; gap: calc(var(--u) * 0.5); cursor: default; line-height: 1.25; padding-block: calc(var(--u) * 0.12); }
.g .lab { font-weight: 500; }
.g .in { color: var(--muted); }
.g.l0 .val { color: var(--muted); }
.g.l1 .val { color: var(--yellow); }
.g.l2 .val { color: var(--amber); font-weight: 700; }
.g.l3 .val, .g.l4 .val { color: var(--red); font-weight: 700; }
.g.l4 .lab { color: var(--red); font-weight: 700; }
.g .sev.s1 .on { color: var(--yellow); }
.g .sev.s2 .on { color: var(--amber); }
.g .sev.s3 .on, .g .sev.s4 .on { color: var(--red); }
.g .g-note { display: none; grid-column: 1 / -1; white-space: normal; line-height: 1.35; padding-bottom: .2em; }
.g.cur .g-note { display: block; }
.r.sel, .r.sel:hover { background: var(--amber); color: #000; }
.r .idx { color: var(--yellow); text-align: right; }
.r .age { color: var(--muted); text-align: right; }
.r .tag { color: var(--cyan); }
.us { color: #fff; background: var(--blue); padding: 0 .3em; margin-right: .35em; font-weight: 700; }
.r.new .hl { font-weight: 700; }
.r.new .age { color: var(--yellow); }
.r .n { color: var(--muted); text-align: right; }
.r .pts { text-align: right; color: var(--yellow); font-weight: 700; }
.r .pts.fade { color: var(--muted); font-weight: 400; }
.r.sel .idx, .r.sel .age, .r.sel .tag, .r.sel .n, .r.sel .pts, .r.sel .sev .on, .r.sel .sev .off { color: #000; }
.r.sel .us { background: #000; }
.r.sel .idx { font-weight: 700; }
.sev { letter-spacing: -.1em; }
.sev .on { color: var(--amber); } .sev .off { color: #3a3a3a; }
.sev.s4 .on, .sev.s5 .on { color: var(--red); }

/* chart */
.chart .pb { position: relative; padding: calc(var(--u) * 0.5) calc(var(--u) * 2.4) calc(var(--u) * 1.5) var(--pad); }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .grid-l { stroke: #262626; stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .ln { fill: none; stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.chart .ln.mwi { stroke: var(--amber); stroke-width: 2.4; }
.chart .ln.war { stroke: var(--red); } .chart .ln.cyber { stroke: var(--cyan); } .chart .ln.doom { stroke: var(--magenta); }
.chart .yl { position: absolute; right: var(--pad); color: var(--muted); transform: translateY(-50%); font-size: .9em; }
.chart .xl { position: absolute; bottom: calc(var(--u) * 0.15); color: var(--muted); font-size: .9em; }
.legend i { font-style: normal; margin-left: .6em; padding: 0 .3em; background: #000; }
.l-mwi { color: var(--amber); } .l-war { color: var(--red); } .l-cyber { color: var(--cyan); } .l-doom { color: var(--magenta); }
.chart .empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }

/* story panel */
.reader .pb { display: flex; flex-direction: column; gap: calc(var(--u) * 0.4); padding: var(--pad) calc(var(--sb) + var(--u) * 0.7) var(--pad) calc(var(--u) * 0.7); }
.r-title { font-size: calc(var(--u) * 1.25); font-weight: 700; line-height: 1.25; }
.r-orig { color: var(--muted); }
.r-facts { display: flex; flex-wrap: wrap; gap: .1em 1.1em; white-space: nowrap; }
.r-facts .k { color: var(--amber); margin-right: .4em; }
.r-facts .zone { color: var(--cyan); }
.r-label { color: var(--amber); font-weight: 700; }
.r-kv { display: grid; grid-template-columns: 6em minmax(0, 1fr); gap: calc(var(--u) * 0.3) calc(var(--u) * 0.7); }
.r-kv dt { color: var(--amber); font-weight: 700; }
.r-kv dd { line-height: 1.4; max-width: 70ch; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.r-kv dd.lead { font-size: 1.08em; }
.r-kv .badge { margin-right: .6em; }
.r-text { max-width: 70ch; font-size: 1.08em; line-height: 1.4; }
.r-kv dd.r-math { display: flex; flex-wrap: wrap; align-items: baseline; overflow: visible; line-height: 1.5; }
.r-math > span { white-space: nowrap; }
.r-head { display: flex; justify-content: space-between; gap: 1em; white-space: nowrap; }
.r-math .k { color: var(--muted); margin-right: .3em; }
.r-math .x { color: var(--muted); margin: 0 .5em; }
.r-math .eq { color: var(--yellow); font-weight: 700; }
.r-math .eq.fade { color: var(--muted); }
.r-math .state { color: var(--muted); margin-left: 1.2em; }
.r-out td { padding: calc(var(--u) * 0.12) 0; }
.r-out td + td { padding-left: calc(var(--u) * 0.7); }
.r-out .os { font-weight: 500; }
.r-out .ot { width: 7em; color: var(--muted); }
.r-out .ol { width: 15.6em; text-align: right; }
.osn { display: flex; align-items: baseline; gap: .5em; min-width: 0; }
.osn .clip { min-width: 0; }
.osn .pw { flex: none; }
.r-out a, .r-more a { color: var(--yellow); text-decoration: none; margin-left: .9em; }
.r-out a:hover, .r-more a:hover, .r-out a:focus-visible { text-decoration: underline; }
.pw { font-size: .85em; padding: 0 .35em; }

/* AI outlook */
.outlook .pb { padding-top: calc(var(--u) * 0.3); }
.o-why { font-weight: 700; line-height: 1.3; margin-bottom: calc(var(--u) * 0.2); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.o-line > span:last-child, .o-pred > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.o-line { display: grid; grid-template-columns: 5.6em minmax(0, 1fr); gap: calc(var(--u) * 0.7); }
.o-line .k { color: var(--amber); }
.o-line .badge { margin-right: .6em; }
.o-line a { text-decoration: none; }
.o-line a:hover { text-decoration: underline; }
.o-pred { display: grid; grid-template-columns: 2.8em 2.6em 3.4em minmax(0, 1fr); gap: calc(var(--u) * 0.7); padding: calc(var(--u) * 0.1) 0; border-bottom: 1px solid var(--row); }
.o-pred .ch { text-align: right; font-weight: 700; }
.o-pred .w, .o-pred .a { color: var(--muted); }
.o-pred:last-child { border-bottom: 0; }
.o-line + .o-pred { border-top: 1px solid var(--rule); margin-top: calc(var(--u) * 0.2); }

/* posts */
.chat .r { grid-template-columns: 3.4em 2.8em 9em minmax(0, 1fr); cursor: default; }
.chat .who { color: var(--muted); }
.chat a { text-decoration: none; }
.chat a:hover { text-decoration: underline; }
.net-hn { color: var(--amber); } .net-bs { color: var(--cyan); } .net-md { color: var(--magenta); }

/* command line */
.cmdline { display: flex; gap: calc(var(--u) * 1); align-items: center; border: 1px solid var(--rule); padding: 2px calc(var(--u) * 0.7); white-space: nowrap; overflow: hidden; }
.prompt { color: var(--amber); font-weight: 700; }
.buf { color: var(--yellow); font-weight: 700; }
.cursor { color: var(--amber); margin-left: calc(var(--u) * -0.9); }
.keys { color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; word-spacing: .1em; }
.keys kbd { margin-left: .9em; }
.src-sum { color: var(--muted); }

/* help */
.help { margin: auto; width: min(140em, 96vw); max-height: 92vh; background: #000; color: var(--text); border: 1px solid var(--amber); padding: 0; font-size: calc(var(--u) * 0.9); }
.help::backdrop { background: rgba(0, 0, 0, .85); }
.help-body { padding: 1em calc(var(--sb) + 1.2em) 1em 1.2em; max-height: calc(92vh - 2em); }
.help-cols { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 2.4em; }
.help h3 { color: var(--amber); font-size: 1em; margin: 1.1em 0 .3em; }
.help h3:first-child { margin-top: 0; }
.help p { margin-bottom: .55em; line-height: 1.45; max-width: 56ch; }
.feeds { display: grid; grid-template-columns: 1fr 1fr; gap: .1em 1em; font-size: .9em; }
.feeds a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
.feeds a:hover { text-decoration: underline; }

/* the panel that takes the keys */
.panel.focus { outline: 1px solid var(--yellow); z-index: 1; }
.panel.focus > .ph { background: var(--yellow); }
.cur, .r.cur, .r.cur:hover { background: #2f2f2f; box-shadow: inset 3px 0 0 var(--yellow); }
.o-line.cur { background: #2f2f2f; box-shadow: inset 3px 0 0 var(--yellow); }
.keys b { color: var(--yellow); font-weight: 700; margin-left: 1em; }
.keys b:first-child { margin-left: 0; }

/* Small wide screens and 4:3 or 5:4 screens: larger type, no chart, fewer columns. Still one screen, no page scroll. */
@media (min-aspect-ratio: 1/1) and (max-aspect-ratio: 3/2), (min-aspect-ratio: 1/1) and (max-width: 1500px) {
  :root { --u: max(14px, min(1.4vw, 1.9vh)); }
  .grid { grid-template-columns: 56fr 44fr; grid-template-rows: minmax(0, 31fr) minmax(0, 41fr) minmax(0, 28fr); }
  .lists { grid-row: 2 / 4; grid-column: 1; }
  .side { grid-row: 2; grid-column: 2; }
  .sigs { grid-row: 3; grid-column: 2; }
  .o-pred { padding: 0; }
  .r-title { font-size: calc(var(--u) * 1.1); }
  .reader .pb { gap: calc(var(--u) * 0.35); }
  .side { grid-template-rows: minmax(0, 1fr); }
  .chat { display: none; }
  .sigs .r { grid-template-columns: 6.4em minmax(0, 1fr) 2.2em; }
  .sigs .in { display: none; }
  .r-out .ot { width: 6.4em; }
  .top { grid-template-columns: 26fr 34fr 40fr; }
  .chart { display: none; }
  .q-val { font-size: calc(var(--u) * 2.3); }
  .r { grid-template-columns: 2.2em 2.8em 4.4em 6em minmax(0, 1fr) 3.6em; gap: calc(var(--u) * 0.55); }
  .r .n { display: none; }
  .chat .r { grid-template-columns: 3.4em 2.8em 7em minmax(0, 1fr); }
  .bar .fill span { min-width: 0; }
  .bar .fill { gap: calc(var(--u) * 1); }
  .src-sum, #next { display: none; }
  .help-cols { grid-template-columns: 1fr 1fr; }
}
/* 4:3 only: the areas table needs the width more than the zone list does */
@media (min-aspect-ratio: 1/1) and (max-aspect-ratio: 3/2) {
  .t-areas th:last-child, .t-areas td:last-child { display: none; }
  .t-areas .trend { width: auto; }
}

/* Very small landscape screens, such as 800x600. */
@media (min-aspect-ratio: 1/1) and (max-width: 900px) {
  .q-val { font-size: calc(var(--u) * 1.9); }
  .r-out .ot { display: none; }
  .t-areas .cnt, .t-areas .sig { display: none; }
  .o-line.money, .o-pred:nth-last-child(-n+2) { display: none; }
  .o-why { -webkit-line-clamp: 1; line-clamp: 1; }
  .r-out .ol { width: 9.4em; }
  .r-out .ol a:last-child { display: none; }
}

/* Portrait and phones: one column, the page scrolls. */
@media (max-aspect-ratio: 99/100) {
  html, body { overflow: auto; height: auto; }
  :root { --u: max(15px, 2.4vw); }
  body { grid-template-rows: none; }
  .grid, .top, .help-cols { grid-template-columns: 1fr; }
  .grid, .lists, .side { grid-template-rows: none; }
  .lists, .side, .sigs { grid-row: auto; grid-column: auto; }
  .chat { display: flex; }
  .pb.scroll { max-height: 70vh; }
  .chart .pb { height: 45vw; flex: none; }
  .quote .pb { gap: calc(var(--u) * 0.6); }
  .r { grid-template-columns: 2em 2.6em 4.4em minmax(0, 1fr) 3.4em; }
  .r .tag, .r .n { display: none; }
  .chat .r { grid-template-columns: 3.4em 2.6em minmax(0, 1fr); }
  .chat .r .who { display: none; }
  .r-out .ot { display: none; }
  .r-out .ol { width: auto; white-space: normal; }
  .bar { flex-wrap: wrap; }
  .bar .fill span { min-width: 0; }
  .keys, #next { display: none; }
}
