:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b1220;
  color: #eef3ff;
}

* {
  box-sizing: border-box;
}

/* Author display rules (e.g. the flex auth steps) must never resurrect an
   element the shell has hidden with the `hidden` attribute. */
[hidden] {
  display: none !important;
}

html,
body {
  min-width: 280px;
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 25%, rgb(59 130 246 / 18%), transparent 36rem),
    #0b1220;
}

/* Track the dynamic viewport on mobile browsers so the retracting toolbar
   never clips the bottom of the canvas; browsers without dvh keep the 100%
   fallback above. */
body {
  height: 100dvh;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

#one-boot {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: max(1.5rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
}

.boot-card {
  width: min(34rem, 100%);
  padding: clamp(1.5rem, 5vw, 3rem);
  border: 1px solid #1f2b45;
  border-radius: 1rem;
  background: #141f36;
}

.brand-mark {
  margin: 0 0 1.25rem;
  color: #60a5fa;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 7vw, 3rem);
  line-height: 1.05;
}

#one-boot-message,
#one-failure-message {
  color: #a9b1d6;
  line-height: 1.6;
}

button {
  min-height: 2.75rem;
  margin-top: 1rem;
  padding: 0.65rem 1rem;
  border: 1px solid #7dd3fc;
  border-radius: 0.5rem;
  background: #141f36;
  color: #eef3ff;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

button:hover {
  background: #1f2b45;
}

button:focus-visible,
summary:focus-visible {
  outline: 3px solid #7dd3fc;
  outline-offset: 3px;
}

details {
  margin-top: 1.25rem;
  color: #fca5a5;
}

html[data-one-ready="true"] #one-boot {
  display: none;
}

#one-auth {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  overflow-y: auto;
  background: rgb(11 18 32 / 82%);
}

/* Auto margins beat grid alignment, so the card stays centered while its top
   remains reachable (the overlay scrolls) if it ever exceeds the viewport. */
.auth-card {
  margin: auto;
}

#one-auth[hidden] {
  display: none;
}

.auth-step {
  display: flex;
  flex-direction: column;
  margin-top: 1.25rem;
}

.auth-label {
  margin-bottom: 0.4rem;
  color: #a9b1d6;
  font-size: 0.85rem;
  font-weight: 600;
}

.auth-card input {
  min-height: 2.75rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid #1f2b45;
  border-radius: 0.5rem;
  background: #0b1220;
  color: #eef3ff;
  font: inherit;

  /* Never below 16px: iOS Safari zoom-jumps into any smaller input. */
  font-size: max(1rem, 16px);
}

.auth-card input:focus-visible {
  outline: 3px solid #7dd3fc;
  outline-offset: 1px;
}

#one-auth-code {
  letter-spacing: 0.35em;
  font-variant-numeric: tabular-nums;
}

.auth-link {
  min-height: auto;
  margin-top: 0.75rem;
  padding: 0.25rem 0;
  border: none;
  background: none;
  color: #7dd3fc;
  font-weight: 500;
  text-decoration: underline;
  cursor: pointer;
}

.auth-link:hover {
  background: none;
  color: #bae6fd;
}

#one-auth-error {
  margin: 1rem 0 0;
  color: #fca5a5;
  line-height: 1.5;
}

button[disabled] {
  opacity: 0.6;
  cursor: progress;
}

/* Landscape phones: compact the cards so sign-in fits without scrolling. */
@media (max-height: 480px) {
  .boot-card {
    padding: 0.75rem 1.25rem;
  }

  .brand-mark {
    display: none;
  }

  h1 {
    font-size: 1.4rem;
  }

  .boot-card p {
    margin: 0.5rem 0 0;
  }

  .auth-step {
    margin-top: 0.75rem;
  }

  .auth-card button {
    margin-top: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (forced-colors: active) {
  .boot-card,
  button {
    border: 1px solid CanvasText;
  }
}
