:root {
  --mits-blue: #2f79b0;
  --mits-blue-dark: #1c5580;
  --panel: #3a3d3e;
  --panel-light: #4a4e50;
  --led-red: #ff2b1a;
  --led-off: #4a1210;
  --amber: #ffb000;
  --ink: #d8dadb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% 0%, #5a1a12 0%, #2a0c08 60%, #150402 100%);
  font-family: 'IBM Plex Mono', monospace;
  color: var(--ink);
  min-height: 100vh;
  padding: 16px;
}

.app-root { max-width: 1200px; margin: 0 auto; }

.crt-frame { display: flex; flex-direction: column; gap: 18px; }

/* ===== PANEL ===== */
.panel {
  background: linear-gradient(180deg, var(--mits-blue) 0%, var(--mits-blue-dark) 100%);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.6), inset 0 2px 6px rgba(255,255,255,0.15);
  overflow-x: auto;
}
.panel-face {
  background:
    repeating-linear-gradient(180deg, rgba(255,255,255,0.015) 0 2px, transparent 2px 4px),
    linear-gradient(160deg, var(--panel-light), var(--panel) 60%, #2e3132);
  border-radius: 8px;
  padding: 18px 20px 12px;
  min-width: 900px;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.5);
}

.led-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; }
.led-row2 { margin-top: 14px; }
.status-cluster, .data-cluster, .addr-cluster, .waithlda {
  display: flex; gap: 10px; align-items: flex-end;
}
.data-cluster { gap: 8px; }
.addr-cluster { gap: 7px; }
.waithlda { gap: 22px; }

.led-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.led-label {
  font-size: 9px; letter-spacing: 0.5px; color: #cfd2d3;
  font-family: 'Oswald', sans-serif; font-weight: 600; white-space: nowrap;
}
.led {
  width: 13px; height: 13px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #6b1f18, var(--led-off));
  border: 1px solid #1a0605;
  box-shadow: inset 0 0 3px rgba(0,0,0,0.8);
  transition: all 0.05s;
}
.led-big { width: 15px; height: 15px; }
.led-on {
  background: radial-gradient(circle at 35% 30%, #ff8a7a, var(--led-red) 70%);
  box-shadow: 0 0 10px 2px rgba(255,60,40,0.9), inset 0 0 2px #fff;
  border-color: #7a0d05;
}

.row-underline {
  display: flex; justify-content: space-between; position: relative;
  margin: 3px 0 6px; padding: 0 40px;
}
.group-cap {
  font-family: 'Oswald', sans-serif; font-size: 10px; letter-spacing: 3px;
  color: #b9bcbd; border-top: 1px solid #6a6d6e; padding-top: 2px;
}

/* ===== SWITCHES ===== */
.switch-row {
  display: flex; justify-content: flex-end; align-items: flex-start;
  gap: 8px; margin-top: 18px; padding-right: 4px;
}
.switch-caption {
  font-family: 'Oswald', sans-serif; font-size: 9px; color: #cfd2d3;
  text-align: right; margin-right: 6px; margin-top: 4px; line-height: 1.1;
}
.control-row {
  display: flex; gap: 16px; margin-top: 26px; padding-left: 120px;
  flex-wrap: wrap;
}
.sw-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.sw-label {
  font-size: 8px; font-family: 'Oswald', sans-serif; color: #cfd2d3;
  text-align: center; line-height: 1.05; white-space: nowrap;
}
.toggle {
  width: 16px; height: 34px; border-radius: 8px;
  background: linear-gradient(180deg, #2a2c2d, #17181a);
  border: 1px solid #0c0d0e; position: relative; cursor: pointer;
  box-shadow: inset 0 0 4px rgba(0,0,0,0.8);
}
.toggle-lever {
  position: absolute; left: 50%; transform: translateX(-50%);
  width: 11px; height: 15px; border-radius: 5px;
  background: linear-gradient(180deg, #d9dbdc, #8b8e8f);
  box-shadow: 0 2px 3px rgba(0,0,0,0.6);
  transition: top 0.12s ease, bottom 0.12s ease;
}
.toggle-down .toggle-lever { bottom: 2px; }
.toggle-up .toggle-lever { top: 2px; }
.toggle:active .toggle-lever { filter: brightness(1.3); }

/* ===== BRAND ===== */
.brand-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 24px; border-top: 2px solid rgba(0,0,0,0.3); padding-top: 10px;
}
.power-cluster { display: flex; }
.brand {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(180deg, #c9ccce, #9a9d9f);
  padding: 6px 18px; border-radius: 4px; margin-left: auto;
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.6);
}
.mits {
  background: var(--mits-blue-dark); color: #fff; font-weight: 700;
  padding: 2px 8px; border-radius: 3px; font-family: 'Oswald', sans-serif;
  font-size: 13px; letter-spacing: 1px;
}
.brand-name {
  font-family: 'Oswald', sans-serif; font-weight: 700; font-size: 24px;
  letter-spacing: 3px; color: #1a1c1d;
}

/* ===== TERMINAL ===== */
.terminal-wrap {
  background: #0a0a08; border-radius: 10px; overflow: hidden;
  border: 1px solid #2a2a24; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.term-header {
  display: flex; align-items: center; gap: 12px;
  background: #1a1a16; padding: 8px 14px; font-size: 12px;
  color: var(--amber); border-bottom: 1px solid #2a2a24;
  font-family: 'Oswald', sans-serif; letter-spacing: 1px;
}
.baud { margin-left: auto; cursor: pointer; opacity: 0.8; }
.baud:hover { opacity: 1; }
.clr-btn {
  background: #2a2a24; color: var(--amber); border: 1px solid #3a3a30;
  padding: 3px 10px; border-radius: 4px; cursor: pointer; font-family: inherit;
}
.terminal {
  position: relative; height: 260px; overflow-y: auto; padding: 14px 16px;
  background:
    repeating-linear-gradient(180deg, rgba(255,176,0,0.03) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, #120e04 0%, #0a0700 100%);
  color: var(--amber); cursor: text; outline: none;
}
.terminal:focus { box-shadow: inset 0 0 20px rgba(255,176,0,0.15); }
.term-off { filter: brightness(0.15) contrast(0.5); }
.term-text {
  margin: 0; white-space: pre-wrap; word-break: break-all;
  font-family: 'IBM Plex Mono', monospace; font-size: 14px; line-height: 1.4;
  text-shadow: 0 0 6px rgba(255,176,0,0.6);
}
.cursor {
  display: inline-block; width: 9px; height: 16px; background: var(--amber);
  animation: blink 1s steps(2) infinite; vertical-align: text-bottom;
  box-shadow: 0 0 8px var(--amber);
}
@keyframes blink { 50% { opacity: 0; } }

/* ===== LOADER ===== */
.loader { display: flex; gap: 14px; flex-wrap: wrap; align-items: stretch; }
.drop-zone {
  flex: 1; min-width: 260px; cursor: pointer;
  border: 2px dashed #6a4a2a; border-radius: 10px; padding: 16px;
  background: linear-gradient(180deg, #221a10, #171009);
  display: flex; flex-direction: column; gap: 4px; justify-content: center;
  transition: all 0.15s;
}
.drop-zone.drag { border-color: var(--amber); background: #2a1e10; }
.dz-title { font-family: 'Oswald', sans-serif; font-size: 16px; color: var(--amber); letter-spacing: 1px; }
.dz-sub { font-size: 12px; color: #a08858; }
.loader-actions { display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.btn {
  background: linear-gradient(180deg, #3a3d3e, #2a2c2d); color: var(--ink);
  border: 1px solid #1a1c1d; padding: 10px 20px; border-radius: 6px;
  cursor: pointer; font-family: 'Oswald', sans-serif; letter-spacing: 1px;
  font-size: 13px; transition: all 0.1s;
}
.btn:hover { filter: brightness(1.2); }
.btn:active { transform: translateY(1px); }
.btn-run { background: linear-gradient(180deg, #2a7a3a, #1c5528); }
.btn-run.active { background: linear-gradient(180deg, #b03a2a, #802018); }

/* ===== 8080 TEST SUITE ===== */
.suite {
  background: #0d0f10; border: 1px solid #2a2c2e; border-radius: 10px;
  overflow: hidden;
}
.suite-header {
  display: flex; align-items: center; justify-content: space-between;
  background: #16181a; padding: 8px 14px; border-bottom: 1px solid #2a2c2e;
}
.suite-title {
  font-family: 'Oswald', sans-serif; font-size: 13px; letter-spacing: 2px;
  color: var(--amber);
}
.suite-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.suite-note {
  font-size: 12px; line-height: 1.5; color: #9aa0a2;
}
.suite-note b { color: var(--amber); }
.rom-list { display: flex; flex-direction: column; gap: 8px; }
.rom-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #101314; border: 1px solid #24282a; border-left: 3px solid #3a3d3e;
  border-radius: 6px; padding: 10px 12px; flex-wrap: wrap;
}
.rom-row.loaded { border-left-color: var(--amber); }
.rom-info { min-width: 200px; flex: 1; }
.rom-name {
  font-family: 'Oswald', sans-serif; font-size: 15px; letter-spacing: 1px;
  color: #e4e6e7; display: flex; align-items: center; gap: 8px;
}
.rom-badge {
  font-size: 9px; letter-spacing: 1px; color: #0d0f10; background: var(--amber);
  padding: 1px 6px; border-radius: 3px; font-weight: 700;
}
.rom-desc { font-size: 11px; color: #6f7476; margin-top: 2px; }
.rom-cyc { color: #4a7a4a; }
.rom-actions { display: flex; gap: 8px; }
.rom-upload {
  cursor: pointer; font-family: 'Oswald', sans-serif; letter-spacing: 1px;
  font-size: 11px; color: var(--ink); background: linear-gradient(180deg, #3a3d3e, #2a2c2d);
  border: 1px solid #1a1c1d; padding: 7px 12px; border-radius: 5px; white-space: nowrap;
}
.rom-upload:hover { filter: brightness(1.2); }
.rom-run {
  font-family: 'Oswald', sans-serif; letter-spacing: 1px; font-size: 11px;
  color: #fff; background: linear-gradient(180deg, #2a7a3a, #1c5528);
  border: 1px solid #143f1e; padding: 7px 16px; border-radius: 5px; cursor: pointer;
}
.rom-run:hover:not(:disabled) { filter: brightness(1.2); }
.rom-run:disabled { opacity: 0.35; cursor: not-allowed; }
.suite-foot {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border-top: 1px solid #24282a; padding-top: 12px;
}
.test-readout {
  font-size: 12px; color: var(--amber); font-family: 'IBM Plex Mono', monospace;
  text-shadow: 0 0 4px rgba(255,176,0,0.4);
  display: flex; flex-direction: column; gap: 6px;
}
.cyc-readout { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.cyc-chip {
  font-size: 11px; letter-spacing: 0.5px; padding: 2px 8px; border-radius: 4px;
  border: 1px solid #2a2c2e; text-shadow: none; white-space: nowrap;
  font-family: 'IBM Plex Mono', monospace;
}
.cyc-got { background: #101314; color: #6fd36f; border-color: #244a24; }
.cyc-exp { background: #101314; color: #9aa0a2; }
.cyc-ok { background: #12280f; color: #7dff7d; border-color: #2a7a2a; box-shadow: 0 0 8px rgba(80,220,80,0.35); }
.cyc-bad { background: #2a0f0d; color: #ff8a7a; border-color: #7a0d05; box-shadow: 0 0 8px rgba(255,60,40,0.3); }

/* ===== STATUS BAR ===== */
.statusbar {
  background: #0d0d0b; border: 1px solid #2a2a24; border-radius: 8px;
  padding: 10px 14px; font-size: 13px; color: var(--amber);
  text-shadow: 0 0 4px rgba(255,176,0,0.4);
}

/* ===== DEBUG ===== */
.debug {
  background: #16181a; border: 1px solid #2a2c2e; border-radius: 8px;
  padding: 14px; display: flex; flex-direction: column; gap: 12px;
}
.reg-grid, .flag-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.reg {
  display: flex; flex-direction: column; align-items: center;
  background: #0d0f10; border: 1px solid #2a2c2e; border-radius: 6px;
  padding: 6px 12px; min-width: 56px;
}
.reg-name { font-size: 10px; color: #7a7d7e; font-family: 'Oswald', sans-serif; letter-spacing: 1px; }
.reg-val { font-size: 16px; color: #6fd36f; font-weight: 600; }
.flag {
  padding: 5px 12px; border-radius: 6px; font-size: 12px;
  background: #0d0f10; border: 1px solid #2a2c2e; color: #5a5d5e;
  font-family: 'Oswald', sans-serif; letter-spacing: 1px;
}
.flag-on { background: #4a1210; color: #ff8a7a; border-color: #7a0d05; box-shadow: 0 0 8px rgba(255,60,40,0.4); }

/* ===== FOOTER ===== */
.footer {
  text-align: center; font-size: 11px; color: #8a6a4a; padding: 10px;
}
.footer a { color: var(--amber); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

@media (max-width: 640px) {
  body { padding: 8px; }
  .brand-name { font-size: 16px; }
  .terminal { height: 200px; }
}