:root {
  --bg: #0d0d1a;
  --bezel: #c8b88a;
  --bezel-dark: #9a8a62;
  --bezel-light: #ddd0a8;
  --panel-bg: #2a2a3e;
  --panel-ridge: #3a3a52;
  --ibm-blue: #4169E1;
  --cga-green: #00AA00;
  --led-red: #ff2222;
  --led-green: #22ff44;
  --led-amber: #ffaa00;
  --led-off: #333;
  --text-primary: #e0e0e0;
  --text-dim: #888;
  --mono-font: 'IBM Plex Mono', 'Courier New', monospace;
  --pixel-font: 'Press Start 2P', monospace;
  --accent: #4169E1;
}

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

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--mono-font);
  min-height: 100vh;
  overflow-x: hidden;
}

/* HEADER */
#header {
  background: linear-gradient(180deg, #1e1e32 0%, #14142a 100%);
  border-bottom: 2px solid #333;
  padding: 8px 16px;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 900px;
  margin: 0 auto;
}
.title {
  font-family: var(--pixel-font);
  font-size: 18px;
  color: var(--ibm-blue);
  text-shadow: 0 0 10px rgba(65,105,225,0.5);
}
.subtitle {
  font-size: 11px;
  color: var(--text-dim);
  flex: 1;
}
.icon-btn {
  background: none;
  border: 1px solid #444;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}
.icon-btn:hover { border-color: var(--ibm-blue); color: var(--text-primary); }

/* MAIN */
#main {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
}

/* MONITOR */
#monitor {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}
.monitor-bezel {
  background: linear-gradient(180deg, var(--bezel-light) 0%, var(--bezel) 30%, var(--bezel-dark) 100%);
  padding: 24px 28px 16px;
  border-radius: 16px;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.3),
    inset 0 -2px 0 rgba(0,0,0,0.3),
    0 8px 32px rgba(0,0,0,0.6),
    0 2px 8px rgba(0,0,0,0.4);
  position: relative;
}
.monitor-screen-frame {
  background: #000;
  border-radius: 8px;
  padding: 8px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.8);
}
#cga-display {
  display: block;
  width: 640px;
  height: 400px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  border-radius: 4px;
}
.scanlines {
  position: absolute;
  top: 8px; left: 8px; right: 8px; bottom: 8px;
  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;
  border-radius: 4px;
}
.scanlines.hidden { display: none; }
.screen-glare {
  position: absolute;
  top: 8px; left: 8px;
  width: 60%;
  height: 40%;
  background: radial-gradient(ellipse at 30% 30%, rgba(255,255,255,0.04) 0%, transparent 70%);
  pointer-events: none;
  border-radius: 4px;
}
.crt-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 10;
  border-radius: 8px;
  transition: opacity 0.8s;
}
.monitor-label {
  text-align: center;
  font-family: var(--mono-font);
  font-size: 10px;
  color: #555;
  margin-top: 8px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* Phosphor effects */
.monitor-screen-frame.green-phosphor #cga-display {
  filter: hue-rotate(90deg) saturate(2) brightness(0.9);
}
.monitor-screen-frame.green-phosphor {
  box-shadow: inset 0 0 30px rgba(0,170,0,0.1);
}
.monitor-screen-frame.amber-phosphor #cga-display {
  filter: sepia(1) saturate(2) brightness(0.9) hue-rotate(-10deg);
}
.monitor-screen-frame.amber-phosphor {
  box-shadow: inset 0 0 30px rgba(255,170,0,0.1);
}

/* CONTROL PANEL */
#control-panel {
  background: linear-gradient(180deg, #3a3a52 0%, #2a2a3e 100%);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  position: relative;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 4px 12px rgba(0,0,0,0.4);
}
.panel-ridges {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: repeating-linear-gradient(
    90deg,
    #444 0px, #444 2px, #333 2px, #333 4px
  );
  border-radius: 8px 8px 0 0;
}
.controls-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 4px;
}
.ctrl-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.led-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--led-off);
  border: 1px solid #222;
  transition: all 0.15s;
}
.led.on-green {
  background: var(--led-green);
  box-shadow: 0 0 6px var(--led-green), 0 0 12px rgba(34,255,68,0.3);
}
.led.on-red {
  background: var(--led-red);
  box-shadow: 0 0 6px var(--led-red);
}
.led.on-amber {
  background: var(--led-amber);
  box-shadow: 0 0 6px var(--led-amber), 0 0 12px rgba(255,170,0,0.3);
}
.led-label {
  font-size: 8px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Hardware Buttons */
.hw-btn {
  font-family: var(--mono-font);
  font-size: 11px;
  font-weight: 700;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  padding: 8px 12px;
  text-transform: uppercase;
  transition: all 0.1s;
  position: relative;
}
.hw-btn:active { transform: translateY(1px); }

.power-btn {
  background: linear-gradient(180deg, #555 0%, #333 100%);
  color: #ccc;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.15);
  font-size: 16px;
  padding: 6px 14px;
}
.power-btn:hover { background: linear-gradient(180deg, #666 0%, #444 100%); }
.power-btn.active { background: linear-gradient(180deg, #444 0%, #2a2a2a 100%); box-shadow: inset 0 2px 4px rgba(0,0,0,0.5); }

.reset-btn {
  background: linear-gradient(180deg, #c44 0%, #922 100%);
  color: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
  font-size: 9px;
  padding: 6px 10px;
}
.reset-btn:hover { background: linear-gradient(180deg, #d55 0%, #a33 100%); }

.turbo-btn {
  background: linear-gradient(180deg, #555 0%, #333 100%);
  color: #ccc;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.15);
  font-size: 9px;
}
.turbo-btn.active { background: linear-gradient(180deg, #444 0%, #2a2a2a 100%); box-shadow: inset 0 2px 4px rgba(0,0,0,0.5); }

.drive-btn {
  background: linear-gradient(180deg, #4a4a5e 0%, #333348 100%);
  color: #aaa;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.1);
  font-size: 10px;
  min-width: 36px;
}
.drive-btn:hover { color: #fff; background: linear-gradient(180deg, #5a5a6e 0%, #434358 100%); }

.speed-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.retro-slider {
  -webkit-appearance: none;
  width: 80px;
  height: 6px;
  background: #222;
  border-radius: 3px;
  outline: none;
  border: 1px solid #444;
}
.retro-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 20px;
  background: linear-gradient(180deg, #777 0%, #444 100%);
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid #555;
}
.speed-val {
  font-size: 10px;
  color: var(--cga-green);
  font-family: var(--pixel-font);
  min-width: 70px;
  text-align: right;
}

/* INFO BAR */
#info-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  background: #1a1a2e;
  border-radius: 4px;
  margin-bottom: 4px;
  font-size: 11px;
}
#status-text { color: var(--text-dim); flex: 1; }
#ips-counter { color: var(--cga-green); font-family: var(--pixel-font); font-size: 9px; }
.text-btn {
  background: none;
  border: 1px solid #444;
  color: var(--text-dim);
  font-family: var(--mono-font);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
}
.text-btn:hover { border-color: var(--ibm-blue); color: var(--text-primary); }

/* DEBUG PANEL */
#debug-panel {
  background: #111122;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 12px;
  margin-bottom: 8px;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s;
  max-height: 600px;
  opacity: 1;
}
#debug-panel.collapsed {
  max-height: 0;
  padding: 0 12px;
  opacity: 0;
  border: none;
  margin: 0;
}
.debug-section {
  margin-bottom: 10px;
}
.debug-section h3 {
  font-size: 10px;
  color: var(--ibm-blue);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 6px;
  border-bottom: 1px solid #222;
  padding-bottom: 3px;
}
.reg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 2px 12px;
  font-family: var(--mono-font);
  font-size: 11px;
}
.reg-grid .reg-item {
  display: flex;
  gap: 4px;
}
.reg-grid .reg-name { color: var(--ibm-blue); }
.reg-grid .reg-val { color: var(--cga-green); }
.mono { font-family: var(--mono-font); font-size: 11px; }
.log-box {
  max-height: 100px;
  overflow-y: auto;
  font-family: var(--mono-font);
  font-size: 10px;
  color: #aaa;
  background: #0a0a15;
  padding: 4px 8px;
  border-radius: 3px;
  border: 1px solid #222;
}
.log-box::-webkit-scrollbar { width: 6px; }
.log-box::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
.debug-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.bp-input {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 16px;
  font-size: 11px;
}
.mono-input {
  background: #0a0a15;
  border: 1px solid #333;
  color: var(--cga-green);
  font-family: var(--mono-font);
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 3px;
  width: 100px;
}
.mem-controls { display: flex; gap: 6px; margin-bottom: 6px; }
.mem-dump {
  max-height: 120px;
  overflow-y: auto;
  font-size: 10px;
  color: #aaa;
  background: #0a0a15;
  padding: 6px;
  border-radius: 3px;
  border: 1px solid #222;
  white-space: pre;
  line-height: 1.4;
}

/* MODALS */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal.hidden { display: none; }
.modal-content {
  background: #1e1e32;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 24px;
  max-width: 480px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-header h2 {
  font-family: var(--pixel-font);
  font-size: 14px;
  color: var(--ibm-blue);
}
.close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
}
.close-btn:hover { color: #fff; }

/* Drop Zone */
.drop-zone {
  border: 2px dashed #444;
  border-radius: 8px;
  padding: 32px;
  text-align: center;
  margin-bottom: 16px;
  transition: all 0.2s;
  cursor: pointer;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--ibm-blue);
  background: rgba(65,105,225,0.05);
}
.floppy-icon { font-size: 48px; margin-bottom: 8px; }
.drop-zone p { color: var(--text-dim); margin-bottom: 4px; }
.drop-zone .small { font-size: 10px; color: #666; }
.file-input { display: none; }
.browse-btn { margin-top: 12px; }

.assign-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.assign-row select {
  background: #0a0a15;
  border: 1px solid #444;
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: 3px;
  font-family: var(--mono-font);
}
#disk-info { color: var(--cga-green); font-size: 11px; }

.mounted-drives { margin-top: 16px; }
.mounted-drives h3 {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
#mounted-list { font-size: 11px; }
.mounted-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background: #0a0a15;
  border-radius: 3px;
  margin-bottom: 4px;
}
.mounted-item .drive-letter { color: var(--ibm-blue); font-weight: 700; }
.mounted-item .disk-name { color: var(--text-dim); flex: 1; margin-left: 8px; }
.eject-btn {
  background: none;
  border: 1px solid #633;
  color: #c66;
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
}
.eject-btn:hover { background: #422; }

.demo-section { margin-top: 16px; }
.demo-section h3 {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.demo-section .text-btn { margin-right: 6px; margin-bottom: 6px; }

/* Settings */
.settings-content { max-width: 360px; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #222;
}
.setting-row label { font-size: 12px; color: var(--text-dim); }
.setting-row select, .setting-row input[type="checkbox"] {
  background: #0a0a15;
  border: 1px solid #444;
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: 3px;
  font-family: var(--mono-font);
}

/* FOOTER */
#footer {
  text-align: center;
  padding: 16px;
  font-size: 10px;
  color: #555;
  border-top: 1px solid #222;
  margin-top: 16px;
}
#footer a {
  color: var(--ibm-blue);
  text-decoration: none;
  margin-left: 12px;
}
#footer a:hover { text-decoration: underline; }

/* CRT power animation */
@keyframes crt-on {
  0% { opacity: 0; transform: scaleY(0.01); filter: brightness(3); }
  40% { opacity: 1; transform: scaleY(0.01); filter: brightness(3); }
  60% { transform: scaleY(1); filter: brightness(1.5); }
  100% { transform: scaleY(1); filter: brightness(1); }
}
.crt-powering-on #cga-display {
  animation: crt-on 0.6s ease-out forwards;
}

/* Responsive */
@media (max-width: 700px) {
  #cga-display { width: 100%; height: auto; }
  .monitor-bezel { padding: 12px 12px 8px; }
  .controls-row { gap: 8px; }
  .speed-group { margin-left: 0; width: 100%; }
  .reg-grid { grid-template-columns: repeat(4, 1fr); }
  .header-inner { flex-wrap: wrap; }
  .subtitle { display: none; }
}