html, body {
height: 100%;
margin: 0;
padding: 0;
background-color: var(--bg);
}

.map-layout {
display: grid;
grid-template-columns: minmax(0, 1.65fr) minmax(21rem, 28rem);
grid-template-areas:
"map overview"
"list list";
gap: 1.5rem;
align-items: start;
padding: 1.5rem;
}

.map-stage {
grid-area: map;
position: relative;
min-width: 0;
}

#map {
height: clamp(32rem, calc(100vh - 9rem), 44rem);
width: 100%;
border-radius: 16px;
overflow: hidden;
box-shadow: var(--shadow-1);
transition: opacity 0.6s ease-out;
}

.map-sidebar-panel {
display: flex;
flex-direction: column;
gap: 0.9rem;
padding: 1.25rem;
border: 1px solid var(--border);
border-radius: 20px;
background: color-mix(in srgb, var(--surface) 94%, transparent);
box-shadow: var(--shadow-1);
}

.map-overview-panel {
grid-area: overview;
position: static;
}

.map-sidebar-list-panel {
grid-area: list;
gap: 0.75rem;
align-self: start;
}

.map-sidebar-kicker {
font-size: 0.72rem;
font-weight: 700;
letter-spacing: 0.16em;
text-transform: uppercase;
color: var(--primary);
}

.map-sidebar-title {
margin: 0;
font-size: clamp(1.5rem, 2.4vw, 2rem);
line-height: 1.05;
color: var(--text);
}

.map-sidebar-copy {
margin: 0;
font-size: 0.98rem;
line-height: 1.55;
color: var(--text-muted);
}

.map-stat-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 0.75rem;
}

.map-stat-card {
display: flex;
flex-direction: column;
gap: 0.35rem;
padding: 0.9rem 1rem;
border-radius: 16px;
background: var(--step-bg);
border: 1px solid var(--border);
}

.map-stat-label {
font-size: 0.78rem;
font-weight: 600;
letter-spacing: 0.08em;
text-transform: uppercase;
color: var(--text-muted);
}

.map-stat-value {
font-size: 1.55rem;
line-height: 1;
color: var(--text);
}

.map-sidebar-highlight {
display: flex;
flex-direction: column;
gap: 0.65rem;
padding: 1rem;
border-radius: 18px;
background: linear-gradient(140deg, color-mix(in srgb, var(--primary) 10%, var(--surface)), var(--surface));
border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border));
}

.map-sidebar-highlight-copy {
margin: 0;
font-size: 0.98rem;
line-height: 1.5;
color: var(--text);
}

.map-sidebar-highlight-meta {
display: flex;
flex-wrap: wrap;
gap: 0.65rem 1rem;
font-size: 0.85rem;
font-weight: 600;
color: var(--text-muted);
}

.map-legend {
display: flex;
flex-direction: column;
gap: 0.7rem;
padding-top: 0.2rem;
}

.map-legend-row {
display: flex;
align-items: center;
gap: 0.7rem;
font-size: 0.9rem;
line-height: 1.45;
color: var(--text-muted);
}

.map-legend-bubble {
display: inline-flex;
align-items: center;
justify-content: center;
width: 2rem;
height: 2rem;
border-radius: 50%;
background: radial-gradient(circle at 30% 30%, #60a5fa, #2563eb 72%);
color: #fff;
font-size: 0.82rem;
font-weight: 800;
box-shadow: 0 12px 20px -16px rgba(15, 23, 42, 0.5);
}

.map-legend-chip {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0.28rem 0.65rem;
border-radius: 999px;
background: color-mix(in srgb, #2563eb 14%, var(--surface));
color: #1d4ed8;
border: 1px solid color-mix(in srgb, #2563eb 20%, transparent);
font-size: 0.76rem;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}

.map-heat-chip {
display: inline-flex;
align-items: center;
justify-content: center;
align-self: flex-start;
padding: 0.34rem 0.72rem;
border-radius: 999px;
font-size: 0.73rem;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
border: 1px solid transparent;
}

.map-heat-chip.is-surging {
background: color-mix(in srgb, #ef4444 16%, var(--surface));
color: #b91c1c;
border-color: color-mix(in srgb, #ef4444 20%, transparent);
}

.map-heat-chip.is-heating {
background: color-mix(in srgb, #f59e0b 18%, var(--surface));
color: #b45309;
border-color: color-mix(in srgb, #f59e0b 20%, transparent);
}

.map-heat-chip.is-active {
background: color-mix(in srgb, #2563eb 14%, var(--surface));
color: #1d4ed8;
border-color: color-mix(in srgb, #2563eb 20%, transparent);
}

.map-heat-chip.is-watch {
background: color-mix(in srgb, var(--text-muted) 10%, var(--surface));
color: var(--text-muted);
border-color: color-mix(in srgb, var(--text-muted) 12%, transparent);
}

.map-hotspot-list {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
gap: 0.85rem;
max-height: none;
overflow: visible;
padding-right: 0;
}

.map-hotspot-card {
display: flex;
flex-direction: column;
gap: 0.85rem;
height: 100%;
padding: 1rem;
border-radius: 18px;
background: var(--surface);
border: 1px solid var(--border);
transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.map-hotspot-card.is-active {
border-color: color-mix(in srgb, var(--primary) 34%, transparent);
box-shadow: 0 20px 36px -26px color-mix(in srgb, var(--primary) 48%, transparent);
transform: translateY(-1px);
}

.map-hotspot-focus {
display: flex;
flex-direction: column;
gap: 0.75rem;
width: 100%;
padding: 0;
border: 0;
background: transparent;
text-align: left;
cursor: pointer;
}

.map-hotspot-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.75rem;
}

.map-hotspot-score {
font-size: 0.9rem;
font-weight: 700;
color: var(--text);
}

.map-hotspot-title {
margin: 0;
font-size: 1.05rem;
font-weight: 700;
line-height: 1.2;
color: var(--text);
}

.map-hotspot-status {
font-size: 0.78rem;
font-weight: 600;
color: var(--text-muted);
text-align: right;
}

.map-hotspot-summary {
display: flex;
flex-wrap: wrap;
gap: 0.45rem 0.9rem;
margin-top: -0.15rem;
font-size: 0.9rem;
font-weight: 600;
color: var(--text-muted);
}

.map-hotspot-counts {
display: flex;
flex-wrap: wrap;
gap: 0.55rem;
}

.map-hotspot-counts span {
display: inline-flex;
align-items: center;
gap: 0.38rem;
padding: 0.34rem 0.55rem;
border-radius: 999px;
background: var(--step-bg);
font-size: 0.82rem;
font-weight: 600;
color: var(--text-muted);
}

.map-hotspot-caption {
margin: 0;
font-size: 0.86rem;
color: var(--primary);
}

.map-hotspot-tags {
display: flex;
flex-wrap: wrap;
gap: 0.45rem;
}

.map-hotspot-tags span {
display: inline-flex;
align-items: center;
padding: 0.28rem 0.6rem;
border-radius: 999px;
background: var(--step-bg);
font-size: 0.78rem;
font-weight: 600;
color: var(--text-muted);
}

.map-list-intro {
display: flex;
flex-direction: column;
gap: 0.35rem;
}

.map-list-title {
margin: 0;
font-size: 1rem;
font-weight: 700;
color: var(--text);
}

.map-list-copy {
margin: 0;
font-size: 0.9rem;
line-height: 1.5;
color: var(--text-muted);
}

.map-hotspot-footer {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 0.75rem;
}

.map-hotspot-latest {
display: flex;
flex-direction: column;
gap: 0.18rem;
min-width: 0;
}

.map-hotspot-latest-label {
font-size: 0.72rem;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
color: var(--text-muted);
}

.map-hotspot-latest-copy {
font-size: 0.9rem;
line-height: 1.45;
color: var(--text);
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}

.map-hotspot-link {
display: inline-flex;
align-items: center;
gap: 0.4rem;
white-space: nowrap;
font-size: 0.88rem;
font-weight: 700;
color: var(--primary);
text-decoration: none;
}

.map-empty-state {
display: flex;
flex-direction: column;
gap: 0.4rem;
padding: 1rem 0 0.2rem;
}

.map-empty-title {
margin: 0;
font-size: 1rem;
font-weight: 700;
color: var(--text);
}

.map-empty-copy {
margin: 0;
font-size: 0.95rem;
line-height: 1.55;
color: var(--text-muted);
}

.leaflet-container {
    background: var(--bg) !important;
}

.leaflet-popup-content-wrapper {
    background: var(--surface) !important;
    color: var(--text) !important;
}

.leaflet-popup-tip {
    background: var(--surface) !important;
}

/* Leaflet UI (controls + attribution) */
.leaflet-control {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--control-shadow) !important;
}

.leaflet-control a {
  color: var(--text) !important;
}

.leaflet-control a:hover {
  background: var(--step-bg) !important;
}

.leaflet-control-attribution {
  background: color-mix(in srgb, var(--surface) 85%, transparent) !important;
  color: var(--text-muted) !important;
  border: 1px solid var(--border) !important;
}
.leaflet-control-attribution a {
  color: var(--primary) !important;
}

.leaflet-popup-content {
  color: var(--text) !important;
}

/* Toast */
.map-toast {
position: fixed;
bottom: 20px;
left: 50%;
transform: translateX(-50%) translateY(20px);
background: var(--toast-bg);
color: var(--toast-text);
padding: 10px 18px;
border-radius: 10px;
font-size: 0.9rem;
opacity: 0;
transition: opacity 0.4s ease, transform 0.4s ease;
box-shadow: var(--shadow-2);
z-index: 1000;
}
.map-toast.show {
opacity: 1;
transform: translateX(-50%) translateY(0);
}

/* Cluster */
.marker-cluster-small div {
background: linear-gradient(145deg, var(--pin-news-1), var(--pin-news-2));
border: 3px solid var(--cluster-border);
color: var(--cluster-text);
font-weight: 600;
font-size: 14px;
}

/* Fix Leaflet injecting opacity on popup (causing faded button text) */
.leaflet-popup-content-wrapper,
.leaflet-popup-content {
    opacity: 1 !important;
}

/* Fix uneven padding between left/right */
.leaflet-popup-content {
    padding: 0 !important;
}

/* Fix the internal container Leaflet adds */
.leaflet-popup-content > div {
    margin: 0 !important;
    padding: 0 !important;
}

/* Photo styling */
.popup-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-top-left-radius: 14px;
    border-top-right-radius: 14px;
    background: var(--map-surface-2);
}

/* Title */
.popup-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}

/* Summary text */
.popup-description {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.45;
    margin-bottom: 1.3rem;
}

/* Footer container */
.popup-footer {
    display: flex;
    justify-content: flex-start;
    margin-top: 10px;
}

/* Button — FIXED version */
.popup-button {
    display: inline-block;
    background: var(--primary);
    color: var(--primary-contrast) !important;
    padding: 0.65rem 1.3rem;
    border-radius: 10px;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;
    transition: background 0.15s ease;
}

/* Header row container */
.popup-header {
display: flex;
gap: 14px;
align-items: flex-start;
margin-bottom: 14px;
}

/* Thumbnail */
.popup-thumb {
    width: 70px;
    height: 70px;
    border-radius: 10px;
    object-fit: cover;
    background: var(--map-surface-2);
    flex-shrink: 0;
}

/* NEWS / EVENT chip */
.popup-type {
    display: inline-block;
    padding: 4px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 6px;
    margin-bottom: 6px;
}

.popup-type.news {
    background: var(--chip-news-bg);
    color: var(--chip-news-text);
}

.popup-type.event {
    background: var(--chip-event-bg);
    color: var(--chip-event-text);
}

.popup-type.figure,
.popup-type.active {
    background: color-mix(in srgb, #2563eb 14%, var(--surface));
    color: #1d4ed8;
}

.popup-type.surging {
    background: color-mix(in srgb, #ef4444 16%, var(--surface));
    color: #b91c1c;
}

.popup-type.heating {
    background: color-mix(in srgb, #f59e0b 18%, var(--surface));
    color: #b45309;
}

.popup-type.watch {
    background: color-mix(in srgb, var(--text-muted) 10%, var(--surface));
    color: var(--text-muted);
}

/* Title + date container */
.popup-info {
    flex: 1;
}

.popup-date {
    font-size: 0.78rem;
    color: var(--map-muted);
    margin-top: 4px;
}

.popup-button:hover {
    background: var(--primary-hover);
}

.popup-chip-row {
display: flex;
flex-wrap: wrap;
gap: 0.45rem;
margin-bottom: 0.75rem;
}

.popup-chip {
display: inline-flex;
align-items: center;
gap: 0.32rem;
padding: 0.3rem 0.55rem;
border-radius: 999px;
background: var(--step-bg);
font-size: 0.75rem;
font-weight: 600;
color: var(--text-muted);
}

.popup-chip i {
font-size: 0.72rem;
}

.popup-topic-list {
display: flex;
flex-direction: column;
gap: 0.45rem;
margin-bottom: 1rem;
}

.popup-topic-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.8rem;
padding: 0.65rem 0.8rem;
border-radius: 12px;
background: var(--step-bg);
text-decoration: none;
}

.popup-topic-name {
font-size: 0.9rem;
font-weight: 700;
color: var(--text);
}

.popup-topic-meta {
font-size: 0.78rem;
font-weight: 600;
color: var(--text-muted);
white-space: nowrap;
}

/* Map Pins */
.custom-pin {
position: relative;
width: 38px;
height: 38px;
background: var(--pin-base);
border-radius: 50% 50% 50% 0;
transform: rotate(-45deg);
box-shadow: var(--shadow-3);
display: flex;
align-items: center;
justify-content: center;
transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.pin-news {
background: linear-gradient(145deg, var(--pin-news-1), var(--pin-news-2));
}
.pin-event {
background: linear-gradient(145deg, var(--pin-event-1), var(--pin-event-2));
}
.pin-figure {
background: linear-gradient(145deg, #14b8a6, #0f766e);
}
.pin-icon {
transform: rotate(45deg);
color: var(--pin-icon);
font-size: 18px;
}

/* Controls */
.map-controls {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
}

.map-btn {
  width: 42px;
  height: 42px;
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  border: none;
  box-shadow: var(--control-shadow);
  font-size: 22px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.map-btn:hover {
  background: var(--step-bg);
}

.map-btn i {
font-size: 18px;
color: var(--text);
}

.map-btn:hover i {
color: var(--icon-hover);
}

.transparent-pin,
.transparent-hotspot {
background: transparent;
border: 0;
}

.map-hotspot-bubble {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 3.4rem;
height: 3.4rem;
border-radius: 50%;
border: 3px solid rgba(255, 255, 255, 0.82);
box-shadow: 0 18px 28px -18px rgba(15, 23, 42, 0.45);
font-size: 0.92rem;
font-weight: 800;
color: #fff;
transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.map-hotspot-bubble::after {
content: "";
position: absolute;
inset: -0.42rem;
border-radius: 50%;
border: 1px solid currentColor;
opacity: 0.18;
}

.map-hotspot-bubble.is-surging {
background: radial-gradient(circle at 30% 30%, #fb7185, #dc2626 72%);
}

.map-hotspot-bubble.is-heating {
background: radial-gradient(circle at 30% 30%, #fbbf24, #ea580c 72%);
}

.map-hotspot-bubble.is-active {
background: radial-gradient(circle at 30% 30%, #60a5fa, #2563eb 72%);
}

.map-hotspot-bubble.is-watch {
background: radial-gradient(circle at 30% 30%, #94a3b8, #475569 72%);
}

.map-hotspot-bubble.is-selected {
transform: scale(1.08);
box-shadow: 0 24px 36px -18px color-mix(in srgb, var(--primary) 65%, transparent);
border-color: color-mix(in srgb, #fff 92%, var(--primary));
}

.map-hotspot-ring {
position: absolute;
inset: -0.6rem;
border-radius: 50%;
border: 1px dashed rgba(255, 255, 255, 0.35);
opacity: 0.7;
}

@media (max-width: 980px) {
.map-layout {
grid-template-columns: minmax(0, 1fr);
grid-template-areas:
"overview"
"map"
"list";
}

#map {
height: 32rem;
}

.map-hotspot-list {
grid-template-columns: 1fr;
}

.map-overview-panel {
position: static;
}
}

@media (max-width: 720px) {
.map-layout {
padding: 1rem;
gap: 1rem;
}

.map-sidebar-panel {
padding: 1rem;
border-radius: 18px;
}

.map-stat-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}

#map {
height: 25rem;
border-radius: 14px;
}

.map-hotspot-footer {
flex-direction: column;
align-items: stretch;
}

.map-hotspot-link {
justify-content: space-between;
}

.map-hotspot-top,
.map-legend-row {
align-items: flex-start;
}

.map-hotspot-status {
text-align: left;
}

.map-hotspot-summary,
.map-sidebar-highlight-meta {
flex-direction: column;
gap: 0.35rem;
}
}
