:root {
  --bg: #0b1220;
  --bg-elev: #121b2e;
  --ink: #e8edf6;
  --ink-dim: #9aa8c0;
  --border: #26324a;
  --accent: #7dd3fc;
  --sphere: #0e1830;
  --graticule: #1c2740;
  --shadow: rgba(0, 0, 0, 0.45);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fb;
    --bg-elev: #ffffff;
    --ink: #1a2233;
    --ink-dim: #5b6784;
    --border: #dbe1ee;
    --accent: #0369a1;
    --sphere: #e6ecf7;
    --graticule: #d3dcee;
    --shadow: rgba(30, 41, 68, 0.15);
  }
}

* { box-sizing: border-box; }

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

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--accent); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.subtitle {
  margin: 0.15rem 0 0;
  color: var(--ink-dim);
  font-size: 0.85rem;
  max-width: 46ch;
}

.search-wrap { position: relative; width: min(320px, 100%); }

#search {
  width: 100%;
  padding: 0.55rem 0.8rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--ink);
  font-size: 0.9rem;
  outline: none;
}

#search:focus { border-color: var(--accent); }

.search-results {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  right: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  box-shadow: 0 10px 30px var(--shadow);
  max-height: 320px;
  overflow-y: auto;
  z-index: 30;
}

.search-results.hidden { display: none; }

.search-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.8rem;
  cursor: pointer;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.search-item:last-child { border-bottom: none; }
.search-item:hover, .search-item.active { background: rgba(125, 211, 252, 0.12); }

.search-item .name { color: var(--ink); }
.search-item .meta { color: var(--ink-dim); font-size: 0.78rem; white-space: nowrap; }

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.5rem 0.5rem;
  gap: 0.75rem;
  min-height: 0;
}

#map-wrap {
  position: relative;
  flex: 1;
  min-height: 320px;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--bg-elev);
  overflow: hidden;
}

#map { width: 100%; height: 100%; display: block; cursor: grab; }
#map:active { cursor: grabbing; }

.sphere { fill: var(--sphere); }
.graticule { fill: none; stroke: var(--graticule); stroke-width: 0.5; }

.tz-region {
  stroke: var(--bg-elev);
  stroke-width: 0.6;
  transition: filter 0.1s ease, stroke-width 0.1s ease;
  cursor: pointer;
}

.tz-region:hover,
.tz-region.active {
  filter: brightness(1.25) saturate(1.15);
  stroke: var(--ink);
  stroke-width: 1.1;
}

.tz-region.legend-match {
  stroke: var(--ink);
  stroke-width: 1.2;
}

.map-hint {
  position: absolute;
  left: 0.75rem;
  bottom: 0.6rem;
  font-size: 0.72rem;
  color: var(--ink-dim);
  background: var(--shadow);
  padding: 0.2rem 0.5rem;
  border-radius: 0.4rem;
  pointer-events: none;
}

.tooltip {
  position: fixed;
  z-index: 40;
  width: 300px;
  max-width: calc(100vw - 2rem);
  max-height: 70vh;
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  box-shadow: 0 16px 40px var(--shadow);
  padding: 0.85rem 0.9rem;
  pointer-events: none;
}

.tooltip.pinned { pointer-events: auto; }
.tooltip.hidden { display: none; }

.tooltip-head {
  padding-right: 1.2rem; /* room for the close button on pinned tooltips */
}

.tt-title-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.tt-abbrev { font-weight: 700; font-size: 1.05rem; }
.tt-offset { color: var(--accent); font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.tt-fullname { font-size: 0.8rem; color: var(--ink); }
.tt-zone { margin-top: 0.15rem; font-size: 0.72rem; color: var(--ink-dim); }

.tt-variants {
  margin-top: 0.3rem;
  font-size: 0.72rem;
  color: var(--ink-dim);
  line-height: 1.4;
}

.tt-variants:empty { display: none; }
.tt-variants b { color: var(--ink); font-weight: 600; }

.tt-clock {
  margin-top: 0.35rem;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.tt-section { margin-top: 0.55rem; }

.tt-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  margin-bottom: 0.2rem;
}

.tt-list { font-size: 0.82rem; color: var(--ink); line-height: 1.4; }

.tt-close {
  display: none;
  position: absolute;
  top: 0.4rem;
  right: 0.5rem;
  border: none;
  background: none;
  color: var(--ink-dim);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}

.tooltip.pinned .tt-close { display: block; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.5rem;
  padding: 0.7rem 0.2rem 1rem;
  font-size: 0.72rem;
  color: var(--ink-dim);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.4rem;
  border-radius: 0.35rem;
  cursor: default;
}

.legend-item:hover { background: rgba(125, 211, 252, 0.1); color: var(--ink); }

.legend-swatch {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 0.15rem;
  flex: none;
}

footer {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
  padding: 0.75rem 1.5rem 1rem;
  font-size: 0.72rem;
  color: var(--ink-dim);
  border-top: 1px solid var(--border);
}
