:root {
    --bg-dark: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent: #38bdf8;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --radius: 16px;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; transition: background-color 0.3s, color 0.3s; }

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    font-size: 16px;
}

.bg-image { position: fixed; inset: 0; z-index: -2; background-size: cover; background-position: center; transition: opacity 0.8s ease; transform: scale(1.05); }
.bg-overlay { position: fixed; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(15,23,42,0.4) 0%, rgba(15,23,42,0.95) 100%); backdrop-filter: blur(10px); }
.bg-overlay::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 50% 50%, var(--accent), transparent 70%); opacity: 0.15; animation: breathe 10s infinite alternate; }
@keyframes breathe { 0% { opacity: 0.1; transform: scale(1); } 100% { opacity: 0.2; transform: scale(1.2); } }

.app-container { max-width: 1200px; margin: 0 auto; padding: 20px; position: relative; z-index: 1; }

.glass { 
    background: var(--glass-bg); 
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); 
    border: 1px solid var(--glass-border); 
    border-radius: var(--radius); 
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s, border-color 0.3s;
}
.glass:hover { transform: translateY(-5px); box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 0 10px -2px var(--accent); border-color: rgba(255,255,255,0.2); }

@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.fade-in-up { animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; opacity: 0; }

.navbar { display: flex; justify-content: space-between; align-items: flex-start; padding: 15px 20px; margin-bottom: 20px; gap: 20px; flex-wrap: wrap; position: relative; z-index: 1000; }
.brand { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.brand-main { font-size: 1.6rem; font-weight: 800; color: #fff; letter-spacing: -0.5px; text-shadow: 0 2px 10px rgba(255,255,255,0.1); }
.brand-badge { font-family: 'Outfit', monospace; font-size: 0.8rem; font-weight: 600; color: var(--accent); background: rgba(56, 189, 248, 0.15); border: 1px solid rgba(56, 189, 248, 0.3); padding: 3px 8px; border-radius: 6px; letter-spacing: 0.5px; transform: translateY(2px); }

.search-container { flex: 1; max-width: 450px; display: flex; flex-direction: column; gap: 10px; position: relative; z-index: 1001; }
.search-wrapper { display: flex; background: rgba(255,255,255,0.08); border-radius: 50px; padding: 8px 15px; width: 100%; transition: 0.3s; position: relative; }
.search-wrapper:focus-within { background: rgba(255,255,255,0.15); border: 1px solid var(--accent); box-shadow: 0 0 15px var(--accent); }
.search-wrapper input { background: transparent; border: none; color: white; outline: none; font-size: 1rem; width: 100%; }
.search-wrapper button { background: transparent; border: none; color: white; cursor: pointer; display: flex; align-items: center; padding: 0 5px; transition: transform 0.2s; }
.search-wrapper button:active { transform: scale(0.9); }

.suggestions-box { position: absolute; top: 110%; left: 0; right: 0; background: #1e293b; border: 1px solid var(--glass-border); border-radius: 12px; overflow: hidden; display: none; box-shadow: 0 10px 40px rgba(0,0,0,0.8); z-index: 9999; max-height: 300px; overflow-y: auto; }
.suggestion-item { padding: 12px 15px; color: var(--text-main); cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 0.95rem; transition: 0.2s; display: flex; justify-content: space-between; }
.suggestion-item:hover { background: var(--accent); color: white; }
.suggestion-item small { color: var(--text-muted); font-size: 0.8rem; }
.suggestion-item:hover small { color: rgba(255,255,255,0.8); }

.history-chips { display: flex; gap: 8px; flex-wrap: wrap; padding-left: 5px; }
.history-chip { background: rgba(255,255,255,0.1); color: var(--text-muted); padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; cursor: pointer; transition: 0.2s; border: 1px solid transparent; }
.history-chip:hover { background: var(--accent); color: white; border-color: var(--accent); transform: scale(1.05); }

/* --- 核心布局修复 --- */
.dashboard { 
    display: grid; 
    grid-template-columns: 360px minmax(0, 1fr); 
    gap: 20px; 
    width: 100%; 
    position: relative; 
    z-index: 1; 
    align-items: stretch; /* 强制左右等高 */
}

/* 确保列容器占满高度 */
.left-col, .right-col { 
    display: flex; 
    flex-direction: column; 
    gap: 20px; 
    min-width: 0; 
    height: 100%; 
}
/* ------------------ */

.split-cards { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 20px; 
}

h3 { font-size: 0.95rem; margin-bottom: 15px; color: var(--text-muted); font-weight: 500; letter-spacing: 0.5px; display: flex; align-items: center; gap: 8px; }

/* 核心卡片 */
.current-card { padding: 25px; text-align: center; position: relative; overflow: hidden; }
.current-card::before { content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background: radial-gradient(circle, var(--accent) 0%, transparent 60%); opacity: 0.1; z-index: -1; }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.card-header h1 { font-size: 1.5rem; font-weight: 600; }
.card-header p { color: var(--accent); font-size: 0.85rem; text-align: left; }
.aqi-badge { background: rgba(255,255,255,0.1); padding: 4px 10px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; border: 1px solid transparent; }

.temp-hero { margin: 10px 0; }
.temp-hero img { width: 100px; height: 100px; filter: drop-shadow(0 0 20px rgba(255,255,255,0.2)); animation: floatIcon 3s ease-in-out infinite; }
@keyframes floatIcon { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.temp-data { font-size: 4.5rem; font-weight: 300; line-height: 1; margin: 5px 0; letter-spacing: -2px; text-shadow: 0 0 30px rgba(255,255,255,0.1); }
.temp-data .unit { font-size: 2rem; vertical-align: top; color: var(--text-muted); }
.weather-text { font-size: 1.2rem; margin-bottom: 5px; }

/* 详情网格 */
.detail-grid { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 12px; 
    padding: 20px; 
    align-content: start; 
}
.d-item { 
    background: rgba(255,255,255,0.03); 
    padding: 15px; 
    border-radius: 12px; 
    display: flex; 
    flex-direction: column; 
    justify-content: space-between; 
    min-height: 100px; 
    transition: 0.2s; 
}
.d-item:hover { background: rgba(255,255,255,0.08); }
.d-head { font-size: 0.8rem; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.d-val { font-size: 1.4rem; font-weight: 600; margin-top: 5px; }
.d-desc { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 5px; }
.progress-bar { height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; margin-top: auto; }
.progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 1s; box-shadow: 0 0 10px var(--accent); }
.uv-gradient { background: linear-gradient(90deg, #22c55e, #eab308, #ef4444); }
.compass-circle { width: 30px; height: 30px; border: 2px solid rgba(255,255,255,0.2); border-radius: 50%; position: relative; margin-top: auto; align-self: flex-end; }
.compass-arrow { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 14px; color: var(--accent); transition: transform 1s; }

/* AQI 卡片样式优化 */
.aqi-card { 
    padding: 20px; 
    display: flex; 
    flex-direction: column; 
}
.aqi-content-wrapper { flex: 1; display: flex; align-items: center; justify-content: center; flex-direction: column; }
.aqi-main-val { font-size: 2.5rem; font-weight: bold; margin-bottom: 5px; color: var(--text-main); }
.aqi-label { font-size: 0.8rem; opacity: 0.7; color: var(--text-muted); }
.aqi-sub-grid { margin-top: 15px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; text-align: center; font-size: 0.75rem; }
.aqi-sub-grid div { background: rgba(255,255,255,0.05); padding: 5px; border-radius: 6px; color: var(--text-muted); }
.aqi-sub-grid b { display: block; color: var(--text-main); font-size: 0.9rem; margin-top: 2px; }

/* 气象冷知识 (右侧底部) */
.trivia-card {
    padding: 25px; 
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    min-height: 200px;
    flex-grow: 1; /* 自动填满右侧剩余空间 */
}
.trivia-icon-bg {
    position: absolute;
    right: -10px;
    bottom: -30px;
    font-size: 10rem;
    font-weight: 800;
    font-family: serif;
    color: rgba(255, 255, 255, 0.03);
    transform: rotate(15deg);
    pointer-events: none;
    z-index: 0;
}
.trivia-header { position: relative; z-index: 1; }
.trivia-content {
    position: relative;
    z-index: 1;
    margin: 15px 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.quote-mark { font-size: 2rem; color: var(--accent); opacity: 0.3; line-height: 1; font-family: serif; }
.quote-mark.right { align-self: flex-end; transform: rotate(180deg); }
.trivia-card h3 { margin-bottom: 0; font-size: 1rem; color: var(--accent); }
.trivia-card p { 
    font-size: 1rem; 
    color: var(--text-main); 
    line-height: 1.7; 
    opacity: 0.95; 
    margin: 5px 0;
    font-style: italic;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.trivia-footer { position: relative; z-index: 2; display: flex; justify-content: flex-end; }
.refresh-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: 0.3s;
}
.refresh-btn:hover { background: var(--accent); color: #fff; transform: scale(1.05); border-color: var(--accent); }
.refresh-btn svg { transition: transform 0.5s; }
.refresh-btn:hover svg { transform: rotate(180deg); }

/* 日月升落 */
.astro-card { padding: 20px; display: flex; flex-direction: column; }
.astro-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.astro-item { 
    background: rgba(255,255,255,0.03); 
    padding: 10px; 
    border-radius: 8px; 
    text-align: center; 
    transition: 0.2s; 
}
.astro-item:hover { background: rgba(255,255,255,0.08); }

/* 其他版块 */
.hourly-card, .forecast-card { padding: 20px; width: 100%; }
.hourly-scroll { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 5px; }
.hour-item { min-width: 60px; text-align: center; background: rgba(255,255,255,0.03); padding: 10px 5px; border-radius: 12px; transition: 0.2s; }
.hour-item:hover { background: rgba(255,255,255,0.1); transform: scale(1.05); }
.h-time { font-size: 0.75rem; color: var(--text-muted); }
.h-icon { width: 30px; height: 30px; margin: 4px 0; }
.h-temp { font-weight: 600; font-size: 0.9rem; }

.forecast-row { display: flex; align-items: center; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,0.05); transition: 0.2s; }
.forecast-row:last-child { border-bottom: none; }
.forecast-row:hover { background: rgba(255,255,255,0.05); padding-left: 10px; padding-right: 10px; border-radius: 8px; border-bottom-color: transparent; }
.f-day { width: 50px; font-weight: 600; font-size: 0.9rem; }
.f-bar-container { flex: 1; height: 6px; background: rgba(255,255,255,0.1); border-radius: 10px; margin: 0 10px; overflow: hidden; }
.f-bar-fill { height: 100%; background: linear-gradient(90deg, #38bdf8, #818cf8); border-radius: 10px; }
.f-detail { width: 70px; text-align: right; font-size: 0.9rem; }

/* 引导卡片 / 导航网格 (Nav Grid) */
.nav-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    width: 100%;
}
.guide-card {
    text-decoration: none;
    display: flex;
    align-items: center;
    padding: 15px;
    gap: 12px;
    transition: 0.3s;
    height: 100%;
}
.guide-card:hover {
    background: rgba(30, 41, 59, 0.8);
    transform: translateY(-3px);
    border-color: var(--accent);
}
.guide-icon {
    background: rgba(56, 189, 248, 0.15);
    min-width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    color: var(--accent);
    transition: 0.3s;
}
.blog-icon { background: rgba(16, 185, 129, 0.15); color: #10b981; }

.guide-card:hover .guide-icon {
    background: var(--accent) !important;
    color: white !important;
    transform: rotate(10deg);
}
.guide-card:hover .blog-icon { background: #10b981 !important; }

.guide-text h3 { margin: 0; color: var(--text-main); font-size: 1rem; margin-bottom: 2px; }
.guide-text p { margin: 0; color: var(--text-muted); font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guide-card:hover h3 { color: var(--accent) !important; }

/* --- 生活建议板块 (强力修复版) --- */
.lifestyle-card { 
    padding: 20px !important; 
    flex-grow: 1; /* 让外层蓝色卡片填满 */
    display: flex !important; /* 强制启用 Flex */
    flex-direction: column !important;
}
.card-title-icon { margin-bottom: 15px; color: var(--accent); display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.lifestyle-grid {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 12px;
    
    /* 关键：让网格容器本身占满卡片的剩余高度 */
    flex: 1 1 auto !important; 
    
    /* 关键：强制将高度分为4等份，并填满 */
    grid-template-rows: repeat(4, 1fr) !important; 
    height: auto !important;
}
.ls-item {
    background: rgba(255,255,255,0.05);
    padding: 0 15px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    transition: 0.3s;
    border: 1px solid transparent;
    
    /* 关键：强制格子填满分配到的空间 */
    height: 100% !important; 
    min-height: 0; /* 防止内容撑破 */
    justify-content: center; /* 让文字垂直居中 */
}
/* --------------------------------- */

.ls-item:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.1);
    transform: translateY(-2px);
}
.ls-header { display: flex; align-items: center; gap: 10px; }
.ls-icon {
    font-size: 1rem;
    background: rgba(56, 189, 248, 0.15);
    width: 28px; height: 28px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: var(--accent);
}
.ls-header strong { font-size: 0.9rem; color: var(--text-main); }
.ls-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0;
    padding-left: 38px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 强制生活指数在左侧栏内为单列布局 */
.left-col .lifestyle-grid { grid-template-columns: 1fr !important; }

/* SEO 和 Info 区域 */
.info-section { margin-top: 30px; padding: 30px; display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 30px; }
.info-column h4 { color: var(--accent); margin-bottom: 15px; font-size: 1.1rem; font-weight: 600; }
.info-column p { color: var(--text-muted); font-size: 0.9rem; line-height: 1.6; }
.seo-links { display: flex; flex-wrap: wrap; gap: 10px; }
.seo-links a { color: var(--text-main); background: rgba(255,255,255,0.05); padding: 5px 10px; border-radius: 6px; text-decoration: none; font-size: 0.85rem; transition: 0.2s; }
.seo-links a:hover { background: var(--accent); color: white; }

.seo-article a:hover { text-decoration: underline; }

.footer { text-align: center; color: var(--text-muted); margin-top: 30px; font-size: 0.75rem; padding-bottom: 20px; }
.footer a { color: var(--text-muted); text-decoration: none; margin: 0 5px; transition: color 0.2s; }
.footer a:hover { color: var(--accent); }

.overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.95); z-index: 99; display: none; place-items: center; }
.spinner { width: 40px; height: 40px; border: 3px solid var(--glass-border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: #ef4444; color: white; padding: 10px 20px; border-radius: 50px; display: none; z-index: 100; font-size: 0.9rem; }

@media (max-width: 900px) {
    .dashboard { grid-template-columns: 1fr; }
    .split-cards { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .navbar { flex-direction: column; align-items: stretch; }
    .search-container { max-width: 100%; }
    .glass:hover { transform: none; }
    .nav-grid { grid-template-columns: 1fr; } /* 手机端导航改回上下排列 */
}