/* ============================================================
   ProfitData — Chart Page
   ============================================================ */
:root {
  --toolbar-w:  38px;
  --sidebar-w:  320px;
  --topbar-h:   38px;
  --status-h:   22px;
  --pane-hdr-h: 20px;
}

body.chart-page {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh; overflow: hidden;
  padding-top: calc(var(--header-h) + 28px);
}

/* ─────────────────────────────────────────
   TOP CONTROL BAR
───────────────────────────────────────── */
.chart-topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0; padding: 0 6px;
  flex-shrink: 0; overflow: visible;
}

/* Symbol block */
.symbol-selector {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px; cursor: pointer; border-radius: 4px;
  transition: background .12s; position: relative; min-width: 160px;
}
.symbol-selector:hover { background: var(--bg3); }
.sym-name  { font-weight: 700; font-size: 14px; letter-spacing: -.2px; }
.sym-price { font-size: 12px; font-weight: 600; white-space: nowrap; }
.sym-change { font-size: 11px; white-space: nowrap; }
/* Auto-collapse price/change when topbar is too narrow */
.sym-info {
  display: flex; flex-direction: column; gap: 1px;
  overflow: hidden; min-width: 0; flex-shrink: 100;
}
/* Prevent sym-name from shrinking */
.symbol-selector > div:first-child { flex-shrink: 0; }
@media (max-width: 1050px) {
  .sym-info { display: none; }
}

.sym-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 6px; z-index: 400; min-width: 220px;
  box-shadow: 0 8px 32px rgba(0,0,0,.6); display: none;
}
.sym-dropdown.open { display: block; }
.sym-search { padding: 8px; border-bottom: 1px solid var(--border); }
.sym-search input {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); padding: 5px 9px; font-size: 12px;
  font-family: var(--font);
}
.sym-search input:focus { outline: none; border-color: var(--accent); }
.sym-list { max-height: 260px; overflow-y: auto; }
.sym-item {
  padding: 8px 12px; cursor: pointer; display: flex;
  justify-content: space-between; align-items: center; font-size: 12px;
}
.sym-item:hover { background: var(--bg3); }
.sym-item.active { color: var(--accent); }

/* Separator */
.topbar-sep {
  width: 1px; height: 18px; background: var(--border);
  margin: 0 6px; flex-shrink: 0;
}

/* Exchange selector */
.exchange-sel {
  background: transparent; border: none; color: var(--text2);
  font-size: 12px; font-weight: 500; padding: 3px 6px;
  font-family: var(--font); border-radius: 4px;
}
.exchange-sel:focus { outline: none; }
.exchange-sel:hover { background: var(--bg3); color: var(--text); }

/* Timeframe buttons */
.tf-group { display: flex; gap: 1px; }
.tf-btn {
  background: none; border: none; color: var(--text2);
  padding: 3px 7px; border-radius: 3px; font-size: 12px; font-weight: 600;
  transition: all .1s;
}
.tf-btn:hover { background: var(--bg3); color: var(--text); }
.tf-btn.active { background: var(--bg3); color: var(--accent); }

/* Chart type dropdown */
.ct-dropdown { position: relative; }
.ct-trigger {
  display: flex; align-items: center; gap: 4px;
  height: 28px; padding: 0 7px;
  background: none; border: 1px solid var(--border);
  border-radius: 4px; cursor: pointer; color: var(--text2);
  transition: background .1s, color .1s;
}
.ct-trigger:hover { background: var(--bg3); color: var(--text); }
.ct-icon { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; }
.ct-caret { flex-shrink: 0; opacity: .6; }
.ct-menu {
  display: none; position: fixed;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px;
  z-index: 300; min-width: 200px;
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
  max-height: 420px; overflow-y: auto;
}
.ct-menu.open { display: block; }
.ct-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: 4px;
  cursor: pointer; color: var(--text2);
  font-size: 12px; transition: background .1s, color .1s;
}
.ct-item:hover { background: var(--bg3); color: var(--text); }
.ct-item.active { color: var(--accent); }
.ct-item-icon { display: flex; align-items: center; width: 20px; flex-shrink: 0; }
.ct-item-name { flex: 1; }
.ct-item-soon { opacity: .4; cursor: default; }
.ct-item-soon:hover { background: none; color: var(--text2); }
.ct-badge {
  font-size: 9px; padding: 1px 4px; border-radius: 3px;
  background: var(--bg4); color: var(--text2); flex-shrink: 0;
}
.ct-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* Indicators / Layout buttons */
.ind-btn {
  background: none; border: none; color: var(--text2);
  font-size: 12px; font-weight: 500; padding: 3px 8px;
  border-radius: 3px; transition: all .12s; white-space: nowrap;
}
.ind-btn:hover { background: var(--bg3); color: var(--text); }

/* Screenshot */
.screenshot-btn {
  background: none; border: none; padding: 3px 6px;
  color: var(--text3); font-size: 14px; border-radius: 3px;
  margin-left: auto;
}
.screenshot-btn:hover { color: var(--text2); background: var(--bg3); }

/* Layout picker */
.layout-picker-wrap { position: relative; }
.layout-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px; z-index: 400;
  display: none; flex-wrap: wrap; gap: 6px; width: 200px;
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
}
.layout-dropdown.open { display: flex; }
.lpick-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 7px; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--border); font-size: 10px; color: var(--text2);
  transition: all .12s; min-width: 52px;
}
.lpick-item:hover { background: var(--bg3); color: var(--text); border-color: var(--text3); }
.lpick-item.active { border-color: var(--accent); color: var(--accent); }
.lpick-preview { display: grid; gap: 2px; width: 36px; height: 24px; }
.lpick-preview div { background: var(--bg4); border-radius: 1px; }
.lp-1x1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.lp-2h  { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
.lp-2v  { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
.lp-3h  { grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr; }
.lp-2x2 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.lp-3v  { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr 1fr; }

/* ─────────────────────────────────────────
   MAIN LAYOUT
───────────────────────────────────────── */
.chart-layout {
  display: flex; flex: 1; overflow: hidden; min-height: 0;
}

/* ─────────────────────────────────────────
   LEFT DRAWING TOOLBAR (TV style)
───────────────────────────────────────── */
.draw-toolbar {
  width: var(--toolbar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 4px 0; gap: 1px; flex-shrink: 0; overflow-y: auto; overflow-x: visible;
}
.draw-btn {
  width: 30px; height: 30px; background: none; border: none;
  border-radius: 4px; color: var(--text2); font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: all .1s; position: relative; flex-shrink: 0;
}
.draw-btn:hover { background: var(--bg3); color: var(--text); }
.draw-btn.active { background: rgba(41,98,255,.2); color: var(--accent); }
.draw-btn:disabled { opacity: .3; }
.draw-sep { width: 22px; height: 1px; background: var(--border); margin: 2px 0; flex-shrink: 0; }
.draw-group { position: relative; }
.draw-group-btn { cursor: pointer; }
.group-icon { display: flex; align-items: center; justify-content: center; }
.group-chevron {
  position: absolute; right: 2px; bottom: 2px;
  font-size: 9px; line-height: 1; opacity: 0.4; pointer-events: none;
}
.draw-flyout {
  display: none; position: fixed;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 6px; flex-direction: column;
  padding: 4px; gap: 2px; z-index: 300;
  box-shadow: 3px 4px 14px rgba(0,0,0,.5);
  min-width: 38px;
}
.draw-group.open .draw-flyout { display: flex; }
.draw-flyout.grid {
  flex-direction: row; flex-wrap: wrap;
  width: 180px; gap: 2px; padding: 6px;
}
.draw-flyout.grid .draw-btn { width: 32px; height: 32px; }
.draw-flyout .draw-btn[title]:hover::after { left: calc(100% + 8px); }
.draw-flyout.grid .draw-btn[title]:hover::after { left: auto; bottom: calc(100% + 4px); top: auto; transform: translateX(-50%); }
.draw-btn[title]:hover::after {
  content: attr(title);
  position: absolute; left: calc(100% + 8px); top: 50%;
  transform: translateY(-50%);
  background: var(--bg4); border: 1px solid var(--border);
  border-radius: 4px; padding: 3px 8px; font-size: 11px;
  white-space: nowrap; color: var(--text); pointer-events: none; z-index: 500;
}

/* ─────────────────────────────────────────
   FLOATING DRAWING PROPERTIES PANEL
───────────────────────────────────────── */
/* (drawing-panel moved to DRAWING CONTROL PANEL section below) */

/* ─────────────────────────────────────────
   CHART AREA (center)
───────────────────────────────────────── */
.chart-area {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; background: var(--bg); position: relative; min-width: 0;
}

/* Chart legend (TV-style, top-left of chart, below cell-header) */
.chart-legend {
  position: absolute; top: 28px; left: 8px; z-index: 10;
  font-size: 11px; pointer-events: none;
}
#legMain {
  color: var(--text2); display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  line-height: 1.4; pointer-events: none;
}
#legMain .leg-main-sym { font-weight: 700; color: var(--text); font-size: 11px; }
#legMain b { font-weight: 600; }
#legMain .c-up { color: var(--green); }
#legMain .c-dn { color: var(--red); }
#legOverlays {
  display: flex; flex-direction: column; gap: 2px;
  margin-top: 3px; pointer-events: auto;
}
.leg-row {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(6,8,16,.8); border-radius: 3px; padding: 1px 5px 1px 4px;
  width: fit-content;
}
.leg-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.leg-sym  { font-weight: 600; color: var(--text); font-size: 11px; }
.leg-val  { color: var(--text2); font-size: 11px; }
.leg-remove {
  background: none; border: none; color: var(--text3);
  font-size: 14px; padding: 0; line-height: 1; cursor: pointer; margin-left: 1px;
}
.leg-remove:hover { color: var(--red); }

/* Loading overlay */
#chartLoader {
  display: none; position: absolute; inset: 0;
  align-items: center; justify-content: center;
  background: rgba(6,8,16,.75); z-index: 100; pointer-events: none;
}
#chartLoader span { color: var(--text2); font-size: 13px; }

/* Chart grid (multi-chart mode) */
.chart-grid {
  display: grid; flex: 1; min-height: 0; gap: 1px; background: var(--border);
  touch-action: none; /* prevent browser scroll interfering with chart gestures */
}
.chart-cell {
  background: var(--bg); display: flex; flex-direction: column;
  min-height: 0; position: relative; border: 2px solid transparent;
}
.chart-cell.active { border-color: rgba(41,98,255,.5); }
.cell-header {
  height: 24px; display: flex; align-items: center; gap: 5px;
  padding: 0 7px; font-size: 11px; flex-shrink: 0;
  background: rgba(6,8,16,.85); border-bottom: 1px solid var(--border);
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
}
.cell-sym   { font-weight: 700; }
.cell-sym-click { cursor: pointer; }
.cell-sym-click:hover { color: var(--accent); }
.cell-tf    { color: var(--text3); font-size: 10px; font-weight: 600; cursor: pointer; padding: 1px 3px; border-radius: 2px; }
.cell-tf:hover { background: var(--bg3); color: var(--text2); }
.cell-price { font-weight: 600; margin-left: auto; }
.cell-chg   { font-size: 10px; }
.cell-add-ov {
  background: rgba(41,98,255,.15); border: 1px solid rgba(41,98,255,.3);
  border-radius: 3px; color: var(--accent);
  font-size: 13px; font-weight: 800; padding: 0 4px; line-height: 1.5;
  cursor: pointer; font-family: var(--font); flex-shrink: 0;
}
.cell-add-ov:hover { background: rgba(41,98,255,.3); border-color: rgba(41,98,255,.6); }
/* Topbar undo / redo buttons */
.topbar-histbtn {
  background: none; border: none; color: var(--text2);
  padding: 3px 6px; border-radius: 3px; display: flex; align-items: center;
  transition: all .1s;
}
.topbar-histbtn:hover:not(:disabled) { background: var(--bg3); color: var(--text); }
.topbar-histbtn:disabled { opacity: .3; }

/* TF picker popup inside cell */
.cell-tf-wrap { position: relative; }
.cell-tf-popup {
  display: none; position: absolute; top: calc(100% + 2px); left: 0; z-index: 300;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 5px; padding: 5px; gap: 2px;
  flex-wrap: wrap; width: 160px;
  box-shadow: 0 6px 20px rgba(0,0,0,.6);
}
.cell-tf-popup.open { display: flex; }
.ctf-btn {
  background: none; border: none; color: var(--text2);
  padding: 3px 8px; border-radius: 3px; font-size: 11px; font-weight: 600;
  font-family: var(--font);
}
.ctf-btn:hover { background: var(--bg3); color: var(--text); }
.ctf-btn.active { color: var(--accent); background: rgba(41,98,255,.1); }
.cell-canvas { flex: 1; min-height: 0; padding-top: 24px; }

/* ─────────────────────────────────────────
   SUB-PANES (Volume, RSI, MACD)
───────────────────────────────────────── */
.sub-pane-wrap {
  display: flex; flex-direction: column; flex-shrink: 0;
  border-top: 1px solid var(--border);
}
.pane-header {
  height: var(--pane-hdr-h); display: flex; align-items: center; gap: 6px;
  padding: 0 8px; font-size: 10px; color: var(--text2);
  flex-shrink: 0; background: var(--bg);
}
.pane-title { font-weight: 600; color: var(--text2); font-size: 10px; }
.pane-legend { flex: 1; display: flex; gap: 8px; font-size: 10px; }
.pane-close {
  background: none; border: none; color: var(--text3);
  font-size: 12px; padding: 0 2px; line-height: 1;
}
.pane-close:hover { color: var(--red); }
.pane-body { height: 100px; flex-shrink: 0; }
.pane-body > div { width: 100%; height: 100%; }

/* ─────────────────────────────────────────
   STATUS BAR
───────────────────────────────────────── */
.chart-statusbar {
  height: var(--status-h);
  background: var(--bg2); border-top: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 10px; gap: 16px;
  font-size: 10.5px; color: var(--text2); flex-shrink: 0;
}
.status-ohlcv { display: flex; gap: 10px; }
.status-ohlcv span { display: flex; gap: 3px; }
.status-ohlcv .c-up { color: var(--green); }
.status-ohlcv .c-dn { color: var(--red); }
.status-coord { color: var(--text3); }

/* ─────────────────────────────────────────
   RIGHT SIDEBAR
───────────────────────────────────────── */
.chart-sidebar {
  width: var(--sidebar-w); background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden;
}
.sidebar-tabs {
  display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.stab {
  flex: 1; padding: 7px 4px; text-align: center; font-size: 11.5px;
  font-weight: 500; color: var(--text2); background: none; border: none;
  border-bottom: 2px solid transparent; transition: all .12s;
}
.stab:hover { color: var(--text); }
.stab.active { color: var(--text); border-bottom-color: var(--accent); }
.sidebar-panel { flex: 1; overflow: hidden; display: none; flex-direction: column; }
.sidebar-panel.active { display: flex; }

/* ── ORDERBOOK ── */
.ob-header {
  display: flex; justify-content: space-between;
  padding: 5px 10px; font-size: 10.5px; color: var(--text2);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.ob-spread {
  text-align: center; padding: 4px 8px; font-size: 11px;
  color: var(--text2); flex-shrink: 0; background: var(--bg3);
}
.ob-spread b { color: var(--text); }
.ob-body { flex: 1; overflow-y: auto; font-size: 11px; }
.ob-side { display: flex; flex-direction: column; }
.ob-asks { flex-direction: column-reverse; }
.ob-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  padding: 2px 10px; gap: 2px; position: relative; cursor: default;
}
.ob-row:hover { background: var(--bg3); }
.ob-row .price { font-weight: 600; }
.ob-row .size  { text-align: right; color: var(--text2); }
.ob-row .total { text-align: right; color: var(--text3); }
.ob-row .bar {
  position: absolute; top: 0; bottom: 0; opacity: .1; pointer-events: none;
}
.ob-row.ask .price { color: var(--red); }
.ob-row.ask .bar   { background: var(--red); right: 0; }
.ob-row.bid .price { color: var(--green); }
.ob-row.bid .bar   { background: var(--green); left: 0; }

/* ── TRADES ── */
.trades-header {
  display: flex; padding: 5px 10px; font-size: 10.5px; color: var(--text2);
  justify-content: space-between; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.trades-body { flex: 1; overflow-y: auto; }
.trade-row {
  display: grid; grid-template-columns: 1fr 1fr auto;
  padding: 2px 10px; font-size: 11px;
  border-bottom: 1px solid rgba(42,46,57,.5);
  animation: fadeIn .25s ease;
}
.trade-row .t-price { font-weight: 600; }
.trade-row.buy  .t-price { color: var(--green); }
.trade-row.sell .t-price { color: var(--red); }
.trade-row .t-time { color: var(--text3); font-size: 10px; text-align: right; }
.trade-row .t-size { text-align: right; color: var(--text2); }

/* ── INFO PANEL ── */
.info-panel { padding: 10px 8px; overflow-y: auto; font-size: 11.5px; }
.info-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 2px; border-bottom: 1px solid var(--border);
}
.info-row .i-label { color: var(--text2); }
.info-row .i-val   { font-weight: 600; }

/* ─────────────────────────────────────────
   INDICATOR DIALOG
───────────────────────────────────────── */
.ind-dialog-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.65); z-index: 600;
  align-items: flex-start; justify-content: center;
  padding-top: 80px;
}
.ind-dialog-overlay.open { display: flex; }
.ind-dialog {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; width: 400px; max-height: 70vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 16px 48px rgba(0,0,0,.6);
}
.ind-dialog-header {
  display: flex; align-items: center; padding: 12px 16px;
  border-bottom: 1px solid var(--border); font-weight: 600; font-size: 14px;
}
.ind-dialog-target {
  padding: 4px 16px 6px; font-size: 11px; color: var(--accent);
  border-bottom: 1px solid var(--border); background: rgba(26,108,245,.06);
}
.ind-search-wrap { padding: 8px 16px; border-bottom: 1px solid var(--border); }
.ind-search {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); padding: 6px 10px;
  font-size: 12px; font-family: var(--font);
}
.ind-search:focus { outline: none; border-color: var(--accent); }
.ind-dialog-close {
  margin-left: auto; background: none; border: none;
  color: var(--text2); font-size: 20px; line-height: 1; padding: 0 2px;
}
.ind-dialog-close:hover { color: var(--red); }
.ind-list { overflow-y: auto; padding: 6px 8px; }
.ind-category {
  padding: 6px 8px 3px; font-size: 10.5px; color: var(--text3);
  text-transform: uppercase; letter-spacing: .6px; font-weight: 600;
}
.ind-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 5px; cursor: pointer; gap: 8px;
}
.ind-item:hover { background: var(--bg3); }
.ind-item label { cursor: pointer; flex: 1; font-size: 12px; }
.ind-item .ind-badge {
  font-size: 9px; padding: 1px 5px; border-radius: 3px;
  background: var(--bg4); color: var(--text3); font-weight: 600;
}
.ind-toggle {
  width: 30px; height: 16px; background: var(--bg4);
  border-radius: 8px; position: relative; transition: background .15s;
  flex-shrink: 0;
}
.ind-toggle.on { background: var(--accent); }
.ind-toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; transition: transform .15s;
}
.ind-toggle.on::after { transform: translateX(14px); }

/* ─────────────────────────────────────────
   COMPARE MODAL
───────────────────────────────────────── */
.compare-modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.65); z-index: 600;
  align-items: flex-start; justify-content: center;
  padding-top: 100px;
}
.compare-modal-overlay.open { display: flex; }
.compare-modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; width: 340px;
  box-shadow: 0 16px 48px rgba(0,0,0,.7);
  display: flex; flex-direction: column; overflow: hidden;
}
.cmp-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 14px;
}
.cmp-modal-close {
  background: none; border: none; color: var(--text2);
  font-size: 22px; line-height: 1; padding: 0 2px; cursor: pointer;
}
.cmp-modal-close:hover { color: var(--red); }
.cmp-modal-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.cmp-modal-search {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); padding: 7px 10px;
  font-size: 12px; font-family: var(--font);
}
.cmp-modal-search:focus { outline: none; border-color: var(--accent); }

.cmp-type-row, .cmp-mode-row {
  display: flex; gap: 4px;
}
.ctype-btn, .cmode-btn {
  flex: 1; padding: 5px 8px; border: 1px solid var(--border);
  border-radius: 4px; background: none; color: var(--text2);
  font-size: 11px; font-weight: 500; font-family: var(--font);
  display: flex; align-items: center; justify-content: center;
}
.ctype-btn:hover, .cmode-btn:hover { background: var(--bg3); color: var(--text); }
.ctype-btn.active, .cmode-btn.active {
  background: rgba(41,98,255,.12); color: var(--accent); border-color: rgba(41,98,255,.4);
}
.cmp-list { max-height: 240px; overflow-y: auto; }
.cmp-item {
  padding: 8px 10px; cursor: pointer; display: flex;
  justify-content: space-between; align-items: center; font-size: 12px;
  border-radius: 4px;
}
.cmp-item:hover { background: var(--bg3); }

/* Overlay sub-pane (same as indicator panes) */
.overlay-pane .pane-title { font-weight: 700; }


/* ─────────────────────────────────────────
   SCROLLBAR
───────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ─────────────────────────────────────────
   DRAWING CONTROL PANEL
───────────────────────────────────────── */
.drawing-panel {
  position: fixed;
  z-index: 250;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  display: none;
  align-items: center;
  gap: 3px;
  box-shadow: 0 4px 20px rgba(0,0,0,.6);
  pointer-events: auto;
  user-select: none;
}
.drawing-panel.visible { display: flex; }
.dp-sep { width: 1px; height: 16px; background: var(--border); margin: 0 3px; flex-shrink: 0; }
.dp-colors { display: flex; gap: 4px; align-items: center; }
.dp-color {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid transparent; padding: 0; cursor: pointer; flex-shrink: 0;
  transition: transform .1s;
}
.dp-color:hover { transform: scale(1.2); }
.dp-color.active { border-color: #fff; box-shadow: 0 0 0 1px rgba(255,255,255,.4); }
.dp-widths, .dp-styles { display: flex; gap: 1px; align-items: center; }
.dp-width, .dp-style {
  background: none; border: none; color: var(--text2);
  padding: 3px 5px; border-radius: 3px; cursor: pointer;
  font-size: 13px; line-height: 1; transition: all .1s;
}
.dp-width:hover, .dp-style:hover,
.dp-width.active, .dp-style.active { color: var(--text); background: var(--bg3); }
.dp-action {
  background: none; border: none; color: var(--text2);
  padding: 4px 5px; border-radius: 3px; cursor: pointer;
  display: flex; align-items: center; transition: all .1s;
}
.dp-action:hover { color: var(--text); background: var(--bg3); }
.dp-action.locked { color: var(--yellow); }
.dp-delete:hover { color: var(--red) !important; }

/* Cursor: crosshair when drawing, pointer when over a selected drawing */
.chart-cell.has-selected { cursor: default; }

/* ─────────────────────────────────────────
   MOBILE HAMBURGER + MENU SHEET
───────────────────────────────────────── */
.mob-hamburger {
  display: none;
  background: none; border: none; color: var(--text2);
  padding: 5px; border-radius: 4px; cursor: pointer; align-items: center;
}
.mob-hamburger:hover { background: var(--bg3); color: var(--text); }

.mob-menu-sheet {
  display: none; position: fixed; bottom: calc(52px + env(safe-area-inset-bottom)); left: 0; right: 0;
  z-index: 310; background: var(--bg);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 32px rgba(0,0,0,.5);
  overflow: hidden;
}
.mob-menu-sheet.open { display: block; }
.mob-sheet-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 12px; border-bottom: 1px solid var(--border);
}
.mob-sheet-close {
  background: none; border: none; color: var(--text2);
  font-size: 24px; line-height: 1; padding: 0 2px; cursor: pointer;
  font-family: var(--font); flex-shrink: 0;
}
.mob-sheet-close:hover { color: var(--text); }
.mob-menu-nav { display: flex; flex-direction: column; }
.mob-menu-item {
  padding: 13px 20px; font-size: 14px; color: var(--text2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  text-decoration: none; cursor: pointer;
}
.mob-menu-item:hover, .mob-menu-item:active { background: var(--bg3); }
.mob-menu-active { color: var(--accent) !important; }
.mob-menu-compare { color: var(--accent) !important; font-weight: 600; text-align: left; width: 100%; }
.mob-menu-disabled { color: var(--text3) !important; cursor: default; pointer-events: none; }
.mob-menu-badge {
  font-size: 9px; padding: 1px 5px; border-radius: 3px;
  background: var(--bg4); color: var(--text3); font-weight: 600;
}

/* Shared close for layout sheet */
.mob-layout-sheet .mob-sheet-hdr { padding: 14px 14px 12px; }

/* Mobile-only controls hidden on desktop */
.mob-drawer-close { display: none !important; }
#mobSidebarClose { display: none; }

/* ─────────────────────────────────────────
   MOBILE TF COMPACT BUTTON
───────────────────────────────────────── */
.mob-tf-wrap { display: none; position: relative; }
.mob-tf-btn {
  background: none; border: none; color: var(--text2);
  font-size: 12px; font-weight: 600; padding: 3px 8px;
  border-radius: 3px; transition: all .12s; white-space: nowrap;
  font-family: var(--font);
}
.mob-tf-btn.open, .mob-tf-btn:hover { background: var(--bg3); color: var(--text); }
.mob-tf-drop {
  display: none; position: fixed;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px; gap: 3px;
  flex-wrap: wrap; width: 174px;
  box-shadow: 0 8px 32px rgba(0,0,0,.7); z-index: 500;
}
.mob-tf-drop.open { display: flex; }
.mob-tf-item {
  background: none; border: none; color: var(--text2);
  font-size: 12px; font-weight: 600; padding: 8px 0;
  border-radius: 4px; font-family: var(--font);
  flex: 0 0 calc(33.33% - 2px); text-align: center;
}
.mob-tf-item:active { background: var(--bg3); color: var(--text); }
.mob-tf-item.active { color: var(--accent); background: rgba(41,98,255,.12); }

/* ─────────────────────────────────────────
   MOBILE BACKDROP + SHEETS
───────────────────────────────────────── */
.mob-backdrop {
  display: none; position: fixed; inset: 0; z-index: 290;
  background: rgba(0,0,0,.5);
}
.mob-backdrop.open { display: block; }

/* Mobile layout sheet */
.mob-layout-sheet {
  display: none; position: fixed; bottom: calc(52px + env(safe-area-inset-bottom)); left: 0; right: 0;
  z-index: 295; background: var(--bg);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 16px 14px 20px;
  box-shadow: 0 -8px 32px rgba(0,0,0,.5);
}
.mob-layout-sheet.open { display: block; }
.mob-sheet-title {
  font-size: 10px; font-weight: 600; color: var(--text2);
  text-transform: uppercase; letter-spacing: .6px;
  margin-bottom: 14px;
}
.mob-layout-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.mob-layout-item {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 8px 10px; border-radius: 5px; cursor: pointer;
  border: 1px solid var(--border); font-size: 11px; color: var(--text2);
  transition: all .12s; min-width: 68px; flex: 1;
}
.mob-layout-item:active { background: var(--bg3); color: var(--text); }
.mob-layout-item.active { border-color: var(--accent); color: var(--accent); }

/* ─────────────────────────────────────────
   MOBILE BOTTOM NAV
───────────────────────────────────────── */
.mobile-nav {
  display: none;
  height: calc(52px + env(safe-area-inset-bottom)); flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.mob-tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  background: none; border: none; color: var(--text2);
  font-size: 9.5px; font-weight: 500; padding: 5px 2px;
  font-family: var(--font); transition: color .12s;
}
.mob-tab.active { color: var(--accent); }
.mob-tab svg { flex-shrink: 0; }

/* ─────────────────────────────────────────
   RESPONSIVE — MOBILE (≤768px)
───────────────────────────────────────── */
@media (max-width: 768px) {
  /* ── Topbar: horizontal scroll strip ── */
  .chart-topbar {
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
    padding: 0 6px; height: 42px;
  }
  .chart-topbar::-webkit-scrollbar { display: none; }
  .exchange-wrap { display: none; }
  .screenshot-btn { display: none; }
  .layout-picker-wrap { display: none; }
  /* Hide topbar Indicators + Compare — bottom nav has them */
  #indBtn { display: none; }
  .compare-topbar-btn { display: none; }

  /* Shrink symbol block; hide price/change */
  .symbol-selector { min-width: auto; }
  .sym-info { display: none; }

  /* Show hamburger */
  .mob-hamburger { display: flex; }

  /* ── TF: hide desktop group, show compact button ── */
  .tf-group { display: none; }
  .mob-tf-wrap { display: block; }

  /* ── Hide desktop-only panels ── */
  .chart-statusbar { display: none; }

  /* ── Draw toolbar: hidden by default, shown as horizontal strip ── */
  .draw-toolbar { display: none; }
  .draw-toolbar.mob-open {
    display: flex; flex-direction: row;
    position: fixed; bottom: calc(52px + env(safe-area-inset-bottom)); left: 0; right: 0;
    width: 100%; height: auto;
    border-right: none; border-top: 1px solid var(--border);
    overflow-x: auto; scrollbar-width: none;
    padding: 6px 8px; gap: 2px; z-index: 295;
    box-shadow: 0 -4px 20px rgba(0,0,0,.5);
  }
  .draw-toolbar.mob-open::-webkit-scrollbar { display: none; }
  .draw-toolbar.mob-open .draw-btn { width: 40px; height: 38px; flex-shrink: 0; }
  .draw-toolbar.mob-open .draw-sep { width: 1px; height: 22px; margin: 0 3px; flex-shrink: 0; }
  .draw-toolbar.mob-open .mob-drawer-close { display: flex !important; margin-left: 6px; color: var(--red); }

  /* ── Mobile nav: show ── */
  .mobile-nav { display: flex; }

  /* ── Sidebar: hidden by default, shown as bottom sheet ── */
  .chart-sidebar {
    position: fixed;
    bottom: calc(52px + env(safe-area-inset-bottom)); left: 0; right: 0;
    width: 100%; height: 46vh;
    border-left: none;
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 32px rgba(0,0,0,.5);
    display: none; z-index: 250;
  }
  .chart-sidebar.mob-open { display: flex; }
  #mobSidebarClose { display: flex; align-items: center; font-size: 22px; color: var(--text2); }

  /* ── Dialogs: bottom sheet style ── */
  .ind-dialog-overlay,
  .compare-modal-overlay {
    padding-top: 0;
    align-items: flex-end;
  }
  .ind-dialog {
    width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 82vh;
  }
  .compare-modal {
    width: 100%;
    border-radius: 16px 16px 0 0;
  }

  /* ── Symbol dropdown: fixed bottom sheet ── */
  .sym-dropdown {
    position: fixed;
    bottom: 52px; top: auto;
    left: 0 !important; right: 0;
    min-width: 100vw; max-width: 100vw;
    border-radius: 16px 16px 0 0;
    border-left: none; border-right: none;
    max-height: 75vh;
  }
  .sym-dropdown.open { display: flex; flex-direction: column; }
  .sym-list { flex: 1; }

  /* ── Chart legend: push below cell header (28px) so OHLC doesn't overlap ── */
  .chart-legend { font-size: 10px; top: 32px; }

  /* ── Sub-panes: slightly shorter on mobile ── */
  .pane-body { height: 80px; }

  /* ── Cell header: larger touch targets ── */
  .cell-header { height: 28px; }
  .cell-canvas  { padding-top: 28px; }
}

/* ─────────────────────────────────────────
   ENGINE TOGGLE
───────────────────────────────────────── */
.engine-toggle {
  display: flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; flex-shrink: 0;
}
.eng-btn {
  background: none; border: none; color: var(--text2);
  font-size: 11px; font-weight: 700; padding: 3px 9px;
  font-family: var(--font); transition: all .1s; letter-spacing: .2px;
}
.eng-btn:hover { color: var(--text); background: var(--bg3); }
.eng-btn.active { background: var(--bg3); color: var(--accent); }

/* ─────────────────────────────────────────
   MICROPLOT CONTAINER
───────────────────────────────────────── */
#mpWrap {
  flex: 1; min-height: 0; display: flex;
  position: relative; overflow: hidden; background: var(--bg);
  flex-direction: column;
}
#mpGrid {
  display: grid; flex: 1; min-height: 0; gap: 1px;
  background: var(--border); width: 100%; height: 100%;
}
.mp-canvas-wrap {
  flex: 1; min-height: 0; position: relative; overflow: hidden;
}
/* Base .u-over/.u-under/.u-select/.u-cursor-*/.u-legend rules live in common.css */

/* ── MicroPlot cell layout with sub-panes ── */
#mpGrid .chart-cell {
  display: flex; flex-direction: column; overflow: hidden;
}
.mp-subpanes {
  flex-shrink: 0; display: flex; flex-direction: column;
  border-top: 1px solid var(--border);
}
.mp-subpane {
  border-top: 1px solid var(--border); position: relative;
  height: 90px; flex-shrink: 0; overflow: hidden; background: var(--bg);
}
.mp-subpane-close {
  position: absolute; top: 4px; right: 68px; z-index: 10;
  width: 16px; height: 16px; border: none; border-radius: 3px;
  background: transparent; color: var(--text2); font-size: 14px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  padding: 0; opacity: 0; transition: opacity .15s, color .15s;
}
.mp-subpane:hover .mp-subpane-close { opacity: 1; }
.mp-subpane-close:hover { color: var(--text); background: var(--bg3); }

/* ── Light theme ── */
[data-theme="light"] .chart-topbar { background: var(--bg2); }
[data-theme="light"] .chart-area { background: #fff; }
[data-theme="light"] #mpWrap { background: #fff; }
[data-theme="light"] .mp-subpane { background: #fff; }
[data-theme="light"] .chart-sidebar { background: var(--bg2); }
[data-theme="light"] .ob-row .bar { opacity: .15; }
[data-theme="light"] .compare-modal { background: #fff; border-color: rgba(0,0,0,.1); }
[data-theme="light"] .ind-dialog .ind-dialog-inner { background: #fff; }
