/* One accepted login design at every width. Below 993px hides
   the image without reverting the form; >=993px uses the split layout.
   The portal's existing marker keeps this scoped to the enabled auth page. */
.auth-banner .auth-backdrop-layer { position: absolute; inset: 0; background: center 30% / cover no-repeat; opacity: 0; transition: opacity .6s ease; }
.auth-banner .auth-backdrop-layer.ready { opacity: 1; }
.auth-banner-copy .auth-greeting { display: none; }

  body[data-auth-backdrop="on"] #auth-view {
    --ax-accent: #b8860b; --ax-accent-hover: #9c7209; --ax-ring: rgba(184, 134, 11, .18);
    --ax-panel: #f6f7f9; --ax-field: #fbfcfd; --ax-field-focus: #fff; --ax-line: #e2e6ec;
    --ax-text: #2a2f36; --ax-muted: #7a828e; --ax-required: #e5484d; --ax-tile: #fff;
  }
  :root[data-theme="dark"] body[data-auth-backdrop="on"] #auth-view {
    --ax-accent: #d6a531; --ax-accent-hover: #e6b641; --ax-ring: rgba(214, 165, 49, .22);
    --ax-panel: #12171d; --ax-field: #1a2028; --ax-field-focus: #1e252e; --ax-line: #2c3540;
    --ax-text: #e8edf2; --ax-muted: #98a2ad; --ax-tile: #1f2730;
  }

  /* Wide windows keep one fixed screen; a taller form scrolls inside the right
     panel. Narrow windows below restore normal page scrolling. */
  html:has(body[data-auth-backdrop="on"] #auth-view:not([hidden])),
  body[data-auth-backdrop="on"]:has(#auth-view:not([hidden])) { overflow: hidden; }
  html:has(body[data-auth-backdrop="on"] #auth-view:not([hidden])) { scrollbar-gutter: auto; }
  body[data-auth-backdrop="on"] #auth-view:not([hidden]) { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1fr) clamp(420px, 24vw, 500px); width: 100%; min-width: 0; max-width: none; height: 100vh; height: 100dvh; margin: 0; padding: 0; overflow: hidden; background: var(--ax-panel); color: var(--ax-text); }
  body[data-auth-backdrop="on"]:has(#auth-view:not([hidden])) .auth-sakura,
  body[data-auth-backdrop="on"]:has(#auth-view:not([hidden])) .portal-footer { display: none; }

  /* The image side: plain "Northstar" top left, the greeting bottom left. */
  body[data-auth-backdrop="on"] #auth-view .auth-banner { height: 100vh; height: 100dvh; min-height: 0; border: 0; border-radius: 0; }
  body[data-auth-backdrop="on"] #auth-view .auth-banner { background: #dfe4e9; }
  :root[data-theme="dark"] body[data-auth-backdrop="on"] #auth-view .auth-banner { background: #101820; }
  body[data-auth-backdrop="on"] #auth-view .auth-banner::after { background: linear-gradient(180deg, rgba(0, 0, 0, .22) 0%, rgba(0, 0, 0, 0) 16%, rgba(0, 0, 0, 0) 76%, rgba(0, 0, 0, .34) 100%); }
  :root[data-theme="dark"] body[data-auth-backdrop="on"] #auth-view .auth-banner::after { background: linear-gradient(180deg, rgba(0, 0, 0, .40) 0%, rgba(0, 0, 0, .10) 16%, rgba(0, 0, 0, .14) 76%, rgba(0, 0, 0, .52) 100%); }
  body[data-auth-backdrop="on"] #auth-view .auth-banner-brand { top: 28px; left: 28px; }
  body[data-auth-backdrop="on"] #auth-view .auth-banner-brand img,
  body[data-auth-backdrop="on"] #auth-view .auth-banner-brand small { display: none; }
  body[data-auth-backdrop="on"] #auth-view .auth-banner-brand strong { color: #fff; font-size: 22px; font-weight: 800; letter-spacing: .02em; text-shadow: 0 2px 10px rgba(0, 0, 0, .4); }
  body[data-auth-backdrop="on"] #auth-view .auth-banner-copy { left: 28px; right: 28px; bottom: 52px; max-width: none; }
  body[data-auth-backdrop="on"] #auth-view .auth-banner-copy > :not(.auth-greeting) { display: none; }
  body[data-auth-backdrop="on"] #auth-view .auth-banner-copy .auth-greeting { display: block; margin: 0; color: #fff; font-size: 22px; font-weight: 600; letter-spacing: .01em; text-shadow: 0 2px 10px rgba(0, 0, 0, .45); }

  /* Theme and language as round buttons top right. */
  body[data-auth-backdrop="on"] #auth-view .auth-preferences { position: fixed; z-index: 5; top: 18px; right: 22px; gap: 10px; }
  body[data-auth-backdrop="on"] #auth-view .auth-preferences .preference-control { border: 1px solid var(--ax-line); border-radius: 999px; background: var(--ax-tile); color: var(--ax-text); box-shadow: 0 4px 14px rgba(15, 30, 45, .10); }

  /* The right panel: a flat form up to 340px wide, vertically centred. */
  body[data-auth-backdrop="on"] #auth-view .auth-card { box-sizing: border-box; display: flex; flex-direction: column; justify-content: safe center; width: min(340px, calc(100% - 80px)); min-width: 0; max-width: 100%; height: 100vh; height: 100dvh; margin: 0; justify-self: center; padding: 72px 0 36px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; border: 0; border-radius: 0; background: transparent; box-shadow: none; color: var(--ax-text); }
  body[data-auth-backdrop="on"] #auth-view .auth-card::-webkit-scrollbar { display: none; }
  body[data-auth-backdrop="on"] #auth-view .auth-card > * { flex-shrink: 0; }
  body[data-auth-backdrop="on"] #auth-view .auth-switch,
  body[data-auth-backdrop="on"] #auth-view .auth-brand > div,
  body[data-auth-backdrop="on"] #auth-view #auth-description,
  body[data-auth-backdrop="on"] #auth-view .password-visibility { display: none; }
  body[data-auth-backdrop="on"] #auth-view .auth-brand .identity-mark { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 14px; background: var(--ax-tile); box-shadow: 0 6px 18px rgba(15, 30, 45, .10); }
  body[data-auth-backdrop="on"] #auth-view .auth-brand .identity-mark img { width: 36px; height: 36px; }
  body[data-auth-backdrop="on"] #auth-view .auth-heading { margin-top: 26px; }
  body[data-auth-backdrop="on"] #auth-view .auth-heading h2 { color: var(--ax-text); font-size: 28px; font-weight: 800; }
  body[data-auth-backdrop="on"] #auth-view .auth-tagline { margin: 8px 0 0; color: var(--ax-muted); font-size: 14px; line-height: 1.6; }

  /* Labels, required marks and the 人机验证 heading. */
  body[data-auth-backdrop="on"] #auth-view .auth-form { margin-top: 26px; }
  body[data-auth-backdrop="on"] #auth-view .auth-form label,
  body[data-auth-backdrop="on"] #auth-view .auth-captcha-label { color: var(--ax-text); font-size: 14px; font-weight: 600; }
  body[data-auth-backdrop="on"] #auth-view .auth-form > label:not(.password-visibility):not(.auth-terms)::after,
  body[data-auth-backdrop="on"] #auth-view .auth-label-row > label::after,
  body[data-auth-backdrop="on"] #auth-view .invite-email-code > label::after,
  body[data-auth-backdrop="on"] #auth-view .auth-captcha-label::after { margin-left: 4px; color: var(--ax-required); content: "*"; }
  body[data-auth-backdrop="on"] #auth-view .auth-captcha-label { margin: 6px 0 0; }
  body[data-auth-backdrop="on"] #auth-view .invite-email-code { margin-top: 8px; }
  body[data-auth-backdrop="on"] #auth-view .invite-email-code > label { display: block; margin-bottom: 8px; }
  body[data-auth-backdrop="on"] #auth-view .invite-email-code-hint { color: var(--ax-muted); font-size: 12px; }
  body[data-auth-backdrop="on"] #auth-view .auth-captcha-label:has(+ .turnstile-slot[hidden]) { display: none; }

  /* Fields: soft filled boxes with an icon on the left; accent ring on focus; an eye on passwords. */
  body[data-auth-backdrop="on"] #auth-view .auth-form input[type="email"],
  body[data-auth-backdrop="on"] #auth-view .auth-form input[type="password"],
  body[data-auth-backdrop="on"] #auth-view .auth-form input[type="text"] { height: 42px; border: 1px solid var(--ax-line); border-radius: 8px; background: var(--ax-field); color: var(--ax-text); font-size: 14px; }
  body[data-auth-backdrop="on"] #auth-view .auth-form input:focus { border-color: var(--ax-accent); outline: 0; background: var(--ax-field-focus); box-shadow: 0 0 0 3px var(--ax-ring); }
  body[data-auth-backdrop="on"] #auth-view .auth-form input::placeholder { color: var(--ax-muted); }
  body[data-auth-backdrop="on"] #auth-view .auth-field { position: relative; display: flex; align-items: center; min-width: 0; }
  body[data-auth-backdrop="on"] #auth-view .auth-field > input { width: 100%; padding-left: 38px; }
  body[data-auth-backdrop="on"] #auth-view .auth-field:has(.auth-eye) > input { padding-right: 40px; }
  body[data-auth-backdrop="on"] #auth-view .auth-icon { width: 17px; height: 17px; flex: none; color: var(--ax-muted); }
  body[data-auth-backdrop="on"] #auth-view .auth-field > .auth-icon { position: absolute; left: 12px; pointer-events: none; }
  body[data-auth-backdrop="on"] #auth-view .auth-eye { position: absolute; right: 6px; display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 6px; background: transparent; color: var(--ax-muted); cursor: pointer; }
  body[data-auth-backdrop="on"] #auth-view .auth-eye:hover { color: var(--ax-text); }

  /* The register e-mail as one box: icon, prefix, @, domain. */
  body[data-auth-backdrop="on"] #auth-view .email-split { grid-template-columns: 17px minmax(0, 1fr) auto minmax(104px, 40%); gap: 8px; height: 42px; padding-left: 12px; border: 1px solid var(--ax-line); border-radius: 8px; background: var(--ax-field); }
  body[data-auth-backdrop="on"] #auth-view .email-split.full { grid-template-columns: 17px minmax(0, 1fr) minmax(104px, 40%); }
  body[data-auth-backdrop="on"] #auth-view .email-split:focus-within { border-color: var(--ax-accent); background: var(--ax-field-focus); box-shadow: 0 0 0 3px var(--ax-ring); }
  body[data-auth-backdrop="on"] #auth-view .auth-form .email-split input[type="text"],
  body[data-auth-backdrop="on"] #auth-view .auth-form .email-split input[type="text"]:focus,
  body[data-auth-backdrop="on"] #auth-view .email-split select { height: 40px; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--ax-text); box-shadow: none; outline: 0; }
  body[data-auth-backdrop="on"] #auth-view .email-split select { padding: 0 8px 0 10px; border-left: 1px solid var(--ax-line); cursor: pointer; }
  body[data-auth-backdrop="on"] #auth-view .email-split .email-at { color: var(--ax-muted); font-weight: 500; }
  body[data-auth-backdrop="on"] #auth-view .email-split > .auth-icon { display: block; }

  /* Buttons and links in the accent colour; the primary buttons carry an arrow. */
  body[data-auth-backdrop="on"] #auth-view .auth-form .primary-command { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border: 0; border-radius: 8px; background: var(--ax-accent); color: #fff; font-weight: 700; box-shadow: 0 6px 16px var(--ax-ring); }
  body[data-auth-backdrop="on"] #auth-view .auth-form .primary-command:hover:not(:disabled) { background: var(--ax-accent-hover); }
  body[data-auth-backdrop="on"] #auth-view #login-form .primary-command::after,
  body[data-auth-backdrop="on"] #auth-view #register-form .primary-command::after { width: 16px; height: 16px; background: url("/assets/auth-arrow.svg") center / contain no-repeat; content: ""; }
  body[data-auth-backdrop="on"] #auth-view .auth-form .secondary-command { height: 42px; border: 1px solid var(--ax-line); border-radius: 8px; background: var(--ax-tile); color: var(--ax-accent); font-weight: 700; }
  body[data-auth-backdrop="on"] #auth-view #forgot-password-button,
  body[data-auth-backdrop="on"] #auth-view .auth-back-button,
  body[data-auth-backdrop="on"] #auth-view #forgot-password-button:hover,
  body[data-auth-backdrop="on"] #auth-view .auth-back-button:hover { padding: 0; border: 0; background: transparent; color: var(--ax-accent); font-size: 13px; font-weight: 600; box-shadow: none; outline: 0; }
  body[data-auth-backdrop="on"] #auth-view #forgot-password-button:hover,
  body[data-auth-backdrop="on"] #auth-view .auth-back-button:hover { text-decoration: underline; }
  body[data-auth-backdrop="on"] #auth-view #forgot-password-button:focus-visible,
  body[data-auth-backdrop="on"] #auth-view .auth-back-button:focus-visible { border: 0; background: transparent; outline: 2px solid var(--ax-ring); outline-offset: 3px; border-radius: 4px; }
  body[data-auth-backdrop="on"] #auth-view .auth-terms input { accent-color: var(--ax-accent); }
  body[data-auth-backdrop="on"] #auth-view .auth-terms a { color: var(--ax-accent); }
  body[data-auth-backdrop="on"] #auth-view .auth-terms::after { color: var(--ax-required); content: "*"; }

  /* Login and register as separate pages: a divider and a button to the other page. */
  body[data-auth-backdrop="on"] #auth-view .auth-alt { display: grid; gap: 14px; margin-top: 32px; }
  body[data-auth-backdrop="on"] #auth-view .auth-alt-divider { display: flex; align-items: center; gap: 12px; margin: 0; color: var(--ax-muted); font-size: 13px; }
  body[data-auth-backdrop="on"] #auth-view .auth-alt-divider::before,
  body[data-auth-backdrop="on"] #auth-view .auth-alt-divider::after { flex: 1; height: 1px; background: var(--ax-line); content: ""; }
  body[data-auth-backdrop="on"] #auth-view .auth-alt-button { min-height: 42px; border: 1px solid var(--ax-line); border-radius: 8px; background: var(--ax-tile); color: var(--ax-text); font-weight: 600; cursor: pointer; }
  body[data-auth-backdrop="on"] #auth-view .auth-alt-button:hover { border-color: var(--ax-accent); color: var(--ax-accent); }

/* The register e-mail as prefix @ domain (user: 注册可以多加一个邮箱后缀); "full" when the prefix holds the address.
   Desktop restyles it above; this keeps it usable in a window made narrow after loading. */
.email-split { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(118px, 42%); align-items: center; gap: 6px; }
.email-split.full { grid-template-columns: minmax(0, 1fr) minmax(118px, 42%); }
.email-split.full .email-at { display: none; }
.email-split .email-at { color: var(--muted); font-weight: 700; }
.email-split input,
.email-split select { width: 100%; height: 42px; padding: 0 10px; border: 1px solid #afbec8; border-radius: 6px; background: var(--field); color: var(--ink); font: inherit; font-size: 14px; }
.email-split > .auth-icon { display: none; }

.auth-terms { display: flex; align-items: center; gap: 8px; margin: 4px 0 2px; color: var(--muted); font-size: 13px; font-weight: 400; }
.auth-terms input { width: 16px; height: 16px; margin: 0; accent-color: var(--teal); }
.auth-terms a { color: var(--teal); font-weight: 600; text-decoration: none; }
.auth-terms a:hover { text-decoration: underline; }

/* Recovery-page geometry must not override the unified auth container. */
body[data-auth-backdrop="on"] #auth-view:not([hidden]):has(#forgot-password-form:not([hidden])) { width: 100%; max-width: none; margin: 0; padding: 0; }
body[data-auth-backdrop="on"] #auth-view:has(#forgot-password-form:not([hidden])) .auth-card { width: min(340px, calc(100% - 80px)); max-width: 100%; margin: 0; padding: 72px 0 36px; }
body[data-auth-backdrop="on"] #auth-view #forgot-password-form .password-email-row { grid-template-columns: minmax(0, 1fr) 112px; gap: 8px; }
body[data-auth-backdrop="on"] #auth-view #forgot-password-form .password-email-row button { min-height: 44px; height: auto; padding: 8px; font-size: 13px; }
body[data-auth-backdrop="on"] #auth-view #forgot-password-form input:not([type="checkbox"]) { min-width: 0; height: 44px; font-size: 14px; }
body[data-auth-backdrop="on"] #auth-view .auth-form input[type="email"],
body[data-auth-backdrop="on"] #auth-view .auth-form input[type="password"],
body[data-auth-backdrop="on"] #auth-view .auth-form input[type="text"] { min-width: 0; }

@media (min-width: 993px) and (max-height: 700px) {
  body[data-auth-backdrop="on"] #auth-view .auth-card { justify-content: flex-start; }
}

/* Exact complement of the script's min-width:993px, including fractional widths. */
@media not all and (min-width: 993px) {
  html:has(body[data-auth-backdrop="on"] #auth-view:not([hidden])),
  body[data-auth-backdrop="on"]:has(#auth-view:not([hidden])) { overflow-x: clip; overflow-y: auto; }
  body[data-auth-backdrop="on"] #auth-view:not([hidden]) { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 100vh; min-height: 100svh; overflow: visible; }
  body[data-auth-backdrop="on"] #auth-view .auth-banner { display: none; }
  body[data-auth-backdrop="on"] #auth-view .auth-card,
  body[data-auth-backdrop="on"] #auth-view:has(#forgot-password-form:not([hidden])) .auth-card { width: min(420px, 100%); max-width: 100%; height: auto; min-height: 100vh; min-height: 100svh; margin: 0 auto; padding: 76px 20px 36px; overflow-y: visible; overscroll-behavior: auto; }
  body[data-auth-backdrop="on"] #auth-view .auth-brand { justify-content: center; }
  body[data-auth-backdrop="on"] #auth-view .auth-heading { text-align: center; }
  body[data-auth-backdrop="on"] #auth-view .auth-preferences { position: absolute; top: 12px; right: 12px; }
  body[data-auth-backdrop="on"] #auth-view .auth-preferences .preference-control { min-width: 44px; min-height: 44px; }
}

@media (max-width: 576px) {
  body[data-auth-backdrop="on"] #auth-view .auth-card,
  body[data-auth-backdrop="on"] #auth-view:has(#forgot-password-form:not([hidden])) .auth-card { justify-content: flex-start; padding: 76px 20px 32px; }
  body[data-auth-backdrop="on"] #auth-view .auth-heading h2 { font-size: 26px; }
  body[data-auth-backdrop="on"] #auth-view .auth-form input[type="email"],
  body[data-auth-backdrop="on"] #auth-view .auth-form input[type="password"],
  body[data-auth-backdrop="on"] #auth-view .auth-form input[type="text"],
  body[data-auth-backdrop="on"] #auth-view #forgot-password-form input:not([type="checkbox"]) { font-size: 16px; }
}
