/* Shared login/register safe-area layout. Keep long forms in normal flow. */
.auth-header {
  padding-top: calc(env(safe-area-inset-top, 0px) + var(--nav-top));
}
@media (max-width: 760px), (pointer: coarse) {
  .auth-page {
    --auth-safe-top: max(32px, env(safe-area-inset-top, 0px));
    --auth-header-height: calc(var(--auth-safe-top) + 91px);
  }
  .auth-header {
    position: relative;
    min-height: var(--auth-header-height);
    padding: calc(var(--auth-safe-top) + 12px) max(20px, env(safe-area-inset-right, 0px)) 16px max(20px, env(safe-area-inset-left, 0px));
    animation: none;
  }
  .auth-header .brand img {
    width: 180px;
    max-width: 56vw;
    height: auto;
    margin: 0;
  }
  .auth-stage {
    min-height: calc(100svh - var(--auth-header-height));
    padding-top: 12px;
  }
}
@media (max-width: 760px) {
  .auth-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    padding: 0 max(14px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px));
  }
  .auth-column {
    flex: none;
    min-height: calc(100svh - var(--auth-header-height) - max(24px, env(safe-area-inset-bottom, 0px)));
    grid-template-rows: minmax(24px, 1fr) auto minmax(72px, 1fr);
    align-content: stretch;
  }
  .auth-card { grid-row: 2; width: 100%; }
  .auth-foot { grid-row: 3; align-self: start; }
  .auth-intro { flex: none; width: 100%; }
}
@media (max-width: 760px) {
  .auth-card { min-width: 0; grid-template-columns: minmax(0, 1fr); }
  .auth-card :is(.login-panel, .register-panel, .turnstile-zone, .turnstile-shell) { min-width: 0; }
}
@media (max-width: 379px) {
  .auth-card .turnstile-shell { grid-template-columns: minmax(0, 1fr); width: 100%; height: 60px; min-height: 60px; }
  .auth-card #turnstile-widget { width: 300px; transform: scale(.9); transform-origin: top center; }
}
@media (max-width: 359px) {
  .auth-card .turnstile-shell { height: 52px; min-height: 52px; }
  .auth-card #turnstile-widget { transform: scale(.8); }
}

/* Anime's rounded type, from the sliced web fonts in /assets/fonts/aulama-round.css. */
.auth-page { --auth-rounded-font: "Aulama Round Latin", "Aulama Round HK", "PingFang TC", sans-serif; }
html[lang^="zh"] .auth-page { --auth-rounded-font: "Aulama Round HK", "Aulama Round Latin", "PingFang TC", sans-serif; }
.auth-page { font-family: var(--auth-rounded-font); font-weight: 500; }
html[lang="zh-CN"] .auth-page, html[lang="zh-Hans"] .auth-page {
  --auth-rounded-font: "Aulama Round CN", "Aulama Round Latin", "PingFang SC", sans-serif;
}
.auth-page :is(button, input, select, textarea) { font-family: var(--auth-rounded-font); }

/* The image overlays its initial; it must not create a second grid row. */
.auth-page .device-account-avatar { position: relative; }
.auth-page .device-account-avatar > span { grid-area: 1 / 1; }
.auth-page .device-account-avatar > img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* Keep the brand above scrolling content; fade blur beyond the header edge. */
.auth-header { isolation: isolate; }
.auth-header::before {
  content: "";
  position: absolute;
  inset: 0 0 -36px;
  z-index: -1;
  pointer-events: none;
  /* a light tint of the page colour, not a solid band: the blur does the work */
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 52%, transparent) 0%, color-mix(in srgb, var(--bg) 30%, transparent) 55%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 55%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 55%, transparent 100%);
  opacity: var(--auth-scroll-shade, 0);
}
@media (max-width: 760px), (pointer: coarse) {
  .auth-header { position: sticky; top: 0; }
}
@media (prefers-reduced-transparency: reduce) {
  .auth-header::before { -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* Phones on their side have little height to spare: a slim header, so the
   form starts within the first screen. */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 560px) {
  .auth-page {
    --auth-safe-top: max(10px, env(safe-area-inset-top, 0px));
    --auth-header-height: calc(var(--auth-safe-top) + 56px);
  }
  .auth-header {
    min-height: var(--auth-header-height);
    padding: var(--auth-safe-top) max(20px, env(safe-area-inset-right, 0px)) 8px max(20px, env(safe-area-inset-left, 0px));
  }
  .auth-header .brand img { width: 124px; }
  .auth-header .theme-button { width: 40px; height: 40px; }
  .auth-stage { padding-top: 4px; }
}
