@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&display=swap');
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #1a1920; --surface: #252330; --border: #3a3848;
  --text: #8dd894; --text-dim: #5d4776; --glow: #5efdf7;
}
body {
  background: var(--bg); color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 100vh;
  overflow: hidden; padding: 8px;
}
#error {
  display: none; color: #f3a787; text-align: center;
  padding: 2em; max-width: 500px; line-height: 1.6;
}
#error h2 { color: #ff5dcc; margin-bottom: 0.5em; font-size: 1.1em; }
#app { display: flex; flex-direction: column; align-items: center; gap: 10px; }
#canvas-wrap {
  position: relative; border: 1px solid var(--border);
  border-radius: 6px; overflow: hidden;
  box-shadow: 0 0 30px rgba(94,253,247,0.06), 0 0 60px rgba(94,253,247,0.03),
    inset 0 0 20px rgba(0,0,0,0.3);
}
canvas {
  display: block;
  width: min(80vw, 80vh, 560px); height: min(80vw, 80vh, 560px);
  image-rendering: pixelated; image-rendering: crisp-edges;
  cursor: crosshair;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
#canvas-wrap::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.35) 100%);
  border-radius: 6px;
}

/* Error banner overlay on canvas */
#sim-error-banner {
  display: none;
  position: absolute; bottom: 8px; left: 8px; right: 8px;
  background: rgba(50, 20, 30, 0.92);
  border: 1px solid #ff5dcc;
  border-radius: 4px; padding: 8px 10px;
  font-size: 10px; color: #f3a787;
  line-height: 1.4; z-index: 10;
  max-height: 80px; overflow-y: auto;
}
#sim-error-banner .err-title {
  color: #ff5dcc; font-weight: 600; margin-bottom: 2px;
}

#toolbar {
  display: flex; flex-wrap: wrap; gap: 6px;
  align-items: center; justify-content: center; max-width: 560px;
}
.tool-group {
  display: flex; gap: 3px; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 5px; padding: 4px 6px;
}
.tool-group label {
  font-size: 10px; color: var(--text-dim); margin-right: 4px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.particle-btn {
  width: 28px; height: 28px; border: 2px solid transparent;
  border-radius: 4px; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: var(--surface);
}
.particle-btn:hover { border-color: var(--text-dim); }
.particle-btn.active {
  border-color: var(--glow);
  box-shadow: 0 0 8px rgba(94,253,247,0.3);
}
.particle-btn .swatch {
  display: block; width: 100%; height: 100%; border-radius: 2px;
}
.ctrl-btn {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-family: inherit; font-size: 11px;
  padding: 4px 10px; border-radius: 4px; cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.ctrl-btn:hover { border-color: var(--text); color: var(--glow); }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 70px; height: 4px; background: var(--border);
  border-radius: 2px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px;
  background: var(--text); border-radius: 50%; cursor: pointer;
}
/* Pipeline health indicators */
.health { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 3px; }
.health.ok { background: #8dd894; box-shadow: 0 0 4px #8dd894; }
.health.fail { background: #ff5dcc; box-shadow: 0 0 4px #ff5dcc; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

#status {
  font-size: 10px; color: var(--text-dim); text-align: center;
  min-height: 14px; line-height: 14px; max-width: 560px;
}
#pipeline-status {
  font-size: 9px; color: var(--text-dim); display: flex;
  gap: 10px; justify-content: center; align-items: center;
}
#debug-log {
  font-size: 9px; color: var(--text-dim); text-align: left;
  max-width: 560px; width: 100%; max-height: 80px; overflow-y: auto;
  padding: 4px; background: rgba(0,0,0,0.3); border-radius: 4px;
  margin-top: 4px; white-space: pre-wrap; word-break: break-all;
}
#debug-log.err { border-left: 2px solid #ff5dcc; }
#debug-log.ok { border-left: 2px solid #8dd894; }
#sim-error-banner .err-hint { margin-top: 4px; color: var(--text-dim); }
.particle-btn .swatch.eraser { border: 1px solid var(--border); }
.err-detail { margin-top: 1em; font-size: 11px; color: var(--text-dim); word-break: break-all; }
