/* Mac Remote — tokens del diseño aprobado. Oscuro por defecto, claro automático. */
:root {
  color-scheme: dark light;
  --bg: #0A0A0C;
  --surface: #16161A;
  --line: rgba(255,255,255,0.08);
  --text: #F5F5F7;
  --text-2: #A1A1AA;
  --text-3: #8E8E96;
  --accent: #2563EB;
  --accent-text: #6EA0FF;
  --ok: #4ADE80;
  --ok-bg: rgba(50,215,75,0.14);
  --danger: #FF7A7A;
  --track-off: rgba(120,120,128,0.36);
  --seg-bg: rgba(118,118,128,0.24);
  --seg-on: rgba(255,255,255,0.18);
  --glass-bg: rgba(40,40,48,0.55);
  --glass-line: rgba(255,255,255,0.13);
  --glass-hi: rgba(255,255,255,0.16);
  --glass-shadow: 0 8px 24px rgba(0,0,0,0.35);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, system-ui, Roboto, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #F2F2F7; --surface: #FFFFFF; --line: rgba(0,0,0,0.07);
    --text: #0B0B0F; --text-2: #55555E; --text-3: #6B6B73;
    --accent-text: #2563EB; --ok: #15803D; --ok-bg: rgba(22,163,74,0.12); --danger: #DC2626;
    --seg-bg: rgba(118,118,128,0.14); --seg-on: #FFFFFF;
    --glass-bg: rgba(255,255,255,0.6); --glass-line: rgba(255,255,255,0.8); --glass-hi: rgba(255,255,255,0.9);
    --glass-shadow: 0 6px 20px rgba(15,15,30,0.1);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }
body { -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
[hidden] { display: none !important; }

.ic { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--glass-line);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--glass-shadow);
}

/* Pantallas normales (todo menos la sesión) */
.screen {
  min-height: 100%;
  max-width: 480px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 28px) 20px calc(env(safe-area-inset-bottom) + 24px);
  display: flex; flex-direction: column;
}
.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: .4px; color: var(--text-3); }
h1.big { margin: 0; font-size: 34px; line-height: 40px; font-weight: 700; letter-spacing: -.6px; }
.sub { margin: 8px 0 0; font-size: 15px; color: var(--text-2); }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.circle-btn { width: 44px; height: 44px; border-radius: 22px; display: flex; align-items: center; justify-content: center; padding: 0; }

/* Emparejar */
.pair-icon { width: 96px; height: 96px; border-radius: 30px; margin: 36px auto 0; display: flex; align-items: center; justify-content: center;
  background: rgba(37,99,235,0.18); border-color: rgba(110,160,255,0.35); color: #9DBEFF; }
.pair h1 { margin: 28px 0 0; text-align: center; font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: -.5px; }
.pair .lead { margin: 10px 12px 0; text-align: center; font-size: 16px; line-height: 23px; color: var(--text-2); }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-2); padding-left: 4px; margin: 0 0 8px; display: block; }
.field { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 8px 0 16px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); color: var(--text-3); }
.field input { flex: 1; min-width: 0; height: 40px; border: 0; background: transparent; color: var(--text); font-size: 17px; outline: none; }
.field input::placeholder { color: var(--text-3); }
.field:focus-within { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.icon-btn { width: 44px; height: 44px; border: 0; border-radius: 14px; background: transparent; color: var(--text-3); display: flex; align-items: center; justify-content: center; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 10px 16px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); }
.stack { display: flex; flex-direction: column; gap: 2px; }
.t16 { font-size: 16px; } .t13 { font-size: 13px; color: var(--text-3); } .t12 { font-size: 12px; color: var(--text-3); }
.primary { height: 56px; border: 0; border-radius: 18px; background: var(--accent); color: #fff; font-size: 17px; font-weight: 600; width: 100%; }
.primary:disabled { opacity: .6; }
.error { min-height: 20px; margin: 12px 4px 0; color: var(--danger); font-size: 14px; text-align: center; }
.fine { margin: auto 8px 0; padding-top: 24px; text-align: center; font-size: 13px; line-height: 19px; color: var(--text-3); }

/* Interruptor (área táctil 56×44, pista 52×32) */
.switch { width: 56px; height: 44px; border: 0; padding: 0; background: transparent; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.switch span { width: 52px; height: 32px; padding: 3px; border-radius: 16px; display: flex; background: var(--track-off); transition: background .2s; }
.switch span::after { content: ""; width: 26px; height: 26px; border-radius: 13px; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); transition: transform .2s; }
.switch[aria-pressed="true"] span { background: #30D158; }
.switch[aria-pressed="true"] span::after { transform: translateX(20px); }

/* Mis equipos */
.device { margin-top: 22px; display: flex; flex-direction: column; gap: 14px; padding: 12px 12px 16px; border-radius: 30px; background: var(--surface);
  border: 1px solid var(--line); color: var(--text); text-align: left; width: 100%; }
.preview { position: relative; width: 100%; aspect-ratio: 16/9; border-radius: 20px; overflow: hidden; background: #111318 center/cover no-repeat;
  display: flex; align-items: center; justify-content: center; color: #5C5C66; }
.preview .go { position: absolute; right: 10px; bottom: 10px; width: 46px; height: 46px; border-radius: 23px; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 16px rgba(0,0,0,.3); }
.pill { display: flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--ok-bg); color: var(--ok); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.off { background: rgba(120,120,128,0.18); color: var(--text-3); }
.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--surface); }
.device .name { font-size: 20px; font-weight: 600; letter-spacing: -.3px; }
.device .meta { font-size: 14px; color: var(--text-2); }
.device .foot { display: flex; align-items: center; gap: 8px; padding: 12px 6px 0; border-top: 1px solid var(--line); color: var(--text-3); font-size: 13px; }
.badge { margin: auto auto 0; display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px; font-size: 13px; color: var(--text-2); }

/* Ajustes */
.nav { display: grid; grid-template-columns: 112px minmax(0, 1fr) 112px; align-items: center; gap: 8px; }
.nav h1 { margin: 0; font-size: 17px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { justify-self: start; height: 44px; padding: 0 14px 0 8px; border-radius: 22px; display: flex; align-items: center; gap: 2px; font-size: 15px; font-weight: 500; }
.group-title { margin: 22px 0 8px; padding-left: 16px; font-size: 13px; font-weight: 600; letter-spacing: .3px; color: var(--text-3); }
.group { border-radius: 20px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.item { min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px 8px 16px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
button.item { width: 100%; border: 0; border-left: 0; background: transparent; text-align: left; font-size: 16px; }
.seg { display: flex; gap: 2px; padding: 3px; border-radius: 13px; background: var(--seg-bg); flex-shrink: 0; }
.seg button { height: 44px; min-width: 56px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; color: var(--text-2); font-size: 14px; font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--seg-on); color: var(--text); font-weight: 600; }
.codec-row { width: 100%; min-height: 60px; border: 0; background: transparent; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--line); text-align: left; }
.codec-row:last-child { border-bottom: 0; }
.codec-row .check { color: var(--accent-text); visibility: hidden; }
.codec-row[aria-checked="true"] .check { visibility: visible; }
.codec-row .tag { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--ok-bg); color: var(--ok); margin-left: 6px; }
.reco { margin-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 12px 12px 16px; border-radius: 18px; background: rgba(37,99,235,0.12); border: 1px solid rgba(110,160,255,0.25); }
.reco-btn { height: 44px; padding: 0 16px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; flex-shrink: 0; }
.link-danger { height: 44px; padding: 0 12px; border: 0; border-radius: 12px; background: transparent; color: var(--danger); font-size: 15px; font-weight: 500; }
.accent-text { color: var(--accent-text); font-weight: 500; }

/* Sesión */
.session { position: fixed; inset: 0; background: #000; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.session video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; transform-origin: 0 0; will-change: transform; }
.keybar { position: absolute; left: 8px; right: 8px; bottom: 8px; display: flex; gap: 4px; padding: 4px; border-radius: 16px; overflow-x: auto; scrollbar-width: none; }
.keybar button { flex: 1 0 44px; height: 44px; border: 0; border-radius: 12px; background: rgba(255,255,255,0.08); color: #F5F5F7; font-size: 17px; font-weight: 500; padding: 0 8px; }
.keybar button[aria-pressed="true"] { background: #2563EB; color: #fff; }
/* Fijo (doble toque): se queda activo para varias teclas seguidas, p. ej. ⌘ + Tab Tab Tab */
.keybar button[data-locked="true"] { background: #2563EB; color: #fff; box-shadow: inset 0 -3px 0 #fff; }
.keybar .hide-kbd { position: sticky; right: 0; background: rgba(60,60,70,0.95); display: flex; align-items: center; justify-content: center; }
.session .surface { position: absolute; inset: 0; }
.bar { position: absolute; top: calc(env(safe-area-inset-top) + 12px); left: 0; right: 0; padding: 0 12px; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; pointer-events: none; }
.bar > * { pointer-events: auto; }
.chip { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: 18px; font-size: 13px; font-weight: 500; color: #E5E5EA; }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: #4ADE80; }
.tools { display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 26px; }
.tbtn { min-width: 44px; height: 44px; border: 0; border-radius: 22px; background: transparent; color: #F5F5F7; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 10px; font-size: 14px; font-weight: 500; }
.tbtn[aria-pressed="true"] { background: rgba(255,255,255,0.16); }
.tbtn.red { color: #FF8A8A; }
.tbtn .lbl { display: none; }
@media (pointer: fine) and (min-width: 900px) { .tbtn .lbl { display: inline; } }
.sep { width: 1px; height: 24px; margin: 0 4px; background: rgba(255,255,255,0.18); }
.handle { width: 72px; height: 28px; margin-top: -12px; border-radius: 0 0 14px 14px; border-top: 0; display: flex; align-items: center; justify-content: center; color: #F5F5F7; padding: 0; }
.session .glass { --glass-bg: rgba(30,30,38,0.5); --glass-line: rgba(255,255,255,0.16); --glass-hi: rgba(255,255,255,0.18); --glass-shadow: 0 10px 30px rgba(0,0,0,0.4); }
.toast { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 16px); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 20px; font-size: 14px; font-weight: 500; white-space: nowrap; color: #F5F5F7; transition: opacity .3s; }
.toast .ok { color: #4ADE80; }
.loader { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: #C7C7CC; font-size: 15px; background: rgba(0,0,0,0.55); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.2); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Campo invisible que abre el teclado del teléfono. 16px evita que iOS haga zoom al enfocarlo. */
.kbd-input { position: absolute; left: 0; bottom: 0; width: 2px; height: 2px; opacity: 0.01; font-size: 16px; border: 0; padding: 0; background: transparent; color: transparent; caret-color: transparent; }

/* ═════════════════════════ Android · Material 3 ═════════════════════════
   Se activa con <html data-platform="android"> (detectado en index.html).
   iPhone y PC siguen con el estilo de arriba. */
.android-only { display: none; }
[data-platform="android"] .android-only { display: inline-block; }
[data-platform="android"] .ios-only { display: none; }

[data-platform="android"] {
  --font: Roboto, "Google Sans", "Noto Sans", system-ui, sans-serif;
  --bg: #111318; --surface: #1D2024; --surface-high: #282A2F; --line: rgba(196,198,208,0.12);
  --text: #E2E2E9; --text-2: #C4C6D0; --text-3: #A9ABB5;
  --primary: #AAC7FF; --on-primary: #0A305F; --primary-cont: #284777; --on-primary-cont: #D6E3FF;
  --sec-cont: #3E4759; --on-sec-cont: #DAE2F9; --outline: #8E9099;
  --inverse: #E2E2E9; --on-inverse: #2E3036;
  --accent: var(--primary); --accent-text: var(--primary);
  --ok: #8BD88F; --ok-bg: rgba(139,216,143,0.14); --danger: #FFB4AB;
}
@media (prefers-color-scheme: light) {
  [data-platform="android"] {
    --bg: #F9F9FF; --surface: #EDEDF4; --surface-high: #E2E2E9; --line: rgba(68,71,79,0.14);
    --text: #1A1B20; --text-2: #44474F; --text-3: #5C5F67;
    --primary: #415F91; --on-primary: #FFFFFF; --primary-cont: #D6E3FF; --on-primary-cont: #001B3E;
    --sec-cont: #DAE2F9; --on-sec-cont: #131C2B; --outline: #74777F;
    --inverse: #2E3036; --on-inverse: #F0F0F7; --ok: #1B6D24; --ok-bg: rgba(27,109,36,0.12); --danger: #BA1A1A;
  }
}

/* Capa de estado al tocar (en vez del "vidrio" de iOS) */
[data-platform="android"] button, [data-platform="android"] a { position: relative; }
[data-platform="android"] button:active:not(:disabled), [data-platform="android"] .device:active {
  box-shadow: inset 0 0 0 999px color-mix(in srgb, var(--text) 12%, transparent);
}
[data-platform="android"] .screen .glass { background: var(--surface-high); -webkit-backdrop-filter: none; backdrop-filter: none; border: 0; box-shadow: none; }

/* Tipografía y barra superior */
[data-platform="android"] h1.big { font-size: 32px; line-height: 40px; font-weight: 400; letter-spacing: 0; }
[data-platform="android"] .eyebrow { color: var(--primary); letter-spacing: .5px; font-weight: 500; }
[data-platform="android"] .circle-btn { width: 48px; height: 48px; border-radius: 24px; background: transparent !important; color: var(--text-2); }
[data-platform="android"] .nav { display: flex; gap: 4px; margin-left: -8px; }
[data-platform="android"] .nav h1 { font-size: 22px; font-weight: 400; text-align: left; }
[data-platform="android"] .back { width: 48px; height: 48px; padding: 0; border-radius: 24px; justify-content: center; background: transparent !important; }
[data-platform="android"] .back-label { display: none; }
[data-platform="android"] .nav > span:last-child { display: none; }

/* Tarjeta del Mac y botón flotante (FAB) */
[data-platform="android"] .device { border: 0; border-radius: 28px; background: var(--surface); }
[data-platform="android"] .preview { border-radius: 16px; }
[data-platform="android"] .preview .go { width: 56px; height: 56px; border-radius: 16px; background: var(--primary-cont); color: var(--on-primary-cont); box-shadow: 0 3px 8px rgba(0,0,0,.3); }
[data-platform="android"] .pill { border-radius: 8px; }
[data-platform="android"] .badge { background: transparent !important; color: var(--text-3); }

/* Formularios: campo "relleno" de Material */
[data-platform="android"] .field { border: 0; border-radius: 4px 4px 0 0; background: var(--surface-high); border-bottom: 1px solid var(--outline); }
[data-platform="android"] .field:focus-within { outline: none; border-bottom: 2px solid var(--primary); }
[data-platform="android"] .field-label { color: var(--text-2); font-weight: 500; }
[data-platform="android"] .primary { height: 48px; border-radius: 24px; background: var(--primary); color: var(--on-primary); font-size: 15px; font-weight: 500; letter-spacing: .1px; }
[data-platform="android"] .pair-icon { background: var(--primary-cont) !important; color: var(--on-primary-cont); border-radius: 28px; }
[data-platform="android"] .card-row { border: 0; border-radius: 16px; background: var(--surface); }

/* Listas de ajustes */
[data-platform="android"] .group { border: 0; border-radius: 20px; background: var(--surface); }
[data-platform="android"] .group-title { color: var(--primary); font-size: 13px; font-weight: 500; letter-spacing: .4px; }
[data-platform="android"] .item, [data-platform="android"] .codec-row { border-bottom-color: var(--line); }

/* Interruptor Material 3 */
[data-platform="android"] .switch { width: 60px; height: 48px; }
[data-platform="android"] .switch span { box-sizing: border-box; width: 52px; height: 32px; padding: 0 6px; align-items: center; background: var(--surface-high); border: 2px solid var(--outline); transition: background .2s, border-color .2s; }
[data-platform="android"] .switch span::after { width: 16px; height: 16px; background: var(--outline); box-shadow: none; transform: none; transition: width .15s, height .15s; }
[data-platform="android"] .switch[aria-pressed="true"] span { background: var(--primary); border-color: var(--primary); justify-content: flex-end; padding: 0 2px; }
[data-platform="android"] .switch[aria-pressed="true"] span::after { width: 24px; height: 24px; background: var(--on-primary); transform: none; }

/* Botones segmentados Material 3 */
[data-platform="android"] .seg { padding: 0; gap: 0; border: 1px solid var(--outline); border-radius: 22px; background: transparent; overflow: hidden; }
[data-platform="android"] .seg button { height: 44px; border-radius: 0; color: var(--text); border-right: 1px solid var(--outline); }
[data-platform="android"] .seg button:last-child { border-right: 0; }
[data-platform="android"] .seg button[aria-pressed="true"] { background: var(--sec-cont); color: var(--on-sec-cont); }
[data-platform="android"] .seg button[aria-pressed="true"]::before { content: "✓ "; }
[data-platform="android"] .codec-row .tag { border-radius: 8px; background: var(--primary-cont); color: var(--on-primary-cont); }
[data-platform="android"] .reco { border: 0; border-radius: 16px; background: var(--primary-cont); color: var(--on-primary-cont); }
[data-platform="android"] .reco .t13 { color: var(--on-primary-cont); opacity: .8; }
[data-platform="android"] .reco-btn { border-radius: 20px; background: var(--primary); color: var(--on-primary); }

/* Sesión: barra flotante Material y "snackbar" */
[data-platform="android"] .session .tools, [data-platform="android"] .session .chip, [data-platform="android"] #t-hide, [data-platform="android"] .handle {
  background: rgba(40,42,47,0.94); -webkit-backdrop-filter: none; backdrop-filter: none; border: 0; box-shadow: 0 4px 12px rgba(0,0,0,.4);
}
[data-platform="android"] .tools { border-radius: 28px; padding: 4px 6px; }
[data-platform="android"] .tbtn { min-width: 48px; height: 48px; border-radius: 24px; color: #E2E2E9; }
[data-platform="android"] .tbtn[aria-pressed="true"] { background: #284777; color: #D6E3FF; }
[data-platform="android"] .toast { left: 16px; right: 16px; transform: none; justify-content: flex-start; border-radius: 8px; height: 48px;
  background: #E2E2E9; color: #2E3036; -webkit-backdrop-filter: none; backdrop-filter: none; border: 0; }
[data-platform="android"] .toast .ok { color: #1B6D24; }
[data-platform="android"] .spinner { border-color: rgba(170,199,255,0.25); border-top-color: #AAC7FF; }
[data-platform="android"] .keybar { background: #1D2024; -webkit-backdrop-filter: none; backdrop-filter: none; border: 0; border-radius: 16px; }
[data-platform="android"] .keybar button { border-radius: 8px; background: #282A2F; }
[data-platform="android"] .keybar button[aria-pressed="true"], [data-platform="android"] .keybar button[data-locked="true"] { background: #AAC7FF; color: #0A305F; }
