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

body {
  display: flex;
  height: 100vh;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #e8eaf0;
  color: #1a1a2e;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

#sidebar {
  width: 230px;
  min-width: 200px;
  background: #1a1a2e;
  color: #e0e0f0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

#sidebar-header {
  padding: 1.2rem 1rem 0.8rem;
  background: #12121f;
  text-align: center;
  border-bottom: 1px solid #2e2e50;
}

.chip-icon { font-size: 2rem; margin-bottom: 0.3rem; }

#sidebar-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #a78bfa;
  letter-spacing: 0.05em;
}

#sidebar-header p {
  font-size: 0.68rem;
  color: #7070a0;
  margin-top: 0.15rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#controls {
  flex: 1;
  overflow-y: auto;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* File input */
.file-label {
  display: block;
  text-align: center;
  background: #a78bfa;
  color: #fff;
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.file-label:hover { background: #8b5cf6; }
input[type="file"] { display: none; }

/* ROM info */
#rom-info {
  background: #12121f;
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  font-size: 0.72rem;
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 0.15rem 0;
  border-bottom: 1px solid #2a2a48;
}
.info-row:last-child { border-bottom: none; }
.info-row .label { color: #7070a0; }

/* Emulator controls */
#emu-controls {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

button {
  flex: 1;
  min-width: 48px;
  padding: 0.35rem 0.3rem;
  border: 1px solid #3a3a60;
  border-radius: 5px;
  background: #22224a;
  color: #c8c8f0;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
button:hover { background: #2e2e68; border-color: #a78bfa; }
button.primary { background: #7c3aed; color: #fff; border-color: #7c3aed; }
button.primary:hover { background: #6d28d9; }

/* Register display */
#regs {
  background: #12121f;
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  font-size: 0.7rem;
  font-family: 'Consolas', 'Fira Code', monospace;
}

.reg-title {
  font-size: 0.68rem;
  color: #7070a0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}

.reg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.15rem 0.5rem;
}

.reg {
  display: flex;
  justify-content: space-between;
}
.rname { color: #a78bfa; }
.rval  { color: #c8ffcc; }

#flags-display {
  margin-top: 0.4rem;
  color: #fde68a;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}

/* Status bar */
#status-bar {
  padding: 0.4rem 0.8rem;
  background: #0d0d1f;
  font-size: 0.68rem;
  color: #8080a0;
  min-height: 1.6rem;
  border-top: 1px solid #2e2e50;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Main content ────────────────────────────────────────────────────────── */

#content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Screen */
#screen-wrap {
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  height: min(50vh, 448px);
}

#screen {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  height: 100%;
  width: auto;
  max-width: 100%;
}

.overlay-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(0,0,0,0.75);
  color: #a0a0c0;
  font-size: 0.9rem;
  line-height: 1.7;
  pointer-events: none;
}

/* Design doc panel */
#doc-panel {
  flex: 1;
  overflow-y: auto;
  background: #f5f5ff;
  border-top: 2px solid #d0cee8;
}

.tab-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 1.2rem;
  background: #e8e4ff;
  border: none;
  border-bottom: 2px solid #a78bfa;
  font-size: 0.82rem;
  font-weight: 700;
  color: #3d3d7e;
  cursor: default;
  border-radius: 0;
  flex: none;
  min-width: unset;
}

#doc-content {
  padding: 1.2rem 1.5rem;
  max-width: 800px;
}

/* Typography for design doc */
#doc-content h1 { font-size: 1.5rem; font-weight: 800; color: #1a1a2e; margin-bottom: 0.5rem; border-bottom: 3px solid #a78bfa; padding-bottom: 0.4rem; }
#doc-content h2 { font-size: 1.1rem; font-weight: 700; color: #2d2d5e; margin: 1.8rem 0 0.6rem; padding: 0.4rem 0.8rem; background: #e8e4ff; border-left: 4px solid #a78bfa; border-radius: 0 4px 4px 0; }
#doc-content h3 { font-size: 0.95rem; font-weight: 700; color: #3d3d7e; margin: 1.2rem 0 0.4rem; border-bottom: 1px solid #d0d0ee; padding-bottom: 0.2rem; }
#doc-content p { line-height: 1.7; margin-bottom: 0.8rem; font-size: 0.88rem; color: #2a2a4a; }
#doc-content table { width: 100%; border-collapse: collapse; margin: 0.8rem 0 1.2rem; font-size: 0.78rem; }
#doc-content th { background: #2d2d5e; color: #e0e0f8; padding: 0.4rem 0.6rem; text-align: left; }
#doc-content td { padding: 0.3rem 0.6rem; border-bottom: 1px solid #dde; color: #333358; }
#doc-content tr:nth-child(even) td { background: #f5f4ff; }
#doc-content pre { background: #1e1e3a; border-radius: 6px; padding: 0.8rem 1rem; overflow-x: auto; margin: 0.8rem 0; font-size: 0.78rem; line-height: 1.5; }
#doc-content pre code { background: none; color: #c8d0ff; font-family: 'Consolas','Fira Code',monospace; }
#doc-content code { background: #ede8ff; color: #5b21b6; padding: 0.1em 0.3em; border-radius: 3px; font-family: 'Consolas','Fira Code',monospace; font-size: 0.82em; }
#doc-content ul, #doc-content ol { padding-left: 1.5rem; margin-bottom: 0.8rem; }
#doc-content li { margin-bottom: 0.2rem; font-size: 0.86rem; line-height: 1.6; color: #2a2a4a; }

/* Utility */
.hidden { display: none !important; }

/* Scrollbars */
#doc-panel::-webkit-scrollbar { width: 6px; }
#doc-panel::-webkit-scrollbar-thumb { background: #a78bfa; border-radius: 3px; }
#controls::-webkit-scrollbar { width: 4px; }
#controls::-webkit-scrollbar-thumb { background: #3a3a60; border-radius: 2px; }
