:root {
  color-scheme: light;
  --bg: #f8fafc;
  --text: #111827;
  --muted: #64748b;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-strong: #ffffff;
  --line: rgba(15, 23, 42, 0.1);
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --shadow: 0 -18px 46px rgba(15, 23, 42, 0.2);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #dbeafe;
}

.map-view {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: #b9d8e7;
}

.map-view::before {
  content: none;
}

.leaflet-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: inherit;
  background: #b9d8e7;
  outline: 0;
  touch-action: pan-x pan-y;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  top: 0;
  left: 0;
}

.leaflet-tile {
  width: 256px;
  height: 256px;
  max-width: none !important;
  max-height: none !important;
  border: 0;
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-shadow-pane {
  z-index: 500;
}

.leaflet-marker-pane {
  z-index: 600;
}

.leaflet-tooltip-pane {
  z-index: 650;
}

.leaflet-popup-pane {
  z-index: 700;
}

.eclipse-gradient-pane {
  z-index: 330;
  pointer-events: none;
  mix-blend-mode: multiply;
}

.eclipse-gradient-layer {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.map-notice {
  position: absolute;
  top: calc(136px + var(--safe-top));
  left: calc(14px + var(--safe-left));
  right: calc(14px + var(--safe-right));
  z-index: 30;
  padding: 12px 14px;
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  color: #991b1b;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.14);
  font-size: 0.9rem;
  font-weight: 720;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.top-bar {
  position: absolute;
  top: calc(12px + var(--safe-top));
  left: calc(14px + var(--safe-left));
  right: calc(14px + var(--safe-right));
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.top-bar h1,
.sheet-header h2 {
  margin: 0;
  color: var(--text);
  letter-spacing: 0;
}

.top-bar h1 {
  font-size: 1.12rem;
  line-height: 1.15;
  font-weight: 760;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.icon-button,
.search-bar,
.bottom-sheet {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.icon-button {
  display: grid;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 999px;
  color: var(--brand-dark);
  pointer-events: auto;
}

.icon-button span {
  font-size: 1.35rem;
  line-height: 1;
}

.search-bar {
  position: absolute;
  top: calc(78px + var(--safe-top));
  left: calc(14px + var(--safe-left));
  right: calc(14px + var(--safe-right));
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 6px 6px 6px 16px;
  border-radius: 999px;
}

.search-bar input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.96rem;
}

.search-bar input::placeholder {
  color: #64748b;
}

.search-bar button {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 999px;
  background: var(--brand);
  color: #ffffff;
}

.search-bar.is-searching {
  opacity: 0.78;
}

.search-bar.is-searching button {
  cursor: progress;
}

.magnitude-legend {
  min-width: 208px;
  padding: 8px 10px 7px;
  margin: 0 calc(12px + var(--safe-right)) calc(128px + var(--safe-bottom)) 0;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.12);
  color: #334155;
  font-size: 0.72rem;
  font-weight: 760;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.magnitude-legend.is-hidden {
  display: none;
}

.legend-scale,
.legend-labels {
  display: grid;
  grid-template-columns: 0.8fr 1fr 1fr 1fr;
}

.legend-scale {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
}

.legend-scale span {
  display: block;
}

.legend-total {
  background: #6b7280;
}

.legend-high {
  background: #b25aa6;
}

.legend-mid {
  background: #f99ab0;
}

.legend-low {
  background: linear-gradient(90deg, #ffd59e, #fff7bf);
}

.legend-labels {
  gap: 6px;
  margin-top: 4px;
}

.selected-marker {
  width: 22px;
  height: 22px;
  border: 3px solid #ffffff;
  border-radius: 999px;
  background: #2563eb;
  box-shadow:
    0 0 0 2px rgba(37, 99, 235, 0.35),
    0 10px 24px rgba(15, 23, 42, 0.28);
}

.selected-marker::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: inherit;
  background: #ffffff;
}

.bottom-sheet {
  position: absolute;
  right: var(--safe-right);
  bottom: 0;
  left: var(--safe-left);
  z-index: 20;
  display: grid;
  gap: 16px;
  max-height: min(72vh, 560px);
  padding: 10px 18px calc(18px + var(--safe-bottom));
  border-width: 1px 1px 0;
  border-radius: 24px 24px 0 0;
  box-shadow: var(--shadow);
  transform: translateY(calc(100% - 108px - var(--safe-bottom)));
  transition:
    transform 360ms cubic-bezier(0.22, 1, 0.36, 1),
    max-height 360ms cubic-bezier(0.22, 1, 0.36, 1);
  touch-action: pan-y;
}

.bottom-sheet.is-open,
.bottom-sheet:focus-within {
  transform: translateY(0);
}

.bottom-sheet.is-collapsed {
  transform: translateY(calc(100% - 34px - var(--safe-bottom)));
}

.bottom-sheet.is-dragging {
  transition: none;
  user-select: none;
}

.sheet-handle {
  display: block;
  justify-self: center;
  position: relative;
  width: 68px;
  height: 28px;
  margin-bottom: 2px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
}

.sheet-handle::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 12px;
  right: 12px;
  height: 5px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.42);
}

.sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sheet-header h2 {
  max-width: 100%;
  font-size: 1.18rem;
  line-height: 1.22;
  font-weight: 780;
}

.status-pill {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--brand-dark);
  font-size: 0.72rem;
  font-weight: 800;
}

.visual-card {
  display: grid;
  grid-template-columns: minmax(124px, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 118px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.86), rgba(239, 246, 255, 0.9));
}

.eclipse-visual {
  width: 100%;
  min-width: 124px;
  max-width: 210px;
  height: auto;
}

.magnitude-summary {
  display: grid;
  gap: 2px;
  text-align: right;
}

.magnitude-summary span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.magnitude-summary strong {
  color: var(--text);
  font-size: clamp(1.85rem, 12vw, 3.35rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.result-item {
  min-width: 0;
  padding: 12px 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-strong);
}

.result-item.is-hidden {
  display: none;
}

.result-item dt {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 760;
}

.result-item dd {
  margin: 0;
  color: var(--text);
  font-size: clamp(0.86rem, 3.8vw, 1.04rem);
  line-height: 1.16;
  font-weight: 820;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.bottom-sheet.is-no-eclipse .visual-card,
.bottom-sheet.is-no-eclipse .result-grid {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.leaflet-control-container .leaflet-top {
  padding-top: calc(132px + var(--safe-top));
}

.leaflet-control-container .leaflet-left {
  padding-left: calc(8px + var(--safe-left));
}

.leaflet-control-container .leaflet-right {
  padding-right: calc(8px + var(--safe-right));
}

.leaflet-control-container .leaflet-bottom {
  padding-bottom: calc(118px + var(--safe-bottom));
}

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

@media (min-width: 720px) {
  .top-bar,
  .search-bar {
    left: max(24px, calc((100vw - 680px) / 2));
    right: max(24px, calc((100vw - 680px) / 2));
  }

  .bottom-sheet {
    right: max(24px, calc((100vw - 680px) / 2));
    left: max(24px, calc((100vw - 680px) / 2));
    border-radius: 28px 28px 0 0;
  }
}

@media (min-width: 480px) {
  .result-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .result-grid.has-sunset {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
