* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #1a1b26;
  --surface: #24283b;
  --border: #3b4261;
  --text: #c0caf5;
  --accent: #7aa2f7;
  --green: #9ece6a;
  --red: #f7768e;
  --yellow: #e0af68;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 18px;
  color: var(--accent);
  font-weight: 600;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  padding: 6px 16px;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-run { background: var(--green); color: #1a1b26; }
.btn-stop { background: var(--red); color: #1a1b26; }
.btn-clear { background: var(--border); color: var(--text); }

.auto-run-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.editor-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}

.display-panel {
  width: 340px;
  min-width: 340px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  overflow-y: auto;
}

.panel-header {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #565f89;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* CodeMirror overrides */
.CodeMirror {
  flex: 1;
  height: 100%;
  font-size: 14px;
  line-height: 1.5;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
}

.canvas-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  background: #0f0f14;
}

#tft-canvas {
  border: 2px solid var(--border);
  image-rendering: pixelated;
  background: #000;
}

.display-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-size: 12px;
  color: #565f89;
}

#display-preset {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px 6px;
  font-size: 12px;
}

.console-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  min-height: 120px;
}

.console-output {
  flex: 1;
  padding: 8px 12px;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.6;
  overflow-y: auto;
  background: var(--bg);
}

.console-output .log { color: var(--text); }
.console-output .error { color: var(--red); }
.console-output .warn { color: var(--yellow); }
.console-output .info { color: var(--accent); }

@media (max-width: 800px) {
  main { flex-direction: column; }
  .display-panel { width: 100%; min-width: unset; }
  .editor-panel { border-right: none; border-bottom: 1px solid var(--border); max-height: 50vh; }
}
