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

:root {
  --ibm-beige: #C4B598;
  --ibm-beige-light: #D4C8A8;
  --ibm-beige-dark: #A89A7C;
  --charcoal: #2C2C2C;
  --charcoal-light: #3A3A3A;
  --amber: #FFB000;
  --green-led: #00FF41;
  --red-led: #FF3333;
  --crt-green: #33FF33;
  --dark-bg: #1A1814;
  --desk-brown: #2A231A;
  --text-dim: #8A8A7A;
  --font-mono: 'IBM Plex Mono', monospace;
}

html, body {
  height: 100%;
  font-family: var(--font-mono);
  background: var(--dark-bg);
  color: #DDD;
  overflow-x: hidden;
}

body {
  background: 
    radial-gradient(ellipse at 50% 30%, #2A231A 0%, #1A1814 70%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0,0,0,0.03) 2px,
      rgba(0,0,0,0.03) 4px
    );
}

#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 10px;
}

/* TOP BAR */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #3A3A3A 0%, #2C2C2C 40%, #252525 100%);
  border: 1px solid #444;
  border-bottom: 2px solid #111;
  border-radius: 4px 4px 0 0;
  padding: 8px 16px;
  gap: 12px;
  flex-wrap: wrap;
}

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

.ibm-text {
  font-size: 24px;
  font-weight: 700;
  color: #4A90D9;
  letter-spacing: 4px;
  text-shadow: 0 0 8px rgba(74,144,217,0.4);
  font-family: var(--font-mono);
}

.model-text {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
}

#controls {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.ctrl-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.ctrl-label {
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.hw-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  position: relative;
  background: linear-gradient(180deg, #555 0%, #333 100%);
  box-shadow: 0 2px 4px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1);
  transition: all 0.1s;
  font-size: 16px;
  color: #CCC;
}

.hw-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
}

.hw-btn .btn-face {
  font-size: 16px;
  line-height: 1;
}

.reset-btn {
  width: 32px;
  height: 32px;
  background: linear-gradient(180deg, #444 0%, #2A2A2A 100%);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.4), 0 1px 0 rgba(255,255,255,0.05);
}

.led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.led-off {
  background: #333;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
}

.led-green {
  background: var(--green-led);
  box-shadow: 0 0 6px var(--green-led), 0 0 12px rgba(0,255,65,0.3);
}

.led-red {
  background: var(--red-led);
  box-shadow: 0 0 6px var(--red-led);
}

.led-amber {
  background: var(--amber);
  box-shadow: 0 0 6px var(--amber), 0 0 12px rgba(255,176,0,0.3);
}

.hw-btn-sm {
  padding: 4px 8px;
  border: 1px solid #555;
  border-radius: 3px;
  background: linear-gradient(180deg, #444 0%, #333 100%);
  color: #AAA;
  font-family: var(--font-mono);
  font-size: 10px;
  cursor: pointer;
}

.hw-btn-sm:hover {
  background: linear-gradient(180deg, #555 0%, #444 100%);
  color: #DDD;
}

.audio-ctrl {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.vol-slider {
  width: 60px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #555;
  border-radius: 2px;
  outline: none;
}

.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: var(--amber);
  border-radius: 50%;
  cursor: pointer;
}

/* MONITOR */
#monitor-container {
  display: flex;
  justify-content: center;
  padding: 0;
}

#monitor-bezel {
  background: linear-gradient(180deg, #D4C8A8 0%, #C4B598 30%, #B0A488 100%);
  border-radius: 16px;
  padding: 24px 28px 12px;
  box-shadow: 
    0 8px 32px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.3),
    inset 0 -2px 0 rgba(0,0,0,0.1);
  width: 100%;
  max-width: 860px;
  position: relative;
}

#screen-frame {
  position: relative;
  background: #111;
  border-radius: 12px;
  padding: 8px;
  box-shadow: inset 0 4px 16px rgba(0,0,0,0.8);
  overflow: hidden;
}

#crt-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 4/3;
  background: #0A0A0A;
  border-radius: 6px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

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

#crt-curve {
  position: absolute;
  top: 8px; left: 8px; right: 8px; bottom: 8px;
  border-radius: 6px;
  pointer-events: none;
  z-index: 3;
  box-shadow:
    inset 0 0 60px rgba(0,0,0,0.4),
    inset 0 0 120px rgba(0,0,0,0.2);
  background: radial-gradient(
    ellipse at 50% 50%,
    transparent 60%,
    rgba(0,0,0,0.35) 100%
  );
}

#focus-overlay {
  position: absolute;
  top: 8px; left: 8px; right: 8px; bottom: 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  z-index: 10;
  cursor: pointer;
}

#focus-overlay span {
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 8px 16px;
  border: 1px solid var(--amber);
  border-radius: 4px;
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; text-shadow: 0 0 8px var(--amber); }
}

#monitor-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px 0;
  font-size: 10px;
  color: #666;
  letter-spacing: 0.5px;
}

.hidden {
  display: none !important;
}

/* FLOPPY PANEL */
#floppy-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(180deg, #D0C4A4 0%, #C4B598 100%);
  border: 1px solid #A89A7C;
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 10px 16px;
  flex-wrap: wrap;
}

.drive-bay {
  flex: 1;
  min-width: 260px;
}

.drive-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.slot-opening {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #222;
  border-radius: 3px;
  padding: 6px 10px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.6);
  min-width: 50px;
}

.drive-label {
  color: #888;
  font-size: 11px;
  font-family: var(--font-mono);
}

.drive-controls {
  display: flex;
  gap: 6px;
}

.floppy-btn {
  padding: 5px 12px;
  background: linear-gradient(180deg, #555 0%, #333 100%);
  border: 1px solid #666;
  border-radius: 3px;
  color: #DDD;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.floppy-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #666 0%, #444 100%);
}

.floppy-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.floppy-btn.eject {
  padding: 5px 8px;
}

.status-text {
  font-size: 10px;
  color: #666;
  font-family: var(--font-mono);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* STATUS BAR */
#status-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--charcoal);
  border: 1px solid #444;
  border-top: none;
  border-radius: 0 0 4px 4px;
  padding: 6px 12px;
  font-size: 10px;
  color: var(--text-dim);
  flex-wrap: wrap;
  margin-top: 8px;
}

#status-bar span {
  white-space: nowrap;
}

.remix-link {
  margin-left: auto;
  color: var(--amber);
  text-decoration: none;
  font-size: 10px;
  opacity: 0.7;
}

.remix-link:hover {
  opacity: 1;
  text-decoration: underline;
}

/* DEBUG PANEL */
#debug-panel {
  background: #1A1A1A;
  border: 1px solid #333;
  border-radius: 0 0 4px 4px;
  padding: 8px 12px;
  font-size: 10px;
  color: var(--green-led);
  font-family: var(--font-mono);
  line-height: 1.6;
}

#registers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 2px 12px;
}

/* ON-SCREEN KEYBOARD */
#osk-container {
  background: linear-gradient(180deg, #D0C4A4 0%, #C4B598 100%);
  border: 1px solid #A89A7C;
  border-radius: 6px;
  padding: 8px;
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: center;
}

.osk-key {
  min-width: 28px;
  height: 28px;
  background: linear-gradient(180deg, #EEE 0%, #CCC 100%);
  border: 1px solid #999;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  box-shadow: 0 2px 0 #999;
}

.osk-key:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 #999;
}

.osk-key.wide {
  min-width: 60px;
}

.osk-key.space {
  min-width: 200px;
}

/* MOBILE */
@media (max-width: 640px) {
  #top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  #controls {
    width: 100%;
    justify-content: space-around;
  }
  #monitor-bezel {
    padding: 12px 14px 8px;
    border-radius: 10px;
  }
  #floppy-panel {
    flex-direction: column;
    align-items: flex-start;
  }
  .drive-slot {
    flex-direction: column;
    align-items: flex-start;
  }
  #status-bar {
    gap: 8px;
  }
  #osk-container {
    gap: 2px;
  }
  .osk-key {
    min-width: 22px;
    height: 24px;
    font-size: 7px;
  }
  .osk-key.space { min-width: 120px; }
}