:root {
    /* 品牌配色 - 现代靛蓝 */
    --primary: #4f46e5;
    --primary-light: #eef2ff;
    --primary-hover: #4338ca;
    --secondary: #ec4899;
    
    /* 语义化颜色 */
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    /* 背景与文字 */
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --bg-item: #f1f5f9;
    
    --text-main: #1e293b;
    --text-sub: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    
    /* 图标配色 */
    --excel-bg: #dcfce7;
    --excel-text: #166534;
    --word-bg: #dbeafe;
    --word-text: #1e40af;
    --pdf-bg: #fee2e2;
    --pdf-text: #991b1b;

    /* 现代阴影系统 */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 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);
    --shadow-floating: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; outline: none; -webkit-tap-highlight-color: transparent; }

body { 
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
    background-color: var(--bg-page); 
    color: var(--text-main); 
    line-height: 1.6; 
    padding-bottom: calc(80px + env(safe-area-inset-bottom)); 
}

/* 装饰性背景 */
.bg-decoration { 
    position: fixed; top: 0; left: 0; width: 100%; height: 420px; 
    background: linear-gradient(135deg, #e0e7ff 0%, #f8fafc 100%); 
    z-index: -1; clip-path: ellipse(150% 100% at 50% 0%); 
}

/* 1. 顶部导航 - 毛玻璃效果 */
.glass-header {
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    /* 顶部增加 safe-area-inset-top，避开刘海 */
    padding: env(safe-area-inset-top) 24px 0 24px; 
    /* 高度自动增加刘海高度 */
    height: calc(64px + env(safe-area-inset-top)); 
    position: sticky; 
    top: 0; 
    z-index: 100;
    background: rgba(255, 255, 255, 0.75); 
    backdrop-filter: blur(12px); 
    border-bottom: 1px solid rgba(255,255,255,0.5); 
    box-shadow: var(--shadow-sm);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; color: var(--primary); letter-spacing: -1px; }
.brand-icon { width: 32px; height: 32px; background: var(--primary); color: white; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 16px; }

.nav-btn { background: white; border: 1px solid var(--border); padding: 8px 18px; border-radius: 20px; font-size: 14px; font-weight: 600; color: var(--text-main); cursor: pointer; display: flex; align-items: center; gap: 8px; transition: 0.2s; }
.nav-btn:hover { border-color: var(--primary); color: var(--primary); box-shadow: var(--shadow-sm); }

.user-pill { display: flex; align-items: center; gap: 12px; background: white; padding: 6px 6px 6px 16px; border-radius: 30px; border: 1px solid var(--border); font-size: 14px; font-weight: 600; }
.user-pill button { width: 30px; height: 30px; border-radius: 50%; border: none; background: #fee2e2; color: var(--danger); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.user-pill button:hover { background: var(--danger); color: white; }

/* 2. 搜索 Hero 区域 */
#mainContent { max-width: 850px; margin: 0 auto; padding: 0 20px; }
.hero-section { text-align: center; margin-top: 80px; margin-bottom: 40px; transition: all 0.5s ease; }
.logo-area h1 { font-size: 56px; font-weight: 900; color: var(--text-main); letter-spacing: -3px; margin-bottom: 10px; background: linear-gradient(to right, var(--primary), var(--secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.logo-area p { color: var(--text-sub); font-size: 17px; margin-bottom: 35px; }

/* 搜索框 */
.search-container { 
    max-width: 640px; margin: 0 auto; width: 100%; 
    /* 吸顶位置下移，防止被变高的 Header 挡住 */
    position: sticky; top: calc(70px + env(safe-area-inset-top)); 
    z-index: 90; 
}

.search-box {
    background: white; border-radius: 18px; padding: 10px; display: flex; align-items: center;
    box-shadow: var(--shadow-floating); border: 1px solid rgba(255,255,255,0.8); transition: 0.3s;
}
.search-box:focus-within { transform: translateY(-2px); border-color: var(--primary); box-shadow: 0 25px 40px -10px rgba(79, 70, 229, 0.18); }

.search-icon { color: var(--text-muted); margin-left: 18px; font-size: 20px; }
#searchInput { flex: 1; border: none; height: 48px; font-size: 16px; padding: 0 16px; color: var(--text-main); background: transparent; }

.search-actions { display: flex; gap: 10px; }
.action-icon { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 12px; cursor: pointer; color: var(--text-sub); transition: 0.2s; }
.action-icon:hover { background: var(--bg-page); color: var(--primary); }
.action-icon-primary { width: 48px; height: 48px; background: var(--primary); color: white; border: none; border-radius: 14px; cursor: pointer; font-size: 20px; transition: 0.2s; }
.action-icon-primary:hover { transform: scale(1.05); box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.4); }

/* Toggle 现代开关 */
.search-options { margin-top: 20px; display: flex; align-items: center; justify-content: center; gap: 12px; }
.toggle-switch { position: relative; display: inline-block; width: 46px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background-color: #cbd5e1; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; box-shadow: var(--shadow-sm); }
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(22px); }
.option-label { font-size: 14px; color: var(--text-sub); font-weight: 500; }

/* 3. 搜索结果卡片 - 矩形风格回归 */
.content-section { margin-bottom: 40px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.section-header h2 { font-size: 19px; font-weight: 800; color: var(--text-main); display: flex; align-items: center; gap: 10px; }
.badge { background: var(--primary-light); color: var(--primary); font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 20px; }

#resultsContainer { display: flex; flex-direction: column; gap: 18px; }

/* 卡片外壳 */
.result-card {
    background: white; border-radius: 16px; padding: 22px;
    box-shadow: var(--shadow-sm); border: 1px solid var(--border);
    transition: 0.2s ease;
}
.result-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--primary); }

.card-header { display: flex; justify-content: space-between; margin-bottom: 18px; align-items: center; }
.file-meta { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 16px; }
.file-icon-box { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; }

/* 经典矩形展示块 - Excel 栅格 */
.data-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.data-item { 
    background: var(--bg-item); border: 1px solid #e2e8f0; 
    border-radius: 8px; padding: 10px 14px; transition: 0.2s;
}
.data-item:hover { background: #fff; border-color: var(--primary); }
.data-label { font-size: 10px; text-transform: uppercase; color: var(--text-muted); font-weight: 800; margin-bottom: 3px; letter-spacing: 0.5px; }
.data-value { font-size: 14px; color: var(--text-main); font-weight: 600; word-break: break-all; line-height: 1.4; }

/* 经典矩形展示块 - 文档摘要 */
.text-snippet-container { 
    background: var(--bg-item); border: 1px solid #e2e8f0; 
    border-radius: 10px; padding: 18px; 
}
.text-snippet { font-size: 14.5px; line-height: 1.8; color: #334155; }

/* 高亮样式 */
mark { background: #fef08a; color: #854d0e; padding: 0 2px; border-radius: 3px; font-weight: 700; }

.sheet-tag { font-size: 11px; background: #f1f3f4; color: var(--text-sub); padding: 4px 10px; border-radius: 7px; font-weight: 800; border: 1px solid var(--border); }

/* 图标颜色 */
.icon-excel { background: var(--excel-bg); color: var(--excel-text); }
.icon-word { background: var(--word-bg); color: var(--word-text); }
.icon-pdf { background: var(--pdf-bg); color: var(--pdf-text); }

/* 4. 文件知识库列表 */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.file-card {
    background: white; border-radius: 14px; padding: 16px; display: flex; align-items: center; gap: 15px;
    border: 1px solid var(--border); transition: 0.2s; position: relative;
}
.file-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.file-card-name { font-weight: 700; font-size: 14px; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-card-date { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.delete-btn { opacity: 0; position: absolute; right: 10px; background: #fee2e2; color: var(--danger); border: none; width: 34px; height: 34px; border-radius: 10px; cursor: pointer; transition: 0.2s; }
.file-card:hover .delete-btn { opacity: 1; }

/* 5. 模态框与组件 */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(5px); z-index: 1000; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; animation: fadeIn 0.2s; }
.modal-card { background: white; width: 90%; max-width: 420px; border-radius: 28px; padding: 30px; box-shadow: var(--shadow-floating); animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1); }

.auth-tabs { display: flex; margin-bottom: 25px; border-bottom: 1px solid var(--border); }
.auth-tab { flex: 1; padding: 12px; background: none; border: none; font-weight: 700; color: var(--text-muted); cursor: pointer; border-bottom: 3px solid transparent; }
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.input-group { position: relative; margin-bottom: 18px; }
.input-group i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.input-group input { width: 100%; padding: 14px 16px 14px 48px; border: 1px solid var(--border); border-radius: 14px; background: #f9fafb; font-size: 15px; transition: 0.2s; }
.input-group input:focus { background: white; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); }

.btn-primary { width: 100%; background: var(--primary); color: white; border: none; padding: 14px; border-radius: 14px; font-weight: 700; cursor: pointer; transition: 0.2s; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3); }

/* 单选卡片样式 */
.radio-card { display: flex; align-items: center; padding: 15px; border: 2px solid var(--border); border-radius: 16px; cursor: pointer; transition: 0.2s; position: relative; margin-bottom: 10px; }
.radio-card.selected { border-color: var(--primary); background: var(--primary-light); }
.radio-card input { display: none; }
.radio-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.radio-desc { font-size: 12px; color: var(--text-sub); display: block; margin-top: 2px; }

/* 加载器动画 */
#loading { display: none; position: fixed; inset: 0; background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(4px); z-index: 2000; align-items: center; justify-content: center; flex-direction: column; }
#loading.active { display: flex; }
.dots-loader { display: flex; gap: 8px; margin-bottom: 15px; }
.dots-loader div { width: 14px; height: 14px; background: var(--primary); border-radius: 50%; animation: bounce 0.6s infinite alternate; }
.dots-loader div:nth-child(2) { animation-delay: 0.2s; }
.dots-loader div:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce { to { transform: translateY(-12px); opacity: 0.4; } }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* 响应式 */
@media (max-width: 640px) {
    .hero-section { margin-top: 40px; }
    .logo-area h1 { font-size: 40px; }
    .data-grid { grid-template-columns: 1fr; }
    .file-grid { grid-template-columns: 1fr; }
    .search-actions .action-icon { display: none; }
    #searchInput { font-size: 14px; }
}