:root {
  --bg: #0b1020;
  --bg-soft: #141b32;
  --card: #1a2340;
  --line: #2a3558;
  --text: #eaf0ff;
  --muted: #93a2c8;
  --brand: #4f7cff;
  --brand-2: #7aa2ff;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: contain;
}

body.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: radial-gradient(1200px 600px at 50% -10%, #1d2a55 0%, var(--bg) 60%);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

header.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
}
header.bar .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #22d3ee);
  display: grid; place-items: center; font-weight: 800; font-size: 16px;
}
header.bar h1 { font-size: 16px; margin: 0; font-weight: 650; letter-spacing: .2px; }
header.bar .sub { font-size: 12px; color: var(--muted); }
header.bar .right { margin-left: auto; font-size: 12px; color: var(--muted); }

main.wrap { flex: 1; padding: 0 16px 24px; max-width: 520px; width: 100%; margin: 0 auto; }

.camera {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 58dvh;
  border-radius: 24px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
}
.camera video, .camera canvas.overlay {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
.camera .frame {
  position: absolute; inset: 12% 14%;
  border: 2px dashed rgba(255, 255, 255, .35);
  border-radius: 50% / 42%;
  pointer-events: none;
  transition: border-color .25s, box-shadow .25s;
}
.camera.detected .frame {
  border-color: var(--ok);
  border-style: solid;
  box-shadow: 0 0 0 9999px rgba(34, 197, 94, .08);
}
.camera .hint {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 26px 16px 14px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .75));
  font-size: 13px; text-align: center; color: #dbe6ff;
}

.status {
  display: flex; gap: 8px; align-items: center; justify-content: center;
  margin: 14px 0 6px; font-size: 13px; color: var(--muted);
  flex-wrap: wrap;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-soft); border: 1px solid var(--line);
  padding: 6px 11px; border-radius: 999px; font-size: 12px;
}
.chip:has(#dotGeo) { cursor: pointer; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.err { background: var(--err); }

button.primary {
  width: 100%; margin-top: 14px; padding: 17px;
  font-size: 17px; font-weight: 650; color: #fff;
  background: linear-gradient(135deg, var(--brand), #22d3ee);
  border: 0; border-radius: 16px; cursor: pointer;
  box-shadow: 0 10px 30px rgba(79, 124, 255, .35);
  transition: transform .12s, opacity .2s;
}
button.primary:active { transform: scale(.985); }
button.primary:disabled { opacity: .45; box-shadow: none; }

button.ghost {
  background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 16px; font-size: 14px; cursor: pointer;
}

.result {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(6, 10, 24, .92);
  backdrop-filter: blur(6px);
  display: none; place-items: center; padding: 24px;
}
.result.show { display: grid; }
.result .card {
  width: 100%; max-width: 380px; text-align: center;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 22px; padding: 30px 22px;
  animation: pop .28s ease;
}
@keyframes pop { from { transform: scale(.9); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.result .icon {
  width: 78px; height: 78px; margin: 0 auto 16px; border-radius: 50%;
  display: grid; place-items: center; font-size: 38px;
}
.result .icon.ok { background: rgba(34, 197, 94, .15); color: var(--ok); }
.result .icon.err { background: rgba(239, 68, 68, .15); color: var(--err); }
.result h2 { margin: 0 0 6px; font-size: 21px; }
.result p { margin: 4px 0; color: var(--muted); font-size: 14px; }
.result .big { font-size: 34px; font-weight: 750; letter-spacing: 1px; margin: 10px 0; }
.result .meta { margin-top: 14px; font-size: 12px; color: var(--muted); line-height: 1.7; }
/* Las instrucciones de ayuda van numeradas: alineadas a la izquierda se leen mejor. */
.result .meta:not(:empty) { text-align: left; background: #141c33; border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px; }
.result .card { max-height: 86dvh; overflow-y: auto; }

.loader {
  position: fixed; inset: 0; z-index: 60;
  background: var(--bg); display: grid; place-items: center; text-align: center;
}
.loader.hide { display: none; }
.spin {
  width: 42px; height: 42px; margin: 0 auto 16px;
  border: 3px solid var(--line); border-top-color: var(--brand);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

.footer-note { text-align: center; font-size: 11px; color: #5f6f96; margin-top: 18px; line-height: 1.6; }
a { color: var(--brand-2); }
