/* Shared header language selector and authentication surface. */
.language-picker { position: relative; }
.language-picker summary { list-style: none; }
.language-picker summary::-webkit-details-marker { display: none; }
.language-options {
  position: absolute; z-index: 20; top: calc(100% + 4px); right: 0;
  min-width: 106px; max-height: min(420px, calc(100dvh - 64px)); overflow-y: auto; padding: 6px 0; margin: 0;
  list-style: none; background: var(--bg); border: 1px solid var(--surface-3);
  border-radius: var(--r-sm); box-shadow: 0 4px 12px #0008;
}
.language-options a { display: flex; align-items: center; min-height: 36px; padding: 4px 12px; white-space: nowrap; }
.language-options a:is(:hover, :focus-visible) { background: var(--surface-2); color: var(--text); outline-offset: -2px; }
.language-options a[aria-current] { color: var(--text); font-weight: var(--fw-lg); }
.auth-dialog, .auth-page {
  width: min(400px, calc(100% - 32px)); padding: 20px;
  border: 1px solid var(--surface-3); border-radius: var(--r-md);
  background: var(--surface); color: var(--text-2);
}
.auth-dialog { position: fixed; max-height: calc(100% - 32px); overflow-y: auto; }
.auth-dialog::backdrop {
  background: rgba(50, 56, 62, .25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
/* 原站把登录/找回密码表单放在视口竖直中段（reset 页标题 y≈371@1000），我们原来是贴顶的 */
main:has(> .auth-page) { display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 200px); padding: 24px 16px; box-sizing: border-box; }
main > .auth-page { flex: 0 0 auto; margin: 0; }
.auth-page { margin: 0 auto; }
.auth-close { position: absolute; inset: 8px 8px auto auto; font-size: 20px; }
.auth-fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.auth-fields h1, .auth-fields .auth-title { margin: 0 36px 8px 0; font-size: var(--fs-xl2); line-height: var(--lh-xs); color: var(--text); }
.auth-fields label { font-size: var(--fs-sm); font-weight: var(--fw-md); }
.auth-fields input { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--surface-3); border-radius: var(--r-sm); background: var(--bg); color: var(--text); font: inherit; }
.auth-fields input + label { margin-top: 4px; }
.auth-fields .btn { margin-top: 8px; }
.auth-fields .login-switch { margin: 4px 0 0; text-align: center; font-size: var(--fs-sm); color: var(--text-3); }
.auth-hint { margin: 0 0 12px; color: var(--text-3); font-size: var(--fs-sm); line-height: 1.5; }
#reset-status { margin: 8px 0 0; font-size: var(--fs-sm); color: var(--text-2); }
#reset-status[data-error='1'] { color: #f7c5c7; }
.auth-fields .login-switch button { padding: 2px; border: 0; background: transparent; color: #4393E4; font: inherit; font-size: 14px; font-weight: 500; text-decoration: none; cursor: pointer; }
.account-view { max-width: 600px; display: grid; gap: var(--sp-4); margin-inline: auto; }
.account-summary h1 { margin: 0; font-size: var(--fs-xl3); line-height: var(--lh-xs); color: var(--text); }
.account-user { margin: 4px 0 16px; color: var(--text-3); overflow-wrap: anywhere; }
.account-view :is(.panel, .topup, .account-credit) { margin: 0; max-width: none; padding: var(--sp-4); border: 1px solid var(--surface-3); border-radius: var(--r-md); background: var(--surface); }
.account-credit { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.account-credit strong { font-size: var(--fs-xl2); color: var(--text); font-variant-numeric: tabular-nums; }
.account-view .topup #pay { width: 100%; margin-top: var(--sp-4); }
.account-view .topup .panel { margin-top: var(--sp-4); }
.account-view :is(.list, .field label, .hint) { color: var(--text-3); }
.account-view .account-logout { border: 1px solid var(--surface-3); color: var(--text-2); background: transparent; }
.account-view .account-logout:hover { background: var(--surface-2); }

/* Auth card: responsive dark surface with a quiet focus/error treatment. */
.auth-dialog, .auth-page {
  padding: 24px; border-radius: 12px; background: #171717; border-color: #363636; color: #ededed;
}
.auth-dialog { inset: 0; margin: auto; box-shadow: 0 20px 64px #0009; }
.auth-dialog[open] { animation: auth-open .18s ease-out; }
/* 对齐 ainudez.net 的 MUI Joy 实测值（卡片 400 宽 / padding 20 / radius 8 / #0B0D0E；
   输入框 36 高、边框 #32383E；按钮 36 高 14px 600；标签 14px 500 + 红星 #C41C1C）。 */
.auth-dialog, .auth-page { padding: 20px; border-radius: 8px; background: #0B0D0E; border-color: #32383E; color: #DDE7EE; }
.auth-fields { display: flex; flex-direction: column; gap: 0; }
.auth-fields h1, .auth-fields .auth-title { margin: 0 0 8px; font-size: 24px; font-weight: 600; line-height: 32px; color: #F0F4F8; text-align: center; }
.auth-fields label { display: flex; align-items: center; gap: 2px; margin: 14px 0 6px; font-size: 14px; font-weight: 500; line-height: 20px; color: #F0F4F8; }
.auth-fields input + label { margin-top: 14px; }
.auth-fields h1 + label, .auth-fields h1 + .auth-label-row { margin-top: 0; }
/* 原站 /zh/reset-password 没有卡片框：表单直接浮在页面上 */
.auth-page--bare { padding: 0; border: 0; background: transparent; }
/* 密码行：label 左、忘记密码？右（原站同一行 space-between） */
.auth-label-row { display: flex; align-items: flex-start; justify-content: space-between; margin: 14px 0 6px; }
.auth-label-row label { margin: 0; }
.auth-forgot-link { font-size: 14px; font-weight: 400; line-height: 21px; color: #9FA6AD; text-decoration: none; }
.auth-forgot-link:hover { text-decoration: underline; }
.auth-forgot-link[hidden] { display: none; }
.auth-fields input { min-height: 36px; height: 36px; padding: 0 12px; border-radius: 6px; background: #0B0D0E; border: 1px solid #32383E; color: #DDE7EE; font-size: 16px; line-height: 24px; }
.auth-fields .btn, .auth-fields #auth-submit, #reset-submit { margin-top: 16px; min-height: 36px; height: 36px; padding: 6px 16px; border-radius: 6px; font-size: 14px; font-weight: 600; background: #0B6BCB; color: #fff; }
.auth-fields .login-switch { margin: 16px 0 0; font-size: 14px; color: #9FA6AD; }
/* 原站聚焦不画绿框：只把边框改成主色，保持键盘可达 */
.auth-fields input:focus { outline: none; border-color: #0B6BCB; }
.auth-fields #auth-submit { border-radius: 6px; background: #0b6bcb; color: #fff; }
.auth-fields #auth-submit:not(:disabled):hover { background: #185ea5; }
.auth-fields #auth-submit:disabled { opacity: .75; cursor: progress; }
.auth-spinner { display: none; flex: none; width: 16px; height: 16px; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: auth-spin .8s linear infinite; }
#auth-submit[aria-busy="true"] .auth-spinner { display: block; }
#auth-submit[aria-busy="true"] [data-auth-submit-label] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
@keyframes auth-open { from { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes auth-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .auth-dialog[open], .auth-spinner { animation: none; } }

/* Manual popover keeps feedback above a native modal without taking focus. */
.auth-toast {
  position: fixed; inset: max(32px, env(safe-area-inset-top)) 0 auto;
  z-index: 120; margin: 0 auto; width: max-content;
  max-width: calc(100% - 24px);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  padding: 10px 16px; border: 1px solid #2f654a; border-radius: 8px;
  background: #173525; color: #e0f5e8; box-shadow: 0 8px 24px #0006;
  font-size: var(--fs-sm); line-height: 1.4; text-align: center;
}
.auth-toast[data-error] { background: #341c22; color: #ffced4; border-color: #783641; }

/* 人机验证（Cloudflare Turnstile）：位置与尺寸对齐原站 —— 密码框下、宽 100%、高 65。 */
/* 尺寸由模板 inline style 定（照抄原站 min-width:300px;width:100%;height:65px），
   这里只留间距；别加 overflow:hidden / flex 居中，会把 Turnstile 挤回 300px 固定宽。 */
.auth-human { width: 100%; margin-top: 14px; }
.auth-human[hidden] { display: none; }
.auth-human-label {
  display: block;
  margin: 14px 0 6px;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  color: #F0F4F8;
}
.auth-human-label[hidden] { display: none; }
