:root {
  --bg: #0a0a0a;
  --bg2: #111111;
  --bg3: #1a1a1a;
  --fg: #00ff41;
  --fg-dim: #00aa2a;
  --fg-bright: #33ff66;
  --accent: #00ff41;
  --error: #ff3333;
  --warning: #ffaa00;
  --border: #003300;
  --gutter-bg: #050505;
  --highlight-line: rgba(0, 255, 65, 0.05);
  --selection: rgba(0, 255, 65, 0.15);
}

[data-theme="amber"] {
  --fg: #ffb000;
  --fg-dim: #aa7500;
  --fg-bright: #ffcc44;
  --accent: #ffb000;
  --border: #332200;
  --highlight-line: rgba(255, 176, 0, 0.05);
  --selection: rgba(255, 176, 0, 0.15);
}

[data-theme="blue"] {
  --bg: #0a0e1a;
  --bg2: #0f1525;
  --bg3: #151d30;
  --fg: #4fc3f7;
  --fg-dim: #2a7da8;
  --fg-bright: #80d8ff;
  --accent: #4fc3f7;
  --border: #0a2540;
  --gutter-bg: #070b14;
  --highlight-line: rgba(79, 195, 247, 0.05);
  --selection: rgba(79, 195, 247, 0.15);
}

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

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

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

/* Scanline overlay */
.scanlines::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  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
  );
}

/* Text glow */
.glow {
  text-shadow: 0 0 8px var(--fg), 0 0 2px var(--fg);
}

.glow-subtle {
  text-shadow: 0 0 4px var(--fg-dim);
}

/* Blink cursor */
@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.blink {
  animation: blink 1s infinite;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

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

/* Editor textarea */
.editor-textarea {
  background: transparent;
  color: transparent;
  caret-color: var(--fg);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  line-height: 20px;
  resize: none;
  outline: none;
  border: none;
  padding: 0;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  tab-size: 8;
  -moz-tab-size: 8;
}

.editor-textarea::selection {
  background: var(--selection);
  color: var(--fg);
}

.syntax-layer {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  line-height: 20px;
  white-space: pre;
  pointer-events: none;
}

/* Syntax colors */
.syn-mnemonic { color: #ff6b6b; font-weight: 600; }
.syn-register { color: #ffd93d; }
.syn-number { color: #6bcb77; }
.syn-label { color: #4d96ff; }
.syn-comment { color: #555555; font-style: italic; }
.syn-directive { color: #c084fc; font-weight: 500; }
.syn-string { color: #6bcb77; }
.syn-keyword { color: #ff922b; }
.syn-punct { color: var(--fg-dim); }
.syn-prefix { color: #ff6b9d; }
.syn-ptr { color: #ff922b; font-weight: 500; }

[data-theme="amber"] .syn-mnemonic { color: #ff6b6b; }
[data-theme="amber"] .syn-register { color: #ffd93d; }
[data-theme="amber"] .syn-number { color: #6bcb77; }
[data-theme="amber"] .syn-label { color: #4d96ff; }
[data-theme="amber"] .syn-directive { color: #c084fc; }

[data-theme="blue"] .syn-mnemonic { color: #ff6b6b; }
[data-theme="blue"] .syn-register { color: #ffd93d; }
[data-theme="blue"] .syn-number { color: #6bcb77; }
[data-theme="blue"] .syn-label { color: #80d8ff; }
[data-theme="blue"] .syn-directive { color: #c084fc; }

/* Button styles */
.retro-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--fg);
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 1px 1px 0 var(--border);
}

.retro-btn:hover {
  background: var(--bg3);
  border-color: var(--fg-dim);
  text-shadow: 0 0 4px var(--fg);
}

.retro-btn:active {
  box-shadow: none;
  transform: translate(1px, 1px);
}

.retro-btn-primary {
  border-color: var(--fg-dim);
  background: rgba(0, 255, 65, 0.1);
}

[data-theme="amber"] .retro-btn-primary {
  background: rgba(255, 176, 0, 0.1);
}

[data-theme="blue"] .retro-btn-primary {
  background: rgba(79, 195, 247, 0.1);
}

/* Hex dump */
.hex-byte {
  cursor: pointer;
  padding: 0 1px;
  border-radius: 1px;
  transition: background 0.15s;
}

.hex-byte:hover {
  background: var(--selection);
}

.hex-byte.highlighted {
  background: var(--selection);
  text-shadow: 0 0 6px var(--fg);
}

/* Opcode grid */
.opcode-cell {
  font-size: 9px;
  padding: 2px 3px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
}

.opcode-cell:hover {
  z-index: 10;
  border-color: var(--fg);
  box-shadow: 0 0 6px var(--fg-dim);
}

.cat-misc { background: rgba(128,128,128,0.15); }
.cat-jump { background: rgba(66,133,244,0.15); }
.cat-move { background: rgba(0,200,83,0.15); }
.cat-string { background: rgba(171,71,188,0.15); }
.cat-arith { background: rgba(255,152,0,0.15); }
.cat-group { background: rgba(255,235,59,0.12); }
.cat-prefix { background: rgba(255,64,129,0.15); }
.cat-empty { background: rgba(0,0,0,0.3); }

/* Error line */
.error-line {
  background: rgba(255, 0, 0, 0.1) !important;
  border-left: 2px solid #ff3333;
}

/* Toggle switch */
.toggle-track {
  width: 32px;
  height: 16px;
  border-radius: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
}

.toggle-track.active {
  background: rgba(0, 255, 65, 0.2);
  border-color: var(--fg-dim);
}

.toggle-knob {
  width: 12px;
  height: 12px;
  border-radius: 6px;
  background: var(--fg-dim);
  position: absolute;
  top: 1px;
  left: 1px;
  transition: all 0.2s;
}

.toggle-track.active .toggle-knob {
  left: 17px;
  background: var(--fg);
}

/* Responsive */
@media (max-width: 768px) {
  .main-panels {
    flex-direction: column !important;
  }
}

/* Fade in */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fade-in {
  animation: fadeIn 0.3s ease-in;
}

/* Select styling */
.retro-select {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--fg);
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M0 2l4 4 4-4z' fill='%2300aa2a'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  padding-right: 20px;
}

.retro-select option {
  background: var(--bg2);
  color: var(--fg);
}