.toolbar { margin: 18px 0 10px; gap: 10px 14px; font-size: 14px; align-items: center; }
.toolbar button, .toolbar .btn { font: inherit; font-size: 14px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--fg); cursor: pointer; text-decoration: none; }
.toolbar button:disabled { opacity: 0.5; cursor: not-allowed; }
.toolbar button.go { background: #d2491f; border-color: #d2491f; color: #fff; }
.ctl { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }
.ctl small { opacity: 0.8; }
.stage-xr { scroll-margin-top: 64px; position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #0d0f14; aspect-ratio: 16 / 10; }
.stage-xr canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.hud { position: absolute; left: 10px; bottom: 8px; font: 11px/1.5 var(--mono); color: #cfd6e4; pointer-events: none; white-space: pre; text-shadow: 0 1px 2px #000; }

/* Emulator controls, shown above the full-screen emulated view. */
.emu-bar { position: fixed; left: 50%; top: 10px; transform: translateX(-50%); z-index: 2147483647; display: flex; gap: 6px; align-items: center; padding: 6px 8px; border-radius: 10px; background: #10131ae6; color: #e8ebf2; font: 13px system-ui, sans-serif; max-width: calc(100vw - 16px); }
.emu-bar button { font: inherit; padding: 7px 12px; border-radius: 7px; border: 1px solid #39415a; background: #1a1e29; color: inherit; cursor: pointer; }
.emu-bar span { padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Without the API the panels stay in the page as an ordinary stack. */
.uis { display: grid; gap: 16px; margin-top: 16px; }
.uis:empty { display: none; }
.uis .xp { max-width: 100%; overflow: auto; border-radius: 12px; }

/* ---------- Panels. Fixed pixel sizes: 600px is one metre. ---------- */
.xp { box-sizing: border-box; display: flex; flex-direction: column; background: #151924; color: #e8ebf2; font: 18px/1.35 system-ui, -apple-system, 'Segoe UI', sans-serif; border: 2px solid #2c3242; border-radius: 0; }
.xp * { box-sizing: border-box; }
.xp button, .xp input, .xp select, .xp textarea { font: inherit; }
.xp :focus-visible { outline: 3px solid #ffb199; outline-offset: 1px; }
.xp [data-ray-hover] { outline: 3px solid #7ad7ff; outline-offset: 1px; }
.xp > header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 10px 16px; background: #1e2433; border-bottom: 1px solid #2c3242; font-size: 17px; flex: none; }
.xp > header time, .xp > header span { font: 14px ui-monospace, Menlo, monospace; color: #9aa3b8; }

.form { width: 560px; height: 380px; }
.form .cols { flex: 1; display: grid; grid-template-columns: 1.15fr 1fr; gap: 18px; padding: 14px 16px; min-height: 0; }
.form label { display: block; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: #9aa3b8; margin: 0 0 4px; }
.form input[type=text], .form textarea, .form select { width: 100%; padding: 9px 10px; border: 1px solid #39415a; border-radius: 7px; background: #0d1016; color: inherit; margin-bottom: 12px; }
.form textarea { resize: none; height: 150px; }
.form input[type=range] { width: 100%; height: 26px; margin: 2px 0 12px; accent-color: #ff7a4d; }
.form .check { display: flex; gap: 10px; align-items: center; text-transform: none; font-weight: 400; font-size: 17px; letter-spacing: 0; color: inherit; margin-bottom: 14px; }
.form .check input { width: 22px; height: 22px; accent-color: #ff7a4d; }
.form button { width: 100%; padding: 12px; border: 0; border-radius: 8px; background: #d2491f; color: #fff; font-weight: 600; cursor: pointer; }
.form button:hover { background: #b33a14; }

.log { width: 480px; height: 380px; }
.log .scroll { flex: 1; min-height: 0; overflow: auto; margin: 0; padding: 6px 16px 6px 44px; }
.log li { padding: 6px 0; border-bottom: 1px solid #262c3a; overflow-wrap: anywhere; }
.log li b { color: #ffb199; }
.log li small { display: block; font: 13px ui-monospace, Menlo, monospace; color: #8b94a8; }
.log li.new { animation: xr-flash 1.4s ease-out; }
@keyframes xr-flash { from { background: #d2491f; } to { background: transparent; } }
.log footer { display: flex; align-items: center; gap: 12px; padding: 8px 16px; border-top: 1px solid #2c3242; font-size: 14px; color: #8b94a8; flex: none; }
.log footer button { padding: 6px 14px; border-radius: 7px; border: 1px solid #39415a; background: #0d1016; color: #e8ebf2; cursor: pointer; }

.stats { width: 480px; height: 380px; font-size: 15px; }
.stats dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; padding: 10px 16px 6px; font: 14px/1.4 ui-monospace, Menlo, monospace; flex: none; }
.stats dt { color: #9aa3b8; }
.stats dd { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats ul { flex: 1; min-height: 0; overflow: auto; margin: 0; padding: 6px 16px 8px; list-style: none; border-top: 1px solid #2c3242; font-size: 14px; }
.stats li { padding: 2px 0; }
.stats li.pass::before { content: '✓ '; color: #7be08f; }
.stats li.fail::before { content: '✗ '; color: #ff8a7a; }

.keys { width: 760px; height: 262px; padding: 10px; gap: 6px; background: #10131a; user-select: none; }
.keys .krow { flex: 1; display: flex; gap: 6px; justify-content: center; }
.keys button { flex: 1 1 0; min-width: 0; border: 1px solid #39415a; border-radius: 8px; background: #1e2433; color: #e8ebf2; font-size: 20px; cursor: pointer; padding: 0; touch-action: manipulation; }
.keys button:active, .keys button.down { background: #d2491f; }
.keys button.wide { flex: 1.6 1 0; font-size: 16px; }
.keys button.space { flex: 6 1 0; }
.keys button[aria-pressed="true"] { background: #7ad7ff; color: #07080c; }

@media (max-width: 620px) {
  .stage-xr { aspect-ratio: 4 / 5; }
}
.emu-bar[hidden] { display: none; }
