:root {
    --map-ink: #26343A;
    --map-control-ink: #27251f;
    --map-paper: #F3EDDF;
    --map-paper-light: #FAF7EF;
    --map-brass: #9A7440;
    --map-burgundy: #713E3A;
    --map-gray: #6F716C;
    --map-rule: #B9AD98;
    --map-link: #645047;
    --map-shadow: rgba(38, 52, 58, 0.14);
    --map-handle-fill: #efe6d4;
    --map-pin-fill: #8A403A;
    --map-route-line: #a64db3;
    --map-route-line-opacity: 0.6375;
    --map-route-line-width: 4.5;
    --map-pin-current-fill: #65302F;
    --map-pin-viewed-fill: #8f8a82;
    --map-pin-halo: #713e3a;
    --map-pin-hole: #FAF7EF;
    --map-popup-bg: #FAF7EF;
    --map-popup-fg: #26343A;
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.map-block {
    position: relative;
    margin: 1rem 0 1.5rem;
}

.map-canvas .map-focus-chips {
    position: absolute;
    top: 10px;
    right: 3.15rem;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-content: flex-start;
    gap: 0.28rem;
    max-width: calc(100% - 3.6rem);
    max-height: 4.8rem;
    overflow-x: hidden;
    overflow-y: auto;
    pointer-events: none;
}

.map-focus-chip {
    pointer-events: auto;
    font: inherit;
    font-size: 0.72rem;
    font-weight: 400;
    line-height: 1.2;
    color: #1c1a16;
    background: transparent;
    border: 1px solid rgba(39, 37, 31, 0.58);
    border-radius: 999px;
    padding: 0.22rem 0.62rem;
    min-height: 2.15rem;
    cursor: pointer;
}

@media (min-width: 40.01rem) {
    .map-canvas .map-focus-chips {
        flex-wrap: nowrap;
    }

    .map-focus-chip {
        min-height: 1.65rem;
        padding: 0.12rem 0.55rem;
    }
}

@media (max-width: 40rem) {
    .map-focus-chip {
        min-height: 2.35rem;
        padding: 0.28rem 0.7rem;
    }
}

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

.map-frame {
    position: relative;
    width: 100%;
    max-width: min(56rem, calc((100vh - 10rem) * 16 / 9));
    margin-left: auto;
    margin-right: auto;
    padding: 0.25rem;
    background: var(--map-paper-light);
    border: 1px solid var(--map-rule);
    border-radius: 2px;
    box-shadow: 0 1px 8px var(--map-shadow);
}

.map-shell-page {
    width: 100%;
    max-width: none;
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.map-shell-page .map-block {
    margin: 0;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
}

.map-shell-page .map-frame {
    max-width: none;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}

.map-workspace {
    display: grid;
    grid-template-areas: "stage sidebar";
    grid-template-columns: minmax(0, 1fr) minmax(17.5rem, 21.25rem);
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
    height: 100%;
    min-height: 0;
    position: relative;
}

.map-stage {
    grid-area: stage;
    position: relative;
    min-width: 0;
    min-height: 0;
    z-index: 2;
}

.map-sheet-slot {
    grid-area: sidebar;
    display: contents;
}

.map-sidebar {
    grid-area: sidebar;
    pointer-events: auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--map-paper-light);
    color: var(--map-ink);
    border: 0;
    border-left: 1px solid var(--map-rule);
    overflow: hidden;
}

/* Compact desktop sidebar action; mobile restores the shared copy icon. */
.map-sidebar [data-share-action="copy"] > svg {
    display: none;
}

@media (max-width: 640px), (max-width: 1024px) and (orientation: portrait), (max-width: 1024px) and (max-height: 640px) {
    .map-sidebar [data-share-action="copy"] > svg {
        display: inline;
    }
}

.map-sidebar-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.map-sidebar-info {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.map-sidebar.is-sheet-preview .map-sidebar-info {
    display: none;
}

.map-sidebar-preview {
    display: none;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
}

.map-sidebar.is-sheet-preview .map-sidebar-preview {
    display: flex;
}

.map-sidebar-top {
    flex: 0 0 auto;
    padding: 0.55rem 0.7rem 0.35rem;
}

.map-sidebar-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    padding: 0;
}

.map-sidebar-content {
    padding: 0 0.7rem 0.45rem;
}

.map-sidebar .site-footer {
    position: relative;
    z-index: 13;
    flex: 0 0 auto;
    max-width: none;
    width: auto;
    margin: 0;
    padding: 0.22rem 0.7rem 0.25rem;
    background: var(--map-paper-light);
}

.map-sidebar-copy {
    font-size: 0.92rem;
}

.map-sidebar-copy > :first-child {
    margin-top: 0;
}

.map-sidebar-intro h1 {
    margin: 0 0 0.35rem;
    font-size: 1.25rem;
}

.map-sidebar-description {
    margin: 0 0 0.6rem;
    font-size: 0.92rem;
}

.map-sidebar-heading {
    margin: 0.7rem 0 0.3rem;
    font-size: 0.95rem;
}

.map-sidebar .place-list,
.map-sidebar .region-routes ul {
    margin: 0;
    padding-left: 1.1rem;
}

body.page-home .map-sidebar-top {
    padding: 0;
}

body.page-home .map-sidebar-copy {
    padding-top: 12px;
}

.map-sidebar-home-intro {
    display: none;
    padding: 0.55rem 0.7rem 0.35rem;
}

.map-sheet-preview-head {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.45rem;
    padding: 0.35rem 0.45rem 0.2rem 0.55rem;
}

.map-sheet-preview-head .map-sheet-preview-name {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: 0.95rem;
    font-weight: 400;
    line-height: 1.35;
    color: var(--heading-ink, #49443c);
    overflow-wrap: anywhere;
}

.map-sheet-preview-close {
    box-sizing: border-box;
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: var(--map-handle-fill);
    color: var(--map-control-ink);
    font-family: Arial, sans-serif;
    font-size: 22px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    overflow: hidden;
}

.map-sheet-preview-close:focus-visible {
    outline: 2px solid var(--map-burgundy);
    outline-offset: 2px;
}

.map-sheet-preview-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    padding: 0 0.55rem 0.45rem;
}

.map-sheet-preview-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    min-width: 0;
}

.map-sheet-preview-card + .map-sheet-preview-card {
    margin-top: 0.55rem;
}

.map-sheet-preview-media {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    align-self: center;
    text-decoration: none;
}

.map-sheet-preview-media img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 2px;
}

.map-sheet-preview-copy {
    flex: 1 1 auto;
    min-width: 0;
}

.map-sheet-preview-name {
    margin: 0 0 0.35rem;
    font-weight: 400;
    color: var(--heading-ink, #49443c);
    overflow-wrap: anywhere;
}

.map-sheet-preview-media:focus-visible {
    outline: 2px solid var(--map-burgundy);
    outline-offset: 2px;
}

@media (max-width: 640px), (max-width: 1024px) and (orientation: portrait), (max-width: 1024px) and (max-height: 640px) {
    body.has-page-map .map-sheet-preview-open,
    body.has-page-map .map-sheet-preview-page {
        flex: 1 1 0;
        min-width: 0;
        text-align: center;
        z-index: 1;
    }
}

@media (max-width: 640px), (max-width: 1024px) and (orientation: portrait), (max-width: 1024px) and (max-height: 640px) {
    @media (aspect-ratio > 1/1) {
        body.has-page-map .map-sheet-preview-media {
            max-width: 100%;
            margin-left: auto;
            margin-right: auto;
        }
    }
}

body.has-page-map {
    overflow: hidden;
}

body.has-page-map .site-main {
    max-width: none;
    margin: 0;
    padding: 0;
}

body.has-page-map .home-intro {
    max-width: 72rem;
    margin: 0 auto;
    padding: 0.45rem 1rem 0.35rem;
}

@media (max-width: 640px), (max-width: 1024px) and (orientation: portrait), (max-width: 1024px) and (max-height: 640px) {
    body.has-page-map .home-intro {
        display: none;
    }

    .map-workspace {
        grid-template-areas:
            "stage"
            "sidebar";
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) minmax(0, 36vh);
        grid-template-rows: minmax(0, 1fr) minmax(0, 36dvh);
    }

    .map-stage {
        z-index: 2;
    }

    .map-sheet-slot {
        display: block;
        position: relative;
        z-index: 1;
        min-width: 0;
        min-height: 0;
        max-height: 36vh;
        max-height: 36dvh;
        pointer-events: auto;
        background: var(--map-paper-light);
    }

    .map-sidebar {
        flex: 1 1 auto;
        width: auto;
        max-width: none;
        max-height: none;
        min-height: 0;
        height: 100%;
        border: 0;
        border-top: 1px solid var(--map-rule);
        border-left: 0;
        border-radius: 0;
        overflow: hidden;
        padding-top: 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .map-sidebar-top {
        padding: 0.85rem 0.6rem 0.35rem;
    }

    .map-sidebar-content {
        padding: 0 0.6rem 0.45rem;
    }

    .map-sidebar .site-footer {
        padding: 0.22rem 0.6rem calc(0.25rem + env(safe-area-inset-bottom, 0px));
    }

    .map-sidebar-home-intro {
        display: block;
        padding: 0.85rem 0.6rem 0.35rem;
    }

    @media (aspect-ratio > 1/1) {
        .map-workspace {
            grid-template-areas: "stage sidebar";
            grid-template-columns: minmax(0, 1fr) minmax(0, calc(100vw / 3));
            grid-template-columns: minmax(0, 1fr) minmax(0, calc(100dvw / 3));
            grid-template-rows: minmax(0, 1fr);
        }

        .map-sheet-slot {
            max-height: none;
            height: 100%;
        }

        .map-sidebar {
            padding-bottom: env(safe-area-inset-bottom, 0px);
            padding-right: env(safe-area-inset-right, 0px);
            padding-left: 0;
            border-top: 0;
            border-left: 1px solid var(--map-rule);
        }

        .map-sidebar-top {
            padding: 0.45rem 0.6rem 0.35rem 0.85rem;
        }
    }

    body.has-page-map .map-workspace {
        grid-template-areas:
            "stage"
            "sidebar";
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) minmax(0, 36vh);
        grid-template-rows: minmax(0, 1fr) minmax(0, 36dvh);
    }

    body.has-page-map .map-sheet-slot {
        display: block;
        box-sizing: border-box;
        border-top: 1px solid var(--map-rule);
        min-width: 0;
        min-height: 0;
        width: auto;
        max-width: none;
        height: auto;
        max-height: 36vh;
        max-height: 36dvh;
        pointer-events: auto;
    }

    body.has-page-map .map-sidebar {
        border-top: 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    @media (aspect-ratio > 1/1) {
        body.has-page-map .map-workspace {
            grid-template-areas: "stage sidebar";
            grid-template-columns: minmax(0, 1fr) minmax(0, calc(100vw / 3));
            grid-template-columns: minmax(0, 1fr) minmax(0, calc(100dvw / 3));
            grid-template-rows: minmax(0, 1fr);
        }

        body.has-page-map .map-sheet-slot {
            box-sizing: border-box;
            border-top: 0;
            width: calc(100vw / 3);
            width: calc(100dvw / 3);
            max-width: calc(100vw / 3);
            max-width: calc(100dvw / 3);
            height: 100%;
            max-height: none;
            min-height: 0;
        }

        body.has-page-map .map-sidebar {
            padding-right: env(safe-area-inset-right, 0px);
            padding-bottom: env(safe-area-inset-bottom, 0px);
            border-top: 0;
            border-left: 1px solid var(--map-rule);
        }
    }
}

.map-canvas {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    min-height: 14rem;
    background: #EDE3D1;
    border-radius: 1px;
}

.map-canvas-page {
    aspect-ratio: auto;
    height: 100%;
    min-height: 0;
}

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

@media (max-width: 640px), (max-width: 1024px) and (orientation: portrait), (max-width: 1024px) and (max-height: 640px) {
    .map-frame {
        max-width: 100%;
    }
}

.map-canvas:fullscreen,
.map-canvas:-webkit-full-screen,
.map-canvas.maplibregl-pseudo-fullscreen {
    max-width: none;
    width: 100%;
    height: 100%;
    min-height: 0;
    aspect-ratio: auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    background: #EDE3D1;
}

.map-pin {
    position: relative;
    display: block;
    width: 26px;
    height: 36px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    transform-origin: 50% 100%;
    overflow: visible;
    filter: drop-shadow(0 1px 2px rgba(38, 52, 58, 0.32));
}

.map-marker-root,
.maplibregl-marker {
    overflow: visible;
}

.map-pin svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.map-pin.is-group {
    width: 32px;
    height: 44px;
}

.map-pin.is-group .map-pin-count {
    position: absolute;
    top: 12.5px;
    left: 50%;
    transform: translate(-50%, -50%);
    width: auto;
    min-width: 0;
    max-width: 14px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--map-pin-fill);
    font: 700 0.68rem/1 var(--font-sans, system-ui, sans-serif);
    text-align: center;
    pointer-events: none;
}

.map-pin.is-spatial {
    box-sizing: border-box;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--map-paper-light, #FAF7EF);
    border: 2px solid var(--map-burgundy, #713E3A);
    transform-origin: 50% 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 1px 2px rgba(38, 52, 58, 0.32));
}

.map-pin.is-spatial .map-pin-count {
    position: static;
    transform: none;
    width: auto;
    max-width: 28px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--map-burgundy, #713E3A);
    font: 700 0.72rem/1 var(--font-sans, system-ui, sans-serif);
    text-align: center;
    pointer-events: none;
}

.map-pin.is-spatial:hover:not(.is-current),
.map-pin.is-spatial:focus-visible:not(.is-current) {
    transform: scale(1.06);
}

.map-pin:hover:not(.is-current),
.map-pin:focus-visible:not(.is-current) {
    transform: scale(1.06);
}

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

.map-pin:focus:not(:focus-visible) {
    outline: none;
}

.map-popup {
    max-width: 16rem;
    color: var(--map-popup-fg);
    background: var(--map-popup-bg);
}

.map-popup-card {
    display: block;
    color: var(--map-link);
    text-decoration: none;
    font-weight: 700;
}

.map-popup-card + .map-popup-card {
    margin-top: 0.55rem;
}

.map-popup img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    margin: 0 0 0.4rem;
}

.map-popup-name {
    display: block;
}

.map-popup-card:hover,
.map-popup-card:focus-visible {
    color: var(--map-burgundy);
}

.maplibregl-ctrl-attrib,
.maplibregl-ctrl-attrib a {
    visibility: visible;
    opacity: 1;
}

.map-canvas .maplibregl-ctrl-attrib.maplibregl-compact {
    background-color: #FAF7EF;
    color: var(--map-control-ink);
    border-radius: 3px;
    box-shadow: none;
    width: 1.75rem;
    height: 1.75rem;
    min-height: 1.75rem;
    min-width: 1.75rem;
    padding: 0;
    overflow: hidden;
}

.map-canvas .maplibregl-ctrl-attrib.maplibregl-compact:after {
    display: none;
}

.map-canvas .maplibregl-ctrl-attrib.maplibregl-compact-show {
    width: 18rem;
    max-width: calc(100vw - 4rem);
    height: auto;
    overflow: visible;
    color: #26343A;
    background-color: #FAF7EF;
    padding: 0.15rem 1.85rem 0.15rem 0.45rem;
}

.map-canvas
.maplibregl-ctrl-attrib.maplibregl-compact-show
.maplibregl-ctrl-attrib-inner {
    display: block;
    width: auto;
    white-space: normal;
}

.map-canvas .maplibregl-ctrl-attrib a {
    color: #645047;
}

.map-canvas .maplibregl-ctrl-attrib a:hover,
.map-canvas .maplibregl-ctrl-attrib a:focus-visible {
    color: #713E3A;
}

.map-canvas .maplibregl-ctrl-attrib-button {
    width: 1.75rem;
    height: 1.75rem;
    background-image: none !important;
    background-color: var(--map-control-ink);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='8' fill='none' stroke='%23000' stroke-width='1.5'/%3E%3Cpath fill='%23000' d='M11 10h2v7h-2zM11 7h2v2h-2z'/%3E%3C/svg%3E") center / 15px 15px no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='8' fill='none' stroke='%23000' stroke-width='1.5'/%3E%3Cpath fill='%23000' d='M11 10h2v7h-2zM11 7h2v2h-2z'/%3E%3C/svg%3E") center / 15px 15px no-repeat;
}

.map-canvas .maplibregl-ctrl-attrib-button:hover,
.map-canvas .maplibregl-ctrl-attrib-button:focus-visible {
    background-color: #3a372f;
}

.map-canvas .maplibregl-ctrl-attrib-button:focus-visible {
    outline: 2px solid #713E3A;
    outline-offset: 2px;
}

.map-canvas:fullscreen .maplibregl-ctrl-attrib.maplibregl-compact,
.map-canvas:-webkit-full-screen .maplibregl-ctrl-attrib.maplibregl-compact,
.map-canvas.maplibregl-pseudo-fullscreen .maplibregl-ctrl-attrib.maplibregl-compact,
.map-shell:fullscreen .maplibregl-ctrl-attrib.maplibregl-compact,
.map-shell:-webkit-full-screen .maplibregl-ctrl-attrib.maplibregl-compact,
.map-shell.maplibregl-pseudo-fullscreen .maplibregl-ctrl-attrib.maplibregl-compact {
    background-color: #FAF7EF;
    border-color: #B9AD98;
}

.maplibregl-popup-content {
    background: var(--map-popup-bg);
    color: var(--map-popup-fg);
    border: 1px solid var(--map-rule);
    box-shadow: 0 1px 8px var(--map-shadow);
}

.maplibregl-popup-tip {
    border-top-color: var(--map-popup-bg);
}

.map-canvas .maplibregl-ctrl-group {
    background: var(--map-paper-light);
    border: 1px solid var(--map-rule);
    border-radius: 2px;
    box-shadow: 0 1px 6px var(--map-shadow);
    overflow: hidden;
}

.map-canvas .maplibregl-ctrl-group button {
    width: 2.25rem;
    height: 2.25rem;
    color: var(--map-control-ink);
    background-color: var(--map-paper-light);
}

.map-canvas .maplibregl-ctrl-group button + button {
    border-top: 1px solid var(--map-rule);
}

.map-canvas .maplibregl-ctrl-group button:not(:disabled):hover {
    background-color: var(--map-paper);
}

.map-canvas .maplibregl-ctrl-group button:not(:disabled):active {
    background-color: #EDE3D1;
}

.map-canvas .maplibregl-ctrl-group button:focus-visible {
    outline: 2px solid var(--map-burgundy);
    outline-offset: -2px;
}

.map-canvas .maplibregl-ctrl button .maplibregl-ctrl-icon {
    background-image: none;
    background-color: var(--map-control-ink);
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: 50%;
    -webkit-mask-size: 17px 17px;
    mask-repeat: no-repeat;
    mask-position: 50%;
    mask-size: 17px 17px;
}

.map-canvas .maplibregl-ctrl button .maplibregl-ctrl-icon.is-local-svg {
    background-color: transparent;
    -webkit-mask-image: none;
    mask-image: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-canvas .maplibregl-ctrl button .maplibregl-ctrl-icon.is-local-svg img {
    width: 24px;
    height: 24px;
    display: block;
    pointer-events: none;
}

.map-canvas .maplibregl-ctrl button:not(:disabled):hover .maplibregl-ctrl-icon,
.map-canvas .maplibregl-ctrl button:not(:disabled):active .maplibregl-ctrl-icon {
    background-color: var(--map-burgundy);
}

.map-canvas .maplibregl-ctrl button:not(:disabled):hover .maplibregl-ctrl-icon.is-local-svg,
.map-canvas .maplibregl-ctrl button:not(:disabled):active .maplibregl-ctrl-icon.is-local-svg {
    background-color: transparent;
}

.map-canvas .maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M11 5h2v14h-2zM5 11h14v2H5z'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M11 5h2v14h-2zM5 11h14v2H5z'/%3E%3C/svg%3E");
}

.map-canvas .maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M5 11h14v2H5z'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M5 11h14v2H5z'/%3E%3C/svg%3E");
}

.map-canvas .maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon.is-local-svg,
.map-canvas .maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon.is-local-svg {
    -webkit-mask-image: none;
    mask-image: none;
    background-color: transparent;
}

.map-canvas:fullscreen .maplibregl-ctrl-group,
.map-canvas:-webkit-full-screen .maplibregl-ctrl-group,
.map-canvas.maplibregl-pseudo-fullscreen .maplibregl-ctrl-group,
.map-shell:fullscreen .maplibregl-ctrl-group,
.map-shell:-webkit-full-screen .maplibregl-ctrl-group,
.map-shell.maplibregl-pseudo-fullscreen .maplibregl-ctrl-group {
    border-color: var(--map-rule);
    box-shadow: 0 1px 6px var(--map-shadow);
}

.map-pin.is-viewed:not(.is-current) {
    opacity: 1;
    filter: drop-shadow(0 1px 2px rgba(38, 52, 58, 0.32));
}

.map-pin.is-current {
    opacity: 1;
    filter: none;
}

.map-shell {
    position: relative;
}

.map-shell:fullscreen,
.map-shell:-webkit-full-screen,
.map-shell.maplibregl-pseudo-fullscreen {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    overflow: hidden;
    background: #EDE3D1;
}

.map-shell:fullscreen .map-workspace,
.map-shell:-webkit-full-screen .map-workspace,
.map-shell.maplibregl-pseudo-fullscreen .map-workspace,
.map-shell:fullscreen .map-stage,
.map-shell:-webkit-full-screen .map-stage,
.map-shell.maplibregl-pseudo-fullscreen .map-stage,
.map-shell:fullscreen .map-block,
.map-shell:-webkit-full-screen .map-block,
.map-shell.maplibregl-pseudo-fullscreen .map-block,
.map-shell:fullscreen .map-frame,
.map-shell:-webkit-full-screen .map-frame,
.map-shell.maplibregl-pseudo-fullscreen .map-frame,
.map-shell:fullscreen .map-canvas,
.map-shell:-webkit-full-screen .map-canvas,
.map-shell.maplibregl-pseudo-fullscreen .map-canvas {
    width: 100%;
    height: 100%;
    max-width: none;
    min-height: 0;
    aspect-ratio: auto;
}

.map-shell:fullscreen .map-frame,
.map-shell:-webkit-full-screen .map-frame,
.map-shell.maplibregl-pseudo-fullscreen .map-frame {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    background: #EDE3D1;
}

.map-viewer {
    margin: 0;
    padding: 0;
    border: 0;
    max-width: none;
    display: none;
    background: var(--map-paper-light);
    color: var(--map-ink);
    min-width: 0;
}

.map-viewer.is-open {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.map-shell.is-viewer-wide .map-viewer.is-open {
    position: absolute;
    top: 0;
    left: auto;
    right: 0;
    bottom: 0;
    width: min(36rem, 58%);
    height: auto;
    max-height: 100%;
    z-index: 12;
    padding: 0.75rem 1rem 2.6rem;
    border-left: 1px solid var(--map-rule);
    box-shadow: -8px 0 18px var(--map-shadow);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.map-viewer::backdrop {
    background: rgba(38, 52, 58, 0.46);
}

.map-shell.is-viewer-cinema .map-viewer.is-open {
    position: fixed;
    inset: 0.5rem;
    z-index: 21;
    width: auto;
    height: auto;
    max-height: calc(100vh - 1rem);
    max-height: calc(100dvh - 1rem);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.75rem 1rem 1rem;
    border: 1px solid var(--map-rule);
    box-shadow: 0 8px 28px var(--map-shadow);
}

body.is-map-viewer-open.is-map-viewer-cinema {
    overflow: hidden;
}

.map-viewer-head {
    display: flex;
    align-items: baseline;
    align-items: first baseline;
    flex: 0 0 auto;
    gap: 8px;
    margin: 0 0 6px;
}

.map-viewer-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: 1.15rem;
    font-weight: 400;
    color: var(--heading-ink, #49443c);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.map-viewer-close {
    box-sizing: border-box;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    min-width: 0;
    min-height: 0;
    max-width: 22px;
    max-height: 22px;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    color: #27251f;
    background: transparent;
    box-shadow: none;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}

.map-viewer-close > span {
    font-family: Arial, sans-serif;
    font-size: 24px;
    font-weight: 400;
    line-height: 1;
}

.map-viewer-close:hover {
    background: #e5dccb;
}

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

.map-viewer-close:focus:not(:focus-visible) {
    outline: none;
}

.map-viewer .youtube-embed {
    flex: 0 0 auto;
    align-self: center;
    width: 100%;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    overflow: visible;
}

.map-viewer .youtube-embed.is-playing iframe {
    z-index: 1;
}

.map-viewer-essay {
    flex: 0 0 auto;
    overflow: visible;
    min-height: 0;
    margin: 0.75rem 0;
    overflow-wrap: anywhere;
}

.map-viewer-essay:has(+ .map-viewer-note) {
    margin-bottom: 0;
}

.map-viewer-note {
    flex: 0 0 auto;
    overflow: visible;
    min-height: 0;
    margin: 0.75rem -1rem;
    padding: 24px 1rem;
    background: #f2e7e4;
    color: #1f2325;
    overflow-wrap: anywhere;
}

.map-viewer .map-viewer-essay > :first-child,
.map-viewer .geopage-note > :first-child {
    margin-top: 0;
}

.map-viewer .map-viewer-essay > :last-child,
.map-viewer .geopage-note > :last-child {
    margin-bottom: 0;
}

.map-viewer .map-viewer-essay + .map-viewer-note {
    margin-top: 32px;
}

.map-viewer .geopage-note h2 {
    margin: 14px 0 7px;
    color: var(--heading-ink);
    font-size: 18px;
    font-weight: 400;
    line-height: 1.25;
}

.map-viewer .geopage-note h2,
.map-viewer .geopage-note h3,
.map-viewer .geopage-note h4 {
    color: #553737;
}

.map-viewer .geopage-note h3 {
    margin: 20px 0 8px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.25;
}

.map-viewer .geopage-note > h2:first-child,
.map-viewer .geopage-note > h3:first-child,
.map-viewer .geopage-note > h4:first-child {
    margin-top: 0;
}

.map-viewer .geopage-note .markdown-help {
    background: #faf2ef;
    color: #1f2325;
}

.map-viewer-related {
    flex: 0 0 auto;
    overflow: visible;
    min-height: 0;
    margin: 0.75rem 0;
}

.map-viewer-full-wrap {
    flex: 0 0 auto;
    margin: 0.35rem 0 0;
    padding: 0.35rem 0 0.15rem;
}

.map-viewer-full-head,
.map-viewer-full-after-essay {
    display: none;
}

.map-viewer-full-after-video {
    display: inline-block;
    margin: 0.5rem 0 0.15rem;
}

.map-viewer-full-essay-wrap {
    display: none;
}

.map-viewer-error {
    margin: 0 0 0.75rem;
}

@media (prefers-reduced-motion: reduce) {
    .map-pin:hover:not(.is-current),
    .map-pin:focus-visible:not(.is-current),
    .map-pin.is-spatial:hover:not(.is-current),
    .map-pin.is-spatial:focus-visible:not(.is-current) {
        transform: none;
    }
}

@media (max-width: 640px), (max-width: 1024px) and (orientation: portrait), (max-width: 1024px) and (max-height: 640px) {
    .map-shell.is-viewer-wide .map-viewer.is-open,
    .map-shell.is-viewer-cinema .map-viewer.is-open {
        padding: 8px;
    }

    .map-viewer .map-viewer-title {
        margin: 0;
        font-family: var(--font-sans, system-ui, sans-serif);
        font-size: 16px;
        font-weight: 400;
        line-height: 1.3;
        color: #49443c;
    }

    .map-viewer-close {
        width: 20px;
        height: 20px;
        max-width: 20px;
        max-height: 20px;
        background: var(--map-handle-fill);
        border-radius: 3px;
        box-shadow: none;
    }

    .map-viewer-close:hover {
        background: var(--map-handle-fill);
    }

    .map-viewer-close > span {
        font-size: 22px;
    }

    .map-viewer .map-viewer-essay,
    .map-viewer .map-viewer-related {
        margin: 8px 0;
    }

    .map-viewer .map-viewer-essay:has(+ .map-viewer-note) {
        margin-bottom: 0;
    }

    .map-viewer .map-viewer-note {
        margin: 8px -8px;
        padding: 24px 8px;
    }

    .map-viewer .map-viewer-essay + .map-viewer-note {
        margin-top: 32px;
    }

    .map-viewer .youtube-embed,
    .map-viewer .youtube-player {
        width: 100%;
        max-width: 100%;
    }

    .map-viewer .youtube-embed {
        align-self: center;
        margin-left: auto;
        margin-right: auto;
    }

    .map-viewer .youtube-embed.is-playing iframe {
        z-index: 1;
    }

    .map-viewer-full-head,
    .map-viewer-full-after-essay {
        display: inline-block;
        z-index: 1;
    }

    .map-viewer-full-after-video {
        display: none;
    }

    .map-viewer-full-video-wrap {
        display: none;
    }

    .map-viewer-full-essay-wrap {
        display: block;
    }

    .map-viewer-close {
        align-self: start;
        position: relative;
        z-index: 1;
    }

    @media not (aspect-ratio > 1/1) {
        .map-viewer-head {
            display: grid;
            grid-template-columns: auto minmax(0, 1fr) auto;
            align-items: start;
        }

        .map-viewer-full-head {
            grid-column: 1;
            grid-row: 1;
        }

        .map-viewer-close {
            grid-column: 3;
            grid-row: 1;
        }

        .map-viewer-title {
            grid-column: 1 / -1;
            grid-row: 2;
        }
    }

    @media (aspect-ratio > 1/1) {
        .map-viewer-head {
            align-items: baseline;
            align-items: first baseline;
        }
    }
}

/* Single preview: CSS divides the available height between picture and actions. */
.map-sheet-preview-list.is-single {
    display: flex;
    flex-direction: column;
}
.map-sheet-preview-list.is-single .map-sheet-preview-card {
    flex: 1;
    min-height: 0;
}
.map-sheet-preview-list.is-single .map-sheet-preview-media {
    flex: 0 1 auto;
    min-height: 0;
    display: flex;
    justify-content: center;
}
.map-sheet-preview-list.is-single .map-sheet-preview-media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.map-sheet-preview-list.is-single .map-sheet-preview-copy {
    flex: 0 0 auto;
}

.map-viewer-opening {
    display: contents;
}
.map-viewer-media {
    flex: 0 0 auto;
    min-width: 0;
    width: 100%;
}
@media (max-width: 640px), (max-width: 1024px) and (orientation: portrait), (max-width: 1024px) and (max-height: 640px) {
  @media (aspect-ratio > 1/1) {
    .map-viewer-opening {
        display: flex;
        flex-direction: column;
        flex: 0 0 auto;
        height: calc(100dvh - 1rem - 18px);
        min-height: 240px;
    }
    .map-viewer-media {
        container-type: size;
        flex: 1 1 0;
        min-height: 200px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .map-viewer-media .youtube-embed {
        flex: 0 0 auto;
        margin: 0;
    }
    .map-viewer-media .youtube-player {
        width: 100%;
        height: 100%;
        aspect-ratio: auto;
    }
  }
}

.map-sheet-preview-actions,
.share-preview-landscape,
.viewer-share-frame > .share-tools { display: none; }
.map-sheet-preview-actions > .place-action::after {
    top: 0;
    height: 100%;
    margin-top: 0;
}

@media (max-width: 640px), (max-width: 1024px) and (orientation: portrait), (max-width: 1024px) and (max-height: 640px) {
    .map-sheet-desktop-share { display: none; }
    .viewer-share-frame > .share-tools { display: flex; justify-content: flex-end; }
    body.has-page-map .map-sheet-preview-actions {
        display: grid;
        grid-template-columns: minmax(0, 1fr) max-content minmax(0, 1fr);
        align-items: stretch;
        gap: 6px;
        width: 100%;
        margin: 6px 0 0;
    }
    .map-sheet-preview-actions > * { min-width: 0; }
    @media (aspect-ratio > 1/1) {
        body.has-page-map .map-sheet-preview-actions {
            display: flex;
            gap: 8px;
            margin-top: 0;
        }
        .map-sheet-preview-actions > .share-preview-middle { display: none; }
        .share-preview-landscape { display: flex; }
    }
    @media not (aspect-ratio > 1/1) {
        .map-sheet-preview-actions > .map-sheet-preview-open,
        .map-sheet-preview-actions > .map-sheet-preview-page,
        .map-sheet-preview-actions > .map-sheet-preview-open .place-action-label,
        .map-sheet-preview-actions > .map-sheet-preview-page .place-action-label {
            white-space: normal;
            overflow-wrap: anywhere;
        }
        .share-preview-landscape { display: none; }
    }
    .viewer-share-frame { min-width: 0; max-width: 100%; }
    @media (aspect-ratio > 1/1) {
        .map-viewer-media { container-type: size; }
        .viewer-share-frame {
            --share-rail: 110px;
            --share-gap: 10px;
            --share-below: 36px;
            width: min(100cqw, calc((100cqh - var(--share-below)) * 16 / 9));
            display: flex;
            flex-direction: column;
            margin: 0 auto;
        }
        .viewer-share-frame > .youtube-embed {
            width: 100%;
            height: auto;
            aspect-ratio: 16 / 9;
            min-width: 0;
            min-height: 0;
            margin: 0;
        }
        .viewer-share-frame .youtube-player {
            width: 100%;
            height: 100%;
            min-width: 0;
            min-height: 0;
        }
        @container (min-width: 560px) and (min-aspect-ratio: 23/10) {
            .viewer-share-frame {
                width: min(100cqw, calc(100cqh * 16 / 9 + var(--share-rail) + var(--share-gap)));
                display: grid;
                grid-template-columns: minmax(0, 1fr) var(--share-rail);
                gap: var(--share-gap);
                align-items: start;
            }
            .viewer-share-frame > .share-tools {
                flex-direction: column;
                align-items: stretch;
                gap: 5px;
                margin: 0;
            }
            .viewer-share-frame > .share-tools .share-button { white-space: normal; }
        }
    }
}
