/* login.html 抽出的登录/注册落地页样式（原内联 <style>）。
   登录页是每个用户的第一跳,externalize 后可被 SW/浏览器长缓存。 */
    :root {
        --primary: #1976d2;
        --primary-h: #1565c0;
        --text: #212529;
        --text-sub: #6c757d;
        --border: #e0e0e0;
        --danger: #d32f2f;
        --success: #2e7d32;
        --bg: #f5f5f7;
        --card-bg: #ffffff;
        --topbar-bg: #1a1a1a;
        --input-bg: #ffffff;
    }
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body {
        font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
        background: var(--bg); color: var(--text);
        min-height: 100vh;
        display: flex; flex-direction: column;
    }
    .login-topbar {
        background: var(--topbar-bg); color: #d1d5db;
        padding: 0 24px; height: 44px;
        display: flex; align-items: center; justify-content: space-between;
        font-size: 13px;
    }
    .login-topbar .brand { color: #fff; font-weight: 700; font-size: 16px; text-decoration: none; }
    .login-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 20px; overflow-y: auto; }
    /* 键盘弹起(原生 adjustResize 缩小视口)时，居中卡片会比视口高导致顶部被裁剪且无法滚动到，
       改为顶部对齐并允许滚动，配合 JS scrollIntoView 把聚焦输入框滚到可见区。 */
    :root.kb-open .login-main { align-items: flex-start; }
    :root.kb-open .login-topbar { display: none; }
    .login-card {
        background: var(--card-bg);
        padding: 40px 36px;
        border: 1px solid var(--border);
        border-radius: 6px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.06);
        width: 100%; max-width: 420px;
        position: relative;
    }
    .login-logo {
        display: inline-flex; align-items: flex-end; gap: 10px;
        color: var(--logo-color, #00827f); font-weight: 700; font-size: 22px;
        margin-bottom: 8px; line-height: 1; letter-spacing: -.02em;
    }
    .login-logo::before {
        content: ""; display: block;
        height: 1.1em; aspect-ratio: 775 / 1511;
        background: url('/static/icons/logo.png?v=9') center/contain no-repeat;
        flex-shrink: 0;
    }
    h1 { font-size: 18px; color: var(--text-sub); font-weight: 500; margin-bottom: 28px; letter-spacing: -.01em; }
    .form-group { margin-bottom: 18px; }
    label { display: block; margin-bottom: 5px; font-weight: 500; color: var(--text-sub); font-size: 13px; }
    input { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 4px;
            font-size: 14px; background: var(--input-bg); color: var(--text); transition: border-color .15s, box-shadow .15s; }
    input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(25,118,210,.15); }
    button {
        width: 100%; padding: 11px; background: var(--primary); color: white;
        border: none; border-radius: 4px; font-size: 14px; font-weight: 500; cursor: pointer;
        transition: background .15s; margin-top: 4px;
    }
    button:hover { background: var(--primary-h); }
    button:disabled { background: #c7c7c9; cursor: not-allowed; }
    .btn-passkey {
        margin-top: 10px; background: var(--input-bg); color: var(--text);
        border: 1px solid var(--border);
        display: flex; align-items: center; justify-content: center; gap: 8px;
    }
    .btn-passkey:hover { background: var(--hover-bg, #f5f5f7); border-color: #c7c7c9; }
    .btn-passkey svg { width: 18px; height: 18px; }
    .divider {
        display: flex; align-items: center; gap: 10px;
        color: var(--text-sub); font-size: 12px; margin: 14px 0 6px;
    }
    .divider::before, .divider::after {
        content: ""; flex: 1; height: 1px; background: var(--border);
    }
    .error { color: var(--danger); text-align: center; margin-top: 12px; font-size: 13px; }
    .info  { color: var(--success); text-align: center; margin-top: 12px; font-size: 13px; }
    .footer { text-align: center; margin-top: 28px; color: var(--text-sub); font-size: 12px; }
    /* ── App 启动闪屏（拉取更新）：仅原生壳显示 ── */
    .splash {
        position: fixed; inset: 0; z-index: 10000;
        background: var(--bg);
        display: none;
        flex-direction: column; align-items: center; justify-content: center;
        gap: 20px; padding: 24px; text-align: center;
        transition: opacity .22s;
    }
    :root[data-app="1"] .splash { display: flex; }
    .splash.fade { opacity: 0; }
    .splash .splash-logo {
        display: inline-flex; align-items: flex-end; gap: 10px;
        color: var(--logo-color, #00827f); font-weight: 700; font-size: 24px;
        line-height: 1; letter-spacing: -.02em;
    }
    .splash .splash-logo::before {
        content: ""; display: block; height: 1.1em; aspect-ratio: 775 / 1511;
        background: url('/static/icons/logo.png?v=9') center/contain no-repeat; flex-shrink: 0;
    }
    .splash .spinner {
        width: 40px; height: 40px; border-radius: 50%;
        border: 3px solid var(--border); border-top-color: var(--primary);
        animation: aw-spin .7s linear infinite;
    }
    .splash .splash-text { color: var(--text-sub); font-size: 13px; font-weight: 500; }

    /* ── 指纹/人脸验证后的等待全屏遮罩 ── */
    .auth-wait {
        position: fixed; inset: 0; z-index: 9999;
        background: var(--bg);
        display: none; flex-direction: column; align-items: center; justify-content: center;
        gap: 18px; padding: 24px; text-align: center;
    }
    .auth-wait.active { display: flex; }
    .auth-wait .aw-logo {
        width: 76px; height: 76px; border-radius: 17px;
        box-shadow: 0 8px 28px rgba(0,0,0,.18);
    }
    .auth-wait .spinner {
        width: 46px; height: 46px; border-radius: 50%;
        border: 3px solid var(--border); border-top-color: var(--primary);
        animation: aw-spin .7s linear infinite;
    }
    @keyframes aw-spin { to { transform: rotate(360deg); } }
    .auth-wait .aw-text { color: var(--text-sub); font-size: 14px; font-weight: 500; }
    .register-link { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-sub); }
    .register-link a { color: var(--primary); text-decoration: none; font-weight: 500; margin-left: 4px; }
    .register-link a:hover { text-decoration: underline; }

    /* ── 继续登录（自动登录）卡片 ── */
    .continue-view { text-align: center; padding: 8px 0 4px; }
    .continue-avatar {
        width: 64px; height: 64px; border-radius: 50%;
        background: var(--primary); color: #fff;
        display: inline-flex; align-items: center; justify-content: center;
        font-size: 26px; font-weight: 700; margin-bottom: 10px;
        text-transform: uppercase;
    }
    .continue-label { font-size: 12px; color: var(--text-sub); }
    .continue-user { font-size: 18px; font-weight: 600; margin: 2px 0 18px; word-break: break-all; }
    .use-other {
        display: inline-block; margin-top: 16px; font-size: 13px;
        color: var(--primary); text-decoration: none; cursor: pointer;
    }
    .use-other:hover { text-decoration: underline; }

    /* ── 选择账户列表 ── */
    .account-list { margin-bottom: 18px; }
    .account-list .list-label { font-size: 12px; color: var(--text-sub); margin-bottom: 8px; }
    .account-row {
        display: flex; align-items: center; gap: 10px;
        padding: 10px 12px; margin-bottom: 8px; cursor: pointer;
        border: 1px solid var(--border); border-radius: 6px;
        background: var(--input-bg); transition: border-color .15s, background .15s;
    }
    .account-row:hover { border-color: var(--primary); background: var(--hover-bg, #f5f5f7); }
    .acc-avatar {
        width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
        background: var(--primary); color: #fff;
        display: inline-flex; align-items: center; justify-content: center;
        font-size: 14px; font-weight: 700; text-transform: uppercase;
    }
    .acc-name { flex: 1; font-size: 14px; font-weight: 500; word-break: break-all; }
    .acc-pk { width: 18px; height: 18px; color: var(--text-sub); flex-shrink: 0; }
    /* 长按露出删除按钮：外层裁剪，内层 .account-row 平移 */
    .account-item { position: relative; margin-bottom: 8px; border-radius: 6px; overflow: hidden; }
    .account-item .account-row { margin-bottom: 0; position: relative; z-index: 1;
        transition: transform .2s ease;
        -webkit-user-select: none; user-select: none;
        -webkit-touch-callout: none; }
    .acc-delete {
        position: absolute; top: 0; right: 0; bottom: 0; z-index: 0;
        width: 84px; border: none; border-radius: 6px; cursor: pointer;
        background: var(--danger, #e5484d); color: #fff; font-size: 14px; font-weight: 600;
    }
    .account-item.revealed .account-row { transform: translateX(-84px); }

    /* ── 深色主题 ── */
    @media (prefers-color-scheme: dark) {
        :root:not([data-theme="light"]) {
            --bg: #0f1115; --card-bg: #161922; --border: #2a2f3a;
            --text: #e6e8ec; --text-sub: #a0a4ae;
            --primary: #1976d2; --primary-h: #1e82e5;
            --topbar-bg: #0a0a0f;
            --input-bg: #1b1f29;
            --hover-bg: #1e2330;
            --logo-color: #4db6ac;
        }
    }
    :root[data-theme="dark"] {
        --bg: #0f1115; --card-bg: #161922; --border: #2a2f3a;
        --text: #e6e8ec; --text-sub: #a0a4ae;
        --primary: #1976d2; --primary-h: #1e82e5;
        --topbar-bg: #0a0a0f;
        --input-bg: #1b1f29;
        --hover-bg: #1e2330;
        --logo-color: #4db6ac;
    }
    :root[data-theme="dark"] input:-webkit-autofill,
    :root[data-theme="dark"] input.autofill {
        -webkit-box-shadow: 0 0 0 100px #1b1f29 inset !important;
        -webkit-text-fill-color: #e6e8ec !important;
    }
    @media (prefers-color-scheme: dark) {
        :root:not([data-theme="light"]) input:-webkit-autofill,
        :root:not([data-theme="light"]) input.autofill {
            -webkit-box-shadow: 0 0 0 100px #1b1f29 inset !important;
            -webkit-text-fill-color: #e6e8ec !important;
        }
    }
