:root {
  --bg: #0b1020;           /* azul oscuro de Andy */
  --bg2: #121a2e;          /* fondo de inputs */
  --card: #161f36;
  --line: #24304d;
  --fg: #e8ecf6;
  --muted: #8b96ad;
  --accent: #2f7cf6;       /* azul Andy */
  --accent2: #5b9dff;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 14px;
  color-scheme: dark;
  --mon: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="20" height="14" rx="2"/><path d="M8 21h8M12 17v4"/></svg>');
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; }
body { overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.err { color: var(--bad); min-height: 1.2em; font-size: 14px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.view { min-height: 100%; }

/* ---------- botones ---------- */
.btn { display: block; width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; text-align: center; font-weight: 600; transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.big { padding: 15px; font-size: 16px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.danger { color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 10px; width: 40px; height: 40px;
  display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover { color: var(--fg); border-color: var(--accent); }
.pill { font-size: 12.5px; color: var(--muted); padding: 5px 11px; border: 1px solid var(--line); border-radius: 99px; background: var(--card); }

input, select, textarea { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; outline: none; color: var(--fg); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder { color: var(--muted); }

/* ---------- inicio (estilo AnyDesk) ---------- */
#v-home { max-width: 760px; margin: 0 auto; padding: 0 16px 40px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 0 10px;
  padding-top: max(16px, env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: -.01em; }
.brand img { width: 32px; height: 32px; border-radius: 9px; }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; }
.brand .logo svg { width: 20px; height: 20px; stroke: #fff; }

.connect-box { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 20px 18px;
  margin-top: 10px; box-shadow: 0 1px 0 rgba(0,0,0,.02), 0 10px 30px rgba(20,20,30,.05); }
.connect-label { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 14px; font-size: 15px; }
.connect-label::before { content: ""; width: 18px; height: 18px; flex: none;
  background: var(--accent); -webkit-mask: var(--mon) center/contain no-repeat; mask: var(--mon) center/contain no-repeat; }
#connect-form { display: grid; gap: 11px; }
#c-id { width: 100%; font-size: 22px; font-weight: 700; text-align: center; letter-spacing: .08em;
  padding: 14px; font-variant-numeric: tabular-nums; }
#c-pass { width: 100%; font-size: 16px; }
.remember { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13.5px; padding: 2px 2px 4px; }
.remember input { width: 18px; height: 18px; accent-color: var(--accent); }

#book-wrap { margin-top: 26px; }
.group-title { margin: 0 2px 12px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 700; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.dev { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 11px; }
.dev.off { opacity: .6; }
.dev-head { display: flex; align-items: center; gap: 11px; }
.dev-ico { width: 38px; height: 38px; border-radius: 10px; flex: none; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.dev-ico svg { width: 20px; height: 20px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 22%, transparent); }
.dev-name { font-weight: 700; font-size: 16px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-sub { font-size: 12.5px; color: var(--muted); }
.watching { font-size: 11.5px; color: var(--warn); font-weight: 600; }
.bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bar { font-size: 11.5px; color: var(--muted); }
.bar i { display: block; height: 5px; border-radius: 3px; background: var(--line); margin-top: 4px; overflow: hidden; }
.bar i b { display: block; height: 100%; background: var(--accent); }
.bar i b.hi { background: var(--warn); }
.bar i b.crit { background: var(--bad); }
.dev-actions { display: flex; gap: 8px; }
.dev-actions .btn { flex: 1; }
.dev-actions .icon-btn { flex: none; width: 46px; height: auto; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; line-height: 1.7; }
.hint { color: var(--muted); font-size: 13px; text-align: center; margin-top: 26px; }

/* ---------- visor (sobre video negro: se queda oscuro) ---------- */
#v-viewer { position: fixed; inset: 0; background: #000; overflow: hidden; touch-action: none; }
#viewport { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
#stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
#screen { display: block; image-rendering: auto; background: #111; }
#rcursor { position: absolute; left: 0; top: 0; width: 16px; height: 24px; pointer-events: none;
  transform-origin: 0 0; filter: drop-shadow(0 0 1px #000); }
#rcursor svg { width: 16px; height: 24px; fill: #fff; stroke: #000; stroke-width: 1.3; }
.viewer-msg { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: #cfd6e2;
  background: #11151cdd; padding: 14px 20px; border-radius: 12px; text-align: center; max-width: 80%; }

.toolbar { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px; background: #1b1e24ee; border: 1px solid #2b2f37;
  border-radius: 14px; padding: 4px; backdrop-filter: blur(10px); max-width: calc(100% - 16px); z-index: 5;
  box-shadow: 0 8px 30px #0008; color: #eceef1; }
.tb { width: 40px; height: 40px; border: none; background: none; border-radius: 10px; display: grid; place-items: center;
  cursor: pointer; color: #eceef1; flex: none; }
.tb:hover, .tb.active { background: #ffffff18; }
.tb.active { color: var(--accent2); }
.tb-name { font-weight: 600; font-size: 13.5px; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.tb-fps { font-size: 11px; color: #949cab; padding-right: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tb-sep { width: 1px; height: 24px; background: #2b2f37; margin: 0 4px; }
.tb-show { position: absolute; top: max(6px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 5;
  width: 46px; height: 24px; border-radius: 0 0 10px 10px; border: 1px solid #2b2f37; border-top: none;
  background: #1b1e24cc; color: #eceef1; display: grid; place-items: center; cursor: pointer; }
.panel { position: absolute; top: calc(max(8px, env(safe-area-inset-top)) + 56px); right: 8px; z-index: 6;
  width: min(360px, calc(100% - 16px)); max-height: calc(100% - 80px); overflow: auto;
  background: #1b1e24f7; color: #eceef1; border: 1px solid #2b2f37; border-radius: 14px; padding: 14px; display: grid; gap: 10px;
  box-shadow: 0 12px 40px #000a; }
.panel-title { font-weight: 700; }
.keys-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.keys-grid button, .toggle { padding: 10px 4px; border-radius: 9px; border: 1px solid #2b2f37; background: #20242b;
  cursor: pointer; font-size: 13px; color: #eceef1; }
.keys-grid button:active { background: var(--accent); border-color: var(--accent); }
.toggle.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.panel-row { display: flex; gap: 6px; align-items: center; }
.panel-row .toggle { flex: 1; }
.panel .btn { background: #20242b; border-color: #2b2f37; color: #eceef1; }
.panel .btn.danger { color: #ff6a60; }
.panel-sep { height: 1px; background: #2b2f37; margin: 4px 0; }
.opt { display: grid; grid-template-columns: 80px 1fr; align-items: center; gap: 10px; font-size: 14px; }
.opt select { background: #20242b; border-color: #2b2f37; color: #eceef1; }
#kbd-input { position: absolute; left: -2000px; top: 30%; width: 200px; height: 40px; opacity: 0; font-size: 16px; }

/* arrastrar y soltar archivos sobre el visor */
.drop-hint { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 30%, #000a); backdrop-filter: blur(2px); pointer-events: none; }
.drop-hint > div { background: var(--accent); color: #fff; font-weight: 700; font-size: 17px;
  padding: 18px 26px; border-radius: 16px; border: 2px dashed #fff8; box-shadow: 0 10px 40px #0008; }

/* ---------- hoja de opciones / toast ---------- */
.sheet { position: fixed; inset: 0; background: #00000066; display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.sheet-box { width: 100%; max-width: 440px; background: var(--card); border: 1px solid var(--line); border-radius: 18px 18px 0 0;
  padding: 16px 16px max(16px, env(safe-area-inset-bottom)); display: grid; gap: 8px; }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet-box { border-radius: 18px; } }
.sheet-title { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
#sheet-body { display: grid; gap: 8px; }
#sheet-body textarea { width: 100%; min-height: 110px; resize: vertical; }
.sheet-input { width: 100%; font-size: 16px; padding: 12px; }
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #2a2f38; color: #fff; border: 1px solid #3a4150; padding: 11px 16px; border-radius: 12px; z-index: 60;
  max-width: calc(100% - 32px); box-shadow: 0 10px 30px #0009; font-size: 14px; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress b { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
@media (max-width: 520px) { .tb-fps { display: none; } .tb { width: 38px; } .tb-name { max-width: 34vw; } }

/* ---------- "Este escritorio" (app de ventana del PC) ---------- */
.this-desk { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, var(--card)), var(--card));
  border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; margin-top: 10px; }
.td-label { font-size: 12.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 700; }
.td-row { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.td-id { font-size: 30px; font-weight: 800; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.td-hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* ================================================================
   MODO ESCRITORIO (programa del PC): barra lateral + contenido
   Por defecto (celular/web) la barra lateral está oculta.
   ================================================================ */
#sidebar { display: none; }
.mini { width: auto; display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 12px; font-size: 13px; }

body.desktop #app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
body.desktop #sidebar { display: flex; flex-direction: column; gap: 6px; padding: 16px 14px;
  background: #0d1526; border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; }
body.desktop #content { min-width: 0; overflow: auto; height: 100vh; }
/* en escritorio la marca y el "este escritorio" viven en la barra lateral */
body.desktop #v-home .topbar .brand { display: none; }
body.desktop #v-home .topbar { justify-content: flex-end; }
body.desktop #this-desk { display: none !important; }
body.desktop #v-home, body.desktop #v-config { max-width: 820px; margin: 0 auto; padding: 8px 26px 40px; }

.side-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; padding: 4px 6px 10px; }
.side-brand img { width: 28px; height: 28px; border-radius: 8px; }

.side-me { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, var(--card)), var(--card));
  border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; display: grid; gap: 7px; }
.sm-top { display: flex; align-items: center; justify-content: space-between; }
.sm-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.sm-id { font-size: 23px; font-weight: 800; letter-spacing: .05em; font-variant-numeric: tabular-nums; line-height: 1.05; }
.sm-name { font-size: 12.5px; color: var(--muted); margin-top: -2px; min-height: .4em; }
.side-me .mini { width: 100%; margin-top: 2px; }
.sm-state { font-size: 11.5px; color: var(--muted); }
.sm-state.on { color: var(--ok); }

.side-nav { display: grid; gap: 3px; margin-top: 10px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 11px;
  border: none; background: none; color: var(--fg); cursor: pointer; font-weight: 600; font-size: 14.5px; text-align: left; }
.nav-item svg { width: 19px; height: 19px; color: var(--muted); flex: none; }
.nav-item:hover { background: #ffffff0d; }
.nav-item.active { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent2); }
.nav-item.active svg { color: var(--accent2); }
.side-foot { margin-top: auto; padding: 8px 8px 2px; font-size: 11px; color: var(--muted); }

/* ---------- configuración ---------- */
.cfg-wrap { display: grid; gap: 16px; padding-top: 10px; }
.cfg-title { margin: 6px 2px 0; font-size: 22px; font-weight: 800; }
.cfg-note { background: var(--card); border: 1px solid var(--warn); border-radius: 12px; padding: 12px 14px;
  color: var(--fg); font-size: 13.5px; margin: 0; }
.cfg-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: grid; gap: 14px; }
.cfg-field { display: grid; gap: 6px; }
.cfg-field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.cfg-field input { width: 100%; font-size: 15px; }
.cfg-hint { font-size: 12px; color: var(--muted); }
.cfg-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.cfg-row-txt { min-width: 0; }
.cfg-row .btn.mini { flex: none; min-width: 92px; }
.cfg-sep { height: 1px; background: var(--line); }
.cfg-card summary { font-weight: 700; cursor: pointer; }
.cfg-card[open] summary { margin-bottom: 2px; }
#cf-salir { max-width: 260px; }

@media (max-width: 680px) {
  body.desktop #app { grid-template-columns: 1fr; }
  body.desktop #sidebar { position: static; height: auto; flex-direction: column; }
  body.desktop #content { height: auto; }
}
