:root {
    --bg-primary: #0a0f1a;
    --bg-card: #1a2234;
    --bg-card-hover: #212d45;
    --text-primary: #f1f5f9;
    --text-secondary: #b0bdd0;
    --text-muted: #8899ad;
    --accent-cyan: #22d3ee;
    --accent-blue: #60a5fa;
    --green: #34d399;
    --yellow: #fbbf24;
    --orange: #fb923c;
    --red: #f87171;
    --purple: #a78bfa;
    --pink: #f472b6;
    --border: #2d3a52;
    --radius: 12px;
}

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

body {
    font-family: 'DM Sans', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.app-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
    gap: 16px;
    flex-wrap: wrap;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.location-search {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    flex: 1;
    max-width: 360px;
}

.location-search input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    padding: 8px 12px;
    outline: none;
    font-family: inherit;
}

.location-search input::placeholder { color: var(--text-muted); }

.btn-search, .btn-geo {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
}

.btn-search:hover, .btn-geo:hover { background: var(--bg-card-hover); color: var(--accent-cyan); }

/* Main */
.main-content { flex: 1; padding: 16px 0; }
.hidden { display: none !important; }

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 80px 20px;
    color: var(--text-secondary);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
.hidden .spinner { animation: none; }

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--red);
    color: var(--red);
    padding: 16px;
    border-radius: var(--radius);
    text-align: center;
}


/* Data */
.data-container { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.location-info { margin-bottom: 20px; }
.location-info h2 { font-size: 1.5rem; margin-bottom: 2px; }
.coords { font-family: 'JetBrains Mono', monospace; color: var(--text-muted); font-size: 0.8rem; }
.timestamp { color: var(--text-secondary); font-size: 0.85rem; }

/* AQI Banner */
.aqi-banner {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 32px;
}

.aqi-left { flex: 1; min-width: 280px; max-width: 450px; }
.aqi-right { flex: 1; display: flex; align-items: center; border-left: 1px solid var(--border); padding-left: 32px; min-height: 80px; }

.aqi-label { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.aqi-reading { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.aqi-value { font-size: 3rem; font-weight: 700; font-family: 'JetBrains Mono', monospace; line-height: 1; }
.aqi-status { font-size: 0.8rem; font-weight: 600; padding: 6px 14px; border-radius: 6px; text-transform: uppercase; }
.aqi-message { color: var(--text-primary); font-size: 1.1rem; margin: 0; line-height: 1.5; }

/* AQI Scale */
.aqi-scale { width: 100%; }
.scale-bar {
    height: 8px;
    background: linear-gradient(90deg, var(--green) 0% 16.6%, var(--yellow) 16.6% 33.3%, var(--orange) 33.3% 50%, var(--red) 50% 66.6%, var(--purple) 66.6% 83.3%, var(--pink) 83.3% 100%);
    border-radius: 4px;
    position: relative;
}
.scale-marker {
    position: absolute;
    top: -5px;
    width: 18px;
    height: 18px;
    background: var(--text-primary);
    border: 3px solid var(--bg-card);
    border-radius: 50%;
    transform: translateX(-50%);
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.scale-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 0.6rem;
    color: var(--text-muted);
}

/* Level colors - shared */
.aqi-good, .level-good { --level-color: var(--green); }
.aqi-moderate, .level-moderate { --level-color: var(--yellow); }
.aqi-unhealthy-sensitive, .level-sensitive { --level-color: var(--orange); }
.aqi-unhealthy, .level-unhealthy { --level-color: var(--red); }
.aqi-very-unhealthy, .level-very-unhealthy { --level-color: var(--purple); }
.aqi-hazardous, .level-hazardous { --level-color: var(--pink); }
.level-unknown { --level-color: var(--text-muted); }

.aqi-banner .aqi-value { color: var(--level-color); }

.aqi-good .aqi-status { background: rgba(52, 211, 153, 0.15); color: var(--green); }
.aqi-moderate .aqi-status { background: rgba(251, 191, 36, 0.15); color: var(--yellow); }
.aqi-unhealthy-sensitive .aqi-status { background: rgba(251, 146, 60, 0.15); color: var(--orange); }
.aqi-unhealthy .aqi-status { background: rgba(248, 113, 113, 0.15); color: var(--red); }
.aqi-very-unhealthy .aqi-status { background: rgba(167, 139, 250, 0.15); color: var(--purple); }
.aqi-hazardous .aqi-status { background: rgba(244, 114, 182, 0.15); color: var(--pink); }

/* Pollutants */
.pollutants-section { margin-bottom: 24px; }
.pollutants-section h3 { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 12px; font-weight: 600; }

.pollutants-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }

.pollutant-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    border-left: 3px solid var(--level-color, var(--border));
}
.pollutant-card:hover { background: var(--bg-card-hover); }

.pollutant-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.pollutant-name { font-size: 0.85rem; font-weight: 600; }
.pollutant-level { font-size: 0.6rem; padding: 2px 6px; border-radius: 8px; font-weight: 600; text-transform: uppercase; background: color-mix(in srgb, var(--level-color) 20%, transparent); color: var(--level-color); }

.pollutant-values { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.pollutant-value { font-size: 1.4rem; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.pollutant-unit { font-size: 0.7rem; color: var(--text-secondary); }
.pollutant-aqi { font-size: 0.75rem; font-weight: 600; padding: 3px 8px; border-radius: 4px; font-family: 'JetBrains Mono', monospace; background: color-mix(in srgb, var(--level-color) 15%, transparent); color: var(--level-color); }
.pollutant-desc { font-size: 0.75rem; color: var(--text-muted); line-height: 1.4; }

/* Forecast */
.forecast-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 10px 10px 10px;
    margin-bottom: 24px;
    overflow: hidden;
}
.forecast-section h3 { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 8px; font-weight: 600; padding-left: 6px; }
.forecast-chart { position: relative; overflow: hidden; }
.forecast-svg { width: 100%; height: auto; display: block; font-family: 'JetBrains Mono', monospace; }
.forecast-dot { cursor: pointer; transition: r 0.15s ease; }
.forecast-dot:hover { r: 7; }
.forecast-tooltip {
    position: absolute;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.8rem;
    color: var(--text-primary);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 10;
    white-space: nowrap;
}

/* Footer */
.footer {
    padding: 20px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}
.footer a { color: var(--accent-cyan); text-decoration: underline; text-underline-offset: 2px; }
.footer a:hover { text-decoration-thickness: 2px; }

/* Mobile */
@media (max-width: 700px) {
    .header { flex-direction: column; }
    .location-search { max-width: none; }
    .aqi-banner { flex-direction: column; align-items: stretch; }
    .aqi-right { border-left: none; padding-left: 0; border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; min-height: auto; }
    .aqi-value { font-size: 2.5rem; }
    .aqi-scale { max-width: none; }
    .pollutants-grid { grid-template-columns: 1fr; }
}
