.map-shell {
    --brand: #14213d;
    --brand-2: #1f3160;
    --accent: #e85d04;
    --bg: #f4f6fa;
    --surface: #fff;
    --surface-2: #f0f2f7;
    --border: #dfe3ec;
    --text: #18202f;
    --muted: #5b6578;
    --focus: #2563eb;
    --radius: 12px;
    --header-height: 60px;
    --panel-width: 460px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html:has(.map-shell),
body:has(.map-shell) {
    --brand: #14213d;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: #14213d;
}

.map-skip {
    position: fixed;
    left: 12px;
    top: calc(8px + env(safe-area-inset-top));
    z-index: 3000;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    transform: translateY(-150%);
}

.map-skip:focus {
    transform: none;
}

.map-shell__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex: 0 0 auto;
    min-height: var(--header-height);
    padding: 8px 16px;
    padding-top: calc(8px + env(safe-area-inset-top));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    background: var(--brand);
    color: #fff;
}

.map-shell__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: #fff;
    text-decoration: none;
}

.map-shell__brand:hover {
    color: #fff;
    text-decoration: none;
}

.map-shell__logo {
    width: 22px;
    height: 29px;
    flex: 0 0 22px;
}

.map-shell__brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.map-shell__title {
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.2;
}

.map-shell__tagline {
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.8125rem;
    line-height: 1.2;
}

.map-shell #language-form {
    flex: 0 0 auto;
    margin: 0;
}

.map-shell__lang {
    display: flex;
    flex: 0 0 auto;
    padding: 2px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
}

.map-shell__lang-btn {
    min-width: 44px;
    min-height: 36px;
    padding: 6px 10px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
}

.map-shell__lang-btn.is-active {
    background: #fff;
    color: var(--brand);
}

.map-shell__body {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

.map-shell__panel {
    display: flex;
    flex-direction: column;
    width: var(--panel-width);
    flex: 0 0 var(--panel-width);
    min-height: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.map-shell__tools {
    flex: 0 0 auto;
    padding: 16px 16px 8px;
}

.map-shell__type-block {
    margin-top: 14px;
}

.map-shell__filter-label,
.map-shell .map-shell__filters label {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.type-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.type-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 4px 12px 4px 10px;
    border: 1.5px solid currentColor;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.type-chip__dot {
    width: 9px;
    height: 9px;
    flex: 0 0 9px;
    border-radius: 50%;
    background: currentColor;
}

.type-chip[aria-pressed="false"] {
    background: transparent !important;
    opacity: 0.45;
}

.type-chip[aria-pressed="false"] .type-chip__dot {
    background: transparent;
    box-shadow: inset 0 0 0 1.5px currentColor;
}

.type-chip__count {
    font-variant-numeric: tabular-nums;
}

.map-shell__filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.map-shell__filters select {
    width: 100%;
}

.map-shell__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 12px;
}

.map-shell__summary .map-shell__count {
    margin: 0;
}

.map-shell__reset {
    min-height: 36px;
    padding: 4px 0;
    border: 0;
    background: transparent;
    color: var(--focus);
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
}

.map-shell label {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 0.8125rem;
    font-weight: 600;
}

.map-shell label.map-shell__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.map-shell .form-control,
.map-shell .search-input {
    width: 100%;
    min-height: 36px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 16px;
    box-shadow: none;
}

.map-shell .search-input {
    border-radius: 999px;
    background: var(--surface-2);
}

.map-shell__count {
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 0.875rem;
    font-weight: 600;
}

.map-shell__error {
    margin: 8px 0 0;
    padding: 10px 12px;
    border: 1px solid #f3c0c0;
    border-radius: 8px;
    background: #fff4f4;
    color: #9b1c1c;
    font-size: 0.875rem;
}

.map-shell__list {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.map-shell .leaflet-bottom.leaflet-left {
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    pointer-events: none;
}

.map-shell .leaflet-bottom.leaflet-left .leaflet-control {
    float: none;
    margin-left: 0;
    margin-bottom: 12px;
    pointer-events: auto;
}

.map-shell .school-type-legend {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    min-width: 0;
    width: max-content;
    max-width: calc(100% - 24px);
    padding: 8px 16px;
    border: 0;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 4px 16px rgba(20, 33, 61, 0.16);
    color: #18202f;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}

.map-shell .school-type-legend__title {
    display: none;
}

.map-shell .school-type-legend__item {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.map-shell .school-type-legend__swatch {
    width: 10px;
    height: 10px;
    flex: 0 0 10px;
    border: 0;
    border-radius: 50%;
    box-shadow: none;
}

.map-shell .school-type-legend__label {
    font-weight: 700;
}

.school-name-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.school-name-list li {
    border-bottom: 1px solid var(--border);
}

.school-name-list a {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text);
    text-decoration: none;
}

.school-name-list__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-width: 44px;
    margin-top: 1px;
    padding: 4px 8px;
    border-radius: 8px;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.02em;
}

.school-name-list__body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.school-name-list__name {
    color: var(--text);
    font-size: 0.9375rem;
    font-weight: 700;
}

.school-name-list__meta {
    color: var(--muted);
    font-size: 0.8125rem;
    font-weight: 400;
    line-height: 1.3;
}

.school-name-list li:hover {
    background: var(--surface-2);
}

.map-shell #pagination-container {
    display: flex;
    justify-content: center;
    margin: 0;
    padding: 18px 16px 22px;
}

.map-shell #pagination-container .show-more {
    min-height: 44px;
    padding: 10px 22px;
    border: 1px solid #cfd6e0;
    border-radius: 999px;
    background: #fff;
    color: #1b2433;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
}

.map-shell #pagination-container .show-more:hover {
    background: var(--surface-2);
}

.map-shell #pagination-container .show-more:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.map-shell__map {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
}

.map-shell #mapid {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.map-shell__tabs {
    display: none;
}

.map-shell :focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.map-shell__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 899px) {
    .map-shell {
        --header-height: 56px;
    }

    .map-shell__tagline {
        display: none;
    }

    .map-shell__panel {
        width: 100%;
        flex: 1 1 auto;
        border-right: 0;
    }

    .map-shell.is-map .map-shell__panel {
        display: none;
    }

    .map-shell.is-list .map-shell__map {
        display: none;
    }

    .map-shell__tabs {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        flex: 0 0 auto;
        padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
        border-top: 1px solid var(--border);
        background: var(--surface);
    }

    .map-shell__tab {
        min-height: 40px;
        border: 1px solid var(--border);
        border-radius: 10px;
        background: var(--surface-2);
        color: var(--text);
        font-weight: 700;
        cursor: pointer;
    }

    .map-shell__tab[aria-pressed="true"] {
        border-color: var(--brand);
        background: var(--brand);
        color: #fff;
    }
}

/* Desktop and laptop windows: compact map icons and a single pagination row.
   Phone sizes stay on the rules above. */
@media (min-width: 900px) {
    .map-shell .leaflet-bar a,
    .map-shell .leaflet-touch .leaflet-bar a,
    .map-shell .leaflet-control-zoom a,
    .map-shell .leaflet-touch .leaflet-control-zoom-in,
    .map-shell .leaflet-touch .leaflet-control-zoom-out {
        width: 30px;
        height: 30px;
        line-height: 28px;
        font-size: 16px;
    }

    .map-shell .leaflet-control-layers-toggle,
    .map-shell .leaflet-touch .leaflet-control-layers-toggle {
        width: 30px;
        height: 30px;
        background-size: 20px 20px;
    }

    .map-shell .fullscreen-icon,
    .map-shell .leaflet-touch .fullscreen-icon {
        background-size: 22px 44px;
        background-position: center 4px;
    }

    .map-shell .fullscreen-icon.leaflet-fullscreen-on,
    .map-shell .leaflet-touch .fullscreen-icon.leaflet-fullscreen-on {
        background-position: center -18px;
    }

    .map-shell .leaflet-top .leaflet-control {
        margin-top: 12px;
    }

    .map-shell .leaflet-left .leaflet-control {
        margin-left: 12px;
    }

    .map-shell .leaflet-right .leaflet-control {
        margin-right: 12px;
    }
}

@media (prefers-color-scheme: dark) {
    .map-shell {
        --bg: #0f1524;
        --surface: #182033;
        --surface-2: #121a2b;
        --border: #2c3650;
        --text: #e8edf7;
        --muted: #a7b0c2;
    }

    .school-name-list li:hover {
        background: #243049;
    }

    .map-shell #pagination-container .show-more {
        border-color: var(--border);
        background: var(--surface);
        color: var(--text);
    }

    .map-shell #pagination-container .show-more:hover {
        background: #243049;
    }

    .map-shell__error {
        border-color: #6e3030;
        background: #3a1d24;
        color: #ffc9c9;
    }
}

@media (prefers-reduced-motion: reduce) {
    .map-shell *,
    .map-shell *::before,
    .map-shell *::after {
        transition: none !important;
        animation: none !important;
    }
}
