/* ═══════════════════════════════════════════════════════════════════════════
   Stock → News analytics, plus the rail's Cheat sheet tab.
   Ported from `Stock Cheat Sheet.dc.html`; see src/shell/pages/terminal/
   stock-news.ts (all sample data) and stock.ts `buildCheatSheet`.

   BRANDING CONTRACT — the handoff broke both of these and this sheet fixes them:

   1. TYPE. The handoff loaded Geist + Geist Mono from Google Fonts. SpiderX runs
      ONE face in all three roles from one sheet (assets/typography.css), so no
      family is loaded here and none may be added. Every "mono" number below is
      `var(--tm-mono)` — which ALIASES the sans — plus `tabular-nums`, which is
      what actually makes a column of figures line up.

   2. COLOUR. Every value is a `--tm-*` token from terminal.css. The only colours
      reaching the DOM directly are SVG fills and score values set inline from
      stock-news.ts, where the colour is DATA.

   Accent rule: lime marks the ACTIVE TAB and nothing else. Direction is
   --tm-live / --tm-loss.

   Scoped under `.app--mode-terminal`, like every other terminal sheet.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── rail: cheat sheet ────────────────────────────────────────────────────── */

/* Full-bleed inside the rail card: the rows carry their own 22px inset so a
   highlighted row's tint runs to the card's edge, the way the ladder's did. */
.app--mode-terminal .tms-cheat {
	display: flex;
	flex-direction: column;
	margin: 0 -22px;
}

.app--mode-terminal .tms-cheat__row {
	display: grid;
	grid-template-columns: 14px 62px minmax(0, 1fr) 74px 84px;
	align-items: center;
	gap: 10px;
	padding: 8px 22px;
	box-shadow: inset 0 -1px 0 var(--tm-line-2);
}

.app--mode-terminal .tms-cheat__mark {
	font-family: var(--tm-mono);
	font-size: 11px;
	color: var(--tm-ink-5);
}

/* Session and profile levels read differently on a chart, so they read
   differently here — and a naked POC gets the one warm colour on the list,
   because it is the line a trader is actually hunting for. */
.app--mode-terminal .tms-cheat__row--session .tms-cheat__mark,
.app--mode-terminal .tms-cheat__row--overnight .tms-cheat__mark,
.app--mode-terminal .tms-cheat__row--open .tms-cheat__mark {
	color: var(--tm-ink-3);
}

.app--mode-terminal .tms-cheat__row--naked .tms-cheat__mark {
	color: var(--tm-warn);
}

.app--mode-terminal .tms-cheat__code {
	font-family: var(--tm-mono);
	font-size: 10.5px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	white-space: nowrap;
	color: var(--tm-ink-2);
}

.app--mode-terminal .tms-cheat__name {
	font-size: 12.5px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: var(--tm-ink-4);
}

.app--mode-terminal .tms-cheat__away {
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 11.5px;
	text-align: right;
	color: var(--tm-ink-4);
}

.app--mode-terminal .tms-cheat__px {
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 13.5px;
	font-weight: 600;
	text-align: right;
	color: var(--tm-ink);
}

/* The live price. The only tinted row on the list — it is where the market is,
   which is the one thing a printed level sheet can never show. */
.app--mode-terminal .tms-cheat__row--now {
	background: linear-gradient(90deg, rgba(62, 207, 142, 0.1), rgba(62, 207, 142, 0.014) 62%, transparent);
}

.app--mode-terminal .tms-cheat__row--now .tms-cheat__mark,
.app--mode-terminal .tms-cheat__row--now .tms-cheat__code,
.app--mode-terminal .tms-cheat__row--now .tms-cheat__px {
	color: var(--tm-live);
}

.app--mode-terminal .tms-cheat__row--now .tms-cheat__name {
	color: rgba(62, 207, 142, 0.7);
}

/* ── section shell ────────────────────────────────────────────────────────── */

.app--mode-terminal .tsn {
	display: flex;
	flex-direction: column;
	gap: 20px;
	margin-top: 14px;
}

.app--mode-terminal .tsn-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 20px;
	flex-wrap: wrap;
	padding-bottom: 14px;
	border-bottom: 1px solid var(--tm-line);
}

.app--mode-terminal .tsn-eyebrow {
	font-family: var(--tm-mono);
	font-size: 10.5px;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--tm-ink-3);
}

.app--mode-terminal .tsn-tabs {
	display: flex;
	align-items: center;
	gap: 2px;
	padding: 3px;
	border: 1px solid var(--tm-line);
	border-radius: 12px;
}

.app--mode-terminal .tsn-tab {
	padding: 7px 13px;
	border: 0;
	border-radius: 9px;
	background: transparent;
	font-family: inherit;
	font-size: 13px;
	font-weight: 500;
	white-space: nowrap;
	color: var(--tm-ink-3);
	cursor: pointer;
	transition: background 0.16s var(--tm-ease), color 0.16s var(--tm-ease);
}

.app--mode-terminal .tsn-tab:hover {
	color: var(--tm-ink);
}

/* THE ONE LIME IN THIS SECTION. Do not add a second. */
.app--mode-terminal .tsn-tab.is-on {
	background: var(--tm-lime);
	color: #0b1203;
}

.app--mode-terminal .tsn-body,
.app--mode-terminal .tsn-stack {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.app--mode-terminal .tsn-sample {
	margin: 0;
	font-size: 11.5px;
	line-height: 1.5;
	color: var(--tm-ink-5);
}

/* ── layout ───────────────────────────────────────────────────────────────── */

.app--mode-terminal .tsn-grid4 {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
	gap: 16px;
}

.app--mode-terminal .tsn-grid3 {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 16px;
}

.app--mode-terminal .tsn-grid2 {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 16px;
}

.app--mode-terminal .tsn-split {
	display: grid;
	gap: 16px;
}

.app--mode-terminal .tsn-split--sent {
	grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
}

.app--mode-terminal .tsn-split--fund {
	grid-template-columns: minmax(0, 0.82fr) minmax(0, 1fr) minmax(0, 1.1fr);
}

.app--mode-terminal .tsn-card--wide {
	grid-column: span 2;
}

.app--mode-terminal .tsn-tiles {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
	gap: 16px;
}

/* ── cards ────────────────────────────────────────────────────────────────── */

.app--mode-terminal .tsn-card {
	display: flex;
	flex-direction: column;
	gap: 15px;
	padding: 20px 22px 18px;
	border: 1px solid var(--tm-line);
	border-radius: 16px;
	background: rgba(255, 255, 255, 0.022);
}

/* A card whose body is a list of full-bleed rows: the padding moves onto the
   rows so their hairlines run edge to edge. */
.app--mode-terminal .tsn-card--rows {
	gap: 0;
	padding: 20px 0 8px;
}

.app--mode-terminal .tsn-card__top {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px;
}

.app--mode-terminal .tsn-card__t {
	font-family: var(--tm-mono);
	font-size: 10.5px;
	letter-spacing: 0.13em;
	text-transform: uppercase;
	color: var(--tm-ink-3);
}

.app--mode-terminal .tsn-card__t--inset {
	padding: 0 22px 12px;
}

.app--mode-terminal .tsn-card__cap {
	font-family: var(--tm-mono);
	font-size: 10.5px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--tm-ink-5);
}

/* ── shared parts ─────────────────────────────────────────────────────────── */

.app--mode-terminal .tsn-fig {
	display: block;
	width: 100%;
}

.app--mode-terminal .tsn-fig > svg {
	display: block;
	width: 100%;
	height: auto;
}

.app--mode-terminal .tsn-fig__row {
	display: flex;
	align-items: baseline;
	gap: 11px;
	flex-wrap: wrap;
}

.app--mode-terminal .tsn-big {
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 34px;
	font-weight: 600;
	letter-spacing: -0.03em;
	color: var(--tm-ink);
}

.app--mode-terminal .tsn-big--sm {
	font-size: 30px;
}

.app--mode-terminal .tsn-chip {
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 12.5px;
	font-weight: 600;
	padding: 3px 8px;
	border-radius: 6px;
}

.app--mode-terminal .tsn-chip--sm {
	font-size: 11px;
	padding: 3px 7px;
}

.app--mode-terminal .tsn-chip--up {
	background: var(--tm-live-bg);
	color: var(--tm-live);
}

.app--mode-terminal .tsn-verdict {
	font-size: 24px;
	font-weight: 700;
	letter-spacing: -0.025em;
}

.app--mode-terminal .tsn-note {
	margin: 0;
	font-size: 12.5px;
	line-height: 1.5;
	color: var(--tm-ink-4);
}

.app--mode-terminal .tsn-list {
	display: flex;
	flex-direction: column;
	gap: 13px;
}

.app--mode-terminal .tsn-list--ruled {
	gap: 9px;
	padding-top: 14px;
	border-top: 1px solid var(--tm-hair);
}

.app--mode-terminal .tsn-kv {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
}

.app--mode-terminal .tsn-kv__k {
	font-size: 12.5px;
	color: var(--tm-ink-3);
}

.app--mode-terminal .tsn-kv__v {
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 13px;
	color: var(--tm-ink-2);
}

.app--mode-terminal .tsn-kv__v--ink {
	color: var(--tm-ink);
}

.app--mode-terminal .tsn-bar__track {
	fill: rgba(255, 255, 255, 0.05);
}

/* Pinned, not `auto`: these viewBoxes are 1000 wide with no aspect ratio, so an
   auto height collapses the bar to a 1.6px hairline. */
.app--mode-terminal .tsn-bar--h8 > svg {
	height: 8px;
}

.app--mode-terminal .tsn-bar--h6 > svg {
	height: 6px;
}

.app--mode-terminal .tsn-grid {
	stroke: var(--tm-line);
	stroke-width: 1;
}

.app--mode-terminal .tsn-zero {
	stroke: rgba(255, 255, 255, 0.2);
	stroke-width: 1;
}

.app--mode-terminal .tsn-stat {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.app--mode-terminal .tsn-stat__k {
	font-size: 10.5px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--tm-ink-4);
}

.app--mode-terminal .tsn-stat__v {
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 14px;
	color: var(--tm-ink-2);
}

.app--mode-terminal .tsn-stat__v--lg {
	font-size: 14.5px;
	font-weight: 600;
}

.app--mode-terminal .tsn-foot {
	display: flex;
	gap: 24px;
	padding-top: 14px;
	border-top: 1px solid var(--tm-hair);
}

/* ── plotted charts (y labels down the right edge) ────────────────────────── */

.app--mode-terminal .tsn-plot {
	display: flex;
	align-items: flex-start;
	gap: 12px;
}

.app--mode-terminal .tsn-plot__main {
	flex: 1;
	min-width: 0;
}

/* Height comes from `plotted()` inline — it has to match the chart it labels,
   and it has no content of its own to size from. Without it every label stacks
   on the first line. */
.app--mode-terminal .tsn-plot__y {
	position: relative;
	width: 34px;
	flex: none;
}

.app--mode-terminal .tsn-plot__y > span {
	position: absolute;
	right: 0;
	transform: translateY(-50%);
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 11px;
	color: var(--tm-ink-4);
}

.app--mode-terminal .tsn-plot__x {
	display: grid;
	margin-top: 9px;
}

.app--mode-terminal .tsn-plot__x > span {
	grid-row: 1;
	justify-self: center;
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 11px;
	white-space: nowrap;
	color: var(--tm-ink-4);
}

.app--mode-terminal .tsn-hist > svg {
	height: 168px;
}

.app--mode-terminal .tsn-monitor > svg {
	height: 196px;
}

.app--mode-terminal .tsn-spark > svg {
	height: 54px;
}

.app--mode-terminal .tsn-monitor__px {
	stroke: rgba(255, 255, 255, 0.3);
	stroke-width: 1.2;
	stroke-dasharray: 4 4;
}

.app--mode-terminal .tsn-keys {
	display: flex;
	align-items: center;
	gap: 20px;
	font-size: 12px;
	color: var(--tm-ink-4);
}

.app--mode-terminal .tsn-key {
	display: inline-flex;
	align-items: center;
	gap: 7px;
}

.app--mode-terminal .tsn-key__line {
	width: 14px;
	height: 2px;
	border-radius: 2px;
	flex: none;
}

.app--mode-terminal .tsn-key__line--dash {
	background: repeating-linear-gradient(
		90deg,
		rgba(255, 255, 255, 0.4) 0 4px,
		transparent 4px 8px
	);
}

/* ── mentions ─────────────────────────────────────────────────────────────── */

.app--mode-terminal .tsn-src {
	display: grid;
	grid-template-columns: 88px minmax(0, 1fr) 60px;
	align-items: center;
	gap: 12px;
}

.app--mode-terminal .tsn-src__k {
	font-size: 12.5px;
	white-space: nowrap;
	color: var(--tm-ink-3);
}

.app--mode-terminal .tsn-src__n {
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 12.5px;
	text-align: right;
	color: var(--tm-ink-2);
}

.app--mode-terminal .tsn-topics {
	display: flex;
	flex-direction: column;
}

.app--mode-terminal .tsn-topic {
	display: grid;
	grid-template-columns: 16px minmax(0, 1fr);
	gap: 4px 10px;
	padding: 9px 0;
	box-shadow: inset 0 -1px 0 var(--tm-line-2);
}

.app--mode-terminal .tsn-topic__r {
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 11px;
	color: var(--tm-ink-5);
}

.app--mode-terminal .tsn-topic__t {
	font-size: 13px;
	line-height: 1.35;
	text-wrap: pretty;
	color: var(--tm-ink);
}

.app--mode-terminal .tsn-topic__m {
	grid-column: 2;
	display: flex;
	align-items: baseline;
	gap: 10px;
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 12px;
	color: var(--tm-ink-3);
}

/* ── sentiment ────────────────────────────────────────────────────────────── */

.app--mode-terminal .tsn-scale {
	display: flex;
	justify-content: space-between;
	font-family: var(--tm-mono);
	font-size: 10.5px;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--tm-ink-5);
}

.app--mode-terminal .tsn-sig {
	display: grid;
	grid-template-columns: 58px minmax(0, 1fr) 76px;
	align-items: baseline;
	gap: 12px;
	padding: 12px 22px;
	box-shadow: inset 0 -1px 0 var(--tm-line-2);
}

.app--mode-terminal .tsn-sig__t {
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 11.5px;
	color: var(--tm-ink-4);
}

.app--mode-terminal .tsn-sig__body {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.app--mode-terminal .tsn-sig__n {
	font-size: 13.5px;
	line-height: 1.4;
	color: var(--tm-ink);
}

.app--mode-terminal .tsn-sig__d {
	font-size: 12px;
	color: var(--tm-ink-4);
}

.app--mode-terminal .tsn-sig__dir {
	font-family: var(--tm-mono);
	font-size: 10.5px;
	font-weight: 600;
	letter-spacing: 0.07em;
	text-transform: uppercase;
	text-align: center;
	padding: 4px 0;
	border-radius: 6px;
}

/* ── fundamental ──────────────────────────────────────────────────────────── */

.app--mode-terminal .tsn-quant {
	display: flex;
	align-items: center;
	gap: 18px;
}

.app--mode-terminal .tsn-quant__dial {
	width: 100px;
	flex: none;
}

.app--mode-terminal .tsn-quant__track {
	stroke: var(--tm-line);
}

.app--mode-terminal .tsn-quant__id {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.app--mode-terminal .tsn-quant__grade {
	font-family: var(--tm-mono);
	font-size: 32px;
	font-weight: 600;
	letter-spacing: -0.02em;
}

.app--mode-terminal .tsn-quant__score {
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 13px;
	color: var(--tm-ink-2);
}

.app--mode-terminal .tsn-quant__rank {
	font-size: 12px;
	color: var(--tm-ink-4);
}

.app--mode-terminal .tsn-factor {
	display: grid;
	grid-template-columns: 84px minmax(0, 1fr) 38px;
	align-items: center;
	gap: 12px;
}

.app--mode-terminal .tsn-factor__k {
	font-size: 12.5px;
	color: var(--tm-ink-3);
}

.app--mode-terminal .tsn-factor__v {
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 12.5px;
	text-align: right;
	color: var(--tm-ink-2);
}

/* The target-price rail: the bar overflows its box so the two markers can hang
   past it, and the range ends are absolutely placed under them. */
.app--mode-terminal .tsn-target {
	position: relative;
	height: 32px;
}

.app--mode-terminal .tsn-target__bar > svg {
	height: 8px;
	overflow: visible;
}

.app--mode-terminal .tsn-target__lo,
.app--mode-terminal .tsn-target__hi {
	position: absolute;
	top: 16px;
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 11px;
	color: var(--tm-ink-4);
}

.app--mode-terminal .tsn-target__lo {
	left: 0;
}

.app--mode-terminal .tsn-target__hi {
	right: 0;
}

.app--mode-terminal .tsn-data {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 14px;
	padding: 9px 22px;
	box-shadow: inset 0 -1px 0 var(--tm-line-2);
}

.app--mode-terminal .tsn-now {
	display: flex;
	flex-direction: column;
	gap: 7px;
}

.app--mode-terminal .tsn-now__top {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
}

.app--mode-terminal .tsn-now__fig {
	display: flex;
	align-items: baseline;
	gap: 8px;
}

.app--mode-terminal .tsn-now__v {
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 14px;
	font-weight: 600;
	color: var(--tm-ink);
}

.app--mode-terminal .tsn-now__d {
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 11.5px;
}

/* ── technical ────────────────────────────────────────────────────────────── */

.app--mode-terminal .tsn-insight {
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: 22px 24px 20px;
	border: 1px solid var(--tm-line);
	border-radius: 16px;
	background: rgba(255, 255, 255, 0.022);
}

/* The two insight cards are the only tinted panels in the section — the tint is
   DIRECTION (the call is bullish or bearish), which is why it is live/loss and
   never the accent. */
.app--mode-terminal .tsn-insight--up {
	border-color: rgba(62, 207, 142, 0.24);
	background: linear-gradient(160deg, rgba(62, 207, 142, 0.08), rgba(255, 255, 255, 0.016) 55%);
}

.app--mode-terminal .tsn-insight--down {
	border-color: rgba(255, 107, 94, 0.24);
	background: linear-gradient(160deg, rgba(255, 107, 94, 0.08), rgba(255, 255, 255, 0.016) 55%);
}

.app--mode-terminal .tsn-insight__top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.app--mode-terminal .tsn-insight__kicker {
	font-family: var(--tm-mono);
	font-size: 10.5px;
	font-weight: 600;
	letter-spacing: 0.11em;
	text-transform: uppercase;
}

.app--mode-terminal .tsn-insight__views {
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 11.5px;
	color: var(--tm-ink-4);
}

.app--mode-terminal .tsn-insight__t {
	margin: 0;
	font-size: 19px;
	font-weight: 700;
	letter-spacing: -0.022em;
	line-height: 1.28;
	color: var(--tm-ink);
}

.app--mode-terminal .tsn-insight__b {
	margin: 0;
	font-size: 13.5px;
	line-height: 1.55;
	color: var(--tm-ink-3);
}

.app--mode-terminal .tsn-tags {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.app--mode-terminal .tsn-tag {
	font-family: var(--tm-mono);
	font-size: 11px;
	letter-spacing: 0.04em;
	padding: 4px 9px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.055);
	color: var(--tm-ink-2);
}

.app--mode-terminal .tsn-insight__stats {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 12px;
	margin-top: auto;
	padding-top: 16px;
	border-top: 1px solid var(--tm-line);
}

.app--mode-terminal .tsn-tile {
	display: flex;
	flex-direction: column;
	gap: 11px;
	padding: 18px 20px;
	border: 1px solid var(--tm-line);
	border-radius: 16px;
	background: rgba(255, 255, 255, 0.022);
}

.app--mode-terminal .tsn-tile__k {
	font-size: 10.5px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--tm-ink-4);
}

.app--mode-terminal .tsn-tile__v {
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 22px;
	font-weight: 600;
	letter-spacing: -0.025em;
}

/* ── responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 1280px) {
	.app--mode-terminal .tsn-split--fund {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.app--mode-terminal .tsn-split--fund > :last-child {
		grid-column: span 2;
	}
}

@media (max-width: 1080px) {
	.app--mode-terminal .tsn-split--sent,
	.app--mode-terminal .tsn-grid3,
	.app--mode-terminal .tsn-grid2 {
		grid-template-columns: minmax(0, 1fr);
	}

	.app--mode-terminal .tsn-card--wide {
		grid-column: auto;
	}
}

@media (max-width: 760px) {
	.app--mode-terminal .tsn-split--fund,
	.app--mode-terminal .tsn-split--fund > :last-child {
		grid-column: auto;
		grid-template-columns: minmax(0, 1fr);
	}

	.app--mode-terminal .tsn-tabs {
		overflow-x: auto;
	}

	.app--mode-terminal .tms-cheat__row {
		grid-template-columns: 14px 54px minmax(0, 1fr) 66px 74px;
		gap: 8px;
		padding-inline: 16px;
	}
}

/* ── the full level sheet, as a modal ─────────────────────────────────────────
   The rail's Cheat sheet shows six rungs; its expand control opens the whole
   ladder (stock.ts `buildLevels`) in the middle of the page.

   The overlay hangs off <body>, NOT off the terminal page — the page is its own
   scroll container, so an overlay inside it scrolls away with the content. That
   also puts it outside `.app--mode-terminal`, which is why this block is the one
   part of this sheet not scoped under it, and why it re-declares the tokens it
   needs rather than inheriting them. */

.tms-modal {
	position: fixed;
	inset: 0;
	z-index: 200;
	display: grid;
	place-items: center;
	padding: clamp(16px, 4vh, 48px) clamp(16px, 4vw, 48px);
	background: rgba(4, 5, 5, 0.72);
	backdrop-filter: blur(3px);
	animation: tms-modal-in 0.16s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes tms-modal-in {
	from {
		opacity: 0;
	}
}

.tms-modal__box {
	position: relative;
	width: min(760px, 100%);
	max-height: 100%;
	overflow-y: auto;
	overscroll-behavior: contain;
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 18px;
	background: #0a0a0b;
	box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.7);
}

/* The ladder brings its own card chrome, so the box only supplies the frame. */
.tms-modal__box > .tms-lvl {
	border: 0;
	border-radius: 0;
	background: none;
}

.tms-modal__x {
	position: absolute;
	top: 14px;
	right: 14px;
	z-index: 1;
	display: grid;
	place-items: center;
	width: 30px;
	height: 30px;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 9px;
	background: rgba(255, 255, 255, 0.03);
	color: #9a9c9e;
	cursor: pointer;
	transition: background 0.16s cubic-bezier(0.32, 0.72, 0, 1), color 0.16s cubic-bezier(0.32, 0.72, 0, 1);
}

.tms-modal__x:hover {
	background: rgba(255, 255, 255, 0.07);
	color: #f0f0f0;
}

/* The expand control, when it actually does something. */
.app--mode-terminal .tms-panel__expand--live {
	display: grid;
	place-items: center;
	padding: 3px;
	margin: -3px;
	border: 0;
	border-radius: 7px;
	background: none;
	color: inherit;
	cursor: pointer;
	transition: background 0.16s var(--tm-ease), color 0.16s var(--tm-ease);
}

.app--mode-terminal .tms-panel__expand--live:hover {
	background: rgba(255, 255, 255, 0.07);
	color: var(--tm-ink);
}

/* Room for the ✕ — the ladder's header runs full width on the page, where
   nothing sits in its corner. */
.tms-modal__box > .tms-lvl > .tms-lvl__top {
	padding-right: 56px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ANALYTICS REFINEMENT PASS (2026-09-04) — appended, because this sheet loads
   after terminal-stock-polish.css and would otherwise win on every selector it
   shares. Precision only: alignment, rhythm, semantic colour, number style.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── section header + tabs ─────────────────────────────────────────────────
   The eyebrow and the switcher sat on different baselines. Centre-aligned now,
   with every tab the same height and the same inner padding. */
.app--mode-terminal .tsn-top {
	align-items: center;
}

.app--mode-terminal .tsn-eyebrow {
	font-size: 10px;
	line-height: 1;
	font-weight: 600;
	letter-spacing: 0.11em;
	color: var(--tm-ink-4);
}

.app--mode-terminal .tsn-tabs {
	gap: 2px;
	padding: 3px;
	border-radius: var(--tm-r-md);
	background: rgba(255, 255, 255, 0.025);
}

.app--mode-terminal .tsn-tab {
	height: 30px;
	padding: 0 12px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 7px;
	font-size: 12.5px;
	font-weight: 600;
	transition:
		background 0.15s var(--tm-ease-ui),
		color 0.15s var(--tm-ease-ui);
}

.app--mode-terminal .tsn-tab:not(.is-on):hover {
	background: rgba(255, 255, 255, 0.035);
	color: var(--tm-ink-2);
}

/* ── cards ─────────────────────────────────────────────────────────────────
   One surface, one border, one radius, one padding. Content-driven height —
   the row rhythm comes from the grid, not from stretching four cards to the
   tallest and leaving three of them half empty. */
.app--mode-terminal .tsn-card {
	padding: 20px;
	border-radius: var(--tm-r-lg);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.012);
}

.app--mode-terminal .tsn-card--rows {
	padding: 20px 0 8px;
}

.app--mode-terminal .tsn-card__t--inset {
	padding: 0 20px 12px;
}

.app--mode-terminal .tsn-card__t {
	font-size: 10px;
	line-height: 1;
	font-weight: 600;
	letter-spacing: 0.11em;
	color: var(--tm-ink-4);
}

.app--mode-terminal .tsn-card__cap {
	font-size: 10px;
	line-height: 1;
	color: var(--tm-ink-5);
}

.app--mode-terminal .tsn-grid4,
.app--mode-terminal .tsn-grid3,
.app--mode-terminal .tsn-grid2,
.app--mode-terminal .tsn-split,
.app--mode-terminal .tsn-tiles,
.app--mode-terminal .tsn-stack,
.app--mode-terminal .tsn-body {
	gap: 14px;
	align-items: start;
}

/* ── numbers ───────────────────────────────────────────────────────────────
   Every figure in the section, one style. `lining-nums` matters as much as
   tabular here: the face has old-style figures available, and a column that
   mixes them never lines up however equal the widths are. */
.app--mode-terminal .tsn-big,
.app--mode-terminal .tsn-chip,
.app--mode-terminal .tsn-kv__v,
.app--mode-terminal .tsn-src__n,
.app--mode-terminal .tsn-factor__v,
.app--mode-terminal .tsn-quant__score,
.app--mode-terminal .tsn-tile__v,
.app--mode-terminal .tsn-now__v,
.app--mode-terminal .tsn-now__d,
.app--mode-terminal .tsn-stat__v,
.app--mode-terminal .tsn-sig__t,
.app--mode-terminal .tsn-topic__m,
.app--mode-terminal .tsn-plot__x > span,
.app--mode-terminal .tsn-plot__y > span,
.app--mode-terminal .tsn-target__lo,
.app--mode-terminal .tsn-target__hi {
	font-variant-numeric: tabular-nums lining-nums;
}

.app--mode-terminal .tsn-big {
	font-weight: 600;
	letter-spacing: -0.03em;
}

/* ── contrast ──────────────────────────────────────────────────────────────
   Explanatory copy was set at the faint level. Nothing a reader has to READ
   lives there — faint is for units, axis ticks and decoration. */
.app--mode-terminal .tsn-note,
.app--mode-terminal .tsn-sig__d {
	font-size: 12.5px;
	line-height: 1.55;
	color: var(--tm-ink-4);
}

.app--mode-terminal .tsn-sample {
	color: var(--tm-ink-5);
}

/* ── meters ────────────────────────────────────────────────────────────────
   One height, one radius, one track opacity across gauges, factors, sources and
   nowcasting. They were three different bars doing one job. */
.app--mode-terminal .tsn-bar--h8 > svg,
.app--mode-terminal .tsn-bar--h6 > svg {
	height: 7px;
}

.app--mode-terminal .tsn-bar__track {
	fill: rgba(255, 255, 255, 0.055);
}

.app--mode-terminal .tsn-src,
.app--mode-terminal .tsn-factor {
	min-height: 22px;
}

/* ── signals list ──────────────────────────────────────────────────────────
   Fixed time column, one badge geometry. Kept a list, not converted to cards. */
.app--mode-terminal .tsn-sig {
	padding: 12px 20px;
	transition: background 0.14s var(--tm-ease-ui);
}

.app--mode-terminal .tsn-sig:hover {
	background: rgba(255, 255, 255, 0.02);
}

.app--mode-terminal .tsn-sig__n {
	font-size: 13.5px;
	font-weight: 500;
	color: var(--tm-ink);
}

.app--mode-terminal .tsn-sig__dir {
	height: 22px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0 8px;
	border-radius: 6px;
	font-size: 10.5px;
	font-weight: 600;
	letter-spacing: 0.07em;
}

/* ── topics ────────────────────────────────────────────────────────────────
   The rank column was elastic, so six rows had six left edges. */
.app--mode-terminal .tsn-topic {
	grid-template-columns: 18px minmax(0, 1fr);
	padding: 10px 0;
}

.app--mode-terminal .tsn-topic__t {
	font-size: 13px;
	font-weight: 500;
	color: var(--tm-ink);
}

/* ── data rows ─────────────────────────────────────────────────────────────
   Key data and the kv lists share a row height and a divider. */
.app--mode-terminal .tsn-data {
	min-height: 38px;
	padding: 9px 20px;
}

.app--mode-terminal .tsn-kv__k {
	font-size: 12.5px;
	color: var(--tm-ink-3);
}

/* ── technical tiles ───────────────────────────────────────────────────────
   THE MICRO-CONSISTENCY FIX. Six cards whose labels, values, badges and meters
   each sat 2–3px off their neighbours, because every card sized itself to its
   own content. A fixed three-row track puts all of them on shared baselines,
   and the meter is pinned to the bottom of every card. */
.app--mode-terminal .tsn-tile {
	display: grid;
	grid-template-rows: auto auto auto;
	gap: 10px;
	min-height: 106px;
	padding: 18px 18px 16px;
	border-radius: var(--tm-r-lg);
}

.app--mode-terminal .tsn-tile .tsn-fig__row {
	align-items: center;
}

.app--mode-terminal .tsn-tile__v {
	font-size: 21px;
	font-weight: 600;
	letter-spacing: -0.025em;
}

.app--mode-terminal .tsn-tile .tsn-bar--h6 {
	align-self: end;
}

.app--mode-terminal .tsn-chip--sm {
	height: 20px;
	display: inline-flex;
	align-items: center;
	padding: 0 7px;
	border-radius: 6px;
	font-size: 10.5px;
	font-weight: 600;
}

/* ── insight cards ─────────────────────────────────────────────────────────
   The semantic tint comes down: an outline with a breath of colour, not a
   coloured card. */
.app--mode-terminal .tsn-insight {
	padding: 20px 22px 18px;
	border-radius: var(--tm-r-lg);
}

.app--mode-terminal .tsn-insight--up {
	border-color: rgba(62, 207, 142, 0.28);
	background: linear-gradient(180deg, rgba(62, 207, 142, 0.035), rgba(62, 207, 142, 0)), rgba(255, 255, 255, 0.02);
}

.app--mode-terminal .tsn-insight--down {
	border-color: rgba(255, 107, 94, 0.27);
	background: linear-gradient(180deg, rgba(255, 107, 94, 0.035), rgba(255, 107, 94, 0)), rgba(255, 255, 255, 0.02);
}

.app--mode-terminal .tsn-insight__t {
	font-size: 18px;
	font-weight: 600;
	letter-spacing: -0.022em;
}

.app--mode-terminal .tsn-insight__b {
	font-size: 13px;
	line-height: 1.55;
	color: var(--tm-ink-3);
}

/* ── quant ring ────────────────────────────────────────────────────────────
   Grade and score share a vertical centre with the ring. */
.app--mode-terminal .tsn-quant {
	align-items: center;
	gap: 20px;
}

.app--mode-terminal .tsn-quant__grade {
	font-size: 30px;
	font-weight: 600;
	letter-spacing: -0.02em;
	line-height: 1;
}

/* ── responsive ────────────────────────────────────────────────────────────
   The section already collapses; this keeps the gaps on the scale and stops the
   four-tab switcher from wrapping. */
@media (max-width: 1080px) {
	.app--mode-terminal .tsn-tabs {
		max-width: 100%;
		overflow-x: auto;
		scrollbar-width: none;
	}

	.app--mode-terminal .tsn-tabs::-webkit-scrollbar {
		display: none;
	}
}
