:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #5f6b76;
  --border: #d9e0e6;
  --damage: #b64926;
  --environmental: #277a6b;
  --warning-bg: #fff4d8;
  --warning-border: #d29c19;
  --focus: #245d8c;
  --shadow: 0 8px 28px rgba(20, 32, 44, 0.10);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button, input, select { font: inherit; }

button {
  cursor: pointer;
  border: 0;
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  background: #1f4f75;
  color: white;
  font-weight: 650;
}

button:hover { filter: brightness(0.95); }

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(36, 93, 140, 0.28);
  outline-offset: 2px;
}

.app-shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 1001;
}

.eyebrow {
  margin: 0 0 0.15rem;
  color: var(--focus);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.85rem);
}

.subtitle {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.map-layout {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: 330px 1fr;
  overflow: hidden;
}

.control-panel {
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 0.4rem 1rem 1.2rem;
  z-index: 800;
}

.panel-section {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.panel-section.compact { border-bottom: 0; }

.panel-section h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.panel-section label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.86rem;
  font-weight: 650;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem;
}

input[type="search"], select {
  width: 100%;
  min-width: 0;
  border: 1px solid #b9c4ce;
  border-radius: 8px;
  padding: 0.62rem 0.7rem;
  background: white;
  color: var(--text);
}

.check-row {
  display: grid !important;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 0.55rem;
  margin: 0.65rem 0 !important;
  font-weight: 550 !important;
}

.layer-dot {
  width: 0.82rem;
  height: 0.82rem;
  border-radius: 50%;
  display: inline-block;
}

.damage-dot { background: var(--damage); }
.environmental-dot { background: var(--environmental); }

.help-text {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  margin: 0;
}

.summary-grid div {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem;
  background: #f8fafb;
}

.summary-grid dt {
  color: var(--muted);
  font-size: 0.72rem;
}

.summary-grid dd {
  margin: 0.1rem 0 0;
  font-size: 1.1rem;
  font-weight: 750;
}

.visible-summary {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.secondary-button {
  background: white;
  color: #24465f;
  border: 1px solid #9fb0bd;
}

.full-width { width: 100%; }

.search-results {
  display: none;
  margin-top: 0.35rem;
  max-height: 210px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.search-results.active { display: block; }

.search-result {
  width: 100%;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
  background: white;
  color: var(--text);
  text-align: left;
  padding: 0.58rem 0.7rem;
  font-weight: 500;
}

.search-result:last-child { border-bottom: 0; }
.search-result:hover { background: #eef4f8; filter: none; }

.map-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #dfe6eb;
}

#earthquake-map {
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #dfe6eb;
}

.earthquake-map-layout select {
  margin-top: .15rem;
}

.damage-tooltip {
  display: grid;
  gap: .22rem;
  max-width: 310px;
  white-space: normal;
}

.damage-tooltip strong { font-size: .82rem; }
.damage-tooltip span { font-size: .72rem; line-height: 1.3; }

.loading-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.8rem;
  background: rgba(255, 255, 255, 0.88);
  z-index: 1200;
}

.loading-overlay.hidden { display: none; }

.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #ccd7df;
  border-top-color: #245d8c;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.status-message {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 1000;
  display: none;
  max-width: min(92%, 760px);
  padding: 0.7rem 1rem;
  border-radius: 8px;
  background: #17202a;
  color: white;
  box-shadow: var(--shadow);
  font-size: 0.84rem;
}

.status-message.visible { display: block; }
.status-message.error { background: #8a2b22; }

.leaflet-popup-content-wrapper {
  border-radius: 10px;
}

.leaflet-popup-content {
  width: min(390px, 75vw) !important;
  max-height: 440px;
  overflow-y: auto;
  margin: 0;
}

.popup-header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0.85rem 1rem;
  background: white;
  border-bottom: 1px solid var(--border);
}

.popup-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.popup-header p {
  margin: 0.18rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.popup-body { padding: 0.75rem 1rem 1rem; }

.popup-record {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.popup-record:last-child { border-bottom: 0; }

.popup-record h4 {
  margin: 0 0 0.45rem;
  font-size: 0.92rem;
}

.record-number {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.popup-record dl {
  display: grid;
  grid-template-columns: 105px 1fr;
  gap: 0.24rem 0.55rem;
  margin: 0.45rem 0;
}

.popup-record dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.popup-record dd {
  margin: 0;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.event-warning {
  margin-top: 0.55rem;
  padding: 0.55rem 0.65rem;
  border-left: 4px solid var(--warning-border);
  background: var(--warning-bg);
  font-size: 0.79rem;
}

.event-warning strong { display: block; }

.description {
  margin: 0.45rem 0 0;
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.marker-count {
  color: white;
  font-size: 10px;
  font-weight: 800;
  text-align: center;
  line-height: 26px;
}

dialog {
  width: min(620px, calc(100% - 2rem));
  border: 0;
  border-radius: 12px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(13, 25, 35, 0.58); }

dialog form { padding: 1rem 1.2rem 1.25rem; }

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.dialog-header h2 { margin: 0; }

.dialog-close {
  background: transparent;
  color: var(--text);
  font-size: 1.6rem;
  padding: 0.2rem 0.4rem;
}

dialog p { line-height: 1.55; }

@media (max-width: 820px) {
  .site-header {
    align-items: flex-start;
    padding: 0.8rem 0.9rem;
  }

  .subtitle { display: none; }

  .map-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(460px, 1fr);
  }

  .control-panel {
    max-height: 42vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 0 0.9rem;
  }

  .panel-section {
    padding: 0.75rem 0;
  }

  .summary-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .summary-grid div { padding: 0.45rem; }
}

@media (max-width: 560px) {
  .site-header { flex-direction: column; }
  .site-header .secondary-button { display: none; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
}


.environmental-div-icon {
  background: transparent;
  border: 0;
}

.environmental-div-icon svg {
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.32));
}

.map-legend {
  max-width: 270px;
  max-height: 68vh;
  overflow-y: auto;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.96);
  box-shadow: 0 2px 10px rgba(0,0,0,0.22);
  font-size: 12px;
  line-height: 1.35;
}

.legend-section + .legend-section {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.legend-section strong,
.legend-section small {
  display: block;
}

.legend-section small {
  margin: 2px 0 7px;
  color: var(--muted);
  font-size: 10px;
}

.legend-subheading {
  margin-top: 9px;
}

.legend-row {
  min-height: 25px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0;
}

.legend-circle {
  flex: 0 0 auto;
  display: inline-block;
  border: 1.5px solid white;
  border-radius: 50%;
  background: #b64926;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.25);
}

.legend-swatch {
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  display: inline-block;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.22);
}

.legend-scroll {
  max-height: 175px;
  overflow-y: auto;
  padding-right: 4px;
}

.leaflet-control-layers {
  font-size: 12px;
}

@media (max-width: 820px) {
  .map-legend {
    max-width: 220px;
    max-height: 42vh;
  }

  .leaflet-control-layers-expanded {
    max-width: 180px;
  }
}


.popup-layer-label {
  margin: 0 0 0.18rem;
  color: var(--focus);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.popup-site-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.popup-site-meta span {
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  background: #edf2f5;
  color: #44525e;
  font-size: 0.68rem;
  font-weight: 700;
}

.popup-site-meta .meta-warning {
  background: #fff0cf;
  color: #735500;
}

.popup-record {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.65rem;
  overflow: hidden;
  background: white;
}

.popup-record:last-child { margin-bottom: 0; }

.popup-record > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.68rem 0.75rem;
  cursor: pointer;
  background: #f7f9fa;
}

.popup-record > summary::-webkit-details-marker { display: none; }

.popup-record > summary::after {
  content: "▾";
  color: var(--muted);
  font-size: 0.85rem;
}

.popup-record[open] > summary::after { transform: rotate(180deg); }

.popup-record > summary > span:first-child {
  min-width: 0;
  display: grid;
  gap: 0.12rem;
}

.popup-record > summary strong {
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.popup-record-content {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}

.severity-badge {
  flex: 0 0 auto;
  max-width: 115px;
  padding: 0.22rem 0.42rem;
  border-radius: 999px;
  background: #e7edf1;
  color: #33434f;
  font-size: 0.66rem;
  font-weight: 800;
  text-align: center;
}

.popup-fields {
  display: grid;
  gap: 0;
  margin: 0;
}

.popup-field {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 0.45rem;
  padding: 0.28rem 0;
  border-bottom: 1px solid #edf0f2;
}

.popup-field:last-child { border-bottom: 0; }

.popup-field dt {
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 700;
}

.popup-field dd {
  min-width: 0;
  margin: 0;
  font-size: 0.77rem;
  overflow-wrap: anywhere;
}

.event-link {
  display: flex;
  gap: 0.55rem;
  margin-top: 0.7rem;
  padding: 0.62rem 0.68rem;
  border-radius: 7px;
  font-size: 0.76rem;
}

.event-link-unlinked {
  border-left: 4px solid var(--warning-border);
  background: var(--warning-bg);
}

.event-link-linked {
  display: block;
  border-left: 4px solid #568a67;
  background: #edf7f0;
}

.event-link-icon {
  display: grid;
  place-content: center;
  flex: 0 0 21px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #a87500;
  color: white;
  font-weight: 900;
}

.event-link strong,
.event-link span {
  display: block;
}

.event-link-title {
  margin-bottom: 0.35rem;
  font-weight: 800;
}

.record-details {
  margin-top: 0.55rem;
  border-top: 1px solid #edf0f2;
  padding-top: 0.45rem;
}

.record-details summary {
  cursor: pointer;
  color: #315f7f;
  font-size: 0.74rem;
  font-weight: 750;
}

.record-details .description {
  margin: 0.45rem 0 0;
  max-height: 190px;
  overflow-y: auto;
}

@media (max-width: 560px) {
  .leaflet-popup-content {
    width: min(355px, 82vw) !important;
    max-height: 58vh;
  }

  .popup-field {
    grid-template-columns: 95px 1fr;
  }
}

/* v1.1 accumulated-damage update */
.tab-shell{min-height:0;height:100%;display:grid;grid-template-rows:auto minmax(0,1fr);overflow:hidden}.tab-list{display:flex;gap:.25rem;padding:.55rem 1rem 0;background:var(--surface);border-bottom:1px solid var(--border)}.tab-button{border-radius:8px 8px 0 0;background:#e9eef2;color:#24465f;border:1px solid var(--border);border-bottom:0;padding:.7rem 1rem}.tab-button[aria-selected="true"]{background:#fff;color:#17202a;box-shadow:0 -2px 0 #245d8c inset}.tab-panel{min-height:0;height:100%;overflow:hidden}.tab-panel[hidden]{display:none}.empty-tab{display:grid;place-items:center;background:#fff;text-align:center;color:var(--muted)}.empty-tab h2{color:var(--text)}
.confidence-fieldset{border:0;border-top:1px solid var(--border);padding:.9rem 0 0;margin:.9rem 0 0}.confidence-fieldset legend{padding:0;font-size:.86rem;font-weight:750}.radio-options{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.35rem .6rem;margin-top:.55rem}.radio-row{display:flex!important;align-items:center;gap:.4rem;margin:0!important;padding:.25rem 0;font-weight:500!important}.radio-row input{margin:0}.radio-row.confidence-all{grid-column:1/-1;justify-content:center;padding-bottom:.45rem;border-bottom:1px solid var(--border);margin-bottom:.15rem!important}.layer-square{width:.82rem;height:.82rem;border-radius:2px;display:inline-block}.environmental-dot{background:var(--environmental)}
.popup-coordinates{font-variant-numeric:tabular-nums}.popup-site-meta{display:flex;gap:.4rem;flex-wrap:wrap;margin-top:.45rem}.popup-site-meta span{background:#eef3f6;border-radius:999px;padding:.18rem .45rem;font-size:.7rem}.earthquake-group{border:1px solid var(--border);border-radius:8px;margin-bottom:.65rem;overflow:hidden}.earthquake-group>summary{display:flex;justify-content:space-between;gap:.7rem;align-items:center;padding:.65rem .75rem;background:#f5f8fa;cursor:pointer}.earthquake-group>summary span{font-size:.72rem;color:var(--muted);text-align:right}.earthquake-group-body{padding:.25rem .75rem .65rem}.event-record{padding:.55rem 0}.event-record+.event-record{border-top:1px dashed var(--border)}.event-record h5{margin:0 0 .35rem;color:var(--muted)}.popup-fields{display:block!important;margin:0!important}.popup-field{display:grid;grid-template-columns:120px minmax(0,1fr);gap:.55rem;padding:.22rem 0}.popup-field dt{font-size:.75rem}.popup-field dd{white-space:pre-wrap;line-height:1.35}.map-legend small{display:block;margin:.2rem 0 .45rem;color:#5f6b76}.legend-section+.legend-section{border-top:1px solid #d9e0e6;margin-top:.65rem;padding-top:.65rem}
@media(max-width:760px){.tab-list{overflow-x:auto}.tab-button{white-space:nowrap}.popup-field{grid-template-columns:100px minmax(0,1fr)}}

/* v1.1 review correction: fixed Confidence layout and scrollable earthquake list */
.radio-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: auto repeat(3, auto);
  align-items: center;
}
.radio-row.confidence-all {
  grid-column: 1;
  grid-row: 1;
  justify-content: flex-start;
  padding-bottom: .45rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: .15rem !important;
}
.confidence-left { grid-column: 1; }
.confidence-right { grid-column: 2; }
.confidence-row-1 { grid-row: 2; }
.confidence-row-2 { grid-row: 3; }
.confidence-row-3 { grid-row: 4; }

.popup-body {
  max-height: 365px;
  overflow-y: auto;
}
.earthquake-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: .7rem;
  overflow: hidden;
  background: #fff;
}
.earthquake-group:last-child { margin-bottom: 0; }
.earthquake-date {
  margin: 0;
  padding: .65rem .75rem;
  background: #f5f8fa;
  border-bottom: 1px solid var(--border);
  font-size: .84rem;
  font-weight: 800;
}
.popup-field-confidence {
  margin: .18rem 0 .3rem;
  padding: .42rem .5rem;
  border: 1px solid #b9cedd;
  border-radius: 6px;
  background: #eef5fa;
}
.popup-field-confidence dt,
.popup-field-confidence dd {
  color: #153f5d;
  font-weight: 800;
}

@media(max-width:760px){
  .radio-options {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
}

/* v1.2 Embed API ---------------------------------------------------------
   ?embed=1 adds .embed-mode to <body> in map-app.js. Embedded mode hides
   only the standalone application chrome; map controls and functionality
   remain unchanged. */
body.embed-mode {
  overflow: hidden;
}

body.embed-mode .app-shell {
  grid-template-rows: 1fr;
}

body.embed-mode .site-header,
body.embed-mode .tab-list {
  display: none;
}

body.embed-mode .tab-shell {
  grid-template-rows: 1fr;
  height: 100%;
}

body.embed-mode #accumulated-panel,
body.embed-mode .map-layout,
body.embed-mode .map-panel,
body.embed-mode #map {
  height: 100%;
  min-height: 0;
}

/* v1.2 Embed map-first interface ----------------------------------------
   Embedded mode keeps the full data/map functionality but prioritizes the
   map. Search floats above the map; layers, confidence and summary move to
   an off-canvas drawer. The standalone layout is unchanged. */
.filters-drawer { display: contents; }
.embed-drawer-header,
.embed-map-actions { display: none; }

body.embed-mode .map-layout {
  position: relative;
  display: block;
  height: 100%;
}

body.embed-mode .control-panel {
  position: absolute;
  inset: 0;
  z-index: 1100;
  overflow: visible;
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: none;
}

body.embed-mode .explore-section {
  position: absolute;
  top: 10px;
  left: 58px;
  right: 58px;
  z-index: 1120;
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: auto;
}

body.embed-mode .explore-section > h2,
body.embed-mode .explore-section > label {
  display: none;
}

body.embed-mode .explore-section .search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .35rem;
  padding: .35rem;
  border: 1px solid rgba(159,176,189,.8);
  border-radius: 10px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 3px 14px rgba(20,32,44,.18);
  backdrop-filter: blur(4px);
}

body.embed-mode .explore-section .search-row input {
  min-width: 0;
  border: 0;
  background: transparent;
  outline: 0;
}

body.embed-mode .explore-section .search-results {
  position: absolute;
  top: calc(100% + .35rem);
  left: 0;
  right: 0;
  margin: 0;
  max-height: min(240px, 40vh);
}

body.embed-mode .filters-drawer {
  display: block;
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 10px;
  width: min(320px, calc(100% - 20px));
  z-index: 1140;
  overflow-y: auto;
  padding: 0 .9rem .9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,.985);
  box-shadow: 0 10px 34px rgba(20,32,44,.24);
  transform: translateX(calc(-100% - 22px));
  transition: transform .2s ease;
  pointer-events: auto;
}

body.embed-mode.embed-filters-open .filters-drawer {
  transform: translateX(0);
}

body.embed-mode .embed-drawer-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin: 0 -.9rem;
  padding: .72rem .9rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.98);
}

body.embed-mode .embed-icon-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  background: #eef3f6;
  color: #24465f;
  font-size: 1.25rem;
  line-height: 1;
}

body.embed-mode .filters-drawer .summary-grid {
  gap: .45rem;
}

body.embed-mode .filters-drawer .summary-grid div {
  padding: .5rem;
}

body.embed-mode .filters-drawer .summary-grid dd {
  font-size: 1rem;
}

body.embed-mode .map-panel {
  position: relative;
  width: 100%;
  height: 100%;
}

body.embed-mode .embed-map-actions {
  position: absolute;
  right: 10px;
  bottom: 28px;
  z-index: 1080;
  display: flex;
  gap: .4rem;
}

body.embed-mode .embed-action-button {
  padding: .55rem .72rem;
  border: 1px solid #7895a8;
  border-radius: 8px;
  background: rgba(31,79,117,.95);
  box-shadow: 0 2px 8px rgba(20,32,44,.18);
  font-size: .8rem;
}

body.embed-mode .embed-action-secondary {
  background: rgba(255,255,255,.96);
  color: #24465f;
}

body.embed-mode .leaflet-control-layers {
  max-width: 190px;
}

@media (max-width: 620px) {
  body.embed-mode .explore-section {
    left: 50px;
    right: 50px;
  }

  body.embed-mode .explore-section .search-row {
    grid-template-columns: minmax(0, 1fr);
  }

  body.embed-mode #search-button {
    display: none;
  }

  body.embed-mode .filters-drawer {
    width: min(300px, calc(100% - 20px));
  }

  body.embed-mode .map-legend {
    max-width: min(210px, 55vw);
  }
}

/* v1.2 data/schema hotfix: keep both tab maps inside the available viewport. */
@media (max-width: 820px) {
  #map, #earthquake-map { min-height: 460px; }
  .map-layout { overflow: visible; height: auto; }
  .tab-shell, .tab-panel { overflow: visible; height: auto; }
  .app-shell { height: auto; min-height: 100%; }
}

/* v1.2 selected-earthquake map refinements -------------------------------- */
@media (min-width: 821px) {
  html, body { overflow: hidden; }
  .app-shell { height: 100dvh; min-height: 0; }
  .site-header { min-height: 0; }
  .tab-shell, .tab-panel, .map-layout, .map-panel { min-height: 0; }
  .tab-panel { height: auto; }
  .map-layout { height: 100%; }
  #map, #earthquake-map { height: 100%; min-height: 0; }
}

.earthquake-control-panel {
  padding-bottom: 1rem;
}

.earthquake-statistics-section h3,
.earthquake-statistics-section h4 {
  margin: 0;
}

.stat-layer-block + .stat-layer-block {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.stat-layer-heading {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .25rem;
}

.stat-layer-heading h3 {
  font-size: .9rem;
}

.stat-total {
  margin: .15rem 0 .7rem;
  color: var(--muted);
  font-size: .75rem;
}

.earthquake-statistics-section h4 {
  margin: .65rem 0 .3rem;
  color: #43515d;
  font-size: .76rem;
}

.compact-stat-table {
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  background: #fafcfd;
}

.stat-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: .65rem;
  align-items: center;
  padding: .28rem .45rem;
  font-size: .72rem;
}

.stat-row + .stat-row {
  border-top: 1px solid #e6ebef;
}

.stat-row strong {
  font-variant-numeric: tabular-nums;
}

.stat-empty {
  display: block;
  padding: .4rem .45rem;
  color: var(--muted);
  font-size: .72rem;
}

/* v1.2 selected-earthquake map: severity symbology, compact effect legend, site labels */
#earthquake-map .map-legend {
  overflow-y: visible;
  max-height: none;
}

#earthquake-map .severity-circle {
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.28);
}

#earthquake-map .earthquake-env-legend-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(54px, 1fr));
  column-gap: 14px;
  row-gap: 1px;
}

#earthquake-map .earthquake-env-legend-grid .legend-row {
  min-height: 22px;
  margin: 0;
}

.site-name-label-icon {
  width: auto !important;
  height: auto !important;
  background: transparent !important;
  border: 0 !important;
  pointer-events: none !important;
}

.site-name-label {
  display: inline-block;
  transform: translate(-50%, -115%);
  white-space: nowrap;
  color: #000;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  text-shadow:
    -1px -1px 0 #fff,
     0   -1px 0 #fff,
     1px -1px 0 #fff,
    -1px  0   0 #fff,
     1px  0   0 #fff,
    -1px  1px 0 #fff,
     0    1px 0 #fff,
     1px  1px 0 #fff,
     0    0   3px #fff;
}

.earthquake-confidence-fieldset .radio-options {
  grid-template-rows: auto repeat(3, auto);
}


/* v1.2 r5: selected-earthquake refinements and embed QA fixes */
.site-name-label-icon, .site-name-label { display: none !important; }
.leaflet-tooltip.damage-tooltip, .damage-tooltip { pointer-events: auto; }
.damage-tooltip a, .popup-link { color: #145b8f; text-decoration: underline; overflow-wrap: anywhere; }
.damage-tooltip a:hover, .popup-link:hover { text-decoration-thickness: 2px; }
html.embed-mode-root, html.embed-mode-root body { width:100%; height:100%; min-height:0; overflow:hidden; }
body.embed-mode .app-shell, body.embed-mode .tab-shell, body.embed-mode #accumulated-panel { width:100%; height:100%; min-height:0; }
body.embed-mode #earthquake-panel { display:none !important; }
body.embed-mode #accumulated-panel { display:block !important; overflow:hidden; }
body.embed-mode #map { width:100%; height:100%; min-height:0; }
