/* 认证壳：登录 / 注册 / 找回 / 改密 / 跳转 / 无权限
   Apple Design：系统字体、半透明分层、按下即反馈、进出同一路径、减弱动效/透明/高对比降级 */
:root {
    --auth-font: system-ui, -apple-system, "SF Pro Text", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --auth-primary: #002fa7;
    --auth-primary-strong: #001f75;
    --auth-primary-soft: rgba(0, 47, 167, 0.1);
    --auth-gradient: linear-gradient(160deg, #001f75 0%, #002fa7 48%, #3d6adf 100%);
    --auth-bg: #f5f5f7;
    --auth-sheet: rgba(255, 255, 255, 0.78);
    --auth-surface: #fff;
    --auth-field-bg: rgba(242, 242, 247, 0.92);
    --auth-text: #1d1d1f;
    --auth-text-muted: #3a3a3c;
    --auth-border: rgba(60, 60, 67, 0.14);
    --auth-border-strong: rgba(60, 60, 67, 0.22);
    --auth-ring: rgba(0, 47, 167, 0.18);
    --auth-danger: #d70015;
    --auth-danger-soft: rgba(255, 59, 48, 0.1);
    --auth-success: #248a3d;
    --auth-success-soft: rgba(52, 199, 89, 0.12);
    --auth-scrim: rgba(0, 0, 0, 0.08);
    --auth-blur: 28px;
    --auth-radius-lg: 22px;
    --auth-radius: 12px;
    --auth-radius-sm: 10px;
    --auth-shadow: 0 1px 0 rgba(255, 255, 255, 0.65) inset, 0 24px 64px rgba(0, 0, 0, 0.14);
    --auth-spring: cubic-bezier(0.32, 0.72, 0, 1);
    --auth-slide: 400ms var(--auth-spring);
    --auth-press: 100ms ease-out;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html:has(.auth-shell--settings),
html:has(.auth-shell--settings) body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}
body {
    margin: 0;
    font: 100%/1.47 var(--auth-font);
    color: var(--auth-text);
    background:
        radial-gradient(900px 480px at 8% -8%, rgba(0, 47, 167, 0.08), transparent 58%),
        radial-gradient(720px 400px at 108% 0%, rgba(61, 106, 223, 0.08), transparent 52%),
        var(--auth-bg);
    -webkit-font-smoothing: antialiased;
}

.app-topbar ~ .auth-page,
.app-topbar ~ .auth-shell,
.app-topbar ~ .auth-status-page {
    min-height: calc(100dvh - var(--app-topbar-height, 56px));
}

.auth-page,
.auth-shell,
.auth-status-page {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
}

/* ---------- 登录 / 注册双栏 ---------- */
.auth-container {
    position: relative;
    width: min(860px, 100%);
    min-height: 620px;
    background: var(--auth-sheet);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: var(--auth-radius-lg);
    box-shadow: var(--auth-shadow);
    backdrop-filter: blur(var(--auth-blur)) saturate(180%);
    -webkit-backdrop-filter: blur(var(--auth-blur)) saturate(180%);
    overflow: hidden;
}

.form-container {
    position: absolute;
    top: 0;
    height: 100%;
    width: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 36px 40px;
    transition: transform var(--auth-slide), opacity var(--auth-slide);
    will-change: transform, opacity;
}
.form-inner { width: 100%; max-width: 340px; }
.sign-in { left: 0; z-index: 2; }

.overlay-container {
    position: absolute;
    top: 0;
    left: 50%;
    width: 50%;
    height: 100%;
    overflow: hidden;
    z-index: 100;
    transition: transform var(--auth-slide);
    will-change: transform;
}
.overlay {
    position: relative;
    left: -100%;
    width: 200%;
    height: 100%;
    color: #f5f5f7;
    background: var(--auth-gradient);
    transition: transform var(--auth-slide);
    will-change: transform;
}
.overlay-panel {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 40px;
    text-align: center;
}
.overlay-left { left: 0; }
.overlay-right { right: 0; }

.overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-width: 280px;
}
.overlay-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-bottom: 4px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.overlay-logo svg { width: 26px; height: 26px; }
.overlay-content h2 {
    margin: 0;
    font-size: 1.5rem;
    line-height: 1.15;
    letter-spacing: -0.02em;
    font-weight: 700;
}
.overlay-content p {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: rgba(245, 245, 247, 0.86);
}

.btn-ghost {
    margin-top: 8px;
    min-height: 44px;
    min-width: 44px;
    padding: 0 28px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.42);
    border-radius: 12px;
    color: #fff;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--auth-press), background-color 160ms ease, border-color 160ms ease;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.2); border-color: #fff; }
.btn-ghost:active { transform: scale(0.97); }
.btn-ghost:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

.subview[hidden] { display: none; }

.auth-kicker {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--auth-text-muted);
}
.panel-title {
    margin: 0;
    font-size: clamp(1.4rem, 2.2vw, 1.7rem);
    line-height: 1.15;
    letter-spacing: -0.02em;
    font-weight: 700;
}
.panel-sub {
    margin: 6px 0 18px;
    font-size: 15px;
    line-height: 1.5;
    font-weight: 500;
    color: var(--auth-text-muted);
}

.switch-line {
    margin: 16px 0 0;
    text-align: center;
    font-size: 13px;
    color: var(--auth-text-muted);
}
.switch-line a,
.link-btn {
    color: var(--auth-primary);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    font: inherit;
    min-height: 44px;
    padding: 0 4px;
}
.switch-line a:hover,
.link-btn:hover { text-decoration: underline; }
.switch-line a:focus-visible,
.link-btn:focus-visible {
    outline: 2px solid var(--auth-primary);
    outline-offset: 3px;
    border-radius: 6px;
}
.forgot-line { margin: -4px 0 0; text-align: right; }
.forgot-line .link-btn { font-size: 13px; }
.mobile-switch { display: none; }

/* ---------- 表单 ---------- */
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 13px; font-weight: 600; letter-spacing: 0.01em; color: var(--auth-text); }
.field__label .req { color: var(--auth-danger); margin-left: 2px; }
.field__control { position: relative; display: flex; align-items: center; }
.field__icon {
    position: absolute;
    left: 12px;
    width: 18px;
    height: 18px;
    color: #86868b;
    pointer-events: none;
}
.field__control input,
.field__control select {
    width: 100%;
    min-height: 44px;
    height: 44px;
    padding: 0 14px 0 40px;
    font: inherit;
    font-size: 15px;
    color: var(--auth-text);
    background: var(--auth-field-bg);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}
.field__control:has(.field__toggle) input { padding-right: 44px; }
.field__control--no-icon input { padding-left: 14px; }
.field__control input::placeholder { color: #aeaeb2; }
.field__control input:hover { border-color: var(--auth-border-strong); }
.field__control input:focus {
    border-color: var(--auth-primary);
    background: #fff;
    box-shadow: 0 0 0 4px var(--auth-ring);
}
.field__control:focus-within .field__icon { color: var(--auth-primary); }

.field__toggle {
    position: absolute;
    right: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #86868b;
    border-radius: 10px;
    cursor: pointer;
    transition: transform var(--auth-press), background-color 120ms ease, color 120ms ease;
}
.field__toggle:hover { color: var(--auth-text); background: rgba(0, 0, 0, 0.05); }
.field__toggle:active { transform: scale(0.97); }
.field__toggle:focus-visible { outline: 2px solid var(--auth-primary); outline-offset: 2px; }
.field__toggle svg { width: 18px; height: 18px; }
.field__toggle .icon-hide { display: none; }
.field__toggle[aria-pressed="true"] .icon-show { display: none; }
.field__toggle[aria-pressed="true"] .icon-hide { display: inline; }

.field__hint { font-size: 12px; line-height: 1.45; color: #6e6e73; }
.field__hint.is-error { color: var(--auth-danger); font-weight: 500; }

.field__suggest {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 40;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    max-height: 232px;
    overflow-y: auto;
}
.field__suggest[hidden] { display: none; }
.field__suggest-item {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
}
.field__suggest-item:hover,
.field__suggest-item.is-active { background: var(--auth-primary-soft); }
.field__suggest-item__at { color: #86868b; }
.field__suggest-item__domain { color: var(--auth-primary); font-weight: 600; }

.field__control.is-invalid input {
    border-color: var(--auth-danger);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(215, 0, 21, 0.12);
}
.field__control.is-invalid .field__icon { color: var(--auth-danger); }

.pw-rules {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.pw-rules li {
    position: relative;
    padding-left: 14px;
    font-size: 12px;
    line-height: 1.4;
    color: #6e6e73;
}
.pw-rules li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.45em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #d2d2d7;
}
.pw-rules li.is-ok { color: var(--auth-success); }
.pw-rules li.is-ok::before { background: var(--auth-success); }
.pw-rules li.is-bad { color: var(--auth-danger); }
.pw-rules li.is-bad::before { background: var(--auth-danger); }

.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 14px;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.45;
    font-weight: 500;
    border-radius: 12px;
    border: 1px solid transparent;
}
.auth-alert svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.auth-alert.error { color: var(--auth-danger); background: var(--auth-danger-soft); }
.auth-alert.success { color: var(--auth-success); background: var(--auth-success-soft); }

.btn {
    position: relative;
    width: 100%;
    min-height: 44px;
    margin-top: 4px;
    padding: 0 18px;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    background: var(--auth-primary);
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 8px 20px -10px rgba(0, 47, 167, 0.7);
    transition: transform var(--auth-press), filter 160ms ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--auth-primary); outline-offset: 3px; }
.btn[disabled],
.btn.is-loading { cursor: not-allowed; opacity: 0.88; }
.btn.is-loading .btn__label { opacity: 0; }
.btn .btn__spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    opacity: 0;
    animation: auth-spin 0.7s linear infinite;
}
.btn.is-loading .btn__spinner { opacity: 1; }
@keyframes auth-spin { to { transform: rotate(360deg); } }

/* ---------- 改密单栏设置 sheet ---------- */
.auth-shell--settings {
    align-items: flex-start;
    justify-content: center;
    padding: 28px 20px 48px;
}
.app-topbar ~ .auth-shell--settings {
    min-height: calc(100dvh - var(--app-topbar-height, 56px));
}
.auth-settings {
    width: min(440px, 100%);
    padding: 28px 28px 24px;
    display: flex;
    flex-direction: column;
    background: var(--auth-sheet);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: var(--auth-radius-lg);
    box-shadow: var(--auth-shadow);
    backdrop-filter: blur(var(--auth-blur)) saturate(180%);
    -webkit-backdrop-filter: blur(var(--auth-blur)) saturate(180%);
}
.auth-settings__head { margin-bottom: 20px; }
.auth-settings__title {
    margin: 0;
    font-size: 1.5rem;
    line-height: 1.15;
    letter-spacing: -0.022em;
    font-weight: 700;
}
.auth-settings__desc {
    margin: 8px 0 0;
    font-size: 14px;
    line-height: 1.5;
    font-weight: 500;
    color: var(--auth-text-muted);
}
.auth-settings .field__control input {
    min-height: 48px;
    height: 48px;
}
.auth-settings .field__control:has(.field__toggle) input { padding-right: 52px; }
.auth-settings .field__toggle {
    width: 44px;
    height: 44px;
    min-width: 44px;
    right: 2px;
    border-radius: 12px;
}
.auth-foot { margin-top: 16px; text-align: center; font-size: 13px; }
.auth-foot a {
    color: var(--auth-primary);
    font-weight: 600;
    text-decoration: none;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}
.auth-foot a:focus-visible { outline: 2px solid var(--auth-primary); outline-offset: 3px; border-radius: 6px; }

/* ---------- 跳转 / 无权限 / 限制 ---------- */
.auth-status {
    width: min(400px, 100%);
    padding: 36px 28px 28px;
    text-align: center;
    background: var(--auth-sheet);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: var(--auth-radius-lg);
    box-shadow: var(--auth-shadow);
    backdrop-filter: blur(var(--auth-blur)) saturate(180%);
    -webkit-backdrop-filter: blur(var(--auth-blur)) saturate(180%);
}
.auth-status__mark {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--auth-primary);
}
.auth-status__mark--warn { background: #c93400; }
.auth-status__mark svg { width: 26px; height: 26px; }
.auth-status h1 {
    margin: 0 0 6px;
    font-size: 1.35rem;
    line-height: 1.15;
    letter-spacing: -0.02em;
    font-weight: 700;
}
.auth-status p {
    margin: 0 0 20px;
    font-size: 15px;
    line-height: 1.5;
    font-weight: 500;
    color: var(--auth-text-muted);
}
.auth-status__bar {
    height: 4px;
    border-radius: 999px;
    background: rgba(60, 60, 67, 0.12);
    overflow: hidden;
}
.auth-status__bar > span {
    display: block;
    height: 100%;
    width: 8%;
    border-radius: inherit;
    background: var(--auth-primary);
    transition: width 2s var(--auth-spring);
}
.auth-status__links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 18px;
}
.auth-status__links a,
.auth-status__links .auth-status__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
    padding: 0 16px;
    border-radius: 12px;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: 0;
    transition: transform var(--auth-press);
}
.auth-status__links a:active,
.auth-status__links .auth-status__btn:active { transform: scale(0.97); }
.auth-status__links a.primary,
.auth-status__links .auth-status__btn.primary {
    background: var(--auth-primary);
    color: #fff;
}
.auth-status__links a.ghost,
.auth-status__links .auth-status__btn.ghost {
    background: rgba(120, 120, 128, 0.12);
    color: var(--auth-text);
}
.auth-status__links a:focus-visible,
.auth-status__links .auth-status__btn:focus-visible {
    outline: 2px solid var(--auth-primary);
    outline-offset: 3px;
}

/* 兼容旧类名 */
.redirect-page,
.denied-page,
.limit-page { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.redirect-card,
.denied-card,
.limit-card { /* 旧模板若残留，跟 auth-status 同观感 */ }

@media (max-width: 768px) {
    .auth-page,
    .auth-shell,
    .auth-status-page { padding: 20px 14px; }
    .auth-container { min-height: 0; }
    .overlay-container { display: none; }
    .form-container {
        position: static;
        width: 100%;
        transform: none !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        padding: 28px 22px;
    }
    .mobile-switch { display: block; }
    .auth-settings { padding: 24px 22px 22px; }
    .pw-rules { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
    .form-container,
    .auth-settings { padding: 22px 16px 20px; }
}

@media (prefers-reduced-motion: reduce) {
    .form-container,
    .overlay-container,
    .overlay,
    .auth-status__bar > span {
        transition: opacity 180ms ease;
    }
    .btn,
    .btn-ghost,
    .field__toggle,
    .auth-status__links a { transition: opacity 160ms ease; }
    .btn:active,
    .btn-ghost:active,
    .field__toggle:active { transform: none; }
}

@media (prefers-reduced-transparency: reduce) {
    .auth-container,
    .auth-settings,
    .auth-status,
    .field__suggest,
    .overlay-logo {
        background: #fff;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    .overlay { background: #002fa7; }
    .overlay-logo { background: rgba(255, 255, 255, 0.16); }
}

@media (prefers-contrast: more) {
    .auth-container,
    .auth-settings,
    .auth-status,
    .field__control input,
    .btn-ghost {
        border: 2px solid #1d1d1f;
        background: #fff;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    .panel-sub,
    .auth-settings__desc,
    .auth-status p,
    .field__hint { color: #1d1d1f; }
}
