/* Cliente web de NEXUS. Tema oscuro, móvil primero, sin fuentes ni recursos externos (CSP: style-src 'self'). */
:root {
  color-scheme: dark;
  --bg: #0f1115;
  --panel: #1a1d24;
  --line: #2e333d;
  --fg: #eef0f3;
  --muted: #a3aab6;
  --accent: #5aa9ff;
  --accent-fg: #06121f;
  --ok: #4ade80;
  --bad: #ff8080;
  --warn-bg: #3a2c05;
  --warn-fg: #ffd866;
  --focus: #ffd866;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }

.screen {
  max-width: 560px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
h1 { font-size: 1.5rem; margin: 8px 0 16px; }
h2 { font-size: 1.2rem; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; margin: 6px 0 0; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .02em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

button, input, select { font: inherit; color: inherit; }
button, select {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled, select:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--bad); }
button[aria-pressed="true"] { background: #23324a; border-color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

input:not([type="radio"]) {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
}
#code { text-transform: uppercase; font-family: ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .05em; }

.field { margin: 0 0 20px; }
.field > label:not(.choice), legend { display: block; font-weight: 600; margin-bottom: 6px; }
fieldset { border: 0; padding: 0; }
.choice { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.choice label { flex: 1; min-height: 44px; display: flex; align-items: center; cursor: pointer; }
.choice input { width: 22px; height: 22px; accent-color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.notice { background: var(--panel); border-left: 4px solid var(--accent); padding: 10px 12px; border-radius: 6px; }
.error { color: var(--bad); font-weight: 600; }

.pc-list { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 10px; }
.pc-list li { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 8px 8px 14px; }
.pc-list .pc-main { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 6px 0; }
.pc-name { display: block; font-weight: 600; overflow-wrap: anywhere; }
.pc-state { font-size: .875rem; color: var(--muted); }
.pc-state.online { color: var(--ok); }

.fingerprints { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; background: var(--panel); padding: 14px; border-radius: 10px; }
.fingerprints dt { color: var(--muted); }
.fingerprints dd { margin: 0; font-size: 1.1rem; overflow-wrap: anywhere; }
.waiting { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.spinner { width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* Sesión: vídeo a toda la pantalla y barra abajo. */
.session { max-width: none; height: 100%; padding: 0; display: flex; flex-direction: column; background: #000; }
.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.stage video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; touch-action: none; }
.stage video:focus-visible { outline-offset: -3px; }
.cursor { position: absolute; left: 0; top: 0; pointer-events: none; transform-origin: 0 0; image-rendering: pixelated; }
.view-only {
  position: absolute; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); margin: 0;
  background: var(--warn-bg); color: var(--warn-fg); padding: 6px 14px; border-radius: 999px; font-weight: 600; font-size: .875rem;
  pointer-events: none; white-space: nowrap; z-index: 1;
}
.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 16px; text-align: center; background: rgba(15, 17, 21, .85); font-size: 1.1rem;
}
.overlay p { margin: 0; max-width: 40ch; overflow-wrap: anywhere; }
.toolbar {
  display: flex; gap: 8px; padding: 8px max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-bottom));
  flex-wrap: wrap; justify-content: center; background: var(--bg); border-top: 1px solid var(--line);
}
.toolbar > * { flex: 0 0 auto; padding-inline: 12px; }
.toolbar select { max-width: 12rem; }
/* Fuera de la vista pero enfocable (display:none no sacaría el teclado del iPhone). 16 px: iOS no hace zoom al enfocar. */
.typing { position: fixed; left: 0; bottom: 0; width: 1px !important; height: 1px; min-height: 0 !important; opacity: 0; padding: 0 !important; border: 0 !important; font-size: 16px; }

dialog { max-width: min(420px, calc(100% - 32px)); background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
