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

:root {
    color-scheme: dark;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: linear-gradient(135deg, #0a0e27 0%, #1a1f3a 100%);
    color: #e2e8f0;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 30px;
    background: linear-gradient(90deg, #7c3aed, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.location-search {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 30px;
    backdrop-filter: blur(10px);
}

.search-box {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: stretch;
}

input[type="text"] {
    min-width: 0;
    padding: 12px 15px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-size: 1rem;
}

input[type="text"]::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

button {
    padding: 12px 25px;
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    max-width: 100%;
}

button:hover,
button:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(124, 58, 237, 0.4);
}

button:focus-visible,
input[type="text"]:focus-visible {
    outline: 2px solid rgba(165, 180, 252, 0.9);
    outline-offset: 2px;
}

.secondary-button {
    background: transparent;
    padding: 8px 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.date-controls {
    display: grid;
    grid-template-columns: auto auto auto minmax(0, 1fr);
    align-items: center;
    justify-content: start;
    gap: 10px;
    margin-top: 14px;
}

.date-chip {
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: white;
    font-weight: 600;
    min-width: 190px;
    text-align: center;
}

.nav-btn {
    min-width: 54px;
    padding: 10px 14px;
    white-space: nowrap;
}

.location-coordinates {
    margin-top: 10px;
    color: rgba(255, 255, 255, 0.74);
    font-size: 0.95rem;
    text-align: center;
}

.status-message {
    margin-top: 8px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.95rem;
    text-align: center;
}

.status-message[hidden] {
    display: none;
}

.status-message[data-state="error"] {
    color: #fecaca;
}

.section {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.section h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: #a5b4fc;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section h2::before {
    font-size: 1.2rem;
}

.section h2.moon-section::before {
    content: "🌙";
}

.section h2.moon-pos-section::before,
.section h2.dark-sky-section::before {
    content: "🌑";
}

.section-note {
    margin-bottom: 16px;
    color: rgba(255, 255, 255, 0.72);
}

.moon-phase {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
}

.moon-svg-container {
    width: 180px;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.moon-svg-container svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.2));
}

.moon-info {
    flex: 1;
}

.moon-info h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #f0f4ff;
}

.moon-info p {
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
}

.moon-info .angle-info {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    margin-top: 10px;
}

.moon-events {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 18px;
}

.moon-event {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 12px 14px;
}

.moon-event-label {
    display: block;
    color: rgba(255, 255, 255, 0.62);
    font-size: 0.8rem;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.moon-event-value {
    color: #f8fbff;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
}

.moon-event-countdown {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.88rem;
    margin-top: 4px;
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.with-top-margin {
    margin-top: 20px;
}

.data-item {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 10px;
    border-left: 3px solid #7c3aed;
}

.data-item label {
    display: block;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 5px;
}

.data-item .value {
    font-size: 1.2rem;
    font-weight: 600;
    color: #f0f4ff;
}

.dark-sky {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.1) 0%, rgba(59, 130, 246, 0.1) 100%);
    border: 1px solid rgba(124, 58, 237, 0.3);
}

.dark-period {
    background: rgba(124, 58, 237, 0.15);
    padding: 20px;
    border-radius: 10px;
    margin-top: 15px;
    border-left: 4px solid #7c3aed;
}

.dark-period .time-range {
    font-size: 1.4rem;
    font-weight: 600;
    color: #f0f4ff;
    margin-bottom: 5px;
}

.dark-period .duration {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
}

.night-weather {
    margin-top: 20px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.night-weather-header {
    margin-bottom: 14px;
}

.night-weather-header .section-note {
    margin-bottom: 0;
}

.detail-button {
    padding: 9px 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    color: #f0f4ff;
    font-size: 0.9rem;
    white-space: nowrap;
}

.detail-button[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.weather-context {
    margin-top: 12px;
    margin-bottom: 0;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 7, 17, 0.74);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 50;
}

.modal-dialog {
    width: min(980px, 100%);
    max-height: min(86vh, 900px);
    overflow: hidden;
    background: rgba(9, 14, 30, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 22px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 24px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-header h3 {
    font-size: 1.3rem;
    color: #f8fbff;
    margin-bottom: 6px;
}

.modal-subtitle {
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.92rem;
}

.modal-close {
    padding: 9px 14px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.14);
}

.modal-content {
    padding: 18px 24px 24px;
    overflow: auto;
    max-height: calc(86vh - 92px);
}

.weather-hourly-grid {
    display: grid;
    gap: 8px;
}

.weather-hourly-row {
    display: grid;
    grid-template-columns: 82px 104px 1.45fr repeat(5, minmax(0, 1fr));
    gap: 12px;
    align-items: stretch;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(255, 255, 255, 0.035);
}

.weather-hourly-row--header {
    position: sticky;
    top: 0;
    z-index: 1;
    padding-top: 0;
    padding-bottom: 6px;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.weather-hourly-cell {
    min-width: 0;
    padding: 8px 10px;
    border-radius: 12px;
}

.weather-hourly-cell--header {
    padding: 0 10px;
}

.weather-hourly-cell--time {
    padding-left: 0;
}

.weather-hourly-row--header .weather-hourly-cell:nth-child(3) .weather-hourly-heading,
.weather-hourly-cell--conditions .weather-hourly-value {
    white-space: nowrap;
}

.weather-hourly-cell--metric {
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.05);
}

.weather-hourly-heading {
    display: block;
    color: rgba(232, 240, 255, 0.66);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.weather-hourly-label {
    display: block;
    color: rgba(255, 255, 255, 0.62);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 5px;
}

.weather-hourly-value {
    display: block;
    color: #f8fbff;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.35;
    white-space: normal;
    overflow-wrap: anywhere;
}

.weather-hourly-value--stacked {
    white-space: normal;
    overflow-wrap: normal;
    display: grid;
    gap: 3px;
}

.weather-hourly-value--stacked span {
    display: block;
    line-height: 1.25;
}

.weather-tone--good {
    background: rgba(74, 222, 128, 0.18);
    border-color: rgba(74, 222, 128, 0.36);
}

.weather-tone--fair {
    background: rgba(250, 204, 21, 0.22);
    border-color: rgba(250, 204, 21, 0.4);
}

.weather-tone--poor {
    background: rgba(251, 146, 60, 0.24);
    border-color: rgba(251, 146, 60, 0.42);
}

.weather-tone--bad {
    background: rgba(248, 113, 113, 0.24);
    border-color: rgba(248, 113, 113, 0.44);
}

.weather-hourly-empty {
    color: rgba(255, 255, 255, 0.72);
    padding: 12px 2px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: rgba(255, 255, 255, 0.7);
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.suggestions:not(:empty) {
    margin-top: 10px;
}

.suggestion {
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.suggestion:hover,
.suggestion:focus-visible {
    background: rgba(124, 58, 237, 0.2);
    border-color: rgba(124, 58, 237, 0.5);
}

.suggestion::before {
    content: "📍";
    margin-right: 5px;
}

@media (max-width: 640px) {
    .search-box,
    .date-controls {
        grid-template-columns: 1fr;
    }

    .search-box button,
    .date-chip,
    .nav-btn {
        width: 100%;
    }

    .moon-phase {
        flex-direction: column;
        gap: 18px;
    }

    .moon-events {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
    }

    .detail-button,
    .modal-close {
        width: 100%;
    }

    .modal-backdrop {
        padding: 12px;
    }

    .modal-header,
    .modal-content {
        padding-left: 16px;
        padding-right: 16px;
    }

    .weather-hourly-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px 10px;
        padding: 12px;
    }

    .weather-hourly-row--header {
        display: none;
    }

    .weather-hourly-cell--time {
        padding-left: 10px;
    }
}
