:root {
  color-scheme: dark;
  --page: #06111a;
  --page-deep: #030b11;
  --surface: rgba(14, 31, 43, 0.86);
  --surface-solid: #0d1d28;
  --surface-soft: rgba(21, 45, 59, 0.68);
  --line: rgba(166, 204, 224, 0.16);
  --line-strong: rgba(166, 204, 224, 0.28);
  --text: #f1f6f8;
  --muted: #9cb2bf;
  --quiet: #6f8998;
  --focus: #93e5ff;
  --danger: #ff8f9a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page-deep);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -20%, rgba(35, 87, 112, 0.26), transparent 42%),
    linear-gradient(180deg, var(--page), var(--page-deep));
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.legend-app {
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: 32px clamp(18px, 3vw, 48px) 52px;
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 26px;
}

.eyebrow {
  margin: 0 0 7px;
  color: #b9d8e7;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 780px;
  margin-bottom: 8px;
  font-size: clamp(1.9rem, 4vw, 4rem);
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 1.02;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 2vw, 2rem);
  font-weight: 400;
}

h3 {
  margin-bottom: 5px;
  font-size: 1.35rem;
  font-weight: 500;
  line-height: 1.15;
}

.intro {
  max-width: 690px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
}

.update-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  color: var(--muted);
  font-size: 0.83rem;
  text-align: right;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #55e49b;
  box-shadow: 0 0 11px rgba(85, 228, 155, 0.8);
}

.update-status.is-stale .status-dot {
  background: #f7bc63;
  box-shadow: 0 0 11px rgba(247, 188, 99, 0.68);
}

.update-status.is-error .status-dot {
  background: var(--danger);
  box-shadow: 0 0 11px rgba(255, 143, 154, 0.7);
}

#refresh-button {
  margin-left: 4px;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

#refresh-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.map-and-detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 340px);
  min-height: 590px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(3, 13, 21, 0.78);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.28);
}

.map-panel {
  position: relative;
  min-height: 590px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(23, 65, 83, 0.23), transparent 60%),
    linear-gradient(180deg, #071722, #041019);
}

#world-map {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 590px;
}

.map-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--quiet);
  pointer-events: none;
}

.map-loading[hidden] {
  display: none;
}

.place-detail {
  padding: 26px 24px;
  border-left: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(19, 40, 53, 0.92), rgba(9, 25, 35, 0.95));
}

.detail-placeholder {
  margin-top: 40%;
  color: var(--quiet);
  text-align: center;
}

.detail-topline,
.detail-reading,
.detail-row,
.motion-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.detail-topline {
  margin-bottom: 18px;
}

.segment-label {
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.large-swatch {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--swatch, #e9ddbd);
  box-shadow: 0 0 28px color-mix(in srgb, var(--swatch, #e9ddbd) 68%, transparent);
}

.large-swatch.scene-swatch {
  background: conic-gradient(from 210deg, #7d4fc1, #38b8d1, #f1bc5f, #7d4fc1);
}

.detail-place {
  color: var(--muted);
}

.detail-reading {
  align-items: end;
  margin: 24px 0 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.temperature {
  font-size: 2.4rem;
  font-weight: 400;
  letter-spacing: -0.04em;
}

.brightness {
  color: var(--muted);
  font-size: 0.86rem;
  text-align: right;
}

.detail-rows {
  display: grid;
  gap: 8px;
}

.detail-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.detail-row span:first-child {
  color: var(--muted);
}

.detail-row span:last-child {
  text-align: right;
}

.why-copy {
  margin: 20px 0 0;
  color: #c2d0d7;
  font-size: 0.9rem;
  line-height: 1.5;
}

.motion-block {
  margin-top: 20px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
}

.motion-heading {
  color: var(--muted);
  font-size: 0.82rem;
}

.motion-heading strong {
  color: var(--text);
  font-weight: 500;
}

.palette {
  display: flex;
  gap: 7px;
  margin-top: 11px;
}

.palette span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--palette-color);
  box-shadow: 0 0 12px color-mix(in srgb, var(--palette-color) 58%, transparent);
}

.event-note {
  margin: 18px 0 0;
  padding: 12px;
  border-left: 2px solid #65ebc1;
  color: #c7f4e6;
  background: rgba(101, 235, 193, 0.07);
  font-size: 0.87rem;
  line-height: 1.45;
}

.place-section {
  margin-top: 36px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 17px;
}

.section-heading > p {
  max-width: 560px;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: right;
}

.place-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.place-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.place-card:hover,
.place-card.is-selected {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.place-card.is-selected {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--card-color, #9fdcf1) 42%, transparent);
}

.card-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--card-color, #e9ddbd);
  box-shadow: 0 0 16px color-mix(in srgb, var(--card-color, #e9ddbd) 55%, transparent);
}

.card-swatch.scene-swatch {
  background: conic-gradient(from 210deg, #7d4fc1, #38b8d1, #f1bc5f, #7d4fc1);
}

.card-copy {
  min-width: 0;
}

.card-city,
.card-condition {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-city {
  font-size: 0.9rem;
  font-weight: 500;
}

.card-condition {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
}

.card-solar {
  display: block;
  width: fit-content;
  margin-top: 5px;
  padding: 3px 6px;
  border: 1px solid rgba(255, 176, 78, 0.52);
  border-radius: 4px;
  color: #ffc777;
  background: rgba(255, 140, 48, 0.1);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.13em;
}

.card-reading {
  color: var(--muted);
  font-size: 0.76rem;
  text-align: right;
  white-space: nowrap;
}

.card-reading span {
  display: block;
}

.card-reading strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 500;
}

.error-message {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 143, 154, 0.35);
  border-radius: 9px;
  color: #ffd0d5;
  background: rgba(255, 143, 154, 0.08);
}

.country {
  fill: #18303e;
  stroke: #284757;
  stroke-width: 0.55;
}

.sphere {
  fill: #06131d;
  stroke: #294654;
  stroke-width: 0.8;
}

.graticule {
  fill: none;
  stroke: rgba(111, 159, 180, 0.13);
  stroke-width: 0.5;
}

.wire-path {
  fill: none;
  stroke: rgba(151, 220, 239, 0.52);
  stroke-width: 1.4;
}

.map-marker {
  cursor: pointer;
}

.map-marker circle {
  stroke: rgba(245, 251, 253, 0.8);
  stroke-width: 1.25;
}

.map-marker.is-selected circle {
  stroke: #ffffff;
  stroke-width: 2.5;
}

.map-marker text {
  fill: var(--text);
  font-size: 10px;
  font-weight: 500;
  paint-order: stroke;
  stroke: rgba(2, 10, 16, 0.95);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.map-marker .marker-index {
  fill: #07121a;
  font-size: 8px;
  stroke: none;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

@media (max-width: 1120px) {
  .place-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .page-header,
  .section-heading {
    align-items: start;
    flex-direction: column;
  }

  .update-status,
  .section-heading > p {
    justify-content: flex-start;
    text-align: left;
  }

  .map-and-detail {
    grid-template-columns: 1fr;
  }

  .map-panel,
  #world-map {
    min-height: 470px;
  }

  .place-detail {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .detail-placeholder {
    margin-top: 0;
  }

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

@media (max-width: 560px) {
  .legend-app {
    padding: 22px 13px 38px;
  }

  .map-and-detail {
    border-radius: 12px;
  }

  .map-panel,
  #world-map {
    min-height: 360px;
  }

  .map-marker text:not(.marker-index) {
    display: none;
  }

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