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

:root {
  --bg: #0a1018;
  --bg2: #0f1824;
  --bg3: #141f2e;
  --cy: #00cfe0;
  --cy-dim: #007a8a;
  --cy-glow: rgba(0, 207, 224, 0.2);
  --am: #f0b420;
  --am-dim: #8a6010;
  --am-glow: rgba(240, 180, 32, 0.18);
  --tx: #c4d8e8;
  --tx-hi: #e4f2fc;
  --tx-md: #8aaec4;
  --tx-lo: #567a90;
  --w2: #1a2a3c;
  --w3: #243448;
  --w4: #2e4058;
  --green: #24d870;
  --red: #e04848;
  --red-dim: #7a2020;
  --tx-dim: #3a5870;
}

html,
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--tx);
  font-family: 'JetBrains Mono', monospace;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.45) 100%);
}

body::after {
  content: none;
}

button,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

.corner {
  position: fixed;
  width: 16px;
  height: 16px;
  border-color: var(--cy-dim);
  border-style: solid;
  z-index: 20;
  opacity: 0.5;
}

.corner.tl { top: 20px; left: 20px; border-width: 1px 0 0 1px; }
.corner.tr { top: 20px; right: 20px; border-width: 1px 1px 0 0; }
.corner.bl { bottom: 20px; left: 20px; border-width: 0 0 1px 1px; }
.corner.br { bottom: 20px; right: 20px; border-width: 0 1px 1px 0; }

.wordmark {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cy);
  text-shadow: 0 0 16px var(--cy-glow);
  z-index: 20;
}

.wordmark span {
  color: var(--cy-dim);
  font-weight: 300;
  text-transform: none;
  letter-spacing: 0;
}

.auth-stage {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  position: relative;
  z-index: 10;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.signup-state {
  width: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
}

.signup-state-active {
  display: flex;
}

.auth-kicker {
  font-size: 11px;
  font-weight: 300;
  color: var(--tx-lo);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 20px;
}

.auth-handle {
  font-size: clamp(42px, 8vw, 72px);
  font-weight: 300;
  color: var(--am);
  letter-spacing: -0.02em;
  text-shadow: 0 0 24px var(--am-glow);
  margin-bottom: 18px;
}

.auth-handle .t {
  color: var(--am-dim);
}

.auth-context {
  font-size: 14px;
  font-weight: 300;
  color: var(--tx-lo);
  letter-spacing: 0.03em;
  margin-bottom: 32px;
  text-align: center;
}

.auth-context-wide {
  max-width: 360px;
}

.auth-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.auth-handoff {
  gap: 10px;
}

.auth-handoff-qr {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--w3);
  background: var(--bg3);
}

.auth-handoff-qr-image {
  width: 180px;
  height: 180px;
  image-rendering: pixelated;
  background: #fff;
}

.auth-handoff-qr-hint {
  font-size: 9px;
  font-weight: 300;
  color: var(--tx-lo);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.auth-handoff-row {
  width: 100%;
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.auth-handoff-link {
  font-size: 12px;
  padding: 10px 12px;
}

.auth-handoff-copy {
  margin-top: 0;
  white-space: nowrap;
  padding-inline: 16px;
}

.auth-label {
  width: 100%;
  font-size: 10px;
  font-weight: 400;
  color: var(--tx-lo);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 8px;
}

.signup-countdown {
  margin-top: 8px;
  font-size: 11px;
  font-weight: 300;
  color: var(--tx-lo);
  letter-spacing: 0.04em;
}

.signup-countdown em {
  font-style: normal;
  font-weight: 500;
  color: var(--tx-md);
  font-variant-numeric: tabular-nums;
}

.signup-countdown.urgent em {
  color: var(--red);
}

.signup-error {
  display: none;
  align-items: baseline;
  gap: 8px;
  margin-top: 16px;
  padding: 10px 14px;
  border-left: 2px solid transparent;
  font-size: 11px;
  font-weight: 300;
  letter-spacing: 0.03em;
  line-height: 1.5;
  width: 100%;
  max-width: 340px;
}

.signup-error.auth-status-hidden {
  display: none;
}

.signup-error:not(.auth-status-hidden) {
  display: flex;
}

.signup-error-soft {
  color: var(--tx-lo);
  border-left-color: var(--w4);
}

.signup-error-hard {
  color: #e07070;
  border-left-color: var(--red-dim);
  background: rgba(224, 72, 72, 0.05);
}

.signup-error-icon {
  flex-shrink: 0;
  font-size: 10px;
}

.signup-error-retry {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 500;
  color: var(--cy);
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  padding: 0;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.signup-error-retry:hover {
  color: var(--tx-hi);
}

.expired-icon {
  font-size: 24px;
  color: var(--tx-dim);
  margin-bottom: 14px;
}

.expired-msg {
  font-size: 13px;
  font-weight: 300;
  color: var(--tx-lo);
  letter-spacing: 0.03em;
  text-align: center;
  line-height: 1.7;
  margin-bottom: 22px;
}

.done-mark {
  font-size: 20px;
  color: var(--green);
  margin-bottom: 14px;
}

.done-msg {
  font-size: 13px;
  font-weight: 300;
  color: var(--tx-lo);
  letter-spacing: 0.03em;
  margin-bottom: 16px;
}

.auth-input,
.pw-input {
  width: 100%;
  font-size: 20px;
  font-weight: 300;
  color: var(--tx-hi);
  background: var(--bg3);
  border: 1px solid var(--w3);
  outline: none;
  padding: 14px 18px;
  caret-color: var(--cy);
  transition: border-color 0.12s;
}

.auth-input:focus,
.pw-input:focus {
  border-color: var(--cy-dim);
}

.auth-input::placeholder,
.pw-input::placeholder {
  color: var(--tx-lo);
}

.auth-field-wrap,
.pw-field-wrap {
  width: 100%;
  position: relative;
}

.pw-input {
  padding-right: 48px;
  letter-spacing: 0.08em;
}

.pw-toggle {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--tx-lo);
  cursor: pointer;
}

.pw-strength {
  width: 100%;
  min-height: 16px;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 300;
  letter-spacing: 0.06em;
  color: var(--tx-lo);
}

.pw-strength.weak {
  color: var(--red);
}

.pw-strength.ok {
  color: var(--tx-md);
}

.pw-strength.strong {
  color: var(--green);
}

.pw-note {
  font-size: 11px;
  font-weight: 300;
  color: var(--tx-lo);
  letter-spacing: 0.03em;
  line-height: 1.7;
  text-align: center;
  max-width: 340px;
  margin-top: 24px;
}

.pw-submit {
  margin-top: 28px;
  padding: 10px 24px;
  background: none;
  border: 1px solid var(--cy-dim);
  color: var(--cy);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.13s, box-shadow 0.13s;
}

.pw-submit:hover {
  border-color: var(--cy);
  box-shadow: 0 0 12px var(--cy-glow);
}

.pw-submit:disabled {
  opacity: 0.55;
  cursor: default;
  box-shadow: none;
}

.pw-submit.loading {
  opacity: 0.5;
  cursor: wait;
}

.generating {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.generating.show {
  display: flex;
}

.gen-text {
  font-size: 12px;
  font-weight: 300;
  color: var(--tx-lo);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.gen-line {
  width: 120px;
  height: 1px;
  background: var(--w2);
  overflow: hidden;
}

.gen-fill {
  height: 100%;
  background: var(--cy);
  animation: fillLine 0.9s ease forwards;
}

.auth-status {
  margin-top: 22px;
  font-size: 11px;
  font-weight: 300;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--tx-md);
}

.auth-status-hidden {
  display: none;
}

.auth-status:not(.auth-status-hidden) {
  display: block;
}

.auth-status[data-level='error'] {
  color: var(--red);
}

.auth-status[data-level='success'] {
  color: var(--green);
}

body.auth-signup {
  overflow: hidden;
}

body.auth-signup::before {
  z-index: 999;
  background: repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0, 0, 0, 0.06) 3px, rgba(0, 0, 0, 0.06) 4px);
}

body.auth-signup::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.5) 100%);
}

.auth-signup .auth-stage {
  position: fixed;
  inset: 0;
  min-height: 0;
  padding: 40px 24px;
}

.auth-signup .auth-card {
  max-width: 400px;
}

.auth-signup .auth-kicker {
  font-size: 9px;
  letter-spacing: 0.2em;
  margin-bottom: 18px;
  animation: up 0.3s ease both;
}

.auth-signup .auth-handle {
  font-size: clamp(46px, 11vw, 56px);
  font-weight: 700;
  line-height: 1;
  margin-bottom: 24px;
  letter-spacing: -0.01em;
  animation: up 0.3s ease 0.05s both;
}

.auth-signup .auth-context {
  font-size: 13px;
  letter-spacing: 0.03em;
  line-height: 1.65;
  margin-bottom: 28px;
  animation: up 0.25s ease 0.08s both;
}

.auth-signup .pw-submit {
  margin-top: 0;
  padding: 12px 32px;
  animation: up 0.25s ease 0.12s both;
}

.auth-signup .auth-handoff {
  gap: 0;
}

.auth-signup .auth-handoff-qr {
  width: 180px;
  height: 180px;
  padding: 12px;
  border: 0;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: up 0.2s ease both;
}

.auth-signup .auth-handoff-qr-image {
  width: 156px;
  height: 156px;
  image-rendering: pixelated;
  background: #fff;
}

.auth-signup .auth-handoff-qr-hint {
  margin-top: 10px;
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--tx-lo);
  animation: up 0.2s ease 0.05s both;
}

.auth-signup .signup-countdown {
  margin-top: 14px;
  animation: up 0.2s ease 0.08s both;
}

.auth-signup .link-or {
  margin-top: 16px;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tx-dim);
  animation: up 0.2s ease 0.1s both;
}

.auth-signup .link-row {
  margin-top: 10px;
  width: 100%;
  display: flex;
  align-items: stretch;
  border: 1px solid var(--w3);
  animation: up 0.2s ease 0.12s both;
}

.auth-signup .link-url {
  flex: 1;
  min-width: 0;
  border: 0;
  background: var(--bg3);
  color: var(--tx-md);
  font-size: 11px;
  font-weight: 300;
  padding: 9px 14px;
  letter-spacing: 0.02em;
}

.auth-signup .link-copy {
  margin: 0;
  border: 0;
  border-left: 1px solid var(--w3);
  padding: 0 14px;
  font-size: 9px;
  line-height: 1;
  color: var(--cy);
  background: none;
  white-space: nowrap;
}

.auth-signup .link-copy:hover {
  background: rgba(0, 207, 224, 0.05);
  box-shadow: none;
}

.auth-signup .link-copy.copied {
  color: var(--green);
}

.auth-signup .signup-error {
  animation: errIn 0.2s ease both;
}

.auth-signup .expired-icon,
.auth-signup .done-mark {
  animation: up 0.2s ease both;
}

.auth-signup .expired-msg,
.auth-signup .done-msg {
  animation: up 0.2s ease 0.05s both;
}

@media (max-width: 520px) {
  .auth-signup .auth-stage {
    padding: 32px 18px;
  }

  .auth-signup .auth-card {
    max-width: 360px;
  }
}

@keyframes up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes errIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fillLine {
  from { width: 0; }
  to { width: 100%; }
}
