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

body {
  background: #1a1a1a;
  font-family: 'IBM Plex Mono', monospace;
  color: #c0c0c0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

#app-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 900px;
  padding: 10px;
}

.monitor-label {
  color: #c8b88a;
  font-size: 11px;
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-bottom: 6px;
  text-align: center;
}

.monitor-bezel {
  background: linear-gradient(145deg, #d4c8a0, #b0a47a);
  border-radius: 18px;
  padding: 22px 26px 30px 26px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.3), inset 0 -2px 0 rgba(0,0,0,0.2);
  position: relative;
}

.monitor-inner {
  background: #0a0a0a;
  border-radius: 10px;
  padding: 8px;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.8), inset 0 0 4px rgba(0,0,0,0.9);
  position: relative;
  overflow: hidden;
}

.scanlines {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.15) 0px,
    rgba(0,0,0,0.15) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 2;
  border-radius: 6px;
}

.crt-glow {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 6px;
  box-shadow: inset 0 0 60px rgba(0,180,0,0.03);
  pointer-events: none;
  z-index: 1;
}

#canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: 720px;
  height: 400px;
  border-radius: 4px;
  position: relative;
  z-index: 0;
  cursor: pointer;
}

.monitor-badge {
  text-align: center;
  margin-top: 8px;
  color: #8b8068;
  font-size: 10px;
  letter-spacing: 2px;
}

.display-mode-bar {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}

.display-mode-btn {
  background: #b0a47a;
  border: 1px solid #8b8068;
  color: #3a3520;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
  letter-spacing: 1px;
}

.display-mode-btn.active {
  background: #3a3520;
  color: #c8b88a;
}

/* Floppy Drive Bay */
.floppy-bay {
  background: linear-gradient(180deg, #d4c8a0, #c0b48e);
  border: 2px solid #8b8068;
  border-radius: 6px;
  padding: 12px 16px;
  margin-top: 12px;
  width: 100%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.3);
}

.floppy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.floppy-title {
  color: #3a3520;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.floppy-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #555;
  box-shadow: 0 0 2px rgba(0,0,0,0.5);
  transition: all 0.1s;
}

.floppy-led.active {
  background: #ff3333;
  box-shadow: 0 0 6px #ff3333;
}

.drop-zone {
  border: 2px dashed #8b8068;
  border-radius: 4px;
  padding: 14px;
  text-align: center;
  background: rgba(0,0,0,0.08);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.drop-zone:hover, .drop-zone.dragover {
  background: rgba(0,0,0,0.15);
  border-color: #5a4f3a;
}

.drop-zone-icon {
  font-size: 28px;
  display: block;
  margin-bottom: 4px;
}

.drop-zone-text {
  color: #5a4f3a;
  font-size: 10px;
  letter-spacing: 1px;
}

.floppy-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.lcd-readout {
  background: #2a3a1a;
  color: #88cc44;
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 2px;
  border: 1px solid #1a2a0a;
  font-family: 'IBM Plex Mono', monospace;
  flex: 1;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
}

.load-btn {
  background: linear-gradient(180deg, #e0d4b4, #c0b48e);
  border: 2px outset #d4c8a0;
  color: #3a3520;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 12px;
  cursor: pointer;
  letter-spacing: 1px;
}

.load-btn:active {
  border-style: inset;
}

.file-input-hidden {
  display: none;
}

/* Control Panel */
.control-panel {
  background: linear-gradient(180deg, #d4c8a0, #c0b48e);
  border: 2px solid #8b8068;
  border-radius: 6px;
  padding: 10px 16px;
  margin-top: 8px;
  width: 100%;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.3);
}

.ctrl-btn {
  background: linear-gradient(180deg, #e8dcc0, #c8bc9a);
  border: 2px outset #d4c8a0;
  color: #3a3520;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 5px 12px;
  cursor: pointer;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.ctrl-btn:active {
  border-style: inset;
}

.ctrl-led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: inset 0 0 2px rgba(0,0,0,0.3);
}

.ctrl-led.green { background: #44cc44; box-shadow: 0 0 4px #44cc44; }
.ctrl-led.red { background: #cc4444; box-shadow: 0 0 4px #cc4444; }
.ctrl-led.yellow { background: #cccc44; box-shadow: 0 0 4px #cccc44; }
.ctrl-led.off { background: #555; box-shadow: none; }

/* Keyboard indicator */
.kbd-indicator {
  background: #222;
  color: #88cc44;
  font-size: 9px;
  padding: 3px 10px;
  border-radius: 3px;
  text-align: center;
  margin-top: 6px;
  width: 100%;
  letter-spacing: 0.5px;
}

/* Device Panel */
.device-panel {
  background: #111;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 8px 12px;
  margin-top: 8px;
  width: 100%;
}

.device-panel-title {
  color: #888;
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 6px;
  border-bottom: 1px solid #333;
  padding-bottom: 4px;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 3px;
}

.device-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  color: #777;
}

.device-led-small {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #444;
  flex-shrink: 0;
}

.device-led-small.active {
  background: #44cc44;
  box-shadow: 0 0 3px #44cc44;
}

/* Debugger Sidebar */
.main-area {
  display: flex;
  gap: 8px;
  width: 100%;
  align-items: flex-start;
}

.main-column { flex: 1; min-width: 0; }

.debugger-toggle {
  background: #222;
  border: 1px solid #444;
  color: #88cc44;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  padding: 3px 10px;
  cursor: pointer;
  border-radius: 3px;
  margin-top: 6px;
  width: 100%;
  text-align: center;
  letter-spacing: 1px;
}

.debugger-panel {
  background: #0a0e14;
  border: 1px solid #1a3a1a;
  border-radius: 4px;
  padding: 8px;
  width: 280px;
  flex-shrink: 0;
  max-height: 640px;
  overflow-y: auto;
  font-size: 10px;
}

.debug-section {
  margin-bottom: 8px;
}

.debug-title {
  color: #44aa44;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  border-bottom: 1px solid #1a3a1a;
  padding-bottom: 2px;
  margin-bottom: 4px;
}

.reg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px 8px;
}

.reg-item {
  display: flex;
  justify-content: space-between;
  color: #33dd33;
  font-size: 10px;
}

.reg-label { color: #669966; }
.reg-value { color: #33ff33; }

.flags-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.flag-item {
  color: #555;
  font-size: 9px;
}

.flag-item.set {
  color: #ffcc00;
  font-weight: 700;
}

.disasm-line {
  color: #33aa33;
  font-size: 9px;
  padding: 1px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.disasm-line.current {
  color: #33ff33;
  background: rgba(51,255,51,0.1);
  font-weight: 700;
}

.hex-dump {
  color: #339933;
  font-size: 9px;
  white-space: pre;
  line-height: 1.4;
  overflow-x: auto;
}

.io-log {
  color: #33aa33;
  font-size: 9px;
  max-height: 60px;
  overflow-y: auto;
}

.io-entry { padding: 0; }

.debug-input {
  background: #0a1a0a;
  border: 1px solid #1a3a1a;
  color: #33ff33;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  padding: 2px 6px;
  width: 100%;
  outline: none;
}

.debug-input:focus {
  border-color: #33ff33;
}

.instr-counter {
  color: #669966;
  font-size: 9px;
}

/* Footer */
.app-footer {
  margin-top: 16px;
  margin-bottom: 10px;
  text-align: center;
  font-size: 10px;
}

.app-footer a {
  color: #666;
  text-decoration: none;
}

.app-footer a:hover {
  color: #88cc44;
}

/* Responsive */
@media (max-width: 780px) {
  #canvas {
    width: 100%;
    height: auto;
  }
  .monitor-bezel {
    padding: 12px;
  }
  .debugger-panel {
    width: 100%;
  }
  .main-area {
    flex-direction: column;
  }
}

/* Scrollbar for debugger */
.debugger-panel::-webkit-scrollbar {
  width: 4px;
}
.debugger-panel::-webkit-scrollbar-track {
  background: #0a0e14;
}
.debugger-panel::-webkit-scrollbar-thumb {
  background: #1a3a1a;
  border-radius: 2px;
}