/*
  UI-only stylesheet for the browser host. No changes to emulator behavior.
  Keeps existing element IDs intact and styles via classes.
*/

:root {
  --bg: #0b0f14;
  --panel: #0f1620;
  --panel-2: #121a25;
  --text: #e6edf3;
  --muted: #9fb0c3;
  --brand: #6ba8ff;
  --accent: #2f81f7;
  --border: #233044;
  --ring: rgba(47,129,247,0.4);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.4 system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(1200px 800px at 20% 0%, #0d131d, var(--bg));
  color: var(--text);
}

.visually-hidden { position: absolute !important; inset: -9999px auto auto -9999px; width: 1px; height: 1px; overflow: hidden; }

.app { min-height: 100%; display: grid; grid-template-rows: auto 1fr auto; }

.toolbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(17,24,39,0.8), rgba(17,24,39,0.6));
  backdrop-filter: blur(8px);
}
.brand { display: grid; grid-template-columns: auto auto; grid-auto-rows: auto; column-gap: 10px; align-items: center; }
.logo { width: 22px; height: 22px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; color: var(--brand); font-weight: 700; }
.title { margin: 0; font-size: 16px; letter-spacing: 0.3px; }
.subtitle { grid-column: 2; margin-top: -2px; font-size: 12px; color: var(--muted); }

.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pad-ind { margin-left: 4px; font-size: 12px; }

.btn { appearance: none; border: 1px solid var(--border); color: var(--text); background: var(--panel-2); padding: 8px 12px; border-radius: 8px; cursor: pointer; transition: border-color 120ms ease, transform 50ms ease;
  user-select: none; font: inherit; }
.btn:hover { border-color: #35507a; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, #2b4e7d, #243d61); border-color: #3c5b8f; color: #eef6ff; }
.btn.ghost { background: transparent; }
.btn.icon { padding: 6px 8px; line-height: 1; }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }
.btn:focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--ring); }

.layout { display: grid; grid-template-columns: 1fr 320px; gap: 16px; padding: 16px; }
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; } }

.panel { background: linear-gradient(180deg, var(--panel), #0d141d); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.25); }

.screen-panel { display: grid; place-items: center; padding: 16px; }
.screen-wrap { background: #000; padding: 8px; border-radius: 8px; border: 1px solid #000; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04); }

/* Crisp pixel scaling */
#screen { image-rendering: optimizeSpeed; image-rendering: pixelated; image-rendering: -moz-crisp-edges; image-rendering: crisp-edges; -ms-interpolation-mode: nearest-neighbor; display: block; width: 512px; height: 480px; }
@media (max-width: 960px) { #screen { width: 384px; height: 360px; } }

.controls { padding: 16px; display: grid; gap: 14px; align-content: start; }
.info-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: linear-gradient(180deg, rgba(16,22,33,0.8), rgba(12,18,27,0.8)); box-shadow: inset 0 1px 0 rgba(255,255,255,0.03); }
.info-card .info-header { font-weight: 600; margin-bottom: 8px; color: var(--text); }
.info-card .info-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; }
.info-card .k { color: var(--muted); }
.info-card .v { color: var(--text); }
.control-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.control-label { width: 64px; color: var(--muted); }
.toggles { display: grid; grid-template-columns: 1fr; gap: 8px; }
.toggles label { display: flex; align-items: center; gap: 8px; }

input[type="range"] { width: 160px; accent-color: var(--accent); }
select#scale-control { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; }
.fit-toggle { display: inline-flex; align-items: center; gap: 8px; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

.note { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }

.status-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--border); background: linear-gradient(0deg, rgba(13,20,29,0.9), rgba(13,20,29,0.7)); }
.status-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; }
.status-text { color: var(--text); }

/* Dropzone */
.dropzone { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(11, 15, 20, 0.55); backdrop-filter: blur(2px); }
.dropzone.hidden { display: none; }
.drop-card { display: grid; gap: 6px; place-items: center; padding: 18px 22px; border-radius: 12px; border: 1px dashed var(--border); background: rgba(18, 26, 37, 0.85); color: var(--text); box-shadow: 0 10px 30px rgba(0,0,0,0.25); }
.drop-icon { font-size: 24px; line-height: 1; opacity: 0.9; }
.drop-text { font-weight: 600; }
.drop-hint { color: var(--muted); font-size: 12px; }

/* Modal */
.modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(3, 10, 18, 0.6); backdrop-filter: blur(3px); }
.modal.hidden { display: none; }
.modal-card { width: min(560px, calc(100vw - 32px)); border-radius: 12px; border: 1px solid var(--border); background: linear-gradient(180deg, var(--panel), #0d141d); box-shadow: 0 20px 50px rgba(0,0,0,0.35); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 12px; display: grid; gap: 10px; }
.kbd-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
@media (max-width: 520px) { .kbd-list { grid-template-columns: 1fr; } }
.kbd { display: inline-block; min-width: 22px; text-align: center; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--border); background: #0e1520; box-shadow: inset 0 -2px 0 rgba(255,255,255,0.03); }

