/* Blob Tracker — dark studio UI */
:root {
  --bg: #0b0e14;
  --panel: #131822;
  --panel2: #0f141d;
  --line: #222b3a;
  --text: #d6deeb;
  --muted: #7c89a0;
  --accent: #39d0ff;
  --accent2: #6ee787;
  --danger: #ff6b6b;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column;
  overflow: hidden;
  user-select: none;
}
body.dragging::after {
  content: "Drop image(s) to load";
  position: fixed; inset: 12px; z-index: 50;
  border: 2px dashed var(--accent); border-radius: 14px;
  background: rgba(57, 208, 255, 0.08);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: var(--accent); pointer-events: none;
}

/* ---- header ---- */
header {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #141a25, #10151e);
  flex: 0 0 auto;
}
header .brand { display: flex; align-items: baseline; gap: 10px; }
header .brand b { font-size: 15px; letter-spacing: 0.2px; }
header .brand b span { color: var(--accent); }
header .brand small { color: var(--muted); }
header .spacer { flex: 1; }
#stats {
  font: 12px/1 ui-monospace, "Cascadia Code", Consolas, monospace;
  color: var(--muted); white-space: nowrap;
}
.hbtn {
  background: #1b2230; color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 12px; cursor: pointer; font-size: 12px;
}
.hbtn:hover { border-color: var(--accent); color: var(--accent); }

/* ---- mode switch (Tracker / Dither / Effects) ---- */
.modeswitch { display: flex; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #0f141d; }
.modeswitch button {
  background: transparent; color: var(--muted); border: 0; border-right: 1px solid var(--line);
  padding: 6px 14px; cursor: pointer; font-size: 12px; font-weight: 600; letter-spacing: 0.3px;
}
.modeswitch button:last-child { border-right: 0; }
.modeswitch button:hover { color: var(--text); background: #161d29; }
.modeswitch button.active { color: #06222e; background: var(--accent); }

/* ---- layout ---- */
main { flex: 1; display: flex; min-height: 0; }
.panel {
  width: 320px; flex: 0 0 320px; overflow-y: auto; overflow-x: hidden;
  background: var(--panel); border-right: 1px solid var(--line);
  padding-bottom: 40px;
}
.panel::-webkit-scrollbar { width: 10px; }
.panel::-webkit-scrollbar-thumb { background: #26303f; border-radius: 6px; }

.stage { position: relative; flex: 1; min-width: 0; background: #0b0e14; }
#stage { width: 100%; height: 100%; display: block; cursor: grab; }
#stage:active { cursor: grabbing; }

/* ---- control sections ---- */
.section { border-bottom: 1px solid var(--line); }
.section-head {
  width: 100%; text-align: left; background: var(--panel2); color: var(--text);
  border: 0; border-bottom: 1px solid var(--line);
  padding: 9px 12px; font-size: 12px; font-weight: 600; letter-spacing: 0.3px;
  cursor: pointer; display: flex; align-items: center; gap: 8px; text-transform: uppercase;
}
.section-head .caret { color: var(--muted); transition: transform 0.15s; font-size: 10px; }
.section.collapsed .caret { transform: rotate(-90deg); }
.section.collapsed .section-body { display: none; }
.section-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }

.ctl { display: flex; flex-direction: column; gap: 5px; }
.ctl-top { display: flex; justify-content: space-between; align-items: baseline; }
.ctl-label { color: var(--muted); font-size: 11.5px; }
.ctl-val { color: var(--accent); font: 11px ui-monospace, monospace; }
.ctl-check { display: flex; align-items: center; gap: 8px; color: var(--text); cursor: pointer; }
.ctl-check input { accent-color: var(--accent); width: 15px; height: 15px; }

.ctl-input, select.ctl-input {
  width: 100%; background: #0c1119; color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 12px;
}
.ctl-input:focus { outline: 1px solid var(--accent); border-color: var(--accent); }

input[type=color].ctl-color {
  width: 100%; height: 28px; background: #0c1119; border: 1px solid var(--line);
  border-radius: 6px; padding: 2px; cursor: pointer;
}
input[type=color].ctl-color::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color].ctl-color::-webkit-color-swatch { border: none; border-radius: 4px; }

input[type=range].ctl-range {
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px;
  background: #2a3445; border-radius: 4px; outline: none; cursor: pointer;
}
input[type=range].ctl-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); border: 2px solid #0b0e14; cursor: pointer;
}
input[type=range].ctl-range::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid #0b0e14; cursor: pointer;
}

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  flex: 1; min-width: 0; background: #1b2230; color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 8px;
  cursor: pointer; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: #123040; border-color: #1d5570; color: var(--accent); }
.btn.primary:hover { background: #16415a; }
.info-row { font-size: 11px; color: var(--muted); padding: 2px 0; line-height: 1.4; }
#live-data {
  white-space: pre-wrap; font: 11px/1.45 ui-monospace, "Cascadia Code", Consolas, monospace;
  color: var(--accent2); background: #0c1119; border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 9px; min-height: 1.4em; max-height: 140px; overflow: auto;
}
#gpu-info { font-style: italic; }
.btn.primary#rec-video { animation: recpulse 1.2s ease-in-out infinite; }
@keyframes recpulse { 0%,100% { border-color: var(--danger); } 50% { border-color: #5a1d1d; } }

/* ---- effect / dither stack ---- */
.fx-stack { display: flex; flex-direction: column; gap: 8px; }
.fx-add-picker {
  display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto;
  background: #0c1119; border: 1px solid var(--line); border-radius: 6px; padding: 6px;
}
.fx-cat-head { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; margin: 6px 0 2px; }
.fx-cat-head:first-child { margin-top: 0; }
.fx-add-item { text-align: left; background: transparent; color: var(--text); border: 0; border-radius: 4px; padding: 5px 7px; cursor: pointer; font-size: 12px; }
.fx-add-item:hover { background: #18222f; color: var(--accent); }

.fx-list { display: flex; flex-direction: column; gap: 6px; }
.fx-layer { border: 1px solid var(--line); border-radius: 6px; background: var(--panel2); overflow: hidden; }
.fx-layer.off { opacity: 0.5; }
.fx-layer-head { display: flex; align-items: center; gap: 5px; padding: 5px 6px; background: #11161f; border-bottom: 1px solid var(--line); }
.fx-layer-head input[type=checkbox] { accent-color: var(--accent); width: 14px; height: 14px; }
.fx-layer-title { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fx-grow { flex: 1; }
.fx-mini { background: #1b2230; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; width: 22px; height: 22px; cursor: pointer; font-size: 11px; padding: 0; line-height: 1; }
.fx-mini:hover { color: var(--accent); border-color: var(--accent); }
.fx-layer-body { padding: 8px; display: flex; flex-direction: column; gap: 9px; }
.fx-kf { background: transparent; color: var(--muted); border: 0; cursor: pointer; font-size: 11px; padding: 0 2px; margin-left: 6px; }
.fx-kf:hover { color: var(--accent); }
.fx-kf.on { color: var(--accent2); }

/* ---- palette editor ---- */
.pal-editor { display: flex; flex-direction: column; gap: 6px; }
.pal-swatches { display: flex; flex-wrap: wrap; gap: 4px; }
.pal-swatch { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.pal-swatch input[type=color].ctl-color { width: 34px; height: 26px; }
.pal-swatch .fx-mini { width: 34px; height: 16px; font-size: 9px; }

/* ---- stage overlays ---- */
#stale {
  position: absolute; top: 12px; right: 12px; z-index: 6;
  background: rgba(255, 107, 107, 0.15); color: var(--danger);
  border: 1px solid var(--danger); border-radius: 6px; padding: 5px 10px; font-size: 11px;
}
#flash {
  position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%) translateY(10px);
  background: #0f1622; border: 1px solid var(--line); color: var(--text);
  padding: 8px 14px; border-radius: 8px; font-size: 12px; z-index: 7;
  opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none; max-width: 80%;
}
#flash.show { opacity: 1; transform: translateX(-50%) translateY(0); }

#transport {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; z-index: 6;
  background: rgba(15, 20, 29, 0.92); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 14px; backdrop-filter: blur(8px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
#transport button {
  background: #1b2230; color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; width: 34px; height: 30px; cursor: pointer; font-size: 13px;
}
#transport button:hover { border-color: var(--accent); color: var(--accent); }
#scrub { width: 320px; accent-color: var(--accent); }

#kf-lane {
  position: absolute; left: 50%; bottom: 66px; transform: translateX(-50%);
  width: 340px; height: 16px; z-index: 6; cursor: crosshair;
  background: rgba(15, 20, 29, 0.92); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}
.kf-dot { position: absolute; top: 50%; width: 9px; height: 9px; background: var(--accent2);
  border: 1px solid #06222e; transform: translate(-50%, -50%) rotate(45deg); cursor: pointer; }
.kf-dot:hover { background: #fff; }
.kf-playhead { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--accent); pointer-events: none; }

.hint {
  position: absolute; left: 12px; bottom: 14px; z-index: 5;
  color: #46526a; font: 11px ui-monospace, monospace; pointer-events: none;
}
