:root {
  --bg: #0e0f12;
  --panel: #15171c;
  --panel-2: #1c1f26;
  --border: #2a2e38;
  --text: #e7e9ee;
  --muted: #8b909d;
  --accent: #ff6a3d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
}

main {
  display: grid;
  grid-template-columns: 1fr 320px;
  height: 100vh;
}

#stage {
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 10%, #1a1d24 0%, transparent 40%),
    radial-gradient(circle at 80% 90%, #161922 0%, transparent 40%),
    var(--bg);
}

#canvas-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  width: min(100%, calc(100vh - 48px));
  max-width: 1080px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
  cursor: pointer;
}

#preview {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
}

#drop-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  pointer-events: none;
  color: var(--muted);
  background: rgba(14,15,18,.6);
  backdrop-filter: blur(2px);
  transition: opacity .2s ease;
}
#drop-hint p { margin: 4px 0; font-size: 18px; color: var(--text); }
#drop-hint .sub { font-size: 13px; color: var(--muted); }
#canvas-wrap.has-video #drop-hint { opacity: 0; }
#canvas-wrap.dragover { outline: 2px dashed var(--accent); outline-offset: -8px; }

#panel {
  background: var(--panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

#panel header h1 {
  margin: 0 0 4px;
  font-size: 16px;
  letter-spacing: .2px;
}
#panel header #filename {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px 14px;
  margin: 0;
  background: var(--panel-2);
}
legend {
  padding: 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
}

label {
  display: block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
label .val {
  float: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
label:first-of-type { margin-top: 0; }

input[type="range"] {
  width: 100%;
  margin-top: 6px;
  accent-color: var(--accent);
}

input[type="color"] {
  display: block;
  width: 100%;
  height: 32px;
  margin-top: 6px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  padding: 2px;
}

select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 6px 8px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}

button {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #1a0e08;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button:disabled {
  background: var(--panel);
  color: var(--muted);
  border-color: var(--border);
  cursor: not-allowed;
}

button.secondary {
  background: var(--panel);
  color: var(--text);
  border-color: var(--border);
  font-weight: 500;
  padding: 6px 10px;
  font-size: 12px;
}
button.secondary:hover {
  background: var(--panel-2);
}

.row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.row button {
  flex: 0 0 auto;
  width: auto;
}

.hint {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#progress { margin-top: 10px; }
#bar {
  height: 6px;
  background: var(--panel);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}
#bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width .15s ease;
}
#progress-text {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
