.main-wrap* {
    box-sizing: border-box;
}

html, body {
		min-height: 100%;
		margin: 0;
		padding: 0;
	}	
	
body {
    font-family: "Spline Sans", "Noto Sans", Arial, sans-serif;
    background: #fef2f2;
    color: #450a0a;
    transition: background 0.3s, color 0.3s;
}

.page-shell {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #e5e7eb;
}

.topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.topbar-inner img {
    height: 40px;
    width: auto;
}

.topbar-title {
    font-size: 15px;
    line-height: 1.2;
    font-weight: 700;
    color: #1f2937;
    text-align: center;
}

.main-wrap {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 18px 14px 0px;
}

.map-card {
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 8px 30px rgba(0,0,0,.10);
    overflow: hidden;
    border: 1px solid #f1f5f9;
}

.map-card-header {
    padding: 18px 18px 14px;
    text-align: center;
}

.map-card-header h2 {
    margin: 0;
    color: #450a0a;
    font-size: 24px;
    line-height: 1.2;
}

.map-card-header p {
    margin: 8px 0 0;
    color: #b91c1c;
    font-size: 14px;
}

.image-container {
    position: relative;
    width: 100%;
    padding: 0 18px 18px;
}

#mapContainer {
    position: relative;
    width: 100%;
    margin: 0 auto;
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 18px rgba(0,0,0,.08);
}

#mapImage {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
    object-position: center;
    transition: opacity .25s ease-in-out;
    z-index: 1;
    pointer-events: none;
}

#pointsContainer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
}

.image-caption {
    position: absolute;
    right: 12px;
    bottom: 12px;
    background: rgba(255,255,255,.92);
    color: #111827;
    padding: 6px 10px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    z-index: 5;
}

#buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 16px 18px 8px;
}

#buttons button {
    background: #fff;
    border: 1px solid #e5e7eb;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,.06);
    transition: .2s ease;
}

#buttons button:hover {
    transform: translateY(-1px);
    background: #f9fafb;
}

#legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 14px 18px 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
    position: static;
    transform: none;
}

#legend span {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 700;
    color: #7f1d1d;
}

#thumbnailBarWrap {
    position: sticky;
    bottom: 0px;
    z-index: 100;
    padding: 10px 12px calc(env(safe-area-inset-bottom, 0px) + 10px);
}

#thumbnailBar {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 2px 6px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}

#thumbnailBar::-webkit-scrollbar {
    height: 8px;
}

#thumbnailBar::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,.15);
    border-radius: 999px;
}

.thumbnail {
    flex: 0 0 calc((100% - 30px) / 4);
    min-width: 82px;
    max-width: 120px;
    border: 2px solid transparent;
    border-radius: 16px;
    padding: 0;
    background: #fff;
    overflow: hidden;
    cursor: pointer;
    scroll-snap-align: start;
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.thumbnail:hover {
    transform: translateY(-2px);
}

.thumbnail.is-active {
    border-color: #dc2626;
    box-shadow: 0 6px 16px rgba(220,38,38,.18);
}

.thumbnail img {
    display: block;
    max-width: 90%;
    max-height: 90%;
    width: auto;
    height: auto;
    margin: auto;
    object-fit: contain;
    aspect-ratio: 1 / 1;
}

.thumb-year {
    display: block;
    width: 100%;
    padding: 8px 6px;
    font-size: 13px;
    font-weight: 700;
    color: #450a0a;
    background: #fff;
    text-align: center;
}

.map-subtitle {
    margin: 0 0 20px;
    padding: 0 8px;
    text-align: center;
    color: #b91c1c;
    font-size: 14px;
    line-height: 1.5;
}

.popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 15px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 2100;
    text-align: center;
    width: min(92vw, 320px);
}

.popup h3 {
    margin: 0 0 8px;
    font-size: 18px;
    color: #111827;
}

.popup p {
    font-size: 12px;
}

.popup p.verde {
    color: green;
    font-size: 10px;
}

.popup p.rojo {
    color: red;
    font-size: 10px;
}

.popup p.orange {
    color: orange;
    font-size: 10px;
}

.popup p.negro {
    color: black;
    font-size: 12px;
}

.popup button {
    margin: 10px 5px 0;
    padding: 8px 12px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
}

.popup .report-button {
    background: #dc2626;
    color: white;
}

.popup .close-button {
    background: #6b7280;
    color: white;
}

/* Marcadores */
.marker {
    position: absolute;
    width: 15px;
    height: 15px;
    border-radius: 999px;
    transform: translate(-50%, -50%);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.18);
    transition: transform .2s ease, opacity .2s ease;
    z-index: 10;
}

.marker:hover {
    transform: translate(-50%, -50%) scale(1.25);
    z-index: 11;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
}

.marker-ok {
    background: #16a34a;
}

.marker-bad {
    background: #dc2626;
}

.marker-warn {
    background: #f59e0b;
}

.marker-info {
    background: #06b6d4;
}

/* Navbar inferior */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    z-index: 2000;
    backdrop-filter: blur(10px);
}

.bottom-nav nav {
    height: 100%;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 6px 0;
}

.bottom-nav nav > a,
.bottom-nav nav > button {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 0;
    background: transparent;
    border: none;
    text-decoration: none;
    color: #444;
    font-size: 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.nav-icon {
    width: 22px;
    height: 22px;
    display: block;
    flex-shrink: 0;
}

.nav-label {
    font-size: 11px;
    line-height: 1;
    font-weight: 500;
}

.bottom-nav nav > a:active,
.bottom-nav nav > button:active {
    transform: scale(0.95);
}

.bottom-nav nav > a.is-active,
.bottom-nav nav > button.is-active,
#toggleMarkers.is-active,
#themeToggle.is-active {
    background: #dbeafe;
    color: #2563eb;
    border-radius: 10px;
}

/* Modo oscuro */
.dark-mode {
    background-color: #121212;
    color: #e5e7eb;
}

.dark-mode .map-card,
.dark-mode #legend span,
.dark-mode .thumbnail,
.dark-mode #buttons button {
    background: rgba(0,0,0,.85);
    color: #fff;
    border-color: rgba(255,255,255,.12);
}

.dark-mode .thumb-year,
.dark-mode .image-caption {
    background: rgba(0,0,0,.85);
    color: #fff;
}

.dark-mode .map-card-header h2,
.dark-mode .topbar-title {
    color: #fff;
}

.dark-mode .map-card-header p {
    color: #fca5a5;
}

.dark-mode .bottom-nav {
    background: rgba(0,0,0,.85);
    border-top-color: rgba(255,255,255,.12);
}

.dark-mode .bottom-nav nav > a,
.dark-mode .bottom-nav nav > button {
    color: #e5e7eb;
}

.dark-mode .bottom-nav nav > a.is-active,
.dark-mode .bottom-nav nav > button.is-active,
.dark-mode #toggleMarkers.is-active,
.dark-mode #themeToggle.is-active {
    background: rgba(37,99,235,.18);
    color: #93c5fd;
}

@media (min-width: 768px) {
    .thumbnail {
        flex-basis: 100px;
    }
	#thumbnailBar {
    display: flex;
	}
	#thumbnailBarWrap{
		bottom: 0;
	}
}