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

:root {
  --bg: #111111;
  --beige: #C8B078;
  --beige-dark: #9A7E4E;
  --acorn-red: #CC0000;
  --phosphor-green: #33FF33;
  --phosphor-amber: #FFAA00;
  --panel-bg: #0a0a0a;
  --panel-border: #2a2a2a;
  --text-green: #33ff33;
  --text-dim: #667766;
}

body {
  background: var(--bg);
  color: #ccc;
  font-family: 'IBM Plex Mono', 'Share Tech Mono', monospace;
  overflow-x: hidden;
  min-height: 100vh;
}

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

/* TOP BAR */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #D4BA82 0%, #B89A5C 50%, #9A7E4E 100%);
  padding: 8px 20px;
  border-bottom: 3px solid #7A6030;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.owl-logo {
  font-size: 28px;
  filter: grayscale(0.3);
}

.bbc-text {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
  letter-spacing: 3px;
}

.micro-text {
  font-size: 14px;
  font-weight: 400;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
  margin-left: 4px;
}

.status-section {
  display: flex;
  align-items: center;
  gap: 20px;
}

.led-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.led {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.3);
}

.led-red { background: #cc0000; box-shadow: 0 0 6px #cc0000; }
.led-green { background: #00cc00; box-shadow: 0 0 8px #00cc00; }
.led-amber { background: #ccaa00; box-shadow: 0 0 8px #ccaa00; animation: pulse-led 1s infinite; }

@keyframes pulse-led {
  0%,100% { opacity: 1; }
  50% { opacity: 0.4; }
}

#led-label {
  font-size: 11px;
  font-weight: 700;
  color: #333;
}

.clock-info {
  display: flex;
  flex-direction: column;
  font-size: 10px;
  color: #444;
  text-align: right;
}

/* MAIN AREA */
#main-area {
  display: flex;
  flex: 1;
  gap: 0;
  padding: 10px;
}

#display-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* MONITOR */
#monitor-bezel {
  background: #1a1a1a;
  border: 6px solid #222;
  border-radius: 20px;
  padding: 16px;
  box-shadow:
    inset 0 0 30px rgba(0,0,0,0.8),
    0 0 20px rgba(0,0,0,0.6),
    0 0 60px rgba(0,0,0,0.3);
  position: relative;
  margin-bottom: 10px;
}

#crt-container {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(50,255,50,0.05);
}

#screen {
  display: block;
  width: 640px;
  height: 512px;
  background: #000;
  border-radius: 8px;
  image-rendering: pixelated;
}

body.phosphor-green #crt-container { box-shadow: 0 0 40px rgba(50,255,50,0.08); }
body.phosphor-amber #crt-container { box-shadow: 0 0 40px rgba(255,170,0,0.08); }

#scanline-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  border-radius: 8px;
  display: none;
}

#scanline-overlay.active {
  display: block;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0) 0px,
    rgba(0,0,0,0) 1px,
    rgba(0,0,0,0.15) 1px,
    rgba(0,0,0,0.15) 2px
  );
}

#drop-zone {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px dashed var(--phosphor-green);
  border-radius: 8px;
  background: rgba(0,50,0,0.6);
  font-size: 20px;
  color: var(--phosphor-green);
  letter-spacing: 2px;
  z-index: 10;
}

#drop-zone.hidden { display: none; }

/* CONTROL BAR */
#control-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: linear-gradient(180deg, #3a3a3a, #2a2a2a);
  border-radius: 8px;
  border: 1px solid #444;
  width: 100%;
  max-width: 672px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bbc-key {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  background: linear-gradient(180deg, #D4BA82 0%, #B89A5C 100%);
  color: #333;
  border: 1px solid #8A6A2E;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 2px 0 #6A5020, inset 0 1px 0 rgba(255,255,255,0.3);
  text-transform: uppercase;
  transition: all 0.1s;
  line-height: 1.2;
}

.bbc-key:hover { filter: brightness(1.1); }
.bbc-key:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 #6A5020, inset 0 1px 0 rgba(255,255,255,0.3);
}

.bbc-key-red {
  background: linear-gradient(180deg, #EE2222 0%, #CC0000 100%);
  color: #fff;
  border-color: #880000;
  box-shadow: 0 2px 0 #660000, inset 0 1px 0 rgba(255,255,255,0.2);
}

.bbc-key.small { padding: 4px 8px; font-size: 14px; }

.bbc-key.active {
  background: linear-gradient(180deg, #5a5 0%, #393 100%);
  color: #fff;
  border-color: #262;
}

.speed-group label, .audio-group label {
  font-size: 10px;
  color: #888;
}

.speed-group input[type=range], .audio-group input[type=range] {
  width: 60px;
  accent-color: var(--beige);
}

#speed-label { font-size: 10px; color: var(--beige); min-width: 30px; }

#audio-viz { background: #000; border-radius: 3px; border: 1px solid #333; }

.toggle-label {
  font-size: 10px;
  color: #888;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

#phosphor-select {
  font-size: 10px;
  background: #222;
  color: #ccc;
  border: 1px solid #444;
  border-radius: 3px;
  padding: 2px;
  font-family: 'IBM Plex Mono', monospace;
}

#rom-info {
  font-size: 11px;
  color: var(--text-green);
  padding: 4px 10px;
  max-width: 672px;
  width: 100%;
}

#rom-info.hidden { display: none; }

/* SIDEBAR */
#sidebar {
  width: 260px;
  display: flex;
  flex-direction: column;
  transition: width 0.3s;
}

#sidebar.collapsed {
  width: 30px;
}

#sidebar.collapsed #sidebar-content { display: none; }

.sidebar-btn {
  background: var(--panel-bg);
  color: var(--text-green);
  border: 1px solid var(--panel-border);
  padding: 4px 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  cursor: pointer;
  text-align: center;
}

#sidebar-content {
  flex: 1;
  overflow-y: auto;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-top: none;
}

.hw-panel {
  padding: 8px;
  border-bottom: 1px solid var(--panel-border);
}

.hw-panel h3 {
  font-size: 10px;
  color: var(--text-green);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 2px;
  opacity: 0.8;
}

.register-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
}

.reg {
  background: #111;
  padding: 2px 4px;
  border-radius: 2px;
  text-align: center;
  border: 1px solid #222;
}

.reg label {
  font-size: 8px;
  color: #666;
  display: block;
}

.reg span {
  font-size: 12px;
  color: var(--text-green);
  font-weight: 700;
}

.reg-wide { grid-column: span 2; }

.flags {
  display: flex;
  gap: 3px;
  margin-top: 4px;
}

.flag {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  background: #111;
  border: 1px solid #333;
  border-radius: 2px;
  color: #444;
}

.flag.lit {
  color: var(--text-green);
  background: #0a2a0a;
  border-color: var(--text-green);
  box-shadow: 0 0 4px rgba(50,255,50,0.3);
}

.flag-dim { opacity: 0.3; }

.crtc-regs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  font-size: 9px;
}

.crtc-regs span {
  background: #111;
  padding: 1px 3px;
  border-radius: 1px;
  color: var(--text-green);
  border: 1px solid #1a1a1a;
}

#ula-status div {
  font-size: 10px;
  display: flex;
  justify-content: space-between;
  padding: 1px 0;
}

#ula-status label { color: #666; }
#ula-status span { color: var(--text-green); }

#memmap {
  width: 32px;
  height: 128px;
  border: 1px solid #333;
  image-rendering: pixelated;
}

.memmap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  font-size: 8px;
}

.ml-ram { color: #4488ff; }
.ml-srom { color: #cccc44; }
.ml-rom { color: #44cc44; }
.ml-io { color: #cc4444; }
.ml-vec { color: #cc44cc; }

.snd-ch {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 2px 0;
}

.snd-ch label { font-size: 9px; color: #666; width: 18px; }
.snd-ch span { font-size: 8px; color: var(--text-green); min-width: 30px; }

.snd-bar {
  flex: 1;
  height: 6px;
  background: #111;
  border-radius: 3px;
  overflow: hidden;
}

.snd-bar div {
  height: 100%;
  background: var(--text-green);
  width: 0%;
  transition: width 0.1s;
}

#disasm-view {
  font-size: 9px;
  color: var(--text-green);
  line-height: 1.4;
  max-height: 150px;
  overflow-y: auto;
}

/* KEYBOARD */
#keyboard-section {
  padding: 10px;
  display: flex;
  justify-content: center;
}

#keyboard {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px;
  background: linear-gradient(180deg, #3a3530 0%, #2a2520 100%);
  border-radius: 8px;
  border: 2px solid #4a4540;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.4);
  max-width: 700px;
}

.kb-row {
  display: flex;
  gap: 3px;
  justify-content: center;
}

.kb-key {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  min-width: 36px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #D4BA82 0%, #B89A5C 100%);
  color: #333;
  border: 1px solid #8A6A2E;
  border-radius: 3px;
  cursor: pointer;
  box-shadow: 0 2px 0 #6A5020, inset 0 1px 0 rgba(255,255,255,0.3);
  user-select: none;
  transition: all 0.05s;
  padding: 0 4px;
}

.kb-key:active, .kb-key.pressed {
  transform: translateY(2px);
  box-shadow: 0 0 0 #6A5020;
  filter: brightness(0.85);
}

.kb-key.fn-key {
  background: linear-gradient(180deg, #EE2222 0%, #CC0000 100%);
  color: #fff;
  border-color: #880000;
  box-shadow: 0 2px 0 #660000, inset 0 1px 0 rgba(255,255,255,0.2);
}

.kb-key.fn-key:active, .kb-key.fn-key.pressed {
  box-shadow: 0 0 0 #660000;
}

.kb-key.wide { min-width: 54px; }
.kb-key.wider { min-width: 72px; }
.kb-key.space-key { min-width: 240px; }
.kb-key.break-key {
  background: linear-gradient(180deg, #ff6644 0%, #dd4422 100%);
  color: #fff;
  border-color: #993311;
}

/* FOOTER */
#footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 10px 20px;
  background: #0a0a0a;
  border-top: 1px solid #222;
  font-size: 10px;
  color: #446644;
  flex-wrap: wrap;
}

#footer a {
  color: var(--text-green);
  text-decoration: none;
}

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

#footer small { color: #335533; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #0a0a0a; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

/* RESPONSIVE */
@media (max-width: 960px) {
  #main-area { flex-direction: column; }
  #sidebar { width: 100%; }
  #sidebar.collapsed { width: 100%; height: 30px; }
  #screen { width: 100%; height: auto; }
  #control-bar { max-width: 100%; }
}

@media (max-width: 700px) {
  .kb-key { min-width: 24px; height: 24px; font-size: 8px; }
  .kb-key.wide { min-width: 36px; }
  .kb-key.wider { min-width: 48px; }
  .kb-key.space-key { min-width: 140px; }
  #keyboard { padding: 6px; }
}