/* Terminal — the instrument panel.
 *
 * The rest of alphapinelab.com is light, airy and Apple-adjacent. This page
 * deliberately is not. A trading terminal earns trust through density: hairline
 * rules instead of cards, monospaced tabular figures instead of a display face,
 * uppercase micro-labels, and a dark ground so that colour means something
 * rather than decorating. The dark shell sits inside the ordinary site chrome,
 * which is what makes it read as an instrument rather than a different website.
 *
 * Colour carries exactly three meanings and never more:
 *   green   the model reads bullish
 *   red     the model reads bearish
 *   amber   caution — thin sample, stale data, a gate that is not satisfied
 * Everything else is neutral. Anything the model cannot support is rendered in
 * the muted tone with an em dash, never as a confident zero.
 */

/* Both themes are defined as the same token set, so every rule below — and the
   canvas, which reads these same custom properties at draw time — is written
   once and themed once. Adding a third theme would mean adding one block here
   and nothing else.

   The text ramp carries three steps and only three: `text` for values, `muted`
   for the labels that name them, `faint` for units and qualifiers. Each step is
   held above 4.5:1 against its own ground so the 9px micro-labels stay legible
   rather than merely present, which is where the first dark pass fell short. */
.terminal-page {
  --t-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

.terminal-shell[data-theme="dark"] {
  --t-bg: #090b0e;
  --t-shell: #0d1014;
  --t-panel: #11151b;
  --t-panel-raised: #171d26;
  --t-line: rgba(255, 255, 255, 0.08);
  --t-line-strong: rgba(255, 255, 255, 0.16);
  --t-text: #edf0f5;
  --t-muted: #9aa4b2;
  --t-faint: #808a99;
  --t-amber: #efad4a;
  --t-cyan: #63b2e4;
  --t-long: #2bc482;
  --t-short: #ec6058;

  --tc-grid: rgba(255, 255, 255, 0.055);
  --tc-axis: rgba(255, 255, 255, 0.13);
  --tc-band-fill: rgba(99, 178, 228, 0.075);
  --tc-band-line: rgba(99, 178, 228, 0.34);
  --tc-basis: rgba(237, 240, 245, 0.3);
  --tc-fast: rgba(239, 173, 74, 0.85);
  --tc-slow: rgba(154, 164, 178, 0.62);
  --tc-vol-up: rgba(43, 196, 130, 0.55);
  --tc-vol-down: rgba(236, 96, 88, 0.55);
  --tc-lane: rgba(255, 255, 255, 0.03);
  --tc-crosshair: rgba(237, 240, 245, 0.4);
  --tc-plate: rgba(9, 11, 14, 0.86);
  --tc-tag-ink: #090b0e;
  --tc-ladder-fill: rgba(154, 164, 178, 0.09);
  --tc-ladder-line: rgba(237, 240, 245, 0.2);
  --tc-pulse-up: rgba(43, 196, 130, 0.22);
  --tc-pulse-down: rgba(236, 96, 88, 0.22);

  --t-hairline: rgba(255, 255, 255, 0.045);
  --t-track: rgba(255, 255, 255, 0.07);
  --t-overlay: rgba(23, 29, 38, 0.94);
  --t-drop-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  --t-accent-soft: rgba(239, 173, 74, 0.1);
  --t-accent-wash: rgba(239, 173, 74, 0.045);
  --t-accent-ring: rgba(239, 173, 74, 0.34);
  --t-accent-halo: rgba(239, 173, 74, 0.16);
  --t-long-ring: rgba(43, 196, 130, 0.42);
}

/* Not an inversion of the dark palette. Saturated greens and reds that read
   correctly on near-black go muddy on near-white, so the directional pair is
   darkened rather than lightened, and the band fill is warmed to keep it from
   disappearing into the page. */
.terminal-shell[data-theme="light"] {
  --t-bg: #f7f8fa;
  --t-shell: #eef0f4;
  --t-panel: #ffffff;
  --t-panel-raised: #f0f2f6;
  --t-line: rgba(18, 22, 28, 0.1);
  --t-line-strong: rgba(18, 22, 28, 0.2);
  --t-text: #12161c;
  --t-muted: #545d6a;
  --t-faint: #656d7a;
  --t-amber: #a56a09;
  --t-cyan: #1f6fa8;
  --t-long: #0b7d4d;
  --t-short: #c2352d;

  --tc-grid: rgba(18, 22, 28, 0.07);
  --tc-axis: rgba(18, 22, 28, 0.18);
  --tc-band-fill: rgba(31, 111, 168, 0.07);
  --tc-band-line: rgba(31, 111, 168, 0.32);
  --tc-basis: rgba(18, 22, 28, 0.34);
  --tc-fast: rgba(165, 106, 9, 0.9);
  --tc-slow: rgba(84, 93, 106, 0.6);
  --tc-vol-up: rgba(11, 125, 77, 0.5);
  --tc-vol-down: rgba(194, 53, 45, 0.5);
  --tc-lane: rgba(18, 22, 28, 0.028);
  --tc-crosshair: rgba(18, 22, 28, 0.45);
  --tc-plate: rgba(247, 248, 250, 0.9);
  --tc-tag-ink: #ffffff;
  --tc-ladder-fill: rgba(84, 93, 106, 0.1);
  --tc-ladder-line: rgba(18, 22, 28, 0.24);
  --tc-pulse-up: rgba(11, 125, 77, 0.18);
  --tc-pulse-down: rgba(194, 53, 45, 0.18);

  --t-hairline: rgba(18, 22, 28, 0.075);
  --t-track: rgba(18, 22, 28, 0.09);
  --t-overlay: rgba(255, 255, 255, 0.95);
  --t-drop-shadow: 0 18px 44px rgba(18, 22, 28, 0.16);
  --t-accent-soft: rgba(165, 106, 9, 0.11);
  --t-accent-wash: rgba(165, 106, 9, 0.05);
  --t-accent-ring: rgba(165, 106, 9, 0.4);
  --t-accent-halo: rgba(165, 106, 9, 0.18);
  --t-long-ring: rgba(11, 125, 77, 0.45);
}

/* The stylesheet carries no screen-reader utility of its own, so the Terminal
   defines the one it needs rather than shipping an unlabelled search field. */
.terminal-page .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- Page intro (stays in the site's light language) --------------------- */

.terminal-intro {
  padding: 64px 0 8px;
  text-align: center;
}

.terminal-intro h1 {
  margin: 18px 0 14px;
  font-size: clamp(2.1rem, 4.4vw, 3.1rem);
  letter-spacing: -0.02em;
  line-height: 1.06;
}

.terminal-intro p {
  max-width: 660px;
  margin: 0 auto;
  font-size: 1.02rem;
}

.terminal-intro .eyebrow-pill {
  margin: 0 auto;
}

/* --- Shell --------------------------------------------------------------- */

/* The terminal opens the page and spans the window edge to edge. A centred
   card with margins either side reads as a screenshot of a product; filling
   the viewport reads as the product. The rounded corners and side borders go
   with the margins — there is nothing left for them to sit against. */
.terminal-stage {
  width: 100%;
}

.terminal-shell {
  overflow: hidden;
  border-bottom: 1px solid var(--t-line);
  background: var(--t-bg);
  color: var(--t-text);
  font-family: var(--t-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
}

.terminal-shell p {
  color: var(--t-muted);
}

/* --- Command bar --------------------------------------------------------- */

.terminal-command {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--t-line);
  background: var(--t-shell);
}

.terminal-mark {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
  padding-right: 14px;
  border-right: 1px solid var(--t-line);
  color: var(--t-amber);
  font-size: 10px;
  letter-spacing: 0.16em;
}

.terminal-mark span {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--t-amber);
  box-shadow: 0 0 0 3px var(--t-accent-halo);
}

.terminal-search {
  position: relative;
  flex: 1;
  min-width: 0;
}

.terminal-search input {
  width: 100%;
  padding: 9px 78px 9px 34px;
  border: 1px solid var(--t-line-strong);
  border-radius: 6px;
  background: var(--t-panel);
  color: var(--t-text);
  font: inherit;
  letter-spacing: 0.02em;
}

.terminal-search input::placeholder {
  color: var(--t-faint);
}

/* The browser's own clear button lands on top of the shortcut badge. Escape
   already clears the field, so the native control is redundant here. */
.terminal-search input::-webkit-search-cancel-button {
  display: none;
}

.terminal-search input:focus {
  border-color: var(--t-accent-ring);
  outline: none;
  box-shadow: 0 0 0 3px var(--t-accent-soft);
}

.terminal-search-icon {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 13px;
  height: 13px;
  color: var(--t-faint);
  transform: translateY(-50%);
  pointer-events: none;
}

.terminal-search kbd {
  position: absolute;
  top: 50%;
  right: 10px;
  padding: 2px 6px;
  border: 1px solid var(--t-line-strong);
  border-radius: 4px;
  color: var(--t-faint);
  font-family: inherit;
  font-size: 10px;
  transform: translateY(-50%);
  pointer-events: none;
}

.terminal-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--t-line-strong);
  border-radius: 8px;
  background: var(--t-panel-raised);
  box-shadow: var(--t-drop-shadow);
}

.terminal-results:empty,
.terminal-results[hidden] {
  display: none;
}

.terminal-result {
  display: grid;
  grid-template-columns: minmax(88px, auto) 1fr auto;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  padding: 9px 13px;
  border: 0;
  border-bottom: 1px solid var(--t-line);
  background: none;
  color: var(--t-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.terminal-result:last-child {
  border-bottom: 0;
}

.terminal-result:hover,
.terminal-result[aria-selected="true"] {
  background: var(--t-accent-soft);
}

.terminal-result b {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.terminal-result i {
  overflow: hidden;
  color: var(--t-muted);
  font-style: normal;
  font-size: 11px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.terminal-result em {
  color: var(--t-faint);
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.terminal-timeframes {
  display: flex;
  flex-shrink: 0;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--t-line);
  border-radius: 6px;
  background: var(--t-panel);
}

.terminal-timeframes button {
  padding: 6px 12px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--t-muted);
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.terminal-timeframes button:hover {
  color: var(--t-text);
}

.terminal-timeframes button:disabled {
  color: var(--t-faint);
  cursor: not-allowed;
  opacity: 0.42;
}

.terminal-timeframes button:disabled:hover {
  color: var(--t-faint);
}

.terminal-timeframes button[aria-pressed="true"] {
  background: var(--t-panel-raised);
  color: var(--t-amber);
  box-shadow: inset 0 0 0 1px var(--t-accent-ring);
}

/* A pill of three: match system, force light, force dark. The active choice
   takes a filled disc rather than a rounded rectangle, so the control reads as
   one switch with a position instead of three separate buttons. */
.terminal-theme {
  display: flex;
  flex-shrink: 0;
  gap: 1px;
  padding: 3px;
  border: 1px solid var(--t-line-strong);
  border-radius: 999px;
  background: var(--t-panel);
}

.terminal-theme button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--t-faint);
  font: inherit;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.terminal-theme button:hover {
  color: var(--t-text);
}

.terminal-theme button:focus-visible {
  outline: 2px solid var(--t-amber);
  outline-offset: 1px;
}

.terminal-theme button[aria-pressed="true"] {
  background: var(--t-panel-raised);
  color: var(--t-amber);
  box-shadow: inset 0 0 0 1px var(--t-accent-ring);
}

.terminal-theme svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.6;
}

/* --- Ticker strip -------------------------------------------------------- */

.terminal-ticker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 22px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--t-line);
  background: linear-gradient(180deg, var(--t-accent-wash), transparent);
}

/* Identity stacks: the ticker and its long name on top, the provenance tags
   underneath. Inline, the exchange tag alone ran to 189px and pushed a third
   of the OHLC strip onto a second row; stacked, it costs height the price
   block already occupies and costs nothing horizontally. */
.terminal-ticker-id {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.terminal-ticker-name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 10px;
}

.terminal-ticker-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.terminal-ticker-id strong {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.terminal-ticker-name span {
  overflow: hidden;
  max-width: 34ch;
  color: var(--t-muted);
  font-size: 11px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* The measured strip, packed to the right so it reads as one block against
   the identity and price on the left. Below roughly 1450px the last cells
   wrap; right-packing keeps both lines flush to the same edge. Spreading them
   with space-between instead looked even on a full row but flung the two
   leftovers to opposite margins the moment it wrapped. */
.terminal-ticker-stats {
  display: flex;
  flex: 1 1 420px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px 22px;
}

.terminal-price {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.terminal-price b {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.terminal-price i {
  font-style: normal;
  font-size: 13px;
}

.terminal-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.terminal-stat u {
  color: var(--t-faint);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-decoration: none;
  text-transform: uppercase;
}

.terminal-stat b {
  font-weight: 500;
  font-size: 12px;
}

.terminal-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border: 1px solid var(--t-line-strong);
  border-radius: 4px;
  color: var(--t-muted);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.terminal-tag[data-tone="warn"] {
  border-color: var(--t-accent-ring);
  color: var(--t-amber);
}

.terminal-tag[data-tone="live"] {
  border-color: var(--t-long-ring);
  color: var(--t-long);
}

.terminal-tag[data-tone="info"] {
  border-color: rgba(67, 149, 210, 0.4);
  color: #70b7e8;
}

/* --- Layout grid --------------------------------------------------------- */

.terminal-body {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
}

.terminal-verdict {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--t-line);
}

.terminal-chartwrap {
  position: relative;
  display: flex;
  min-width: 0;
}

.terminal-modules {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--t-line);
}

/* --- Module chrome ------------------------------------------------------- */

.tm {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 14px 16px 16px;
  border-right: 1px solid var(--t-line);
  border-bottom: 1px solid var(--t-line);
  background: var(--t-bg);
}

.tm[data-span="2"] { grid-column: span 2; }
.tm[data-span="4"] { grid-column: 1 / -1; }

.tm-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--t-line);
}

.tm-head h3 {
  margin: 0;
  color: var(--t-text);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.tm-head span {
  color: var(--t-faint);
  font-size: 9px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  white-space: nowrap;
}

.tm-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 10px;
  padding: 5px 0;
}

.tm-row + .tm-row {
  border-top: 1px solid var(--t-hairline);
}

.tm-row dt {
  min-width: 0;
  overflow: hidden;
  color: var(--t-muted);
  font-size: 11px;
  font-weight: 400;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tm-row dd {
  margin: 0;
  color: var(--t-text);
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  text-align: right;
  white-space: nowrap;
}

.tm-row dd small {
  display: block;
  margin-top: 1px;
  color: var(--t-faint);
  font-size: 9.5px;
  font-weight: 400;
  letter-spacing: 0.05em;
}

.tm dl {
  margin: 0;
}

.tm-note {
  margin: 12px 0 0;
  color: var(--t-faint);
  font-size: 10px;
  line-height: 1.5;
}

/* Scoped to the shell so these outrank `.tm-row dd`, which sets its own colour
   and would otherwise win on specificity and neutralise every tone. */
.terminal-shell .pos { color: var(--t-long); }
.terminal-shell .neg { color: var(--t-short); }
.terminal-shell .warn { color: var(--t-amber); }
.terminal-shell .mute { color: var(--t-faint); }

/* --- Verdict column ------------------------------------------------------ */

.terminal-verdict-main {
  padding: 20px 18px 18px;
  border-bottom: 1px solid var(--t-line);
}

.terminal-verdict-label {
  color: var(--t-faint);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.terminal-verdict-state {
  margin: 8px 0 4px;
  font-size: clamp(1.4rem, 2.4vw, 1.85rem);
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.05;
}

.terminal-verdict-sub {
  color: var(--t-muted);
  font-size: 11px;
}

/* Signed meter: the zero line is fixed at the centre so a glance at where the
   bar starts tells you the sign before you read the number. */
.meter-wrap {
  position: relative;
  margin: 14px 0 8px;
}

.meter-graphic {
  display: block;
  width: 100%;
  height: 24px;
  overflow: visible;
  stroke: none;
}

.meter-value {
  fill: var(--t-muted);
  stroke: none;
  font-family: var(--t-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.meter-track {
  fill: var(--t-track);
  stroke: none;
}

.meter-zero {
  stroke: var(--t-line-strong);
  stroke-width: 1;
}

.meter-positive { fill: var(--t-long); }
.meter-negative { fill: var(--t-short); }
.meter-neutral { fill: var(--t-faint); }

.meter-scale {
  display: flex;
  justify-content: space-between;
  color: var(--t-faint);
  font-size: 9px;
  letter-spacing: 0.1em;
}

.terminal-verdict-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--t-line);
}

.terminal-verdict-grid > div {
  padding: 12px 16px;
  border-right: 1px solid var(--t-line);
  border-bottom: 1px solid var(--t-line);
}

.terminal-verdict-grid > div:nth-child(2n) { border-right: 0; }
.terminal-verdict-grid > div:nth-last-child(-n + 2) { border-bottom: 0; }

.terminal-verdict-grid u {
  display: block;
  color: var(--t-faint);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-decoration: none;
  text-transform: uppercase;
}

.terminal-verdict-grid b {
  display: block;
  margin-top: 3px;
  font-size: 15px;
  font-weight: 600;
}

.terminal-verdict-grid small {
  color: var(--t-faint);
  font-size: 9.5px;
}

/* Grade checklist: a pass/fail column reads faster than six sentences. */
.grade-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 14px 18px 10px;
}

.grade-letter {
  font-size: 30px;
  font-weight: 600;
  line-height: 1;
}

.grade-meta {
  color: var(--t-muted);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.grade-list {
  margin: 0;
  padding: 0 18px 18px;
  list-style: none;
}

.grade-list li {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 9px;
  padding: 5px 0;
  border-top: 1px solid var(--t-hairline);
  font-size: 11px;
}

.grade-list li span:first-child {
  font-weight: 600;
}

.grade-list li em {
  color: var(--t-faint);
  font-style: normal;
  font-size: 10px;
  white-space: nowrap;
}

/* The verdict column is shorter than the chart beside it. Rather than leave a
   dead gap, its tail carries the parameter set every number above was computed
   with — the one piece of context a trader would otherwise have to take on
   trust. `margin-top: auto` pins it to the bottom at any column height. */
.terminal-inputs {
  margin-top: auto;
  padding: 14px 18px 16px;
  border-top: 1px solid var(--t-line);
}

.terminal-inputs u {
  display: block;
  margin-bottom: 8px;
  color: var(--t-faint);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-decoration: none;
  text-transform: uppercase;
}

.terminal-inputs dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 14px;
  margin: 0;
}

.terminal-inputs div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 10.5px;
}

.terminal-inputs dt { color: var(--t-faint); }
.terminal-inputs dd { margin: 0; color: var(--t-muted); }

/* --- Chart --------------------------------------------------------------- */

.terminal-chart {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  /* Fills whatever height the verdict column beside it sets, with a floor so
     it never collapses when that column is short. */
  min-height: 460px;
}

.terminal-chart canvas {
  display: block;
  flex: 1;
  width: 100%;
  min-height: 0;
  touch-action: pan-y;
  cursor: crosshair;
}

.terminal-chart canvas.is-panning {
  cursor: grabbing;
}

.terminal-legend {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  max-width: calc(100% - 100px);
  color: var(--t-muted);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  pointer-events: none;
}

.terminal-legend b {
  color: var(--t-text);
  font-weight: 500;
}

.terminal-legend-key {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.terminal-legend-key::before {
  content: "";
  width: 10px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
}

.legend-ema-fast { color: var(--t-amber); }
.legend-ema-slow { color: var(--t-muted); }
.legend-band { color: var(--t-cyan); }

/* Appears only when the chart has been panned off the newest bar — a control
   that is always visible is a control that is usually pointless. */
.terminal-reset {
  position: absolute;
  z-index: 3;
  right: 74px;
  bottom: 30px;
  padding: 5px 11px;
  border: 1px solid var(--t-line-strong);
  border-radius: 5px;
  background: var(--t-overlay);
  color: var(--t-muted);
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

.terminal-reset:hover {
  border-color: var(--t-accent-ring);
  color: var(--t-amber);
}

/* --- Signal tape --------------------------------------------------------- */

.tape {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.tape th {
  padding: 0 10px 7px 0;
  color: var(--t-faint);
  font-weight: 400;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-align: left;
  text-transform: uppercase;
}

.tape td {
  padding: 5px 10px 5px 0;
  border-top: 1px solid var(--t-hairline);
  white-space: nowrap;
}

.tape td:nth-child(3) {
  width: 99%;
  overflow: hidden;
  max-width: 0;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tape td:first-child {
  color: var(--t-faint);
}

.tape-code {
  display: inline-block;
  min-width: 54px;
  padding: 1px 6px;
  border: 1px solid var(--t-line-strong);
  border-radius: 3px;
  color: var(--t-muted);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-align: center;
}

.tape tr[data-tone="long"] .tape-code { border-color: rgba(35, 184, 119, 0.45); color: var(--t-long); }
.tape tr[data-tone="short"] .tape-code { border-color: rgba(226, 86, 79, 0.45); color: var(--t-short); }
.tape tr[data-tone="warn"] .tape-code { border-color: rgba(232, 163, 61, 0.45); color: var(--t-amber); }

/* --- States -------------------------------------------------------------- */

.terminal-state {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  justify-content: center;
  min-height: 380px;
  padding: 40px 24px;
  text-align: center;
}

.terminal-state h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.terminal-state p {
  max-width: 46ch;
  margin: 0;
  font-size: 12px;
}

.terminal-state button {
  margin-top: 6px;
  padding: 8px 18px;
  border: 1px solid var(--t-line-strong);
  border-radius: 6px;
  background: var(--t-panel-raised);
  color: var(--t-text);
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

.terminal-state button:hover {
  border-color: var(--t-accent-ring);
  color: var(--t-amber);
}

.terminal-loading {
  position: absolute;
  z-index: 10;
  top: 0;
  right: 0;
  left: 0;
  height: 2px;
  overflow: hidden;
  background: var(--t-accent-halo);
}

.terminal-loading::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 34%;
  background: var(--t-amber);
  animation: terminal-scan 1.05s ease-in-out infinite;
}

@keyframes terminal-scan {
  0% { left: -34%; }
  100% { left: 100%; }
}

/* --- Foot ---------------------------------------------------------------- */

.terminal-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--t-line);
  background: var(--t-shell);
  color: var(--t-faint);
  font-size: 10px;
  line-height: 1.6;
}

.terminal-foot strong {
  color: var(--t-muted);
  font-weight: 500;
}

.terminal-foot a {
  color: var(--t-muted);
  text-decoration: underline;
  text-decoration-color: var(--t-line-strong);
  text-underline-offset: 2px;
}

.terminal-foot a:hover {
  color: var(--t-amber);
}

/* --- Methodology (light again) ------------------------------------------- */

/* The methodology reads as one continuous argument, so the layout is built to
   pace it: a rail of eight numbered steps stays pinned while each step's
   explanation scrolls past at reading length. Native scrolling only — the rail
   follows the reader, the page never hijacks the wheel. */

.terminal-method {
  padding: 8px 0 88px;
}

.method-head {
  max-width: 700px;
}

.method-head .eyebrow-pill {
  margin-bottom: 16px;
}

.method-head p {
  font-size: 0.98rem;
}

.method-grid {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 20px 56px;
  align-items: start;
  margin-top: 40px;
}

.method-rail {
  position: sticky;
  top: 92px;
}

.method-rail ol {
  margin: 0;
  padding: 0;
  list-style: none;
  border-left: 1px solid var(--line);
}

.method-rail a {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 0 9px 16px;
  border-left: 2px solid transparent;
  margin-left: -1.5px;
  color: inherit;
  font-size: 0.86rem;
  text-decoration: none;
  opacity: 0.55;
  transition: opacity 0.2s ease, border-color 0.2s ease;
}

.method-rail a i {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-style: normal;
  letter-spacing: 0.08em;
}

.method-rail li.is-active a {
  border-left-color: var(--teal-deep);
  opacity: 1;
  font-weight: 600;
}

.method-rail a:hover { opacity: 1; }

.method-step {
  /* Reading length per step: tall enough that one step owns the viewport
     while it is being read, short enough that no step demands empty scroll. */
  min-height: 46vh;
  padding: 34px 0 26px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 84px;
  max-width: 640px;
}

.method-step:first-child { border-top: 0; padding-top: 6px; }

.method-step h3 {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 12px;
  font-size: 1.18rem;
}

.method-step h3 i {
  color: var(--teal-deep);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-style: normal;
  letter-spacing: 0.1em;
}

.method-step p {
  margin: 0 0 14px;
  font-size: 0.94rem;
}

.method-formula {
  margin: 18px 0;
  padding: 14px 18px;
  border-left: 3px solid var(--teal-deep);
  border-radius: 0 10px 10px 0;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  overflow-x: auto;
  white-space: nowrap;
}

.method-formula small {
  display: block;
  margin-top: 8px;
  font-family: inherit;
  font-size: 0.72rem;
  opacity: 0.65;
  white-space: normal;
}

@media (max-width: 900px) {
  .method-grid { grid-template-columns: 1fr; }
  .method-rail {
    top: 64px;
    z-index: 5;
    padding: 8px 0;
    background: var(--bg, #fff);
  }
  .method-rail ol {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    border-left: 0;
  }
  .method-rail a { padding: 6px 10px; border-left: 0; border-bottom: 2px solid transparent; }
  .method-rail a span { display: none; }
  .method-rail li.is-active a { border-bottom-color: var(--teal-deep); }
  .method-step { min-height: 0; }
}

/* --- Responsive ---------------------------------------------------------- */

@media (max-width: 1080px) {
  .terminal-body { grid-template-columns: 1fr; }
  .terminal-verdict { border-right: 0; border-bottom: 1px solid var(--t-line); }
  .terminal-modules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tm[data-span="4"] { grid-column: 1 / -1; }
  .terminal-chart { min-height: 400px; }
}

@media (max-width: 720px) {
  .terminal-command { flex-wrap: wrap; }
  .terminal-search { order: 3; flex-basis: 100%; }
  .terminal-timeframes { margin-left: auto; }
  /* The mark's divider separates it from the timeframes, which wrap away on
     narrow screens and would leave the rule pointing at nothing. */
  .terminal-mark { border-right: 0; padding-right: 0; }
  .terminal-modules { grid-template-columns: 1fr; }
  .tm[data-span="2"], .tm[data-span="4"] { grid-column: 1 / -1; }
  .tm { border-right: 0; }
  .terminal-chart { min-height: 380px; }

  /* Floating over the plot costs four wrapped lines here and buries the top of
     the chart. Below this width the legend stops overlaying and becomes a
     strip above the canvas, which the flex column then sizes around. */
  .terminal-legend {
    position: static;
    max-width: none;
    padding: 9px 12px;
    border-bottom: 1px solid var(--t-line);
  }

  /* The colour key is legible from the chart itself and is the first thing to
     go when the strip has to earn its height. */
  .terminal-legend .terminal-legend-key { display: none; }
  .terminal-shell { border-radius: 10px; font-size: 12px; }
  .terminal-price b { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  .terminal-loading::after { animation-duration: 3s; }
}

/* --- Account & sign-in ---------------------------------------------------- */

/* Quota and account share one pill, styled to sit beside the theme switch as
   its sibling: same border, same radius, same disc-shaped buttons. */
.terminal-account {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 1px;
  padding: 3px;
  border: 1px solid var(--t-line-strong);
  border-radius: 999px;
  background: var(--t-panel);
}

.terminal-account > button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--t-faint);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.terminal-account > button:hover {
  color: var(--t-text);
}

.terminal-account > button:focus-visible {
  outline: 2px solid var(--t-amber);
  outline-offset: 1px;
}

/* Signed in reads like the active theme position: a filled amber disc. */
.terminal-account > button[data-signed-in] {
  background: var(--t-panel-raised);
  color: var(--t-amber);
  box-shadow: inset 0 0 0 1px var(--t-accent-ring);
}

.terminal-account svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.6;
}

/* The click-open account menu: who is signed in, and the one action. */
.terminal-account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 55;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 200px;
  padding: 12px;
  border: 1px solid var(--t-line-strong);
  border-radius: 9px;
  background: var(--t-panel);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  font-family: var(--t-mono);
}

.terminal-account-email {
  overflow: hidden;
  color: var(--t-muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.terminal-account-menu button {
  padding: 8px 10px;
  border: 1px solid var(--t-line);
  border-radius: 7px;
  background: var(--t-panel-raised);
  color: var(--t-text);
  font-family: var(--t-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.terminal-account-menu button:hover,
.terminal-account-menu button:focus-visible {
  border-color: var(--t-amber);
  color: var(--t-amber);
}

.terminal-auth {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 6, 9, 0.62);
  backdrop-filter: blur(3px);
}

.terminal-auth-card {
  position: relative;
  width: min(420px, 100%);
  padding: 26px 26px 22px;
  border: 1px solid var(--t-line-strong);
  border-radius: 10px;
  background: var(--t-panel);
  color: var(--t-text);
  font-family: var(--t-mono);
}

.terminal-auth-card h2 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.terminal-auth-sub {
  margin: 0 0 18px;
  color: var(--t-muted);
  font-size: 12px;
  line-height: 1.6;
}

.terminal-auth-card form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.terminal-auth-card input {
  padding: 10px 12px;
  border: 1px solid var(--t-line);
  border-radius: 7px;
  background: var(--t-panel-raised);
  color: var(--t-text);
  font-family: var(--t-mono);
  font-size: 13px;
}

.terminal-auth-card input:focus-visible {
  outline: none;
  border-color: var(--t-amber);
}

.terminal-auth-card button[type="submit"] {
  padding: 10px 12px;
  border: 1px solid var(--t-amber);
  border-radius: 7px;
  background: transparent;
  color: var(--t-amber);
  font-family: var(--t-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.terminal-auth-card button[type="submit"]:hover:not(:disabled) {
  background: var(--t-amber);
  color: var(--t-bg);
}

.terminal-auth-card button[type="submit"]:disabled {
  opacity: 0.5;
  cursor: wait;
}

.terminal-auth-note {
  margin: 14px 0 0;
  color: var(--t-long);
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.terminal-auth-note.is-error {
  color: var(--t-short);
}

.terminal-auth-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: none;
  color: var(--t-faint);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.terminal-auth-close:hover { color: var(--t-text); }

/* --- Quota chip & the pricing wall ---------------------------------------- */

/* Lives inside the account pill, to the left of the person icon. */
.terminal-quota {
  padding: 0 6px 0 10px;
  color: var(--t-muted);
  font-family: var(--t-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  line-height: 28px;
  white-space: nowrap;
  cursor: default;
}

/* The last reading turns the count amber — the wall should never be a surprise. */
.terminal-quota.is-full {
  color: var(--t-amber);
}

.terminal-wall-card {
  width: min(560px, 100%);
}

.terminal-plans {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
}

.terminal-plan {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 16px 16px;
  border: 1px solid var(--t-line);
  border-radius: 9px;
  background: var(--t-panel-raised);
}

.terminal-plan.is-featured {
  border-color: var(--t-amber);
}

/* The "Best value" ribbon. */
.terminal-plan > i {
  position: absolute;
  top: -9px;
  right: 12px;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--t-amber);
  color: var(--t-bg);
  font-size: 9px;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Plan name. */
.terminal-plan > u {
  color: var(--t-muted);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-decoration: none;
  text-transform: uppercase;
}

/* Price line. */
.terminal-plan > b {
  color: var(--t-text);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.terminal-plan > b span {
  color: var(--t-faint);
  font-size: 12px;
  font-weight: 400;
}

.terminal-plan ul {
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--t-muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.terminal-plan ul li::before {
  content: "› ";
  color: var(--t-amber);
}

.terminal-plan > a,
.terminal-plan > button {
  padding: 9px 12px;
  border: 1px solid var(--t-amber);
  border-radius: 7px;
  background: transparent;
  color: var(--t-amber);
  font-family: var(--t-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
}

.terminal-plan > a:hover,
.terminal-plan > a:focus-visible {
  background: var(--t-amber);
  color: var(--t-bg);
}

.terminal-plan.is-featured > a {
  background: var(--t-amber);
  color: var(--t-bg);
}

.terminal-plan.is-featured > a:hover,
.terminal-plan.is-featured > a:focus-visible {
  filter: brightness(1.12);
}

.terminal-plan > button:disabled {
  border-color: var(--t-line);
  color: var(--t-faint);
  cursor: default;
}

@media (max-width: 560px) {
  .terminal-plans { grid-template-columns: 1fr; }
}

/* --- Reading settings ("tune") --------------------------------------------- */

.terminal-tune {
  position: relative;
  display: flex;
  flex-shrink: 0;
  padding: 3px;
  border: 1px solid var(--t-line-strong);
  border-radius: 999px;
  background: var(--t-panel);
}

.terminal-tune > button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--t-faint);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.terminal-tune > button:hover { color: var(--t-text); }

.terminal-tune > button:focus-visible {
  outline: 2px solid var(--t-amber);
  outline-offset: 1px;
}

/* Non-default settings read like an active theme position: the amber disc
   says "this reading is tuned" before a single module is scanned. */
.terminal-tune > button.is-tuned {
  background: var(--t-panel-raised);
  color: var(--t-amber);
  box-shadow: inset 0 0 0 1px var(--t-accent-ring);
}

.terminal-tune svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.6;
}

.terminal-tune-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 55;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 280px;
  padding: 14px;
  border: 1px solid var(--t-line-strong);
  border-radius: 9px;
  background: var(--t-panel);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  font-family: var(--t-mono);
}

.tune-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.tune-field label {
  color: var(--t-muted);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.tune-field select,
.tune-field input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--t-line);
  border-radius: 7px;
  background: var(--t-panel-raised);
  color: var(--t-text);
  font-family: var(--t-mono);
  font-size: 12px;
}

.tune-field select:focus-visible,
.tune-field input:focus-visible {
  outline: none;
  border-color: var(--t-amber);
}

.tune-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  /* Bottom-aligned so the two inputs stay level even if one label wraps. */
  align-items: end;
}

.tune-note {
  margin: 0;
  color: var(--t-faint);
  font-size: 10.5px;
  line-height: 1.55;
}

#tuneReset {
  padding: 8px 10px;
  border: 1px solid var(--t-line);
  border-radius: 7px;
  background: none;
  color: var(--t-muted);
  font-family: var(--t-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

#tuneReset:hover,
#tuneReset:focus-visible {
  border-color: var(--t-amber);
  color: var(--t-amber);
}
