:root {
  --bg: #07070d;
  --panel: rgba(18, 20, 30, 0.72);
  --border: rgba(120, 160, 255, 0.18);
  --cyan: #3ad0ff;
  --lime: #7dffb0;
  --mag: #ff5db1;
  --ink: #e8ecff;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(58,208,255,0.08), transparent),
    radial-gradient(1000px 700px at 110% 120%, rgba(255,93,177,0.08), transparent),
    var(--bg);
  color: var(--ink);
  font-family: 'Bricolage Grotesque', sans-serif;
  overflow: hidden;
}

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* ---------- Header ---------- */
#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.brand { font-weight: 800; font-size: 17px; letter-spacing: -0.5px; white-space: nowrap; }
.brand .ray {
  background: linear-gradient(90deg, var(--cyan), var(--mag));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  font-weight: 200;
}
.hud {
  display: flex; gap: 14px; margin-left: auto;
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  color: rgba(232,236,255,0.55);
}
.hud-item b { color: var(--lime); font-weight: 700; }

.quality {
  display: flex; gap: 4px; padding: 3px;
  background: rgba(0,0,0,0.35); border-radius: 10px;
  border: 1px solid var(--border);
}
.quality button {
  border: none; background: transparent; cursor: pointer;
  font-size: 16px; padding: 5px 9px; border-radius: 7px;
  transition: all 0.15s; filter: grayscale(0.6) opacity(0.6);
}
.quality button.active {
  background: rgba(58,208,255,0.18); filter: none;
  box-shadow: 0 0 12px rgba(58,208,255,0.3);
}

/* ---------- Stage ---------- */
#stage { position: relative; flex: 1; overflow: hidden; background: #05050a; }
#canvas {
  position: absolute; left: 0; top: 0;
  width: 100%; height: 100%;
  image-rendering: auto;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

#hint {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-family: 'JetBrains Mono', monospace; font-size: 13px;
  color: rgba(232,236,255,0.4); pointer-events: none;
  text-align: center; animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 0.3; } 50% { opacity: 0.7; } }

/* ---------- Toolbar ---------- */
#toolbar {
  position: absolute; left: 12px; top: 12px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 15;
}
.tool-group {
  display: flex; flex-direction: column; gap: 3px;
  padding: 5px; border-radius: 12px;
  background: var(--panel); backdrop-filter: blur(10px);
  border: 1px solid var(--border);
}
.tool-group.mat { transition: opacity 0.2s; }
.tool-group button {
  border: none; background: transparent; color: var(--ink);
  cursor: pointer; font-size: 17px; padding: 7px 9px; border-radius: 8px;
  transition: all 0.13s; line-height: 1;
}
.tool-group button:hover { background: rgba(255,255,255,0.08); transform: scale(1.08); }
.tool-group button.active {
  background: rgba(125,255,176,0.16);
  box-shadow: inset 0 0 0 1px rgba(125,255,176,0.4);
}
#colorPick {
  width: 34px; height: 30px; border: none; border-radius: 8px;
  background: transparent; cursor: pointer; padding: 0;
}
#colorPick::-webkit-color-swatch-wrapper { padding: 2px; }
#colorPick::-webkit-color-swatch { border: none; border-radius: 6px; }

/* ---------- Preset menu ---------- */
#presetMenu {
  position: absolute; left: 60px; bottom: 60px;
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px; border-radius: 12px;
  background: var(--panel); backdrop-filter: blur(14px);
  border: 1px solid var(--border); z-index: 25;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
#presetMenu.hidden { display: none; }
.pm-title {
  font-family: 'JetBrains Mono', monospace; font-size: 10px;
  color: rgba(232,236,255,0.5); padding: 2px 6px 4px; text-transform: uppercase;
  letter-spacing: 1px;
}
#presetMenu button {
  border: none; background: rgba(255,255,255,0.04); color: var(--ink);
  cursor: pointer; text-align: left; font-family: 'Bricolage Grotesque';
  font-size: 13px; padding: 8px 12px; border-radius: 8px; transition: all 0.12s;
}
#presetMenu button:hover { background: rgba(58,208,255,0.16); }

/* ---------- Status bar ---------- */
#statusbar {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 14px;
  background: var(--panel); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  z-index: 20;
}
.tier-badge {
  padding: 3px 9px; border-radius: 20px; font-weight: 700;
  background: rgba(58,208,255,0.15); color: var(--cyan);
  border: 1px solid rgba(58,208,255,0.3);
}
#ftGraph { border-radius: 4px; opacity: 0.9; }
.frame-info { color: rgba(232,236,255,0.55); }
.remix {
  margin-left: auto; color: rgba(232,236,255,0.4);
  text-decoration: none; font-size: 10px;
}
.remix:hover { color: var(--lime); }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 60px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: rgba(10,12,20,0.92); backdrop-filter: blur(14px);
  color: var(--ink); padding: 10px 18px; border-radius: 12px;
  border: 1px solid var(--border); font-size: 13px;
  opacity: 0; pointer-events: none; transition: all 0.3s; z-index: 50;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5); max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .brand { font-size: 14px; }
  .brand .ray { display: none; }
  .hud { gap: 8px; font-size: 9px; }
  #toolbar {
    left: 50%; top: auto; bottom: 10px; transform: translateX(-50%);
    flex-direction: row; flex-wrap: wrap; justify-content: center;
    max-width: 96vw;
  }
  .tool-group { flex-direction: row; }
  #presetMenu { left: 50%; transform: translateX(-50%); bottom: 90px; }
  #ftGraph { width: 70px; }
}
</parameter>