:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #0d1117;
  --bg-tertiary: #161b22;
  --green: #00ff41;
  --green-dim: #00cc33;
  --green-glow: rgba(0, 255, 65, 0.15);
  --amber: #ffb000;
  --red: #ff4444;
  --text: #c9d1d9;
  --text-dim: #8b949e;
  --border: #21262d;
}

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

body {
  background: var(--bg-primary);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  overflow-x: hidden;
}

/* CRT Scanline overlay */
.scanlines::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.12) 2px,
    rgba(0, 0, 0, 0.12) 4px
  );
  z-index: 2;
}

/* CRT glow for title */
.crt-glow {
  text-shadow:
    0 0 7px var(--green),
    0 0 10px var(--green),
    0 0 21px var(--green),
    0 0 42px rgba(0, 255, 65, 0.3);
}

.crt-glow-subtle {
  text-shadow:
    0 0 4px var(--green),
    0 0 8px rgba(0, 255, 65, 0.3);
}

/* Compile button glow */
.compile-btn {
  position: relative;
  transition: all 0.3s ease;
  box-shadow: 0 0 15px rgba(0, 255, 65, 0.2), inset 0 0 15px rgba(0, 255, 65, 0.05);
}

.compile-btn:hover {
  box-shadow: 0 0 30px rgba(0, 255, 65, 0.4), inset 0 0 20px rgba(0, 255, 65, 0.1);
  transform: scale(1.02);
}

.compile-btn:active {
  transform: scale(0.98);
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 15px rgba(0, 255, 65, 0.2); }
  50% { box-shadow: 0 0 25px rgba(0, 255, 65, 0.4); }
}

.compile-btn-idle {
  animation: pulse-glow 2s infinite;
}

/* Processing animation */
@keyframes compile-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.compiling-icon {
  display: inline-block;
  animation: compile-spin 0.6s linear infinite;
}

/* Editor line numbers */
.line-numbers {
  counter-reset: line;
  padding: 12px 0;
}

.line-numbers span {
  counter-increment: line;
  display: block;
  line-height: 1.5;
  font-size: 12px;
  color: var(--text-dim);
  text-align: right;
  padding-right: 12px;
  user-select: none;
}

.line-numbers span::before {
  content: counter(line);
}

/* Textarea styling */
.code-editor {
  background: transparent;
  color: var(--text);
  caret-color: var(--green);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: none;
  outline: none;
  border: none;
  width: 100%;
  padding: 12px;
  tab-size: 2;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}

.code-editor::selection {
  background: rgba(0, 255, 65, 0.2);
}

/* Highlighted code overlay */
.code-highlight {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.5;
  padding: 12px;
  white-space: pre;
  overflow-wrap: normal;
  pointer-events: none;
}

/* Syntax highlighting colors */
.syn-keyword { color: #ff7b72; }
.syn-type { color: #79c0ff; }
.syn-string { color: #a5d6ff; }
.syn-number { color: #d2a8ff; }
.syn-comment { color: #8b949e; font-style: italic; }
.syn-func { color: #d2a8ff; }
.syn-param { color: #ffa657; }
.syn-instruction { color: var(--green); }
.syn-register { color: var(--amber); }
.syn-label { color: #ff7b72; }
.syn-directive { color: #79c0ff; }

/* Output code block */
.output-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.5;
  padding: 12px;
  white-space: pre;
  overflow: auto;
  min-height: 200px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

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

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

/* Console styling */
.console-line {
  font-size: 12px;
  line-height: 1.6;
  padding: 2px 12px;
  font-family: 'JetBrains Mono', monospace;
}

/* Tab styling */
.tab-btn {
  transition: all 0.2s ease;
  position: relative;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

/* Toolbar button */
.toolbar-btn {
  transition: all 0.15s ease;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  cursor: pointer;
}

.toolbar-btn:hover {
  border-color: var(--green);
  color: var(--green);
  background: rgba(0, 255, 65, 0.05);
}

/* Animated Z80 chip */
@keyframes chip-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.chip-icon {
  animation: chip-pulse 3s ease-in-out infinite;
}

/* Reference sidebar */
.reference-sidebar {
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Keyboard shortcuts overlay */
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-enter {
  animation: fadeIn 0.2s ease;
}

/* Status bar blink */
@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.blink {
  animation: blink-cursor 1s step-end infinite;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .code-editor, .code-highlight, .output-code {
    font-size: 11px;
  }
  
  .line-numbers span {
    font-size: 10px;
  }
}

/* Flicker effect on compile */
@keyframes screen-flicker {
  0% { opacity: 1; }
  5% { opacity: 0.8; }
  10% { opacity: 1; }
  15% { opacity: 0.9; }
  20% { opacity: 1; }
}

.flicker {
  animation: screen-flicker 0.3s ease;
}

/* Hover highlight for line correspondence */
.line-highlight {
  background: rgba(0, 255, 65, 0.08);
}