.m-auth {
  --auth-page: var(--mauve-blush);
  --auth-control: color-mix(in srgb, var(--theme-card) 74%, var(--theme-soft));
  --auth-elevation: color-mix(in srgb, var(--mauve-deep) 12%, transparent);
  --auth-highlight: color-mix(in srgb, var(--theme-card) 86%, transparent);
  background: radial-gradient(ellipse at 82% 0%, var(--theme-soft), transparent 52%), var(--auth-page);
  color: var(--theme-ink);
  padding: clamp(22px, 3.5vw, 56px) max(clamp(16px, 4vw, 68px), env(safe-area-inset-right))
    clamp(34px, 4.8vw, 72px) max(clamp(16px, 4vw, 68px), env(safe-area-inset-left));
}

html[data-theme="dark"] .m-auth {
  --auth-page: var(--theme-page);
  color-scheme: dark;
}

.m-auth-layout {
  width: min(100%, 520px);
  display: grid;
  margin-inline: auto;
  border: 1px solid var(--theme-line);
  border-radius: 28px;
  background: var(--theme-card);
  box-shadow: 0 18px 60px var(--auth-elevation);
}

.m-auth-story { display: none; }

.m-auth-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: clamp(12px, 3vw, 34px) clamp(18px, 4vw, 50px) clamp(25px, 4vw, 54px);
}

.m-auth-top {
  color: var(--theme-muted);
  font-size: .875rem;
  font-weight: 650;
}

.m-auth-top a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
}

.m-auth svg { width: 20px; height: 20px; flex: none; }
.m-auth-top a svg { width: 16px; height: 16px; }

.m-auth-toggle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--theme-muted);
  cursor: pointer;
}

.m-auth-toggle:hover {
  background: var(--theme-soft);
  color: var(--theme-accent);
}

.m-auth-body {
  width: min(100%, 440px);
  margin: auto;
  padding-block: clamp(16px, 3vw, 34px) 0;
}

.m-auth-intro { margin-block: 0 26px; text-align: center; }

.m-auth-logo {
  display: inline-grid;
  place-items: center;
  max-width: 100%;
  padding: 2px 14px;
  margin-bottom: 19px;
  border: 1px solid var(--theme-line);
  border-radius: 16px;
  background: linear-gradient(145deg, var(--theme-card), var(--auth-control));
  box-shadow: inset 1px 1px 0 var(--auth-highlight), 0 6px 18px var(--auth-elevation);
}

.m-auth-logo > .m-auth-brand.brand-logo-only {
  width: clamp(157px, 46vw, 205px);
  height: 54px;
  min-width: 0;
}

.m-auth h1 {
  margin: 0;
  color: var(--theme-ink);
  font-size: clamp(1.8rem, 3.25vw, 2.75rem);
  letter-spacing: -.055em;
  line-height: 1.11;
  text-wrap: balance;
}

.m-auth-sub {
  max-width: 36ch;
  margin: 9px auto 0;
  color: var(--theme-muted);
  font-size: .95rem;
  line-height: 1.55;
  text-wrap: pretty;
}

.m-auth-form, .m-auth-welcome-actions, .m-auth-providers {
  display: grid;
  gap: 16px;
}

.m-auth-field { display: grid; gap: 6px; min-width: 0; }
.m-auth-field label { font-size: .9rem; font-weight: 700; }
.m-auth-control { position: relative; }

.m-auth-field-icon {
  position: absolute;
  inset-inline-start: 15px;
  top: 50%;
  display: grid;
  transform: translateY(-50%);
  color: var(--theme-accent);
  pointer-events: none;
}

.m-auth-field .m-auth-control input {
  display: block;
  width: 100%;
  height: 54px;
  padding: 0 14px 0 45px;
  border: 1px solid var(--theme-control-line);
  border-radius: 14px;
  background: var(--auth-control);
  color: var(--theme-ink);
  box-shadow: inset 1px 2px 5px var(--auth-elevation), inset -1px -1px 0 var(--auth-highlight);
  font: inherit;
  font-size: 1rem;
}

.m-auth-field .m-auth-password input { padding-inline-end: 52px; }
.m-auth-control input::placeholder { color: var(--theme-muted); opacity: 1; }
.m-auth-field .m-auth-control input[aria-invalid="true"] { border-color: var(--theme-error); }

.m-auth-toggle {
  position: absolute;
  top: 5px;
  inset-inline-end: 5px;
  border-radius: 10px;
}

.m-auth-field-error, .m-auth-help, .m-auth-password-help, .m-auth-info, .m-auth-result {
  margin: 0;
  font-size: .84rem;
  line-height: 1.55;
}

.m-auth-field-error { color: var(--theme-error); }
.m-auth .form-error:empty { display: none; }
.m-auth-field-error:empty, .m-auth-result:empty { position: absolute; }
.m-auth-help, .m-auth-password-help { color: var(--theme-muted); }

.m-auth-password-help { display: grid; gap: 5px; }
.m-auth-password-help p { margin: 0; }
.m-auth-strength { display: flex; gap: 5px; height: 4px; }
.m-auth-strength span { flex: 1; border-radius: 5px; background: var(--theme-line); }
.m-auth-strength:not([data-level="0"]) span:first-child,
.m-auth-strength:is([data-level="2"], [data-level="3"], [data-level="4"]) span:nth-child(2),
.m-auth-strength:is([data-level="3"], [data-level="4"]) span:nth-child(3),
.m-auth-strength[data-level="4"] span:nth-child(4) { background: var(--theme-accent); }

.m-auth-info, .m-auth .form-error:not(:empty) {
  border-radius: 12px;
  padding: 11px 13px;
}

.m-auth-info {
  border: 1px solid var(--theme-line);
  background: var(--auth-control);
  margin-block-end: 12px;
}

.m-auth-form .m-auth-info { margin-block-end: 0; }
.m-auth .form-error { font-size: .875rem; }
.m-auth-result { color: var(--theme-accent); }

.m-auth-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 14px;
  color: var(--theme-muted);
  font-size: .875rem;
}

.m-auth-options > a, .m-auth-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

.m-auth-check { cursor: pointer; }
.m-auth-check input { width: 17px; height: 17px; margin: 0; }

.m-auth :is(.m-auth-switch, .m-auth-legal, .m-auth-options) a {
  color: var(--theme-accent);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.m-auth :is(.m-auth-switch, .m-auth-legal, .m-auth-options, .m-auth-top) a:hover {
  color: var(--theme-accent-hover);
}

.m-auth :is(.m-auth-primary, .m-auth-secondary, .m-auth-social) {
  display: flex;
  width: 100%;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  border: 1px solid var(--theme-control-line);
  border-radius: 999px;
  font: inherit;
  font-size: .96rem;
  font-weight: 750;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: box-shadow .18s ease, filter .18s ease, transform .18s ease;
}

.m-auth .m-auth-primary {
  border-color: var(--mauve-deep);
  background: var(--mauve-action-fill);
  color: #fff;
  box-shadow: inset 0 1px 0 #ffffff28, 0 6px 16px var(--auth-elevation);
}

.m-auth .m-auth-primary:not(:disabled):hover { filter: brightness(1.1); transform: translateY(-1px); }
.m-auth .m-auth-primary:not(:disabled):active { transform: translateY(1px); }
.m-auth button:disabled { opacity: .82; cursor: wait; }
.m-auth-submit-label { display: inline-flex; align-items: center; gap: 10px; }
.m-auth-submit-pending { display: none; }
.m-auth-primary[aria-busy="true"] .m-auth-submit-label { display: none; }
.m-auth-primary[aria-busy="true"] .m-auth-submit-pending { display: inline-flex; align-items: center; gap: 10px; }
.m-auth-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #ffffff60;
  border-top-color: #fff;
  border-radius: 50%;
  animation: auth-spin .75s linear infinite;
}

@keyframes auth-spin { to { rotate: 1turn; } }

.m-auth :is(.m-auth-social, .m-auth-secondary) {
  background: var(--auth-control);
  color: var(--theme-ink);
}

.m-auth :is(.m-auth-social, .m-auth-secondary):not(:disabled):hover { box-shadow: var(--theme-shadow); }

.m-auth .m-auth-google {
  background: #fff;
  color: #1f1f1f;
  border-color: #747775;
  font-family: Roboto, Arial, sans-serif;
  font-weight: 500;
}

.m-auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 12px;
  color: var(--theme-muted);
  font-size: .84rem;
  text-align: center;
}

.m-auth-divider::before, .m-auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--theme-line);
}

.m-auth-providers { gap: 9px; }
.m-auth .m-auth-social :is(svg, img) {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  object-fit: contain;
}
.m-auth .m-auth-social:disabled {
  opacity: 1;
  cursor: not-allowed;
  box-shadow: none;
}
.m-auth .m-auth-passkey { color: var(--theme-accent); }
.m-auth-provider-status {
  margin: 6px 12px 3px;
  color: var(--theme-muted);
  font-size: .8rem;
  line-height: 1.5;
  text-align: center;
}
.m-auth-switch, .m-auth-legal {
  margin: 19px 0 0;
  color: var(--theme-muted);
  line-height: 1.55;
  text-align: center;
}

.m-auth-switch { font-size: .92rem; }
.m-auth-legal { font-size: .8rem; }

@media (min-width: 900px) {
  .m-auth-layout {
    width: min(100%, 1380px);
    min-height: 680px;
    grid-template-columns: minmax(0, 47fr) minmax(0, 53fr);
  }

  .m-auth-story {
    position: relative;
    isolation: isolate;
    display: flex;
    align-items: flex-end;
    min-width: 0;
    overflow: hidden;
    padding: clamp(25px, 3.2vw, 58px);
    border-radius: 27px 0 0 27px;
    background: var(--mauve-deep);
    color: var(--mauve-inverse);
  }

  .m-auth-story-photo, .m-auth-story::after {
    position: absolute;
    inset: 0;
    pointer-events: none;
  }

  .m-auth-story-photo { z-index: -2; }
  .m-auth-story-photo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 79% 35%;
  }
  .m-auth-story-photo.is-custom img { object-position: center; }

  .m-auth-story::after {
    z-index: -1;
    content: "";
    background: linear-gradient(180deg, #2800360d 34%, #28003635 55%, #23042ae8 100%);
  }

  .m-auth-story-title {
    margin: 0;
    font-size: clamp(2.4rem, 4vw, 4.75rem);
    font-weight: 800;
    letter-spacing: -.07em;
    line-height: .98;
    text-shadow: 0 2px 12px #23042a50;
  }

  .m-auth-story-description {
    max-width: 34ch;
    margin: 16px 0 0;
    color: var(--mauve-inverse-muted);
    font-size: clamp(.92rem, 1.2vw, 1.08rem);
    line-height: 1.5;
  }
}

@media (prefers-reduced-motion: reduce) {
  .m-auth :is(.m-auth-primary, .m-auth-secondary, .m-auth-social) { transition: none; }
  .m-auth .m-auth-primary:not(:disabled):is(:hover, :active) { transform: none; }
  .m-auth-spinner { animation: none; }
}
