:root {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --text: #14201D;
  --muted: #66756F;
  --accent: #00614A;
  --on-accent: #FFFFFF;
  --border: #E1E1E1;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A1512;
    --surface: #101E1A;
    --text: #F3F6F4;
    --muted: #8FA39D;
    --accent: #1FBA8F;
    --on-accent: #04231C;
    --border: #1E2E29;
  }
}

:root[data-theme="dark"] {
  --bg: #0A1512;
  --surface: #101E1A;
  --text: #F3F6F4;
  --muted: #8FA39D;
  --accent: #1FBA8F;
  --on-accent: #04231C;
  --border: #1E2E29;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

html {
  -webkit-tap-highlight-color: transparent;
}

body {
  height: 100vh;
  height: 100dvh;
  display: flex;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Standalone/PWA mode needs this exemption explicitly — the app-wide
   user-select: none above is for tap-friendly chrome, not for the OTP
   digits the user actually needs to type/paste into. */
input,
textarea {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

img,
svg {
  -webkit-user-drag: none;
}

.screen {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(20px, env(safe-area-inset-top)) 24px calc(clamp(16px, 3dvh, 28px) + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 44px;
  flex: none;
  margin-bottom: clamp(12px, 4dvh, 28px);
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--text);
  text-decoration: none;
  transition: transform 120ms ease, background-color 120ms ease;
}

.back-btn:active {
  transform: scale(0.88);
  background: color-mix(in srgb, var(--text) 8%, transparent);
}

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
}

.theme-switch {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  z-index: 10;
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: transform 120ms ease;
}

.theme-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}

.theme-btn[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

.theme-btn:active {
  transform: scale(0.88);
}

.signal-visual {
  display: flex;
  justify-content: center;
  flex: none;
  margin-bottom: clamp(6px, 2dvh, 16px);
  color: var(--accent);
}

.signal-visual svg {
  display: block;
  width: clamp(72px, 22dvh, 180px);
  height: clamp(72px, 22dvh, 180px);
}

/* Same animation family as the welcome/login screens, but every signal
   direction is reversed — pulses and dash-flow travel INWARD toward the
   hub instead of outward from it, so the network reads as "receiving and
   verifying" rather than "broadcasting." Amplitude sits slightly above
   the login screen's (~65-75% of the welcome screen vs login's ~60-70%). */
.pulses circle {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.7;
  stroke-linecap: round;
  opacity: 0;
  transform-origin: 100px 100px;
  animation: dvr-pulse-inward 3.6s ease-in infinite;
}

.pulses circle:nth-child(2) { animation-delay: 1.2s; }

@keyframes dvr-pulse-inward {
  0%   { transform: scale(1.3); opacity: 0; }
  35%  { opacity: 0.6; }
  100% { transform: scale(0.25); opacity: 0; }
}

.mesh line {
  stroke: var(--accent);
  stroke-width: 1.35;
  stroke-linecap: round;
  opacity: 0.36;
  stroke-dasharray: 4 7;
  stroke-dashoffset: 0;
  animation: dvr-line-flow-inward 3.6s linear infinite;
}

.mesh line:nth-child(1) { animation-delay: 0s; }
.mesh line:nth-child(2) { animation-delay: 0.25s; }
.mesh line:nth-child(3) { animation-delay: 0.5s; }
.mesh line:nth-child(4) { animation-delay: 0.75s; }
.mesh line:nth-child(5) { animation-delay: 1s; }
.mesh line:nth-child(6) { animation-delay: 1.25s; }

@keyframes dvr-line-flow-inward {
  to { stroke-dashoffset: 22; }
}

.nodes circle {
  fill: var(--accent);
  opacity: 0.5;
  transform-box: fill-box;
  transform-origin: center;
  animation: dvr-node-glow 2.8s ease-in-out infinite;
}

.nodes circle:nth-child(1) { animation-delay: 0s; }
.nodes circle:nth-child(2) { animation-delay: 0.4s; }
.nodes circle:nth-child(3) { animation-delay: 0.8s; }
.nodes circle:nth-child(4) { animation-delay: 1.2s; }
.nodes circle:nth-child(5) { animation-delay: 1.6s; }
.nodes circle:nth-child(6) { animation-delay: 2s; }

@keyframes dvr-node-glow {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50%      { opacity: 0.92; transform: scale(1.18); }
}

/* The "verification" moment: a thin ring around the hub that briefly
   resolves into view right as an inward pulse arrives at the core — a
   confirmation flash belonging to the same signal language, not a
   checkmark glyph. */
.hub {
  fill: var(--accent);
  transform-box: fill-box;
  transform-origin: center;
  animation: dvr-hub-verify 3.6s ease-in-out infinite;
}

@keyframes dvr-hub-verify {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 0 1px color-mix(in srgb, var(--accent) 25%, transparent));
  }
  35% {
    transform: scale(1.1);
    filter: drop-shadow(0 0 5px color-mix(in srgb, var(--accent) 60%, transparent));
  }
  55% {
    transform: scale(1);
    filter: drop-shadow(0 0 1px color-mix(in srgb, var(--accent) 25%, transparent));
  }
}

@media (prefers-reduced-motion: reduce) {
  .pulses circle { animation: none; opacity: 0.18; transform: scale(1); }
  .mesh line { animation: none; }
  .nodes circle { animation: none; opacity: 0.75; transform: scale(1); }
  .hub { animation: none; filter: none; }
  .back-btn,
  .theme-btn,
  .btn-primary,
  .resend-btn {
    transition: none;
  }
}

.intro {
  flex: none;
  margin-bottom: clamp(14px, 4dvh, 32px);
}

h1 {
  font-size: clamp(24px, 7vw, 32px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 8px;
}

.lead-sub {
  font-size: 15px;
  line-height: 1.4;
  color: var(--muted);
}

.identifier-display {
  margin-top: 2px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.otp-group {
  display: flex;
  flex: none;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: clamp(14px, 3.5dvh, 28px);
}

.otp-box {
  width: 100%;
  max-width: 52px;
  height: clamp(46px, 9dvh, 58px);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  font-size: 22px;
  text-align: center;
  padding: 0;
}

.otp-box:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 100%;
  height: clamp(48px, 9dvh, 56px);
  border: 0;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 16px;
  text-decoration: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 120ms ease, opacity 160ms ease;
}

.btn-primary:active {
  transform: scale(0.97);
  opacity: 0.92;
}

.resend-row {
  flex: none;
  margin-top: clamp(12px, 3dvh, 22px);
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.resend-btn {
  border: 0;
  background: none;
  padding: 0;
  margin-left: 4px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  transition: opacity 120ms ease;
}

.resend-btn:disabled {
  color: var(--muted);
  cursor: default;
}

.resend-btn:not(:disabled):active {
  opacity: 0.55;
}

.security-note {
  flex: none;
  margin-top: auto;
  padding-top: clamp(10px, 3dvh, 24px);
  text-align: center;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }
}

@media (min-width: 560px) {
  html, body {
    overflow: auto;
  }
  body {
    align-items: center;
  }
  .screen {
    height: auto;
    padding-top: 40px;
    padding-bottom: 40px;
  }
}
