:root {
  --bg: #09090c;
  --panel: #111116;
  --panel-2: #16161d;
  --field: #1a1a22;
  --raised: #262631;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.12);
  --text: #ededf2;
  --text-2: #c3c3cf;
  --muted: #8a8a99;
  --muted-2: #6b6b7a;
  --accent: #8b6cff;
  --accent-2: #a78bfa;
  --pink: #ff5e8a;
  --grad: linear-gradient(135deg, #7c5cff 0%, #c55cf0 50%, #ff5e8a 100%);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --radius: 10px;
  --panel-w: 304px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.4; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.icon { display: inline-flex; line-height: 0; }

/* ------------------------------------------------------------------ layout */
.app {
  display: grid;
  grid-template-columns: var(--panel-w) minmax(0, 1fr) var(--panel-w);
  grid-template-rows: 52px minmax(0, 1fr);
  grid-template-areas: "top top top" "left stage right";
  height: 100%;
  opacity: 0;
  transition: opacity 0.3s ease;
}
body.ready .app { opacity: 1; }

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 12, 16, 0.92);
  backdrop-filter: blur(10px);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
/* Hueloop wordmark: the second "o" is a color wheel with a sparkle in its middle. */
.wordmark {
  display: inline-block;
  flex: none;
  font-family: Outfit, var(--font);
  font-weight: 900;
  font-size: 23px;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
}
.wm-o {
  position: relative;
  display: inline-block;
  padding-right: 0.04em;
  margin-right: -0.04em;
  background: conic-gradient(from 200deg at 49.2% 62%, #ff3d77, #ffb300, #2ee6a6, #3d7dff, #a45cff, #ff3d77);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.wm-o svg { position: absolute; left: 49.2%; top: 62%; width: 0.17em; height: 0.17em; transform: translate(-50%, -50%); fill: var(--text); }
.doc-name {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  padding: 4px 8px;
  width: 190px;
  min-width: 0;
}
.doc-name:hover { border-color: var(--line); }
.doc-name:focus { border-color: var(--accent); color: var(--text); outline: none; background: var(--field); }
.top-actions { display: flex; align-items: center; gap: 6px; }
.sep { width: 1px; height: 20px; background: var(--line-2); margin: 0 4px; }

.panel {
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--panel);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}
.panel-left { grid-area: left; border-right: 1px solid var(--line); }
.panel-right { grid-area: right; border-left: 1px solid var(--line); }
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 4px; border: 2px solid var(--panel); }

/* ------------------------------------------------------------------ stage */
.stage {
  grid-area: stage;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 18px 18px,
    radial-gradient(1200px 700px at 50% 40%, #16161d, #0a0a0d);
}
.stage-inner {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  position: relative;
}
.frame {
  position: relative;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 24px 70px rgba(0, 0, 0, 0.55), 0 6px 18px rgba(0, 0, 0, 0.35);
  background: #000;
}
.frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}
.frame:fullscreen { width: 100vw !important; height: 100vh !important; border-radius: 0; }
.overlay { position: absolute; inset: 0; pointer-events: none; }

.handle {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  transition: box-shadow 0.15s ease, width 0.15s, height 0.15s;
}
.handle.dragging { cursor: grabbing; }
.mesh-handle {
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(0, 0, 0, 0.45);
}
.mesh-handle span { position: absolute; inset: 2px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.35); }
.mesh-handle.active { box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0 0 5px rgba(139, 108, 255, 0.55), 0 4px 14px rgba(0, 0, 0, 0.45); }
.center-handle {
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(0, 0, 0, 0.4);
  background: radial-gradient(circle, #fff 0 2.5px, rgba(0, 0, 0, 0.25) 3.5px, transparent 4px);
}

.timeline {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 12, 16, 0.8);
}
.icon-btn.play { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.time, .quality { font: 500 11.5px var(--mono); color: var(--muted); white-space: nowrap; }
.time { min-width: 96px; color: var(--text-2); }
.quality { margin-left: auto; }
.scrub-wrap { position: relative; flex: 1; min-width: 60px; max-width: 520px; display: flex; align-items: center; }
.scrub { flex: 1; width: 100%; min-width: 0; }
.scrub-keys { position: absolute; left: 7px; right: 7px; top: calc(50% + 8px); height: 0; pointer-events: none; }
.scrub-keys span { position: absolute; top: 0; width: 6px; height: 6px; background: #ffd66b; transform: translate(-50%, -50%) rotate(45deg); border-radius: 1px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); }

/* ------------------------------------------------------------------ buttons */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.07); color: var(--text); }
.icon-btn.active { color: var(--accent-2); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.05);
  font-weight: 550;
  font-size: 12.5px;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary {
  border: 0;
  background: var(--grad);
  color: #fff;
  box-shadow: 0 6px 20px rgba(160, 90, 255, 0.28), inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--grad); }
.btn.small { height: 30px; padding: 0 10px; }
.btn.wide { width: 100%; height: 38px; }
.btn-row { display: flex; gap: 8px; }

/* ------------------------------------------------------------------ sections */
.section { border-bottom: 1px solid var(--line); }
.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 14px 16px 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
}
.section-title { flex: 1; }
.section-head .icon { color: var(--muted-2); transition: transform 0.2s ease; }
.section.open .section-head .icon { transform: rotate(180deg); }
.section-head:hover .icon { color: var(--text); }
.section-body { display: none; flex-direction: column; gap: 13px; padding: 2px 16px 18px; }
.section.open .section-body { display: flex; }

.subhead {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.subhead::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.note { margin: 0; color: var(--muted-2); font-size: 11.5px; line-height: 1.45; }

/* ------------------------------------------------------------------ controls */
.ctl-label { color: var(--text-2); font-size: 12px; user-select: none; }
.ctl-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 3px; }
.ctl-value { display: inline-flex; align-items: baseline; gap: 2px; }
.ctl-unit { color: var(--muted-2); font: 500 10.5px var(--mono); }
.ctl-num {
  width: 58px;
  padding: 3px 5px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: 500 11.5px var(--mono);
  text-align: right;
}
.ctl-num:hover { border-color: var(--line); }
.ctl-num:focus { border-color: var(--accent); background: var(--field); outline: none; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  --p: 50%;
  touch-action: pan-y;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent-2) var(--p), rgba(255, 255, 255, 0.1) var(--p));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5), 0 0 0 4px rgba(167, 139, 250, 0);
  transition: box-shadow 0.15s;
}
input[type="range"]:hover::-webkit-slider-thumb,
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5), 0 0 0 4px rgba(167, 139, 250, 0.25); }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.1); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent-2); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); }

.ctl-inline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ctl-inline > .ctl-label { flex: none; }
.ctl-inline .select-wrap, .ctl-inline .color-input { width: 58%; }
.select-wrap { position: relative; min-width: 0; }
.select-wrap.grow { flex: 1; }
.select-wrap .icon { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--muted); }
select, .text-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 32px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--text);
  font-size: 12.5px;
  text-overflow: ellipsis;
}
.text-input { padding: 0 10px; }
select:hover, .text-input:hover { border-color: var(--line-2); }
select:focus, .text-input:focus { border-color: var(--accent); outline: none; }
select option, select optgroup { background: #1a1a22; color: var(--text); }

.ctl-seg { display: flex; flex-direction: column; gap: 6px; }
.segmented {
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--field);
}
.seg-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  padding: 6px 4px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 550;
  white-space: nowrap;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--raised); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.06); }
.segmented.compact { flex: none; }
.segmented.compact .seg-btn { flex: none; padding: 5px 9px; }

.ctl-toggle { cursor: pointer; }
.switch { position: relative; width: 32px; height: 18px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch-knob {
  position: absolute;
  inset: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.14);
  transition: background 0.15s;
  pointer-events: none;
}
.switch-knob::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.switch input:checked + .switch-knob { background: var(--accent); }
.switch input:checked + .switch-knob::after { transform: translateX(14px); }
.switch input:focus-visible + .switch-knob { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.color-input {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  min-width: 0;
}
.swatch {
  position: relative;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  overflow: hidden;
}
.swatch input { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); opacity: 0; cursor: pointer; border: 0; padding: 0; }
.hex-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: 500 12px var(--mono);
  text-transform: uppercase;
}
.hex-input:focus { outline: none; }

/* canvas size */
.dims { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.dim-label { color: var(--muted-2); font: 600 10.5px var(--mono); }
.ctl-num.dim { width: 64px; text-align: left; border-color: var(--line); background: var(--field); height: 30px; }
.ratio { margin-left: auto; color: var(--muted); font: 500 11px var(--mono); }

/* presets */
.preset-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 8px; }
.preset-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  min-width: 0;
}
.preset-thumb {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  overflow: hidden;
  background: var(--field);
  box-shadow: inset 0 0 0 1px var(--line-2);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.preset-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.preset-thumb img:not([src]) { visibility: hidden; }
.preset-card:hover .preset-thumb { transform: translateY(-1px); box-shadow: 0 0 0 1.5px var(--accent-2), 0 6px 16px rgba(0, 0, 0, 0.4); }
.preset-name { font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preset-card:hover .preset-name { color: var(--text); }
.preset-card.surprise .preset-thumb { color: var(--accent-2); background: linear-gradient(135deg, rgba(124, 92, 255, 0.18), rgba(255, 94, 138, 0.12)); }

/* mode grid */
.mode-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 2px 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.mode-btn:hover { color: var(--text); border-color: var(--line-2); }
.mode-btn.active { color: var(--text); border-color: var(--accent); background: rgba(139, 108, 255, 0.12); }
.mode-glyph { position: relative; width: 30px; height: 20px; border-radius: 5px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12); }
.glyph-curves { background: radial-gradient(ellipse 140% 90% at 0% 100%, #ffc07a 0 25%, #ff5e8a 45%, #7c5cff 70%, #1d1247 100%); }
.glyph-mesh { background: radial-gradient(at 20% 25%, #ff5e8a, transparent 60%), radial-gradient(at 85% 20%, #ffc07a, transparent 55%), radial-gradient(at 55% 95%, #7c5cff, transparent 65%), #22154f; }
.glyph-linear { background: linear-gradient(90deg, #1d1247, #7c5cff 40%, #ff5e8a 70%, #ffc07a); }
.glyph-radial { background: radial-gradient(circle at 50% 50%, #ffc07a 0, #ff5e8a 25%, #7c5cff 55%, #1d1247 85%); }
.glyph-conic { background: conic-gradient(from 90deg, #1d1247, #7c5cff, #ff5e8a, #ffc07a, #1d1247); }
.glyph-diamond { background: #1d1247; }
.glyph-diamond::after { content: ""; position: absolute; inset: 1px 6px; background: radial-gradient(circle, #ffc07a, #ff5e8a 45%, #7c5cff 90%); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.glyph-spiral { background: repeating-conic-gradient(from 0deg, #1d1247 0deg, #7c5cff 30deg, #ff5e8a 60%, #1d1247 90deg); }
.glyph-noise { background: radial-gradient(ellipse at 30% 40%, #ff5e8a 0 18%, transparent 46%), radial-gradient(ellipse at 72% 70%, #ffc07a 0 12%, transparent 40%), radial-gradient(ellipse at 80% 15%, #7c5cff, transparent 50%), linear-gradient(120deg, #3b1ea8, #1d1247); }

/* gradient editor */
.ctl-gradient { display: flex; flex-direction: column; gap: 10px; }
.grad-editor { padding: 0 2px; }
.grad-bar {
  height: 30px;
  border-radius: 8px;
  cursor: copy;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 2px 8px rgba(0, 0, 0, 0.3);
}
.grad-stops { position: relative; height: 24px; margin-top: 4px; }
.stop-handle {
  position: absolute;
  top: 3px;
  width: 16px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: #f4f4f8;
  transform: translateX(-50%);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
  cursor: ew-resize;
  touch-action: none;
  transition: transform 0.12s, opacity 0.12s, box-shadow 0.12s;
}
.stop-handle::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 50%;
  margin-left: -5px;
  border: 5px solid transparent;
  border-top: 0;
  border-bottom-color: #f4f4f8;
}
.stop-fill { position: absolute; inset: 2.5px; border-radius: 2.5px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2); }
.stop-handle.active { box-shadow: 0 0 0 2px var(--accent), 0 1px 6px rgba(0, 0, 0, 0.6); z-index: 2; }
.stop-handle.active::before { border-bottom-color: var(--accent); }
.stop-handle.removing { opacity: 0.35; transform: translate(-50%, 10px); }
.stop-inspector { display: flex; align-items: center; gap: 6px; }
.stop-inspector .color-input { flex: 1; }
.pos-wrap { display: inline-flex; align-items: baseline; gap: 2px; }
.ctl-num.pos-num { width: 50px; border-color: var(--line); background: var(--field); height: 32px; }
.grad-tools { display: flex; align-items: center; gap: 4px; }

/* curves */
.ctl-curves { display: flex; flex-direction: column; gap: 8px; }
.curve-toolbar { display: flex; align-items: center; gap: 4px; }
.curve-toolbar .segmented.compact.grow { flex: 1; }
.curve-toolbar .segmented.compact.grow .seg-btn { flex: 1; }
.curve-toolbar .select-wrap.grow { min-width: 0; }
.curve-canvas {
  width: 100%;
  height: 176px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0c0c11;
  touch-action: none;
  cursor: crosshair;
}

/* ------------------------------------------------------------------ modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(4, 4, 7, 0.62);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.18s ease;
}
.modal-backdrop.show { opacity: 1; }
.modal {
  width: min(480px, 100%);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65);
}
.modal.small { width: min(400px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 6px 20px; }
.modal-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 10px 9px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent-2); }
.tab-pane { display: flex; flex-direction: column; gap: 14px; padding: 18px 20px 20px; }
.field-label { margin-bottom: 7px; color: var(--text-2); font-size: 12px; }
.field-hint { margin-left: 6px; color: var(--muted-2); font-size: 11px; }
.out-size {
  padding: 9px 11px;
  border-radius: 8px;
  background: var(--field);
  border: 1px solid var(--line);
  color: var(--text-2);
  font: 500 11.5px var(--mono);
}
.lead { margin: 0; color: var(--text-2); font-size: 13px; line-height: 1.5; }
.uses { margin: 0; padding-left: 18px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.uses b { color: var(--text-2); font-weight: 600; }
.progress { display: flex; align-items: center; gap: 10px; }
.progress-track { flex: 1; height: 6px; border-radius: 3px; background: var(--field); overflow: hidden; }
.progress-bar { width: 0; height: 100%; background: var(--grad); transition: width 0.15s linear; }
.progress-text { font: 500 11.5px var(--mono); color: var(--text-2); min-width: 96px; text-align: right; }

.shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; margin: 0; padding: 12px 20px 22px; font-size: 12.5px; }
.shortcuts dt { color: var(--text-2); white-space: nowrap; }
.shortcuts dd { margin: 0; color: var(--muted); }
kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--field);
  color: var(--text);
  font: 500 11px var(--mono);
  text-align: center;
}

/* ------------------------------------------------------------------ toast & fatal */
.toast {
  position: fixed;
  left: 50%;
  bottom: 70px;
  z-index: 60;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: #1c1c24;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  font-size: 12.5px;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(255, 94, 94, 0.4); color: #ffc2c2; }
.fatal { max-width: 440px; margin: auto; padding: 32px; text-align: center; color: var(--text-2); }
.fatal h2 { color: var(--text); font-size: 17px; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1240px) {
  :root { --panel-w: 276px; }
}

@media (max-width: 1000px) {
  html, body { overflow: auto; height: auto; }
  .app { display: flex; flex-direction: column; height: auto; min-height: 100%; }
  .topbar { position: sticky; top: env(safe-area-inset-top, 0px); height: 52px; flex: none; order: 0; }
  .stage { position: sticky; top: calc(52px + env(safe-area-inset-top, 0px)); z-index: 10; flex: none; order: 1; height: 46vh; height: 46dvh; border-bottom: 1px solid var(--line); }
  .panel-left { order: 2; }
  .panel-right { order: 3; }
  .panel { overflow: visible; border: 0; }
  .panel-right { border-top: 1px solid var(--line); }
  .timeline { height: 44px; }
  .quality { display: none; }
}

@media (max-width: 680px) {
  .doc-name, .sep, #help { display: none; }
  .btn .label { display: none; }
  .btn { padding: 0 9px; }
  .btn.wide .label, .btn.wide { padding: 0 12px; }
  .topbar { padding: 0 12px 0 16px; }
  .time { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ------------------------------------------------------------------ v2 components */
.section-badge {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
}
.section-badge.on { background: rgba(139, 108, 255, 0.18); color: #d4c8ff; }

/* Quick navigation chips at the top of the effects panel */
.panel-nav {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 17, 22, 0.94);
  backdrop-filter: blur(8px);
}
.nav-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field);
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
}
.nav-chip:hover { color: var(--text); border-color: var(--line-2); }
.chip-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, 0.18); }
.nav-chip.on { color: var(--text); }
.nav-chip.on .chip-dot { background: var(--grad); box-shadow: 0 0 6px rgba(197, 92, 240, 0.7); }

/* Visual choice grids (glass styles, dot layouts and shapes, sparkle shapes) */
.choice-grid { display: grid; gap: 5px; }
.choice-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 7px 2px 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--field);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 550;
}
.choice-btn:hover { color: var(--text); border-color: var(--line-2); }
.choice-btn.active { color: var(--text); border-color: var(--accent); background: rgba(139, 108, 255, 0.12); }
.choice-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.choice-glyph {
  position: relative;
  display: grid;
  place-items: center;
  width: 28px;
  height: 18px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
  color: var(--text-2);
}
.choice-btn.active .choice-glyph { color: #d4c8ff; }
.choice-glyph[class*="g-"] { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12); overflow: hidden; }
.g-off { background: linear-gradient(135deg, transparent 46%, var(--muted-2) 46% 54%, transparent 54%), var(--panel-2); }
.g-ribs { background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.45) 0 1px, rgba(255, 255, 255, 0) 1px 3px, rgba(0, 0, 0, 0.25) 3px 4px), linear-gradient(135deg, #5b3cc4, #ff5e8a); }
.g-waves { background: repeating-radial-gradient(ellipse 160% 60% at 50% 160%, rgba(255, 255, 255, 0.5) 0 1px, transparent 1px 4px), linear-gradient(135deg, #5b3cc4, #ff5e8a); }
.g-rings { background: repeating-radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.5) 0 1px, transparent 1px 4px), linear-gradient(135deg, #5b3cc4, #ff5e8a); }
.g-tiles { background: linear-gradient(rgba(255, 255, 255, 0.5) 1px, transparent 1px) 0 0 / 7px 7px, linear-gradient(90deg, rgba(255, 255, 255, 0.5) 1px, transparent 1px) 0 0 / 7px 7px, linear-gradient(135deg, #5b3cc4, #ff5e8a); }
.g-hex { background: radial-gradient(circle, rgba(255, 255, 255, 0.6) 1.3px, transparent 1.8px) 0 0 / 6px 6px, radial-gradient(circle, rgba(255, 255, 255, 0.6) 1.3px, transparent 1.8px) 3px 3px / 6px 6px, linear-gradient(135deg, #5b3cc4, #ff5e8a); }
.g-diamonds { background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.45) 0 1px, transparent 1px 5px), repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.45) 0 1px, transparent 1px 5px), linear-gradient(135deg, #5b3cc4, #ff5e8a); }
.g-bubbles { background: radial-gradient(circle at 40% 40%, rgba(255, 255, 255, 0.9) 0 0.8px, rgba(255, 255, 255, 0.25) 1.5px 3px, transparent 3.4px) 0 0 / 8px 8px, linear-gradient(135deg, #5b3cc4, #ff5e8a); }
.g-shards { background: conic-gradient(from 15deg at 38% 58%, rgba(255, 255, 255, 0.35) 0 60deg, rgba(0, 0, 0, 0.2) 60deg 150deg, rgba(255, 255, 255, 0.12) 150deg 230deg, rgba(0, 0, 0, 0.3) 230deg 290deg, transparent 290deg), linear-gradient(135deg, #5b3cc4, #ff5e8a); }
.g-orb { background: radial-gradient(circle at 42% 40%, rgba(255, 255, 255, 0.95) 0 1px, rgba(255, 255, 255, 0.35) 2px, rgba(255, 255, 255, 0.08) 5.5px, rgba(0, 0, 0, 0.35) 6.5px, transparent 7.2px), linear-gradient(135deg, #5b3cc4, #ff5e8a); }
.g-clear { background: linear-gradient(135deg, rgba(255, 255, 255, 0.35) 0 18%, transparent 18% 100%), linear-gradient(135deg, #7c6ad6, #ff9ab5); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.55) !important; }
.g-frosted { background: radial-gradient(rgba(255, 255, 255, 0.4) 0.6px, transparent 1px) 0 0 / 3px 3px, radial-gradient(rgba(255, 255, 255, 0.25) 0.6px, transparent 1px) 1.5px 1.5px / 3px 3px, linear-gradient(135deg, #7c6ad6, #ff9ab5); }

/* Pattern layer tabs */
.ctl-layers { display: flex; flex-direction: column; gap: 6px; }
.layer-row { display: flex; align-items: center; gap: 6px; }
.layer-tabs { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; min-width: 0; }
.layer-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 4px 8px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
  white-space: nowrap;
}
.layer-tab:hover { color: var(--text); }
.layer-tab.active { color: var(--text); border-color: var(--accent); background: rgba(139, 108, 255, 0.12); }
.layer-tab.muted { opacity: 0.55; }
.layer-num {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  font: 600 10px var(--mono);
}
.layer-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  padding: 5px 9px;
  border: 1px dashed var(--line-2);
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 550;
}
.layer-add:hover:not(:disabled) { border-color: var(--accent-2); color: var(--text); }
.layer-tools { display: flex; justify-content: flex-end; gap: 2px; }

/* Preset category filters */
.presets { display: flex; flex-direction: column; gap: 10px; }
.preset-filters { display: flex; flex-wrap: wrap; gap: 5px; }
.filter-chip {
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
}
.filter-chip:hover { color: var(--text); }
.filter-chip.active { color: var(--text); background: var(--raised); border-color: var(--line-2); }

/* Still / Motion switch */
.output-toggle { flex: none; }
.output-toggle .seg-btn { padding: 5px 9px; }
body[data-output="still"] #play { display: none; }
body[data-output="still"] .scrub-wrap { max-width: 360px; }
.wide-btn { width: 100%; }

@media (max-width: 1000px) {
  .panel-nav { position: static; }
}
@media (max-width: 680px) {
  .output-toggle .label { display: none; }
  .timeline { gap: 6px; padding: 0 8px; }
  .timeline .time { display: none; }
  .curves-toggle { padding: 0 8px; }
}

/* Export dialog additions */
.segmented.wrap { flex-wrap: wrap; }
.tab-stack { display: flex; flex-direction: column; gap: 14px; }
.pane-divider { height: 1px; margin: 4px 0; background: var(--line); }
.pack-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.pack-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--field);
  color: var(--muted);
  text-align: left;
}
.pack-chip:hover { border-color: var(--line-2); color: var(--text); }
.pack-chip.active { border-color: var(--accent); background: rgba(139, 108, 255, 0.12); color: var(--text); }
.pack-name { font-size: 12px; font-weight: 600; }
.pack-size { font: 500 10.5px var(--mono); color: var(--muted-2); }
.still-notice { display: flex; flex-direction: column; gap: 12px; }

/* ------------------------------------------------------------------ v3: objects, curves on canvas, palettes */
.curves-toggle { flex: none; }
.curves-toggle.active { border-color: var(--accent); background: rgba(139, 108, 255, 0.16); color: var(--text); }
.curve-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; touch-action: none; }
.curve-overlay.active { pointer-events: auto; cursor: crosshair; }
.curve-legend {
  position: absolute;
  bottom: -30px;
  left: 0;
  display: flex;
  gap: 6px;
  pointer-events: auto;
}
.curve-legend button {
  padding: 3px 9px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  background: rgba(10, 10, 14, 0.6);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  backdrop-filter: blur(6px);
}
.curve-legend button.off { opacity: 0.45; }

.el-handle {
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 4px 12px rgba(0, 0, 0, 0.45);
  background: rgba(10, 10, 14, 0.35);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 12px;
  line-height: 1;
}
.el-handle.active { box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 0 0 5px rgba(139, 108, 255, 0.55); }
.size-handle {
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid #fff;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
  cursor: ew-resize;
}
.pt-handle {
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid #fff;
  background: rgba(255, 140, 80, 0.9);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}
.size-ring {
  position: absolute;
  left: 0;
  top: 0;
  border: 1px dashed rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  pointer-events: none;
}

.add-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.add-grid .choice-btn { padding: 7px 2px 6px; }

.palette-groups { display: flex; flex-direction: column; gap: 10px; }
.palette-group-title { font-size: 10.5px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted-2); }
.palette-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.palette-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--field);
  color: var(--text-2);
  text-align: left;
  font-size: 11px;
  font-weight: 550;
}
.palette-card:hover { border-color: var(--line-2); color: var(--text); }
.palette-card.active { border-color: var(--accent); background: rgba(139, 108, 255, 0.12); color: var(--text); }
.palette-strip { height: 16px; border-radius: 5px; }
.palette-tools { display: flex; gap: 6px; align-items: center; }
.palette-tools .grow { flex: 1; }

.customize-empty { color: var(--muted); font-size: 12px; }
.section[data-id="customize"] .section-title::before { content: '✦ '; color: var(--accent-2); }

.point-edit { display: flex; gap: 6px; align-items: center; font-size: 11.5px; color: var(--muted); }
.point-edit .ctl-num { width: 56px; }

/* ------------------------------------------------------------------ keyframes */
.key-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 18px;
  height: 18px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted-2);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.ctl:hover .key-btn, .key-btn:focus-visible, .stop-inspector .key-btn, .curve-toolbar .key-btn, .palette-tools .key-btn { opacity: 0.8; }
.key-btn:hover { opacity: 1; color: var(--text); background: rgba(255, 255, 255, 0.07); }
.key-btn[data-state="track"] { opacity: 1; color: #ffd66b; }
.key-btn[data-state="key"] { opacity: 1; color: #ffd66b; }
.key-btn[data-state="key"] svg path { fill: currentColor; }
.key-btn[data-state="wave"] { opacity: 1; color: var(--accent-2); }
.key-btn[data-state="wave"] svg path { fill: currentColor; }
.key-btn[data-state="off"] { opacity: 0.8; color: var(--muted-2); }
.key-btn-lg { width: 28px; height: 28px; border-radius: 7px; margin-left: 0; }
.ctl-inline > .key-btn { margin-left: auto; margin-right: -6px; }
body[data-output="still"] .key-btn[data-state="none"] { display: none; }
.ctl.animated .ctl-num { color: #ffd66b; }
.ctl.animated input[type="range"] { --accent-2: #ffd66b; }

.keys-toggle { flex: none; }
.keys-toggle.active { border-color: #ffd66b; background: rgba(255, 214, 107, 0.12); color: var(--text); }
.keys-count { min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: #ffd66b; color: #1a1400; font: 700 10px/16px var(--font); text-align: center; }

.keys-panel {
  display: flex;
  flex-direction: column;
  max-height: min(44vh, 380px);
  flex: none;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 14, 19, 0.96);
  outline: none;
}
.keys-head { display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.keys-head .grow { flex: 1; }
.keys-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: 12.5px; color: #ffd66b; margin-right: 6px; }
.keys-add { display: flex; align-items: center; gap: 6px; }
.keys-add .select-wrap { width: 200px; }
.keys-head .btn.ghost, .keys-inspector .btn.ghost { background: transparent; }
.keys-body { overflow: auto; min-height: 0; flex: 1 1 auto; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.12) transparent; }
.keys-grid { position: relative; --label-w: 230px; --lane-pad: 14px; }
.keys-row { display: grid; grid-template-columns: var(--label-w) minmax(0, 1fr); min-height: 30px; border-top: 1px solid var(--line); }
.keys-row:first-child { border-top: 0; }
.keys-row.sel { background: rgba(255, 214, 107, 0.05); }
.keys-row.muted .keys-lane { opacity: 0.35; }
.keys-label { display: flex; align-items: center; gap: 2px; min-width: 0; padding: 0 6px 0 8px; font-size: 12px; cursor: pointer; border-right: 1px solid var(--line); }
.keys-label.muted { color: var(--muted-2); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; cursor: default; }
.keys-name { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 6px; overflow: hidden; white-space: nowrap; }
.keys-name b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.keys-name small { color: var(--muted); font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; }
.icon-btn.tiny { width: 22px; height: 22px; border-radius: 6px; }
.icon-btn.tiny.off { color: var(--muted-2); opacity: 0.6; }
.keys-lane { position: relative; margin: 0 var(--lane-pad); min-height: 30px; cursor: crosshair; }
.keys-lane.wave { background: var(--wave-grad, none) center / 100% 4px no-repeat; }
.keys-lane svg { position: absolute; left: 0; top: 2px; width: 100%; height: 26px; pointer-events: none; }
.keys-lane polyline { fill: none; stroke: var(--accent-2); stroke-width: 1.6; }
.kf {
  position: absolute;
  top: 50%;
  width: 11px;
  height: 11px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.55);
  border-radius: 2px;
  background: #ffd66b;
  transform: translate(-50%, -50%) rotate(45deg);
  cursor: grab;
  z-index: 2;
  touch-action: none;
}
.kf.color { background: var(--kf-color); border-color: rgba(255, 255, 255, 0.7); }
.kf:hover { box-shadow: 0 0 0 3px rgba(255, 214, 107, 0.3); }
.kf.sel { box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(0, 0, 0, 0.4); }
.kf-span { position: absolute; top: 50%; height: 2px; margin-top: -1px; background: rgba(255, 214, 107, 0.4); pointer-events: none; }
.kf-span.wrap { background: repeating-linear-gradient(90deg, rgba(255, 214, 107, 0.35) 0 4px, transparent 4px 8px); }
.kf-span.hold { background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.3) 0 2px, transparent 2px 5px); }
.keys-ruler { position: relative; height: 24px; margin: 0 var(--lane-pad); cursor: ew-resize; }
.keys-ruler .tick { position: absolute; bottom: 0; height: 5px; border-left: 1px solid var(--line-2); font: 500 10px var(--mono); color: var(--muted-2); }
.keys-ruler .tick.major { height: 100%; padding: 3px 0 0 4px; }
.keys-overlay { position: absolute; top: 0; bottom: 0; left: calc(var(--label-w) + var(--lane-pad)); right: var(--lane-pad); pointer-events: none; }
.keys-playhead { position: absolute; top: 0; bottom: 0; width: 1.5px; margin-left: -0.75px; background: var(--pink); box-shadow: 0 0 6px rgba(255, 94, 138, 0.6); }
.keys-empty { margin: 0; padding: 14px 16px; color: var(--muted); font-size: 12px; max-width: 720px; }
.keys-inspector { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; padding: 8px 12px; border-top: 1px solid var(--line); font-size: 12px; }
.kfi-title { font-weight: 600; color: var(--text); margin-right: 4px; }
.kfi-field { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.kfi-field .ctl-num { width: 74px; border-color: var(--line); background: var(--field); height: 28px; text-align: left; }
.kfi-field .select-wrap { width: 130px; }
.kfi-field .color-input { width: 150px; }
.kfi-check input { accent-color: #ffd66b; }
.kfi-note { color: var(--muted); }

.key-menu {
  position: fixed;
  z-index: 1000;
  min-width: 220px;
  padding: 5px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--raised);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.menu-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 10px; border: 0; border-radius: 7px; background: transparent; text-align: left; font-size: 12.5px; }
.menu-item:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); }

@media (max-width: 1000px) {
  .stage.keys-open { height: 82vh; height: 82dvh; }
  .keys-panel { max-height: 44dvh; }
}
@media (max-width: 680px) {
  .keys-grid { --label-w: 112px; --lane-pad: 10px; }
  .keys-name small { display: none; }
  .keys-head { gap: 4px; padding: 6px 8px; }
  .keys-title, .keys-head .grow { display: none; }
  .keys-add { flex: 1; min-width: 0; }
  .keys-add .select-wrap { width: auto; flex: 1; min-width: 0; }
  .keys-toggle .label { display: none; }
  .keys-label .icon-btn.tiny:not(:last-child) { display: none; }
  .keys-inspector { gap: 6px 10px; padding: 6px 8px; }
  .kfi-field .ctl-num { width: 62px; }
}

.motion-path { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.motion-path polyline { fill: none; stroke: #ffd66b; stroke-width: 1.5; stroke-dasharray: 2 5; stroke-linecap: round; filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.6)); }

/* Glass mask handles */
.mask-handle {
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 4px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  background: rgba(139, 108, 255, 0.35);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 3px 10px rgba(0, 0, 0, 0.4);
}
.mask-size-handle {
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid #fff;
  background: rgba(139, 108, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
  cursor: nwse-resize;
}

/* Image and text layers */
.layer-pick { display: flex; flex-direction: column; gap: 8px; }
.layer-row { display: flex; gap: 10px; align-items: center; min-width: 0; }
.layer-thumb-box {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: repeating-conic-gradient(#2a2a33 0 25%, #1c1c24 0 50%) 0 0 / 12px 12px;
  overflow: hidden;
}
.layer-thumb { width: 100%; height: 100%; object-fit: contain; display: block; }
.layer-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.layer-name { font-size: 12.5px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-status { font-size: 11px; color: var(--muted); line-height: 1.35; }
.icon-btn.small { width: 30px; height: 30px; border: 1px solid var(--line); }
.text-content {
  width: 100%;
  min-height: 52px;
  resize: vertical;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--text);
  font: 13px/1.4 var(--font);
}
.text-content:hover { border-color: var(--line-2); }
.text-content:focus { border-color: var(--accent); outline: none; }
.token-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 6px; }
.token-hint { font-size: 11px; color: var(--muted-2); margin-right: 2px; }
.layer-handle {
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 4px 12px rgba(0, 0, 0, 0.45);
  background: rgba(10, 10, 14, 0.4);
  display: grid;
  place-items: center;
  color: #fff;
  font: 700 13px/1 var(--font);
}
.stage.drop-target .frame { outline: 2px dashed var(--accent-2); outline-offset: 6px; }

/* Colors from a picture */
.pic-thumb { width: 100%; max-height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.pic-card { padding: 0; overflow: hidden; }
.pic-apply {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 5px 5px 4px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}
.pic-use {
  padding: 5px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  text-align: left;
}
.pic-use:hover, .pic-apply:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.pic-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pic-apply { text-transform: capitalize; }

/* Music */
.key-btn[data-state="audio"] { opacity: 1; color: #5ee0c4; }
.key-btn[data-state="audio"] svg path { fill: currentColor; }
.keys-lane.audio { cursor: default; background: var(--wave-grad, none) center / 100% 4px no-repeat; }
.audio-meter {
  position: absolute;
  left: 0;
  top: 50%;
  height: 10px;
  width: calc(var(--lvl, 0) * 100%);
  transform: translateY(-50%);
  border-radius: 5px;
  background: linear-gradient(90deg, rgba(94, 224, 196, 0.35), #5ee0c4);
  transition: width 0.06s linear;
  pointer-events: none;
}
.audio-tag { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; color: #5ee0c4; pointer-events: none; }
.kfi-modes { flex: none; }
.kfi-modes .seg-btn { display: inline-flex; align-items: center; gap: 4px; padding: 0 9px; }
.music { display: flex; flex-direction: column; gap: 8px; }
.music .btn.active { border-color: #5ee0c4; color: #5ee0c4; }
.music-status { display: flex; align-items: center; gap: 6px; color: #5ee0c4; font-size: 12px; min-width: 0; }
.music-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.music-meter { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.music-bar { display: flex; flex-direction: column; gap: 3px; }
.music-bar i { display: block; height: 6px; border-radius: 3px; background: linear-gradient(90deg, #5ee0c4 calc(var(--lvl, 0) * 100%), rgba(255, 255, 255, 0.08) calc(var(--lvl, 0) * 100%)); }
.music-bar small { font-size: 10.5px; color: var(--muted); }
.keys-lane .audio-tag svg { position: static; width: 11px; height: 11px; }
.keys-lane .audio-tag .icon { display: inline-flex; }

/* Hueloop Pro */
.pro-chip {
  display: inline-flex;
  align-items: center;
  margin-left: 5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--grad);
  color: #fff;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.06em;
  line-height: 1.5;
  vertical-align: middle;
}
.pro-chip.on-thumb { position: absolute; top: 4px; right: 4px; margin: 0; z-index: 1; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); }
.pro-btn { border-color: rgba(197, 92, 240, 0.45); }
.pro-btn .icon { color: #d88cff; }
.pro-btn.active { background: rgba(139, 108, 255, 0.14); border-color: var(--accent); }
.pro-note { color: var(--text-2); }
.link-btn { padding: 0; border: 0; background: none; color: var(--accent-2); font: inherit; text-decoration: underline; cursor: pointer; }
.pro-modal { width: min(560px, 100%); }
.pro-modal .modal-head h2 { display: flex; align-items: center; gap: 8px; font-size: 17px; }
.pro-mark { padding: 2px 7px; border-radius: 6px; background: var(--grad); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; }
.pro-body { padding: 8px 20px 4px; }
.pro-reason { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: rgba(139, 108, 255, 0.12); color: var(--text); font-size: 13px; }
.pro-plans { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pro-plan { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 14px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--panel-2); }
.pro-plan.best { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(139, 108, 255, 0.35) inset; }
.pro-flag { position: absolute; top: -9px; right: 12px; padding: 1px 8px; border-radius: 999px; background: var(--grad); color: #fff; font-size: 10.5px; font-weight: 700; }
.pro-plan-name { font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.pro-price { display: flex; align-items: baseline; gap: 6px; }
.pro-price b { font-size: 28px; font-weight: 750; color: var(--text); }
.pro-price span { color: var(--muted); font-size: 13px; }
.pro-blurb { margin: 0 0 6px; color: var(--text-2); font-size: 12.5px; line-height: 1.4; flex: 1; }
.pro-plan a.btn { text-decoration: none; justify-content: center; }
.pro-features { list-style: none; margin: 16px 0; padding: 0; display: grid; gap: 8px; }
.pro-features li { display: flex; gap: 9px; align-items: flex-start; color: var(--text-2); font-size: 13px; line-height: 1.35; }
.pro-features .icon { color: var(--accent-2); flex: none; margin-top: 1px; }
.pro-key { padding: 12px 0 8px; border-top: 1px solid var(--line); }
.pro-key-row { display: flex; gap: 8px; margin-top: 6px; }
.pro-key-row .text-input { flex: 1; min-width: 0; font-family: var(--mono); }
.pro-error { margin: 8px 0 0; color: #ff8a9a; font-size: 12.5px; }
.pro-own-head { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 650; color: var(--text); }
.pro-own-head .icon { color: var(--accent-2); }
.pro-own-head b { margin-left: auto; padding: 2px 8px; border-radius: 999px; background: var(--raised); color: var(--text-2); font-size: 12px; font-weight: 600; }
.pro-own-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 14px 0; font-size: 13px; }
.pro-own-list dt { color: var(--muted); }
.pro-own-list dd { margin: 0; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }
.pro-own .btn-row a.btn { text-decoration: none; justify-content: center; }
.pro-foot { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 10px 20px 16px; color: var(--muted-2); font-size: 11.5px; }
.pro-foot a { color: var(--muted); }
@media (max-width: 520px) {
  .pro-plans { grid-template-columns: 1fr; }
}
