.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 16px;
}

.card {
  width: 100%;
  max-width: 368px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 24px 24px 22px;
  animation: slideUp var(--dur-med) var(--ease-out) both;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

.brand-mark img {
  flex: none;
  width: 40px;
  height: 40px;
}

.brand h1 {
  margin: 0;
  text-transform: uppercase;
  color: var(--text);
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Scoped to the auth pages: this file is also loaded by the dashboard,
   where a bare `form` selector would override Tailwind grid/flex utilities
   on the React settings panels. */
.auth-wrap form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: var(--space);
}

.field:first-child {
  margin-top: 0;
}

.field > label,
.choice-field legend {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  margin: 0;
}

.field-hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-faint);
}

input[type="text"],
input[type="password"],
select {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px; /* shadcn-like: rounded-md */
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 11px 12px;
  outline: none;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}

input[type="text"]::placeholder,
input[type="password"]::placeholder {
  color: var(--text-faint);
}

input[type="text"]:hover,
input[type="password"]:hover,
select:hover {
  border-color: var(--text-faint);
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  border-color: var(--text-faint);
  box-shadow: 0 0 0 1px var(--text-faint); /* shadcn-like: ring-1 */
}

.form-actions {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.link-btn {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  text-align: left;
  transition: color var(--dur-fast) var(--ease-out);
}

.link-btn:hover {
  color: var(--text);
}

/* Back navigation (step 2 → step 1): shadcn ghost button with arrow */
.back-btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  padding: 6px 10px 6px 8px;
  transition:
    color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
}

.back-btn::before {
  content: '←';
  font-size: 13px;
  line-height: 1;
}

.back-btn:hover {
  color: var(--text);
  background: var(--bg-elev);
  border-color: var(--border);
}

.auth-footer {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.auth-footer a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: border-color var(--dur-fast) var(--ease-out);
}

.auth-footer a:hover {
  border-bottom-color: var(--text-muted);
}

.totp-hint {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

.totp-input {
  text-align: center;
  font-size: 20px;
  letter-spacing: 0.45em;
  font-variant-numeric: tabular-nums;
  padding: 12px 8px 12px 16px;
}

/* Login TOTP: six digit cells, real input hidden on top (no visible caret) */
.totp-boxes {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.totp-boxes .totp-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  box-shadow: none;
  font-size: 16px; /* >= 16px prevents iOS focus zoom */
  cursor: text;
  -webkit-text-security: disc;
}

.totp-boxes .totp-overlay:hover,
.totp-boxes .totp-overlay:focus {
  border: none;
  box-shadow: none;
}

.totp-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.totp-cell.filled {
  border-color: var(--accent);
  transform: translateY(-1px);
  font-size: 22px;
  letter-spacing: 0;
}

.totp-boxes:focus-within .totp-cell.active {
  border-color: var(--accent);
  animation: totpCellPulse 1.4s var(--ease-soft) infinite;
}

@keyframes totpCellPulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
  }
  50% {
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 6%, transparent);
  }
}

@media (prefers-reduced-motion: reduce) {
  .totp-cell,
  .totp-boxes:focus-within .totp-cell.active {
    animation: none;
    transition: none;
  }
}

.qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
  padding: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}

.qr-wrap img {
  width: 152px;
  height: 152px;
  display: block;
  background: #fff; /* QR codes need a white backing to stay scannable in dark mode */
  border: 1px solid var(--border);
}

.secret-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  border-top: 1px solid var(--border-soft);
  padding-top: 12px;
}

.secret-line {
  margin: 0;
  font-size: 10px;
  color: var(--text-muted);
  word-break: break-all;
  text-align: left;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  line-height: 1.45;
  flex: 1;
}

.turnstile-host {
  width: 100%;
  margin-top: 10px;
  line-height: 0;
}

.turnstile-host:empty {
  margin-top: 0;
  min-height: 0;
}

.choice-field {
  margin: var(--space) 0 0;
  padding: 0;
  border: 0;
  min-inline-size: 0;
}

.choice-field legend {
  margin: 0 0 6px;
  padding: 0;
}

.choice-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elev);
}

.choice {
  position: relative;
  margin: 0;
  display: block;
  cursor: pointer;
}

.choice + .choice {
  border-left: 1px solid var(--border);
}

.choice input {
  position: absolute;
  opacity: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.choice span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-muted);
  background: transparent;
  user-select: none;
  transition:
    color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
}

.choice:hover span {
  color: var(--text);
  background: var(--surface-2);
}

.choice input:checked + span {
  color: var(--accent-text);
  background: var(--accent);
  font-weight: var(--fw-semi);
}

.choice input:focus-visible + span {
  outline: 1px solid var(--focus);
  outline-offset: -1px;
}

.done-block {
  padding: 4px 0 2px;
}

.done-msg {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}
