:root {
  --bg: #eef6f8;
  --panel: #fbfdff;
  --panel-strong: #e4f0f4;
  --line: #c9dce4;
  --text: #10252e;
  --muted: #5a6f78;
  --blue: #176f8f;
  --blue-dark: #0f4f67;
  --blue-soft: #dceff5;
  --green: #6f8f63;
  --green-dark: #4f7047;
  --gold: #b99453;
  --water: #4fa6c8;
  --shadow: 0 16px 35px rgba(17, 52, 65, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 430px minmax(0, 1fr);
  grid-template-areas: "sidebar map";
  width: 100%;
  height: 100dvh;
  min-height: 0;
}

.sidebar {
  grid-area: sidebar;
  min-height: 0;
  overflow-y: auto;
  padding: 22px 18px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfdff 0%, #eef6f8 100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand h1 {
  margin: 0;
  font-size: 23px;
  line-height: 1.1;
}

.brand p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(251, 253, 255, 0.94);
  box-shadow: var(--shadow);
}

.field {
  display: grid;
  gap: 6px;
}

.field-full,
.button-wide {
  grid-column: 1 / -1;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

input {
  padding: 12px 13px;
}

select {
  padding: 11px 12px;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 111, 143, 0.15);
}

.button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
}

.button-primary {
  background: var(--blue);
  color: #fff;
}

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

.button-secondary {
  border: 1px solid #d4c6ad;
  background: var(--panel-strong);
  color: var(--text);
}

.result-summary {
  display: flex;
  gap: 6px;
  align-items: baseline;
  margin: 18px 2px 10px;
  color: var(--muted);
  font-size: 14px;
}

.result-summary strong {
  color: var(--text);
  font-size: 22px;
}

.results {
  display: grid;
  gap: 12px;
  padding-bottom: 20px;
}

.launch-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 25px rgba(17, 52, 65, 0.08);
}

.launch-image {
  position: relative;
  display: flex;
  align-items: end;
  min-height: 120px;
  background:
    linear-gradient(135deg, rgba(15, 79, 103, 0.82), rgba(111, 143, 99, 0.42)),
    radial-gradient(circle at 25% 20%, rgba(255, 255, 255, 0.5), transparent 32%),
    linear-gradient(150deg, #8fc9dd, #d7ebdd);
  background-position: center;
  background-size: cover;
}

.photo-badge {
  margin: 8px;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(16, 37, 46, 0.76);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.launch-body {
  padding: 13px;
}

.launch-heading {
  display: flex;
  gap: 10px;
  align-items: start;
  justify-content: space-between;
}

.launch-heading h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.18;
}

.pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(111, 143, 99, 0.14);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
}

.launch-meta,
.launch-description,
.verification-line {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.verification-line {
  color: var(--blue-dark);
  font-weight: 800;
}

.rating-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.rating {
  border-radius: 8px;
  padding: 8px;
  background: #edf6f9;
  font-size: 12px;
}

.rating strong {
  display: block;
  margin-bottom: 2px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(23, 111, 143, 0.12);
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 700;
}

.card-button {
  width: 100%;
  margin-top: 12px;
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.map-panel {
  grid-area: map;
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #e6f2f6;
}

.detail-panel {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: grid;
  justify-items: end;
  background: rgba(16, 37, 46, 0.24);
}

.detail-panel[hidden] {
  display: none;
}

.detail-card {
  position: relative;
  width: min(440px, calc(100vw - 24px));
  height: calc(100dvh - 24px);
  margin: 12px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(17, 52, 65, 0.26);
  padding: 20px;
}

.detail-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.detail-kicker {
  margin-right: 44px;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-card h2 {
  margin: 6px 44px 0 0;
  font-size: 28px;
  line-height: 1.08;
}

.detail-card h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.detail-card p {
  color: var(--muted);
  line-height: 1.5;
}

.detail-subtitle {
  margin: 8px 44px 0 0;
}

.detail-photo {
  margin: 16px 0 0;
}

.detail-photo img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  object-fit: cover;
}

.detail-photo figcaption {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.detail-photo a {
  color: var(--blue-dark);
  font-weight: 800;
}

.detail-status {
  display: grid;
  gap: 3px;
  margin-top: 16px;
  border-radius: 8px;
  padding: 12px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 13px;
}

.detail-status.needs-verification {
  border-left: 4px solid var(--gold);
}

.detail-status.is-verified {
  border-left: 4px solid var(--green);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}

.detail-grid div {
  border-radius: 8px;
  padding: 10px;
  background: #edf6f9;
}

.detail-grid dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.detail-grid dd {
  margin: 4px 0 0;
  font-weight: 800;
}

.detail-section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}

.source-list {
  margin: 8px 0 0;
  padding-left: 18px;
}

.source-list a {
  color: var(--blue-dark);
  font-weight: 800;
}

.muted-list-item,
.source-note {
  color: var(--muted);
}

.map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.leaflet-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #e6f2f6;
  font-family: inherit;
}

/*
  Critical Leaflet layout fallback.
  If the external Leaflet stylesheet is blocked or delayed, the JS still runs,
  but map tiles render as scattered image blocks. These local rules keep tiles,
  panes, markers, popups, and controls positioned correctly.
*/
.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,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  display: block;
  max-width: none !important;
  max-height: none !important;
  margin: 0;
  padding: 0;
  border: 0;
}

.leaflet-tile {
  width: 256px;
  height: 256px;
}

.leaflet-tile-container {
  transform-origin: 0 0;
}

.leaflet-map-pane {
  z-index: auto;
}

.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;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  float: left;
  clear: both;
  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;
}

.leaflet-top .leaflet-control {
  margin-top: 10px;
}

.leaflet-left .leaflet-control {
  margin-left: 10px;
}

.leaflet-right .leaflet-control {
  margin-right: 10px;
}

.leaflet-bottom .leaflet-control {
  margin-bottom: 10px;
}

.leaflet-control-zoom {
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  background: #fff;
}

.leaflet-control-zoom a {
  display: block;
  width: 30px;
  height: 30px;
  color: #111;
  line-height: 30px;
  text-align: center;
  text-decoration: none;
  font-size: 18px;
  font-weight: 700;
}

.leaflet-control-zoom a + a {
  border-top: 1px solid #ccc;
}

.leaflet-popup {
  position: absolute;
  margin-bottom: 20px;
  text-align: center;
}

.leaflet-popup-content-wrapper {
  padding: 1px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.25);
}

.leaflet-popup-content {
  min-width: 170px;
  margin: 12px 14px;
  text-align: left;
}

.leaflet-popup-tip-container {
  position: absolute;
  left: 50%;
  width: 40px;
  height: 20px;
  margin-left: -20px;
  overflow: hidden;
  pointer-events: none;
}

.leaflet-popup-tip {
  width: 17px;
  height: 17px;
  margin: -10px auto 0;
  background: #fff;
  transform: rotate(45deg);
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.25);
}

.launch-marker {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 8px 18px rgba(20, 32, 35, 0.28);
  font-size: 14px;
  font-weight: 900;
}

.popup-title {
  margin: 0 0 5px;
  font-size: 15px;
}

.popup-detail {
  margin: 0;
  color: #4b595c;
  line-height: 1.35;
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto minmax(360px, 52dvh) auto;
    grid-template-areas:
      "brand"
      "controls"
      "summary"
      "map"
      "results";
    height: auto;
    min-height: 100dvh;
  }

  .sidebar {
    display: contents;
  }

  .brand {
    grid-area: brand;
    margin: 0;
    padding: 16px 12px 12px;
    background: linear-gradient(180deg, #fbfdff 0%, #eef6f8 100%);
  }

  .controls {
    grid-area: controls;
    margin: 0 12px;
    box-shadow: none;
  }

  .result-summary {
    grid-area: summary;
    margin: 12px 0 8px;
    padding: 0 12px;
  }

  .results {
    grid-area: results;
    padding: 12px;
  }

  .map-panel {
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    min-height: 360px;
  }

  .detail-panel {
    align-items: end;
    justify-items: stretch;
  }

  .detail-card {
    width: 100%;
    max-height: 82dvh;
    height: auto;
    margin: 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 8px 8px 0 0;
  }
}

@media (max-width: 520px) {
  .sidebar {
    padding: 16px 12px;
  }

  .controls {
    grid-template-columns: 1fr;
  }
}
