[hidden] { display: none !important; }

:root {
  color-scheme: dark;
  --bg: #07051a;
  --panel: rgba(18, 13, 46, 0.74);
  --line: rgba(156, 136, 255, 0.28);
  --text: #eeeaff;
  --muted: #a39ed6;
  --a1: #7ef3ff;
  --a2: #ff5fd2;
}

body[data-theme="nebula"] {
  --bg: #07051a;
  --panel: rgba(18, 13, 46, 0.74);
  --line: rgba(156, 136, 255, 0.28);
  --text: #eeeaff;
  --muted: #a39ed6;
  --a1: #7ef3ff;
  --a2: #ff5fd2;
}

body[data-theme="synthwave"] {
  --bg: #14001f;
  --panel: rgba(34, 6, 50, 0.76);
  --line: rgba(255, 90, 200, 0.3);
  --text: #fff0fb;
  --muted: #d59bd6;
  --a1: #ff3ea5;
  --a2: #2ee6ff;
}

body[data-theme="ember"] {
  --bg: #120a06;
  --panel: rgba(40, 24, 16, 0.78);
  --line: rgba(255, 170, 110, 0.28);
  --text: #fff2e6;
  --muted: #cfa98c;
  --a1: #ff8a3d;
  --a2: #ffd166;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, "Segoe UI", Roboto, sans-serif;
}

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

#view:active { cursor: grabbing; }

.panel {
  position: fixed;
  top: 16px;
  z-index: 2;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 6px 16px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

#explore { left: 16px; width: 280px; }
#tune { right: 16px; width: 300px; }

h2 {
  margin: 14px 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--a1);
}

button {
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 10px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.1s, box-shadow 0.2s;
}

button:hover {
  border-color: var(--a1);
  background: rgba(255, 255, 255, 0.12);
}

button:active { transform: scale(0.97); }

button[aria-pressed="true"] {
  background: linear-gradient(120deg, var(--a1), var(--a2));
  color: #0b0820;
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 0 18px -4px var(--a1);
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--a1);
  outline-offset: 2px;
}

.fractal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.fractal-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}

.key {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  font-size: 11px;
  color: var(--muted);
}

.chips,
.btn-row,
.seg,
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.btn-row { margin-top: 8px; }
.btn-row button { flex: 1 1 auto; }

.seg button { flex: 1 1 auto; font-size: 13px; }

.swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.swatches button {
  height: 28px;
  padding: 0;
  border-radius: 8px;
}

.slider {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  margin: 10px 0 4px;
  font-size: 13px;
}

.slider output {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.slider input { grid-column: 1 / -1; }

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

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

.julia { margin-top: 6px; }

.pad {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  margin-top: 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 50% 50% / 50% 50%,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 50% 50% / 50% 50%,
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.4));
  touch-action: none;
  cursor: crosshair;
}

#padDot {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--a2);
  box-shadow: 0 0 12px var(--a2);
  pointer-events: none;
}

.notice {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: 420px;
  padding: 16px 20px;
  margin: 0;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  text-align: center;
}

#stats {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  margin: 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  font: 12px/1.5 ui-monospace, Consolas, monospace;
  pointer-events: none;
}

.show-ui {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 2;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

body.ui-hidden .panel,
body.ui-hidden .mobile-bar { display: none; }

.mobile-bar { display: none; }

@media (max-width: 820px) {
  .panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    max-height: 62vh;
    border-radius: 18px 18px 0 0;
    transform: translateY(110%);
    transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
    padding-bottom: 84px;
  }

  #explore,
  #tune {
    left: 0;
    right: 0;
    width: auto;
  }

  .panel.open { transform: none; }

  .mobile-bar {
    display: flex;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 3;
    gap: 8px;
  }

  .mobile-bar button {
    flex: 1;
    background: var(--panel);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  .show-ui { bottom: 76px; }
}
