/* App shell - minimalist dark UI. Nothing here is captured on export. */

:root {
  --bg:        #0d0e12;
  --bg-2:      #14161c;
  --line:      #23262f;
  --text:      #e6e8ee;
  --muted:     #868b99;
  --accent:    #7c9cff;
  --danger:    #ff6b6b;
  --radius:    8px;
  --sidebar-w: 312px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 400 13px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100%;
}

/* ---------- Sidebar ---------- */

#sidebar {
  border-right: 1px solid var(--line);
  background: var(--bg-2);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 32px;
}

#sidebar::-webkit-scrollbar { width: 10px; }
#sidebar::-webkit-scrollbar-thumb { background: #2a2e39; border-radius: 8px; border: 3px solid var(--bg-2); }

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 18px 18px 14px;
  position: sticky;
  top: 0;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  z-index: 5;
}
.brand h1 { font-size: 14px; font-weight: 600; margin: 0; letter-spacing: .2px; }
.brand-mark {
  width: 14px; height: 14px; border-radius: 4px;
  background: linear-gradient(135deg, #7c9cff, #f093fb);
}

.panel { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel h2 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 12px;
}

.row {
  display: grid;
  grid-template-columns: 78px 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  min-height: 26px;
}
.row > span { color: var(--muted); font-size: 12px; }
.row.check { grid-template-columns: 78px 1fr; }
.row.check input { justify-self: start; }
.row.stack { display: block; }
.row.stack .row { grid-template-columns: 78px 1fr auto; margin: 10px 0 0; }
.row:last-child { margin-bottom: 0; }

.row output {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 11px;
  min-width: 30px;
  text-align: right;
}

select, input[type="text"], input[type="number"] {
  grid-column: 2 / -1;
  width: 100%;
  background: #1b1e26;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 8px;
  font: inherit;
  font-size: 12px;
  outline: none;
}
select:focus, input[type="text"]:focus, input[type="number"]:focus { border-color: var(--accent); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 18px;
  width: 100%;
  margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px; background: #2b2f3a; border-radius: 3px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px; margin-top: -5px;
  background: var(--text); border-radius: 50%; cursor: pointer;
}
input[type="range"]::-moz-range-track { height: 3px; background: #2b2f3a; border-radius: 3px; }
input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border: 0; background: var(--text); border-radius: 50%; cursor: pointer;
}

input[type="color"] {
  grid-column: 2 / -1;
  width: 100%; height: 26px; padding: 0;
  background: transparent; border: 1px solid var(--line);
  border-radius: 6px; cursor: pointer;
}

input[type="checkbox"] {
  appearance: none;
  width: 32px; height: 18px; border-radius: 10px;
  background: #2b2f3a; position: relative; cursor: pointer;
  transition: background .15s;
}
input[type="checkbox"]::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%; background: #8b91a1;
  transition: transform .15s, background .15s;
}
input[type="checkbox"]:checked { background: var(--accent); }
input[type="checkbox"]:checked::after { transform: translateX(14px); background: #fff; }

/* Segmented control */
.seg {
  grid-column: 2 / -1;
  display: flex;
  gap: 3px;
  background: #1b1e26;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px;
}
.seg.wide { grid-column: 1 / -1; width: 100%; margin-bottom: 12px; }
.seg.wrap { flex-wrap: wrap; }
.seg button {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: #2b3040; color: var(--text); }

/* Gradient swatches */
.swatches {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
  margin-bottom: 12px;
}
.swatches button {
  aspect-ratio: 1;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,.09);
  cursor: pointer;
  padding: 0;
  outline: 0;
}
.swatches button.on { box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 3.5px var(--accent); }

/* Buttons */
button.primary, button.ghost {
  font: inherit;
  font-size: 12px;
  border-radius: 6px;
  padding: 7px 10px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #1b1e26;
  color: var(--text);
  width: 100%;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #0d1020; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.ghost:hover { border-color: #3a3f4d; }
button.ghost.danger { color: var(--danger); }

.actions { display: grid; gap: 6px; margin-top: 12px; }

.hint { color: #6b7080; font-size: 11px; line-height: 1.45; margin: 10px 0 0; }

/* ---------- Stage ---------- */

#stage {
  position: relative;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 40px;
  background:
    radial-gradient(circle at 1px 1px, #1c1f28 1px, transparent 0) 0 0 / 22px 22px,
    var(--bg);
}

/* max-content keeps the grid from squeezing the frame when a code line is
   wider than the stage - the preview scales down instead of clipping. */
#scaler { width: max-content; transform-origin: center center; will-change: transform; }

#zoomBadge {
  position: fixed;
  right: 16px; bottom: 14px;
  font-size: 11px;
  color: var(--muted);
  background: rgba(20,22,28,.86);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 8px;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

#dropHint {
  position: absolute;
  inset: 16px;
  border: 2px dashed var(--accent);
  border-radius: 14px;
  display: none;
  place-items: center;
  color: var(--accent);
  font-size: 14px;
  background: rgba(124,156,255,.07);
  pointer-events: none;
  z-index: 20;
}
#stage.dragging #dropHint { display: grid; }

#toast {
  position: fixed;
  left: 50%; bottom: 26px;
  transform: translate(-50%, 16px);
  background: #1e2129;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 100;
  max-width: 70vw;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#toast.err { border-color: var(--danger); color: #ffb4b4; }

#boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
  z-index: 200;
}
#boot.gone { display: none; }

@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  #sidebar { order: 2; border-right: 0; border-top: 1px solid var(--line); max-height: 46vh; }
  #stage { order: 1; padding: 20px; }
}
