:root {
  --bg: #100e17; --surface: #1d1a2b; --line: #3b3556; --text: #f6f3ff; --muted: #c5bfdc; --faint: #848bbd;
  --pink: #ff7edb; --cyan: #36f9f6; --yellow: #fede5d;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--muted);
  font: 13px/1.5 ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}
a { color: var(--cyan); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 1px solid var(--yellow); outline-offset: 1px; }
[hidden] { display: none !important; }

header {
  display: flex; align-items: stretch; justify-content: space-between; gap: 8px;
  border-bottom: 1px solid var(--line); flex: none;
}
nav { display: flex; }
nav button {
  padding: 7px 14px; border: 0; border-right: 1px solid var(--line); background: none; color: var(--faint);
  white-space: nowrap;
}
nav button b { color: var(--muted); }
nav button:hover { background: var(--surface); }
nav button[aria-selected="true"] { background: var(--pink); color: #2a1030; }
nav button[aria-selected="true"] b { color: #100e17; }
.file { margin: 0; padding: 7px 10px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file a { margin-left: 6px; text-decoration: none; }

main { flex: 1; min-height: 0; position: relative; }
section { position: absolute; inset: 0; display: flex; flex-direction: column; }
.foot { margin: 0; padding: 6px 10px; border-top: 1px solid var(--line); color: var(--faint); font-size: 12px; flex: none; }
.status { color: var(--faint); padding: 20px; margin: 0; }
.err { color: #fe4450; }

/* NES */
#pane-nes { align-items: center; justify-content: center; gap: 8px; padding: 8px; }
.stage { position: relative; flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
#screen {
  max-width: 100%; max-height: 100%; height: 100%; aspect-ratio: 256 / 240;
  image-rendering: pixelated; background: #000; display: block;
}
#power {
  position: absolute; left: 50%; bottom: 10%; transform: translateX(-50%);
  padding: 8px 16px; border: 1px solid var(--yellow); border-radius: 3px; background: #100e17e6; color: var(--yellow);
}
.pad { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; flex: none; }
.pad button {
  min-width: 44px; min-height: 34px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 3px;
  background: var(--surface); color: var(--text); touch-action: manipulation; user-select: none;
}
.pad button:active, .pad button.down { background: var(--pink); color: #100e17; }
.pad i { font-style: normal; color: var(--faint); font-size: 11px; }
.pad button:active i, .pad button.down i { color: #100e17; }
.keys { color: var(--faint); font-size: 12px; margin-left: 6px; }

/* PDF */
#pages { flex: 1; min-height: 0; overflow: auto; padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
#pages canvas { display: block; width: min(100%, 720px); height: auto; box-shadow: 0 0 0 1px var(--line); }

/* sh */
#term { flex: 1; min-height: 0; padding: 8px 4px 4px 10px; background: #0b0a10; overflow: hidden; }
code { color: var(--muted); }

@media (max-width: 520px) {
  nav button { padding: 7px 10px; }
  nav button span, .keys { display: none; }
}
