/* ═══════════════════════════════════════════════════════
   Settings Panel (TradingView-style)
   ═══════════════════════════════════════════════════════ */
.ctx-menu {
  position: fixed; z-index: 5000;
  background: var(--card);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-lg);
  min-width: 300px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .6);
  display: none;
  font-family: var(--font-ui);
  user-select: none;
  overflow: hidden;
}
.ctx-menu.visible { display: block; }
.ctx-menu.dragging { user-select: none; }

/* Tabs */
.ctx-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.ctx-tab {
  flex: 1;
  padding: 10px 0;
  border: none;
  background: none;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: .87rem;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: color var(--ease);
  text-align: center;
}
.ctx-tab:hover { color: var(--text); }
.ctx-tab.active { color: var(--blue); }
.ctx-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 16px;
  right: 16px;
  height: 2px;
  background: var(--blue);
  border-radius: 1px 1px 0 0;
}

/* Scrollable body & tab panes */
.ctx-body {
  height: 400px;
  overflow-y: auto;
}
.ctx-tab-pane { display: none; }
.ctx-tab-pane.active { display: block; }

/* Style row — compact TradingView-like */
.ctx-style-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: opacity var(--ease);
}
.ctx-style-row:hover { opacity: .8; }
.ctx-style-row label {
  font-size: .86rem;
  font-weight: 450;
  color: var(--text-dim);
  margin-left: auto;
  pointer-events: none;
}

/* Small color swatch */
.ctx-swatch {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--surface-border-hi);
  flex-shrink: 0;
  cursor: pointer;
  transition: transform var(--ease), box-shadow var(--ease);
}
.ctx-swatch:hover { transform: scale(1.08); box-shadow: 0 0 0 2px var(--blue-focus); }

/* Line preview */
.ctx-line-preview { flex-shrink: 0; display: block; }

/* Always-visible property row (thickness / style) */
.ctx-prop-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0;
}
.ctx-prop-row > label {
  font-size: .82rem; font-weight: 500;
  color: var(--text-muted);
  min-width: 64px; flex-shrink: 0;
}

/* Fibonacci level rows */
.ctx-fib-level {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 0;
}
.ctx-fib-swatch { width: 24px; height: 24px; border-radius: var(--radius-sm); flex-shrink: 0; cursor: pointer; }
.ctx-fib-val {
  font-family: var(--font-ui);
  font-size: .88rem; font-weight: 500;
  color: var(--text);
  min-width: 52px;
}
.ctx-fib-spacer { flex: 1; }
.ctx-fib-del {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); flex-shrink: 0;
  transition: all var(--ease);
}
.ctx-fib-del:hover { background: var(--surface-border); color: var(--red); }
.ctx-fib-del svg {
  width: 14px; height: 14px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.ctx-fib-picker { padding-left: 34px; }
.ctx-fib-add-row {
  display: flex; align-items: center; gap: 8px;
}
.ctx-fib-add-input {
  flex: 1; padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: .88rem;
  outline: none;
  transition: border-color .15s;
}
.ctx-fib-add-input:focus { border-color: var(--blue); }
.ctx-fib-add-input::placeholder { color: var(--text-muted); }
.ctx-fib-add-btn { flex-shrink: 0; padding: 6px 12px !important; }
.ctx-fib-uniform-row {
  display: flex; align-items: center; gap: 10px; padding: 2px 0;
}
.ctx-fib-uniform-swatch {
  width: 24px; height: 24px; border-radius: var(--radius-sm); flex-shrink: 0; cursor: pointer;
}
.ctx-fib-uniform-label {
  font-size: .85rem; color: var(--text-dim);
}
.ctx-fib-uniform-picker { padding-left: 34px; }
.ctx-fib-divide-label {
  font-size: .85rem; color: var(--text-dim); white-space: nowrap; flex-shrink: 0;
}
.ctx-select {
  width: 100%; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text);
  font-family: var(--font-ui); font-size: .85rem;
  outline: none; cursor: pointer;
  transition: border-color .15s;
}
.ctx-select:focus { border-color: var(--blue); }

/* Inline picker (expands below style row) */
.ctx-picker {
  display: none;
  padding: 10px 0 4px;
}
.ctx-picker.visible { display: block; }

/* Color palette grid */
.ctx-palette {
  display: grid;
  grid-template-columns: repeat(8, 22px);
  gap: 2px;
  margin-bottom: 8px;
}
.ctx-pc {
  width: 22px; height: 22px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform .08s, border-color .08s;
}
.ctx-pc:hover { transform: scale(1.15); z-index: 1; }
.ctx-pc.active { border-color: #fff; }

/* Custom color [+] button */
.ctx-pc-add {
  width: 22px; height: 22px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-hi);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .82rem; color: var(--text-muted);
  cursor: pointer; background: none;
  transition: all var(--ease);
  margin-top: 2px;
}
.ctx-pc-add:hover { border-color: var(--text-dim); color: var(--text); }

/* Picker separator & rows */
.ctx-picker-sep { height: 1px; background: var(--border); margin: 8px 0; }
.ctx-picker-row {
  display: flex; align-items: center; gap: 8px; padding: 4px 0;
}
.ctx-picker-row > label {
  font-size: .82rem; font-weight: 500;
  color: var(--text-muted);
  min-width: 58px; flex-shrink: 0;
}

/* Header */
.ctx-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  cursor: grab;
}
.ctx-menu.dragging .ctx-hdr { cursor: grabbing; }
.ctx-hdr-title {
  font-family: var(--font-ui);
  font-size: .97rem; font-weight: 600;
  color: var(--text-bright); letter-spacing: .02em;
}
.ctx-hdr-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 1.2rem; font-weight: 400; line-height: 1;
  transition: all var(--ease);
}
.ctx-hdr-close:hover { background: var(--hover-medium); color: #fff; }

/* Sections */
.ctx-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.ctx-section:last-of-type { border-bottom: none; }

.ctx-section-label {
  font-size: .82rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Rows */
.ctx-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0; gap: 12px;
}
.ctx-row label {
  font-size: .88rem; font-weight: 450;
  color: var(--text-dim); flex-shrink: 0;
  min-width: 56px;
}

/* Color dots */
.ctx-colors { display: flex; gap: 6px; align-items: center; }
.ctx-colors .cm-dot {
  width: 20px; height: 20px;
  border-radius: 50%; cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--ease), border-color var(--ease);
}
.ctx-colors .cm-dot:hover { transform: scale(1.15); }
.ctx-colors .cm-dot.active { border-color: #fff; }
.ctx-colors .cm-dot.custom {
  background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
}

/* Style toggle buttons */
.ctx-styles { display: flex; gap: 4px; }
.ctx-style-btn {
  width: 42px; height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
  transition: all var(--ease);
}
.ctx-style-btn:hover { border-color: var(--border-hi); background: var(--divider-soft); }
.ctx-style-btn.active { border-color: var(--blue); background: var(--blue-dim); color: var(--blue); }
.ctx-style-btn svg { overflow: visible; }

/* Width toggle buttons */
.ctx-widths { display: flex; gap: 4px; }
.ctx-w {
  width: 34px; height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--ease);
}
.ctx-w:hover { border-color: var(--border-hi); background: var(--divider-soft); }
.ctx-w.active { border-color: var(--blue); background: var(--blue-dim); }
.ctx-w svg { overflow: visible; }

/* Range slider for opacity */
.ctx-range-wrap {
  display: flex; align-items: center; gap: 10px;
  flex: 1; justify-content: flex-end;
}
.ctx-range-wrap input[type="range"] {
  width: 100px;
  -webkit-appearance: none; appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}
.ctx-range-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
  border: none;
}
.ctx-range-val {
  font-family: var(--font-ui);
  font-size: .82rem;
  color: var(--text-dim);
  min-width: 36px;
  text-align: right;
}

/* Number inputs */
.ctx-row input[type="number"] {
  width: 72px; padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: .88rem;
  outline: none;
  text-align: right;
  transition: border-color .15s;
}
.ctx-row input[type="number"]:focus { border-color: var(--blue); }

/* Select dropdowns */
.ctx-row select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: .88rem;
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
}
.ctx-row select option {
  font-family: var(--font-ui);
  background: var(--card); color: var(--text);
}
.ctx-row select:focus { border-color: var(--blue); }

/* Sectioned style tab: category dividers + compact rows */
.ctx-style-divider {
  font-size: .72rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-muted);
  margin: 14px 0 8px; padding-top: 12px;
  border-top: 1px solid var(--border);
}
.ctx-style-divider:first-child { margin-top: 0; padding-top: 2px; border-top: none; }
.ctx-row-compact { padding: 6px 0; }
.ctx-sel-compact { width: 132px; }

/* Inline color input */
.ctx-row input[type="color"] {
  width: 30px; height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer; padding: 3px;
}
.ctx-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.ctx-row input[type="color"]::-webkit-color-swatch { border: none; border-radius: var(--radius-sm); }

/* Dimension tab rows */
.ctx-dim-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0; gap: 10px;
}
.ctx-dim-row label {
  font-size: .85rem; font-weight: 450;
  color: var(--text-dim); flex-shrink: 0;
  white-space: nowrap;
}
.ctx-dim-input {
  width: 100px; padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: .88rem;
  outline: none;
  text-align: right;
  transition: border-color .15s;
}
.ctx-dim-input:focus { border-color: var(--blue); }
.ctx-dim-hint {
  font-size: .82rem; color: var(--text-muted);
  line-height: 1.4; margin-bottom: 8px;
}

/* Composite Sine panel */
.comp-panel {
  position:fixed; top:0; left:var(--toolbar-w); bottom:0;
  z-index:900; width:280px;
  background:var(--panel); border-right:1px solid var(--border);
  display:flex; flex-direction:column;
}
.comp-panel-right {
  position:fixed; top:0; right:var(--rsb-strip-w, 52px); bottom:0;
  z-index:900; width:280px;
  background:var(--panel); border-left:1px solid var(--border);
  display:flex; flex-direction:column;
}
.comp-hdr {
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 18px 12px; border-bottom:1px solid var(--border);
}
.comp-title {
  font-size:.85rem; font-weight:700; color:var(--text);
  letter-spacing:.02em;
}
.comp-close {
  background:none; border:none; color:var(--text-dim);
  font-size:1.1rem; cursor:pointer; padding:0 2px; line-height:1;
}
.comp-close:hover { color:var(--text); }
.comp-desc {
  padding:12px 18px; font-size:.82rem; line-height:1.55;
  color:var(--text-muted); border-bottom:1px solid var(--border);
}
.comp-cols {
  display:flex; align-items:center; gap:8px;
  padding:8px 18px 4px; font-size:.82rem; font-weight:600;
  color:var(--text-muted); text-transform:uppercase; letter-spacing:.04em;
}
.comp-col-label { flex:1; }
.comp-col-r { flex:none; width:50px; text-align:center; }
.comp-list {
  flex:1; overflow-y:auto; padding:2px 0;
}
.comp-empty {
  padding:24px 18px; text-align:center;
  color:var(--text-muted); font-size:.82rem; line-height:1.6;
}
.comp-row {
  display:flex; align-items:center; gap:8px;
  padding:7px 18px; transition:background .1s;
}
.comp-row:hover { background:var(--hover-subtle); }
.comp-harm-row { padding-left:28px; opacity:.85; }
.comp-harm-indent { flex:none; width:10px; border-left:1px solid var(--border); height:16px; margin-left:2px; }
.comp-harm-spacer { flex:none; width:26px; }
.comp-harm-name { font-style:italic; }
.comp-info { flex:1; display:flex; flex-direction:column; gap:1px; min-width:0; }
.comp-name { font-size:.82rem; color:var(--text-dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.comp-meta { font-size:.82rem; color:var(--text-muted); font-family:var(--font-ui); }
.comp-eye {
  flex:none; width:26px; height:26px; padding:0;
  background:none; border:1px solid transparent; border-radius:var(--radius-sm);
  color:var(--text-dim); cursor:pointer; display:flex; align-items:center; justify-content:center;
}
.comp-eye svg { width:15px; height:15px; fill:none; stroke:currentColor; stroke-width:1.6; }
.comp-eye:hover { border-color:var(--border); color:var(--text); }
.comp-eye.off { color:var(--text-muted); opacity:.45; }
.comp-inv {
  flex:none; width:26px; height:26px; padding:0;
  background:none; border:1px solid transparent; border-radius:var(--radius-sm);
  color:var(--text-muted); cursor:pointer; font-size:.82rem; font-weight:700;
  font-family:var(--font-ui);
  display:flex; align-items:center; justify-content:center;
  transition:all .15s;
}
.comp-inv:hover { border-color:var(--border); color:var(--text); }
.comp-inv.on { background:var(--blue); border-color:var(--blue); color:#fff; }
.comp-btn {
  padding:7px 20px; border-radius:var(--radius-sm); font-size:.82rem; font-weight:600;
  cursor:pointer; border:1px solid var(--border);
  background:transparent; color:var(--text); transition:all .15s;
}
.comp-btn:hover { border-color:var(--text-dim); }
.comp-btn.create-btn { background:var(--blue); border-color:var(--blue); color:#fff; }
.comp-btn.create-btn:hover { opacity:.85; }
/* Scrollable body */
.comp-body { flex:1; overflow-y:auto; }
/* Section labels */
.comp-section-label {
  padding:10px 18px 6px; font-size:.82rem; font-weight:700;
  color:var(--text-muted); text-transform:uppercase; letter-spacing:.06em;
}
.comp-section-composites {
  display:flex; align-items:center; justify-content:space-between;
  border-top:1px solid var(--border); margin-top:4px; padding-top:12px;
}
.comp-add-btn {
  background:none; border:1px solid var(--border); color:var(--text-dim);
  width:22px; height:22px; border-radius:var(--radius-sm); cursor:pointer;
  font-size:.85rem; font-weight:600; display:flex; align-items:center;
  justify-content:center; transition:all var(--ease);
}
.comp-add-btn:hover { border-color:var(--text-dim); color:var(--text); }
/* Sine list items (top section) */
.comp-sine-item {
  display:flex; align-items:center; gap:8px; padding:5px 18px;
}
.comp-sine-label { font-size:.82rem; color:var(--text-dim); }
/* Accordion */
.comp-acc { border-bottom:1px solid var(--border); }
.comp-acc:last-child { border-bottom:none; }
.comp-acc-hdr {
  display:flex; align-items:center; gap:8px; padding:9px 18px;
  cursor:pointer; transition:background var(--ease);
}
.comp-acc-hdr:hover { background:var(--hover-subtle); }
.comp-acc-hdr.open { background:var(--surface-veil); }
.comp-acc-arrow {
  font-size:.82rem; color:var(--text-muted); width:10px; flex-shrink:0;
  transition:color var(--ease);
}
.comp-acc-label {
  font-size:.82rem; font-weight:600; color:var(--text);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.comp-frozen-badge {
  font-size:.82rem; font-weight:700; color:var(--green);
  text-transform:uppercase; letter-spacing:.04em; flex-shrink:0;
}
.comp-acc-body { padding:0 0 8px; }
.comp-row-divider { border-top:1px solid var(--border); margin:4px 18px; }
.comp-acc-actions { padding:8px 18px 4px; }
/* Context menu for composite right-click */
.comp-ctx-menu {
  background:var(--overlay-bg); backdrop-filter:var(--overlay-blur);
  border:1px solid var(--border); border-radius:var(--radius-sm);
  box-shadow:var(--overlay-shadow); padding:4px 0; min-width:170px;
}
.comp-ctx-item {
  padding:7px 14px; font-size:.82rem; color:var(--text); cursor:pointer;
  transition:background var(--ease);
}
.comp-ctx-item:hover { background:rgba(255,255,255,var(--hover-medium)); }
.comp-ctx-sep { border-top:1px solid var(--border); margin:4px 0; }
.comp-ctx-danger { color:var(--red, #e55); }
.comp-style-dot { transition:transform var(--ease),box-shadow var(--ease); }
.comp-style-dot:hover { transform:scale(1.3); box-shadow:0 0 6px var(--surface-border-strong); }
.comp-frozen-msg {
  padding:10px 18px; font-size:.7rem; color:var(--text-muted); line-height:1.5;
}
/* Delete button (x) for sines and composites */
.comp-del-btn {
  flex-shrink:0; background:none; border:none; color:var(--text-muted);
  font-size:1rem; cursor:pointer; padding:0 2px; line-height:1; opacity:.4;
  transition:all var(--ease);
}
.comp-del-btn:hover { color:var(--red); opacity:1; }
/* Drag handle */
.comp-drag-handle {
  flex-shrink:0; width:14px; color:var(--text-muted); font-size:.7rem;
  cursor:grab; opacity:.35; transition:opacity var(--ease); user-select:none;
}
.comp-drag-handle:hover { opacity:.8; }
.comp-row-dragging { opacity:.35; }
/* Drop target highlight */
.comp-acc-drop { outline:1px dashed var(--blue); outline-offset:-1px; background:var(--blue-dim); }
.comp-acc-drop > .comp-acc-hdr { background:var(--blue-dim); }
/* Unassigned section */
.comp-acc-unassigned { border-top:1px solid var(--border); margin-top:4px; padding-top:2px; }
.comp-row-unassigned { opacity:.7; }
.comp-row-unassigned:hover { opacity:1; }

/* Multi-color section */
.ctx-multicolor { }
.ctx-color-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0; gap: 12px;
}
.ctx-color-row label {
  font-size: .88rem; font-weight: 450; color: var(--text-dim);
}
.ctx-color-row input[type="color"] {
  width: 28px; height: 24px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); cursor: pointer; padding: 2px;
}
.ctx-color-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.ctx-color-row input[type="color"]::-webkit-color-swatch { border: none; border-radius: 2px; }

/* Footer */
.ctx-footer {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.ctx-footer-spacer { flex: 1; }
.ctx-footer-btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--ease);
}
.ctx-footer-btn:hover { background: var(--surface-raised); color: var(--text); border-color: var(--border-hi); }
.ctx-footer-btn.danger { color: var(--red); border-color: rgba(240,80,110,.25); }
.ctx-footer-btn.danger:hover { background: var(--red-dim); }
.ctx-footer-btn.primary {
  background: var(--blue); color: #fff;
  border-color: var(--blue); font-weight: 600;
}
.ctx-footer-btn.primary:hover { background: var(--blue-hover); }

/* ═══════════════════════════════════════════════════════
   Settings Modal — full-screen overlay with sidebar nav
   ═══════════════════════════════════════════════════════ */
.cs-overlay {
  position: fixed; inset: 0; z-index: 5000;
  background: var(--overlay-bg);
  backdrop-filter: blur(var(--overlay-blur, 6px));
  -webkit-backdrop-filter: blur(var(--overlay-blur, 6px));
  display: none;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  animation: csOverlayFade .15s ease;
}
.cs-overlay.visible { display: flex; }
@keyframes csOverlayFade { from { opacity: 0; } to { opacity: 1; } }

.cs-modal {
  width: min(820px, 92vw);
  height: min(560px, 88vh);
  background: var(--panel);
  border: 1px solid var(--surface-border-hi);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 80px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.03) inset;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: csModalIn .18s cubic-bezier(.2,.8,.3,1);
}
@keyframes csModalIn { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }

.cs-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--surface-border);
  background: var(--surface-veil);
}
.cs-modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: -.01em;
}
.cs-modal-close {
  width: 28px; height: 28px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 1.4rem;
  line-height: 1;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--ease);
  display: inline-flex; align-items: center; justify-content: center;
}
.cs-modal-close:hover { background: var(--hover-medium); color: var(--text-bright); }

.cs-modal-body {
  flex: 1;
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: 0;
}

.cs-modal-nav {
  border-right: 1px solid var(--surface-border);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface-veil);
  overflow-y: auto;
}
.cs-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  transition: var(--ease);
}
.cs-nav-item:hover { background: var(--hover-subtle); color: var(--text); }
.cs-nav-item.active {
  background: var(--surface-raised);
  color: var(--text-bright);
}
.cs-nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: .9;
}

.cs-modal-content {
  padding: 26px 32px;
  overflow-y: auto;
  background: var(--panel);
}

.cs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 0;
  border-bottom: 1px solid var(--divider-soft);
}
.cs-row:last-child { border-bottom: none; }
.cs-row-info { min-width: 0; }
.cs-row-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-bright);
  margin-bottom: 3px;
}
.cs-row-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}
.cs-row-control { flex-shrink: 0; }

/* Segmented pill (lang, x-axis) */
.cs-segment {
  display: inline-flex;
  background: var(--surface-raised);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.cs-segment-btn {
  padding: 6px 14px;
  border: none;
  background: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 0.86rem;
  font-weight: 500;
  transition: var(--ease);
  white-space: nowrap;
}
.cs-segment-btn:hover { color: var(--text); }
.cs-segment-btn.active {
  background: var(--pill-active-bg);
  color: var(--pill-active-color);
  font-weight: 600;
}

/* Section label inside a tab (above sub-grids) */
.cs-section-label {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 4px 0 8px;
}

/* Theme cards grid */
.cs-theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding-top: 6px;
}
.cs-theme-card {
  position: relative;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 14px;
  background: var(--surface-veil);
  cursor: pointer;
  transition: var(--ease);
  text-align: left;
  font-family: var(--font-ui);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cs-theme-card:hover {
  border-color: var(--surface-border-strong);
  background: var(--surface-raised);
}
.cs-theme-card.active {
  border-color: var(--blue);
  background: var(--blue-dim);
  box-shadow: 0 0 0 1px var(--blue) inset;
}
.cs-theme-preview {
  height: 56px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
}
.cs-theme-sw {
  width: 12px; height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255,255,255,.15);
}
.cs-theme-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-bright);
}
.cs-theme-check {
  position: absolute;
  top: 20px; right: 20px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  z-index: 2;
  box-shadow: 0 0 0 2px var(--surface-veil);
}

/* ═══════════════════════════════════════════════════════
   Abis Trends — Optimize UI
   ═══════════════════════════════════════════════════════ */
.ctx-abis-opt {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.ctx-abis-opt-btns {
  display: flex; gap: 8px; margin-top: 8px;
}
.ctx-abis-opt-btn {
  flex: 1; padding: 8px 0;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--ease);
}
.ctx-abis-opt-btn:hover { background: rgba(255,255,255, var(--hover-medium)); }
.ctx-abis-opt-btn:disabled { opacity: .5; cursor: wait; }
.ctx-abis-opt-btn.loading { color: var(--text-dim); }

.ctx-abis-results-title {
  margin-top: 12px; margin-bottom: 6px;
  font-size: 0.85rem; font-weight: 600;
  color: var(--text-bright);
}
.ctx-abis-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.82rem; font-family: var(--font-ui);
}
.ctx-abis-table th {
  padding: 4px 5px;
  text-align: right;
  color: var(--text-dim);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}
.ctx-abis-table th:first-child { text-align: left; }
.ctx-abis-table td {
  padding: 4px 5px;
  text-align: right;
  color: var(--text);
}
.ctx-abis-table td:first-child { text-align: left; }
.ctx-abis-table td.pos { color: var(--green); }
.ctx-abis-table td.neg { color: var(--red); }

.ctx-abis-row {
  cursor: pointer;
  transition: var(--ease);
}
.ctx-abis-row:hover { background: rgba(255,255,255, var(--hover-subtle)); }
.ctx-abis-row.selected { background: rgba(77,166,255,.12); }


.ctx-abis-no-results {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-dim);
  text-align: center;
}


