:root {
  --glass: rgba(12, 14, 24, 0.62);
  --line: rgba(255, 255, 255, 0.09);
  --text: #e9ecf5;
  --muted: #8b90a6;
  --accent: #3cf2c3;
  --accent-2: #9b5de5;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #05060f;
  color: var(--text);
  font-family: "Space Grotesk", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

canvas#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.brand {
  position: fixed;
  top: 20px;
  left: 24px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  pointer-events: none;
  mix-blend-mode: difference;
}
.logo {
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.04em;
  color: #fff;
}
.tag {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: #fff;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  transition: opacity 0.6s;
}
.loading.done { opacity: 0; pointer-events: none; }
.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- panel ---------- */
.panel {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 272px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  transition: width 0.3s ease, transform 0.3s ease;
}
.panel.collapsed { width: 44px; }
.panel.collapsed .panel-body { display: none; }

.toggle {
  align-self: flex-end;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
}
.toggle:hover { color: var(--text); }

.panel-body {
  padding: 0 18px 16px;
  overflow-y: auto;
  scrollbar-width: thin;
}

section { margin-bottom: 18px; }

h3 {
  margin: 0 0 10px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.palettes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.swatch {
  position: relative;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--line);
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  transition: transform 0.15s;
}
.swatch:hover { transform: translateY(-2px); }
.swatch.active { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatch span {
  position: absolute;
  inset: auto 0 0 0;
  height: 40%;
  display: flex;
}
.swatch span i { flex: 1; }

.sliders label {
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: 4px;
  font-size: 13px;
  margin-bottom: 10px;
}
.sliders output {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--accent);
}
input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  outline: none;
  opacity: 0.85;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(60, 242, 195, 0.2);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.seg button {
  background: none;
  border: 0;
  color: var(--muted);
  padding: 8px 0;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: rgba(60, 242, 195, 0.14); color: var(--text); }

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.actions button {
  padding: 9px 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.actions button:hover { background: rgba(255, 255, 255, 0.09); border-color: rgba(255, 255, 255, 0.2); }
.actions #reseed {
  grid-column: 1 / -1;
  background: linear-gradient(90deg, rgba(60, 242, 195, 0.22), rgba(155, 93, 229, 0.22));
}

.meta {
  display: flex;
  justify-content: space-between;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.meta b { color: var(--text); font-weight: 600; }

.hint {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.35);
  padding: 7px 14px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 1s;
}
kbd {
  font-family: inherit;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  padding: 0 4px;
}

.toast {
  position: fixed;
  left: 50%;
  top: 22px;
  transform: translate(-50%, -12px);
  opacity: 0;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

body.hide-ui .panel,
body.hide-ui .hint,
body.hide-ui .brand { opacity: 0; pointer-events: none; }

@media (max-width: 600px) {
  .panel {
    top: auto;
    bottom: 12px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: 55vh;
  }
  .panel.collapsed { left: auto; width: 44px; }
  .brand { left: 16px; top: 14px; }
  .tag { display: none; }
  .hint { display: none; }
}
