:root {
  --phosphor: #ffb000;
  --phosphor-dim: #664800;
  --phosphor-glow: rgba(255, 176, 0, 0.5);
  --bg: #0a0a0a;
  --bg-panel: #111111;
  --bg-bezel: #1a1a1a;
  --border: #2a2a2a;
}

.green-mode {
  --phosphor: #33ff33;
  --phosphor-dim: #0a5c0a;
  --phosphor-glow: rgba(51, 255, 51, 0.5);
}

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

body {
  background: var(--bg);
  color: var(--phosphor);
  font-family: 'Share Tech Mono', 'Courier New', monospace;
  overflow-x: hidden;
  min-height: 100vh;
}

/* CRT Scanline Overlay */
.crt-overlay {
  pointer-events: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.03) 0px,
    rgba(0,0,0,0.03) 1px,
    transparent 1px,
    transparent 3px
  );
}

.crt-glow {
  text-shadow: 0 0 4px var(--phosphor-glow), 0 0 8px var(--phosphor-glow);
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03), 0 2px 8px rgba(0,0,0,0.5);
}

.bezel {
  background: linear-gradient(180deg, #222 0%, #181818 50%, #111 100%);
  border: 1px solid #333;
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 4px 12px rgba(0,0,0,0.6);
}

/* LED Indicators */
.led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transition: all 0.15s ease;
  border: 1px solid rgba(255,255,255,0.1);
}

.led-on {
  background: var(--phosphor);
  box-shadow: 0 0 6px var(--phosphor-glow), 0 0 12px var(--phosphor-glow);
}

.led-off {
  background: #1a1a1a;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
}

.led-red-on {
  background: #ff3333;
  box-shadow: 0 0 6px rgba(255,51,51,0.6), 0 0 12px rgba(255,51,51,0.3);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 48px;
  height: 24px;
  background: #222;
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid #444;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
  transition: background 0.3s;
}

.toggle-switch.on {
  background: #2a2a2a;
}

.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(180deg, #888 0%, #555 100%);
  border: 1px solid #666;
  transition: left 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.toggle-switch.on .toggle-knob {
  left: 26px;
}

/* Push Button */
.push-btn {
  padding: 4px 12px;
  background: linear-gradient(180deg, #3a3a3a 0%, #222 100%);
  border: 1px solid #555;
  border-radius: 3px;
  color: var(--phosphor);
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.05);
  transition: all 0.1s;
  user-select: none;
}

.push-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.push-btn:hover {
  border-color: var(--phosphor-dim);
}

.push-btn-red {
  background: linear-gradient(180deg, #5a1a1a 0%, #3a0a0a 100%);
  border-color: #882222;
  color: #ff4444;
}

.push-btn-red:hover {
  border-color: #ff4444;
}

/* Register flash */
@keyframes regFlash {
  0% { background: var(--phosphor); color: #000; }
  100% { background: transparent; color: var(--phosphor); }
}

.reg-flash {
  animation: regFlash 0.4s ease-out;
}

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

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

/* PC pulse */
@keyframes pcPulse {
  0%, 100% { border-color: var(--phosphor-dim); }
  50% { border-color: var(--phosphor); box-shadow: 0 0 8px var(--phosphor-glow); }
}

.pc-pulse {
  animation: pcPulse 1.5s ease-in-out infinite;
}

/* Manufacturer plate */
.mfg-plate {
  background: linear-gradient(180deg, #444 0%, #333 50%, #2a2a2a 100%);
  border: 1px solid #555;
  border-radius: 2px;
  padding: 2px 8px;
  font-size: 10px;
  letter-spacing: 3px;
  color: #888;
  text-shadow: 0 -1px 0 #111, 0 1px 0 #555;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 1px 3px rgba(0,0,0,0.5);
}

/* Memory view */
.mem-row {
  font-size: 12px;
  line-height: 1.6;
  padding: 0 4px;
  white-space: nowrap;
  transition: background 0.2s;
}

.mem-row:hover {
  background: rgba(255,176,0,0.05);
}

.mem-row-pc {
  background: rgba(255,176,0,0.12) !important;
  border-left: 2px solid var(--phosphor);
}

.green-mode .mem-row-pc {
  background: rgba(51,255,51,0.12) !important;
}

@keyframes memFlash {
  0% { background: var(--phosphor); color: #000; }
  100% { background: transparent; }
}

.mem-flash {
  animation: memFlash 0.5s ease-out;
}

/* TTY Console */
.tty-output {
  font-family: 'VT323', 'Share Tech Mono', monospace;
  font-size: 16px;
  line-height: 1.3;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Boot sequence */
@keyframes bootFlicker {
  0% { opacity: 0; }
  10% { opacity: 0.3; }
  20% { opacity: 0.1; }
  40% { opacity: 0.6; }
  60% { opacity: 0.3; }
  80% { opacity: 0.8; }
  100% { opacity: 1; }
}

.boot-flicker {
  animation: bootFlicker 1.2s ease-out;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #111; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #444; }

/* Help modal */
.modal-backdrop {
  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 {
  max-width: 700px;
  max-height: 80vh;
  overflow-y: auto;
  background: #111;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 24px;
  color: var(--phosphor);
}

/* Editable octal input */
.octal-input {
  background: transparent;
  border: 1px solid transparent;
  color: var(--phosphor);
  font-family: 'Share Tech Mono', monospace;
  font-size: inherit;
  padding: 0 2px;
  width: 60px;
  outline: none;
}

.octal-input:focus {
  border-color: var(--phosphor);
  background: rgba(255,176,0,0.08);
}

.green-mode .octal-input:focus {
  background: rgba(51,255,51,0.08);
}

/* Responsive */
@media (max-width: 768px) {
  .desktop-grid { flex-direction: column !important; }
  .panel { margin-bottom: 8px; }
}