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

:root {
  --ibm-beige: #c8b898;
  --ibm-beige-light: #d9ccb0;
  --ibm-beige-dark: #a89878;
  --ibm-gray: #555;
  --ibm-blue: #2060d0;
  --crt-green: #33ff33;
  --crt-amber: #ffaa00;
  --led-green: #00ff44;
  --led-red: #ff2200;
  --panel-bg: #b8a888;
}

body {
  background: #1a1410;
  background-image:
    repeating-linear-gradient(
      90deg,
      transparent, transparent 2px,
      rgba(60,40,20,0.15) 2px, rgba(60,40,20,0.15) 4px
    ),
    repeating-linear-gradient(
      0deg,
      transparent, transparent 2px,
      rgba(60,40,20,0.1) 2px, rgba(60,40,20,0.1) 4px
    );
  font-family: 'IBM Plex Mono', monospace;
  color: #ccc;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
}

#emulator-wrapper {
  max-width: 900px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

/* Monitor Bezel */
#monitor-bezel {
  background: linear-gradient(180deg, #c0b090 0%, #a89878 50%, #9a8a70 100%);
  border-radius: 18px 18px 12px 12px;
  padding: 16px 22px 12px 22px;
  box-shadow:
    0 4px 20px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(255,255,255,0.3),
    inset 0 -2px 4px rgba(0,0,0,0.2);
  width: 100%;
  position: relative;
}

#bezel-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px 8px 8px;
}

#ibm-logo {
  display: flex;
  gap: 2px;
}

.ibm-stripe {
  display: inline-block;
  font-weight: 700;
  font-size: 18px;
  color: var(--ibm-blue);
  background: repeating-linear-gradient(
    0deg,
    var(--ibm-blue) 0px, var(--ibm-blue) 2px,
    transparent 2px, transparent 4px
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 1px;
}

#monitor-model {
  font-size: 10px;
  color: #666;
  font-weight: 500;
}

/* CRT Display */
#crt-container {
  position: relative;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow:
    inset 0 0 60px rgba(0,0,0,0.8),
    inset 0 0 8px rgba(0,0,0,1),
    0 0 2px rgba(0,0,0,0.5);
  border: 3px solid #222;
}

#canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border-radius: 10px;
}

#crt-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  border-radius: 10px;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.35) 100%);
}

#scanlines {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  border-radius: 10px;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px, transparent 1px,
    rgba(0,0,0,0.12) 1px, rgba(0,0,0,0.12) 2px
  );
}

#bezel-bottom {
  display: flex;
  justify-content: space-around;
  padding: 8px 8px 0 8px;
  font-size: 9px;
  color: #777;
}

/* Control Panel */
#control-panel {
  width: 100%;
  background: linear-gradient(180deg, var(--ibm-beige) 0%, var(--ibm-beige-dark) 100%);
  border-radius: 0 0 10px 10px;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  position: relative;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.3),
    0 2px 10px rgba(0,0,0,0.3);
  border-top: 2px solid #998870;
}

#panel-texture {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  opacity: 0.07;
  background: repeating-linear-gradient(
    90deg,
    transparent, transparent 1px,
    rgba(0,0,0,0.5) 1px, rgba(0,0,0,0.5) 2px
  );
  border-radius: 0 0 10px 10px;
}

.control-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
  z-index: 1;
}

.control-label {
  font-size: 8px;
  color: #555;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Power Button */
#power-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid #555;
  background: linear-gradient(145deg, #dd4422, #bb2200);
  cursor: pointer;
  box-shadow:
    0 3px 6px rgba(0,0,0,0.4),
    inset 0 1px 2px rgba(255,255,255,0.3);
  transition: all 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#power-btn:active {
  transform: scale(0.92);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

#power-btn.on {
  background: linear-gradient(145deg, #44cc22, #22aa00);
}

.power-btn-inner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
  position: relative;
}

.power-btn-inner::after {
  content: '';
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 7px;
  background: rgba(255,255,255,0.4);
}

/* Floppy Drive */
#floppy-drive {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #888;
  padding: 4px 10px;
  border-radius: 3px;
  border: 1px solid #666;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}

#floppy-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #333;
  transition: background 0.15s;
}

#floppy-led.active {
  background: var(--led-green);
  box-shadow: 0 0 6px var(--led-green);
}

#floppy-slot {
  font-size: 10px;
  color: #ccc;
}

#insert-disk-btn, #eject-disk-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  padding: 3px 8px;
  background: #777;
  color: #eee;
  border: 1px solid #555;
  border-radius: 2px;
  cursor: pointer;
}

#insert-disk-btn:hover, #eject-disk-btn:hover {
  background: #999;
}

#eject-disk-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#disk-name-label {
  font-size: 9px;
  color: #666;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Speed Display */
#speed-display {
  background: #1a2a1a;
  color: #33ff66;
  padding: 4px 10px;
  border-radius: 3px;
  border: 1px solid #333;
  font-size: 14px;
  font-weight: 700;
  font-family: 'IBM Plex Mono', monospace;
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.5);
  display: flex;
  align-items: baseline;
  gap: 3px;
}

#speed-unit {
  font-size: 9px;
  opacity: 0.7;
}

/* Turbo Button */
#turbo-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  padding: 5px 10px;
  background: linear-gradient(180deg, #888, #666);
  color: #ddd;
  border: 2px solid #555;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

#turbo-btn.active {
  background: linear-gradient(180deg, #666, #444);
  border-color: #888;
}

#turbo-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #333;
}

#turbo-btn.active #turbo-led {
  background: var(--led-green);
  box-shadow: 0 0 4px var(--led-green);
}

/* Volume */
#volume-knob {
  width: 80px;
  accent-color: var(--ibm-beige-dark);
}

/* Debug Toggle */
#debug-toggle-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  padding: 5px 10px;
  background: linear-gradient(180deg, #888, #666);
  color: #ddd;
  border: 2px solid #555;
  border-radius: 3px;
  cursor: pointer;
}

/* Status Bar */
#status-bar {
  width: 100%;
  background: #1a1a2a;
  padding: 6px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 10px;
  color: #8888aa;
  border-radius: 0 0 6px 6px;
  border-top: 1px solid #333;
}

/* Debug Panel */
#debug-panel {
  width: 100%;
  background: #111118;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 12px;
  margin-top: 8px;
  max-height: 400px;
  overflow-y: auto;
}

#debug-panel.hidden { display: none; }

#debug-panel h3 {
  color: var(--ibm-blue);
  font-size: 13px;
  margin-bottom: 8px;
}

#debug-panel h4 {
  color: #88aacc;
  font-size: 11px;
  margin: 8px 0 4px;
}

#debug-controls {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

#debug-controls button {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  padding: 3px 10px;
  background: #2a2a3a;
  color: #aaa;
  border: 1px solid #444;
  border-radius: 3px;
  cursor: pointer;
}

#debug-controls button:hover {
  background: #3a3a5a;
  color: #ddd;
}

#debug-panel pre {
  font-size: 10px;
  color: #77cc77;
  background: #0a0a12;
  padding: 6px;
  border-radius: 3px;
  overflow-x: auto;
  line-height: 1.4;
}

#mem-addr-input {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  padding: 2px 6px;
  background: #1a1a2a;
  color: #aaa;
  border: 1px solid #444;
  border-radius: 2px;
  width: 150px;
}

#mem-go-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  padding: 2px 8px;
  background: #2a2a3a;
  color: #aaa;
  border: 1px solid #444;
  border-radius: 2px;
  cursor: pointer;
}

/* Footer */
#app-footer {
  margin-top: 16px;
  font-size: 10px;
  color: #555;
  text-align: center;
  padding: 8px;
}

#app-footer a {
  color: var(--ibm-blue);
  text-decoration: none;
}

#app-footer a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 600px) {
  body { padding: 4px; }
  #monitor-bezel { padding: 8px 10px 6px 10px; border-radius: 10px 10px 6px 6px; }
  #control-panel { padding: 8px; gap: 8px; }
  .control-label { font-size: 7px; }
  #speed-display { font-size: 11px; }
  #status-bar { font-size: 8px; gap: 6px; }
}