:root {
  --panel-bg: #1a1a2e;
  --chassis-color: #2a2a2a;
  --ibm-blue: #0050D8;
  --text-primary: #d0d0d0;
  --text-dim: #707090;
  --monitor-phosphor: #FFFFFF;
  --accent: #33FF33;
  --border-color: #333355;
  --panel-header-bg: #12122a;
  --btn-bg: #2a2a40;
  --btn-hover: #3a3a55;
  --error-color: #ff4444;
  --warn-color: #ffaa00;
  --info-color: #44aaff;
}

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

body {
  background: #0d0d1a;
  color: var(--text-primary);
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.4;
  overflow-x: hidden;
}

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

/* HEADER */
header#header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: linear-gradient(180deg, #1e1e3a 0%, #14142a 100%);
  border-bottom: 2px solid var(--ibm-blue);
}

.ibm-logo {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 32px;
}
.ibm-logo .stripe {
  display: block;
  height: 3px;
  background: var(--ibm-blue);
  border-radius: 1px;
}

.header-text h1 {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 1px;
}
.header-text .subtitle {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 300;
}

#status-led {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.led {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid #555;
}
.led.stopped { background: #444; }
.led.running { background: #33ff33; box-shadow: 0 0 6px #33ff33; animation: blink-led 1s infinite; }
.led.halted { background: #ff4444; box-shadow: 0 0 6px #ff4444; }
.status-text { font-size: 11px; font-weight: 600; text-transform: uppercase; }

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

/* MAIN LAYOUT */
#main-layout {
  display: flex;
  flex: 1;
  gap: 0;
  overflow: hidden;
}

#display-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  min-width: 0;
}

/* MONITOR */
.monitor-bezel {
  background: #1c1c1c;
  border: 3px solid #333;
  border-radius: 16px;
  padding: 20px 24px 12px;
  box-shadow: 0 4px 30px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.05);
  max-width: 100%;
}
.monitor-inner {
  position: relative;
  background: #000;
  border: 2px solid #111;
  border-radius: 6px;
  overflow: hidden;
  line-height: 0;
}
#cga-display {
  width: 720px;
  height: 400px;
  max-width: 100%;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  display: block;
}
.scanlines {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(0,0,0,0.15) 1px,
    rgba(0,0,0,0.15) 2px
  );
  pointer-events: none;
}
.monitor-label {
  text-align: center;
  font-size: 9px;
  color: #555;
  margin-top: 6px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* CONTROL BAR */
#control-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  width: 100%;
  max-width: 750px;
}

.ctrl-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 14px;
  border: 1px solid #444;
  border-radius: 3px;
  background: var(--btn-bg);
  color: var(--text-primary);
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.15s;
}
.ctrl-btn:hover { background: var(--btn-hover); border-color: #666; }
.ctrl-btn:active { transform: translateY(1px); }
.ctrl-btn.small { padding: 4px 8px; }

.power-btn {
  background: #1a3a1a;
  border-color: #2a5a2a;
  color: #66ff66;
}
.power-btn.active {
  background: #2a5a2a;
  box-shadow: 0 0 8px rgba(51,255,51,0.3);
}
.reset-btn {
  background: #3a1a1a;
  border-color: #5a2a2a;
  color: #ff6666;
}

.speed-control, .phosphor-control, .audio-control {
  display: flex;
  align-items: center;
  gap: 4px;
}
.speed-control label, .phosphor-control label {
  font-size: 10px;
  color: var(--text-dim);
}
.speed-control select, .phosphor-control select {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  background: var(--btn-bg);
  color: var(--text-primary);
  border: 1px solid #444;
  border-radius: 2px;
  padding: 3px 6px;
}

.floppy-slot {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: #111;
  border: 1px solid #333;
  border-radius: 4px;
}
.drive-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
}
.drive-led {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #333;
}
.drive-led.active {
  background: #ff4444;
  box-shadow: 0 0 4px #ff4444;
}
.floppy-btn { font-size: 10px; padding: 4px 10px; }
.floppy-name { font-size: 9px; color: var(--text-dim); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.vol-slider {
  width: 60px;
  height: 4px;
  accent-color: var(--ibm-blue);
}

/* DEBUG SECTION */
#debug-section {
  width: 320px;
  min-width: 280px;
  overflow-y: auto;
  background: var(--panel-bg);
  border-left: 1px solid var(--border-color);
  max-height: calc(100vh - 60px);
}

.panel {
  border-bottom: 1px solid var(--border-color);
}
.panel-header {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: var(--panel-header-bg);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ibm-blue);
}
.panel-header:hover { background: #181838; }
.panel-body {
  padding: 8px 12px;
  max-height: 400px;
  overflow-y: auto;
}
.panel-body.collapsed {
  display: none;
}

/* REGISTERS */
.reg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 12px;
  font-size: 11px;
}
.reg-item {
  display: flex;
  justify-content: space-between;
}
.reg-name {
  color: var(--text-dim);
  font-weight: 500;
}
.reg-val {
  color: var(--accent);
  font-weight: 600;
}

.flags-display {
  margin-top: 6px;
  font-size: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.flag-item {
  padding: 1px 4px;
  border: 1px solid #333;
  border-radius: 2px;
  background: #111;
}
.flag-item.set {
  background: #1a3a1a;
  border-color: #2a5a2a;
  color: #66ff66;
}

/* DISASSEMBLY */
.disasm-list {
  font-size: 10px;
  line-height: 1.6;
}
.disasm-line {
  padding: 1px 4px;
  border-radius: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.disasm-line.current {
  background: rgba(51,255,51,0.15);
  color: var(--accent);
  font-weight: 600;
}
.disasm-addr { color: var(--text-dim); }
.disasm-bytes { color: #666; }
.disasm-mnem { color: var(--ibm-blue); font-weight: 500; }

/* PERFORMANCE */
.perf-display { font-size: 11px; }
.perf-item { display: flex; justify-content: space-between; padding: 1px 0; }
.perf-label { color: var(--text-dim); }
.perf-val { color: var(--accent); }

/* CHIP TABS */
.chip-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.chip-tab {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  padding: 3px 8px;
  border: 1px solid #333;
  border-radius: 2px;
  background: #111;
  color: var(--text-dim);
  cursor: pointer;
}
.chip-tab.active {
  background: var(--ibm-blue);
  color: #fff;
  border-color: var(--ibm-blue);
}
.chip-content {
  font-size: 10px;
  line-height: 1.5;
}
.chip-row {
  display: flex;
  justify-content: space-between;
}
.chip-label { color: var(--text-dim); }
.chip-val { color: var(--accent); }

/* MEMORY VIEWER */
.mem-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 10px;
}
.mem-input {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  width: 60px;
  padding: 2px 6px;
  background: #111;
  border: 1px solid #444;
  border-radius: 2px;
  color: var(--accent);
}
.mem-dump {
  font-size: 10px;
  line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
}

/* CONSOLE */
#console-section {
  border-top: 1px solid var(--border-color);
}
.console-filters {
  font-size: 9px;
  font-weight: 400;
  display: flex;
  gap: 8px;
}
.console-filters label {
  display: flex;
  align-items: center;
  gap: 3px;
  color: var(--text-dim);
  cursor: pointer;
}
.console-filters input { width: 12px; height: 12px; }
.console-log {
  max-height: 150px;
  overflow-y: auto;
  font-size: 10px;
  line-height: 1.5;
}
.log-line { padding: 0 4px; }
.log-error { color: var(--error-color); }
.log-warn { color: var(--warn-color); }
.log-info { color: var(--info-color); }

/* FOOTER */
footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 20px;
  font-size: 10px;
  color: var(--text-dim);
  background: var(--panel-header-bg);
  border-top: 1px solid var(--border-color);
}
footer a {
  color: var(--ibm-blue);
  text-decoration: none;
}
footer a:hover { text-decoration: underline; }

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

/* Responsive */
@media (max-width: 900px) {
  #main-layout { flex-direction: column; }
  #debug-section {
    width: 100%;
    min-width: unset;
    border-left: none;
    border-top: 1px solid var(--border-color);
    max-height: 300px;
  }
  #cga-display { width: 100%; height: auto; }
  .monitor-bezel { padding: 10px 12px 8px; }
  #control-bar { justify-content: center; }
}