.zt-chart-frame {
  min-width: 0;
  width: 100%;
  color: var(--text, #f4eee5);
  font-variant-numeric: tabular-nums;
}

.zt-chart-hud {
  position: absolute;
  z-index: 5;
  inset: 5px 76px auto 6px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: fit-content;
  max-width: calc(100% - 82px);
  pointer-events: none;
}

.zt-chart-legend {
  display: flex;
  align-items: baseline;
  gap: .3rem;
  width: fit-content;
  max-width: 100%;
  padding: 3px 5px;
  border-radius: 4px;
  color: var(--live-axis, var(--text));
  background: color-mix(in srgb, var(--live-plot, var(--surface)) 88%, transparent);
  font-size: .69rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  pointer-events: auto;
}

.zt-chart-legend > * { flex: none; }
.zt-chart-legend > :empty { display: none; }
.zt-chart-legend h2 { margin: 0; font-size: inherit; line-height: inherit; font-weight: 720; }
.zt-chart-legend strong { font-weight: 620; }
.zt-chart-legend:focus-visible { outline-offset: -1px; }

.zt-chart-exchange, .zt-chart-exchange-name {
  display: inline-flex;
  align-items: baseline;
  gap: .3rem;
}
.zt-chart-exchange-name::before {
  align-self: center;
  width: .36rem;
  height: .36rem;
  border-radius: 50%;
  background: currentColor;
  content: "";
}
.zt-chart-exchange[data-status="live"] .zt-chart-exchange-name { color: var(--live-green-label, #b4f4bc); }
.zt-chart-exchange:is([data-status="stale"], [data-status="reconnecting"]) .zt-chart-exchange-name {
  color: var(--live-warning, #f79a4c);
}
.zt-chart-exchange-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.zt-chart-indicator {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 3px 0 5px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--live-plot, var(--surface)) 88%, transparent);
  color: var(--live-axis, var(--text));
  font-size: .72rem;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
}
.zt-chart-indicator[data-visible="false"] span { color: var(--muted); }
.zt-chart-indicator button {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  min-height: 25px;
  padding: 0;
  border-color: transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--live-axis, var(--text));
  pointer-events: auto;
}
.zt-chart-indicator button:hover:enabled {
  border-color: var(--live-divider, var(--border));
  background: var(--surface-raised);
}
.zt-chart-indicator button:focus-visible { outline-offset: -1px; }
.zt-chart-indicator button .icon { width: 14px; height: 14px; }

.zt-chart-stage {
  position: relative;
  contain: inline-size;
  height: clamp(270px, 29vw, 470px);
  border: 1px solid var(--live-divider, var(--line));
  border-radius: 9px;
  overflow: hidden;
}

.zt-chart-canvas {
  position: relative;
  width: 100%;
  height: 100%;
}

.zt-chart-canvas:focus-visible { outline-offset: -2px; }

.zt-chart-drawing-grip {
  position: absolute;
  z-index: 5;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  touch-action: none;
  cursor: ns-resize;
}

.zt-chart-drawing-grip::before {
  position: absolute;
  inset: 6px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  background: var(--live-plot, var(--surface));
  content: "";
}

.zt-chart-drawing-grip[data-drawing-grip="target"] { color: var(--live-target, #4fdb6b); }
.zt-chart-drawing-grip[data-drawing-grip="stop"] { color: var(--live-down, #fa4748); }
.zt-chart-drawing-grip:is([data-drawing-grip="horizontal"], [data-drawing-grip="from"], [data-drawing-grip="to"]) { color: var(--live-drawing, #79a8ff); }
.zt-chart-drawing-grip:is([data-drawing-grip="from"], [data-drawing-grip="to"]) { cursor: move; }
.zt-chart-canvas[data-drawing-cursor="horizontal"] { cursor: ns-resize; }
.zt-chart-canvas:is([data-drawing-cursor="from"], [data-drawing-cursor="to"]) { cursor: move; }
.zt-chart-drawing-grip[data-drawing-grip="resize"] { color: var(--live-drawing, #79a8ff); cursor: nwse-resize; }

.zt-chart-context {
  position: absolute;
  z-index: 6;
  min-width: 100px;
  padding: 3px;
  border: 1px solid var(--live-divider, var(--border));
  border-radius: 7px;
  background: var(--live-plot, var(--surface));
  box-shadow: var(--shadow);
}

.zt-chart-context button {
  width: 100%;
  min-height: 32px;
  padding: 4px 10px;
  border-color: transparent;
  background: none;
  justify-content: flex-start;
  color: var(--live-axis, var(--text));
  font-size: .78rem;
}

.zt-chart-context button:is(:hover, :focus-visible) {
  border-color: var(--live-divider, var(--border));
  background: var(--surface-raised);
  outline-offset: -2px;
}

.zt-chart-context [data-chart-context-clear] { color: var(--live-red-label, var(--red)); }

.zt-chart-issues {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  color: var(--live-warning, #f79a4c);
}

.zt-chart-issue {
  position: absolute;
  inset-block: 5px 0;
  border-left: 1px dashed currentColor;
  opacity: .7;
}

.zt-chart-issue::before {
  content: "!";
  position: absolute;
  left: 0;
  top: 1px;
  transform: translateX(-50%);
  width: 10px;
  border-radius: 3px;
  background: var(--live-plot, var(--surface));
  text-align: center;
  font: 700 10px/12px Inter, sans-serif;
}

.zt-chart-issue[data-issue="adjusted_open"] {
  border-color: transparent;
}

.zt-chart-issue[data-issue="adjusted_open"]::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

.zt-chart-overlay {
  position: absolute;
  inset: 0 74px 0 0;
  z-index: 3;
  pointer-events: none;
}

.zt-chart-trade-entry {
  position: absolute;
  inset-inline-end: 6px;
  max-width: calc(100% - 12px);
  display: flex;
  flex-wrap: wrap;
  gap: 2px 7px;
  align-items: center;
  padding: 4px 7px;
  transform: translateY(-50%);
  border: 1px solid var(--live-gold, #ffca60);
  border-radius: 6px;
  background: var(--live-plot, var(--surface));
  color: var(--live-axis, var(--text));
  font-size: .72rem;
  line-height: 1.2;
  white-space: nowrap;
}

.zt-chart-trade-level { font-weight: 700; }
.zt-chart-frame [data-entry-edit] {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
  font-weight: 700;
  line-height: inherit;
  pointer-events: auto;
  touch-action: none;
  cursor: ns-resize;
}
.zt-chart-frame [data-entry-edit]:hover,
.zt-chart-frame [data-entry-edit].dragging { color: var(--live-gold, #ffca60); }

.zt-chart-trade-entry [data-chart-reward-risk],
.zt-draft-entry [data-chart-reward-risk] {
  color: var(--live-gold, #ffca60);
  font-weight: 700;
}

[data-chart-reward-risk]:empty, [data-chart-live-pnl]:empty { display: none; }
[data-chart-live-pnl][data-direction="gain"] { color: var(--live-target, #4fdb6b); }
[data-chart-live-pnl][data-direction="loss"] { color: var(--live-down, #fa4748); }

.zt-chart-frame .zt-chart-handle {
  position: absolute;
  inset-inline: 5px 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  z-index: 1;
  padding: 0;
  min-height: 12px;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--zt-handle-color);
  font-size: .77rem;
  white-space: nowrap;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  cursor: ns-resize;
}

.zt-chart-handle > span {
  min-width: 0;
  padding: 3px 7px;
  border: 1px solid var(--zt-handle-color);
  border-radius: 5px;
  background: var(--live-plot, var(--surface));
  overflow: hidden;
  text-overflow: ellipsis;
}

.zt-chart-frame .zt-chart-handle:disabled:not(.dragging) {
  opacity: 1;
  pointer-events: none;
}

.zt-chart-frame .zt-chart-handle:focus-visible { outline: none; }
.zt-chart-frame .zt-chart-handle:focus-visible > span {
  outline: 2px solid var(--zt-handle-color);
  outline-offset: 2px;
}

.zt-chart-frame .zt-chart-handle.dragging > span,
.zt-chart-frame .zt-chart-handle:hover > span {
  box-shadow: 0 0 0 1px var(--zt-handle-color);
}

.zt-chart-handle-target { --zt-handle-color: var(--live-target, #4fdb6b); }
.zt-chart-handle-stopTrigger { --zt-handle-color: var(--live-down, #fa4748); }
.zt-chart-frame .zt-chart-handle-close { --zt-handle-color: var(--live-gold, #ffca60); width: max-content; }

.zt-chart-manual {
  position: absolute;
  inset: 0 74px 0 0;
  z-index: 4;
  pointer-events: none;
}

.zt-draft-entry {
  position: absolute;
  inset-inline-end: 7px;
  z-index: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: calc(100% - 14px);
  gap: 3px;
  padding: 3px;
  transform: translateY(-50%);
  border: 1px dashed var(--zt-draft-color);
  border-radius: 10px;
  background: var(--live-plot, var(--surface));
  --zt-draft-color: var(--live-up, #32ca73);
  --zt-confirm-fill: #176539;
  --zt-confirm-hover: #217244;
}

.zt-draft-entry-main, .zt-draft-entry-options, .zt-draft-entry-steps {
  display: flex;
  align-items: center;
  gap: 3px;
}
.zt-draft-entry-options { flex-wrap: wrap; justify-content: flex-end; }

.zt-draft-entry [data-chart-reward-risk] {
  padding-inline: 3px;
  font-size: .69rem;
  white-space: nowrap;
}

.zt-draft-entry[data-side="short"] {
  --zt-draft-color: var(--live-down, #fa4748);
  --zt-confirm-fill: #952731;
  --zt-confirm-hover: #aa3540;
}

.zt-chart-manual button {
  min-height: 26px;
  padding: 2px 6px;
  border: 1px solid color-mix(in srgb, var(--zt-draft-color) 60%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--zt-draft-color) 12%, var(--live-plot, var(--surface)));
  color: var(--zt-draft-color);
  font-size: .72rem;
  font-weight: 750;
  line-height: 1.1;
  white-space: nowrap;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  cursor: ns-resize;
}

.zt-chart-manual button:focus-visible,
.zt-chart-manual button.dragging {
  outline: 1px solid var(--zt-draft-color);
  outline-offset: 2px;
}

.zt-chart-manual button:disabled { cursor: progress; }

.zt-chart-manual .zt-draft-confirm {
  padding-inline: 8px;
  background: var(--zt-confirm-fill);
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
}
.zt-chart-manual .zt-draft-confirm:hover:enabled { background: var(--zt-confirm-hover); }
.zt-chart-manual [data-draft-entry-step] {
  min-width: 26px;
  padding-inline: 4px;
  cursor: pointer;
  touch-action: manipulation;
}

.zt-chart-manual [data-order-type="market"] [data-draft-level="entry"] {
  opacity: 1;
  cursor: default;
}

.zt-draft-protection {
  position: absolute;
  inset-inline-start: 7px;
  transform: translateY(-50%);
}

.zt-draft-protection.dragging { z-index: 2; }

.zt-chart-manual [data-draft-level="target"] { inset-inline-start: 52px; }

.zt-chart-manual [data-draft-level="entryTrigger"] {
  inset-inline-start: 97px;
  --zt-draft-color: var(--live-gold, #ffca60);
}

.zt-chart-manual [data-draft-level="stopTrigger"],
.zt-chart-manual [data-draft-attach="stopTrigger"] { --zt-draft-color: var(--live-down, #fa4748); }

.zt-chart-manual [data-draft-level="target"],
.zt-chart-manual [data-draft-attach="target"] { --zt-draft-color: var(--live-target, #4fdb6b); }

.zt-chart-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.zt-chart-review { width: min(510px, calc(100% - 1.75rem)); }
.zt-chart-review .dialog-heading h2 {
  margin: 0;
  font-size: 1.08rem;
}

.zt-chart-review .zt-chart-close {
  flex-shrink: 0;
  width: 32px;
  min-height: 32px;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
}

.zt-chart-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  gap: 8px;
}

.zt-chart-fields label {
  display: grid;
  min-width: 0;
  gap: 4px;
  font-size: .79rem;
}

.zt-chart-fields input { width: 100%; min-width: 0; }
.zt-chart-skip {
  display: flex;
  align-items: start;
  gap: 8px;
  font-size: .85rem;
}
.zt-chart-skip input {
  width: 1rem;
  height: 1rem;
  min-height: 1rem;
  flex: 0 0 auto;
  margin: 2px 0 0;
  accent-color: var(--accent);
}
.zt-chart-limit, .zt-chart-message { margin: 0; }
.zt-chart-message:not(:empty) { color: var(--red); }
.zt-chart-message:empty { display: none; }
.zt-chart-editor-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 7px; }
.zt-chart-credit {
  position: absolute;
  z-index: 3;
  inset-inline-start: 6px;
  inset-block-end: calc(var(--zt-time-axis-height, 24px) + 3px);
  max-width: calc(100% - 82px);
  padding: 2px 4px;
  border-radius: 4px;
  color: var(--live-caption, var(--muted));
  background: color-mix(in srgb, var(--live-plot, var(--surface)) 92%, transparent);
  font-size: .62rem;
  line-height: 1.25;
  pointer-events: none;
}
.zt-chart-credit a { color: inherit; text-underline-offset: 2px; pointer-events: auto; }

.zt-chart-frame [hidden] { display: none; }

.live-chart:fullscreen .zt-chart-frame { display: flex; flex: 1; min-height: 0; flex-direction: column; }
.live-chart:fullscreen .zt-chart-stage { flex: 1; height: auto; min-height: 175px; }

@media (max-width: 650px) {
  .zt-chart-stage { height: clamp(248px, 67vw, 370px); }
  .zt-chart-hud { inset-inline-end: 6px; max-width: calc(100% - 12px); }
  .zt-chart-legend { font-size: .65rem; }
  .zt-chart-indicator { font-size: .69rem; }
  .zt-chart-indicator button { width: 27px; height: 27px; min-height: 27px; }
  .zt-chart-frame .zt-chart-handle { font-size: .7rem; }
  .zt-chart-trade-entry[data-open="true"]:not([hidden]) {
    display: grid;
    width: max-content;
  }
  .zt-chart-trade-entry[data-open="true"] { grid-template-columns: repeat(2, max-content); }
  .zt-chart-trade-entry [data-chart-live-pnl] { grid-column: 1 / -1; }
  .zt-draft-entry { width: max-content; }
  .zt-draft-entry[data-order-type="limit"] { padding: 0; border: 0; background: transparent; }
  .zt-draft-entry[data-order-type="limit"] .zt-draft-entry-options {
    position: absolute;
    inset-inline-end: 0;
    inset-block-end: calc(100% + 3px);
    width: max-content;
  }
  .zt-draft-entry[data-order-type="limit"][data-side="short"] .zt-draft-entry-options {
    inset-block: calc(100% + 3px) auto;
  }
  .zt-draft-entry[data-order-type="limit"] [data-chart-reward-risk]:not(:empty) {
    padding: 4px 5px;
    border-radius: 5px;
    background: var(--live-plot, var(--surface));
  }
  .zt-chart-manual .zt-draft-confirm, .zt-chart-manual [data-draft-entry-step] { min-height: 30px; }
  .zt-chart-manual [data-draft-level="entryTrigger"] { inset-inline-start: 7px; }
}
