/* DCTL Studio — scoped to #dctl-wrap. Shares the inspector visual system
   (dark surfaces, square corners, Helvetica/Menlo) and the two-pane generator
   layout used by Slate Composer. */

#dctl-wrap {
  --bg: #0f0f10;
  --surface: #1a1a1a;
  --surface2: #1e1e1e;
  --surface3: #262626;
  --border: rgba(255,255,255,0.14);
  --border-light: rgba(255,255,255,0.2);
  --text: #e9e9e9;
  --text-muted: #aaaaaa;
  --text-dim: #888;
  --accent: #d8d8d8;
  --accent-dim: rgba(255,255,255,0.06);
  --accent-glow: rgba(255,255,255,0.12);
  --ok:   #34d399;
  --warn: #facc15;
  --bad:  #f87171;
  --info: #60a5fa;
  background: var(--bg);
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 12px;
  line-height: 1.5;
  display: block;
  user-select: none; -webkit-user-select: none;
}

#dctl-wrap *, #dctl-wrap *::before, #dctl-wrap *::after { box-sizing: border-box; }

/* App-like UI: suppress text selection everywhere except editable fields and the
   generated-code output (which users copy from). */
#dctl-wrap input, #dctl-wrap textarea, #dctl-wrap select,
#dctl-wrap [contenteditable], #dctl-wrap .dctl-code, #dctl-wrap .dctl-code * {
  user-select: text; -webkit-user-select: text;
}

#dctl-wrap code {
  font-family: 'Menlo', 'Consolas', monospace;
  background: var(--surface3);
  padding: 1px 4px;
  border: 1px solid var(--border);
  font-size: 11px;
}

/* ─── APP ─────────────────────────────────────── */
#dctl-wrap #dctl-app {
  padding: 24px 28px;
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#dctl-wrap #dctl-app-header {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
#dctl-wrap #dctl-title { font-size: 22px; font-weight: 600; letter-spacing: -0.3px; }
#dctl-wrap #dctl-title span { color: var(--accent); }
#dctl-wrap .header-row-2 {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
#dctl-wrap .header-blurb { color: var(--text-muted); font-size: 12px; max-width: 760px; }
#dctl-wrap .header-actions { display: flex; gap: 8px; }

/* ─── BUTTONS ─────────────────────────────────── */
#dctl-wrap .dctl-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 0;
  padding: 6px 12px;
  font-size: 11px;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
#dctl-wrap .dctl-btn:hover { color: var(--text); border-color: var(--border-light); }
#dctl-wrap .dctl-btn.is-active { color: var(--text); border-color: var(--border-light); background: var(--surface3); }
#dctl-wrap #dctl-preview-bypass.is-active { color: #1a1a1a; background: #e3b341; border-color: #e3b341; }
#dctl-wrap #dctl-preview-bypass.is-active:hover { background: #f0c14b; border-color: #f0c14b; }
#dctl-wrap .dctl-btn:disabled { opacity: 0.45; cursor: default; }

/* ─── LAYOUT ──────────────────────────────────── */
#dctl-wrap #dctl-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}
@media (max-width: 1100px) {
  #dctl-wrap #dctl-layout { grid-template-columns: minmax(0, 1fr); flex: none; min-height: 0; }
}

/* ─── BUILDER ─────────────────────────────────── */
#dctl-wrap #dctl-builder {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0; /* allow the builder to shrink below its content's min-content
                   (grid items default to min-width:auto and would overflow) */
}
#dctl-wrap .dctl-builder-head {
  flex: none;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
/* Only the module list scrolls; the header and output stay put. */
#dctl-wrap #dctl-modules {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  /* Symmetric horizontal padding so the pane flash's outer box-shadow has room
     on the left edge too (overflow-x:hidden would otherwise clip it). */
  padding: 0 4px;
}
@media (max-width: 1100px) {
  #dctl-wrap #dctl-builder { min-height: 0; }
  #dctl-wrap #dctl-modules { overflow: visible; flex: none; }
}
#dctl-wrap .dctl-builder-head h2 {
  font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.6px; margin: 0; color: var(--text);
}
#dctl-wrap .dctl-builder-actions { display: flex; align-items: center; gap: 8px; }
#dctl-wrap .dctl-add-wrap { position: relative; }
#dctl-wrap .dctl-add-menu {
  position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--surface2); border: 1px solid var(--border-light);
  min-width: 320px; max-height: 80vh; overflow-y: auto;
  z-index: 30; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
#dctl-wrap .dctl-add-menu button {
  display: flex; align-items: baseline; gap: 12px; width: 100%; text-align: left;
  background: none; border: none; color: var(--text-muted);
  padding: 5px 12px; font-size: 12px; line-height: 1.4; cursor: pointer; white-space: nowrap;
}
/* The Add Module list specifically wraps into as many columns as fit the space
   below the button (max-height is set in JS), so it never trails off the bottom
   of the window. Columns grow leftward from the right-anchored edge. */
#dctl-wrap #dctl-add-menu {
  display: flex; flex-flow: column wrap; align-content: flex-start;
  min-width: 0; max-width: 92vw; overflow: hidden;
}
#dctl-wrap #dctl-add-menu button { width: 256px; box-sizing: border-box; }
#dctl-wrap #dctl-add-menu button:not(:first-child) { border-top: 1px solid var(--border); }
#dctl-wrap .dctl-add-menu button:hover { background: var(--surface3); color: var(--text); }
#dctl-wrap .dctl-add-menu button small { margin-left: auto; color: var(--text-dim); font-size: 10px; }

#dctl-wrap .dctl-menu-empty { padding: 9px 12px; font-size: 11px; color: var(--text-dim); }
#dctl-wrap .dctl-proj-row { display: flex; align-items: stretch; border-top: 1px solid var(--border); }
#dctl-wrap .dctl-proj-load {
  flex: 1; display: block; text-align: left; background: none; border: none;
  color: var(--text-muted); padding: 9px 12px; font-size: 12px; cursor: pointer;
}
#dctl-wrap .dctl-proj-load:hover { background: var(--surface3); color: var(--text); }
#dctl-wrap .dctl-proj-load small { display: block; color: var(--text-dim); font-size: 10px; margin-top: 1px; }
#dctl-wrap .dctl-proj-del {
  background: none; border: none; border-left: 1px solid var(--border);
  color: var(--text-dim); padding: 0 11px; font-size: 12px; cursor: pointer;
}
#dctl-wrap .dctl-proj-del:hover { background: var(--surface3); color: var(--text); }

#dctl-wrap .dctl-empty {
  border: 1px dashed var(--border); padding: 28px; text-align: center;
  color: var(--text-dim); font-size: 13px; background: var(--surface);
}

/* ─── MODULE PANE ─────────────────────────────── */
#dctl-wrap .dctl-mod {
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 12px;
}
#dctl-wrap .dctl-mod.is-dragging { opacity: 0.4; }
#dctl-wrap .dctl-mod.drop-before { box-shadow: 0 -2px 0 0 var(--accent); }
#dctl-wrap .dctl-mod.drop-after { box-shadow: 0 2px 0 0 var(--accent); }
#dctl-wrap .dctl-mod.is-disabled .dctl-mod-body { opacity: 0.4; }

/* Welded Logic chains: colored bar down the left edge, bridging the inter-pane
   gap so consecutive linked panes read as one continuous if/else ladder. */
#dctl-wrap .dctl-mod.is-chain { position: relative; }
#dctl-wrap .dctl-mod.is-chain::before {
  content: ''; position: absolute; left: -1px; top: 0; bottom: 0;
  width: 3px; background: var(--chain-color, var(--accent)); z-index: 1;
}
#dctl-wrap .dctl-mod.is-chain-first::before,
#dctl-wrap .dctl-mod.is-chain-mid::before { bottom: -12px; }
#dctl-wrap .dctl-mod.is-chain .dctl-mod-head {
  border-left: none;
  box-shadow: inset 2px 0 0 0 color-mix(in srgb, var(--chain-color) 35%, transparent);
}

#dctl-wrap .dctl-mod-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; background: var(--surface2);
  border-bottom: 1px solid var(--border);
  user-select: none; -webkit-user-select: none;
}
#dctl-wrap .dctl-drag {
  cursor: grab; color: var(--text-dim); font-size: 14px;
  user-select: none; padding: 0 2px; letter-spacing: -1px;
}
#dctl-wrap .dctl-drag:active { cursor: grabbing; }
#dctl-wrap .dctl-mod-title { font-size: 12px; font-weight: 600; color: var(--text); flex: none; cursor: pointer; white-space: nowrap; }
#dctl-wrap .dctl-mod-title small { color: var(--text-dim); font-weight: 400; margin-left: 6px; }
#dctl-wrap .dctl-mod-name {
  flex: 1; min-width: 60px; background: var(--surface, rgba(0,0,0,0.2));
  border: 1px solid var(--border); color: var(--text);
  font: inherit; font-size: 11px; padding: 3px 7px; border-radius: 0;
}
#dctl-wrap .dctl-mod-name::placeholder { color: var(--text-dim); opacity: 0.6; font-style: italic; }
#dctl-wrap .dctl-mod-name:focus { outline: none; border-color: var(--accent, #6ae); }
#dctl-wrap .dctl-badge {
  display: inline-block; margin-left: 6px; padding: 1px 6px;
  font-size: 9px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase;
  border: 1px solid var(--warn, #d8a657); color: var(--warn, #d8a657);
  border-radius: 2px; vertical-align: middle; white-space: nowrap;
}
#dctl-wrap .dctl-mod-head .dctl-icon-btn {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 13px; padding: 2px 5px; line-height: 1;
}
#dctl-wrap .dctl-mod-head .dctl-icon-btn:hover { color: var(--text); }
#dctl-wrap .dctl-mod-head .dctl-icon-btn.is-active { color: var(--accent, #6ae); }
/* Channel mask: compact R/G/B toggle box next to the Crop button. */
#dctl-wrap .dctl-chan { display: inline-flex; gap: 1px; margin: 0 3px; }
#dctl-wrap .dctl-chan-btn {
  background: var(--surface, rgba(0,0,0,0.2)); border: 1px solid var(--border);
  color: var(--text-dim); cursor: pointer; font-size: 9px; font-weight: 600;
  letter-spacing: 0.3px; padding: 2px 4px; line-height: 1; min-width: 15px;
}
#dctl-wrap .dctl-chan-btn:hover { color: var(--text); border-color: var(--border-light); }
#dctl-wrap .dctl-chan-btn.is-active { color: #111; border-color: transparent; }
#dctl-wrap .dctl-chan-btn:nth-child(1).is-active { background: #e0564f; }
#dctl-wrap .dctl-chan-btn:nth-child(2).is-active { background: #5bbf5b; }
#dctl-wrap .dctl-chan-btn:nth-child(3).is-active { background: #5b8def; }
/* Break/join link button on welded Logic modules. */
#dctl-wrap .dctl-link-btn { font-size: 11px; line-height: 1; }
#dctl-wrap .dctl-link-btn.is-broken { opacity: 0.5; filter: grayscale(1); }
#dctl-wrap .dctl-link-btn:hover { opacity: 1; filter: none; }
/* False Color range rows. */
#dctl-wrap .dctl-fc-bands { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 10px; }
#dctl-wrap .dctl-fc-band {
  display: grid;
  /* The color column is sized to the native <input type=color> intrinsic min
     width (~42px in WebKit) so the swatch doesn't overflow into the R field. */
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 0.85fr) 44px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 24px;
  gap: 7px; align-items: center;
}
#dctl-wrap .dctl-fc-head { margin-bottom: 3px; }
#dctl-wrap .dctl-fc-lbl { font-size: 10px; color: var(--text-dim); letter-spacing: 0.3px; text-align: center; }
#dctl-wrap .dctl-fc-lbl:first-child, #dctl-wrap .dctl-fc-lbl:nth-child(2) { text-align: left; padding-left: 5px; }
#dctl-wrap .dctl-fc-num { width: 100%; min-width: 0; box-sizing: border-box; padding: 4px 5px; }
#dctl-wrap .dctl-fc-col { width: 100%; min-width: 0; height: 24px; padding: 1px 2px; box-sizing: border-box; }
#dctl-wrap .dctl-fc-rm {
  width: 24px; min-width: 24px; height: 24px; padding: 0; box-sizing: border-box; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px;
  background: none; border: none; color: var(--text-dim); cursor: pointer;
}
#dctl-wrap .dctl-fc-rm:hover { color: var(--text); }
#dctl-wrap .dctl-crop {
  border: 1px solid var(--border); background: var(--surface3, rgba(255,255,255,0.03));
  padding: 10px 12px; margin-bottom: 12px;
}
#dctl-wrap .dctl-crop .dctl-sub { margin-top: 0; }
#dctl-wrap .dctl-chev { transition: transform 0.15s; display: inline-block; cursor: pointer; }
#dctl-wrap .dctl-mod.collapsed .dctl-chev { transform: rotate(-90deg); }
#dctl-wrap .dctl-mod.collapsed .dctl-mod-body { display: none; }

#dctl-wrap .dctl-mod-body { padding: 12px 14px; }

/* control rows */
#dctl-wrap .dctl-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 9px; flex-wrap: wrap;
}
#dctl-wrap .dctl-row:last-child { margin-bottom: 0; }
#dctl-wrap .dctl-row > label { font-size: 11px; color: var(--text-muted); min-width: 92px; }
#dctl-wrap .dctl-sub { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); margin: 10px 0 6px; }
#dctl-wrap .dctl-sub.dctl-warn-text { color: var(--warn, #e0a106); text-transform: none; }
#dctl-wrap .dctl-grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
#dctl-wrap .dctl-grid3 + .dctl-row { margin-top: 10px; }
#dctl-wrap .dctl-cell { min-width: 0; }
#dctl-wrap .dctl-grid3 .dctl-cell span { display: block; font-size: 10px; color: var(--text-dim); margin-bottom: 2px; }

#dctl-wrap select.dctl-input,
#dctl-wrap input.dctl-input {
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 0;
  padding: 5px 8px;
  font-size: 12px;
  font-family: inherit;
  flex: 1;
  min-width: 0;
}
#dctl-wrap input.dctl-input[type="number"] { font-family: 'Menlo','Consolas',monospace; }
#dctl-wrap select.dctl-input:focus,
#dctl-wrap input.dctl-input:focus { outline: none; border-color: var(--border-light); }
#dctl-wrap .dctl-input.mono { font-family: 'Menlo','Consolas',monospace; }
#dctl-wrap label.dctl-check { display: inline-flex; align-items: center; gap: 6px; min-width: 0; cursor: pointer; }
#dctl-wrap label.dctl-check input { flex: none; }
#dctl-wrap .dctl-checks { display: flex; gap: 16px; flex: 1; min-width: 0; align-items: center; }
#dctl-wrap .dctl-checklist { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin: 2px 0 8px; }
#dctl-wrap .dctl-checklist label.dctl-check { font-size: 12px; }
#dctl-wrap input[type="color"].dctl-input { padding: 1px; height: 28px; flex: none; width: 42px; }

/* ─── PARAMETRIC LINK CONTROL ─────────────────── */
#dctl-wrap .dctl-linknum { display: flex; gap: 4px; flex: 1; min-width: 0; }
#dctl-wrap .dctl-linknum input.dctl-input { flex: 1; min-width: 0; }
#dctl-wrap select.dctl-linksel { flex: none; width: 34px; padding: 5px 2px; color: var(--text-dim); }
#dctl-wrap select.dctl-linksel:focus { color: var(--text); }
#dctl-wrap .dctl-linknum input.dctl-input:disabled { color: var(--info); font-style: italic; opacity: 0.85; }
/* When a control is linked to a variable, hide the now-inert number/slider input
   and let the dropdown grow so the assigned variable name is fully visible. */
#dctl-wrap .dctl-linknum.is-linked input.dctl-input { display: none; }
#dctl-wrap .dctl-slider.is-linked input.dctl-range,
#dctl-wrap .dctl-slider.is-linked input.dctl-input { display: none; }
#dctl-wrap .dctl-linknum.is-linked select.dctl-linksel,
#dctl-wrap .dctl-slider.is-linked select.dctl-linksel {
  flex: 1; width: auto; min-width: 0; padding: 5px 6px; color: var(--info);
}
#dctl-wrap .dctl-slider { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
#dctl-wrap .dctl-slider input.dctl-range { flex: 1; min-width: 0; height: 4px; accent-color: var(--info); cursor: pointer; }
#dctl-wrap .dctl-cc-master > span:first-child,
#dctl-wrap .dctl-cc-master > label:first-child { opacity: 0.6; font-style: italic; }
#dctl-wrap .dctl-slider input.dctl-input { flex: none; width: 66px; text-align: right; }
#dctl-wrap .dctl-slider input.dctl-input:disabled { color: var(--info); font-style: italic; opacity: 0.85; }
/* Hide native number spinners — they steal horizontal space and crop the value. */
#dctl-wrap input.dctl-input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
#dctl-wrap input.dctl-input[type="number"]::-webkit-outer-spin-button,
#dctl-wrap input.dctl-input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ─── PARAMETRIC CONTROLS EDITOR ──────────────── */
#dctl-wrap .dctl-grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
#dctl-wrap .dctl-grid4 .dctl-cell span { display: block; font-size: 10px; color: var(--text-dim); margin-bottom: 2px; }
#dctl-wrap .dctl-pctl { border: 1px solid var(--border); background: var(--surface2); padding: 8px 10px; margin-bottom: 8px; }
#dctl-wrap .dctl-pctl-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
#dctl-wrap select.dctl-pctl-kind { flex: none; width: auto; min-width: 120px; }
#dctl-wrap .dctl-pctl-sp { flex: 1; }
#dctl-wrap .dctl-optrow { gap: 6px; }
#dctl-wrap .dctl-optrow input.mono { flex: 0 0 38%; }
#dctl-wrap button.dctl-padd { margin-bottom: 12px; }

/* Apply LUT drop zone */
#dctl-wrap .dctl-dropzone { border: 1px dashed var(--border-light); background: var(--surface2); padding: 18px 12px; text-align: center; cursor: pointer; margin-bottom: 8px; transition: border-color .12s, background .12s; }
#dctl-wrap .dctl-dropzone:hover { border-color: var(--accent); }
#dctl-wrap .dctl-dropzone.is-over { border-color: var(--info); background: var(--accent-dim); }
/* color swatch + R/G/B float fields (Generator colors) */
#dctl-wrap .dctl-colrow { display: flex; gap: 5px; flex: 1; min-width: 0; align-items: center; }
#dctl-wrap .dctl-colrow-pick { flex: none; width: 40px; min-width: 40px; height: 24px; padding: 1px 2px; box-sizing: border-box; }
#dctl-wrap .dctl-colrow-f { flex: 1 1 0; min-width: 0; box-sizing: border-box; }
#dctl-wrap .dctl-dz-title { font-size: 12px; color: var(--text); }
#dctl-wrap .dctl-dz-name { font-size: 15px; font-weight: 600; color: var(--text); word-break: break-all; line-height: 1.25; }
#dctl-wrap .dctl-dropzone.is-loaded { border-style: solid; }
#dctl-wrap .dctl-dz-hint { font-size: 10px; color: var(--text-dim); margin-top: 4px; }

/* Custom Math textarea */
#dctl-wrap textarea.dctl-code-input { width: 100%; box-sizing: border-box; background: #101012; color: var(--text); border: 1px solid var(--border); padding: 8px; font-family: 'Menlo','Consolas',monospace; font-size: 12px; line-height: 1.5; resize: vertical; }
#dctl-wrap textarea.dctl-code-input:focus { outline: none; border-color: var(--border-light); }
/* code editor with a line-number gutter */
#dctl-wrap .dctl-code-edit { display: flex; align-items: stretch; background: #101012; border: 1px solid var(--border); }
#dctl-wrap .dctl-code-edit:focus-within { border-color: var(--border-light); }
#dctl-wrap .dctl-code-gutter {
  flex: none; min-width: 26px; text-align: right; box-sizing: border-box;
  padding: 8px 6px 8px 8px; font-family: 'Menlo','Consolas',monospace; font-size: 12px; line-height: 1.5;
  color: #54545a; background: #0b0b0d; border-right: 1px solid var(--border);
  white-space: pre; overflow: hidden; user-select: none;
}
#dctl-wrap .dctl-code-edit textarea.dctl-code-input { flex: 1 1 auto; width: auto; border: none; white-space: pre; overflow-x: auto; }
#dctl-wrap .dctl-checkrow { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); cursor: pointer; user-select: none; }
#dctl-wrap .dctl-checkrow input { margin: 0; cursor: pointer; }
#dctl-wrap .dctl-code-warn { margin-top: 6px; font-size: 11px; line-height: 1.4; color: var(--warn, #d8a657); }

/* ─── OUTPUT ──────────────────────────────────── */
/* Stays put while the module list scrolls; the code view fills the column. */
#dctl-wrap #dctl-output { display: flex; flex-direction: column; min-height: 0; }
#dctl-wrap .dctl-out-meta { flex: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
@media (max-width: 1100px) { #dctl-wrap #dctl-output { min-height: 0; } }
#dctl-wrap .dctl-field { display: flex; align-items: center; gap: 10px; margin: 0; }
#dctl-wrap .dctl-field > span { font-size: 11px; color: var(--text-muted); min-width: 72px; }

#dctl-wrap .dctl-out-head {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 0;
}
#dctl-wrap .dctl-tabs { display: flex; gap: 0; }
#dctl-wrap .dctl-tab {
  background: var(--surface2); border: 1px solid var(--border); border-bottom: none;
  color: var(--text-dim); padding: 6px 16px; font-size: 11px; cursor: pointer;
  letter-spacing: 0.5px;
}
#dctl-wrap .dctl-tab + .dctl-tab { border-left: none; }
#dctl-wrap .dctl-tab.is-active { background: #101012; color: var(--text); border-color: var(--border-light); }
#dctl-wrap .dctl-out-actions { display: flex; gap: 8px; }

#dctl-wrap .dctl-warnings {
  flex: none;
  border: 1px solid var(--warn); border-top: none;
  background: rgba(250,204,21,0.08); color: var(--warn);
  font-size: 11px; padding: 8px 12px;
}
#dctl-wrap .dctl-warnings ul { margin: 0; padding-left: 16px; }

#dctl-wrap .dctl-code {
  flex: 1; min-height: 0;
  margin: 0; background: #101012; border: 1px solid var(--border-light);
  padding: 14px 16px; overflow: auto;
  font-family: 'Menlo','Consolas',monospace; font-size: 11.5px; line-height: 1.55;
  color: #d4d4d4; white-space: pre; tab-size: 4;
}
#dctl-wrap .dctl-code code { background: none; border: none; padding: 0; font-size: inherit; color: inherit; counter-reset: dctlln; }
#dctl-wrap .dctl-cline { display: block; counter-increment: dctlln; padding-left: 3.6em; }
#dctl-wrap .dctl-cline::before {
  content: counter(dctlln);
  display: inline-block; width: 2.4em; margin-left: -3.6em; margin-right: 1.2em;
  text-align: right; color: #54545a; -webkit-user-select: none; user-select: none;
}
#dctl-wrap .dctl-code.is-wrap { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
#dctl-wrap .dctl-cline.is-hl { background: rgba(250,204,21,0.13); box-shadow: inset 2px 0 0 var(--warn, #facc15); }
#dctl-wrap .dctl-cline.is-hl::before { color: var(--warn, #facc15); }
/* Code lines that belong to a module are clickable (jump to that module's pane). */
#dctl-wrap .dctl-cline.is-clickable { cursor: pointer; }
#dctl-wrap .dctl-cline.is-clickable:hover { background: rgba(250,204,21,0.06); }
/* Flash a builder pane when its lines are clicked in the code view. */
#dctl-wrap .dctl-mod.is-codehl { animation: dctl-pane-flash 1.6s ease-out; }
@keyframes dctl-pane-flash {
  0%   { box-shadow: 0 0 0 2px var(--warn, #facc15), 0 0 14px 2px rgba(250,204,21,0.5); }
  100% { box-shadow: 0 0 0 2px rgba(250,204,21,0); }
}
@media (max-width: 1100px) { #dctl-wrap .dctl-code { flex: none; max-height: 70vh; } }

#dctl-wrap .dctl-wrap-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-dim); cursor: pointer; user-select: none;
}
#dctl-wrap .dctl-wrap-toggle input { margin: 0; cursor: pointer; }

/* image preview */
#dctl-wrap .dctl-preview { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#dctl-wrap .dctl-preview-stage {
  position: relative;
  border: 1px solid var(--border-light); overflow: hidden;
  transition: border-color .12s;
}
#dctl-wrap .dctl-preview-stage.is-over { border-color: var(--info); }
#dctl-wrap .dctl-preview-stage canvas {
  width: 100%; height: auto; image-rendering: auto; display: block;
}
#dctl-wrap .dctl-preview-hint {
  margin-top: 8px; text-align: center;
  font-size: 10px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-dim); pointer-events: none;
}
#dctl-wrap .dctl-preview-stage.is-over + .dctl-preview-hint { color: var(--info); }
#dctl-wrap .dctl-preview-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
#dctl-wrap .dctl-preview-bar .dctl-sub { margin: 0; }
#dctl-wrap .dctl-preview-bar-actions { display: flex; align-items: center; gap: 8px; flex: none; }
#dctl-wrap .dctl-preview-res { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
#dctl-wrap select.dctl-preview-res-sel { width: auto; padding: 4px 6px; }
#dctl-wrap #dctl-preview-note { margin-top: 4px; color: var(--warn, #d8a657); }
@media (max-width: 1100px) { #dctl-wrap .dctl-preview { flex: none; } }

/* ─── PREVIEW TEST CONTROLS ─────────────────── */
#dctl-wrap .dctl-preview-controls { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
#dctl-wrap .dctl-pv-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
#dctl-wrap .dctl-pv-head .dctl-sub { margin: 0; }
#dctl-wrap .dctl-pv-reset { flex: none; padding: 2px 10px; }
#dctl-wrap .dctl-preview-controls .dctl-linknum input.dctl-range { flex: 1; min-width: 0; height: 4px; accent-color: var(--info); cursor: pointer; }
#dctl-wrap .dctl-preview-controls .dctl-linknum input[type="number"].dctl-input { flex: none; width: 64px; }

/* lightweight syntax tint */
#dctl-wrap .dctl-code .c { color: #6a9955; }   /* comment */
#dctl-wrap .dctl-code .k { color: #569cd6; }   /* keyword/type */
#dctl-wrap .dctl-code .n { color: #b5cea8; }   /* number */
#dctl-wrap .dctl-code .t { color: #4ec9b0; }   /* tag */
#dctl-wrap .dctl-code .a { color: #9cdcfe; }   /* attr */
