:root {
  color-scheme: light;
  --ink: #1c2625;
  --muted: #66716d;
  --paper: rgba(247, 244, 235, 0.94);
  --paper-solid: #f7f4eb;
  --line: rgba(28, 38, 37, 0.14);
  --sun: #ea8e39;
  --sun-deep: #d27024;
  --shadow: #2d3d3a;
  --radius: 18px;
  --small-radius: 11px;
  --deck-shadow: 0 16px 42px rgba(32, 44, 42, 0.18), 0 2px 8px rgba(32, 44, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body, #app, #map { width: 100%; height: 100%; margin: 0; }
body { overflow: hidden; background: #d8ddd5; color: var(--ink); }
button, input, select { font: inherit; }
button, select { color: inherit; }

#map { position: absolute; inset: 0; }
#map canvas { transition: filter 500ms ease; }

#nightVeil {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(21, 31, 52, 0.46), rgba(10, 18, 34, 0.2));
  opacity: 0;
  mix-blend-mode: multiply;
  transition: opacity 500ms ease;
}

.control-deck {
  position: absolute;
  z-index: 5;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  width: min(1120px, calc(100% - 28px));
  transform: translateX(-50%);
  border: 1px solid rgba(255,255,255,.72);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--deck-shadow);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  overflow: visible;
}

.top-row {
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto;
  gap: 22px;
  align-items: center;
  min-height: 72px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.brand-block { display: flex; align-items: center; gap: 11px; min-width: 188px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: #fff7e7;
  background: var(--shadow);
  border-radius: 13px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.brand-mark svg { width: 28px; fill: currentColor; }
.brand-block h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 20px; line-height: 1; letter-spacing: -.02em; }
.brand-block p { margin: 5px 0 0; color: var(--muted); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }

.search {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: 9px;
  height: 44px;
  padding-left: 13px;
  border: 1px solid var(--line);
  border-radius: var(--small-radius);
  background: rgba(255,255,255,.7);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.search:focus-within { border-color: rgba(210,112,36,.65); box-shadow: 0 0 0 3px rgba(234,142,57,.14); }
.search svg { width: 19px; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.search input { min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 14px; }
.search input::placeholder { color: #8a938f; }
.search button {
  align-self: stretch;
  min-width: 48px;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0 var(--small-radius) var(--small-radius) 0;
  background: transparent;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}
.search button:hover { background: rgba(234,142,57,.12); }

.season-field { display: grid; gap: 4px; min-width: 205px; }
.season-field label, .stat-label { color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.season-field select {
  max-width: 230px;
  height: 31px;
  padding: 0 30px 0 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.timeline-row {
  display: grid;
  grid-template-columns: 44px minmax(300px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 13px 16px 11px;
}

.round-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: white;
  background: var(--sun);
  box-shadow: 0 5px 16px rgba(210,112,36,.28);
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease;
}
.round-button:hover { transform: translateY(-1px); background: var(--sun-deep); }
.round-button svg { width: 22px; fill: currentColor; }
.round-button .pause-icon { display: none; }
.round-button.playing .play-icon { display: none; }
.round-button.playing .pause-icon { display: block; }

.timeline { min-width: 0; }
.time-readout { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
#timeOutput { font-family: Georgia, "Times New Roman", serif; font-size: 22px; font-weight: 700; line-height: 1; }
#dateOutput { color: var(--muted); font-size: 12px; font-weight: 650; }

#timeSlider {
  --progress: 41.7%;
  width: 100%;
  height: 7px;
  margin: 3px 0 0;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 20px;
  outline: none;
  background: linear-gradient(90deg, var(--sun) 0 var(--progress), #d9d8cf var(--progress) 100%);
  cursor: pointer;
}
#timeSlider::-webkit-slider-thumb {
  width: 19px; height: 19px; appearance: none; -webkit-appearance: none;
  border: 3px solid var(--paper-solid); border-radius: 50%; background: var(--sun);
  box-shadow: 0 1px 5px rgba(28,38,37,.34);
}
#timeSlider::-moz-range-thumb {
  width: 14px; height: 14px; border: 3px solid var(--paper-solid); border-radius: 50%; background: var(--sun);
  box-shadow: 0 1px 5px rgba(28,38,37,.34);
}
.tick-labels { display: flex; justify-content: space-between; margin-top: 5px; color: #808986; font-size: 9px; font-weight: 650; }

.solar-stats { display: flex; gap: 4px; }
.solar-stats > div { min-width: 79px; padding: 8px 10px; border-left: 1px solid var(--line); }
.solar-stats span { display: block; }
.solar-stats strong { display: block; margin-top: 3px; font-size: 13px; font-variant-numeric: tabular-nums; }

.map-tools {
  position: absolute;
  z-index: 4;
  top: 184px;
  right: 14px;
  display: grid;
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 8px 24px rgba(32,44,42,.16);
  overflow: hidden;
}
.map-tools button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}
.map-tools button:last-child { border: 0; }
.map-tools button:hover { background: rgba(234,142,57,.12); }
.map-tools svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; }

.search-results {
  position: absolute;
  z-index: 8;
  top: 76px;
  left: 50%;
  width: min(510px, calc(100% - 48px));
  transform: translateX(-33%);
  padding: 6px;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 13px;
  background: rgba(250,248,242,.98);
  box-shadow: var(--deck-shadow);
}
.search-result {
  display: block;
  width: 100%;
  padding: 10px 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  font-size: 13px;
  line-height: 1.35;
  cursor: pointer;
}
.search-result:hover, .search-result:focus-visible { background: rgba(234,142,57,.12); outline: 0; }
.search-empty { padding: 13px; color: var(--muted); font-size: 13px; }

.status-toast, .loading {
  position: absolute;
  z-index: 7;
  left: 50%;
  bottom: 69px;
  transform: translateX(-50%);
  padding: 9px 13px;
  border-radius: 999px;
  color: white;
  background: rgba(35,48,46,.91);
  box-shadow: 0 6px 22px rgba(0,0,0,.16);
  font-size: 12px;
  font-weight: 650;
}
.loading { display: flex; align-items: center; gap: 8px; }
.loading span { width: 8px; height: 8px; border-radius: 50%; background: var(--sun); animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(.55); opacity: .5; } }

.map-key {
  position: absolute;
  z-index: 3;
  left: 14px;
  bottom: 42px;
  display: flex;
  gap: 13px;
  padding: 8px 11px;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 11px;
  background: rgba(247,244,235,.88);
  color: var(--muted);
  backdrop-filter: blur(10px);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.map-key span { display: flex; align-items: center; gap: 6px; }
.map-key i { display: inline-block; width: 16px; height: 10px; border-radius: 2px; }
.building-swatch { background: #c68052; }
.shadow-swatch { background: rgba(43,55,52,.65); filter: blur(.3px); }

.credits {
  position: absolute;
  z-index: 3;
  right: 8px;
  bottom: 5px;
  max-width: min(760px, calc(100% - 16px));
  padding: 4px 7px;
  border-radius: 5px;
  background: rgba(247,244,235,.83);
  color: #5f6965;
  font-size: 10px;
  text-align: right;
}
.credits a { color: inherit; }

.maplibregl-ctrl-top-right { top: 184px; right: 55px; }
.maplibregl-ctrl-group { border-radius: 11px !important; box-shadow: 0 8px 24px rgba(32,44,42,.16) !important; overflow: hidden; }
.maplibregl-popup-content { padding: 13px 15px !important; border-radius: 12px !important; box-shadow: var(--deck-shadow) !important; font: 12px/1.45 inherit; }
.building-popup strong { display: block; margin-bottom: 4px; font-family: Georgia, "Times New Roman", serif; font-size: 16px; }
.building-popup span { color: var(--muted); }

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

@media (max-width: 820px) {
  .control-deck { width: calc(100% - 18px); top: max(9px, env(safe-area-inset-top)); }
  .top-row { grid-template-columns: 1fr auto; gap: 10px; padding: 10px; }
  .brand-block { min-width: 0; }
  .brand-block p { display: none; }
  .search { grid-column: 1 / -1; grid-row: 2; }
  .season-field { min-width: 150px; justify-self: end; }
  .season-field select { max-width: 170px; }
  .timeline-row { grid-template-columns: 40px 1fr; gap: 10px; padding: 10px; }
  .solar-stats { grid-column: 1 / -1; justify-content: stretch; }
  .solar-stats > div { flex: 1; padding: 4px 10px 2px; }
  .map-tools, .maplibregl-ctrl-top-right { top: 273px; }
  .search-results { top: 132px; transform: translateX(-50%); }
  .credits { display: none; }
  .map-key { bottom: 8px; }
}

@media (max-width: 480px) {
  .brand-mark { width: 37px; height: 37px; border-radius: 11px; }
  .brand-block h1 { font-size: 18px; }
  .season-field { min-width: 136px; }
  .season-field select { width: 136px; font-size: 12px; }
  #timeOutput { font-size: 20px; }
  .solar-stats strong { font-size: 12px; }
  .maplibregl-ctrl-top-right { display: none; }
  .map-tools { right: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
