/* ================= 变量定义 (浅色模式默认) ================= */
:root {
    /* 主色调 */
    --primary: #6366f1;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    
    /* 背景与玻璃拟态 */
    --page-bg: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.90);
    --card-border: rgba(255, 255, 255, 0.6);
    --card-shadow: 0 10px 40px -10px rgba(0,0,0,0.08);
    
    /* 输入框与控件 */
    --input-bg: #f3f4f6;
    --input-text: #334155;
    --input-placeholder: #cbd5e1;
    --input-focus-border: rgba(99, 102, 241, 0.1);
    
    /* 标签页 */
    --tab-bg: #eff2f6;
    --tab-text-inactive: #8da2b5;
    --tab-bg-active: #ffffff;
    
    /* 字体颜色 */
    --text-title: #1f2937;
    --text-sub: #6b7280;
    --text-label: #475569;
    --text-footer: #cbd5e1;
    --text-footer-strong: #94a3b8;
    
    /* 按钮 */
    --otp-btn-bg: #10b981;
    --otp-btn-text: #ffffff;
    
    /* 尺寸 */
    --radius-box: 24px;
    --radius-input: 12px;
    
    /* 交互 */
    --tg-bg: rgba(255,255,255,0.4);
    --tg-icon: #cbd5e1;
    --tg-hover-bg: #ffffff;
}

/* ================= 深色模式适配 ================= */
@media (prefers-color-scheme: dark) {
    :root {
        /* 背景变深 (Slate 900) */
        --page-bg: #0f172a; 
        
        /* 卡片变深且半透明 */
        --card-bg: rgba(30, 41, 59, 0.75); 
        --card-border: rgba(255, 255, 255, 0.1);
        --card-shadow: 0 20px 40px -10px rgba(0,0,0,0.5);
        
        /* 输入框变深 */
        --input-bg: #1e293b; 
        --input-text: #f1f5f9;
        --input-placeholder: #64748b;
        --input-focus-border: rgba(99, 102, 241, 0.3);
        
        /* 标签页 */
        --tab-bg: #1e293b;
        --tab-text-inactive: #64748b;
        --tab-bg-active: #334155;
        
        /* 字体反白 */
        --text-title: #f8fafc;
        --text-sub: #94a3b8;
        --text-label: #cbd5e1;
        
        /* 底部声明 */
        --text-footer: #475569;
        --text-footer-strong: #64748b;
        
        /* 按钮微调 */
        --otp-btn-bg: #059669; 
        
        /* TG 图标 */
        --tg-bg: rgba(255,255,255,0.1);
        --tg-icon: #64748b;
        --tg-hover-bg: #334155;
    }
}

/* ================= 全局布局 ================= */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
*:focus { outline: none; }

html, body {
    height: 100%;
    width: 100%;
    min-height: 100dvh; 
    overflow-x: hidden;
    overscroll-behavior-y: none;
}

body { 
    margin: 0; 
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif; 
    
    background-color: var(--page-bg);
    /* 动态光晕背景 */
    background-image: 
        radial-gradient(at 80% 0%, hsla(250,100%,70%,0.15) 0px, transparent 50%),
        radial-gradient(at 0% 50%, hsla(220, 100%, 70%, 0.1) 0px, transparent 50%),
        radial-gradient(at 80% 100%, hsla(260, 100%, 70%, 0.1) 0px, transparent 50%),
        radial-gradient(at 0% 0%, hsla(190, 100%, 70%, 0.1) 0px, transparent 50%);
    
    display: flex; 
    flex-direction: column;
    align-items: center;
    
    padding: 0 20px;
    padding-top: calc(10px + env(safe-area-inset-top)); 
    transition: background-color 0.3s ease;
}

/* ================= 布局核心 (视觉调整版) ================= */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center; /* 垂直居中 */
    align-items: center;
    width: 100%;
    max-width: 380px;
    
    /* 关键修改：增加顶部 padding，把卡片视觉中心往下压 */
    padding-top: 60px;
    padding-bottom: 10px;
}

/* ================= 登录卡片 ================= */
.auth-card { 
    width: 100%; 
    background: var(--card-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    
    border-radius: var(--radius-box); 
    padding: 24px 20px; 
    
    box-shadow: 
        var(--card-shadow),
        0 0 0 1px var(--card-border) inset;
    
    animation: slideUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

/* ================= 头部文字 ================= */
.header { text-align: center; margin-bottom: 20px; }
.header h2 { 
    margin: 0; 
    font-size: 24px; 
    color: var(--text-title); 
    font-weight: 800; 
    letter-spacing: -0.5px;
    transition: color 0.3s;
}
.header p { 
    margin: 8px 0 0; 
    font-size: 12px; 
    color: var(--text-sub); 
    line-height: 1.5; 
    font-weight: 500;
    transition: color 0.3s;
}

/* ================= Tabs 切换 ================= */
.tabs { 
    display: flex; 
    background: var(--tab-bg); 
    padding: 3px; 
    border-radius: 14px; 
    margin-bottom: 20px; 
    transition: background 0.3s;
}
.tab { 
    flex: 1; 
    text-align: center; 
    padding: 9px; 
    font-size: 13px; 
    font-weight: 600; 
    color: var(--tab-text-inactive); 
    cursor: pointer; 
    border-radius: 11px; 
    transition: all 0.3s ease; 
}
.tab.active { 
    color: var(--primary); 
    background: var(--tab-bg-active); 
    box-shadow: 0 2px 6px rgba(0,0,0,0.08); 
}

/* ================= 表单输入 ================= */
.form-group { margin-bottom: 14px; }

.input-label { 
    display: block; 
    font-size: 12px; 
    color: var(--text-label); 
    margin-bottom: 5px; 
    font-weight: 600; 
    padding-left: 4px;
    transition: color 0.3s;
}

input { 
    width: 100%; 
    padding: 12px 14px; 
    
    background: var(--input-bg); 
    border: 2px solid transparent; 
    border-radius: var(--radius-input); 
    font-size: 14px; 
    color: var(--input-text); 
    transition: all 0.2s; 
    -webkit-appearance: none;
}
input:focus { 
    background: var(--tab-bg-active); 
    border-color: var(--primary); 
    box-shadow: 0 0 0 4px var(--input-focus-border); 
}
input::placeholder { color: var(--input-placeholder); font-size: 13px; }

.otp-group { display: flex; gap: 8px; }
.otp-btn { 
    background: var(--otp-btn-bg); 
    color: var(--otp-btn-text); 
    border: none; 
    padding: 0 12px; 
    border-radius: var(--radius-input); 
    font-weight: 600; 
    font-size: 12px; 
    cursor: pointer; 
    white-space: nowrap; 
    transition: opacity 0.2s;
}
.otp-btn:active { opacity: 0.8; }
.otp-btn:disabled { background: var(--input-bg); color: var(--text-sub); cursor: not-allowed; }

/* ================= 按钮 ================= */
.submit-btn { 
    width: 100%; 
    margin-top: 6px; 
    padding: 14px; 
    background: var(--primary-gradient); 
    color: white; 
    border: none; 
    border-radius: var(--radius-input); 
    font-size: 15px; 
    font-weight: 700; 
    cursor: pointer; 
    transition: all 0.3s; 
    box-shadow: 0 8px 20px -5px rgba(99, 102, 241, 0.4); 
}
.submit-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 25px -5px rgba(99, 102, 241, 0.5); }
.submit-btn:active { transform: scale(0.98); }
.submit-btn:disabled { background: var(--input-bg); color: var(--text-sub); box-shadow: none; cursor: not-allowed; }

/* ================= 底部声明 ================= */
.footer-note {
    flex-shrink: 0; 
    text-align: center;
    width: 100%;
    
    color: var(--text-footer); 
    font-size: 11px; 
    line-height: 1.5;
    
    /* 沉底关键：给底部留出安全区域 */
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    margin-bottom: 10px;
    transition: color 0.3s;
}
.footer-note span { color: var(--text-footer-strong); font-weight: 500; }

.tg-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 14px;
    color: var(--tg-icon); 
    transition: all 0.3s;
    cursor: pointer;
    padding: 10px;
    background: var(--tg-bg); 
    border-radius: 50%;
}
.tg-link svg { width: 18px; height: 18px; fill: currentColor; }
.tg-link:hover { color: #229ED9; background: var(--tg-hover-bg); transform: scale(1.1); }

/* ================= Toast & Anim ================= */
.hidden { display: none; }
.toast { 
    position: fixed; 
    top: calc(20px + env(safe-area-inset-top)); 
    left: 50%; 
    transform: translateX(-50%) translateY(-200%); 
    background: #1e293b; 
    color: white; 
    padding: 10px 20px; 
    border-radius: 99px; 
    font-size: 13px; 
    font-weight: 500; 
    opacity: 0; 
    transition: all 0.4s cubic-bezier(0.19, 1, 0.22, 1); 
    z-index: 1000; 
    white-space: nowrap; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.15); 
}
@media (prefers-color-scheme: dark) {
    .toast { border: 1px solid rgba(255,255,255,0.1); }
}

.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

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