.maps-list {
    display: grid;
    gap: 18px;
}

.map-card {
    overflow: hidden;
    border: 1px solid var(--rule);
    border-radius: 4px;
    background: rgba(255,255,255,0.44);
}

.map-card-title {
    padding: 11px 14px 9px;
    border-bottom: 1px solid var(--rule);
    color: var(--ink-soft);
    font-family: var(--ui);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.map-box {
    width: 100%;
    height: 290px;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(30px, env(safe-area-inset-top)) 78px max(30px, env(safe-area-inset-bottom));
    overflow: auto;
    background: rgba(3,4,9,0.92);
    backdrop-filter: blur(22px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 220ms ease, visibility 220ms ease;
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.lightbox-figure {
    max-width: min(1100px, 88vw);
    display: grid;
    justify-items: center;
    gap: 15px;
    margin: auto;
}

.lightbox img {
    max-width: 100%;
    max-height: calc(100dvh - 130px);
    border-radius: 3px;
    box-shadow: 0 25px 90px rgba(0,0,0,0.52);
}

.lightbox-caption {
    color: rgba(244,241,234,0.72);
    font-size: 0.88rem;
    text-align: center;
}

.lightbox-close,
.lightbox-nav {
    position: fixed;
    z-index: 2;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 50%;
    background: rgba(7,9,16,0.35);
    color: rgba(255,255,255,0.72);
    cursor: pointer;
    transition: color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.lightbox-close:hover,
.lightbox-nav:hover {
    color: #fff;
    border-color: rgba(255,255,255,0.5);
}

.lightbox-close {
    top: max(20px, env(safe-area-inset-top));
    right: max(24px, env(safe-area-inset-right));
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
}

.lightbox-nav {
    top: 50%;
    width: 46px;
    height: 46px;
    font-family: var(--ui);
    font-size: 1.2rem;
    transform: translateY(-50%);
}

.lightbox-nav:hover {
    transform: translateY(-50%) scale(1.04);
}

.lightbox-prev { left: 23px; }
.lightbox-next { right: 23px; }

.transition-veil {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at center, rgba(255,242,211,0.22), rgba(184,205,245,0.08) 18%, rgba(6,9,20,0.12) 43%, transparent 72%);
    color: rgba(255,248,231,0.82);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 360ms ease, visibility 360ms ease;
}

.transition-veil.is-active {
    opacity: 1;
    visibility: visible;
}

.transition-veil span {
    position: absolute;
    bottom: max(34px, env(safe-area-inset-bottom));
    font-family: var(--mono);
    font-size: 0.66rem;
    letter-spacing: 0.12em;
    text-shadow: 0 0 24px rgba(213,225,255,0.55);
}

@media (max-width: 768px) {
    .homepage-parity .project-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) and (min-aspect-ratio: 16/9) {
    .portal-panel {
        width: clamp(286px, 42vw, 340px);
    }

    .celestial-panel {
        width: clamp(286px, 40vw, 330px);
    }
}

@media (max-aspect-ratio: 3/2),
       (max-width: 1024px) and (max-aspect-ratio: 16/9) {
    .portal-panel,
    .portal-panel.is-left,
    .celestial-panel,
    .celestial-panel.is-left {
        top: auto;
        left: max(10px, env(safe-area-inset-left));
        right: max(10px, env(safe-area-inset-right));
        bottom: max(10px, env(safe-area-inset-bottom));
        width: auto;
        max-height: 50dvh;
        transform: translateY(28px) scale(0.99);
        transform-origin: bottom center;
    }

    body.panel-open .portal-panel {
        transform: translateY(0) scale(1);
    }

    body.celestial-open .celestial-panel {
        transform: translateY(0) scale(1);
    }

    .portal-panel-header,
    .celestial-panel-header {
        padding: 18px 62px 14px 20px;
    }

    .portal-panel-body,
    .celestial-panel-body {
        padding: 18px 20px 28px;
    }

    body.route-preview-active .portal-panel,
    body.route-preview-active .portal-panel.is-left {
        width: auto;
        max-height: 44dvh;
    }

    body.route-preview-active .portal-panel-body {
        padding: 14px;
    }
}

@media (max-height: 520px) and (min-aspect-ratio: 3/2) {
    .portal-panel,
    .celestial-panel {
        top: max(78px, calc(env(safe-area-inset-top) + 64px));
        left: auto;
        right: max(18px, env(safe-area-inset-right));
        bottom: max(18px, env(safe-area-inset-bottom));
        max-height: none;
        transform: translateX(34px) scale(0.985);
        transform-origin: right center;
    }

    .portal-panel {
        width: clamp(180px, 34vw, 280px);
    }

    .celestial-panel {
        width: clamp(176px, 33vw, 270px);
    }

    .portal-panel.is-left,
    .celestial-panel.is-left {
        right: auto;
        left: max(18px, env(safe-area-inset-left));
        transform-origin: left center;
    }

    body.panel-open .portal-panel,
    body.celestial-open .celestial-panel {
        transform: translateX(0) scale(1);
    }
}

@media (max-width: 1024px), (max-aspect-ratio: 3/2) {
    body.route-preview-active .portal-panel,
    body.route-preview-active .portal-panel.is-left {
        top: auto;
        left: max(10px, env(safe-area-inset-left));
        right: max(10px, env(safe-area-inset-right));
        bottom: max(10px, env(safe-area-inset-bottom));
        width: auto;
        max-height: min(44dvh, 188px);
        transform: translateY(28px) scale(0.99);
        transform-origin: bottom center;
    }

    body.route-preview-active.panel-open .portal-panel {
        transform: translateY(0) scale(1);
    }

    body.route-preview-active .portal-panel-body {
        padding: 14px;
    }

    body.route-preview-active .portal-panel-header,
    body.route-preview-active .home-route-summary {
        display: none;
    }

    body.route-preview-active .home-route-preview {
        padding: 14px;
    }

    body.route-preview-active .home-route-actions {
        grid-template-columns: minmax(0, 1fr) auto;
        margin-top: 10px;
    }
}

@media (max-width: 1024px) and (max-height: 520px) {
    body.route-preview-active .portal-panel,
    body.route-preview-active .portal-panel.is-left {
        max-height: 36dvh;
    }

    body.route-preview-active .portal-panel-header,
    body.route-preview-active .home-route-summary {
        display: none;
    }

    body.route-preview-active .home-route-preview {
        padding: 12px;
    }

    body.route-preview-active .home-route-actions {
        grid-template-columns: minmax(0, 1fr) auto;
        margin-top: 9px;
    }
}

@media (max-width: 760px) {
    .section-drawer-toggle {
        width: 44px;
        height: 68px;
    }

    body.section-drawer-open .section-drawer-toggle {
        transform: translate(min(86vw, calc(100vw - 24px)), -50%);
    }

    .section-drawer {
        width: min(86vw, calc(100vw - 24px));
    }

    .section-drawer-header {
        padding: 22px 66px 16px 20px;
    }

    .section-index-item,
    .section-index-home {
        min-height: 58px;
        padding-inline: 9px;
    }

    .section-index-visibility {
        min-width: 64px;
    }

    .life-mark {
        top: max(17px, env(safe-area-inset-top));
        left: max(17px, env(safe-area-inset-left));
    }

    .language-switch {
        top: max(15px, env(safe-area-inset-top));
        right: max(15px, env(safe-area-inset-right));
    }

    .control-legend {
        display: none;
    }

    .scene-status {
        right: auto;
        left: max(17px, env(safe-area-inset-left));
        bottom: max(15px, env(safe-area-inset-bottom));
    }

    .star-hit {
        width: 76px;
        height: 76px;
    }

    .star-hit-copy {
        max-width: 42vw;
    }

    .portal-close {
        top: 15px;
        right: 17px;
    }

    .gallery-grid,
    .friends-list {
        grid-template-columns: 1fr;
    }

    .home-route-actions {
        grid-template-columns: 1fr;
    }

    .about-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .about-portrait {
        width: 120px;
    }

    .about-links {
        justify-content: center;
    }

    .project-grid {
        grid-template-columns: 1fr;
    }

    .map-box {
        height: 250px;
    }

    .lightbox {
        padding: 70px 16px 92px;
    }

    .lightbox img {
        max-height: calc(100dvh - 190px);
    }

    .lightbox-nav {
        top: auto;
        bottom: max(23px, env(safe-area-inset-bottom));
        transform: none;
    }

    .lightbox-nav:hover {
        transform: scale(1.04);
    }

    .lightbox-prev { left: calc(50% - 58px); }
    .lightbox-next { right: calc(50% - 58px); }
}

@media (hover: none), (pointer: coarse) {
    .portal-hit {
        width: 88px;
        height: 88px;
    }

    .celestial-hit {
        width: 94px;
        height: 94px;
    }

    .gaze-instruction {
        display: none;
    }

    .gallery-caption {
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
