:root {
  --bg: #05070d;
  --bg2: #0a0f1c;
  --panel: rgba(16, 24, 42, 0.72);
  --line: rgba(94, 234, 255, 0.18);
  --text: #e6f1ff;
  --muted: #8aa0bd;
  --cyan: #5eeaff;
  --violet: #a78bfa;
  --red: #ff4d6d;
  --green: #34d399;
  --amber: #fbbf24;
  --radius: 18px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(94, 234, 255, 0.12), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, rgba(167, 139, 250, 0.10), transparent 60%),
    var(--bg);
  min-height: 100vh;
  line-height: 1.55;
}
body::before {
  /* rejilla sutil */
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background-image:
    linear-gradient(rgba(94, 234, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(94, 234, 255, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 85%);
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

/* --- cabecera --- */
.top {
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(14px);
  background: rgba(5, 7, 13, 0.7);
  border-bottom: 1px solid var(--line);
}
.top .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 0.08em; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; }
.nav { display: flex; gap: 22px; align-items: center; font-size: 0.95rem; }
.nav a { color: var(--muted); }
.nav a:hover { color: var(--text); text-decoration: none; }

/* --- botones --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 12px 22px; font: inherit; font-weight: 600; cursor: pointer;
  background: rgba(255, 255, 255, 0.04); color: var(--text);
  transition: transform .15s, box-shadow .2s, background .2s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); background: rgba(255, 255, 255, 0.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary {
  border-color: transparent; color: #04121a;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  box-shadow: 0 0 28px rgba(94, 234, 255, 0.35);
}
.btn.primary:hover { box-shadow: 0 0 40px rgba(94, 234, 255, 0.55); }
.btn.danger { background: rgba(255, 77, 109, 0.15); border-color: rgba(255, 77, 109, 0.5); color: #ffd1da; }
.btn.small { padding: 8px 14px; font-size: 0.9rem; }

/* --- landing --- */
.hero { padding-top: 96px; padding-bottom: 72px; display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 48px; align-items: center; }
.eyebrow { font-family: var(--mono); color: var(--cyan); font-size: 0.85rem; letter-spacing: 0.18em; text-transform: uppercase; }
h1 { font-size: clamp(2.3rem, 5vw, 3.8rem); line-height: 1.08; margin: 14px 0 18px; letter-spacing: -0.02em; }
h1 .grad { background: linear-gradient(135deg, var(--cyan), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { color: var(--muted); font-size: 1.15rem; max-width: 34em; }
.cta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 30px; }
.note { color: var(--muted); font-size: 0.85rem; margin-top: 14px; }

.scope {
  position: relative; aspect-ratio: 4 / 3; border-radius: 24px;
  border: 1px solid var(--line); overflow: hidden;
  background: radial-gradient(circle at 50% 50%, rgba(94, 234, 255, 0.08), transparent 70%), var(--bg2);
  box-shadow: 0 0 80px rgba(94, 234, 255, 0.08) inset;
}
.scope .ring { position: absolute; inset: 14%; border: 1px dashed rgba(94, 234, 255, 0.25); border-radius: 50%; }
.scope .ring.r2 { inset: 30%; }
.scope .sweep {
  position: absolute; inset: 0;
  background: conic-gradient(from 0deg, rgba(94, 234, 255, 0.28), transparent 18%);
  border-radius: 50%; transform-origin: 50% 50%;
  animation: sweep 4s linear infinite;
  mask-image: radial-gradient(circle, black 55%, transparent 56%);
}
@keyframes sweep { to { transform: rotate(360deg); } }
.scope .blip {
  position: absolute; width: 12px; height: 12px; border-radius: 50%; background: var(--red);
  box-shadow: 0 0 20px var(--red); left: 66%; top: 34%; animation: blip 4s ease-out infinite;
}
@keyframes blip { 0%, 8% { opacity: 0; } 12% { opacity: 1; } 60% { opacity: 0.2; } 100% { opacity: 0; } }
.scope .hud {
  position: absolute; left: 16px; right: 16px; bottom: 14px;
  display: flex; justify-content: space-between; font-family: var(--mono); font-size: 0.8rem; color: var(--muted);
}
.scope .hud b { color: var(--green); font-weight: 600; }
.scope .alert {
  position: absolute; top: 16px; right: 16px; padding: 10px 14px; border-radius: 14px;
  background: rgba(10, 15, 28, 0.9); border: 1px solid rgba(255, 77, 109, 0.5);
  font-size: 0.85rem; max-width: 62%; animation: pop 4s ease-out infinite;
}
.scope .alert small { display: block; color: var(--muted); }
@keyframes pop { 0%, 10% { opacity: 0; transform: translateY(-6px); } 16%, 70% { opacity: 1; transform: none; } 100% { opacity: 0; } }

section { padding: 64px 0; }
h2 { font-size: clamp(1.6rem, 3vw, 2.3rem); margin: 0 0 10px; letter-spacing: -0.01em; }
.sub { color: var(--muted); margin: 0 0 34px; max-width: 42em; }

.grid { display: grid; gap: 18px; }
.grid.g3 { grid-template-columns: repeat(3, 1fr); }
.grid.g2 { grid-template-columns: repeat(2, 1fr); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; backdrop-filter: blur(8px);
}
.card h3 { margin: 10px 0 6px; font-size: 1.1rem; }
.card p { margin: 0; color: var(--muted); }
.step { font-family: var(--mono); color: var(--cyan); font-size: 0.85rem; }
.icon { font-size: 1.6rem; }

.devices { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; color: var(--text);
  background: rgba(255, 255, 255, 0.03); font-size: 0.95rem;
}

details { border-bottom: 1px solid var(--line); padding: 16px 0; }
details summary { cursor: pointer; font-weight: 600; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "+ "; color: var(--cyan); font-family: var(--mono); }
details[open] summary::before { content: "− "; }
details p { color: var(--muted); margin: 10px 0 0; }

footer { border-top: 1px solid var(--line); padding: 30px 0 40px; color: var(--muted); font-size: 0.9rem; }
footer .wrap { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }

.legal { max-width: 760px; padding: 56px 24px 80px; margin: 0 auto; }
.legal h1 { font-size: 2.2rem; }
.legal h2 { font-size: 1.3rem; margin-top: 34px; }
.legal p, .legal li { color: #c9d6e8; }

/* --- app --- */
.app { display: grid; grid-template-columns: 1.35fr 1fr; gap: 20px; padding-top: 24px; padding-bottom: 48px; }
.viewer { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #000; aspect-ratio: 4 / 3; }
.viewer video, .viewer canvas.overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.viewer canvas.overlay { cursor: crosshair; touch-action: none; }
.viewer .placeholder {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; color: var(--muted);
}
.state {
  position: absolute; top: 14px; left: 14px; z-index: 2;
  font-family: var(--mono); font-size: 0.85rem; letter-spacing: 0.08em;
  padding: 6px 12px; border-radius: 999px; background: rgba(0, 0, 0, 0.6); border: 1px solid var(--line);
}
.state::before { content: "●"; margin-right: 6px; }
.state.off::before { color: var(--muted); }
.state.wait::before { color: var(--amber); }
.state.on::before { color: var(--green); animation: pulse 1.4s infinite; }
.state.alarm { border-color: var(--red); }
.state.alarm::before { color: var(--red); animation: pulse .5s infinite; }
@keyframes pulse { 50% { opacity: .2; } }
.meter { position: absolute; left: 14px; right: 14px; bottom: 14px; height: 6px; border-radius: 6px; background: rgba(255,255,255,.12); z-index: 2; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--green), var(--amber), var(--red)); transition: width .15s; }
.meter .mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: #fff; opacity: .7; }

.controls { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.side { display: flex; flex-direction: column; gap: 16px; }
.side .card h3 { margin-top: 0; }
label.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 12px 0 4px; color: var(--muted); font-size: 0.92rem; }
input[type=range] { width: 100%; accent-color: var(--cyan); }
select, input[type=text], input[type=number] {
  width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35); color: var(--text); font: inherit;
}
.topic { font-family: var(--mono); font-size: 0.9rem; word-break: break-all; background: rgba(0,0,0,.35); padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); }
.qr { background: #fff; border-radius: 12px; padding: 8px; width: 168px; height: 168px; margin: 12px 0; }
.qr svg, .qr img { width: 100%; height: 100%; display: block; }
.pair { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.pair ol { margin: 0; padding-left: 18px; color: var(--muted); font-size: 0.92rem; }
.msg { font-size: 0.9rem; color: var(--muted); min-height: 1.3em; margin-top: 8px; }
.msg.ok { color: var(--green); }
.msg.err { color: var(--red); }
.history { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.history figure { margin: 0; }
.history img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; }
.history figcaption { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); margin-top: 4px; }
.warn { border-color: rgba(251, 191, 36, 0.4); }
.warn p { color: #f6dca0; }
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--bg2); color: var(--text); padding: 12px; max-width: 92vw; }
dialog img { max-width: 86vw; max-height: 78vh; display: block; border-radius: 10px; }
dialog::backdrop { background: rgba(0,0,0,.75); }

@media (max-width: 880px) {
  .hero, .app { grid-template-columns: 1fr; }
  .hero { padding-top: 56px; }
  .grid.g3, .grid.g2 { grid-template-columns: 1fr; }
  .nav a.hide-m { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
