/* Sign-in forms: the homepage card (dark, inside .lp) and the dashboard's
   signed-out fallback (follows the app's light or dark theme). Loaded after the
   page's own stylesheet so these spacing rules win. Settings
   (account-settings.css) reuses the password box and strength meter. */
.auth-container,
.account-settings {
  --auth-danger: var(--danger, #b63249);
  --auth-muted: var(--fg-secondary, #606b80);
  --auth-track: var(--border, #dce1ec);
  --auth-weak: var(--danger, #b63249);
  --auth-okay: #b7791f;
  --auth-good: var(--teal, #087c70);
  --auth-strong: #15803d;
  --auth-link: var(--primary, #6149bd);
}

body.dark-mode :is(.auth-container, .account-settings) {
  --auth-okay: #f2c66d;
  --auth-strong: #86efac;
}

.lp .auth-container {
  --auth-danger: #fca5a5;
  --auth-muted: var(--lp-muted, #a7a3c7);
  --auth-track: rgba(255, 255, 255, .12);
  --auth-weak: #f87171;
  --auth-okay: #fbbf24;
  --auth-good: #2dd4bf;
  --auth-strong: #4ade80;
  --auth-link: var(--lp-violet-soft, #c4b5fd);
}

.auth-form form {
  display: grid;
  gap: 16px;
}

.auth-field {
  display: grid;
  gap: 6px;
  min-width: 0;
  text-align: left;
}

.auth-field[hidden] {
  display: none;
}

.auth-field__top {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  justify-content: space-between;
}

.auth-field__label {
  font-size: .92rem;
  font-weight: 600;
  line-height: 1.3;
}

.auth-form .auth-field input,
.lp .lp-auth__card .auth-form .auth-field input {
  box-sizing: border-box;
  margin: 0;
  max-width: 100%;
  min-height: 48px;
  width: 100%;
}

.auth-form .auth-field input[aria-invalid="true"],
.lp .lp-auth__card .auth-form .auth-field input[aria-invalid="true"] {
  border-color: var(--auth-danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--auth-danger) 22%, transparent);
}

.auth-field__error {
  align-items: flex-start;
  color: var(--auth-danger);
  display: flex;
  font-size: .87rem;
  gap: 8px;
  line-height: 1.4;
  margin: 0;
}

.auth-field__error::before {
  align-items: center;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  content: "!";
  display: inline-flex;
  flex: none;
  font-size: .72rem;
  font-weight: 700;
  height: 15px;
  justify-content: center;
  margin-top: 2px;
  width: 15px;
}

.auth-field__error[hidden] {
  display: none;
}

.auth-field .auth-hint,
.lp .lp-auth__card .auth-field .auth-hint {
  color: var(--auth-muted);
  font-size: .82rem;
  line-height: 1.45;
  margin: 0;
  text-align: left;
}

.auth-secondary-link,
.auth-toggle a {
  color: var(--auth-link);
  cursor: pointer;
  font-weight: 600;
}

.auth-field__top .auth-secondary-link {
  font-size: .86rem;
}

.auth-secondary-link:focus-visible,
.auth-toggle a:focus-visible,
.auth-fineprint a:focus-visible {
  border-radius: 4px;
  outline: 2px solid var(--auth-link);
  outline-offset: 2px;
}

/* Password strength: a short bar and a word, never color alone. */
.auth-strength {
  align-items: center;
  color: var(--auth-muted);
  display: flex;
  font-size: .84rem;
  gap: 10px;
  margin: 0;
}

.auth-strength[hidden] {
  display: none;
}

.auth-strength__bar {
  background: var(--auth-track);
  border-radius: 999px;
  flex: 0 0 88px;
  height: 6px;
  overflow: hidden;
}

.auth-strength__bar > span {
  border-radius: inherit;
  display: block;
  height: 100%;
  transition: background-color .2s ease, width .2s ease;
  width: 0;
}

.auth-strength[data-level="1"] .auth-strength__bar > span { background: var(--auth-weak); width: 25%; }
.auth-strength[data-level="2"] .auth-strength__bar > span { background: var(--auth-okay); width: 50%; }
.auth-strength[data-level="3"] .auth-strength__bar > span { background: var(--auth-good); width: 75%; }
.auth-strength[data-level="4"] .auth-strength__bar > span { background: var(--auth-strong); width: 100%; }

.auth-form .auth-submit {
  margin-top: 4px;
  min-height: 48px;
  width: 100%;
}

.auth-form button[disabled] {
  cursor: progress;
  opacity: .75;
}

.auth-fineprint {
  color: var(--auth-muted);
  font-size: .8rem;
  line-height: 1.5;
  margin: -4px 0 0;
  text-align: left;
}

.auth-fineprint a {
  color: inherit;
  text-decoration: underline;
}

.auth-form > .auth-toggle {
  margin: 18px 0 0;
}

.auth-resend {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.auth-resend p {
  color: var(--auth-muted);
  font-size: .9rem;
  margin: 0;
}

/* Password boxes with a Show button: homepage card, dashboard fallback and settings. */
.auth-password {
  position: relative;
}

:is(.auth-form, .account-settings) .auth-password input {
  padding-right: 76px;
}

:is(.auth-form, .account-settings) .auth-password .auth-password__toggle {
  background: transparent;
  border: 0;
  border-radius: 8px;
  box-shadow: none;
  color: var(--auth-link);
  cursor: pointer;
  font-size: .88rem;
  font-weight: 600;
  margin: 0;
  min-height: 34px;
  padding: 6px 10px;
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: auto;
}

:is(.auth-form, .account-settings) .auth-password .auth-password__toggle:hover {
  background: color-mix(in srgb, var(--auth-link) 12%, transparent);
  box-shadow: none;
  transform: translateY(-50%);
}

:is(.auth-form, .account-settings) .auth-password .auth-password__toggle:focus-visible {
  outline: 2px solid var(--auth-link);
  outline-offset: 1px;
}

#authSuccess {
  line-height: 1.5;
  text-align: left;
}

@media (max-width: 480px) {
  .auth-form form {
    gap: 14px;
  }

  .auth-form .auth-field input,
  .lp .lp-auth__card .auth-form .auth-field input {
    font-size: 16px; /* stops iOS zooming into the box */
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-strength__bar > span {
    transition: none;
  }
}

/* The homepage card pins its Show button 7px from the top; center it instead. */
.lp .lp-auth__card .auth-form .auth-password .auth-password__toggle {
  top: 50%;
  transform: translateY(-50%);
}

/* Two-factor code step, shown after a correct password or a Google sign-in. */
#twoFactorForm {
  display: none;
}

.auth-form .auth-field input.auth-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.25rem;
  letter-spacing: .18em;
  text-align: center;
}

.auth-check {
  align-items: center;
  color: var(--auth-muted);
  cursor: pointer;
  display: flex;
  font-size: .9rem;
  gap: 10px;
  text-align: left;
}

.auth-check input {
  accent-color: var(--auth-link);
  flex: none;
  height: 18px;
  margin: 0;
  width: 18px;
}

.auth-check--weekly {
  align-items: flex-start;
  line-height: 1.45;
  margin: 2px 0 14px;
}

.auth-check--weekly input {
  margin-top: 2px;
}

#twoFactorForm > .auth-toggle + .auth-toggle {
  margin-top: 8px;
}

/* "Log in with a passkey": a quiet second button under Log in. Hidden until
   passkeys.js finds navigator.credentials, so older browsers never see it. */
.auth-form .auth-passkey,
.lp .lp-auth__card .auth-form .auth-passkey {
  align-items: center;
  background: transparent;
  border: 1px solid var(--auth-track);
  border-radius: 12px;
  box-shadow: none;
  color: var(--auth-link);
  cursor: pointer;
  display: flex;
  filter: none;
  font: 600 .98rem Inter, sans-serif;
  gap: 10px;
  justify-content: center;
  margin: 10px 0 0;
  min-height: 48px;
  padding: 12px 16px;
  transform: none;
  transition: background-color .15s ease, border-color .15s ease;
  width: 100%;
}

.auth-form .auth-passkey:hover,
.lp .lp-auth__card .auth-form .auth-passkey:hover {
  background: color-mix(in srgb, var(--auth-link) 10%, transparent);
  border-color: var(--auth-link);
  box-shadow: none;
  filter: none;
}

.auth-form .auth-passkey:focus-visible,
.lp .lp-auth__card .auth-form .auth-passkey:focus-visible {
  box-shadow: var(--ring, 0 0 0 3px rgba(139, 92, 246, .45));
  outline: none;
}

.auth-form .auth-passkey[hidden] {
  display: none;
}

.auth-passkey__icon {
  flex: none;
}
