/* =========================================================
   Simulight — Light Show Designer
   Dark, modern, pro UI
   ========================================================= */

:root {
  --bg0: #07090f;
  --bg1: #0d1118;
  --bg2: #141923;
  --bg3: #1b2130;
  --bg4: #252d41;
  --line: rgba(255,255,255,0.06);
  --line-strong: rgba(255,255,255,0.12);
  --text: #e6ecf4;
  --text-dim: #9aa4b8;
  --muted: #5c667a;
  --accent: #ffa726;
  --accent2: #ff2a8a;
  --accent3: #2ad4ff;
  --ok: #5dffb0;
  --warn: #ffb020;
  --err: #ff4d7a;
  --shadow: 0 6px 24px rgba(0,0,0,0.45);
  --radius: 10px;
  --radius-sm: 6px;

  --topbar-h: 54px;
  --timeline-h: 200px;
  --left-w: 280px;
  --right-w: 340px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg0);
  color: var(--text);
  font-family: 'Inter', 'SF Pro Display', -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 13px;
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); font-weight: 600; }
h4 { margin: 14px 0 8px; font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.muted { color: var(--muted); font-size: 12px; }
button { font-family: inherit; }

/* ===== Scrollbars ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 10px; border: 2px solid var(--bg0); }
::-webkit-scrollbar-thumb:hover { background: #334156; }

/* ===== Top Bar ===== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: linear-gradient(180deg, #0f1420 0%, #0a0d14 100%);
  border-bottom: 1px solid var(--line-strong);
  display: flex; align-items: center; gap: 16px;
  padding: 0 14px; z-index: 100;
  box-shadow: 0 1px 0 rgba(255,255,255,0.02);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.logo { filter: drop-shadow(0 0 8px rgba(255,167,38,0.55)); }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: 0.02em; }
.brand-tag { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.14em; }

.menu { display: flex; gap: 2px; }
.menu-btn {
  background: transparent; border: 1px solid transparent; color: var(--text-dim);
  padding: 6px 10px; border-radius: var(--radius-sm); font-size: 12px; cursor: pointer;
  transition: all .15s;
}
.menu-btn:hover { color: var(--text); background: var(--bg2); border-color: var(--line); }
.menu-btn.demo {
  background: linear-gradient(135deg, rgba(255,167,38,0.18), rgba(255,42,138,0.18));
  border: 1px solid rgba(255,167,38,0.4);
  color: var(--accent);
  font-weight: 700;
}
.menu-btn.demo:hover {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #1a0a06;
  border-color: transparent;
  box-shadow: 0 0 18px rgba(255,42,138,0.35);
}

.transport {
  display: flex; align-items: center; gap: 6px;
  padding: 0 10px; border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  height: 100%; margin-left: auto;
}
.tbtn {
  width: 34px; height: 34px; border-radius: 50%; background: var(--bg3);
  border: 1px solid var(--line); color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.tbtn:hover { background: var(--bg4); transform: translateY(-1px); }
.tbtn.play { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; box-shadow: 0 4px 14px rgba(255,42,138,0.3); }
.tbtn.play:hover { filter: brightness(1.12); transform: translateY(-1px); }
.time-display {
  font-family: 'SF Mono','Courier New',monospace;
  font-size: 14px; font-weight: 500;
  background: var(--bg1); padding: 6px 10px; border-radius: var(--radius-sm);
  color: var(--accent3); min-width: 82px; text-align: center;
  border: 1px solid var(--line);
}
.bpm {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg1); padding: 4px 8px; border-radius: var(--radius-sm); border: 1px solid var(--line);
}
.bpm label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.bpm input { width: 54px; }
.tap {
  background: var(--bg3); color: var(--text); border: 1px solid var(--line);
  padding: 3px 8px; font-size: 10px; font-weight: 700; border-radius: 4px; cursor: pointer;
  letter-spacing: 0.12em;
}
.tap:hover { background: var(--bg4); }
.tap.beat { background: var(--accent); color: #000; }

.master { display: flex; align-items: center; gap: 8px; padding: 0 10px; }
.master label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.master input[type=range] { width: 110px; }
#master-val { font-size: 11px; color: var(--text-dim); min-width: 36px; text-align: right; }

.bo-btn {
  background: linear-gradient(180deg, #2a0615, #1a0308);
  color: var(--err); border: 1px solid var(--err);
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer;
  font-weight: 800; font-size: 11px; letter-spacing: 0.18em;
  transition: all .15s;
}
.bo-btn:hover { background: var(--err); color: #fff; box-shadow: 0 0 20px rgba(255,77,122,0.6); }
.bo-btn.active { background: var(--err); color: #fff; box-shadow: 0 0 0 3px rgba(255,77,122,0.25); }

/* ===== Global Inputs ===== */
input[type=text], input[type=number], select {
  background: var(--bg1); color: var(--text); border: 1px solid var(--line);
  padding: 6px 8px; border-radius: var(--radius-sm); font-size: 12px;
  outline: none;
  font-family: inherit;
}
input[type=text]:focus, input[type=number]:focus, select:focus { border-color: var(--accent); }

/* Range sliders — custom look */
input[type=range] {
  -webkit-appearance: none; appearance: none;
  height: 4px; background: linear-gradient(to right, var(--accent), var(--accent2));
  border-radius: 2px; outline: none; cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent);
  cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  transition: transform .12s;
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.22); }

/* ===== Layout ===== */
.layout {
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0;
  bottom: var(--timeline-h);
  display: grid;
  grid-template-columns: var(--left-w) 1fr var(--right-w);
  gap: 1px;
  background: var(--line-strong);
}

.side {
  background: var(--bg1);
  overflow: hidden;
  display: flex; flex-direction: column;
}

.tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--bg2); }
.tab {
  flex: 1; background: transparent; border: none; color: var(--text-dim);
  padding: 11px 10px; cursor: pointer; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  position: relative; transition: color .15s;
  font-weight: 600;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab.active::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

.tab-pane { display: none; padding: 12px; overflow-y: auto; flex: 1; }
.tab-pane.active { display: block; }

.pane-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.pane-header h3 { flex: 1; }
.count-badge {
  background: var(--bg4); color: var(--text-dim); padding: 2px 8px;
  border-radius: 10px; font-size: 10px; font-weight: 700;
}
.universe-sel {
  font-size: 10px; color: var(--text-dim); letter-spacing: 0.1em;
  padding: 2px 8px; background: var(--bg2); border-radius: 4px;
}

.icon-btn {
  width: 26px; height: 26px; border-radius: var(--radius-sm);
  background: var(--bg3); border: 1px solid var(--line); color: var(--text-dim);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.icon-btn:hover { background: var(--bg4); color: var(--text); }

.mini {
  background: var(--bg3); color: var(--text); border: 1px solid var(--line);
  padding: 5px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 11px;
  transition: all .15s;
}
.mini:hover { background: var(--bg4); }
.mini.danger { color: var(--err); border-color: rgba(255,77,122,0.25); }
.mini.danger:hover { background: rgba(255,77,122,0.1); }
.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #1a0a06; border: none; padding: 8px 14px; border-radius: var(--radius-sm);
  font-weight: 700; cursor: pointer; letter-spacing: 0.04em;
  transition: all .15s;
}
.primary:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(255,42,138,0.3); }
.secondary {
  background: var(--bg3); color: var(--text); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer;
}
.secondary:hover { background: var(--bg4); }

/* ===== QLC+ Import dropzone ===== */
.qlc-dropzone {
  margin-bottom: 10px;
  padding: 10px 8px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg2);
  color: var(--text-dim);
  font-size: 11px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
}
.qlc-dropzone:hover { border-color: var(--accent); color: var(--text); }
.qlc-dropzone.drag { border-color: var(--accent3); background: rgba(42,212,255,0.08); color: var(--accent3); }
.qlc-dropzone strong { color: var(--accent); }

.fx-template .fx-qlc-badge {
  position: absolute;
  top: 3px; right: 3px;
  background: var(--accent3); color: #021418;
  font-size: 8px; font-weight: 800;
  padding: 1px 4px; border-radius: 3px;
  letter-spacing: 0.05em;
}
.fx-template { position: relative; }

/* ===== Fixture library templates ===== */
.fixture-templates {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.fx-template {
  background: var(--bg2); border: 1px solid var(--line);
  padding: 10px 8px; border-radius: var(--radius-sm); cursor: grab;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: all .15s;
  text-align: center;
}
.fx-template:hover { border-color: var(--accent); transform: translateY(-2px); background: var(--bg3); }
.fx-template:active { cursor: grabbing; }
.fx-template .fx-ic {
  width: 32px; height: 32px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff, #ffa726 40%, #ff2a8a 100%);
  box-shadow: 0 0 10px rgba(255,167,38,0.4);
}
.fx-template .fx-ic.moving { border-radius: 20% 20% 40% 40% / 30% 30% 50% 50%; background: linear-gradient(180deg, #334156, #1b2130); box-shadow: inset 0 -8px 10px rgba(0,0,0,0.5); position: relative; }
.fx-template .fx-ic.moving::after { content: ''; position: absolute; top: 55%; left: 50%; width: 18px; height: 18px; background: radial-gradient(circle, #fff, #2ad4ff 60%, transparent); transform: translate(-50%, -50%); border-radius: 50%; }
.fx-template .fx-ic.bar { width: 48px; height: 12px; border-radius: 4px; background: linear-gradient(90deg, #ff2a8a, #ffa726, #2ad4ff, #5dffb0); }
.fx-template .fx-ic.strobe { background: #fff; box-shadow: 0 0 16px #fff; }
.fx-template .fx-ic.laser { background: radial-gradient(circle, #5dffb0, #2ad4ff 60%, transparent); }
.fx-template .fx-name { font-size: 10px; color: var(--text-dim); line-height: 1.2; }

/* Stage list */
.stage-list { display: flex; flex-direction: column; gap: 4px; }
.stage-item {
  background: var(--bg2); border: 1px solid var(--line);
  padding: 8px 10px; border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  transition: all .12s;
}
.stage-item:hover { background: var(--bg3); }
.stage-item.selected { border-color: var(--accent); background: rgba(255,167,38,0.08); }
.stage-item .dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--muted);
  box-shadow: 0 0 0 2px var(--bg1);
}
.stage-item .dot.on { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.stage-item .sname { flex: 1; font-size: 12px; }
.stage-item .saddr { font-size: 10px; color: var(--muted); font-family: monospace; }
.stage-item .sdel {
  width: 22px; height: 22px; border-radius: 50%;
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  transition: all .12s; font-size: 14px;
}
.stage-item .sdel:hover { background: rgba(255,77,122,0.15); color: var(--err); }

/* Patch */
.patch-list {
  display: flex; flex-direction: column; gap: 4px;
  margin-bottom: 16px;
}
.patch-row {
  display: grid; grid-template-columns: 50px 1fr 50px;
  gap: 6px; align-items: center;
  padding: 6px; background: var(--bg2); border-radius: var(--radius-sm);
  font-size: 11px;
}
.patch-row input[type=number] {
  width: 100%; padding: 2px 4px; font-size: 11px;
}
.patch-row .pname { font-size: 11px; }
.universe-map {
  display: grid; grid-template-columns: repeat(32, 1fr); gap: 1px;
  padding: 6px; background: var(--bg2); border-radius: var(--radius-sm);
  margin-top: 10px;
}
.umap-cell {
  aspect-ratio: 1/1; background: var(--bg1); border-radius: 1px;
  transition: background .1s;
}
.umap-cell.used { background: var(--accent3); }
.umap-cell.hi { background: var(--accent); }

/* Scenes */
.scenes-list { display: flex; flex-direction: column; gap: 4px; }
.scene-item {
  background: var(--bg2); border: 1px solid var(--line);
  padding: 8px 10px; border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  transition: all .12s;
}
.scene-item:hover { background: var(--bg3); border-color: var(--line-strong); }
.scene-item.active { border-color: var(--accent); background: rgba(255,167,38,0.1); box-shadow: 0 0 0 1px var(--accent); }
.scene-item .sc-name { flex: 1; font-size: 12px; font-weight: 500; }
.scene-item .sc-meta { font-size: 10px; color: var(--muted); }
.scene-item .sc-play {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg4); border: none; color: var(--text);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.scene-item .sc-play:hover { background: var(--accent); color: #000; }

.chase-box { margin-top: 18px; }
.chase-list { display: flex; flex-direction: column; gap: 4px; }
.chase-item {
  background: var(--bg2); border: 1px solid var(--line);
  padding: 8px; border-radius: var(--radius-sm);
  font-size: 11px;
}
.chase-item.running { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok); }

/* ===== Viewport ===== */
.viewport { position: relative; background: #000; overflow: hidden; }
#scene-canvas { width: 100%; height: 100%; display: block; }

.view-ui {
  position: absolute; top: 12px; left: 12px; right: 12px;
  display: flex; justify-content: space-between; gap: 12px;
  pointer-events: none;
}
.view-ui > * { pointer-events: all; }
.view-presets {
  display: inline-flex; background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 3px;
}
.view-presets button {
  background: transparent; border: none; color: var(--text-dim);
  padding: 6px 12px; cursor: pointer; font-size: 11px; border-radius: 6px;
  text-transform: uppercase; letter-spacing: 0.06em;
  transition: all .15s;
}
.view-presets button:hover { color: var(--text); }
.view-presets button.active {
  background: var(--accent); color: #0a0507; font-weight: 700;
}
.view-settings {
  display: flex; gap: 10px; align-items: center;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 6px 12px;
}
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; cursor: pointer; color: var(--text-dim); }
.chk input { cursor: pointer; }
.slider-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); }
.slider-inline input { width: 70px; }

.viewport-hint {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
  color: var(--text-dim); padding: 6px 12px; border-radius: 100px;
  font-size: 11px; border: 1px solid var(--line);
  pointer-events: none; opacity: 1; transition: opacity .4s;
}
.viewport-hint.hidden { opacity: 0; }

.drop-marker {
  position: absolute; width: 40px; height: 40px; border-radius: 50%;
  border: 2px dashed var(--accent); pointer-events: none;
  transform: translate(-50%, -50%);
  opacity: 0; transition: opacity .12s;
}
.drop-marker.on { opacity: 1; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{transform:translate(-50%,-50%) scale(1);} 50%{transform:translate(-50%,-50%) scale(1.12);} }

/* Fixture labels in 3D */
.fx-label {
  position: absolute; background: rgba(0,0,0,0.7); color: var(--text);
  padding: 2px 6px; border-radius: 4px; font-size: 10px;
  font-family: 'SF Mono', monospace; pointer-events: none;
  border: 1px solid var(--line); backdrop-filter: blur(4px);
  transform: translate(-50%, -100%); white-space: nowrap;
}
.fx-label.sel { border-color: var(--accent); color: var(--accent); }

/* ===== Programmer ===== */
.selection-chips {
  display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px;
  min-height: 24px;
}
.chip {
  background: rgba(255,167,38,0.18); color: var(--accent);
  border: 1px solid var(--accent); padding: 2px 8px;
  border-radius: 100px; font-size: 10px; font-weight: 600;
}

.programmer .block {
  background: var(--bg2); border: 1px solid var(--line);
  padding: 10px; border-radius: var(--radius-sm); margin-bottom: 10px;
}
.block-title { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-dim); margin-bottom: 8px; }

.intensity-row { display: flex; align-items: center; gap: 8px; }
.intensity-row input { flex: 1; }
#prog-intensity-val { font-size: 11px; min-width: 40px; text-align: right; color: var(--text-dim); }

.color-block { display: flex; flex-direction: column; gap: 10px; align-items: center; }
#color-wheel { cursor: crosshair; border-radius: 50%; box-shadow: 0 4px 20px rgba(0,0,0,0.5); }
.color-rgbwau { width: 100%; display: flex; flex-direction: column; gap: 4px; }
.chn-row {
  display: grid; grid-template-columns: 34px 1fr 40px; gap: 8px; align-items: center;
}
.chn-row label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; }
.chn-row span { font-size: 11px; color: var(--text-dim); text-align: right; font-family: monospace; }

.color-presets { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; width: 100%; }
.color-preset {
  aspect-ratio: 1/1; border-radius: 4px; cursor: pointer; border: 1px solid var(--line);
  transition: transform .12s;
}
.color-preset:hover { transform: scale(1.15); }

.pt-pad {
  position: relative; width: 200px; height: 200px; margin: 0 auto;
  cursor: crosshair;
}
#pt-canvas { width: 200px; height: 200px; display: block; }
.pt-labels {
  position: absolute; top: 50%; left: 50%; width: 100%; height: 100%;
  transform: translate(-50%, -50%); pointer-events: none;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em;
  padding: 0 10px;
}
.pt-labels span:first-child::before { content: '↔ '; }
.pt-labels span:last-child::after { content: ' ↕'; }

.store-row {
  margin-top: 12px; padding: 12px; background: var(--bg2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  display: flex; flex-direction: column; gap: 8px;
}
.store-row input[type=text] { width: 100%; }
.fade-inputs { display: flex; gap: 8px; }
.fade-inputs label { flex: 1; font-size: 10px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; text-transform: uppercase; letter-spacing: 0.08em;}
.fade-inputs input { width: 56px; padding: 4px; }

/* Properties */
.props-body { padding: 4px; }
.prop-row { display: grid; grid-template-columns: 80px 1fr; gap: 8px; margin-bottom: 8px; align-items: center; font-size: 12px; }
.prop-row label { color: var(--text-dim); font-size: 11px; }
.prop-row input[type=text], .prop-row input[type=number] { width: 100%; }

/* Channels monitor */
.channels-grid { display: grid; grid-template-columns: repeat(16, 1fr); gap: 2px; padding: 4px; }
.dmx-cell {
  aspect-ratio: 1/2;
  background: var(--bg2); border-radius: 1px;
  position: relative; overflow: hidden;
}
.dmx-cell .fill { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(180deg, var(--accent2), var(--accent)); transition: height .05s; }
.dmx-cell .num { position: absolute; top: 2px; left: 2px; font-size: 7px; color: rgba(255,255,255,0.3); font-family: monospace; }
.dmx-cell.addr-start .num { color: var(--accent); font-weight: 700; }

/* ===== Timeline ===== */
.timeline {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--timeline-h);
  background: var(--bg1); border-top: 1px solid var(--line-strong);
  display: flex; flex-direction: column;
  z-index: 50;
}
.timeline-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  background: var(--bg2);
  gap: 12px;
}
.tl-left, .tl-right { display: flex; align-items: center; gap: 8px; }
.tl-zoom { display: flex; align-items: center; gap: 6px; }
.tl-zoom input { width: 120px; }
.tl-audio-name { font-size: 11px; color: var(--muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tl-wrapper {
  flex: 1; position: relative;
  overflow-x: auto; overflow-y: hidden;
  background: repeating-linear-gradient(90deg, var(--bg1) 0, var(--bg1) 79px, var(--bg2) 79px, var(--bg2) 80px);
}
#tl-canvas { display: block; height: 100%; min-width: 100%; }
.tl-playhead {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--accent); pointer-events: none;
  box-shadow: 0 0 10px var(--accent); z-index: 5;
}
.tl-playhead::before {
  content: ''; position: absolute; top: -4px; left: -5px;
  width: 0; height: 0;
  border-left: 6px solid transparent; border-right: 6px solid transparent;
  border-top: 8px solid var(--accent);
}
.tl-cues { position: absolute; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; }
.tl-cue {
  position: absolute; top: 0; bottom: 0; width: 3px;
  background: var(--accent3); cursor: ew-resize; pointer-events: auto;
  opacity: 0.9; transition: opacity .15s;
}
.tl-cue:hover, .tl-cue.active {
  opacity: 1; box-shadow: 0 0 8px var(--accent3);
}
.tl-cue-label {
  position: absolute; top: 4px; left: 6px; font-size: 10px;
  color: var(--accent3); white-space: nowrap; font-family: 'SF Mono', monospace;
  background: rgba(0,0,0,0.6); padding: 1px 4px; border-radius: 3px;
}
.tl-cue-del {
  position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--err); color: #fff; border: none;
  font-size: 10px; cursor: pointer; display: none;
  line-height: 1;
}
.tl-cue.active .tl-cue-del { display: block; }

/* ===== Modal ===== */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  display: none; align-items: center; justify-content: center;
  z-index: 200; backdrop-filter: blur(6px);
}
.modal.open { display: flex; }
.modal-card {
  background: var(--bg1); border: 1px solid var(--line-strong);
  border-radius: var(--radius); width: 640px; max-width: 96vw;
  max-height: 90vh; overflow: hidden; display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  background: var(--bg2);
}
.modal-head h3 { font-size: 14px; color: var(--text); letter-spacing: 0.02em; text-transform: none; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot {
  padding: 12px 18px; border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end; gap: 8px;
  background: var(--bg2);
}

.row { display: grid; grid-template-columns: 120px 1fr; gap: 12px; margin-bottom: 10px; align-items: center; }
.row label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.row select { width: 100%; }

.channel-builder {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px;
}
.ch-builder-row {
  display: grid; grid-template-columns: 34px 1fr 120px 60px 24px;
  gap: 6px; align-items: center;
  background: var(--bg2); padding: 6px; border-radius: var(--radius-sm);
}

/* ================================================================
   VIEW PRESETS — expanded 7-button panel
   ================================================================ */
.view-presets {
  flex-wrap: wrap;
}
.view-presets button {
  padding: 6px 10px;
  min-width: 46px;
}
.view-presets button[data-view="iso"].active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}

/* ================================================================
   COMPASS — orientation gizmo in viewport corner
   ================================================================ */
.compass {
  position: absolute;
  bottom: 58px; right: 14px;
  width: 92px; height: 92px;
  pointer-events: none;
  opacity: 0.9;
  z-index: 10;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
}
.compass-svg {
  width: 100%; height: 100%;
  display: block;
}
.compass-ring {
  fill: rgba(0,0,0,0.55);
  stroke: var(--line-strong);
  stroke-width: 1.5;
}
.compass-inner {
  fill: none;
  stroke: rgba(255,255,255,0.08);
  stroke-width: 1;
}
.axis-x, .axis-z {
  stroke: rgba(255,255,255,0.1);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}
.compass-svg .cn {
  font: 700 9px 'Inter', sans-serif;
  fill: var(--text-dim);
  letter-spacing: 0.05em;
}
.compass-svg .cn-front { fill: var(--accent); }
#compass-pointer {
  transform-origin: 0 0;
  transition: transform .18s cubic-bezier(.2,.7,.3,1);
}
.pointer-fill {
  fill: var(--accent);
  filter: drop-shadow(0 0 4px var(--accent));
}
.pointer-line {
  stroke: var(--accent);
  stroke-width: 2;
  opacity: 0.6;
}
.pointer-hub {
  fill: var(--accent2);
  stroke: #1a0a06;
  stroke-width: 1.5;
}
.compass-label {
  position: absolute;
  bottom: -18px; left: 50%; transform: translateX(-50%);
  font: 700 9px 'Inter', sans-serif;
  letter-spacing: 0.15em;
  color: var(--accent);
  background: rgba(0,0,0,0.6);
  padding: 2px 8px;
  border-radius: 100px;
  border: 1px solid var(--line);
  text-transform: uppercase;
  white-space: nowrap;
}

/* Shortcut hints at the bottom */
.viewport-shortcuts {
  position: absolute;
  bottom: 14px; right: 14px;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(8px);
  color: var(--text-dim); font-size: 10px;
  padding: 5px 10px; border-radius: 100px;
  border: 1px solid var(--line);
  pointer-events: none;
  letter-spacing: 0.03em;
}
.viewport-shortcuts kbd {
  background: var(--bg3);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  font: 600 10px monospace;
  color: var(--text);
  margin: 0 1px;
}

/* ================================================================
   SCENE EDITOR MODAL (QLC+-like)
   ================================================================ */
.modal-card.scene-editor {
  width: 1100px;
  max-width: 96vw;
  height: 82vh;
  max-height: 82vh;
}
.se-head-actions { display: flex; gap: 6px; align-items: center; }

.se-toolbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 14px;
  padding: 12px 18px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.se-toolbar .se-row {
  display: flex; align-items: center; gap: 8px;
}
.se-toolbar label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-dim); font-weight: 600;
}
.se-toolbar input[type="text"] {
  flex: 1; min-width: 200px;
  padding: 6px 10px;
  background: var(--bg0); border: 1px solid var(--line-strong);
  color: var(--text); border-radius: var(--radius-sm);
  font-size: 13px;
}
.se-toolbar input[type="number"] {
  width: 60px;
  padding: 5px 8px;
  background: var(--bg0); border: 1px solid var(--line);
  color: var(--text); border-radius: 4px;
  font-size: 12px; text-align: right;
}
.se-unit { font-size: 11px; color: var(--muted); margin-right: 8px; }

.se-body {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  overflow: hidden;
  min-height: 0;
}

/* Left: fixture list */
.se-fixtures {
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  background: var(--bg1);
  overflow: hidden;
}
.se-fx-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: var(--bg2);
}
.se-fx-head h4 {
  font-size: 11px; color: var(--text);
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.se-fx-actions { display: flex; gap: 4px; }
.se-filter {
  margin: 8px 10px;
  padding: 6px 10px;
  background: var(--bg0); border: 1px solid var(--line);
  color: var(--text); border-radius: var(--radius-sm);
  font-size: 12px;
}
.se-fx-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 6px 10px;
}
.se-fx-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; margin: 2px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .12s;
}
.se-fx-item:hover { background: var(--bg2); }
.se-fx-item.active {
  background: rgba(255,167,38,0.14);
  border-color: rgba(255,167,38,0.4);
}
.se-fx-item input[type="checkbox"] {
  accent-color: var(--accent);
}
.se-fx-item .fx-icon {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--text-dim);
}
.se-fx-item.has-values .fx-icon {
  background: var(--accent); box-shadow: 0 0 6px var(--accent);
}
.se-fx-item .fx-name {
  flex: 1; font-size: 12px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.se-fx-item .fx-addr {
  font-size: 10px; font-family: monospace; color: var(--muted);
  background: var(--bg2); padding: 2px 5px; border-radius: 3px;
}

/* Right: channel groups */
.se-channels {
  overflow-y: auto;
  padding: 0;
  background: var(--bg0);
}
.se-empty {
  padding: 40px 30px; color: var(--text-dim); text-align: center;
  font-size: 13px;
}
.se-empty p { margin-bottom: 8px; }

.se-group {
  border-bottom: 1px solid var(--line);
}
.se-group-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 18px;
  background: var(--bg2);
  cursor: pointer;
  user-select: none;
}
.se-group-head h5 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--accent); font-weight: 700;
}
.se-group-head .se-group-toggle { color: var(--muted); font-size: 10px; }
.se-group-body { padding: 10px 14px; display: grid; gap: 6px; }

.se-channel-row {
  display: grid;
  grid-template-columns: 80px 1fr 50px 30px;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  background: var(--bg1);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: border-color .12s;
}
.se-channel-row:hover { border-color: var(--line); }
.se-channel-row.programmed {
  border-color: rgba(255,167,38,0.35);
  background: rgba(255,167,38,0.04);
}
.se-channel-row label {
  font-size: 11px; color: var(--text);
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.se-channel-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.se-channel-row input[type="number"] {
  width: 50px;
  padding: 3px 6px;
  background: var(--bg0); border: 1px solid var(--line);
  color: var(--text); border-radius: 4px;
  font-size: 11px; text-align: right;
  font-family: monospace;
}
.se-channel-row .se-ch-del {
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; font-size: 14px; padding: 0;
  opacity: 0; transition: opacity .12s;
}
.se-channel-row:hover .se-ch-del,
.se-channel-row.programmed .se-ch-del { opacity: 1; }
.se-channel-row .se-ch-del:hover { color: var(--err); }

/* Scene editor footer */
.scene-editor .modal-foot {
  display: flex; justify-content: space-between; align-items: center;
}
.se-status { font-size: 11px; }
.se-status b { color: var(--accent); }
.se-foot-actions { display: flex; gap: 8px; }
.primary.glow {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #1a0a06;
  box-shadow: 0 0 14px rgba(255,42,138,0.4);
}

/* Copy-from dropdown */
#se-copy-from-select {
  background: var(--bg0); border: 1px solid var(--line-strong);
  color: var(--text); padding: 4px 8px; border-radius: 4px;
  font-size: 12px;
}

/* scrollbar polish inside scene editor */
.se-fx-list::-webkit-scrollbar,
.se-channels::-webkit-scrollbar {
  width: 8px;
}
.se-fx-list::-webkit-scrollbar-thumb,
.se-channels::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
}
.se-fx-list::-webkit-scrollbar-track,
.se-channels::-webkit-scrollbar-track {
  background: var(--bg0);
}

/* Scene row action button in left panel */
.scene-row .scene-edit-btn {
  background: transparent; border: none; color: var(--text-dim);
  cursor: pointer; padding: 2px 4px; font-size: 12px;
}
.scene-row .scene-edit-btn:hover { color: var(--accent); }

.ch-builder-row .ch-idx { font-size: 10px; color: var(--muted); text-align: center; font-family: monospace; }
.ch-builder-row input { padding: 4px 6px; }
.ch-builder-row button.del {
  background: transparent; border: none; color: var(--err); cursor: pointer; font-size: 16px;
}

/* Toasts */
.toasts {
  position: fixed; bottom: calc(var(--timeline-h) + 12px); right: 12px;
  display: flex; flex-direction: column; gap: 6px; z-index: 500;
  pointer-events: none;
}
.toast {
  background: var(--bg3); border: 1px solid var(--line-strong);
  color: var(--text); padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 12px; box-shadow: var(--shadow);
  animation: slidein .2s ease-out, fadeout .3s ease-in 2.5s forwards;
  pointer-events: auto;
  max-width: 320px;
}
.toast.ok { border-left: 3px solid var(--ok); }
.toast.warn { border-left: 3px solid var(--warn); }
.toast.err { border-left: 3px solid var(--err); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeout { to { opacity: 0; transform: translateX(20px); } }

/* Responsive tweak */
@media (max-width: 1200px) {
  :root { --left-w: 230px; --right-w: 280px; }
}
