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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --accent: #f59e0b;
    --danger: #ef4444;
    --success: #10b981;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--gray-900);
    line-height: 1.6;
}

.container { max-width: 900px; margin: 0 auto; padding: 0 20px; }

/* Header */
header {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}
header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}
.logo {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 18px; font-weight: 900;
}
nav a {
    color: var(--gray-700);
    text-decoration: none;
    margin-left: 24px;
    font-size: 15px;
    font-weight: 500;
    transition: color 0.2s;
}
nav a:hover, nav a.active { color: var(--primary); }

/* Hero */
.hero {
    text-align: center;
    padding: 48px 0 32px;
    color: white;
}
.hero h1 {
    font-size: 36px;
    font-weight: 800;
    margin-bottom: 12px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.hero p {
    font-size: 17px;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
}

/* Main Card */
.main-card {
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    padding: 32px;
    margin-bottom: 32px;
}

/* Upload Area */
.upload-section { margin-bottom: 24px; }
.upload-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    background: var(--gray-100);
    padding: 4px;
    border-radius: 10px;
}
.upload-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.2s;
}
.upload-tab.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow);
}

.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--gray-50);
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.upload-zone-icon {
    font-size: 48px;
    margin-bottom: 12px;
}
.upload-zone p {
    color: var(--gray-500);
    font-size: 14px;
}
.upload-zone .highlight { color: var(--primary); font-weight: 600; }

#imagePreview {
    margin-top: 16px;
    text-align: center;
}
#imagePreview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.ocr-status {
    margin-top: 12px;
    padding: 10px 16px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 8px;
    font-size: 14px;
    display: none;
}
.ocr-status.show { display: block; }

/* Text Input */
.text-input-section { display: none; }
.text-input-section.active { display: block; }
textarea {
    width: 100%;
    min-height: 200px;
    padding: 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s;
    line-height: 1.7;
}
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Buttons */
.btn {
    padding: 14px 32px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: white;
    box-shadow: 0 4px 14px rgba(37,99,235,0.4);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,99,235,0.5); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}
.btn-secondary:hover { background: var(--gray-200); }
.btn-full { width: 100%; margin-top: 16px; }

/* Loading */
.loading {
    text-align: center;
    padding: 40px 20px;
    display: none;
}
.loading.show { display: block; }
.spinner {
    width: 48px; height: 48px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading p { color: var(--gray-500); font-size: 15px; }

/* Result */
.result-section { display: none; margin-top: 24px; }
.result-section.show { display: block; }
.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--gray-100);
}
.result-header h2 {
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.result-content {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 24px;
    font-size: 14px;
    line-height: 1.8;
}
.result-content h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-dark);
    margin: 20px 0 10px;
    padding-left: 10px;
    border-left: 4px solid var(--primary);
}
.result-content h3:first-child { margin-top: 0; }
.result-content .risk {
    color: var(--danger);
    font-weight: 700;
}
.result-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

/* Features */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}
.feature-card {
    background: rgba(255,255,255,0.95);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}
.feature-card:hover { transform: translateY(-4px); }
.feature-icon {
    width: 48px; height: 48px;
    background: var(--primary-light);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
    margin-bottom: 12px;
}
.feature-card h3 { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.feature-card p { font-size: 14px; color: var(--gray-500); }

/* Footer */
footer {
    text-align: center;
    padding: 24px 0;
    color: rgba(255,255,255,0.8);
    font-size: 13px;
}

/* Tips */
.tips {
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 20px;
    margin-top: 24px;
    color: white;
}
.tips h3 { font-size: 15px; margin-bottom: 10px; }
.tips ul { padding-left: 20px; font-size: 13px; opacity: 0.9; }
.tips li { margin-bottom: 6px; }

.hidden { display: none !important; }

/* 底部导航栏 */
.bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    /* 顶部导航简化 */
    header .container {
        height: 56px;
        padding: 0 16px;
    }
    header nav {
        display: none !important;
    }
    .logo {
        font-size: 20px;
    }
    .logo-icon {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    #authContainer {
        margin-left: auto;
    }
    .auth-bar {
        gap: 8px;
    }
    .auth-usage {
        font-size: 11px;
        padding: 3px 8px;
    }
    .auth-user {
        display: none !important;
    }

    /* Hero */
    .hero {
        padding: 32px 0 24px;
    }
    .hero h1 {
        font-size: 26px;
    }
    .hero p {
        font-size: 14px;
    }

    /* 卡片 */
    .main-card {
        padding: 16px;
        border-radius: 16px;
        margin-bottom: 20px;
    }
    .container {
        padding: 0 16px;
    }

    /* 上传区域 */
    .upload-zone {
        padding: 28px 16px;
        min-height: 140px;
    }
    .upload-zone-icon {
        font-size: 36px;
    }
    .upload-tab {
        padding: 10px 6px;
        font-size: 12px;
    }
    textarea {
        min-height: 140px;
        font-size: 15px;
    }

    /* 按钮 */
    .btn {
        padding: 14px 20px;
        font-size: 15px;
    }
    .btn-full {
        width: 100%;
    }
    .result-actions {
        flex-direction: column;
    }

    /* 功能区 */
    .features {
        grid-template-columns: 1fr;
    }
    .feature-card {
        padding: 16px;
    }

    /* 底部导航栏 */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
        z-index: 100;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .bottom-nav a {
        flex: 1;
        text-align: center;
        padding: 8px 4px 10px;
        text-decoration: none;
        color: var(--gray-400);
        font-size: 11px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
    }
    .bottom-nav a .nav-icon {
        font-size: 22px;
        line-height: 1;
    }
    .bottom-nav a.active {
        color: var(--primary);
    }
    .bottom-nav a.active .nav-icon {
        transform: scale(1.1);
    }

    /* 页面底部留白，避免被底部导航遮挡 */
    body {
        padding-bottom: 70px;
    }
    footer {
        margin-bottom: 60px;
    }
}
