*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    /* 中文优先落到雅黑/苹方，QQ、微信内置浏览器也能拿到清晰的字形 */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', 'Source Han Sans SC', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    background: var(--bg-color, #0f0f23);
    color: var(--text-color, #e0e0e0);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    /* 只锁横向：小屏上一旦内容高于一屏，纵向必须还能滚 */
    overflow-x: hidden;
    overflow-y: auto;
}

/* ====== 强制拦截弹窗（微信/QQ/微博） ====== */
.block-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.block-modal {
    background: var(--card-color, #1a1a2e);
    border-radius: 24px;
    padding: 48px 40px;
    max-width: 440px;
    width: 90%;
    text-align: center;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    animation: slideUp 0.4s ease;
}

.block-icon {
    color: #ff6b6b;
    margin-bottom: 20px;
}

.block-modal h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #fff;
}

.block-msg {
    font-size: 14px;
    color: #999;
    line-height: 1.6;
    margin-bottom: 28px;
}

.copy-box {
    display: flex;
    gap: 8px;
    margin-bottom: 32px;
}

.copy-box input {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 12px 14px;
    color: #ccc;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.copy-box input:focus {
    border-color: var(--accent-color, #6c63ff);
}

.btn-copy {
    background: var(--accent-color, #6c63ff);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 12px 22px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-copy:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}

.btn-copy:active {
    transform: translateY(0);
}

.browser-icons {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.browser-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #aaa;
}

.block-hint {
    font-size: 13px;
    color: #777;
    margin-bottom: 18px;
    margin-top: 4px;
}

/* ====== 首次安装凭据弹窗 ====== */
.cred-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.cred-modal {
    background: var(--card-color, #1a1a2e);
    border-radius: 24px;
    padding: 44px 40px;
    max-width: 460px;
    width: 90%;
    text-align: center;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(108, 99, 255, 0.2);
    animation: slideUp 0.4s ease;
}

.cred-icon {
    margin-bottom: 16px;
}

.cred-modal h2 {
    font-size: 22px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 8px;
}

.cred-desc {
    font-size: 14px;
    color: #888;
    margin-bottom: 28px;
}

.cred-list {
    text-align: left;
    margin-bottom: 28px;
}

.cred-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    margin-bottom: 8px;
    transition: all 0.2s;
}

.cred-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.cred-row:last-child {
    margin-bottom: 0;
}

.cred-label {
    font-size: 13px;
    color: #888;
    flex-shrink: 0;
    margin-right: 12px;
}

.cred-value {
    font-size: 14px;
    color: #ddd;
    font-family: 'Consolas', 'Monaco', monospace;
    word-break: break-all;
    text-align: right;
}

.cred-value a {
    color: var(--accent-color, #6c63ff);
    text-decoration: none;
}

.cred-value a:hover {
    text-decoration: underline;
}

.cred-highlight {
    background: rgba(108, 99, 255, 0.08);
    border-color: rgba(108, 99, 255, 0.25);
}

.cred-pw {
    color: var(--accent-color, #6c63ff);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 1px;
}

.cred-btn {
    background: var(--accent-color, #6c63ff);
    color: #fff;
    border: none;
    border-radius: 14px;
    padding: 15px 40px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.cred-btn:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(108, 99, 255, 0.3);
}

/* ====== 密码验证页 ====== */
.auth-container {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;            /* 手机浏览器工具栏收起/展开都不跳 */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(14px, 3vh, 20px);
    background: var(--bg-color, #0f0f23);
    position: relative;
    /* 关掉装饰光斑带来的可滚动区域：首页一屏显示，不出现下拉 */
    overflow: hidden;
    overscroll-behavior: none;
}

.auth-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 20%, rgba(108, 99, 255, 0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 80%, rgba(108, 99, 255, 0.05) 0%, transparent 50%);
    animation: bgShift 20s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes bgShift {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-5%, -3%); }
}

.auth-card {
    background: var(--card-color, #1a1a2e);
    border-radius: 24px;
    padding: 48px 40px;
    max-width: 440px;
    width: 100%;
    text-align: center;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.06);
    position: relative;
    z-index: 1;
    animation: slideUp 0.5s ease;
    /* 一屏放得下就居中，放不下也只让卡片自己滚，整页不出现下拉 */
    max-height: calc(100dvh - 28px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.logo {
    margin-bottom: 24px;
}

.logo img {
    max-height: 64px;
    max-width: 200px;
    border-radius: 12px;
}

.auth-card h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #fff;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 15px;
    color: #a3a8c0;
    margin-bottom: 32px;
    line-height: 1.6;
    font-weight: 400;
}

/* 首次部署提示：远程访客看到，只说明怎么拿访问密码，不显示任何凭证 */
.first-run-hint {
    margin: -18px 0 26px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid rgba(108, 99, 255, 0.28);
    background: rgba(108, 99, 255, 0.08);
    color: #b7b1ff;
    font-size: 12px;
    line-height: 1.7;
    text-align: left;
}

.auth-form {
    margin-bottom: 24px;
}

/* 图形验证码：数字 / 字母 / 字母+数字三种方式在前台随机出图。
   用 inline-block + vertical-align 排列，不依赖 flex 的 gap：
   QQ 浏览器、微信内置浏览器、老版安卓 WebView 都不会把「换一张」挤到图片上。 */
.captcha-row {
    margin-bottom: 14px;
    text-align: center;
    font-size: 0;               /* 消掉 inline-block 之间的空白间隙，宽度可控 */
    line-height: 0;
    white-space: nowrap;
}

.captcha-img {
    display: inline-block;
    vertical-align: middle;
    width: 148px;
    height: 48px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: #fbfcff;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.captcha-refresh {
    display: inline-block;
    vertical-align: middle;
    margin-left: 12px;
    font-size: 13px;
    line-height: 48px;           /* 与图片同高，中线对齐 */
    color: #b8b2ff;
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.captcha-refresh:hover {
    color: #fff;
    text-decoration: underline;
}

.input-group {
    display: flex;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    overflow: hidden;
    transition: all 0.3s;
}

.input-group:focus-within {
    border-color: var(--accent-color, #6c63ff);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}

.input-group input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    padding: 16px 20px;
    color: #fff;
    font-size: 16px;              /* 16px 起 iOS 才不会自动放大输入框 */
    font-weight: 500;
    outline: none;
    letter-spacing: 2px;
}

.input-group input::placeholder {
    color: #7f85a0;
    font-weight: 400;
    letter-spacing: 0;
}

.btn-submit {
    background: var(--accent-color, #6c63ff);
    border: none;
    padding: 16px 22px;
    cursor: pointer;
    color: #fff;
    display: flex;
    align-items: center;
    transition: all 0.2s;
}

.btn-submit:hover {
    filter: brightness(1.15);
}

.btn-submit svg {
    transition: transform 0.2s;
}

.btn-submit:hover svg {
    transform: translateX(3px);
}

.error-msg {
    color: #ff6b6b;
    font-size: 13px;
    margin-top: 12px;
    padding: 8px 12px;
    background: rgba(255, 107, 107, 0.08);
    border-radius: 8px;
    border: 1px solid rgba(255, 107, 107, 0.15);
}

.footer-text {
    font-size: 12px;
    color: #555;
}

/* ====== 验证通过 ====== */
.welcome-container {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(14px, 3vh, 20px);
    overflow: hidden;
    overscroll-behavior: none;
}

.welcome-card {
    background: var(--card-color, #1a1a2e);
    border-radius: 24px;
    padding: 48px 40px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.06);
    animation: slideUp 0.5s ease;
    max-height: calc(100dvh - 28px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.welcome-icon {
    margin-bottom: 20px;
}

.welcome-card h1 {
    font-size: 24px;
    color: #fff;
    margin-bottom: 8px;
}

.welcome-card p {
    color: #888;
    margin-bottom: 24px;
}

.btn-enter {
    display: inline-block;
    background: var(--accent-color, #6c63ff);
    color: #fff;
    text-decoration: none;
    padding: 14px 36px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-enter:hover {
    filter: brightness(1.15);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(108, 99, 255, 0.3);
}

.countdown-hint {
    font-size: 12px;
    color: #666;
    margin-top: 10px;
}

.countdown-display {
    margin: 16px 0 8px;
}

.countdown-number {
    display: inline-block;
    font-size: 48px;
    font-weight: 700;
    color: var(--accent-color, #6c63ff);
    line-height: 1;
    transition: transform 0.2s ease;
}

.redirect-fail {
    font-size: 12px;
    color: #ff6b6b;
    margin-top: 8px;
}

/* ====== 客服面板 ====== */
.cs-panel {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1000;
}

.cs-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-color, #6c63ff);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 24px rgba(108, 99, 255, 0.4);
    transition: all 0.3s;
    position: relative;
}

.cs-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 32px rgba(108, 99, 255, 0.5);
}

.cs-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ff6b6b;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.cs-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 300px;
    background: var(--card-color, #1a1a2e);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.06);
    overflow: hidden;
    transform: scale(0.9) translateY(10px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: bottom right;
}

.cs-window.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    visibility: visible;
}

.cs-header {
    background: linear-gradient(135deg, var(--accent-color, #6c63ff), #8b5cf6);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cs-header h3 {
    color: #fff;
    font-size: 16px;
    font-weight: 600;
}

.cs-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.cs-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.cs-body {
    padding: 20px;
}

.cs-subtitle {
    font-size: 13px;
    color: #888;
    margin-bottom: 16px;
}

.cs-channels {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cs-channel {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    text-decoration: none;
    color: var(--text-color, #e0e0e0);
    transition: all 0.2s;
    cursor: pointer;
}

.cs-channel:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent-color, #6c63ff);
    transform: translateX(-3px);
}

.cs-channel-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.qq-icon {
    background: rgba(0, 120, 212, 0.15);
    color: #0078D4;
}

.wechat-icon {
    background: rgba(7, 193, 96, 0.15);
    color: #07C160;
}

.weibo-icon {
    background: rgba(230, 46, 0, 0.15);
    color: #E62E00;
}

.email-icon {
    background: rgba(108, 99, 255, 0.15);
    color: var(--accent-color, #6c63ff);
}

.cs-channel span {
    font-size: 14px;
    font-weight: 500;
    color: #fff;
}

.cs-channel small {
    display: block;
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

/* ====== 微信二维码弹窗 ====== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--card-color, #1a1a2e);
    border-radius: 20px;
    padding: 36px;
    text-align: center;
    position: relative;
    max-width: 320px;
    width: 90%;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.06);
    animation: slideUp 0.3s ease;
}

.modal-content h3 {
    font-size: 18px;
    color: #fff;
    margin-bottom: 20px;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #aaa;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.qr-image {
    width: 200px;
    height: 200px;
    border-radius: 12px;
    margin-bottom: 16px;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.modal-content p {
    font-size: 13px;
    color: #888;
}

/* ====== 动画 ====== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ====== 响应式 ====== */
@media (max-width: 480px) {
    .block-modal, .auth-card, .welcome-card, .cred-modal {
        padding: 32px 20px;
        border-radius: 18px;
    }

    .block-modal h2 {
        font-size: 18px;
    }

    .auth-card h1 {
        font-size: 24px;
    }

    .browser-icons {
        gap: 14px;
    }

    .browser-item {
        font-size: 10px;
    }

    .browser-item svg {
        width: 26px;
        height: 26px;
    }

    .copy-box {
        flex-direction: column;
    }

    .cred-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .cred-value {
        text-align: left;
    }

    .cs-panel {
        right: 16px;
        bottom: 16px;
    }

    .cs-window {
        width: calc(100vw - 32px);
        right: -8px;
    }
}

/* ====== 平板 / 手机横屏 ====== */
@media (max-width: 768px) {
    .auth-card, .welcome-card, .block-modal, .cred-modal {
        padding: 36px 24px;
    }

    .auth-card h1 {
        font-size: 25px;
    }

    .subtitle {
        margin-bottom: 28px;
    }

    .auth-container, .welcome-container, .block-overlay {
        padding: 16px;
    }
}

/* ====== 小屏手机（iPhone SE 一类 360px） ====== */
@media (max-width: 360px) {
    .auth-card, .cred-modal, .block-modal, .welcome-card {
        padding: 26px 16px;
        border-radius: 16px;
    }

    .auth-card h1 {
        font-size: 22px;
    }

    .input-group input {
        font-size: 16px;
        padding: 15px 16px;
    }

    .captcha-img {
        width: 132px;
        height: 44px;
    }

    .captcha-refresh {
        font-size: 12px;
        line-height: 44px;
        margin-left: 8px;
    }

    .cred-value {
        word-break: break-all;
    }
}

/* ====== 按屏幕高度收一收：首页一屏显示，尽量不出现下拉 ====== */
@media (max-height: 680px) {
    .auth-card, .welcome-card {
        padding: 32px 26px;
    }

    .subtitle {
        margin-bottom: 20px;
    }

    .captcha-row {
        margin-bottom: 10px;
    }

    .auth-form {
        margin-bottom: 16px;
    }
}

@media (max-height: 560px) {
    .auth-card, .welcome-card {
        padding: 22px 20px;
        border-radius: 18px;
    }

    .auth-card h1 {
        font-size: 21px;
        margin-bottom: 6px;
    }

    .subtitle {
        font-size: 13px;
        margin-bottom: 14px;
    }

    .captcha-img {
        width: 132px;
        height: 44px;
    }

    .captcha-refresh {
        font-size: 12px;
        line-height: 44px;
        margin-left: 8px;
    }

    .input-group input {
        padding: 11px 14px;
    }

    .btn-submit {
        padding: 11px 18px;
    }

    /* 手机横屏这种极矮的情况：卡片内部自己滚，整页依然不下拉 */
    .auth-card, .welcome-card {
        max-height: calc(100dvh - 16px);
    }
}
