:root {
  --bg: #07080c;
  --panel: rgba(20, 22, 30, .9);
  --line: rgba(255, 255, 255, .09);
  --text: #eef0f5;
  --muted: #9aa1b3;
  --accent: #e5383b;
  --accent2: #ffb703;
  --radius: 14px;
  --px: 3px;        /* 1 pixel do GBA na tela (JS) */
  --scan: 2px;      /* distância entre scanlines, ~densidade física da tela (JS) */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  /* cor do console (desktop) */
  --shell1: #3a3d47; --shell2: #1c1e25; --shell-text: rgba(255, 255, 255, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
body {
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; touch-action: manipulation; overscroll-behavior: none;
}
button, select, input { font: inherit; color: inherit; }
a { color: var(--accent2); }
kbd {
  display: inline-block; min-width: 1.7em; padding: 0 .4em; margin: 0 .06em;
  font: 700 .78em/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: center; white-space: nowrap;
  color: var(--text); background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .18); border-bottom-width: 2px; border-radius: 6px;
}

/* ---------- fundo imersivo ---------- */
#ambient {
  position: fixed; inset: -12%; width: 124%; height: 124%; object-fit: cover; z-index: 0;
  filter: blur(56px) saturate(1.9) brightness(.6); opacity: 0; transition: opacity 1.2s ease; pointer-events: none;
}
body.ambient-on #ambient.live { opacity: 1; }
.backdrop {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(229, 56, 59, .16), transparent 60%),
    radial-gradient(90% 70% at 50% 110%, rgba(66, 84, 255, .14), transparent 60%),
    radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, .55) 100%);
}

/* ---------- estrutura ---------- */
#layout { position: fixed; inset: 0; z-index: 1; }
.side { display: none; }
.center { display: contents; }
#app { position: fixed; inset: 0; z-index: 1; display: flex; flex-direction: column; }
.stage { position: relative; flex: 1; display: grid; place-items: center; min-height: 0; padding: 24px; }
.bezel { display: contents; }
.led, .brand, .speaker { display: none; }
.screen {
  position: relative; line-height: 0; border-radius: 6px; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .65), 0 0 0 1px rgba(255, 255, 255, .06);
}
.screen canvas {
  display: block; width: calc(240 * var(--px)); height: calc(160 * var(--px));
  image-rendering: pixelated; image-rendering: crisp-edges; background: #000;
}
.screen.gba-color canvas { filter: brightness(.88) contrast(.92) saturate(.85) sepia(.06); }
.crt-overlay { position: absolute; inset: 0; pointer-events: none; }
.pause-badge {
  position: absolute; inset: 0; margin: auto; width: max-content; height: max-content; padding: 6px 16px;
  font: 800 13px/1.6 ui-monospace, monospace; letter-spacing: .3em; background: rgba(0, 0, 0, .7); border-radius: 8px;
}

/* ---------- filtros (linhas em --scan = densidade física, não o pixel do GBA) ---------- */
.screen[data-filter="scanlines"] .crt-overlay {
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, .42) 50%, rgba(0, 0, 0, 0) 100%) 0 0 / 100% var(--scan);
}
.screen[data-filter="crt"] canvas { filter: contrast(1.1) saturate(1.22) brightness(1.1); }
.screen[data-filter="crt"] .crt-overlay {
  background:
    radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, .5) 100%),
    linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, .36) 50%, rgba(0, 0, 0, 0) 100%) 0 0 / 100% var(--scan),
    linear-gradient(to right, rgba(255, 50, 50, .08) 0 33.3%, rgba(50, 255, 50, .08) 33.3% 66.6%, rgba(70, 70, 255, .08) 66.6%) 0 0 / calc(var(--scan) * 1.5) 100%;
  box-shadow: inset 0 0 calc(var(--px) * 7) rgba(0, 0, 0, .5);
}
.screen[data-filter="crt"] { box-shadow: 0 0 calc(var(--px) * 9) rgba(140, 170, 255, .16), 0 30px 80px rgba(0, 0, 0, .65); }
/* telas grandes: pixels grandes demais ficam "duros"; um leve desfoque imita o fósforo */
body.big-pixels .screen[data-filter="crt"] canvas { filter: contrast(1.1) saturate(1.22) brightness(1.12) blur(.35px); }

/* ---------- botões de canto ---------- */
.corner { position: fixed; z-index: 5; top: calc(12px + var(--sat)); right: calc(12px + var(--sar)); display: flex; gap: 8px; opacity: .55; transition: opacity .2s; }
.corner:hover, .corner:focus-within { opacity: 1; }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0; cursor: pointer;
  color: #fff; background: rgba(10, 11, 16, .45); border: 1px solid rgba(255, 255, 255, .14); border-radius: 12px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: rgba(30, 33, 45, .7); }
.icon-btn.small { width: 34px; height: 34px; border-radius: 10px; flex: 0 0 auto; }

/* toast */
.toast {
  position: fixed; z-index: 20; left: 50%; top: calc(14px + var(--sat)); transform: translateX(-50%);
  max-width: calc(100vw - 120px); padding: 8px 14px; font-size: .85rem; text-align: center;
  background: rgba(14, 15, 21, .88); border: 1px solid var(--line); border-radius: 12px; backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px); pointer-events: none; animation: toastIn .25s ease;
}
.toast.err { border-color: rgba(229, 56, 59, .6); color: #ffb3b4; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -6px); } }

/* instalar como app */
.install {
  position: fixed; z-index: 21; left: 50%; transform: translateX(-50%); top: calc(10px + var(--sat));
  width: min(440px, calc(100vw - 20px)); display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px;
  background: rgba(20, 22, 30, .95); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); animation: toastIn .3s ease;
}
.install img { border-radius: 10px; flex: 0 0 auto; }
.install-text { flex: 1; display: flex; flex-direction: column; font-size: .82rem; line-height: 1.3; }
.install-text span { color: var(--muted); }
.install-box { display: flex; flex-direction: column; gap: 8px; }

/* carregando / erro */
.boot, .error { position: fixed; inset: 0; z-index: 30; display: grid; place-content: center; justify-items: center; gap: 14px; text-align: center; padding: 24px; }
.boot { background: radial-gradient(ellipse at center, #141621, var(--bg)); color: var(--muted); }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .12); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error { background: rgba(7, 8, 12, .92); }
.error .card { max-width: 460px; padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); text-align: left; }
.error h2 { margin: 0 0 6px; }
.error p { color: var(--muted); margin: 0 0 12px; }
.error pre { max-height: 160px; overflow: auto; font-size: 12px; white-space: pre-wrap; color: #ffb3b4; -webkit-user-select: text; user-select: text; }
.error .row { display: flex; gap: 8px; margin-top: 12px; }

/* ---------- controle (comum) ---------- */
.pad { display: none; }
body.pad-on .pad { display: block; }
.key {
  appearance: none; border: 0; padding: 0; cursor: pointer; touch-action: none; color: rgba(255, 255, 255, .92);
  font: 800 1rem/1 system-ui, sans-serif; -webkit-user-select: none; user-select: none; position: relative;
  background: rgba(255, 255, 255, .11); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 4px 14px rgba(0, 0, 0, .35);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: transform .05s, background .08s, filter .08s;
}
.key.pressed { transform: scale(.93); background: rgba(255, 255, 255, .26); }
.key.round { width: 80px; height: 80px; border-radius: 50%; font-size: 1.45rem; }
.key.a { background: linear-gradient(160deg, #ec4245, #a91e22); }
.key.b { background: linear-gradient(160deg, #7a5cf0, #452ea9); }
.key.round.pressed { filter: brightness(1.35); }
.key.sh { width: 96px; height: 40px; border-radius: 12px; font-size: .92rem; }
.key.pill { padding: 10px 15px; border-radius: 999px; font-size: .68rem; letter-spacing: .1em; color: rgba(255, 255, 255, .72); }
.key.menu { width: 44px; height: 36px; border-radius: 12px; display: grid; place-items: center; }
.key.menu svg { width: 20px; height: 20px; }
.dpad { position: relative; width: 168px; height: 168px; touch-action: none; }
.dpad .arm, .dpad .hub { position: absolute; background: rgba(255, 255, 255, .12); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16); }
.dpad .arm.up, .dpad .arm.down { left: 56px; width: 56px; height: 60px; }
.dpad .arm.left, .dpad .arm.right { top: 56px; width: 60px; height: 56px; }
.dpad .arm.up { top: 0; border-radius: 12px 12px 0 0; }
.dpad .arm.down { bottom: 0; border-radius: 0 0 12px 12px; }
.dpad .arm.left { left: 0; border-radius: 12px 0 0 12px; }
.dpad .arm.right { right: 0; border-radius: 0 12px 12px 0; }
.dpad .hub { left: 56px; top: 56px; width: 56px; height: 56px; background: rgba(255, 255, 255, .09); box-shadow: none; }
.dpad .arm::after { content: ""; position: absolute; inset: 0; margin: auto; width: 0; height: 0; border: 8px solid transparent; opacity: .6; }
.dpad .up::after { border-bottom-color: #fff; border-top-width: 0; }
.dpad .down::after { border-top-color: #fff; border-bottom-width: 0; }
.dpad .left::after { border-right-color: #fff; border-left-width: 0; }
.dpad .right::after { border-left-color: #fff; border-right-width: 0; }
.dpad .arm.on { background: rgba(255, 255, 255, .34); }
.ab { display: flex; gap: 18px; align-items: center; transform: rotate(-22deg); touch-action: none; }
.ab .a { margin-bottom: 48px; }
.mid { display: flex; justify-content: center; align-items: center; gap: 14px; }

/* ===== celular em pé (estilo Delta) ===== */
body.portrait.pad-on .stage { flex: 0 0 auto; padding: var(--sat) 0 0; }
body.portrait.pad-on .screen { border-radius: 0; box-shadow: 0 18px 40px rgba(0, 0, 0, .55); }
body.portrait.pad-on .pad {
  position: relative; flex: 1; min-height: 0;
  display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto 1fr auto;
  grid-template-areas: "l r" "dpad ab" "mid mid";
  padding: 14px calc(16px + var(--sar)) calc(14px + var(--sab)) calc(16px + var(--sal));
}
body.portrait.pad-on .key.l { grid-area: l; justify-self: start; }
body.portrait.pad-on .key.r { grid-area: r; justify-self: end; }
body.portrait.pad-on .dpad { grid-area: dpad; align-self: center; justify-self: start; }
body.portrait.pad-on .ab { grid-area: ab; align-self: center; justify-self: end; margin-right: 6px; }
body.portrait.pad-on .mid { grid-area: mid; }
body.portrait.pad-on .corner { display: none; }
body.portrait.pad-on .toast { top: calc(min(66.67vw, 58vh) + var(--sat) + 70px); }
@media (max-height: 700px) {
  body.portrait.pad-on .key.round { width: 66px; height: 66px; }
  body.portrait.pad-on .dpad { transform: scale(.86); transform-origin: left center; }
  body.portrait.pad-on .ab .a { margin-bottom: 36px; }
}

/* ===== celular deitado ===== */
body.landscape.pad-on .stage { padding: 0; }
body.landscape.pad-on .screen { border-radius: 0; }
body.landscape.pad-on .pad { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
body.landscape.pad-on .pad > * { pointer-events: auto; position: absolute; opacity: .8; }
body.landscape.pad-on .key.l { top: calc(12px + var(--sat)); left: calc(14px + var(--sal)); }
body.landscape.pad-on .key.r { top: calc(12px + var(--sat)); right: calc(14px + var(--sar)); }
body.landscape.pad-on .dpad { left: calc(16px + var(--sal)); bottom: calc(18px + var(--sab)); transform: scale(.78); transform-origin: left bottom; }
body.landscape.pad-on .ab { right: calc(26px + var(--sar)); bottom: calc(28px + var(--sab)); }
body.landscape.pad-on .key.round { width: 60px; height: 60px; font-size: 1.15rem; }
body.landscape.pad-on .ab .a { margin-bottom: 36px; }
body.landscape.pad-on .key.sh { width: 78px; height: 34px; }
body.landscape.pad-on .mid { left: 50%; bottom: calc(8px + var(--sab)); transform: translateX(-50%); }
body.landscape.pad-on .corner { display: none; }
body.landscape.pad-on .toast { font-size: .78rem; }
body.landscape.pad-on .speaker { display: none; }

/* =====================================================================
   DESKTOP ("modo cinema"): tela flutuando no centro + fileira de teclas;
   configurações à esquerda, como jogar à direita
   ===================================================================== */
body.device #layout { display: grid; grid-template-columns: var(--sideL, 300px) minmax(0, 1fr) var(--sideR, 340px); }
body.device.compact #layout { grid-template-columns: minmax(0, 1fr); }
body.device.compact .side { display: none; }
body.device.medium #layout { grid-template-columns: minmax(0, 1fr) var(--sideR, 340px); }
body.device.medium .side-left { display: none; }
body.device.medium .side-right { margin-left: 0; }
body.device .side {
  display: flex; flex-direction: column; min-height: 0; overflow: hidden; margin: 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
}
body.device .side-left { margin-right: 0; }
body.device .side-right { margin-left: 0; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px 6px; font-size: 1.05rem; font-weight: 700; }
.side-brand b { color: var(--accent); }
.logo-dot { width: 14px; height: 14px; border-radius: 4px; background: var(--accent); box-shadow: 0 0 14px rgba(229, 56, 59, .6); }
#sideSettingsHost { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#sideSettingsHost .settings { flex: 1; min-height: 0; display: flex; flex-direction: column; }
body.device .tabs button[data-tab="controls"] { display: none; }
body.device.compact .tabs button[data-tab="controls"] { display: block; }
.side-right h2 { margin: 0; padding: 16px 18px 4px; font-size: 1.05rem; }
#helpHost { flex: 1; overflow-y: auto; padding: 4px 18px 18px; }

body.device .center { display: grid; place-items: center; min-width: 0; min-height: 0; padding: 24px 20px; }
body.device #app { position: relative; inset: auto; z-index: auto; display: flex; flex-direction: column; align-items: center; gap: 46px; }
body.device .stage { flex: none; padding: 0; display: block; }
body.device .pad { display: none !important; }
body.device .screen {
  border-radius: 12px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, .10),
    0 0 0 7px rgba(8, 9, 12, .65),
    0 0 0 8px rgba(255, 255, 255, .06),
    0 40px 90px rgba(0, 0, 0, .7),
    0 0 140px rgba(120, 140, 255, .14);
  -webkit-box-reflect: below 22px linear-gradient(to bottom, transparent 72%, rgba(255, 255, 255, .10));
}
body.device .screen[data-filter="crt"] {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, .10),
    0 0 0 7px rgba(8, 9, 12, .65),
    0 0 0 8px rgba(255, 255, 255, .06),
    0 40px 90px rgba(0, 0, 0, .7),
    0 0 160px rgba(140, 170, 255, .2);
}
/* título discreto acima da tela */
body.device .stage::before {
  content: "I-NINJA  ·  GBA PROTOTYPE V1-25"; position: absolute; left: 0; right: 0; top: -30px; text-align: center;
  font: 700 .7rem/1 system-ui, sans-serif; letter-spacing: .42em; color: rgba(255, 255, 255, .38);
}
body.device .corner { opacity: .7; }
body.device:not(.compact) .corner { right: calc(var(--sideR, 340px) + 28px); }
body.device:not(.compact):not(.medium) #menuBtn { display: none; }
body.device.fs #layout { grid-template-columns: minmax(0, 1fr); }
body.device.fs .side { display: none; }

/* ---------- fileira de teclas (guia vivo do teclado) ---------- */
.keystrip { display: none; }
body.device .keystrip {
  display: flex; align-items: flex-end; justify-content: center; gap: 22px; flex-wrap: wrap;
  padding: 16px 22px 14px; border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .02));
  border: 1px solid rgba(255, 255, 255, .08); box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.kgroup { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.kgroup .caps { display: grid; gap: 5px; }
.kgroup.arrows .caps { grid-template-columns: repeat(3, var(--cap)); grid-template-areas: ". up ." "left down right"; }
.kgroup .label { display: flex; align-items: center; gap: 6px; font-size: .74rem; color: rgba(255, 255, 255, .78); white-space: nowrap; }
.kgroup .label .gba {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 6px;
  font: 800 .62rem/1 system-ui; color: #fff; background: rgba(255, 255, 255, .14);
}
.kgroup .label .gba.a { background: #c9302c; border-radius: 50%; padding: 0; width: 20px; }
.kgroup .label .gba.b { background: #5a40c9; border-radius: 50%; padding: 0; width: 20px; }
:root { --cap: 46px; }
.cap {
  appearance: none; position: relative; height: var(--cap); min-width: var(--cap); padding: 0 12px 4px;
  font: 700 .9rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: #e9ebf2; cursor: pointer;
  border: 0; border-radius: 10px;
  background: linear-gradient(180deg, #353946 0%, #23262f 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), inset 0 -4px 0 rgba(0, 0, 0, .35), 0 4px 0 #0c0d11, 0 8px 16px rgba(0, 0, 0, .45);
  transition: transform .06s, box-shadow .06s, background .1s, color .1s;
}
.cap.wide { min-width: calc(var(--cap) * 1.9); font-size: .78rem; }
.cap.up { grid-area: up; } .cap.left { grid-area: left; } .cap.down { grid-area: down; } .cap.right { grid-area: right; }
.cap.pressed {
  transform: translateY(4px);
  color: #fff; background: linear-gradient(180deg, #ef4b4e, #b52326);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), inset 0 -2px 0 rgba(0, 0, 0, .3), 0 0 0 #0c0d11, 0 0 22px rgba(229, 56, 59, .65);
}
@media (max-height: 820px) { :root { --cap: 40px; } body.device #app { gap: 38px; } }

/* ---------- como jogar (painel direito / aba Controles) ---------- */
.help h3 { margin: 16px 0 8px; font-size: .74rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.help .row-btn {
  display: grid; grid-template-columns: 88px 30px 1fr; align-items: center; gap: 10px; padding: 7px 8px; margin: 0 -8px;
  border-radius: 10px; transition: background .12s;
}
.help .row-btn.lit { background: rgba(229, 56, 59, .18); }
.help .row-btn .gba {
  display: grid; place-items: center; width: 30px; height: 26px; border-radius: 8px; font: 800 .7rem/1 system-ui;
  background: rgba(255, 255, 255, .1); color: #fff;
}
.help .gba.a { background: #c9302c; border-radius: 50%; width: 26px; }
.help .gba.b { background: #5a40c9; border-radius: 50%; width: 26px; }
.help .row-btn .what { font-size: .86rem; line-height: 1.3; }
.help .row-btn .what small { display: block; color: var(--muted); font-size: .76rem; }
.help .keys2 { display: flex; flex-wrap: nowrap; gap: 2px; }
.help .keys2 kbd { min-width: 1.45em; padding: 0 .25em; }
.help .mini { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: .84rem; align-items: center; }
.help .mini .gba { display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 6px; border-radius: 7px; font: 800 .66rem/1 system-ui; background: rgba(255, 255, 255, .1); }
.help .tip { margin: 6px 0 0; font-size: .8rem; color: var(--muted); }
.help .hk { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; font-size: .84rem; align-items: center; }

/* ---------- configurações (painel / folha) ---------- */
.sheet {
  width: min(520px, calc(100vw - 24px)); max-height: min(86vh, 760px); padding: 0; margin: auto;
  color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 40px 120px rgba(0, 0, 0, .7); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  overflow: hidden; flex-direction: column;
}
.sheet[open] { display: flex; }
.sheet::backdrop { background: rgba(0, 0, 0, .45); backdrop-filter: blur(3px); }
@media (max-width: 600px) {
  .sheet { width: 100vw; max-width: 100vw; max-height: 88vh; margin: auto 0 0; border-radius: 20px 20px 0 0; border-bottom: 0; padding-bottom: var(--sab); }
}
#sheetSettingsHost { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#sheetSettingsHost .settings { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 8px 18px; }
.sheet-head h2 { margin: 0; flex: 1; font-size: 1.05rem; letter-spacing: .02em; }
.sheet-head h2 span { color: var(--accent); }
.tabs { display: flex; padding: 0 8px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; flex: 0 0 auto; }
.tabs button {
  flex: 1; padding: 10px 8px; background: none; border: 0; border-bottom: 2px solid transparent; outline: none;
  color: var(--muted); font-weight: 600; font-size: .86rem; cursor: pointer; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs button:focus-visible { color: var(--text); }
.panel { padding: 14px 18px 20px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; min-height: 0; }
.panel h3 { margin: 8px 0 0; font-size: .74rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.note { margin: 0; color: var(--muted); font-size: .84rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 12px; font-weight: 600; font-size: .9rem; color: var(--text); cursor: pointer;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .12); border-radius: 11px;
}
.btn:hover { background: rgba(255, 255, 255, .1); }
.btn.primary { background: var(--accent); border-color: #ff6164; color: #fff; }
.btn.on { background: rgba(88, 114, 176, .35); border-color: #5872b0; }
.btn.small { padding: 7px 11px; font-size: .84rem; }
.btn.file { position: relative; overflow: hidden; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-row input { flex: 1; accent-color: var(--accent); }
select { width: 100%; padding: 9px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .14); border-radius: 10px; }
select option { background: #1a1c25; }
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.slots label { text-align: center; padding: 7px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.slots label:has(input:checked) { border-color: var(--accent); background: rgba(229, 56, 59, .14); }
.slots input, .seg input, .swatches input { display: none; }
.choices { display: flex; flex-direction: column; gap: 6px; }
.choices label { display: grid; grid-template-columns: auto auto 1fr; align-items: baseline; gap: 8px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.choices.compact label { display: flex; align-items: center; }
.choices label:has(input:checked) { border-color: rgba(229, 56, 59, .7); background: rgba(229, 56, 59, .09); }
.choices span { color: var(--muted); font-size: .8rem; text-align: right; }
.choices.compact span { color: var(--text); font-size: .88rem; text-align: left; }
.choices input { accent-color: var(--accent); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; background: rgba(255, 255, 255, .05); border-radius: 11px; }
.seg label { text-align: center; padding: 7px; border-radius: 9px; cursor: pointer; font-size: .88rem; }
.seg label:has(input:checked) { background: rgba(255, 255, 255, .14); }
body.device .touch-only { display: none; }
.toggles { display: flex; flex-direction: column; gap: 8px; }
.toggle { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; }
.toggle b { display: block; font-size: .92rem; }
.toggle small { color: var(--muted); }
.switch { position: relative; width: 42px; height: 24px; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; background: rgba(255, 255, 255, .16); border-radius: 99px; transition: background .15s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }
.console { margin: 0; max-height: 200px; overflow: auto; padding: 10px; background: #0a0b0e; border: 1px solid var(--line); border-radius: 10px; font: 12px/1.45 ui-monospace, Menlo, monospace; color: #b8f2c9; white-space: pre-wrap; -webkit-user-select: text; user-select: text; }
.fixes { margin: 0; padding-left: 18px; color: var(--muted); font-size: .86rem; display: flex; flex-direction: column; gap: 6px; }
.fixes b { color: var(--text); }
.version { font-size: .75rem; opacity: .7; }
