/* Trading page: Konatus Bearing guide inside the site shell. */
:root {
  --tv-bg: #131722;
  --tv-panel: #1e222d;
  --tv-border: #2a2e39;
  --tv-text: #d1d4dc;
  --tv-muted: #a4a9b6;
  --tv-up: #26a69a;
  --tv-down: #ef5350;
  --tv-mute: #90a4ae;
  --tv-blue: #2962ff;
  --tv-hover: #2a2e39;
  --tv-font: Trebuchet MS, Roboto, Ubuntu, sans-serif;
}

body[data-page="trading"] {
  background: var(--tv-bg);
}

body[data-page="trading"] .page.active {
  padding-top: var(--header-height);
}

#page-trading {
  width: 100%;
  max-width: none;
  padding-inline: 0;
}

.tv-desk {
  --tv-toolbar: 92px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: calc(100vh - var(--header-height));
  min-height: 640px;
  background: var(--tv-bg);
  color: var(--tv-text);
  font-family: var(--tv-font);
  border-bottom: 1px solid var(--tv-border);
}

.tv-toolbar {
  background: var(--tv-panel);
  border-bottom: 1px solid var(--tv-border);
  padding: 8px 12px 6px;
}

.tv-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.tv-toolbar h1 {
  margin: 0 8px 0 0;
  font: 700 15px/1.2 var(--tv-font);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--tv-text);
}

.tv-symbol input {
  width: 8.5rem;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--tv-border);
  border-radius: 2px;
  background: #131722;
  color: var(--tv-text);
  font: 700 14px/1.2 var(--tv-font);
  text-transform: uppercase;
}

.tv-intervals {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.tv-interval,
.tv-gear {
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--tv-muted);
  font: 600 13px/1 var(--tv-font);
  cursor: pointer;
}

.tv-interval[aria-pressed="true"] {
  background: var(--tv-hover);
  color: var(--tv-text);
}

.tv-interval:hover,
.tv-gear:hover {
  color: var(--tv-text);
  background: var(--tv-hover);
}

.tv-status {
  margin: 0 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--tv-muted);
}

.tv-delay {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid #c9a227;
  color: #e0b84a;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 700;
}

.tv-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--tv-muted);
}

.tv-legend strong {
  color: var(--tv-text);
  font-weight: 600;
}

.tv-legend .up { color: var(--tv-up); }
.tv-legend .down { color: var(--tv-down); }
.tv-legend .mute { color: var(--tv-mute); }

.tv-settings {
  background: #171b26;
  border-bottom: 1px solid var(--tv-border);
  padding: 12px 16px 16px;
}

.tv-settings fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 16px;
}

.tv-settings legend {
  padding: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tv-muted);
}

.tv-settings label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--tv-muted);
}

.tv-settings select,
.tv-settings input[type="number"] {
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid var(--tv-border);
  border-radius: 2px;
  background: var(--tv-bg);
  color: var(--tv-text);
  font: 13px var(--tv-font);
}

.tv-check {
  display: flex !important;
  align-items: center;
  gap: 8px;
  color: var(--tv-text) !important;
}

.tv-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--tv-blue);
}

.tv-stage {
  position: relative;
  min-height: 0;
  background: var(--tv-bg);
}

#tv-chart {
  position: absolute;
  inset: 0;
}

.tv-readout {
  position: absolute;
  right: 68px;
  /* Overridden from JS to sit above the price pane's lower edge; this is the
     fallback for the first paint and for no-JS. */
  bottom: 46%;
  z-index: 3;
  margin: 0;
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 14px;
  padding: 8px 12px;
  background: rgba(19, 23, 34, 0.98);
  border: 1px solid var(--tv-border);
  border-radius: 3px;
  font-family: var(--tv-font);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
  color: var(--tv-text);
  pointer-events: none;
  max-width: min(320px, 52%);
}

.tv-readout dt {
  color: var(--tv-muted);
  white-space: nowrap;
}

.tv-readout dd {
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.tv-readout .up { color: var(--tv-up); }
.tv-readout .down { color: var(--tv-down); }
.tv-readout .mute { color: var(--tv-mute); }
.tv-readout[hidden] { display: none; }

/* The chart is short on a phone and an eleven-row panel would cover it.
   The legend line already carries the verdict and its cause. */
@media (max-width: 640px) {
  .tv-readout { display: none; }
}

.tv-message {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 2;
  margin: 0;
  max-width: 36rem;
  padding: 8px 12px;
  background: rgba(30, 34, 45, 0.92);
  border: 1px solid var(--tv-border);
  color: var(--tv-text);
  font-size: 13px;
}

.tv-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tv-notes {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding: 2.5rem var(--gutter) 4rem;
}

.tv-notes h2 {
  font-family: var(--serif-display);
  font-size: var(--t-h2);
  color: var(--parchment);
  margin: 0 0 1rem;
}

.tv-notes p,
.tv-notes li,
.tv-notes dd,
.tv-notes figcaption {
  max-width: var(--measure-prose);
  font-size: var(--t-body);
  line-height: 1.7;
  color: var(--ink);
  margin: 0 0 1rem;
}

.tv-notes h3 {
  font-family: var(--serif-display);
  font-size: var(--t-h3);
  color: var(--parchment);
  margin: 2rem 0 0.75rem;
}

.tv-flow {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 1.5rem 0 2rem;
  padding: 0;
  max-width: none;
}

.tv-flow li {
  margin: 0;
  padding: 0.75rem 0.7rem 0.85rem;
  border: 1px solid var(--gold-a35, rgba(201, 162, 39, 0.35));
  background: var(--gold-a04, rgba(201, 162, 39, 0.04));
  color: var(--ink);
  font-size: 0.85rem;
  line-height: 1.35;
}

.tv-flow span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--parchment);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tv-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0.75rem 1.5rem;
  margin: 0 0 2rem;
}

.tv-swatches div {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  font-size: 0.95rem;
}

.tv-swatch {
  display: inline-block;
  width: 1.1rem;
  height: 0.45rem;
  flex: 0 0 auto;
}

.tv-swatch-up { background: #a6cf9a; }
.tv-swatch-down { background: #edaba0; }
.tv-swatch-mute { background: #a5b0a7; }
.tv-swatch-vwap { background: #ff9800; }

.tv-diagrams {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 1.5rem;
  margin: 0 0 2rem;
}

.tv-diagram {
  margin: 0;
  padding: 1rem 1rem 0.25rem;
  border: 1px solid var(--gold-a35, rgba(201, 162, 39, 0.35));
  background: #171b26;
  color: #d1d4dc;
}

.tv-diagram svg {
  display: block;
  width: 100%;
  height: auto;
  font-family: Trebuchet MS, Roboto, Ubuntu, sans-serif;
}

.tv-diagram figcaption {
  color: var(--ink-soft, #cfc6b0);
  font-size: 0.92rem;
  margin: 0.75rem 0 1rem;
  max-width: none;
}

.tv-defs {
  margin: 0 0 1.5rem;
  max-width: var(--measure-prose);
}

.tv-defs dt {
  margin: 1rem 0 0.25rem;
  color: var(--parchment);
  font-weight: 600;
}

.tv-defs dd {
  margin: 0;
}

.tv-compare {
  width: 100%;
  max-width: var(--measure-prose);
  margin: 0 0 1.5rem;
  border-collapse: collapse;
  font-size: var(--t-body);
  color: var(--ink);
}

.tv-compare caption {
  text-align: left;
  color: var(--tv-muted);
  font-size: 0.85em;
  padding-bottom: 0.6rem;
}

.tv-compare th,
.tv-compare td {
  text-align: left;
  vertical-align: top;
  padding: 0.55rem 0.9rem 0.55rem 0;
  border-bottom: 1px solid var(--tv-border);
  line-height: 1.5;
}

.tv-compare thead th {
  color: var(--parchment);
  font-weight: 600;
  white-space: nowrap;
}

.tv-compare tbody th {
  color: var(--parchment);
  font-weight: 600;
  white-space: nowrap;
  padding-right: 1.25rem;
}

.tv-compare tbody tr:last-child th,
.tv-compare tbody tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 640px) {
  .tv-compare,
  .tv-compare tbody,
  .tv-compare tr,
  .tv-compare td,
  .tv-compare tbody th {
    display: block;
    width: 100%;
  }
  .tv-compare thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .tv-compare tbody tr {
    border-bottom: 1px solid var(--tv-border);
    padding: 0.5rem 0;
  }
  .tv-compare tbody th,
  .tv-compare td {
    border-bottom: 0;
    padding: 0.15rem 0;
    white-space: normal;
  }
  .tv-compare td::before {
    content: attr(data-label) ": ";
    color: var(--tv-muted);
  }
}

.tv-bt-stats {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1.5rem 0 2rem;
  padding: 0;
  max-width: none;
}

.tv-bt-stats li {
  margin: 0;
  padding: 0.85rem 0.8rem 1rem;
  border: 1px solid var(--gold-a35, rgba(201, 162, 39, 0.35));
  background: var(--gold-a04, rgba(201, 162, 39, 0.04));
  color: var(--ink);
  font-size: 0.85rem;
  line-height: 1.35;
}

.tv-bt-stats strong {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--parchment);
  font-family: var(--serif-display);
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.15;
}

.tv-limits {
  max-width: var(--measure-prose);
  margin: 0;
  padding-left: 1.1rem;
}

.tv-limits li {
  margin: 0 0 0.7rem;
}

.tv-code-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
}

.tv-copy,
.tv-download {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--gold-a60, rgba(201, 162, 39, 0.6));
  background: transparent;
  color: var(--parchment);
  font: 600 13px/1 var(--tv-font);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.tv-copy:hover,
.tv-download:hover {
  background: var(--gold-a04, rgba(201, 162, 39, 0.08));
}

.tv-code pre {
  max-width: none;
  max-height: 28rem;
  overflow: auto;
  margin: 0 0 2rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--gold-a35, rgba(201, 162, 39, 0.35));
  background: #131722;
  color: #d1d4dc;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}

@media (max-width: 768px) {
  .tv-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tv-bt-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

body[data-page="trading"] footer {
  background: #100d08;
}

@media (max-width: 768px) {
  .tv-desk { height: calc(100svh - var(--header-height)); min-height: 560px; }
  .tv-status { margin-left: 0; }
  .tv-symbol input { width: 6.5rem; }
  .tv-toolbar h1 { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .tv-interval, .tv-gear { transition: none; }
}

/* Konatus Bearing 0.3: hero, dashboard illustration (colors from the Pine dark theme), source toggle. */
.kb-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 2.5rem;
  align-items: center;
}

.kb-hero .eyebrow { text-align: left; }

.kb-figure { margin: 0 0 0 auto; max-width: 24rem; width: 100%; }

.kb-figure figcaption {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--tv-muted);
}

.kb-panel {
  padding: 0.9rem 1rem 0.7rem;
  border: 1px solid #344238;
  background: #151b18;
  color: #e8ece6;
  font: 13px/1.35 var(--tv-font);
  font-variant-numeric: tabular-nums;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.kb-panel p { margin: 0; max-width: none; font-size: inherit; line-height: inherit; color: inherit; }
.kb-panel-head { display: flex; justify-content: space-between; color: #a5b0a7; font-size: 12px; letter-spacing: 0.06em; }
.kb-panel .kb-state { margin-top: 0.6rem; color: #e7c184; font-size: 1.45rem; font-weight: 700; letter-spacing: 0.02em; }
.kb-panel .kb-reason { margin-bottom: 0.6rem; color: #a5b0a7; }
.kb-panel dl { margin: 0; }
.kb-panel dl div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.3rem 0; border-top: 1px solid #25302a; }
.kb-panel dt { color: #a5b0a7; text-transform: uppercase; font-size: 11.5px; letter-spacing: 0.05em; }
.kb-panel dd { margin: 0; max-width: none; font-size: 13px; line-height: 1.35; color: #e8ece6; }
.kb-panel dd.kb-up { color: #a6cf9a; }
.kb-panel dd.kb-dim { color: #a5b0a7; }
.kb-panel dd.kb-amber { color: #e7c184; }
.kb-panel .kb-panel-foot { margin-top: 0.45rem; color: #a5b0a7; font-size: 11.5px; }

.kb-source { margin: 0 0 2rem; }

.kb-source summary {
  cursor: pointer;
  color: var(--parchment);
  margin-bottom: 0.75rem;
}

@media (max-width: 860px) {
  .kb-hero { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
  .kb-figure { margin-left: 0; }
}

/* Entry glyphs mirror Pine 0.3.1; labels keep meaning independent of color. */
.kb-markers span { display: block; font-size: 1.5rem; line-height: 1; margin-bottom: .5rem; }
.kb-marker-long { color: #4caf50; }
.kb-marker-short { color: #f23645; }
.kb-marker-exit { color: #e7c184; }
