:root {
  --bg: #0a0e0a;
  --bg-panel: #0d140d;
  --phosphor: #33ff66;
  --phosphor-dim: #1f8f3d;
  --amber: #ffb000;
  --amber-dim: #7a5400;
  --border: #1c331c;
  --err: #ff4a4a;
  --font: 'JetBrains Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--phosphor);
  font-family: var(--font);
  font-size: 14px;
  min-height: 100vh;
}

/* CRT scanline atmosphere */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0) 0px,
    rgba(0,0,0,0) 2px,
    rgba(0,0,0,0.12) 3px,
    rgba(0,0,0,0) 4px
  );
  opacity: 0.5;
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  background: radial-gradient(ellipse at center, rgba(51,255,102,0.04) 0%, rgba(0,0,0,0.35) 100%);
}

.app-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
  position: relative;
  z-index: 1;
}

/* HEADER */
.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 18px;
  background: linear-gradient(180deg, #0f1a0f, #0a0e0a);
  box-shadow: 0 0 24px rgba(51,255,102,0.08) inset;
  margin-bottom: 14px;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.app-header h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--amber);
  text-shadow: 0 0 12px rgba(255,176,0,0.6);
}
.header-sub {
  color: var(--phosphor-dim);
  font-style: italic;
  font-weight: 300;
  flex: 1;
  min-width: 140px;
}
.cycle-counter {
  color: var(--phosphor);
  font-weight: 700;
  font-size: 12px;
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 5px;
  background: #050805;
  text-shadow: 0 0 8px rgba(51,255,102,0.5);
  cursor: help;
}
.power-led {
  width: 12px; height: 12px; border-radius: 50%;
  background: #331000;
  box-shadow: 0 0 4px rgba(255,80,0,0.4);
}
.power-led.on {
  background: #ff3b00;
  box-shadow: 0 0 12px 2px rgba(255,80,0,0.9);
  animation: pulse 1s infinite;
}
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.4;} }

/* GRID LAYOUTS */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 14px;
  margin-bottom: 14px;
}
.bottom-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

/* BEZEL PANELS */
.bezel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel);
  box-shadow: 0 0 0 1px #000 inset, 0 4px 16px rgba(0,0,0,0.5);
  overflow: hidden;
}
.panel-title {
  background: linear-gradient(180deg,#122412,#0a120a);
  color: var(--amber);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
}
.panel-body { padding: 12px; }

/* TOOLBAR */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; align-items: center; }
.toolbar-sub { margin-bottom: 10px; }
.btn {
  font-family: var(--font);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--phosphor);
  background: #0e1a0e;
  border: 1px solid var(--phosphor-dim);
  border-radius: 6px;
  padding: 9px 14px;
  cursor: pointer;
  transition: all 0.12s;
  text-shadow: 0 0 6px rgba(51,255,102,0.4);
}
.btn:hover {
  background: #16281 6;
  background: #16281a;
  box-shadow: 0 0 14px rgba(51,255,102,0.35);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(1px); }
.btn-run { color: var(--amber); border-color: var(--amber-dim); text-shadow: 0 0 6px rgba(255,176,0,0.5); }
.btn-run:hover { box-shadow: 0 0 14px rgba(255,176,0,0.4); }
.btn-reset { color: var(--err); border-color: #6a1c1c; text-shadow: 0 0 6px rgba(255,74,74,0.4); }
.btn-reset:hover { box-shadow: 0 0 14px rgba(255,74,74,0.3); }

.ex-select {
  font-family: var(--font);
  font-size: 12px;
  background: #0e1a0e;
  color: var(--phosphor);
  border: 1px solid var(--phosphor-dim);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
}
.speed-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; letter-spacing: 1px; color: var(--phosphor-dim);
}
.speed-label input { accent-color: var(--phosphor); cursor: pointer; }

/* EDITOR */
.editor-wrap {
  display: flex;
  min-height: 340px;
  max-height: 480px;
}
.gutter {
  background: #060a06;
  color: var(--phosphor-dim);
  padding: 12px 8px;
  text-align: right;
  user-select: none;
  font-size: 13px;
  line-height: 1.5;
  border-right: 1px solid var(--border);
  overflow: hidden;
  min-width: 44px;
}
.gutter-line { height: 19.5px; }
.gutter-line.cur { color: var(--amber); font-weight: 700; text-shadow: 0 0 6px var(--amber); }
.editor {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: var(--phosphor);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  padding: 12px;
  white-space: pre;
  overflow: auto;
  text-shadow: 0 0 4px rgba(51,255,102,0.3);
}
.editor::placeholder { color: var(--phosphor-dim); }

/* REGISTERS */
.reg-grid { display: flex; flex-direction: column; gap: 8px; }
.regbox {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 8px 12px;
  background: #060a06;
  transition: background 0.15s;
}
.regbox.flash {
  background: #1a3a1a;
  box-shadow: 0 0 10px rgba(51,255,102,0.4);
}
.reg-label { color: var(--amber); font-weight: 700; letter-spacing: 1px; }
.reg-val {
  color: var(--phosphor);
  font-weight: 700;
  font-size: 16px;
  text-shadow: 0 0 8px rgba(51,255,102,0.5);
}

/* FLAGS */
.flags { display: flex; gap: 6px; justify-content: space-between; }
.flag {
  flex: 1;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 0;
  color: #244024;
  font-weight: 700;
  background: #060a06;
  transition: all 0.15s;
}
.flag.lit {
  color: var(--amber);
  border-color: var(--amber-dim);
  text-shadow: 0 0 10px var(--amber);
  box-shadow: 0 0 8px rgba(255,176,0,0.25) inset;
}

/* MEMORY */
.mem-controls { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.mini-btn {
  font-family: var(--font);
  font-size: 11px;
  color: var(--phosphor);
  background: #0e1a0e;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
}
.mini-btn:hover { background: #16281a; }
.mem-jump {
  font-family: var(--font);
  font-size: 12px;
  width: 70px;
  background: #060a06;
  color: var(--amber);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  text-align: center;
}
.mem-dump { font-size: 12px; line-height: 1.7; overflow-x: auto; }
.mem-row { display: flex; gap: 10px; white-space: nowrap; }
.mem-addr { color: var(--amber); font-weight: 700; }
.mem-cells { display: inline-flex; gap: 5px; }
.mem-cell { color: #2a4a2a; }
.mem-cell.mem-nonzero { color: var(--phosphor); }
.mem-cell.mem-pc {
  background: var(--amber);
  color: #000;
  border-radius: 2px;
  padding: 0 2px;
  font-weight: 700;
}

/* CONSOLE */
.console {
  height: 200px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.5;
  background: #050805;
  border-radius: 4px;
  padding: 8px;
}
.console-line { color: var(--phosphor); text-shadow: 0 0 4px rgba(51,255,102,0.3); }
.console-line.err { color: var(--err); text-shadow: 0 0 6px rgba(255,74,74,0.4); }
.blink-cursor { color: var(--phosphor); animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* MACHINE CODE */
.machine-code { height: 200px; overflow-y: auto; font-size: 12px; line-height: 1.6; }
.mc-line { display: flex; gap: 10px; padding: 1px 4px; border-radius: 3px; }
.mc-line.cur { background: #1a3a1a; box-shadow: 0 0 8px rgba(51,255,102,0.2); }
.mc-addr { color: var(--amber); width: 40px; }
.mc-bytes { color: var(--phosphor); width: 78px; }
.mc-src { color: var(--phosphor-dim); }
.dim { color: var(--phosphor-dim); font-style: italic; }

/* FOOTER */
.app-footer {
  text-align: center;
  color: var(--phosphor-dim);
  font-size: 12px;
  padding: 12px;
}
.app-footer a { color: var(--amber); text-decoration: none; }
.app-footer a:hover { text-shadow: 0 0 8px var(--amber); }

/* RESPONSIVE */
@media (max-width: 900px) {
  .main-grid { grid-template-columns: 1fr; }
  .bottom-grid { grid-template-columns: 1fr; }
  .reg-grid { flex-direction: row; flex-wrap: wrap; }
  .regbox { flex: 1 1 40%; }
  .app-header h1 { font-size: 20px; letter-spacing: 2px; }
  .cycle-counter { width: 100%; text-align: center; }
}
@media (max-width: 500px) {
  body { font-size: 13px; }
  .editor-wrap { min-height: 260px; }
  .btn { padding: 8px 10px; font-size: 11px; }
}