:root {
  color-scheme: dark;
  --bg: #14161c;
  --panel: #1c1f27;
  --border: #2c3140;
  --text: #e4e6eb;
  --muted: #8b93a7;
  --accent: #7dd3fc;
  --error-bg: #3b1a1a;
  --error-border: #a33;
  --error-text: #ffb3b3;
}

* { box-sizing: border-box; }

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

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

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

header h1 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  margin-right: auto;
  color: var(--text);
}

button {
  background: #2a2f3d;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}

button:hover { background: #363c4d; }
button:active { background: #454c62; }
button.primary { background: #1d4e63; border-color: #2b6d89; }
button.primary:hover { background: #24607a; }

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

#blocklyDiv {
  flex: 1 1 55%;
  min-width: 0;
  border-right: 1px solid var(--border);
}

#previewPane {
  flex: 1 1 45%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--panel);
}

#canvasWrap {
  flex: 1 1 60%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  min-height: 0;
  padding: 8px;
}

#hydraCanvas {
  max-width: 100%;
  max-height: 100%;
  width: 640px;
  height: 360px;
  background: #000;
  border: 1px solid var(--border);
}

#codeWrap {
  flex: 1 1 40%;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  min-height: 0;
}

#codeWrap h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 10px 16px 4px;
}

#codeOutput {
  flex: 1;
  margin: 0 16px 16px;
  padding: 10px;
  overflow: auto;
  background: #0e1016;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: 12px/1.5 "SF Mono", Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c8e6ff;
}

#errorBox {
  margin: 0 16px 12px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
  font: 12px/1.4 monospace;
  white-space: pre-wrap;
  display: none;
}

#errorBox.visible { display: block; }

@media (max-width: 900px) {
  main { flex-direction: column; }
  #blocklyDiv { flex: 1 1 50vh; border-right: none; border-bottom: 1px solid var(--border); }
  #previewPane { flex: 1 1 50vh; }
}
