/* v2 chart context menu → kit x-ctx. Compact (anh): narrow, small text, tight pad.
   Clip-path steps reveal. Independent of v1 css/ctxmenu.css. */

@keyframes x-pop {
  from {
    clip-path: inset(0 0 100% 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}

.v2-cxm,
.v2-cxm.x-ctx {
  position: fixed;
  z-index: 120;
  border-radius: var(--r);
}
.v2-cxm[hidden] {
  display: none !important;
}
.v2-cxm-ghost {
  pointer-events: none;
}
.v2-cxm-c {
  position: relative;
  min-width: 180px;
  max-width: min(240px, calc(100vw - 16px));
  max-height: calc(100vh - 16px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 4px;
  background: var(--tile);
  border: 1px solid var(--acc);
  box-shadow: var(--v2-shadow-4) var(--acc);
  border-radius: var(--r);
  color: var(--tx);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  outline: none;
  animation: x-pop 120ms var(--st);
}
.v2-cxm.sub .v2-cxm-c {
  min-width: 140px;
}
.v2-cxm-hl {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 28px;
  background: var(--alt);
  opacity: 0;
  pointer-events: none;
  border-radius: var(--r);
}
.v2-cxm-hl[data-tone="danger"] {
  background: var(--crit);
  opacity: 0.18;
}
.v2-cxm-i {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: var(--tx);
  font: 600 12px var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  cursor: var(--cur-pointer);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.v2-cxm-i:hover:not(:disabled),
.v2-cxm-i[data-active]:not(:disabled),
.v2-cxm-i:focus-visible:not(:disabled) {
  background: var(--acc);
  color: var(--ink);
  font-weight: 700;
  outline: 0;
}
.v2-cxm-i:disabled {
  opacity: 0.35;
  cursor: var(--cur-default);
  color: var(--mute);
}
.v2-cxm-i[data-tone="danger"] {
  color: var(--crit-tx);
}
.v2-cxm-i[data-tone="danger"]:hover:not(:disabled),
.v2-cxm-i[data-tone="danger"][data-active]:not(:disabled) {
  background: var(--crit);
  color: var(--ink);
}
.v2-cxm-i .lab {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.v2-cxm-i .hint {
  flex: 0 0 auto;
  color: var(--mute);
  font-weight: 400;
}
.v2-cxm-i:hover .hint,
.v2-cxm-i[data-active] .hint {
  color: var(--ink);
  opacity: 0.75;
}
.v2-cxm-i .chev {
  flex: 0 0 auto;
  color: var(--mute);
}
.v2-cxm-i:hover .chev,
.v2-cxm-i[data-active] .chev {
  color: var(--ink);
}
.v2-cxm-i .v2-cxm-ind {
  flex: 0 0 12px;
  width: 12px;
  height: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--alt);
}
.v2-cxm-i.on .v2-cxm-ind,
.v2-cxm-i[aria-checked="true"] .v2-cxm-ind {
  background: var(--acc);
  border-color: var(--acc);
  color: var(--ink);
}
.v2-cxm-i:hover .v2-cxm-ind,
.v2-cxm-i[data-active] .v2-cxm-ind {
  border-color: var(--ink);
}
.v2-cxm-i .v2-cxm-ind.radio {
  border-radius: var(--r);
}
.v2-cxm-i .v2-cxm-ind.radio > i {
  display: none;
  width: 6px;
  height: 6px;
  background: var(--ink);
}
.v2-cxm-i.on .v2-cxm-ind.radio > i,
.v2-cxm-i[aria-checked="true"] .v2-cxm-ind.radio > i {
  display: block;
}
.v2-cxm-sep {
  height: 1px;
  margin: 2px 0;
  background: var(--line);
  border: 0;
}
.v2-cxm-lab {
  padding: 4px 8px 2px;
  color: var(--mute);
  font-size: var(--fs-12);
  font-family: var(--mono);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
html.v2-cxm-press {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Chart settings panel (opened from the menu's CHART SETTINGS). Wide, two tabs:
   MAIN = chart, TRADING = order confirms + hotkeys. Rows = label + kit x-tg switch. */
.v2-chart-set {
  position: fixed;
  z-index: 121;
  width: 560px;
  max-width: calc(100vw - 16px);
  /* Compact: a long tab (HOTKEYS) scrolls inside the body instead of growing the panel. */
  max-height: min(480px, calc(100vh - 16px));
  display: flex;
  flex-direction: column;
  background: var(--tile);
  border: 1px solid var(--acc);
  box-shadow: var(--v2-shadow-4) var(--acc);
  border-radius: var(--r);
  color: var(--tx);
  font-family: var(--mono);
  font-size: var(--fs-12);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  touch-action: manipulation;
  animation: x-pop 160ms var(--st);
}
.v2-chart-set[hidden] {
  display: none !important;
}
.v2-chart-set .v2-hd {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 33px;
  padding: 0 8px;
  background: var(--alt);
  border-bottom: 1px solid var(--line);
}
/* Desktop: the header is the drag handle. */
.v2-chart-set .v2-hd {
  cursor: grab;
  user-select: none;
}
.v2-chart-set[data-v2-drag] .v2-hd {
  cursor: grabbing;
}
.v2-chart-set[data-v2-touch] .v2-hd {
  cursor: default;
}
.v2-chart-set .v2-chart-set-x {
  cursor: pointer;
  margin-left: auto;
  height: 26px;
  min-height: 26px;
  padding: 0 8px;
}
/* Kit x-tabs: active = inverted block. */
.v2-chart-set-tabs.x-tabs {
  flex: 0 0 auto;
  display: flex;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.v2-chart-set-tabs.x-tabs button {
  flex: 1 1 0;
  min-height: 33px;
  padding: 0 16px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: var(--r);
  background: transparent;
  color: var(--mute);
  font: 600 var(--fs-12) var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 160ms var(--st);
}
.v2-chart-set-tabs.x-tabs button:last-child {
  border-right: 0;
}
.v2-chart-set-tabs.x-tabs button:hover {
  color: var(--tx);
}
.v2-chart-set-tabs.x-tabs button[aria-selected="true"] {
  position: relative;
  background: transparent;
  color: var(--tx);
}
.v2-chart-set-tabs.x-tabs button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 3px;
  background: var(--acc);
  pointer-events: none;
}
.v2-chart-set-tabs.x-tabs button:focus-visible {
  outline: 1px solid var(--bone);
  outline-offset: -3px;
}
.v2-chart-set-body {
  flex: 1 1 auto;
  min-height: 0;
  /* Vertical only: nothing in settings is meant to scroll sideways (same fix as the ticket, #137). */
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
/* Sections side by side; the 1px gaps show --line as rules. */
.v2-chart-set-p {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
}
.v2-chart-set-sec {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--tile);
}
.v2-chart-set-sec .x-lab {
  margin: 0;
  padding: 8px 8px 4px;
  color: var(--mute);
  font: 500 var(--fs-12) var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
/* Leftover space under a shorter section: large area → plain tile, no diagonal hatch. */
.v2-chart-set-sec::after {
  content: "";
  flex: 1 1 auto;
  min-height: 0;
  background: var(--tile);
}
.v2-chart-set-keys::after,
.v2-chart-set-ref::after {
  display: none;
}
/* Reference rows are read-only and desktop only: denser than the rebindable keycaps. */
.v2-chart-set .v2-chart-set-ref .x-ks {
  gap: 4px;
}
.v2-chart-set .v2-chart-set-ref .x-ks > div {
  padding: 4px 8px;
}
.v2-chart-set .v2-chart-set-ref .x-ks kbd {
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
}
.v2-chart-set-tf {
  text-transform: none;
}
/* Always-on reference keys: read-only caps, one combo per alternative. */
.v2-chart-set-combo {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  color: var(--mute);
}
/* TRADING and HOTKEYS stack full width: long confirm labels, the switches, then the key grids. */
.v2-chart-set-p[data-v2-pane="trading"],
.v2-chart-set-p[data-v2-pane="hotkeys"] {
  grid-template-columns: 1fr;
}
.v2-chart-set-b {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--line);
  border-top: 1px solid var(--line);
  /* The kit press (translate 2px) stays inside the section, so pressing a row (Privacy mode sits on the
     right edge) never grows the panel's scroll area and flashes a scrollbar. clip, not hidden: no scroll box. */
  overflow: clip;
}
.v2-chart-set-b .v2-btn,
.v2-chart-set-b .v2-chart-set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 33px;
  min-height: 33px;
  padding: 0 8px;
  background: var(--tile);
  border: 0;
  border-radius: var(--r);
  width: 100%;
  color: var(--tx);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  touch-action: manipulation;
  box-sizing: border-box;
  white-space: nowrap;
}
.v2-chart-set-row .lab {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}
/* State lives in the switch, not the row: drop the shell's inverted .v2-btn.on block. */
.v2-chart-set-b .v2-chart-set-row.on {
  background: var(--tile);
  color: var(--tx);
  box-shadow: none;
}
.v2-chart-set-b .v2-chart-set-row:hover,
.v2-chart-set-b .v2-chart-set-row.on:hover,
.v2-chart-set-b .v2-chart-set-row:focus-visible {
  background: var(--alt);
  color: var(--tx);
  box-shadow: none;
  outline: 0;
}
/* Kit x-tg, row-sized (kit is 80×44): mute knob off, rose knob + rose frame on. */
.v2-chart-set-row .x-tg {
  flex: 0 0 auto;
  display: flex;
  width: 40px;
  height: 20px;
  padding: 3px;
  border: 1px solid var(--line);
  background: var(--bg);
  box-sizing: border-box;
}
.v2-chart-set-row .x-tg i {
  width: 12px;
  height: 12px;
  background: var(--mute);
  transition:
    transform 160ms var(--st-3),
    background 160ms var(--st-3);
}
.v2-chart-set-row[aria-checked="true"] .x-tg {
  border-color: var(--acc);
}
.v2-chart-set-row[aria-checked="true"] .x-tg i {
  transform: translateX(20px);
  background: var(--acc);
}
/* Kit x-ks shortcut grid + kbd keycaps. Dimmed while hotkeys are off. */
.v2-chart-set .x-ks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  padding: 8px;
  border-top: 1px solid var(--line);
}
.v2-chart-set .x-ks > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
}
.v2-chart-set .x-ks kbd {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--bone);
  border-bottom-width: 3px;
  background: var(--alt);
  color: var(--tx);
  font: 600 var(--fs-12) var(--mono);
  box-sizing: border-box;
}
/* Keycap is a button: click it, then press the new key. Capture = rose cap + blink. */
.v2-chart-set .v2-chart-set-kbd {
  display: inline-grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.v2-chart-set .v2-chart-set-kbd:hover kbd,
.v2-chart-set .v2-chart-set-kbd:focus-visible kbd {
  border-color: var(--acc);
}
.v2-chart-set .v2-chart-set-kbd:focus-visible {
  outline: 1px solid var(--acc);
  outline-offset: 2px;
}
.v2-chart-set .v2-chart-set-kbd[aria-pressed="true"] kbd {
  border-color: var(--acc);
  background: var(--acc-hi);
  color: var(--bg);
  animation: v2-kbd-cap 800ms var(--st-2) infinite;
}
@keyframes v2-kbd-cap {
  50% {
    opacity: 0.5;
  }
}
@media (prefers-reduced-motion: reduce) {
  .v2-chart-set .v2-chart-set-kbd[aria-pressed="true"] kbd {
    animation: none;
  }
}
.v2-chart-set[data-v2-hotkeys="off"] .v2-chart-set-keys .x-ks {
  opacity: 0.45;
}
/* Footer: one full-width reset action under the tabs. */
.v2-chart-set-ft {
  flex: 0 0 auto;
  display: flex;
  border-top: 1px solid var(--line);
  background: var(--tile);
}
.v2-chart-set-ft .v2-chart-set-reset {
  flex: 1 1 auto;
  height: 33px;
  min-height: 33px;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: var(--bone);
  box-shadow: none;
  font: 600 var(--fs-12) var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.v2-chart-set-ft .v2-chart-set-reset:hover,
.v2-chart-set-ft .v2-chart-set-reset:focus-visible {
  background: var(--bone);
  color: var(--ink);
  outline: 0;
}
/* Phones / touch: hotkey rows, switch and key list are hidden (no keyboard). */
.v2-chart-set[data-v2-touch] .v2-hk-only {
  display: none;
}
.v2-chart-set-note {
  margin: 0;
  padding: 0 8px 8px;
  color: var(--mute);
  font: 400 var(--fs-12) var(--mono);
  letter-spacing: 0.04em;
  text-transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .v2-cxm-c,
  .v2-chart-set {
    animation: none;
  }
}
/* Hotkey order spec, read from the ticket. Brighter than the hint under it. */
.v2-chart-set-note.v2-chart-set-uses {
  color: var(--tx);
}
.v2-chart-set-uses:empty {
  display: none;
}
