* { box-sizing: border-box; }

:root {
  --bg: #111114;
  --panel: #1b1b20;
  --line: #2c2c33;
  --text: #ececf1;
  --muted: #8b8b96;
  --accent: #ffffff;
  --danger: #e5484d;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

body { display: flex; flex-direction: column; }

header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 6px; }
h1 { font-size: 18px; margin: 0; letter-spacing: 0.4px; }
.tagline { margin: 0; color: var(--muted); font-size: 13px; }

main {
  flex: 1;
  display: flex;
  min-height: 0;
}

.panel {
  width: 250px;
  flex: none;
  padding: 16px;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel section h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin: 0 0 10px;
}

.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.tool {
  padding: 9px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #232329;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.tool:hover { border-color: #4a4a55; }
.tool.active { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 600; }

.slider { display: block; margin-bottom: 12px; font-size: 13px; }
.slider span { display: flex; justify-content: space-between; margin-bottom: 4px; color: var(--muted); }
.slider output { color: var(--text); font-variant-numeric: tabular-nums; }
.slider input[type="range"] { width: 100%; accent-color: #fff; }

.check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 12px; color: var(--muted); }
.check input { accent-color: #fff; width: 15px; height: 15px; }

.select { display: block; font-size: 13px; margin-bottom: 12px; }
.select span { display: block; color: var(--muted); margin-bottom: 4px; }
select {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #232329;
  color: var(--text);
  font-size: 13px;
}

.row { display: flex; gap: 8px; margin-bottom: 8px; }
.row .btn { flex: 1; }

.btn {
  width: 100%;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #232329;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 8px;
}
.btn:hover { border-color: #4a4a55; }
.btn.primary { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 600; }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }

.hint { font-size: 12px; color: var(--muted); line-height: 1.6; margin: auto 0 0; padding-top: 12px; }

.stage {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
  min-width: 0;
}

.canvas-wrap {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1;
  width: min(100%, 80vh);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.55);
  overflow: hidden;
  touch-action: none;
  cursor: crosshair;
}

.canvas-wrap[data-bg="white"] { background: #fff; }
.canvas-wrap[data-bg="black"] { background: #000; }
.canvas-wrap[data-bg="transparent"] {
  background: repeating-conic-gradient(#3a3a41 0 25%, #26262c 0 50%) 0 0 / 16px 16px;
}

.canvas-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#blob { filter: url(#goo); }

@media (max-width: 720px) {
  main { flex-direction: column; }
  .panel { width: 100%; border-right: none; border-bottom: 1px solid var(--line); }
}
