* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: sans-serif;
}

body {
    background: #f0f2f5;
    padding: 0.75rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    -webkit-user-select: text; /* Allow text selection - Safari */
    user-select: text; /* Allow text selection - standard */
}

.app {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 1000px;
    padding: 0.75rem;
    overflow: hidden;
}

header {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
}

header h1 {
    margin-bottom: 0.75rem;
    font-size: 1.4rem;
}


.search {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

#city-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-width: 150px;
    user-select: text; /* Allow text selection */
}

#search-btn {
    background: #2c3e50;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.5rem 0.8rem;
    cursor: pointer;
}

#search-btn:hover {
    background: #34495e;
}

#search-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

main {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

section {
    width: 100%;
}

section h3 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

#current-weather,
#chart-container,
#search-history,
.forecast-card {
    background: #fafafa;
    border-radius: 8px;
    padding: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

#city-display {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    user-select: text; /* Allow text selection */
}

.weather-main {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin: 0.5rem 0;
}

#weather-icon {
    height: 50px;
    width: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#temp {
    font-size: 1.8rem;
    font-weight: bold;
    user-select: text; /* Allow text selection */
}

#condition {
    color: #666;
    margin-bottom: 0.5rem;
    text-align: center;
    font-size: 0.95rem;
    user-select: text; /* Allow text selection */
}

.details {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    color: #777;
    justify-content: center;
    font-size: 0.9rem;
    user-select: text; /* Allow text selection */
}

/* Chart */
#chart-container {
    width: 100%;
    height: 200px;
}

/* Forecast Cards */
#forecast-container h3 {
    margin-bottom: 0.5rem;
}

#forecast-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.forecast-card {
    text-align: center;
    padding: 0.6rem;
    user-select: text; /* Allow text selection */
}

.forecast-icon {
    margin: 0.2rem 0;
    height: 30px;
    display: flex;
    justify-content: center;
}

.forecast-day {
    font-weight: 500;
    margin-bottom: 0.2rem;
    font-size: 0.9rem;
}

.forecast-temp {
    color: #555;
    font-size: 0.9rem;
}

.forecast-condition {
    color: #777;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    font-size: 0.85rem;
}

#history-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding-top: 0.4rem;
}

.history-item {
    background: #eaeaea;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    user-select: text; /* Allow text selection */
}

.history-item:hover {
    background: #ddd;
}

.hidden {
    display: none;
}

.error {
    color: #c0392b;
    background: #fadbd8;
    padding: 0.6rem;
    border-radius: 4px;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    user-select: text; /* Allow text selection */
}

.weather-data-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Theme classes */
.sunny {
    background: linear-gradient(135deg, #f9d976 0%, #f39f86 100%);
}

.cloudy {
    background: linear-gradient(135deg, #b6cad8 0%, #c9d9e4 100%);
}

.rainy {
    background: linear-gradient(135deg, #87aec9 0%, #a0b7c7 100%);
}

@media (min-width: 641px) {
    .app {
        padding: 1rem;
    }

    header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    header h1 {
        margin-bottom: 0;
    }

    .search {
        width: 60%;
        margin-bottom: 0;
    }

    #current-weather {
        display: flex;
        flex-wrap: wrap;
    }

    #city-display {
        width: 100%;
    }

    .weather-main {
        width: auto;
        margin-right: 1.5rem;
    }

    .weather-details-group {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    #condition {
        text-align: left;
    }

    .details {
        justify-content: flex-start;
    }

    #forecast-cards {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.4rem;
    }

    #chart-container {
        height: 250px;
    }
}

@media (min-width: 1025px) {
    .app {
        padding: 1.5rem;
        max-width: 1200px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .search {
        width: 50%;
    }

    #search-btn {
        padding: 0.5rem 1.2rem;
    }

    .weather-data-container {
        display: flex;
        flex-direction: row;
        gap: 1rem;
    }

    #current-weather {
        width: 35%;
        display: flex;
        flex-direction: column;
    }

    #chart-container {
        width: 65%;
        height: auto;
    }

    /* more compact */
    #forecast-container {
        margin-top: 0.5rem;
    }

    .forecast-card {
        padding: 0.75rem 0.5rem;
    }

    .bottom-container {
        display: flex;
        gap: 1rem;
    }

    #search-history {
        width: 35%;
    }

    #forecast-container {
        width: 65%;
    }
}