:root {
  --bg-primary: #0a0e14;
  --bg-secondary: #0d1117;
  --bg-panel: #0f1419;
  --bg-input: #080b10;
  --border-color: #1a2030;
  --accent: #FFB000;
  --accent-glow: rgba(255, 176, 0, 0.15);
  --text-primary: #FFB000;
  --text-secondary: #b08c40;
  --text-dim: #5a5040;
  --text-code: #FFB000;
  --error: #FF4444;
  --warning: #FFAA00;
  --success: #44FF44;
  --cat-misc: #8888aa;
  --cat-jump: #ff8844;
  --cat-move: #44ccbb;
  --cat-string: #cc66aa;
  --cat-arith: #44cc66;
  --cat-group: #cccc44;
  --cat-prefix: #aa66cc;
}

[data-theme="green"] {
  --accent: #33FF33;
  --accent-glow: rgba(51, 255, 51, 0.12);
  --text-primary: #33FF33;
  --text-secondary: #22aa22;
  --text-dim: #1a661a;
  --text-code: #33FF33;
}

[data-theme="white"] {
  --bg-primary: #f0f0ec;
  --bg-secondary: #e8e8e4;
  --bg-panel: #ffffff;
  --bg-input: #fafafa;
  --border-color: #ccccbb;
  --accent: #2244aa;
  --accent-glow: rgba(34, 68, 170, 0.08);
  --text-primary: #222222;
  --text-secondary: #555555;
  --text-dim: #999999;
  --text-code: #1a1a2e;
}

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

body {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
}

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

.scanlines {
  pointer-events: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 4px
  );
}

.crt-curve {
  border-radius: 4px;
  box-shadow: inset 0 0 60px rgba(0,0,0,0.3);
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  box-shadow: 0 0 12px var(--accent-glow);
}

.panel-header {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  background: var(--bg-secondary);
  user-select: none;
}

textarea.code-editor {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg-input);
  color: var(--text-code);
  border: none;
  outline: none;
  resize: none;
  width: 100%;
  height: 100%;
  padding: 0;
  caret-color: var(--accent);
  tab-size: 4;
}

textarea.code-editor::selection {
  background: var(--accent);
  color: var(--bg-primary);
}

.line-numbers {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-dim);
  text-align: right;
  user-select: none;
  padding-right: 8px;
  min-width: 36px;
}

.line-numbers .error-line {
  background: rgba(255, 68, 68, 0.2);
  color: var(--error);
}

.hex-dump {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  line-height: 1.6;
}

.hex-addr {
  color: var(--text-dim);
}

.hex-byte-arith { color: var(--cat-arith); }
.hex-byte-move { color: var(--cat-move); }
.hex-byte-jump { color: var(--cat-jump); }
.hex-byte-string { color: var(--cat-string); }
.hex-byte-misc { color: var(--cat-misc); }
.hex-byte-group { color: var(--cat-group); }
.hex-byte-prefix { color: var(--cat-prefix); }
.hex-byte-default { color: var(--text-primary); }

.hex-ascii {
  color: var(--text-dim);
}

.console-output {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  line-height: 1.5;
}

.console-error { color: var(--error); }
.console-warn { color: var(--warning); }
.console-success { color: var(--success); }
.console-info { color: var(--text-dim); }

.btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:hover {
  background: var(--accent);
  color: var(--bg-primary);
  border-color: var(--accent);
}

.btn-compile {
  background: rgba(68, 255, 68, 0.1);
  border-color: #44FF44;
  color: #44FF44;
  text-shadow: 0 0 8px rgba(68, 255, 68, 0.3);
}

.btn-compile:hover {
  background: #44FF44;
  color: var(--bg-primary);
  box-shadow: 0 0 16px rgba(68, 255, 68, 0.4);
}

.tab-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn:hover {
  color: var(--text-secondary);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.blink {
  animation: blink 1s infinite;
}

@keyframes flash-green {
  0% { box-shadow: inset 0 0 30px rgba(68, 255, 68, 0.4); }
  100% { box-shadow: inset 0 0 0px rgba(68, 255, 68, 0); }
}

.flash-compile {
  animation: flash-green 0.6s ease-out;
}

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-panel);
  border: 1px solid var(--accent);
  box-shadow: 0 0 40px var(--accent-glow);
  max-width: 800px;
  max-height: 80vh;
  width: 90%;
  overflow-y: auto;
  padding: 24px;
}

.modal-content h2 {
  color: var(--accent);
  font-size: 18px;
  margin-bottom: 16px;
}

.modal-content h3 {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 16px 0 8px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 4px;
}

.modal-content p, .modal-content li {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.6;
}

.modal-content code {
  color: var(--accent);
  background: var(--bg-input);
  padding: 1px 5px;
  font-size: 12px;
}

.toast {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background: var(--bg-panel);
  border: 1px solid var(--accent);
  padding: 12px 20px;
  z-index: 2000;
  font-size: 13px;
  box-shadow: 0 0 20px var(--accent-glow);
  animation: slideInToast 0.3s ease-out;
}

@keyframes slideInToast {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  z-index: 100;
  min-width: 200px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
}

.dropdown-item:hover {
  background: var(--accent);
  color: var(--bg-primary);
}

.disasm-line {
  display: flex;
  gap: 12px;
  font-size: 13px;
  line-height: 1.6;
}

.disasm-addr { color: var(--text-dim); min-width: 48px; }
.disasm-bytes { color: var(--text-secondary); min-width: 100px; }
.disasm-mnemonic { color: var(--accent); }
.disasm-cycles { color: var(--text-dim); font-size: 11px; margin-left: auto; }

.ref-entry {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-color);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.1s;
}

.ref-entry:hover {
  background: var(--accent-glow);
}

.register-box {
  display: inline-block;
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  margin: 3px;
  font-size: 12px;
  min-width: 80px;
  text-align: center;
}

.register-label {
  color: var(--text-dim);
  font-size: 10px;
  display: block;
}

.register-value {
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

@media (max-width: 1200px) {
  .main-panels {
    flex-direction: column !important;
  }
  .main-panels > div {
    width: 100% !important;
    min-height: 250px;
  }
}

@media (max-width: 768px) {
  .toolbar-inner {
    flex-wrap: wrap;
    gap: 4px !important;
  }
  .btn {
    font-size: 11px;
    padding: 5px 8px;
  }
}