/* NEXO · cliente web (celular y PC): estructura común.
   Un solo DOM para las cinco apariencias: este archivo pone la forma y el reparto de espacio; cada tema
   (ui/temas/<id>.css) define las variables de color y retoca las formas que necesite.
   Variables fijas del contrato: --bg --sup --sup2 --bd --tx --su --ac --ac-tx --ok --av --ml --r --rg --f-t --f-c --f-n --sh.
   Aquí también viven los valores por defecto, para que la página sea usable aunque un tema no cargue. */

:root {
  --bg: #f1f1f6; --sup: #ffffff; --sup2: #e8e8ee; --bd: #d3d3db; --tx: #0c0c10; --su: #62626c;
  --ac: #0a68f5; --ac-tx: #ffffff; --ok: #1a8f45; --av: #b36b00; --ml: #cf2f25;
  --r: 10px; --rg: 16px; --f-t: system-ui, sans-serif; --f-c: system-ui, sans-serif; --f-n: ui-monospace, "Cascadia Mono", monospace;
  --sh: none; --bw: 1px; --foco: var(--ac); --stage: #05070a; --velo: rgba(0, 0, 0, .5);
  --hud: color-mix(in srgb, var(--sup) 90%, transparent); --barra-alto: 56px;
}
[data-modo="oscuro"] { color-scheme: dark; }
[data-modo="claro"] { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
html { background: var(--bg); }
body {
  font: 15px/1.4 var(--f-c); color: var(--tx); background: var(--bg);
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
.i { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--foco); outline-offset: 2px; }
.luz { width: 10px; height: 10px; border-radius: 50%; background: var(--su); flex: none; display: inline-block; }
.luz.ok, .ok > .luz { background: var(--ok); }
.luz.av, .wait > .luz { background: var(--av); }
.luz.ml, .bad > .luz { background: var(--ml); }

/* ---------- marcas: cada tema muestra la suya; Rey Muerto, la corona en pixel art ---------- */
.mk { width: 28px; height: 28px; flex: none; color: var(--ac); }
.mk use { display: none; }
[data-tema="cabina"] .mk .m-cabina, [data-tema="nativa"] .mk .m-nativa, [data-tema="cianotipo"] .mk .m-cianotipo, [data-tema="bloque"] .mk .m-bloque { display: inline; }
.mk-txt { font: 700 20px var(--f-t); letter-spacing: .01em; }
.firma, .firma-pie, .rey, .lapiz { display: none; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em; min-height: 46px; padding: 0 18px;
  background: var(--sup); color: var(--tx); border: var(--bw) solid var(--bd); border-radius: var(--r); font-weight: 600; white-space: nowrap;
  box-shadow: var(--sh);
}
.btn.pri { background: var(--ac); color: var(--ac-tx); border-color: var(--ac); }
.btn.txt { background: transparent; border-color: transparent; color: var(--ac); box-shadow: none; }
.btn.grande { min-height: 54px; width: 100%; font-size: 17px; }
.btn:disabled { opacity: .5; }

/* ================= PORTAL: emparejar y elegir ================= */
#session-gate {
  position: fixed; inset: 0; z-index: 30; overflow: auto; display: flex; justify-content: center;
  padding: max(22px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
  background: var(--bg); isolation: isolate;
}
#session-gate::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.gate-card { position: relative; width: min(520px, 100%); min-height: 100%; margin: auto; display: flex; flex-direction: column; gap: 18px; }
.portal-marca { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.portal-marca .mk-txt { font-size: 22px; }
.portal-marca .firma { margin-left: auto; font-size: 12px; color: var(--su); letter-spacing: .08em; }
.portal-vista { display: flex; flex-direction: column; gap: 14px; flex: 1; min-width: 0; }
.portal-vista[hidden] { display: none; }
.portal-vista h1 { font: 700 30px/1.1 var(--f-t); }
.portal-vista .sub, .gate-sub { color: var(--su); }
.portal-vista .sub b { color: var(--tx); font-weight: 700; }
.nota { font-size: 13px; color: var(--su); text-align: center; }
#pair-form .btn.grande { margin-top: auto; }
.login-error { min-height: 1.3em; font-size: 13px; color: var(--ml); }
.gate-status { min-height: 1.4em; font-size: 13px; color: var(--su); }

.cod { position: relative; margin: 6px 0 0; }
.cod input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; z-index: 1; border: 0; background: none; font-size: 16px; }
.casillas { display: flex; gap: 6px; align-items: center; pointer-events: none; }
.casillas i {
  flex: 1; min-width: 0; height: 58px; display: grid; place-items: center; font: 600 24px var(--f-n); font-style: normal;
  background: var(--sup); border: var(--bw) solid var(--bd); border-radius: var(--r);
}
.casillas i.act { border-color: var(--ac); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ac) 24%, transparent); }
.casillas em { color: var(--su); font-style: normal; font-size: 22px; padding: 0 2px; }
.cod:focus-within .casillas i.act { border-color: var(--foco); }

.session-grid { display: grid; gap: 12px; }
.session-choice {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%; min-height: 76px; padding: 14px;
  background: var(--sup); color: var(--tx); border: var(--bw) solid var(--bd); border-radius: var(--rg); box-shadow: var(--sh);
}
.session-choice .tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.session-choice strong { font: 700 18px var(--f-t); }
.session-choice .tx span { color: var(--su); font-size: 13px; }
.session-choice > .i { color: var(--ac); width: 28px; height: 28px; }
.session-choice:disabled { opacity: .55; }
.session-choice.original { flex-direction: column; align-items: stretch; gap: 12px; }
.session-choice .mini {
  aspect-ratio: 16 / 9; border-radius: calc(var(--r) - 2px); overflow: hidden; border: var(--bw) solid var(--bd);
  display: grid; place-items: center; background: var(--sup2); color: var(--su);
}
.session-choice .mini .i { width: 46px; height: 46px; }
.session-choice .mini img { width: 100%; height: 100%; object-fit: cover; display: block; }
.session-choice .fila { display: flex; align-items: center; gap: 10px; }
.session-choice .fila .luz { margin-left: auto; width: 12px; height: 12px; }
#original-login { display: grid; gap: 10px; padding-top: 6px; }
#original-login input {
  min-width: 0; min-height: 50px; padding: 0 14px; background: var(--sup); color: var(--tx);
  border: var(--bw) solid var(--bd); border-radius: var(--r); font-size: 16px;
}
#original-login input:focus { border-color: var(--foco); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--foco) 25%, transparent); }
@media (min-width: 700px) {
  #session-gate { align-items: center; }
  .gate-card { min-height: 0; padding: 30px; background: var(--sup); border: var(--bw) solid var(--bd); border-radius: calc(var(--rg) + 4px); box-shadow: var(--sh); }
  .session-choice, .casillas i { background: var(--bg); }
}
@media (max-height: 520px) and (orientation: landscape) {
  .gate-card { width: min(720px, 100%); gap: 12px; }
  .session-choice.original { flex-direction: row; align-items: center; }
  .session-choice.original .mini { width: 190px; flex: none; }
  .session-choice.original .fila { flex: 1; }
  .portal-vista h1 { font-size: 24px; }
  .portal-vista { gap: 10px; }
}

/* ================= SESIÓN REMOTA ================= */
#stage { position: fixed; inset: 0; z-index: 1; display: grid; place-items: center; touch-action: none; user-select: none; background: var(--stage); cursor: default; overflow: hidden; }
#remote-surface { position: absolute; inset: 0; transform-origin: center; will-change: transform; pointer-events: none; }
#touch-cursor { position: absolute; width: 20px; height: 20px; border: 2px solid white; border-radius: 50%; background: #1118; box-shadow: 0 0 0 1px #111; transform: translate(-50%,-50%); pointer-events: none; z-index: 2; }
.sensibilidad { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 12px; }
.sensibilidad select { min-height: 44px; background: var(--sup2); color: var(--tx); border: 1px solid var(--bd); border-radius: var(--r); padding: 6px; }
body.computer-mode #view-reset,body.computer-mode .sensibilidad { display: none; }
@media (orientation:landscape) and (max-height:600px) {
  body.mobile-mode .tools { bottom: max(6px,env(safe-area-inset-bottom)); padding: 4px; gap: 3px; }
  body.mobile-mode .tools > button { min-width: 64px; height: 44px; flex-direction: row; font-size: 12px; gap: 5px; }
  body.mobile-mode .top { top: max(5px,env(safe-area-inset-top)); }
  body.mobile-mode .pill,body.mobile-mode .chip { min-height: 28px; font-size: 11px; }
  body.mobile-mode .help { display: none; }
}
#screen, #rtc-video, #gpu-video { display: block; position: absolute; left: 50%; top: 50%; width: 100%; height: 100%; object-fit: contain; pointer-events: none; transform-origin: center; }
#rtc-video, #gpu-video { visibility: hidden; }
body.rtc-direct #rtc-video { visibility: visible; }
body.rtc-direct #screen { visibility: hidden; }
body.gpu-direct #rtc-video { visibility: hidden; }
body.gpu-direct #gpu-video { visibility: visible; }

/* HUD: el estado con palabras y el monitor, arriba */
.top {
  position: fixed; z-index: 3; left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top));
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px; pointer-events: none; transition: opacity .22s, visibility 0s;
}
.top > * { pointer-events: auto; }
.marca-m { display: none; align-items: center; gap: 8px; color: var(--tx); }
.marca-m .mk-txt { font-size: 18px; }
.pill, .chip {
  display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 12px; max-width: 100%;
  background: var(--hud); color: var(--tx); border: var(--bw) solid var(--bd); border-radius: 99px; font-size: 13px; font-weight: 600;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.pill .est { font-weight: 700; white-space: nowrap; }
.pill .met { font-family: var(--f-n); font-weight: 500; color: var(--su); white-space: nowrap; }
.pill .met::before { content: "·"; margin-right: 7px; opacity: .6; }
.chip { position: relative; }
.chip::after { content: ""; position: absolute; inset: -6px -2px; }
.chip .i { width: 18px; height: 18px; }
#monitor { margin-left: auto; }
.chip.encendido { color: var(--ml); border-color: var(--ml); }
.top, .tools, .help { transition: opacity .22s, visibility 0s; }
body.ui-hidden .top, body.ui-hidden .tools, body.ui-hidden .help { opacity: 0; visibility: hidden; transition: opacity .22s, visibility 0s .22s; }

/* Barra de cinco acciones: Teclado, Mover, Sonido, Micrófono, Más */
.tools {
  position: fixed; z-index: 4; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; gap: 6px; padding: 6px; max-width: calc(100vw - 16px);
  background: var(--hud); border: var(--bw) solid var(--bd); border-radius: var(--rg); box-shadow: var(--sh);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.tools > button {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-width: 68px; height: 58px; padding: 0 6px; border-radius: var(--r); background: transparent; color: var(--su);
  font-size: 12px; font-weight: 600; line-height: 1.1; white-space: nowrap;
}
.tools > button .i { width: 22px; height: 22px; }
.tools > button.on { background: var(--sup2); color: var(--tx); }
#touch-mode .drag-shape { display: none; }
#touch-mode.drag .nav-shape { display: none; }
#touch-mode.drag .drag-shape { display: block; }
body.computer-mode #touch-mode { display: none; }
body.mobile-mode #windows-bridge { display: none !important; }
#mic .mic-tachado { opacity: 0; stroke: var(--ml); }
#mic.mudo .mic-tachado { opacity: 1; }
#mic.mudo { color: var(--ml); }
#mic.conectando { animation: latido 1.3s ease-in-out infinite; }
/* La barra de nivel es la única prueba, sin mirar la PC, de que la voz sale de verdad. */
#mic-nivel { position: absolute; left: 10px; right: 10px; bottom: 4px; height: 3px; border-radius: 3px; background: var(--ok); transform: scaleX(0); transform-origin: left; opacity: 0; transition: transform .1s linear, opacity .2s; }
#mic.grabando:not(.mudo) #mic-nivel { opacity: .9; }
@keyframes latido { 50% { opacity: .5; } }
@media (max-width: 520px) {
  .tools { left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); transform: none; max-width: none; }
  .tools > button { flex: 1; min-width: 0; }
}

/* Modo computadora: barra de arriba con marca, estado y acciones; la pantalla ocupa el resto */
body.computer-mode .top {
  left: 0; right: 0; top: 0; height: var(--barra-alto); padding: 0 14px; flex-wrap: nowrap; gap: 12px;
  background: var(--hud); border-bottom: var(--bw) solid var(--bd); pointer-events: auto;
}
body.computer-mode .marca-m { display: inline-flex; }
body.computer-mode #monitor { margin-left: 0; }
body.computer-mode .tools {
  top: 0; right: 12px; left: auto; bottom: auto; transform: none; height: var(--barra-alto); padding: 0; gap: 4px; align-items: center;
  background: transparent; border: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; max-width: none;
}
body.computer-mode .tools > button { flex-direction: row; gap: 8px; height: 40px; min-width: 0; flex: none; padding: 0 12px; font-size: 13.5px; }
body.computer-mode .tools > button .i { width: 20px; height: 20px; }
body.computer-mode .tools .mas-txt { display: none; }
body.computer-mode #mic-nivel { left: 12px; right: 12px; bottom: 3px; }
body.computer-mode #stage { top: var(--barra-alto); }
body.computer-mode.ui-hidden #stage, body.computer-mode.fullscreen-session:not(.fullscreen-controls) #stage { top: 0; }
body.computer-mode .pill .est { font-size: 13px; }
/* Se reservan juntos el estado, el monitor y las seis acciones. Con etiquetas
   completas se solapaban a 1280 px, aun sin aparecer scroll horizontal. */
@media (max-width: 1360px) { body.computer-mode .tools > button span { display: none; } body.computer-mode .tools > button { width: 40px; padding: 0; justify-content: center; } }
@media (max-width: 720px) { body.computer-mode .marca-m .mk-txt, body.computer-mode #met-res, body.computer-mode #monitor-label { display: none; } }
@media (max-width: 520px) { body.computer-mode #met-rtt { display: none; } }
@media (max-width: 520px) { .pill .met#met-res { display: none; } }

#ui-toggle {
  position: fixed; right: 0; top: 50%; transform: translateY(-50%); z-index: 8; width: 38px; height: 68px; padding: 0;
  display: grid; place-items: center; background: var(--sup); color: var(--tx); border: var(--bw) solid var(--bd); border-right: 0;
  border-radius: 16px 0 0 16px; opacity: 0; pointer-events: none; transition: opacity .22s; box-shadow: var(--sh);
}
body.ui-hidden #ui-toggle { opacity: .7; pointer-events: auto; }
body.ui-hidden #ui-toggle:hover, body.ui-hidden #ui-toggle:focus-visible { opacity: 1; }
body.fullscreen-session { background: #000; }
body.fullscreen-session #stage { background: #000; }
body.fullscreen-session.computer-mode:not(.fullscreen-controls) .top,
body.fullscreen-session.computer-mode:not(.fullscreen-controls) .tools,
body.fullscreen-session.computer-mode:not(.fullscreen-controls) .help { opacity: 0; visibility: hidden; }
body.fullscreen-session.computer-mode:not(.fullscreen-controls) #ui-toggle { opacity: .4; pointer-events: auto; }

.help {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 3;
  max-width: calc(100vw - 24px); padding: 8px 14px; background: var(--hud); border: var(--bw) solid var(--bd); border-radius: 99px;
  font-size: 12px; color: var(--su); text-align: center; pointer-events: none; transition: opacity .5s;
}
body.computer-mode .help { bottom: 18px; }
.toast {
  position: fixed; left: 50%; top: calc(max(10px, env(safe-area-inset-top)) + 52px); transform: translateX(-50%); z-index: 40;
  max-width: min(92vw, 520px); padding: 10px 16px; background: var(--sup); color: var(--tx); border: var(--bw) solid var(--bd);
  border-radius: var(--r); font-size: 13.5px; text-align: center; opacity: 0; transition: opacity .2s; pointer-events: none; box-shadow: 0 8px 28px rgba(0, 0, 0, .3);
}
.toast.show { opacity: 1; }
body.computer-mode .toast { top: calc(var(--barra-alto) + 14px); }

/* Avisos: ayudante de atajos y pantalla protegida de Windows */
#desktop-assist, #secure-banner, #fallback-banner {
  position: fixed; left: 50%; transform: translateX(-50%); max-width: min(660px, calc(100vw - 24px));
  top: calc(max(10px, env(safe-area-inset-top)) + 52px); display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--sup); color: var(--tx); border: var(--bw) solid var(--ac); border-radius: var(--rg); font-size: 13px; box-shadow: 0 12px 36px rgba(0, 0, 0, .35);
}
body.computer-mode #desktop-assist, body.computer-mode #secure-banner, body.computer-mode #fallback-banner { top: calc(var(--barra-alto) + 12px); }
#desktop-assist { z-index: 18; }
#desktop-assist span, #fallback-banner span { min-width: 0; flex: 1; }
#fallback-banner { z-index: 19; }
#fallback-banner button { flex: none; min-height: 40px; padding: 0 14px; border-radius: var(--r); background: var(--sup2); color: var(--tx); font-weight: 700; font-size: 13px; }
#desktop-assist a, #desktop-assist button { flex: none; display: inline-grid; place-items: center; min-height: 40px; padding: 0 14px; border-radius: var(--r); background: var(--ac); color: var(--ac-tx); text-decoration: none; font-weight: 700; font-size: 13px; }
#desktop-assist button { background: var(--sup2); color: var(--tx); }
#secure-banner { z-index: 22; border-color: var(--ml); text-align: center; justify-content: center; }
@media (max-width: 620px) { #desktop-assist { flex-wrap: wrap; justify-content: center; text-align: center; } #desktop-assist span { flex-basis: 100%; } }

/* ---------- Hoja «Más» ---------- */
.velo { position: fixed; inset: 0; z-index: 9; background: var(--velo); opacity: 0; transition: opacity .22s; }
body.mas-abierta .velo { opacity: 1; }
.hoja {
  position: fixed; z-index: 10; left: 50%; bottom: 0; width: min(620px, 100%); max-height: calc(100dvh - 20px); overflow: auto;
  transform: translate(-50%, 104%); transition: transform .26s cubic-bezier(.2, .8, .2, 1);
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px;
  background: var(--sup); color: var(--tx); border: var(--bw) solid var(--bd); border-bottom: 0; border-radius: 22px 22px 0 0; box-shadow: 0 -16px 48px rgba(0, 0, 0, .4);
}
body.mas-abierta .hoja { transform: translate(-50%, 0); }
.asa { width: 42px; height: 4px; border-radius: 3px; background: var(--bd); align-self: center; flex: none; }
.hoja-cab { display: flex; align-items: center; justify-content: space-between; }
.hoja-cab h2 { font: 700 19px var(--f-t); }
.cerrar { width: 44px; height: 44px; margin: -6px -8px -6px 0; display: grid; place-items: center; border-radius: var(--r); color: var(--su); }
.rej { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rej > button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; min-height: 76px; padding: 10px 4px;
  background: var(--sup2); border: var(--bw) solid transparent; border-radius: var(--r); font-size: 12.5px; font-weight: 600; line-height: 1.15; color: var(--tx);
}
.rej > button .i { width: 22px; height: 22px; color: var(--ac); }
.rej > button small { display: block; font-size: 11.5px; font-weight: 500; color: var(--su); margin-top: 1px; }
.rej > button.active { border-color: var(--ac); }
.grupo { display: flex; flex-direction: column; gap: 8px; }
.grupo-t { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--su); }
.calidad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--sup2); border-radius: var(--r); }
.calidad button { min-height: 46px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: calc(var(--r) - 3px); color: var(--su); font-size: 13px; line-height: 1.15; }
.calidad button b { font-weight: 700; color: inherit; }
.calidad button small { font-size: 11px; opacity: .8; }
.calidad button.on { background: var(--bg); color: var(--tx); box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.opciones { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.opciones button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 2px; min-height: 76px; border: var(--bw) solid transparent; border-radius: var(--r); font-size: 11.5px; font-weight: 600; color: var(--su); background: var(--sup2); }
.opciones button.on { border-color: var(--ac); color: var(--tx); }
.muestra { width: 100%; max-width: 54px; aspect-ratio: 4 / 3; border-radius: 6px; background: var(--bg); border: 1px solid var(--bd); padding: 5px; display: flex; flex-direction: column; gap: 3px; }
.muestra i { display: block; height: 4px; border-radius: 2px; background: var(--sup2); }
.muestra i:first-child { width: 60%; background: var(--ac); }
.muestra i:nth-child(2) { background: var(--tx); opacity: .7; width: 85%; }
hr.cadena { border: 0; height: 1px; margin: 2px 0; background: var(--bd); width: 100%; }
body.computer-mode .hoja {
  left: auto; right: 12px; top: calc(var(--barra-alto) + 8px); bottom: auto; width: 440px; max-height: calc(100dvh - var(--barra-alto) - 24px);
  transform: translateY(-10px); opacity: 0; pointer-events: none; border: var(--bw) solid var(--bd); border-radius: var(--rg); padding-bottom: 18px;
  transition: transform .2s, opacity .2s;
}
body.computer-mode.mas-abierta .hoja { transform: none; opacity: 1; pointer-events: auto; }
body.computer-mode .velo { background: transparent; }
body.computer-mode .asa { display: none; }
body.computer-mode .rej { grid-template-columns: repeat(3, 1fr); }
@media (orientation: landscape) and (max-height: 520px) {
  body.mobile-mode .hoja { width: min(820px, 100% - 24px); padding-top: 8px; gap: 8px; }
  body.mobile-mode .rej { grid-template-columns: repeat(7, 1fr); }
  body.mobile-mode .rej > button { min-height: 66px; font-size: 11.5px; }
  body.mobile-mode .rej > button span { overflow-wrap: anywhere; }
}

/* ---------- Teclado remoto ---------- */
#panel {
  position: fixed; left: 0; right: 0; bottom: var(--keyboard-inset, 0px); z-index: 6; max-height: calc(100dvh - 8px); overflow-y: auto;
  padding: 12px max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: var(--sup); color: var(--tx); border-top: var(--bw) solid var(--bd); box-shadow: 0 -16px 44px rgba(0, 0, 0, .4);
  transform: translateY(105%); transition: transform .24s cubic-bezier(.2, .8, .2, 1), bottom .12s;
}
#panel.open { transform: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 2px 10px; }
.panel-head .realm { font: 700 15px var(--f-t); letter-spacing: .02em; }
.panel-actions { display: flex; align-items: center; gap: 6px; }
.panel-head button { min-height: 40px; padding: 0 12px; background: var(--sup2); border: var(--bw) solid var(--bd); border-radius: var(--r); font-size: 12.5px; font-weight: 600; color: var(--tx); }
.panel-head #close { width: 42px; padding: 0; display: grid; place-items: center; }
.panel-head #close .i { width: 18px; height: 18px; }
.entry { display: flex; gap: 8px; }
.remote-editor {
  min-width: 0; flex: 1; height: 52px; overflow: hidden; white-space: nowrap; background: var(--bg); color: var(--tx);
  border: var(--bw) solid var(--bd); border-radius: var(--r); padding: 14px 15px; font-size: 17px; line-height: 22px; outline: none;
}
.remote-editor:empty::before { content: attr(data-placeholder); color: var(--su); pointer-events: none; }
.remote-editor:focus { border-color: var(--foco); box-shadow: 0 0 0 3px color-mix(in srgb, var(--foco) 25%, transparent); }
.key {
  min-height: 50px; display: grid; place-items: center; padding: 8px; touch-action: none; background: var(--sup2); color: var(--tx);
  border: var(--bw) solid var(--bd); border-radius: var(--r); font-size: 14.5px; font-weight: 600; box-shadow: var(--sh);
}
.key:active { filter: brightness(1.15); transform: scale(.97); }
.key .i { width: 21px; height: 21px; }
.key.enter { min-width: 62px; background: var(--ac); color: var(--ac-tx); border-color: var(--ac); }
.shortcut-body { display: none; }
#panel.shortcuts .shortcut-body { display: block; }
#panel.shortcuts .entry { opacity: .55; }
.rows { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 8px; }
.rows.actions { grid-template-columns: repeat(4, 1fr); }
body.computer-mode #panel { left: max(12px, calc(50% - 340px)); right: max(12px, calc(50% - 340px)); border: var(--bw) solid var(--bd); border-bottom: 0; border-radius: var(--rg) var(--rg) 0 0; }
@media (orientation: landscape) and (max-height: 520px) { body.mobile-mode #panel { left: 6%; right: 6%; border-radius: 18px 18px 0 0; padding-top: 10px; } .key { min-height: 44px; } }

/* ---------- Cuadros: diagnóstico y portapapeles ---------- */
.modal { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; padding: 18px; background: var(--velo); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#sharing { z-index: 24; }
.tarjeta {
  width: min(660px, 100%); max-height: 90dvh; overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 20px;
  background: var(--sup); color: var(--tx); border: var(--bw) solid var(--bd); border-radius: var(--rg); box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
}
.tarjeta-cab { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tarjeta-cab h2 { font: 700 20px var(--f-t); }
.tarjeta button, .file-label {
  display: inline-grid; place-items: center; min-height: 44px; padding: 0 14px; background: var(--sup2); color: var(--tx);
  border: var(--bw) solid var(--bd); border-radius: var(--r); font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.diagnostic-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.diagnostic-item { padding: 10px 12px; background: var(--bg); border: var(--bw) solid var(--bd); border-radius: var(--r); }
.diagnostic-item small { display: block; color: var(--su); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.diagnostic-item strong { display: block; margin-top: 3px; font-size: 14px; overflow-wrap: anywhere; font-family: var(--f-n); font-weight: 500; }
.diagnostic-note { color: var(--su); font-size: 12.5px; line-height: 1.5; }
.sharing-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.file-label input { display: none; }
.file-list { display: grid; gap: 7px; }
.file-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; border: var(--bw) solid var(--bd); border-radius: var(--r); background: var(--bg); }
.file-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.file-row a, .file-row button { min-height: 36px; padding: 0 8px; color: var(--ac); background: none; border: 0; font-size: 12.5px; text-decoration: none; }
.tarjeta textarea { width: 100%; min-height: 110px; resize: vertical; padding: 12px; background: var(--bg); color: var(--tx); border: var(--bw) solid var(--bd); border-radius: var(--r); font-size: 15px; }
.tarjeta textarea:focus { outline: none; border-color: var(--foco); box-shadow: 0 0 0 3px color-mix(in srgb, var(--foco) 25%, transparent); }
@media (max-width: 520px) { .diagnostic-grid { grid-template-columns: 1fr; } .opciones { grid-template-columns: repeat(3, 1fr); } }

/* La página de micrófono necesita desplazamiento propio: el escritorio remoto
   bloquea el scroll del body para interpretar los gestos como entrada remota. */
body.pagina-mic { height: 100%; overflow-y: auto; overflow-x: hidden; }
.mic-pagina { width: min(940px, 100%); min-height: 100%; margin: auto; padding: max(24px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 24px; }
.mic-pagina > .rey { margin: 0 auto; }
.mic-cuerpo { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(0, 1.6fr); align-items: center; gap: clamp(24px, 5vw, 60px); flex: 1; }
.mic-izq { display: flex; flex-direction: column; align-items: center; gap: 24px; }
.mic-boton { width: clamp(164px, 22vw, 224px); aspect-ratio: 1; position: relative; isolation: isolate; border: 2px solid var(--bd); border-radius: 50%; color: var(--tx); background: var(--sup); box-shadow: var(--sh); }
.mic-boton .contenido { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.mic-boton svg { width: 64px; height: 64px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.mic-boton .rotulo { font-weight: 700; font-size: 18px; }
.mic-boton #aro { position: absolute; inset: -10px; z-index: -1; border: 8px solid var(--ok); border-radius: inherit; opacity: 0; transition: transform .12s, opacity .12s; pointer-events: none; }
.pagina-mic.activo .mic-boton { color: var(--ok); border-color: var(--ok); }
.pagina-mic.silenciado .mic-boton { color: var(--su); border-color: var(--bd); }
.pagina-mic.conectando .mic-boton { border-color: var(--av); }
.pagina-mic.con-fallo .mic-boton { border-color: var(--ml); }
.mic-pagina #medidor { width: min(200px, 80%); height: 8px; border-radius: 8px; background: var(--sup2); overflow: hidden; }
.mic-pagina #barra { display: block; height: 100%; width: 0; background: var(--ok); transition: width .12s; }
.mic-der { display: flex; min-width: 0; flex-direction: column; gap: 18px; }
.mic-cab { display: grid; gap: 10px; }
.mic-cab h1 { font: 700 clamp(26px, 4vw, 38px)/1.15 var(--f-t); }
.mic-cab p, .mic-pagina .ficha { color: var(--su); line-height: 1.65; }
.mic-pagina #estado { font-size: 17px; }
.mic-pagina #aviso { padding: 12px; background: var(--sup2); border-left: 3px solid var(--av); overflow-wrap: anywhere; }
.mic-pagina #dispositivo { color: var(--su); font-size: 13px; overflow-wrap: anywhere; }
.mic-pagina .acciones { display: flex; flex-wrap: wrap; gap: 10px; }
.mic-pagina .ficha { padding: 18px; background: var(--sup); border: var(--bw) solid var(--bd); border-radius: var(--rg); font-size: 14px; }
.mic-pagina .ficha b { color: var(--tx); }
.mic-pagina .volver { display: flex; align-items: center; gap: 8px; min-height: 44px; margin-top: 14px; color: var(--foco); font-weight: 600; }
.mic-pagina .nota { display: block; margin-top: 6px; font-size: 12px; }
@media (max-width: 600px) {
  .mic-cuerpo { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .mic-der { text-align: center; }
  .mic-pagina .acciones { justify-content: center; }
  .mic-pagina .ficha { text-align: left; }
  .mic-pagina .portal-marca { flex-wrap: wrap; }
}
@media (max-height: 500px) and (min-width: 601px) {
  .mic-pagina { gap: 16px; }
  .mic-pagina > .rey { display: none; }
  .mic-boton { width: 156px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

body.keyboard-open .tools { visibility: hidden; }
#touch-cursor[hidden] { display: none; }
#panel.keyboard-rotated { transition: none; border-radius: var(--rg); max-height: calc(100vw - 16px); }
#panel.keyboard-rotated .panel-head { flex-wrap: wrap; gap: 4px; }
#panel.keyboard-rotated .panel-actions { flex-wrap: wrap; gap: 3px; }
#panel.keyboard-rotated .panel-head button { padding-inline: 8px; }
