body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-sans);
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

#map {
    height: calc(100vh - var(--header-h));
    width: 100%;
}

.maplibregl-popup {
    z-index: 1;
}

.map-tooltip .maplibregl-popup-content {
    padding: var(--s-2) var(--s-3);
    border-radius: var(--radius-s);
    box-shadow: 0 1px 3px rgba(21, 25, 26, 0.3);
    color: var(--ink);
    white-space: nowrap;
    font-family: var(--font-sans);
    font-size: var(--fs-ui);
    line-height: 1.45;
    font-variant-numeric: tabular-nums;
}

.photo-preview {
    position: fixed;
    z-index: 1100;
    display: none;
    border-radius: var(--radius-m);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.55);
    pointer-events: none;
}

.image-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 12, 12, 0.94);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    cursor: pointer;
}

.image-overlay:focus {
    outline: none;
}

.image-overlay img {
    max-width: 80%;
    max-height: 70%;
    object-fit: contain;
    cursor: default;
}

.image-caption {
    font-family: var(--font-serif);
    color: var(--on-photo);
    font-size: 1.25rem;
    line-height: 1.45;
    margin-top: var(--s-5);
    text-align: center;
    max-width: min(80%, 40rem);
    cursor: default;
}

.image-day {
    display: block;
    margin-bottom: var(--s-2);
    font-family: var(--font-sans);
    font-size: var(--fs-label);
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.72);
}

.overlay-button {
    position: absolute;
    z-index: 10001;
    width: 48px;
    height: 48px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.overlay-button[hidden] {
    display: none;
}

.overlay-button:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.overlay-button:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

.overlay-button .material-symbols-outlined {
    font-size: 32px;
}

.nav-arrow {
    top: 50%;
    transform: translateY(-50%);
}

.nav-arrow.left {
    left: 22px;
}

.nav-arrow.right {
    right: 22px;
}

.close-button {
    top: 20px;
    right: 20px;
}

.close-button .material-symbols-outlined {
    font-size: 28px;
}

.map-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: var(--surface);
    padding: var(--s-3) var(--s-4);
    border-radius: var(--radius-m);
    box-shadow: var(--shadow-book);
    font-family: var(--font-sans);
    font-size: var(--fs-small);
    font-weight: 500;
    color: var(--ink);
    z-index: 1000;
}

.legend-item {
    display: flex;
    align-items: center;
    min-height: 36px;
    cursor: pointer;
    user-select: none;
}

.legend-item input {
    width: 16px;
    height: 16px;
    margin: 0 var(--s-3) 0 0;
    accent-color: var(--accent);
}

.legend-item input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.legend-lines {
    display: inline-flex;
    gap: 4px;
    margin-right: var(--s-2);
}

.legend-lines span {
    width: 12px;
    height: 3px;
    border-radius: 2px;
    background: #6b1f9a;
}

.legend-lines span + span {
    background: #1570b8;
}

.legend-icon {
    margin-right: var(--s-2);
    width: 24px;
    height: 24px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.legend-icon .material-symbols-outlined {
    font-size: 15px;
}

.legend-icon + .legend-icon {
    margin-left: -4px;
}

.material-icon-marker {
    cursor: pointer;
}

.endpoint-marker {
    cursor: default;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.endpoint-marker::after {
    content: '';
    margin-top: -1px;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid #fff;
}

.photo-marker {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-pin {
    box-sizing: border-box;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
}

.map-pin .material-symbols-outlined {
    font-size: 18px;
    font-variation-settings: 'FILL' 1, 'wght' 600;
}

.endpoint-marker .map-pin {
    width: 34px;
    height: 34px;
    box-shadow: none;
}

.endpoint-marker .map-pin .material-symbols-outlined {
    font-size: 22px;
}

.map-pin-camp {
    background-color: #c8a96e;
}

.map-pin-photo {
    background-color: #6b1f9a;
}

.map-pin-start {
    background-color: #2e8b57;
}

.map-pin-end {
    background-color: #d02020;
}

@media (hover: hover) {
    .photo-marker:hover .map-pin {
        transform: scale(1.15);
    }
}

.marker-cluster {
    box-sizing: border-box;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
    background-color: #6b1f9a;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}

.marker-cluster-small {
    width: 32px;
    height: 32px;
}

.marker-cluster-medium {
    width: 38px;
    height: 38px;
    font-size: 14px;
}

.marker-cluster-large {
    width: 44px;
    height: 44px;
    font-size: 15px;
}

.legend-text-short {
    display: none;
}

.day-card {
    display: none;
}

@media (max-width: 640px), (max-height: 500px) {
    #map {
        height: calc(100vh - var(--header-h));
        height: calc(100dvh - var(--header-h));
    }

    .map-legend {
        left: 12px;
        right: 12px;
        bottom: 28px;
        padding: 0;
        background: none;
        box-shadow: none;
        border-radius: 0;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: var(--s-2);
        font-size: var(--fs-small);
        pointer-events: none;
    }

    .legend-item {
        position: relative;
        margin: 0;
        height: 40px;
        min-height: 0;
        padding: 0 14px;
        border-radius: var(--radius-pill);
        background: var(--surface);
        box-shadow: 0 1px 4px rgba(21, 25, 26, 0.25);
        pointer-events: auto;
        -webkit-tap-highlight-color: transparent;
    }

    .legend-item input {
        position: absolute;
        opacity: 0;
        width: 1px;
        height: 1px;
        margin: 0;
    }

    .legend-item:has(input:not(:checked)) > * {
        opacity: 0.4;
    }

    .legend-item:has(input:not(:checked)) .legend-text-short {
        text-decoration: line-through;
    }

    .legend-item:has(input:focus-visible) {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }

    .legend-icon {
        width: 22px;
        height: 22px;
        margin-right: 6px;
    }

    .legend-icon .material-symbols-outlined {
        font-size: 14px;
    }

    .legend-text {
        display: none;
    }

    .legend-text-short {
        display: inline;
    }

    .maplibregl-ctrl-bottom-right .maplibregl-ctrl-group {
        display: none;
    }

    .map-tooltip .maplibregl-popup-content {
        font-size: var(--fs-small);
        padding: var(--s-1) var(--s-2);
    }

    .day-card {
        display: block;
        position: fixed;
        left: 8px;
        right: 8px;
        bottom: 8px;
        max-width: 520px;
        margin: 0 auto;
        padding: var(--s-3) var(--s-3) var(--s-4);
        background: var(--surface);
        border-radius: 16px;
        box-shadow: 0 2px 14px rgba(21, 25, 26, 0.28);
        font-family: var(--font-sans);
        color: var(--ink);
        z-index: 1001;
        transform: translateY(calc(100% + 16px));
        transition: transform 0.25s var(--ease);
    }

    .day-card.open {
        transform: none;
    }

    .day-card-header {
        display: flex;
        align-items: center;
        gap: var(--s-2);
        padding-right: 52px;
    }

    .day-card-title {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        line-height: 1.3;
    }

    .day-card-title strong {
        font-family: var(--font-serif);
        font-size: 1.375rem;
        font-weight: 500;
    }

    .day-card-title span {
        font-size: 0.875rem;
        color: var(--ink-3);
    }

    .day-card-button {
        width: 44px;
        height: 44px;
        flex: none;
        border: none;
        border-radius: 50%;
        background: var(--paper-2);
        color: var(--ink);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .day-card-button:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }

    .day-card-button:disabled {
        opacity: 0.3;
        cursor: default;
    }

    .day-card-close {
        position: absolute;
        top: var(--s-3);
        right: var(--s-3);
        background: none;
    }

    .day-card-route {
        margin: var(--s-3) 0;
        text-align: center;
        font-family: var(--font-serif);
        font-size: 1.0625rem;
    }

    .day-card-stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--s-3) var(--s-4);
        margin: 0;
        padding-top: var(--s-3);
        border-top: 1px solid var(--line);
    }

    .day-card-stats div {
        text-align: center;
    }

    .day-card-stats dt {
        font-size: var(--fs-label);
        font-weight: 500;
        letter-spacing: var(--tracking-caps);
        text-transform: uppercase;
        color: var(--ink-3);
    }

    .day-card-stats dd {
        margin: 2px 0 0;
        font-size: 1.0625rem;
        font-weight: 500;
        font-variant-numeric: tabular-nums;
    }

    .image-overlay img {
        max-width: 100%;
        max-height: 70%;
    }

    .image-caption {
        font-size: 1.0625rem;
        padding: 0 var(--s-4);
        max-width: none;
    }

    .nav-arrow.left {
        left: 8px;
    }

    .nav-arrow.right {
        right: 8px;
    }

    .close-button {
        top: 12px;
        right: 12px;
    }
}

@media (max-width: 640px) {
    .map-legend {
        display: grid;
        grid-template-columns: 1fr 1fr;
        max-width: 360px;
        margin: 0 auto;
    }

    .legend-item {
        justify-content: center;
    }
}

@media (max-height: 500px) {
    .day-card-stats {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    .day-card,
    .map-pin,
    .overlay-button {
        transition: none;
    }
}
