.spark-auth {
  --auth-ink: #171613;
  --auth-surface: #22211d;
  --auth-paper: #f4eddd;
  --auth-muted: #c7bfb1;
  --auth-line: #4d4840;
  --auth-accent: #e7a379;
  box-sizing: border-box;
  position: fixed;
  inset: 0;
  width: min(29rem, calc(100% - 2rem));
  height: min(34rem, calc(100% - 2rem));
  height: min(34rem, calc(100dvh - 2rem));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  overflow: hidden;
  color: var(--auth-paper);
  background: var(--auth-ink);
  border: 1px solid var(--auth-line);
  border-radius: 1.125rem;
  box-shadow: 0 1.5rem 5rem #080705a8;
  color-scheme: dark;
}

.spark-auth *,
.spark-auth *::before,
.spark-auth *::after { box-sizing: border-box; }

.spark-auth [hidden] { display: none !important; }

.spark-auth::backdrop {
  background: rgb(12 11 10 / 72%);
  backdrop-filter: blur(7px);
}

.spark-auth__shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
}

.spark-auth__heading {
  min-height: 4.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: 1.15rem 1.6rem;
  border-bottom: 1px solid var(--auth-line);
}

.spark-auth__heading h2 {
  margin: 0;
  color: var(--auth-paper);
  font-size: clamp(1.35rem, 5vw, 1.75rem);
  font-weight: 640;
  letter-spacing: -.04em;
  line-height: 1.25;
}

.spark-auth :where(button, a, input):focus-visible {
  outline: 2px solid var(--auth-accent);
  outline-offset: 3px;
}

.spark-auth__heading h2:focus { outline: none; }

.spark-auth__close {
  appearance: none;
  display: grid;
  place-items: center;
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  margin: -.25rem -.52rem -.25rem 0;
  color: var(--auth-paper);
  background: transparent;
  border: 0;
  border-radius: .5rem;
  cursor: pointer;
}

.spark-auth__close span,
.spark-auth__close span::after {
  display: block;
  width: 1.03rem;
  height: 1px;
  background: currentColor;
  transform: rotate(45deg);
}

.spark-auth__close span::after {
  content: "";
  transform: rotate(90deg);
}

.spark-auth__body {
  min-height: 0;
  padding: 1.1rem 1.6rem 1.25rem;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.spark-auth__guest {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.spark-auth__methods {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-bottom: 1px solid var(--auth-line);
}

.spark-auth__methods button {
  appearance: none;
  min-height: 2.75rem;
  padding: .48rem .35rem;
  color: var(--auth-muted);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  font: inherit;
  font-size: .95rem;
  font-weight: 530;
  cursor: pointer;
}

.spark-auth__methods button[aria-pressed="true"] {
  color: var(--auth-paper);
  border-bottom-color: var(--auth-accent);
  font-weight: 650;
}

.spark-auth__message {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: .75rem;
  padding-block: 1.2rem;
}

.spark-auth__message p,
.spark-auth__account p {
  margin: 0;
  color: var(--auth-muted);
  font-size: .96rem;
  line-height: 1.55;
}

.spark-auth__message--form-note {
  flex: 0 0 auto;
  padding: .85rem 0 0;
}

.spark-auth__message--form-note p { font-size: .83rem; }

.spark-auth__retry {
  appearance: none;
  min-height: 2.75rem;
  padding: .5rem .8rem;
  color: var(--auth-paper);
  background: var(--auth-surface);
  border: 1px solid var(--auth-line);
  border-radius: .55rem;
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
}

.spark-auth__credentials {
  display: grid;
  gap: .55rem;
  padding-top: 1.15rem;
}

.spark-auth__credentials label {
  color: var(--auth-paper);
  font-size: .86rem;
  line-height: 1.5;
}

.spark-auth__credentials label:not(:first-child) { margin-top: .35rem; }

.spark-auth__credentials input {
  min-width: 0;
  width: 100%;
  min-height: 3rem;
  padding: .72rem .8rem;
  color: var(--auth-paper);
  background: var(--auth-surface);
  border: 1px solid var(--auth-line);
  border-radius: .55rem;
  font: inherit;
  font-size: 1rem;
}

.spark-auth__credentials input::placeholder { color: var(--auth-muted); }

.spark-auth__code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(6.4rem, auto);
  gap: .5rem;
}

.spark-auth__code-row button {
  appearance: none;
  min-height: 3rem;
  padding: .4rem .55rem;
  color: var(--auth-paper);
  background: var(--auth-surface);
  border: 1px solid var(--auth-line);
  border-radius: .55rem;
  font: inherit;
  font-size: .83rem;
  white-space: nowrap;
  cursor: pointer;
}

.spark-auth__footer {
  display: grid;
  grid-template-rows: 2.25rem 2.9rem;
  gap: .5rem;
  padding: .45rem 1.6rem 1.15rem;
  border-top: 1px solid var(--auth-line);
}

.spark-auth__status {
  align-self: center;
  margin: 0;
  overflow: auto;
  max-height: 100%;
  color: var(--auth-accent);
  font-size: .84rem;
  line-height: 1.34;
  overflow-wrap: anywhere;
}

.spark-auth__actions > * {
  width: 100%;
  height: 100%;
}

.spark-auth__action {
  appearance: none;
  display: grid;
  place-items: center;
  padding: .4rem .6rem;
  color: var(--auth-ink);
  background: var(--auth-paper);
  border: 1px solid var(--auth-paper);
  border-radius: .6rem;
  text-decoration: none;
  font: inherit;
  font-size: .95rem;
  font-weight: 680;
  cursor: pointer;
}

.spark-auth__action--outline {
  color: var(--auth-paper);
  background: transparent;
  border-color: var(--auth-line);
}

.spark-auth :where(button:disabled, a[aria-disabled="true"]) {
  opacity: .61;
  cursor: default;
}

.spark-auth__account {
  display: grid;
  align-content: center;
  gap: .5rem;
  min-height: 100%;
}

.spark-auth__account strong {
  color: var(--auth-paper);
  font-size: 1.15rem;
  font-weight: 620;
}

@media (hover: hover) {
  .spark-auth__close:hover,
  .spark-auth__retry:hover,
  .spark-auth__action--outline:hover { background: var(--auth-surface); }

  .spark-auth__methods button:hover { color: var(--auth-paper); }
}

@media (max-width: 380px) {
  .spark-auth__heading,
  .spark-auth__body,
  .spark-auth__footer { padding-inline: 1rem; }
}

@media (max-height: 410px) {
  .spark-auth__heading { min-height: 3.4rem; padding-block: .65rem; }
  .spark-auth__body { padding-block: .65rem; }
  .spark-auth__footer { padding-bottom: .65rem; }
}

@media (prefers-reduced-motion: reduce) {
  .spark-auth::backdrop { backdrop-filter: none; }
}
