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

:root {
    --bg: #0a0f1e;
    --card: rgba(255,255,255,0.04);
    --border: rgba(255,255,255,0.08);
    --text: #f0f4ff;
    --muted: rgba(240,244,255,0.45);
    --accent: #5b8dff;
}

/* Fix para Safari/iOS */
html {
    height: -webkit-fill-available;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-x: hidden;
}

/* Blobs de fondo */
.bg-blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.18;
    pointer-events: none;
    transition: background 2s ease;
}
.bg-blob.b1 {
    width: 500px; height: 500px;
    top: -100px; left: -100px;
    background: var(--blob1, #3b82f6);
    animation: float1 12s ease-in-out infinite;
}
.bg-blob.b2 {
    width: 400px; height: 400px;
    bottom: -80px; right: -80px;
    background: var(--blob2, #8b5cf6);
    animation: float2 15s ease-in-out infinite;
}

@keyframes float1 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(40px,30px)} }
@keyframes float2 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(-30px,-40px)} }

/* App */
.app {
    width: 100%;
    max-width: 480px;
    padding: 24px 16px;
    animation: fadeUp 0.6s ease both;
}

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

h1 {
    font-family: 'Syne', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 28px;
}

/* Buscador */
.search-wrap {
    display: flex;
    gap: 10px;
    margin-bottom: 28px;
}

input {
    flex: 1;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 18px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}
input::placeholder { color: var(--muted); }
input:focus { border-color: var(--accent); }

button {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 14px;
    padding: 14px 20px;
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    letter-spacing: 0.05em;
    transition: opacity 0.2s, transform 0.15s;
}
button:hover { opacity: 0.85; transform: translateY(-1px); }
button:active { transform: translateY(0); }

/* Card */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 32px;
    backdrop-filter: blur(20px);
    display: none;
    animation: fadeUp 0.5s ease both;
}
.card.visible { display: block; }

.city-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
}

.city-name {
    font-family: 'Syne', sans-serif;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.1;
}
.city-country {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 4px;
}

.weather-icon {
    font-size: 3.5rem;
    line-height: 1;
}

.temp-row { margin-bottom: 8px; }

.temp-big {
    font-family: 'Syne', sans-serif;
    font-size: 5rem;
    font-weight: 800;
    line-height: 1;
    background: linear-gradient(135deg, #fff 40%, var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.temp-unit { font-size: 2rem; font-weight: 400; }

.description {
    font-size: 1rem;
    color: var(--muted);
    text-transform: capitalize;
    margin-bottom: 28px;
}

.divider {
    height: 1px;
    background: var(--border);
    margin-bottom: 24px;
}

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.stat {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    text-align: center;
}
.stat-icon { font-size: 1.3rem; margin-bottom: 6px; }
.stat-val { font-family: 'Syne', sans-serif; font-size: 1.1rem; font-weight: 700; }
.stat-lbl { font-size: 0.72rem; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.08em; }

/* Error y loading */
.error {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.25);
    border-radius: 14px;
    padding: 14px 18px;
    color: #fca5a5;
    font-size: 0.9rem;
    display: none;
    margin-bottom: 16px;
}
.error.visible { display: block; }

.loading {
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
    display: none;
    padding: 20px;
}
.loading.visible { display: block; }

@media (max-width: 480px) {
    .card {
        padding: 20px;
    }

    .city-name {
        font-size: 1.5rem;
    }

    .temp-big {
        font-size: 3.5rem;
    }

    .temp-unit {
        font-size: 1.5rem;
    }

    .stat {
        padding: 10px 6px;
    }

    .stat-val {
        font-size: 0.95rem;
    }

    .stat-lbl {
        font-size: 0.65rem;
    }

    .stat-icon {
        font-size: 1.1rem;
    }

    .history-wrap {
        margin-top: 15px;
        padding-top: 10px;
    }

    .history-wrap h3 {
        font-size: 0.8rem;
        margin-bottom: 8px;
    }

    #searchHistory li {
        font-size: 0.75rem;
        padding: 4px 8px;
    }
}

/* Estilos para los nuevos botones */
#geolocateBtn,
#unitsToggle {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 14px;
    padding: 14px 16px;
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    letter-spacing: 0.05em;
    transition: opacity 0.2s, transform 0.15s;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#geolocateBtn:hover,
#unitsToggle:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

#geolocateBtn:active,
#unitsToggle:active {
    transform: translateY(0);
}

/* Ajustes para el contenedor de búsqueda con los nuevos botones */
.search-wrap {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.search-wrap input {
    min-width: 120px;
}

@media (max-width: 480px) {
    .search-wrap {
        gap: 6px;
    }
    
    .search-wrap input,
    #geolocateBtn,
    #unitsToggle,
    .search-wrap button {
        padding: 12px 14px;
        font-size: 0.8rem;
    }
    
    #geolocateBtn,
    #unitsToggle {
        min-width: 40px;
        padding: 12px;
    }
}