/* Trading desk. TradingView dark chrome inside the site shell. */
:root {
  --tv-bg: #131722;
  --tv-panel: #1e222d;
  --tv-border: #2a2e39;
  --tv-text: #d1d4dc;
  --tv-muted: #787b86;
  --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: 560px;
  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-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: #26a69a; }
.tv-swatch-down { background: #ef5350; }
.tv-swatch-mute { background: #90a4ae; }
.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-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)); }
}

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

@media (max-width: 768px) {
  .tv-desk { height: calc(100svh - var(--header-height)); min-height: 480px; }
  .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; }
}
