:root {
    --body-bg: #aebbc6;
    --body-bg-2: #a1afbb;
    --text: #18242d;
    --text-soft: #465a67;

    --surface: #e2e9ee;
    --surface-soft: #d8e1e8;
    --surface-border: #a9bac6;
    --surface-border-strong: #98adbb;

    --accent: #355f7b;
    --accent-strong: #294a60;
    --accent-soft: #c8d7e1;

    --shadow-lg: 0 18px 40px rgba(24, 36, 45, 0.14);
    --shadow-md: 0 10px 24px rgba(24, 36, 45, 0.12);
    --shadow-sm: 0 6px 16px rgba(24, 36, 45, 0.10);

    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 10px;

    --button-bg: #355f7b;
    --button-bg-hover: #294a60;
    --button-text: #ffffff;
    --button-border: rgba(53, 95, 123, 0.26);

    --input-bg: #eef3f7;
    --input-border: #9fb2bf;
    --input-focus: #728b9c;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 24px;
    min-height: 100vh;
    font-family: Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top right, rgba(53, 95, 123, 0.14) 0%, rgba(53, 95, 123, 0) 24%),
        linear-gradient(180deg, var(--body-bg) 0%, var(--body-bg-2) 100%);
    cursor: default;
}

.home-shell {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
}

.home-layout {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

/* PANELS */

.search-panel,
.results-panel {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.search-panel {
    background: linear-gradient(180deg, #e3eaef 0%, #d5dee5 100%);
    position: relative;
    /* overflow: hidden; */
}

.search-panel::before {
    position: absolute;
    top: -140px;
    right: -120px;
    width: 360px;
    height: 360px;
    background: radial-gradient(circle, rgba(53, 95, 123, 0.14) 0%, rgba(53, 95, 123, 0) 72%);
    pointer-events: none;
}

.search-panel::after {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0) 42%);
    pointer-events: none;
}

.search-panel-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 28px 28px 30px;
    max-width: 100%;
}

/* BRAND */

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: inherit;
}

.brand-hero {
    width: 100%;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 14px;
}

.brand-logo {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 4px 10px rgba(24, 36, 45, 0.14));
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}

.brand-title {
    display: block;
    margin: 0;
    width: 100%;
    max-width: none;
    font-size: clamp(1.3rem, 2.1vw, 1.85rem);
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text);
    font-weight: 800;
}

/* SEARCH BOX */

.search-box {
    width: 100%;
    background: rgba(238, 243, 247, 0.78);
    border: 1px solid rgba(159, 178, 191, 0.92);
    border-radius: 22px;
    box-shadow:
        0 10px 24px rgba(24, 36, 45, 0.10),
        inset 0 1px 0 rgba(255, 255, 255, 0.38);
    backdrop-filter: blur(8px);
    padding: 18px;
}

.search-wrap {
    position: relative;
    width: 100%;
    z-index: 5;
}

.search-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.search-input-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

#station-search {
    width: 100%;
    height: 50px;
    border-radius: 14px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text);
    padding: 0 52px 0 14px;
    font-size: 16px;
    box-shadow: 0 2px 8px rgba(24, 36, 45, 0.05);
}

#station-search:focus,
#station-search:focus-visible {
    outline: none;
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(53, 95, 123, 0.16);
}

#station-search::placeholder {
    color: #667b89;
}

#clear-search-btn {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text-soft);
    cursor: pointer;
    display: none;
}

#clear-search-btn.is-visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

#search-btn {
    min-width: 140px;
    border-radius: 14px;
    border: 1px solid var(--button-border);
    background: var(--button-bg);
    color: var(--button-text);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    padding: 0 18px;
    box-shadow: 0 8px 18px rgba(53, 95, 123, 0.22);
    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        background 0.15s ease,
        opacity 0.15s ease,
        border-color 0.15s ease;
}

.search-meta {
    margin: 14px 0 0 0;
    color: var(--text-soft);
    font-size: 0.98rem;
    line-height: 1.55;
    text-align: center;
}

/* AUTOCOMPLETE */

.autocomplete {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #eef3f7;
    border: 1px solid var(--surface-border);
    border-radius: 16px;
    box-shadow:
        0 16px 32px rgba(24, 36, 45, 0.15),
        0 2px 6px rgba(24, 36, 45, 0.07);
    max-height: 320px;
    overflow-y: auto;
    display: none;
    z-index: 10;
}

.autocomplete-item {
    padding: 11px 14px;
    cursor: pointer;
    color: var(--text);
    border-bottom: 1px solid rgba(24, 36, 45, 0.06);
    line-height: 1.35;
    word-break: break-word;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background: var(--accent-soft);
}

/* RESULTS PANEL */

.results-panel {
    padding: 24px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.section-head-copy {
    min-width: 0;
}

.section-head h2 {
    margin: 0;
    color: var(--text);
    font-size: 1.4rem;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.section-subtitle {
    margin: 8px 0 0 0;
    color: var(--text-soft);
    font-size: 0.98rem;
    line-height: 1.5;
}

.section-head .meta {
    flex-shrink: 0;
    padding: 9px 12px;
    border-radius: 999px;
    background: var(--surface-soft);
    border: 1px solid var(--surface-border);
    color: var(--text-soft);
    font-size: 0.93rem;
    font-weight: 700;
    line-height: 1.2;
}

#results-container {
    min-height: 80px;
}

.state-box {
    padding: 30px 18px;
    text-align: center;
    color: var(--text-soft);
    background: var(--surface-soft);
    border: 1px dashed var(--surface-border-strong);
    border-radius: 16px;
    line-height: 1.5;
}

/* GRID */

.stations-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 22px 18px;
    align-items: stretch;
}

/* CARD */

.station-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 18px;
    padding: 14px 14px 12px;
    width: 100%;
    height: 100%;
    box-shadow: var(--shadow-sm);
    position: relative;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.station-card-image {
    width: 100%;
    max-width: 170px;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    margin: 0 auto;
}

.station-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.station-card-image.is-loaded img {
    opacity: 1;
}

.station-image-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.station-image-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(53, 95, 123, 0.16);
    border-top-color: rgba(53, 95, 123, 0.92);
    border-radius: 50%;
    animation: station-spin 0.8s linear infinite;
}

@keyframes station-spin {
    to {
        transform: rotate(360deg);
    }
}

.station-card-image.is-loaded .station-image-loader,
.station-card-image.is-fallback .station-image-loader {
    display: none;
}

.station-card-image .fallback-icon {
    font-size: 80px;
    color: #7f94a1;
}

.station-card-body {
    width: 100%;
    padding: 12px 4px 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-grow: 1;
}

.station-card-name {
    font-size: 0.96rem;
    font-weight: 700;
    text-align: center;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.35;
}

/* ACTIONS */

.actions {
    display: flex;
    justify-content: center;
    margin-top: 24px;
}

#load-more-btn {
    display: none;
    border-radius: 14px;
    border: 1px solid var(--button-border);
    background: var(--button-bg);
    color: var(--button-text);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    padding: 12px 30px;
    box-shadow: 0 8px 18px rgba(53, 95, 123, 0.22);
    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        background 0.15s ease,
        opacity 0.15s ease,
        border-color 0.15s ease;
}

/* DISABLED */

#search-btn:disabled,
#load-more-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* FOOTER */

.home-footer {
    margin-top: 28px;
    padding: 18px 20px;
    text-align: center;
    background: rgba(226, 233, 238, 0.86);
    border: 1px solid var(--surface-border);
    border-radius: 18px;
    box-shadow: var(--shadow-sm);
}

.footer-note {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-soft);
    line-height: 1.65;
}

/* HOVER DESKTOP ONLY */

@media (hover: hover) and (min-width: 701px) {
    #clear-search-btn:hover {
        background: rgba(53, 95, 123, 0.10);
        color: var(--accent-strong);
    }

    .station-card:hover {
        border-color: var(--accent);
    }

    #search-btn:not(:disabled):hover,
    #load-more-btn:not(:disabled):hover {
        transform: translateY(-2px);
        box-shadow: 0 12px 22px rgba(53, 95, 123, 0.24);
        background: var(--button-bg-hover);
    }
}

/* RESPONSIVE */

@media (max-width: 1100px) {
    .stations-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .stations-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    body {
        padding: 12px;
    }

    .search-panel-inner,
    .results-panel {
        padding: 16px;
    }

    .search-panel-inner {
        gap: 18px;
    }

    .brand-hero {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .brand-hero .brand-text {
        align-items: center;
    }

    .brand-title {
        font-size: 1.3rem;
        text-align: center;
    }

    .search-box {
        padding: 14px;
        border-radius: 18px;
    }

    .search-row {
        flex-direction: column;
    }

    #search-btn,
    #load-more-btn {
        min-height: 46px;
        width: 100%;
    }

    .search-meta {
        font-size: 0.95rem;
    }

    .section-head {
        flex-direction: column;
        align-items: center;
        gap: 8px;
        text-align: center;
    }

    .section-head .meta {
        text-align: center;
        width: auto;
    }

    .stations-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px 12px;
    }

    .station-card-image {
        max-width: 130px;
    }

    .home-footer {
        padding: 16px;
    }

    .footer-note {
        font-size: 0.92rem;
    }
}

@media (max-width: 380px) {
    .stations-grid {
        grid-template-columns: 1fr;
    }

    .station-card-image {
        max-width: 150px;
    }
}