:root {
    --mm-blue: #0076c0;
    --mm-blue-dark: #005a91;
    --mm-ink: #172433;
    --mm-muted: #5f6b78;
    --mm-surface: rgba(255, 255, 255, 0.94);
    --mm-line: rgba(23, 36, 51, 0.12);
    --mm-shadow: 0 12px 36px rgba(14, 32, 51, 0.16);
    --mm-radius: 16px;
}

* { box-sizing: border-box; }

html, body, #map {
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
}

body {
    overflow: hidden;
    color: var(--mm-ink);
    font-family: "Roboto", Arial, sans-serif;
}

button { font: inherit; }

.map-header {
    position: fixed;
    z-index: 1000;
    top: 16px;
    left: 16px;
    display: flex;
    align-items: center;
    width: min(480px, calc(100vw - 32px));
    min-height: 92px;
    padding: 12px 14px 12px 12px;
    border: 1px solid rgba(255,255,255,.7);
    border-radius: var(--mm-radius);
    background: var(--mm-surface);
    box-shadow: var(--mm-shadow);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.map-header__logo {
    width: 66px;
    height: 66px;
    margin-right: 14px;
    flex: 0 0 auto;
    filter: drop-shadow(0 4px 8px rgba(14,32,51,.16));
}
.map-header__text { min-width: 0; flex: 1; }
.map-header h1 {
    margin: 1px 0 0;
    font-family: "Roboto", Arial, sans-serif;
    font-size: 27px;
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -.025em;
}
.map-header p { margin: 0; }
.map-header__eyebrow {
    color: var(--mm-blue-dark);
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: .13em;
}
.map-header__subtitle { margin-top: 5px !important; color: var(--mm-muted); font-size: 12px; line-height: 1.3; }
.language-nav {
    display: flex;
    align-items: center;
    gap: 3px;
    margin: 0 8px;
    padding: 3px;
    border-radius: 9px;
    background: rgba(23,36,51,.06);
}
.language-link {
    display: grid;
    place-items: center;
    min-width: 29px;
    height: 27px;
    padding: 0 5px;
    border-radius: 7px;
    color: #536170;
    font-size: 10px;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: .04em;
}
.language-link:hover { color: var(--mm-blue-dark); background: rgba(255,255,255,.75); }
.language-link[aria-current="page"] { color: #fff; background: var(--mm-blue); box-shadow: 0 2px 6px rgba(0,90,145,.2); }

.icon-button,
.panel-close {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border: 0;
    border-radius: 50%;
    color: var(--mm-ink);
    background: rgba(0,118,192,.09);
    cursor: pointer;
    transition: background .18s ease, transform .18s ease;
}
.icon-button:hover, .panel-close:hover { background: rgba(0,118,192,.17); transform: translateY(-1px); }
.icon-button:focus-visible, .panel-close:focus-visible, .modal-button:focus-visible, .credits-button:focus-visible { outline: 3px solid rgba(0,118,192,.35); outline-offset: 2px; }

.leaflet-top.leaflet-left { top: 252px; left: 6px; }
.leaflet-bar { border: 0 !important; border-radius: 12px !important; box-shadow: 0 7px 22px rgba(14,32,51,.14) !important; overflow: hidden; }
.leaflet-bar a { width: 36px !important; height: 36px !important; line-height: 36px !important; color: var(--mm-ink) !important; border-color: var(--mm-line) !important; }
.leaflet-bar a:hover { background: #f3f8fb !important; }

.filter-panel {
    position: fixed;
    z-index: 950;
    top: 148px;
    left: 16px;
    width: min(650px, calc(100vw - 32px));
    padding: 11px 12px 12px;
    border: 1px solid rgba(255,255,255,.7);
    border-radius: 14px;
    background: var(--mm-surface);
    box-shadow: 0 8px 24px rgba(14,32,51,.13);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.filter-panel__heading { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.filter-panel__heading::before { content: "⠿"; color: #8a98a6; font-size: 15px; line-height: 1; }
.filter-panel__heading strong { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.filter-panel__heading span { margin-left: auto; color: var(--mm-muted); font-size: 11px; font-weight: 500; }
.filter-panel.is-dragging { box-shadow: 0 16px 38px rgba(14,32,51,.22); }
.filter-fields { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.25fr) minmax(92px,.55fr) auto; align-items: end; gap: 8px; }
.filter-fields label { display: grid; gap: 4px; color: #526171; font-size: 10px; font-weight: 700; }
.filter-fields select {
    width: 100%;
    height: 36px;
    padding: 0 30px 0 10px;
    border: 1px solid rgba(23,36,51,.16);
    border-radius: 9px;
    color: var(--mm-ink);
    background: #fff;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
}
.filter-fields select:focus { outline: 3px solid rgba(0,118,192,.2); border-color: var(--mm-blue); }
.filter-reset {
    height: 36px;
    padding: 0 12px;
    border: 0;
    border-radius: 9px;
    color: var(--mm-blue-dark);
    background: rgba(0,118,192,.1);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}
.filter-reset:hover:not(:disabled) { background: rgba(0,118,192,.18); }
.filter-reset:disabled { color: #8c98a3; background: rgba(23,36,51,.05); cursor: default; }

.map-legend {
    position: fixed;
    z-index: 900;
    left: 16px;
    bottom: 48px;
    width: 188px;
    padding: 12px 14px;
    border: 1px solid rgba(255,255,255,.7);
    border-radius: 13px;
    background: var(--mm-surface);
    box-shadow: 0 8px 24px rgba(14,32,51,.13);
    backdrop-filter: blur(12px);
}
.map-legend h2 { margin: 0 0 9px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.legend-row { display: flex; align-items: center; gap: 10px; margin: 7px 0; color: #344252; font-size: 12px; }
.legend-logo { width: 20px; height: 20px; flex: 0 0 auto; filter: drop-shadow(0 1px 3px rgba(0,0,0,.2)); }
.legend-route { width: 31px; height: 4px; border-radius: 4px; background: repeating-linear-gradient(90deg, var(--mm-blue) 0 9px, transparent 9px 14px); filter: drop-shadow(0 0 1px white); }

.credits-button {
    position: fixed;
    z-index: 900;
    left: 16px;
    bottom: 13px;
    padding: 7px 11px;
    border: 1px solid rgba(255,255,255,.75);
    border-radius: 9px;
    color: #344252;
    background: var(--mm-surface);
    box-shadow: 0 5px 15px rgba(14,32,51,.1);
    cursor: pointer;
    font-size: 11px;
}

.site-panel {
    position: fixed;
    z-index: 1100;
    top: 16px;
    right: 16px;
    bottom: 16px;
    width: min(440px, calc(100vw - 32px));
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.8);
    border-radius: 20px;
    background: #fff;
    box-shadow: -8px 16px 44px rgba(14,32,51,.2);
    transform: translateX(calc(100% + 40px));
    visibility: hidden;
    transition: transform .28s cubic-bezier(.22,.8,.25,1), visibility 0s linear .28s;
}
.site-panel.is-open { transform: translateX(0); visibility: visible; transition-delay: 0s; }
.site-panel__bar { position: absolute; z-index: 2; top: 12px; right: 12px; }
.site-panel__bar .panel-close {
    color: #fff;
    background: rgba(255,255,255,.18);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.28);
    backdrop-filter: blur(8px);
}
.site-panel__bar .panel-close:hover { background: rgba(255,255,255,.3); }
.site-panel__content { height: 100%; overflow-y: auto; padding: 26px 28px 40px; scrollbar-color: #a8b4bf transparent; scrollbar-width: thin; }
.site-panel__content h1, .site-panel__content h2, .site-panel__content h3 { color: var(--mm-ink); line-height: 1.2; letter-spacing: -.02em; }
.site-panel__content h1 { margin: 0 48px 16px 0; font-size: 26px; }
.site-panel__content h2 { margin: 24px 0 10px; font-size: 18px; }
.site-panel__content h3 { margin: 20px 0 8px; font-size: 15px; }
.site-panel__content p, .site-panel__content li { font-size: 15px; line-height: 1.62; }
.site-panel__content p { margin: 0 0 14px; }
.site-panel__content section { margin-top: 22px; }
.site-panel__content section h3 {
    margin: 0 0 9px;
    padding-bottom: 7px;
    border-bottom: 1px solid var(--mm-line);
    color: #25455f;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: .045em;
}
.site-facts {
    margin: 18px 0 22px;
    padding: 14px 16px 1px;
    border: 1px solid #dce8ef;
    border-radius: 11px;
    background: #f7fafc;
}
.site-notes {
    padding: 13px 15px 1px;
    border-left: 3px solid #9ebdce;
    color: #526171;
    background: #f5f8fa;
}
.site-notes p { font-size: 13px; }
.site-nominator { margin-top: 23px !important; padding-top: 14px; border-top: 1px solid var(--mm-line); }
.image-gallery { margin-top: 20px !important; }
.image-gallery__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 8px;
}
.image-gallery__thumb {
    position: relative;
    aspect-ratio: 4 / 3;
    min-width: 0;
    overflow: hidden;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: #e7eef3;
    box-shadow: 0 2px 8px rgba(14,32,51,.12);
    cursor: zoom-in;
}
.site-panel__content .image-gallery__thumb img {
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    border-radius: 0;
    object-fit: cover;
    box-shadow: none;
    transition: transform .2s ease, filter .2s ease;
}
.image-gallery__thumb::after {
    content: "↗";
    position: absolute;
    right: 5px;
    bottom: 5px;
    display: grid;
    width: 22px;
    height: 22px;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: rgba(0,38,64,.7);
    font-size: 11px;
    opacity: 0;
    transition: opacity .2s ease;
}
.image-gallery__thumb:hover img { transform: scale(1.045); filter: brightness(.9); }
.image-gallery__thumb:hover::after, .image-gallery__thumb:focus-visible::after { opacity: 1; }
.image-gallery__thumb:focus-visible { outline: 3px solid rgba(0,118,192,.45); outline-offset: 2px; }

.gallery-lightbox {
    position: fixed;
    z-index: 4000;
    inset: 0;
    display: grid;
    visibility: hidden;
    place-items: center;
    padding: 24px;
    background: rgba(5,15,24,.88);
    opacity: 0;
    transition: opacity .2s ease, visibility 0s linear .2s;
}
.gallery-lightbox.is-open { visibility: visible; opacity: 1; transition-delay: 0s; }
.gallery-lightbox__dialog {
    position: relative;
    display: grid;
    width: min(1120px, 100%);
    height: min(820px, calc(100vh - 48px));
    grid-template-columns: 54px minmax(0, 1fr) 54px;
    align-items: center;
}
.gallery-lightbox figure { display: grid; min-width: 0; max-height: 100%; margin: 0; grid-column: 2; place-items: center; }
.gallery-lightbox__image {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 105px);
    border-radius: 8px;
    background: #152533;
    box-shadow: 0 18px 55px rgba(0,0,0,.45);
    object-fit: contain;
}
.gallery-lightbox__counter { margin-top: 10px; color: rgba(255,255,255,.85); font-size: 12px; font-weight: 500; }
.gallery-lightbox button {
    display: grid;
    width: 44px;
    height: 44px;
    padding: 0;
    place-items: center;
    border: 1px solid rgba(255,255,255,.28);
    border-radius: 50%;
    color: #fff;
    background: rgba(255,255,255,.12);
    cursor: pointer;
    font-family: Arial, sans-serif;
}
.gallery-lightbox button:hover { background: rgba(255,255,255,.24); }
.gallery-lightbox button:focus-visible { outline: 3px solid rgba(72,184,255,.75); outline-offset: 3px; }
.gallery-lightbox__previous, .gallery-lightbox__next { font-size: 38px; line-height: 1; }
.gallery-lightbox__previous { grid-column: 1; }
.gallery-lightbox__next { grid-column: 3; }
.gallery-lightbox__next { justify-self: end; }
.gallery-lightbox__close { position: absolute; z-index: 1; top: 0; right: 0; font-size: 27px; }
.gallery-lightbox button[hidden] { display: none; }
.site-panel__content #rheader {
    position: relative;
    margin: -26px -28px 24px;
    padding: 45px 72px 25px 28px;
    overflow: hidden;
    color: #fff;
    background: linear-gradient(135deg, #005a91 0%, #0076c0 72%, #1b91d8 100%);
    font-family: "Roboto", Arial, sans-serif;
    font-size: 27px;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -.02em;
}
.site-panel__content #rheader::before {
    content: "Memory site";
    position: absolute;
    top: 22px;
    left: 28px;
    font-family: "Roboto", sans-serif;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: .15em;
    opacity: .82;
}
html[lang="es"] .site-panel__content #rheader::before { content: "Sitio de memoria"; }
html[lang="pt"] .site-panel__content #rheader::before { content: "Local de memória"; }
.site-panel__content p > strong:first-child {
    color: #26394b;
    font-weight: 700;
}
.site-panel__content ul, .site-panel__content ol { padding-left: 22px; }
.site-panel__content li::marker { color: var(--mm-blue); }
.site-panel__content a { color: var(--mm-blue-dark); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.site-panel__content img { display: block; max-width: 100% !important; height: auto !important; margin: 18px auto; border-radius: 11px; box-shadow: 0 6px 20px rgba(14,32,51,.13); }
.site-panel__content hr { margin: 24px 0; border: 0; border-top: 1px solid var(--mm-line); }

.leaflet-marker-icon { transition: filter .16s ease, transform .16s ease; transform-origin: bottom center; }
.leaflet-marker-icon:hover { z-index: 1000 !important; filter: drop-shadow(0 5px 7px rgba(0,68,112,.35)); transform: scale(1.08); }
.leaflet-marker-icon.is-selected { z-index: 1000 !important; filter: drop-shadow(0 0 7px rgba(0,118,192,.9)); transform: scale(1.1); }

.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background: rgba(0,118,192,.22) !important; }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div { color: white !important; background: var(--mm-blue) !important; font-weight: 700 !important; box-shadow: inset 0 0 0 2px rgba(255,255,255,.7); }

.modal-backdrop {
    position: fixed;
    z-index: 2000;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(11,24,38,.52);
    backdrop-filter: blur(5px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility 0s linear .2s;
}
.modal-backdrop.is-open { opacity: 1; visibility: visible; transition-delay: 0s; }
.modal-card { width: min(560px, 100%); max-height: min(720px, calc(100vh - 40px)); overflow-y: auto; padding: 32px; border-radius: 20px; background: #fff; box-shadow: var(--mm-shadow); }
.modal-logo { float: right; width: 76px; height: 76px; margin: -5px 0 10px 20px; filter: drop-shadow(0 5px 10px rgba(14,32,51,.15)); }
.modal-card__eyebrow { margin: 0 0 8px; color: var(--mm-blue-dark); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .12em; }
.modal-card h2 { margin: 0 0 13px; font-size: 30px; letter-spacing: -.03em; }
.modal-card p { color: #435161; font-size: 15px; line-height: 1.6; }
.modal-button { margin-top: 12px; padding: 11px 18px; border: 0; border-radius: 10px; color: #fff; background: var(--mm-blue); cursor: pointer; font-weight: 700; }
.modal-button:hover { background: var(--mm-blue-dark); }
.credits-copy { padding-top: 16px; border-top: 1px solid var(--mm-line); font-size: 12px !important; }
.disclaimer {
    margin: 20px 0 !important;
    padding: 14px 16px;
    border-left: 4px solid var(--mm-blue);
    border-radius: 0 9px 9px 0;
    color: #405064 !important;
    background: #f1f6f9;
    font-size: 13px !important;
    line-height: 1.5 !important;
}

.leaflet-control-attribution { max-width: 55vw; color: #52606d; background: rgba(255,255,255,.78) !important; font-size: 9px !important; }

@media (max-width: 700px) {
    .map-header { top: 10px; left: 10px; width: calc(100vw - 20px); min-height: 66px; padding: 11px 11px 11px 15px; }
    .map-header__logo { width: 48px; height: 48px; margin-right: 10px; }
    .map-header h1 { font-size: 21px; }
    .map-header__eyebrow { font-size: 8px; }
    .map-header__subtitle { font-size: 10.5px; }
    .language-nav { margin: 0 4px; gap: 1px; }
    .language-link { min-width: 25px; height: 25px; padding: 0 3px; font-size: 9px; }
    .filter-panel { top: 114px; left: 10px; width: calc(100vw - 20px); }
    .filter-panel__heading::before { display: none; }
    .filter-fields { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
    .filter-reset { height: 36px; }
    .leaflet-top.leaflet-left { top: 282px; left: 0; }
    .map-legend { left: 10px; bottom: 43px; width: 162px; padding: 10px 12px; }
    .credits-button { left: 10px; bottom: 9px; }
    .site-panel { top: auto; right: 8px; bottom: 8px; left: 8px; width: auto; height: min(70vh, 620px); border-radius: 20px 20px 14px 14px; transform: translateY(calc(100% + 30px)); }
    .site-panel.is-open { transform: translateY(0); }
    .site-panel::before { content: ""; position: absolute; z-index: 3; top: 8px; left: 50%; width: 42px; height: 4px; border-radius: 4px; background: #c8d0d8; transform: translateX(-50%); }
    .site-panel__content { padding: 32px 20px 34px; }
    .site-panel__content h1 { font-size: 23px; }
    .site-panel__content #rheader { margin: -32px -20px 22px; padding: 44px 58px 23px 20px; font-size: 24px; }
    .site-panel__content #rheader::before { left: 20px; }
    .image-gallery__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .gallery-lightbox { padding: 12px; }
    .gallery-lightbox__dialog { height: calc(100vh - 24px); grid-template-columns: 42px minmax(0, 1fr) 42px; }
    .gallery-lightbox button { width: 36px; height: 36px; }
    .gallery-lightbox__previous, .gallery-lightbox__next { font-size: 31px; }
    .gallery-lightbox__image { max-height: calc(100vh - 82px); }
    .modal-card { padding: 25px 22px; }
    .modal-card h2 { font-size: 25px; }
}

@media (min-width: 701px) {
    .filter-panel__heading { cursor: grab; user-select: none; touch-action: none; }
    .filter-panel.is-dragging .filter-panel__heading { cursor: grabbing; }
}

@media (max-width: 470px) {
    .map-header { padding-left: 9px; }
    .map-header__logo { width: 42px; height: 42px; margin-right: 8px; }
    .map-header h1 { font-size: 18px; }
    .map-header__subtitle { display: none; }
    .language-nav { margin-left: 2px; }
    .icon-button { width: 32px; height: 32px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
