:root {
  --bg: #0a0c14;
  --bg-soft: #11141f;
  --panel: #141826;
  --panel-2: #1b2031;
  --line: #262c41;
  --line-soft: #1e2334;
  --text: #eef1f8;
  --text-dim: #9aa3bd;
  --text-faint: #6b7390;
  --accent: #818cf8;
  --accent-2: #a78bfa;
  --accent-ink: #0a0c14;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body { overflow-x: hidden; } /* backstop: never scroll the page sideways */

body {
  background:
    radial-gradient(1100px 600px at 80% -10%, rgba(129, 140, 248, 0.16), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(167, 139, 250, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px clamp(14px, 4vw, 32px) 48px;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  font-size: 30px;
  filter: drop-shadow(0 4px 10px rgba(129, 140, 248, 0.45));
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 19px; letter-spacing: -0.01em; }
.brand-sub { font-size: 12.5px; color: var(--text-faint); }

.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
}

.privacy-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.16);
}

/* ---------- Intro line ---------- */
.intro {
  margin: -6px 2px 20px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dim);
  max-width: 62ch;
  overflow-wrap: break-word;
}
.intro-accent { color: var(--accent); font-weight: 600; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 22px;
  align-items: start;
}

/* ---------- Stage ---------- */
.stage { min-width: 0; }

.canvas-wrap {
  position: relative;
  background:
    linear-gradient(var(--panel), var(--panel)) padding-box,
    linear-gradient(135deg, rgba(129, 140, 248, 0.5), rgba(167, 139, 250, 0.18)) border-box;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  /* checkerboard so transparent images read clearly */
  background-color: var(--panel);
}

#canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 9px;
  background:
    repeating-conic-gradient(#171b29 0% 25%, #1d2233 0% 50%) 50% / 26px 26px;
  touch-action: none;
  cursor: grab;
}
#canvas.dragging { cursor: grabbing; }

.drop-hint {
  position: absolute;
  inset: 14px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: rgba(10, 12, 20, 0.0);
  transition: background 0.15s ease;
}
.canvas-wrap.drag-over .drop-hint {
  background: rgba(129, 140, 248, 0.14);
  outline: 2px dashed rgba(129, 140, 248, 0.7);
  outline-offset: -10px;
}
.drop-hint-inner { text-align: center; color: var(--text-dim); }
.drop-emoji { font-size: 38px; margin-bottom: 6px; }
.drop-hint-inner p { margin: 0; font-weight: 600; font-size: 15px; }
.drop-hint-inner span { font-size: 12.5px; color: var(--text-faint); }

.stage-tip {
  margin: 12px 2px 0;
  font-size: 12.5px;
  color: var(--text-faint);
  text-align: center;
}

/* ---------- Panel ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 18px 18px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 18px;
}

.group { padding: 16px 0; border-bottom: 1px solid var(--line-soft); }
.group:last-of-type { border-bottom: none; }

.group-label {
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 12px;
}

/* Upload */
.upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 13px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 14.5px;
  cursor: pointer;
  border: none;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.upload-btn:hover { filter: brightness(1.06); }
.upload-btn:active { transform: translateY(1px); }
.upload-icon { font-size: 16px; }

.starter-label {
  margin: 14px 0 9px;
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
}

.starters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
}
.starter {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  transition: transform 0.08s ease, border-color 0.15s ease;
}
.starter:hover { transform: translateY(-2px); border-color: var(--accent); }
.starter.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(129,140,248,0.35); }
.starter canvas, .starter > div { width: 100%; height: 100%; display: block; }

/* Fields */
.field { margin-bottom: 9px; }
.field:last-child { margin-bottom: 0; }
input[type="text"] {
  width: 100%;
  padding: 11px 13px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
input[type="text"]::placeholder { color: var(--text-faint); font-weight: 600; }
input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.22);
}

/* Control rows */
.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}
.control-row label { font-size: 13.5px; color: var(--text-dim); white-space: nowrap; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: var(--line);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid var(--panel);
  box-shadow: 0 0 0 1px var(--accent);
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid var(--panel);
}

.swatches { display: inline-flex; gap: 7px; }
.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  cursor: pointer;
  padding: 0;
  transition: transform 0.08s ease;
}
.swatch:hover { transform: scale(1.12); }
.swatch.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(129,140,248,0.4); }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* Export */
.export-group { display: grid; gap: 9px; }
.btn {
  width: 100%;
  padding: 13px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.08s ease, filter 0.15s ease, background 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
}
.btn-ghost:hover { background: #222a3d; }
.btn-quiet { color: var(--text-faint); font-weight: 600; }

.made-with {
  margin: 16px 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-faint);
  text-align: center;
  overflow-wrap: break-word;
}
.made-with a { color: var(--accent); text-decoration: none; font-weight: 600; }
.made-with a:hover { text-decoration: underline; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Mobile ---------- */
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .panel { position: static; }
  .privacy-pill { font-size: 0; gap: 0; padding: 9px; }
  .privacy-pill .dot { margin: 0; }
}
@media (max-width: 460px) {
  .brand-sub { display: none; }
}
