/*
 * DEX chart V1: the market header, the trading chart (Lightweight Charts, vendored), the tape, the AMM pool context,
 * the trading layouts that place them, and the owner-only Test Lab page's header.
 *
 * Tokens only (dex.css owns the palette, light and dark); logical properties only, so every rule mirrors under RTL.
 * The chart itself stays LTR in every locale (time runs left to right). Loaded after dex.css, spot.css, shell-v1.css.
 */

/* ------------------------------------------------------------ market header --- */

.mkt-head {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}

.mkt-id {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--s2);
  padding: var(--s4) var(--s5);
  border-inline-end: 1px solid var(--line-soft);
  min-width: 0;
}

.mkt-pair-mark {
  display: inline-flex;
  align-items: center;
  gap: 0;
}

.mkt-pair-mark .pair-leg + .pair-leg {
  margin-inline-start: -7px;
}

.mkt-pair-mark .asset-logo {
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--surface);
}

.mkt-pair-name {
  margin-inline-start: var(--s4);
  font-size: var(--t-head);
  font-weight: 750;
  color: var(--ink);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.mkt-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-size: var(--t-micro);
  color: var(--ink-2);
  white-space: nowrap;
}

.mkt-badge b {
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: var(--accent-quiet);
  border-radius: 999px;
  padding: 0 var(--s3);
}

.mkt-head .md-stats {
  border-bottom: 0;
  flex: 1 1 auto;
  align-items: stretch;
  flex-wrap: wrap;
  min-width: 0;
}

.mkt-head .md-stats .stat {
  min-width: 0;
  padding: var(--s4) var(--s5);
}

.mkt-head .md-stats .stat:last-child {
  border-inline-end: 0;
}

.mkt-head .stat .v .unit,
.market-bar .stat .v .unit {
  font-size: var(--t-small);
  font-weight: 600;
  color: var(--ink-3);
}

.mkt-state {
  display: flex;
  align-items: center;
  padding: var(--s3) var(--s5);
  margin-inline-start: auto;
}

/* The Spot market bar: the same header, with the badge under the pair. */
.market-bar .pair .mkt-badge {
  margin-top: var(--s1);
}

.market-bar .stat.headline .v,
.mkt-head .stat.headline .v {
  font-size: 20px;
  letter-spacing: -0.01em;
}

/* ------------------------------------------------------------------- chart --- */

.md-panel .md-head {
  flex-wrap: wrap;
  row-gap: var(--s2);
}

.md-panel .md-head .panel-tools {
  flex-wrap: wrap;
  justify-content: flex-end;
  row-gap: var(--s2);
  gap: var(--s4);
}

.md-panel .timeframes {
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.md-panel .timeframes button.tiny {
  border: 0;
  border-radius: 0;
  border-inline-end: 1px solid var(--line-soft);
  min-height: 26px;
  min-width: 34px;
  padding: 0 var(--s3);
  font-size: var(--t-small);
  font-family: var(--mono);
}

.md-panel .timeframes button.tiny:last-child {
  border-inline-end: 0;
}

.md-panel .timeframes button.tiny[aria-pressed="true"] {
  background: var(--accent);
  color: #ffffff;
}

.chart-tools {
  display: inline-flex;
  gap: var(--s2);
}

.chart-tools button.tiny {
  min-height: 26px;
  min-width: 28px;
  font-size: var(--t-small);
}

.md-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* The OHLC legend: its own row above the plot, so it never covers a candle. */
.md-legend.chart-readout {
  position: static;
  inset: auto;
  margin: 0;
  max-width: none;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s1) var(--s4);
  min-height: 26px;
  padding: var(--s2) var(--s4);
  background: transparent;
  border-radius: 0;
  font-family: var(--mono);
  font-size: var(--t-small);
  color: var(--ink-2);
  pointer-events: auto;
}

.md-legend .rd {
  display: inline-flex;
  gap: var(--s2);
  white-space: nowrap;
}

.md-legend .rd i {
  font-style: normal;
  color: var(--ink-3);
}

.md-legend .rd b {
  font-weight: 650;
  color: var(--ink);
}

.md-legend .rd b.up {
  color: var(--up600);
}

.md-legend .rd b.down {
  color: var(--down600);
}

.md-legend .rd-gap {
  color: var(--ink-3);
  font-style: italic;
}

.md-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 380px;
}

.md-stage > .md-canvas {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  outline: none;
}

.md-stage > .md-canvas:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* NOTHING TO DRAW is said in the middle of the plot, as a statement rather than an empty grid. */
.md-message {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s4);
  padding: var(--s6);
  pointer-events: none;
  z-index: 3;
  font-size: var(--t-head);
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  line-height: 1.5;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
}

/* A drawn mark (three bars), not an image: nothing to fetch, and it takes the theme's ink. */
.md-message::before {
  content: "";
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background:
    linear-gradient(var(--ink-3), var(--ink-3)) 14px 17px / 4px 16px no-repeat,
    linear-gradient(var(--accent), var(--accent)) 22px 12px / 4px 24px no-repeat,
    linear-gradient(var(--ink-3), var(--ink-3)) 30px 19px / 4px 12px no-repeat,
    var(--surface-2);
  border: 1px solid var(--line-soft);
}

.md-message[data-sub]::after {
  content: attr(data-sub);
  max-width: 420px;
  font-size: var(--t-small);
  font-weight: 500;
  color: var(--ink-2);
}

.md-message[hidden] {
  display: none;
}

.md-message[data-kind="view"] {
  background: transparent;
  font-size: var(--t-small);
  font-weight: 600;
  color: var(--ink-2);
}

.md-message[data-kind="view"]::before {
  display: none;
}

.md-since {
  position: absolute;
  /* Physical, not logical: the plot is LTR in every locale and its price axis is always on the right. */
  top: var(--s3);
  right: 76px;
  z-index: 2;
  font-size: var(--t-micro);
  font-family: var(--mono);
  color: var(--ink-2);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 1px var(--s4);
  pointer-events: none;
}

.md-since[hidden] {
  display: none;
}

.md-canvas[data-empty="true"] {
  opacity: 0.35;
}

.md-foot {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--s1) var(--s5);
  padding: var(--s2) var(--s4) var(--s3);
  border-top: 1px solid var(--line-soft);
  font-size: var(--t-micro);
  color: var(--ink-3);
  line-height: 1.5;
}

.md-foot .md-note {
  flex: 1 1 320px;
  margin: 0;
  padding: 0;
}

.md-updated {
  font-family: var(--mono);
  white-space: nowrap;
}

.md-attrib {
  color: var(--ink-3);
  text-decoration: none;
  /* The library's notice is two short runs: each stays whole, and the copyright line wraps under the name if the
     foot is narrow (a phone) rather than pushing the page sideways. */
  overflow-wrap: anywhere;
}

.md-attrib-name {
  white-space: nowrap;
}

/* How the chart is kept current: streaming, polling, reconnecting, or failing. The word is the signal; the dot
   reinforces it. */
.md-feed {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  color: var(--ink-3);
}

.md-feed::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.md-feed[data-mode="stream"]::before {
  background: var(--dx-buy, var(--up600, #0f7a52));
}

.md-feed[data-mode="reconnecting"],
.md-feed[data-mode="down"] {
  color: var(--dx-warn, var(--warn, #9a6a00));
}

.md-attrib:hover {
  color: var(--ink-2);
  text-decoration: underline;
}

.md-panel .md-health {
  margin: 0 var(--s4) var(--s2);
}

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

.md-trades .panel-body {
  max-height: none;
}

.md-trades-scope {
  margin: 0;
  padding: var(--s2) var(--s4);
  font-size: var(--t-micro);
  color: var(--ink-3);
  line-height: 1.45;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.md-trade-table th,
.md-trade-table td {
  padding-inline: var(--s3);
}

.md-trade-table th:first-child,
.md-trade-table td:first-child {
  padding-inline-start: var(--s4);
}

.md-trade-table th:last-child,
.md-trade-table td:last-child {
  padding-inline-end: var(--s4);
  color: var(--ink-2);
}

.md-trade-table td {
  padding-block: 3px;
}

.md-trade-table td.up {
  color: var(--up600);
}

.md-trade-table td.down {
  color: var(--down600);
}

.md-trades-empty {
  padding: var(--s7) var(--s5);
}

/* ------------------------------------------------------- Spot (order book) --- */

/* A FIXED HEIGHT, not a minimum: with only a minimum the fr rows size to their content and a long tape stretches the
   terminal past the screen. Each panel scrolls inside its own box instead. */
.terminal {
  /* The ticket runs the full height beside the market, so its action is never below the fold. */
  grid-template-areas:
    "bar    bar    bar"
    "chart  book   ticket"
    "chart  tape   ticket"
    "tables tables ticket";
  grid-template-columns: minmax(0, 1fr) 280px 300px;
  grid-template-rows: auto minmax(0, 1fr) minmax(0, 0.72fr) minmax(170px, 24vh);
  height: max(760px, calc(100vh - 46px));
  min-height: 0;
}

.terminal > .md-panel .panel-body {
  overflow: hidden;
}

.terminal .md-stage {
  min-height: 300px;
}

.terminal > .tape-panel.md-trades .panel-body {
  overflow: auto;
}

@media (max-width: 1180px) {
  .terminal {
    grid-template-columns: minmax(0, 1fr) 280px;
    grid-template-rows: auto minmax(440px, 62vh) auto minmax(220px, 34vh) minmax(180px, 28vh);
    height: auto;
  }
}

/* --------------------------------------------------------------- AMM trade --- */

.amm-page.amm-page-trade {
  max-width: 1720px;
  padding: var(--s3) var(--s3) var(--s6);
  gap: var(--s3);
}

.amm-page-trade .amm-trade {
  display: grid;
  grid-template-areas:
    "head  head  head"
    "chart ctx   ticket";
  grid-template-columns: minmax(0, 1fr) 340px 340px;
  gap: var(--s3);
  align-items: stretch;
}

.amm-page-trade .amm-trade > .mkt-head {
  grid-area: head;
}

.amm-page-trade .amm-market-col {
  grid-area: chart;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.amm-page-trade .amm-market-col > .md-panel {
  flex: 1 1 auto;
  min-height: clamp(460px, calc(100vh - 200px), 860px);
}

.amm-page-trade .amm-context-col {
  grid-area: ctx;
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  min-width: 0;
  min-height: 0;
}

.amm-page-trade .amm-context-col > .md-trades {
  flex: 1 1 0;
  min-height: 240px;
}

.amm-page-trade .amm-context-col > .md-trades .panel-body {
  overflow: auto;
}

.amm-page-trade .amm-ticket-col {
  grid-area: ticket;
  align-self: start;
}

.amm-pool-rows {
  padding: var(--s3) var(--s4);
  display: grid;
  gap: var(--s2);
}

.amm-pool-rows .row {
  display: flex;
  justify-content: space-between;
  gap: var(--s4);
  font-size: var(--t-small);
}

.amm-pool-rows .row .k {
  color: var(--ink-2);
}

.amm-pool-rows .row .v {
  font-family: var(--mono);
  text-align: end;
  overflow-wrap: anywhere;
}

.amm-pool-rows .note {
  margin: var(--s2) 0 0;
  font-size: var(--t-micro);
  color: var(--ink-3);
}

/* The trade's ticket next to the chart; the pool and the tape under both. */
@media (max-width: 1280px) {
  .amm-page-trade .amm-trade {
    grid-template-areas:
      "head  head"
      "chart ticket"
      "ctx   ctx";
    grid-template-columns: minmax(0, 1fr) 330px;
  }
  .amm-page-trade .amm-context-col {
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    align-items: start;
  }
  .amm-page-trade .amm-context-col > .md-trades .panel-body {
    max-height: 360px;
  }
  .amm-page-trade .amm-market-col > .md-panel {
    min-height: clamp(440px, 64vh, 720px);
  }
}

@media (max-width: 860px) {
  .amm-page-trade .amm-trade {
    grid-template-areas:
      "head"
      "chart"
      "ticket"
      "ctx";
    grid-template-columns: minmax(0, 1fr);
  }
  .amm-page-trade .amm-market-col {
    display: flex;
  }
  .amm-page-trade .amm-context-col {
    display: flex;
    flex-direction: column;
  }
  .amm-page-trade .amm-market-col > .md-panel {
    min-height: 0;
  }
}

/* ------------------------------------------------------------------- phone --- */

@media (max-width: 820px) {
  /* The chart keeps a usable height: a share of the screen, never a strip. */
  .md-stage,
  .terminal .md-stage {
    min-height: 0;
    flex: 0 0 auto;
    height: clamp(300px, 54vh, 460px);
  }
  .terminal > .md-panel .panel-body,
  .chart-panel.md-panel .panel-body {
    height: auto;
  }
  .md-panel .md-head {
    padding-inline: var(--s3);
  }
  .md-panel .md-head .panel-title {
    display: none;
  }
  .md-panel .md-head .panel-tools {
    margin-inline-start: 0;
    width: 100%;
    justify-content: space-between;
  }
  .md-panel .timeframes button.tiny {
    min-height: 32px;
    min-width: 0;
    flex: 1 1 0;
    padding: 0 var(--s2);
  }
  .md-panel .timeframes {
    flex: 1 1 auto;
  }
  .chart-tools button.tiny {
    min-height: 32px;
    min-width: 36px;
  }
  .md-legend.chart-readout {
    font-size: var(--t-micro);
    gap: 0 var(--s4);
    min-height: 38px;
  }
  .md-trades .panel-body {
    max-height: none;
  }
  /* The header as a grid of figures: pair across the top, the six figures in three columns. */
  .mkt-head {
    flex-direction: column;
  }
  .mkt-id {
    border-inline-end: 0;
    border-bottom: 1px solid var(--line-soft);
    padding: var(--s3) var(--s4);
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
  }
  .mkt-head .md-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .mkt-head .md-stats .stat {
    padding: var(--s3) var(--s4);
    border-bottom: 1px solid var(--line-soft);
  }
  .mkt-head .md-stats .stat:nth-child(3n) {
    border-inline-end: 0;
  }
  .mkt-head .md-stats .stat.headline .v {
    font-size: var(--t-head);
  }
  .mkt-state {
    position: absolute;
    inset-block-start: var(--s3);
    inset-inline-end: var(--s3);
    padding: 0;
  }
  .mkt-head {
    position: relative;
  }
  .mkt-id {
    padding-inline-end: 64px;
  }
  /* Spot's bar: the pair across the top, then the figures as a grid (no sideways scroll to find a number). */
  .terminal > .market-bar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
  }
  .terminal > .market-bar .pair {
    grid-column: 1 / -1;
    min-width: 0;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    border-inline-end: 0;
    border-bottom: 1px solid var(--line-soft);
    padding: var(--s3) var(--s4);
  }
  .terminal > .market-bar .pair-identity {
    display: none;
  }
  .terminal > .market-bar .stat {
    min-width: 0;
    padding: var(--s2) var(--s4);
    border-bottom: 1px solid var(--line-soft);
  }
  .terminal > .market-bar .stat:last-child {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    border-bottom: 0;
  }
  .terminal > .market-bar .stat.headline .v {
    font-size: var(--t-head);
  }
  .terminal > .market-bar .stat .v {
    font-size: var(--t-body);
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .amm-page.amm-page-trade {
    padding: var(--s3) var(--s3) var(--s6);
  }
}

/* ------------------------------------------------------- the Test Lab page --- */

.tl-topbar {
  gap: var(--s4);
  padding-block: var(--s2);
}

.tl-owner-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 1px var(--s3);
  border-radius: 999px;
  color: var(--warn600);
  background: var(--warn50);
  border: 1px solid color-mix(in srgb, var(--warn600) 35%, transparent);
  white-space: nowrap;
}

.tl-page-nav {
  display: flex;
  align-items: center;
}

.tl-back {
  color: var(--accent-ink);
  font-weight: 650;
  text-decoration: none;
  padding: var(--s2) var(--s3);
  border-radius: var(--radius);
}

.tl-back:hover {
  background: var(--accent-quiet);
}

@media (max-width: 820px) {
  .tl-page-nets {
    order: 3;
    width: 100%;
  }
}

@media (max-width: 560px) {
  /* One row: the six timeframes, Fit and Reset. Zoom is a pinch on a phone; the +/- buttons give way. */
  .md-panel .md-head .panel-tools {
    flex-wrap: nowrap;
    gap: var(--s2);
  }
  .md-panel .timeframes {
    flex: 1 1 auto;
  }
  [data-field="chart-zoom-in"],
  [data-field="chart-zoom-out"] {
    display: none;
  }
  .chart-tools button.tiny {
    min-width: 32px;
    padding: 0 var(--s2);
  }
  /* LIVE is said once, in the market header; any other state (stale, unavailable...) stays in the chart's head. */
  .md-panel .md-head .state-chip[data-tone="good"] {
    display: none;
  }
}

/* ------------------------------------------------- DEX V5 chart tools (Track C) --- */

.c5-toolbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--dx-sp-2, 8px);
  padding: var(--dx-sp-1, 4px) var(--s4, 12px);
  border-bottom: 1px solid var(--dx-border, var(--line-soft));
  overflow-x: auto;
  scrollbar-width: thin;
  font-size: var(--dx-fs-xs, var(--t-small, 12px));
  font-variant-numeric: tabular-nums;
}

.c5-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}

.c5-sep {
  width: 1px;
  align-self: stretch;
  margin: 2px 0;
  background: var(--dx-border, var(--line-soft));
  flex: 0 0 auto;
}

.c5-btn,
.c5-select {
  min-height: 28px;
  min-width: 28px;
  padding: 0 var(--dx-sp-2, 8px);
  border: 1px solid transparent;
  border-radius: var(--dx-radius-s, 5px);
  background: transparent;
  color: var(--dx-text-dim, var(--ink-2));
  font: inherit;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
}

.c5-select {
  border-color: var(--dx-border, var(--line));
  background: var(--dx-surface, var(--surface));
  color: var(--dx-text, var(--ink));
}

.c5-btn:hover:not(:disabled) {
  background: var(--dx-surface-2, var(--surface-2));
  color: var(--dx-text, var(--ink));
}

.c5-btn:focus-visible,
.c5-select:focus-visible,
.c5-num:focus-visible,
.c5-text:focus-visible {
  outline: 2px solid var(--dx-focus, var(--accent));
  outline-offset: 1px;
}

.c5-btn[aria-pressed="true"] {
  background: var(--dx-accent, var(--accent));
  color: #ffffff;
}

.c5-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.c5-btn.armed {
  background: var(--dx-danger, var(--down600));
  color: #ffffff;
}

.c5-btn.c5-primary {
  background: var(--dx-accent, var(--accent));
  color: #ffffff;
}

.c5-tool {
  font-size: 15px;
}

.c5-btn[data-field="chart5-indicators"][data-count]:not([data-count="0"])::after {
  content: attr(data-count);
  margin-inline-start: 4px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--dx-surface-2, var(--surface-2));
  color: var(--dx-text, var(--ink));
  font-size: 10px;
}

.c5-note {
  flex: 1 1 auto;
  min-width: 160px;
  color: var(--dx-text-dim, var(--ink-3));
  font-size: var(--dx-fs-xs, 11px);
  white-space: normal;
}

.c5-note[hidden] {
  display: none;
}

.c5-pop {
  position: fixed;
  z-index: 60;
  top: auto;
  margin-top: 4px;
  width: min(420px, calc(100vw - 32px));
  max-height: min(70vh, 520px);
  overflow: auto;
  padding: var(--dx-sp-3, 12px);
  background: var(--dx-surface, var(--surface));
  color: var(--dx-text, var(--ink));
  border: 1px solid var(--dx-border, var(--line));
  border-radius: var(--dx-radius-m, 8px);
  box-shadow: var(--dx-shadow-2, 0 12px 32px rgba(0, 0, 0, 0.18));
  font-size: var(--dx-fs-sm, 12px);
}

.c5-pop-note {
  margin: 0 0 var(--dx-sp-2, 8px);
  color: var(--dx-text-dim, var(--ink-2));
  line-height: 1.45;
}

.c5-ind,
.c5-layout,
.c5-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--dx-sp-2, 8px);
  padding: var(--dx-sp-1, 4px) 0;
}

.c5-ind {
  border-bottom: 1px solid var(--dx-border, var(--line-soft));
}

.c5-ind b {
  min-width: 96px;
}

.c5-layout span {
  flex: 1 1 auto;
}

.c5-param {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--dx-text-dim, var(--ink-2));
}

.c5-num {
  width: 64px;
  min-height: 28px;
  font: inherit;
  font-family: var(--dx-mono, var(--mono));
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--dx-border, var(--line));
  border-radius: var(--dx-radius-s, 5px);
  background: var(--dx-bg, var(--surface));
  color: inherit;
  padding: 0 6px;
}

.c5-text {
  flex: 1 1 140px;
  min-height: 28px;
  font: inherit;
  border: 1px solid var(--dx-border, var(--line));
  border-radius: var(--dx-radius-s, 5px);
  background: var(--dx-bg, var(--surface));
  color: inherit;
  padding: 0 8px;
}

.c5-colour {
  width: 32px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--dx-border, var(--line));
  border-radius: var(--dx-radius-s, 5px);
  background: none;
}

.c5-empty {
  margin: var(--dx-sp-1, 4px) 0;
  color: var(--dx-text-dim, var(--ink-3));
}

/* The indicator legend: over the top-left of the plot, never over the price axis. */
.c5-ind-legend {
  position: absolute;
  top: var(--s2, 6px);
  left: var(--s4, 10px);
  right: 80px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 2px var(--dx-sp-3, 12px);
  pointer-events: none;
  font-family: var(--dx-mono, var(--mono));
  font-size: var(--dx-fs-xs, 11px);
  font-variant-numeric: tabular-nums;
}

.c5-ind-legend[hidden] {
  display: none;
}

.c5-ind-item {
  display: inline-flex;
  gap: 4px;
  color: var(--c5-ind);
  background: color-mix(in srgb, var(--dx-surface, var(--surface)) 82%, transparent);
  border-radius: 3px;
  padding: 0 3px;
}

.c5-ind-item i {
  font-style: normal;
  opacity: 0.85;
}

/* FULL SCREEN: the chart's panel fills the viewport; the page behind does not scroll. */
.c5-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 80 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  border-radius: 0 !important;
  display: flex !important;
  flex-direction: column;
  background: var(--dx-surface, var(--surface));
}

.c5-fullscreen .md-body {
  flex: 1 1 auto;
}

.c5-fullscreen .md-stage {
  min-height: 0;
}

html.c5-fs-lock,
html.c5-fs-lock body {
  overflow: hidden;
}

.md-stage > .md-canvas[data-locked="true"] {
  cursor: crosshair;
}

@media (max-width: 560px) {
  .c5-toolbar {
    padding-inline: var(--dx-sp-2, 8px);
  }

  .c5-btn,
  .c5-select {
    min-height: 34px;
    min-width: 34px;
  }

  .c5-note {
    display: none;
  }
}

/* V-08 (Track H): in a narrow chart column the legend wraps inside its box, value by value, instead of running past
   the panel's edge. A single long value (a date) breaks rather than overflowing. */
.md-legend.chart-readout {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.md-legend .rd {
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
  white-space: normal;
}

.md-legend .rd b {
  overflow-wrap: anywhere;
}

.md-panel,
.md-body,
.md-stage {
  min-width: 0;
}
