:root {
  color-scheme: dark;
  --bg: #071824;
  --panel: #ffffff;
  --panel-ink: #17212b;
  --muted: #687583;
  --line: #d8e1e5;
  --soft-line: #e9eef1;
  --ocean: #0a2b42;
  --ocean-deep: #061b2a;
  --teal: #0f766e;
  --teal-soft: #e7f5f3;
  --blue: #2563eb;
  --amber: #f59e0b;
  --danger: #c2413a;
  --shadow: 0 18px 55px rgba(0, 17, 27, 0.2);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: #f6fbff;
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
p,
dl,
dd {
  margin: 0;
}

.weather-app {
  display: grid;
  grid-template-columns: minmax(312px, 372px) minmax(0, 1fr);
  min-height: 100vh;
}

.control-panel {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
  padding: 26px;
  background: var(--panel);
  color: var(--panel-ink);
  box-shadow: var(--shadow);
}

.brand-row,
.brand,
.section-heading,
.forecast-card-heading,
.map-toolbar,
.toolbar-status,
.range-heading,
.range-labels,
.playback-controls {
  display: flex;
  align-items: center;
}

.brand-row,
.section-heading,
.forecast-card-heading,
.map-toolbar,
.range-heading,
.range-labels {
  justify-content: space-between;
}

.brand-row {
  gap: 10px;
}

.brand {
  gap: 11px;
  min-width: 0;
}

.brand > span:last-child {
  display: grid;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  background: linear-gradient(145deg, #0e8290, #0b425e);
  color: #ffffff;
  font-size: 12px;
  font-weight: 850;
  box-shadow: inset 0 -10px 20px rgba(0, 0, 0, 0.14);
}

.brand strong,
.brand small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand strong {
  font-size: 16px;
}

.brand small {
  color: var(--muted);
  font-size: 11px;
}

.home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 68px;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  transition: border-color 0.18s ease, color 0.18s ease;
}

.home-link:hover,
.home-link:focus-visible {
  border-color: var(--teal);
  color: var(--teal);
  outline: none;
}

.layer-section {
  display: grid;
  gap: 14px;
}

.section-heading {
  gap: 16px;
}

.section-heading > div {
  display: grid;
  gap: 3px;
}

.section-heading p,
.forecast-card-heading span,
.source-card span,
.source-card small,
.notice-copy,
.forecast-meta dt {
  color: var(--muted);
}

.section-heading p,
.forecast-card-heading span,
.source-card span,
.forecast-meta dt {
  font-size: 11px;
  font-weight: 750;
}

h1 {
  font-size: 18px;
  line-height: 1.25;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

.live-badge {
  padding: 4px 8px;
  border-radius: 999px;
  background: #e8f7ef;
  color: #16784a;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.layer-tabs {
  display: grid;
  gap: 9px;
}

.layer-tab {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 68px;
  padding: 11px 13px;
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
  background: #f8fafb;
  color: var(--panel-ink);
  text-align: left;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.layer-tab:hover,
.layer-tab:focus-visible {
  border-color: #91c2bd;
  outline: none;
  transform: translateY(-1px);
}

.layer-tab.is-active {
  border-color: var(--teal);
  background: var(--teal-soft);
  box-shadow: inset 3px 0 var(--teal);
}

.layer-tab > span:last-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.layer-tab strong {
  font-size: 14px;
}

.layer-tab small {
  color: var(--muted);
  font-size: 11px;
}

.tab-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: #e8eff8;
}

.rain-icon::before {
  width: 20px;
  height: 10px;
  border-radius: 10px;
  background: #3a83e7;
  box-shadow: -5px 5px 0 -3px #3a83e7, 5px 5px 0 -3px #3a83e7;
  content: "";
}

.rain-icon::after {
  position: absolute;
  bottom: 6px;
  width: 3px;
  height: 7px;
  border-radius: 999px;
  background: #28a5d8;
  box-shadow: -7px 1px #28a5d8, 7px 1px #28a5d8;
  content: "";
}

.forecast-icon::before {
  width: 19px;
  height: 19px;
  border: 2px solid #5a6cc7;
  border-radius: 999px;
  content: "";
}

.forecast-icon::after {
  position: absolute;
  width: 7px;
  height: 7px;
  border-left: 2px solid #5a6cc7;
  border-bottom: 2px solid #5a6cc7;
  transform: translate(1px, -1px);
  content: "";
}

.wind-icon::before,
.wind-icon::after {
  position: absolute;
  height: 8px;
  border-top: 2px solid #147f78;
  border-radius: 50%;
  content: "";
}

.wind-icon::before {
  width: 23px;
  transform: translateY(-4px);
}

.wind-icon::after {
  width: 17px;
  transform: translate(3px, 5px);
}

.forecast-card,
.source-card {
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.forecast-card {
  display: grid;
  gap: 15px;
  padding: 15px;
}

.forecast-card-heading {
  gap: 12px;
}

.forecast-card-heading > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.forecast-card-heading h2 {
  font-size: 15px;
}

.icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #ffffff;
  color: var(--teal);
  font-size: 21px;
  font-weight: 700;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--teal);
  outline: none;
}

.forecast-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.forecast-meta div:last-child {
  grid-column: 1 / -1;
}

.forecast-meta div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 9px;
  border-radius: 8px;
  background: #eef4f5;
}

.forecast-meta dd {
  min-width: 0;
  font-size: 12px;
  font-weight: 760;
  line-height: 1.35;
  overflow-wrap: anywhere;
  white-space: normal;
}

.source-card {
  display: grid;
  gap: 3px;
  padding: 14px;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.source-card:hover,
.source-card:focus-visible {
  border-color: var(--teal);
  background: #f1faf8;
  outline: none;
}

.source-card strong {
  font-size: 15px;
}

.source-card small,
.notice-copy,
.copyright {
  font-size: 11px;
}

.notice-copy {
  line-height: 1.6;
}

.boundary-attribution {
  margin-top: -8px;
}

.boundary-attribution a {
  color: #8bdce5;
  text-underline-offset: 2px;
}

.copyright {
  margin-top: auto;
  color: var(--muted);
}

.map-workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 5%, rgba(28, 113, 131, 0.25), transparent 30%),
    linear-gradient(160deg, #0b2637 0%, #071a29 58%, #06141e 100%);
}

.map-toolbar {
  gap: 18px;
  min-height: 86px;
  padding: 20px 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.11);
  background: rgba(7, 24, 36, 0.72);
  backdrop-filter: blur(14px);
}

.map-toolbar > div:first-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.map-toolbar h2 {
  font-size: 22px;
}

.eyebrow {
  color: #70c7cf;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.toolbar-status {
  justify-content: flex-end;
  gap: 8px;
  color: #b8c8d2;
  font-size: 12px;
  text-align: right;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #42d392;
  box-shadow: 0 0 0 4px rgba(66, 211, 146, 0.12);
}

.status-dot.is-loading {
  background: #f7b955;
  box-shadow: 0 0 0 4px rgba(247, 185, 85, 0.12);
  animation: pulse 1s infinite alternate;
}

.status-dot.is-error {
  background: #ee736c;
  box-shadow: 0 0 0 4px rgba(238, 115, 108, 0.12);
}

.map-stage {
  position: relative;
  display: grid;
  min-height: 0;
  padding: 22px 88px 22px 28px;
  overflow: hidden;
}

.map-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 520px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: var(--ocean-deep);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.35);
  isolation: isolate;
  overflow: hidden;
}

.map-engine {
  position: absolute;
  inset: 0;
  z-index: 0;
}

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

.google-map {
  background: #cbd9df;
}

.weather-layer-picker {
  position: absolute;
  left: 10px;
  top: 44px;
  z-index: 10;
  display: grid;
  gap: 7px;
}

.weather-layer-picker[hidden] {
  display: none;
}

.weather-type-button {
  min-width: 104px;
  height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  background: rgba(20, 99, 222, 0.9);
  color: #ffffff;
  font-size: 12px;
  font-weight: 760;
  text-align: center;
  box-shadow: 0 7px 20px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(6px);
}

.weather-type-button:hover,
.weather-type-button:focus-visible {
  border-color: #ffffff;
  outline: none;
}

.weather-type-button.is-active {
  background: #075985;
  box-shadow: inset 3px 0 #67e8f9, 0 7px 20px rgba(0, 0, 0, 0.24);
}

.location-button {
  position: absolute;
  right: 10px;
  top: 108px;
  z-index: 10;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: #ffffff;
  color: #3c4043;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.location-button span,
.location-button span::before,
.location-button span::after {
  display: block;
  border-radius: 999px;
}

.location-button span {
  position: relative;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
}

.location-button span::before {
  position: absolute;
  inset: 4px;
  content: "";
  background: currentColor;
}

.location-button span::after {
  position: absolute;
  left: 7px;
  top: -6px;
  width: 2px;
  height: 26px;
  content: "";
  background: currentColor;
  box-shadow: -8px 8px 0 -0.2px currentColor, 8px 8px 0 -0.2px currentColor;
  clip-path: polygon(0 0, 100% 0, 100% 27%, 0 27%, 0 73%, 100% 73%, 100% 100%, 0 100%);
}

.location-button:hover,
.location-button:focus-visible {
  color: #0f766e;
  outline: 2px solid #0f766e;
  outline-offset: 2px;
}

.location-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.location-button.is-locating span {
  animation: pulse 0.65s infinite alternate;
}

.coverage-note {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 9;
  padding: 5px 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(5, 24, 36, 0.74);
  color: rgba(222, 239, 243, 0.78);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: -0.01em;
  pointer-events: none;
  backdrop-filter: blur(4px);
}

.loading-overlay,
.error-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  padding: 26px;
  background: rgba(5, 24, 36, 0.82);
  text-align: center;
  backdrop-filter: blur(5px);
}

.loading-overlay[hidden],
.error-overlay[hidden] {
  display: none;
}

.loading-overlay small,
.error-overlay p {
  color: #b8c8d2;
  font-size: 12px;
}

.spinner {
  width: 34px;
  height: 34px;
  margin-bottom: 5px;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: #64d5dc;
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.error-overlay button {
  min-width: 104px;
  height: 38px;
  margin-top: 7px;
  border: 0;
  border-radius: 8px;
  background: #ffffff;
  color: #153445;
  font-weight: 780;
}

.legend {
  position: absolute;
  right: 24px;
  top: 50%;
  z-index: 4;
  display: grid;
  gap: 9px;
  width: 72px;
  padding: 12px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(5, 24, 36, 0.76);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.22);
  transform: translateY(-50%);
  backdrop-filter: blur(10px);
}

.legend strong {
  font-size: 10px;
  text-align: center;
}

.legend-list {
  display: grid;
  gap: 5px;
}

.legend-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  color: #c7d5dd;
  font-size: 9px;
}

.legend-color {
  width: 12px;
  height: 9px;
  border-radius: 2px;
}

.timeline-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(160px, 220px);
  align-items: center;
  gap: 22px;
  min-height: 112px;
  padding: 18px 28px;
  border-top: 1px solid rgba(255, 255, 255, 0.11);
  background: rgba(7, 24, 36, 0.86);
  backdrop-filter: blur(14px);
}

.radar-transparency-control {
  display: grid;
  gap: 9px;
  min-width: 0;
  padding-left: 20px;
  border-left: 1px solid rgba(255, 255, 255, 0.11);
}

.radar-transparency-control[hidden] {
  display: none;
}

.radar-transparency-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #b8c8d2;
  font-size: 11px;
}

.radar-transparency-heading output {
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

#radarTransparencyRange {
  width: 100%;
  accent-color: #35c0bd;
  cursor: pointer;
}

.playback-controls {
  gap: 8px;
}

.timeline-button,
.play-button {
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.timeline-button {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 19px;
}

.play-button {
  width: 50px;
  height: 50px;
  border-radius: 999px;
  background: var(--teal);
  font-size: 16px;
  box-shadow: 0 8px 24px rgba(15, 118, 110, 0.35);
}

.timeline-button:hover,
.timeline-button:focus-visible,
.play-button:hover,
.play-button:focus-visible {
  border-color: #7bdddc;
  outline: none;
}

.range-control {
  display: grid;
  gap: 9px;
  min-width: 0;
}

.range-heading {
  gap: 10px;
  color: #b8c8d2;
  font-size: 11px;
}

.range-heading output {
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
}

#leadRange {
  width: 100%;
  accent-color: #35c0bd;
  cursor: pointer;
}

.range-labels {
  gap: 10px;
  color: #8095a4;
  font-size: 10px;
}

#selectedValidText {
  overflow: hidden;
  color: #c7d5dd;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  to { opacity: 0.45; }
}

@media (max-width: 920px) {
  .weather-app {
    grid-template-columns: 1fr;
  }

  .control-panel {
    gap: 18px;
    padding: 20px;
    box-shadow: 0 12px 30px rgba(0, 17, 27, 0.16);
  }

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

  .layer-tab {
    grid-template-columns: 1fr;
    justify-items: center;
    min-height: 100px;
    text-align: center;
  }

  .layer-tab.is-active {
    box-shadow: inset 0 -3px var(--teal);
  }

  .forecast-card,
  .source-card,
  .notice-copy,
  .copyright {
    display: none;
  }

  .map-workspace {
    min-height: 760px;
  }

  .map-stage {
    min-height: 520px;
  }
}

@media (max-width: 620px) {
  .control-panel {
    padding: 16px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .section-heading {
    align-items: end;
  }

  .section-heading h1 {
    font-size: 16px;
  }

  .layer-tabs {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    overflow: visible;
  }

  .layer-tab {
    grid-template-columns: 32px minmax(104px, 1fr);
    justify-items: stretch;
    width: 100%;
    min-height: 62px;
    padding: 9px 11px;
    text-align: left;
  }

  .layer-tab > span:last-child {
    align-self: center;
  }

  .tab-icon {
    width: 32px;
    height: 32px;
  }

  .map-workspace {
    min-height: 680px;
  }

  .map-toolbar {
    display: grid;
    align-items: start;
    justify-content: stretch;
    gap: 8px;
    min-height: 94px;
    padding: 16px;
  }

  .map-toolbar h2 {
    font-size: 18px;
  }

  .toolbar-status {
    justify-content: flex-start;
    max-width: none;
    font-size: 10px;
    text-align: left;
  }

  .map-stage {
    min-height: 450px;
    padding: 14px 66px 14px 14px;
  }

  .map-viewport {
    width: 100%;
    height: 520px;
    min-height: 520px;
  }

  .location-button {
    top: 108px;
  }

  .weather-layer-picker {
    top: 40px;
    gap: 5px;
  }

  .weather-type-button {
    min-width: 88px;
    height: 36px;
    padding: 0 10px;
    font-size: 10px;
  }

  .legend {
    right: 7px;
    width: 57px;
    padding: 9px 7px;
  }

  .legend-row {
    grid-template-columns: 10px minmax(0, 1fr);
    gap: 4px;
    font-size: 8px;
  }

  .legend-color {
    width: 10px;
  }

  .timeline-panel {
    grid-template-columns: 1fr;
    gap: 13px;
    padding: 14px 16px 18px;
  }

  .playback-controls {
    justify-content: center;
    order: 3;
  }

  .radar-transparency-control {
    order: 2;
    padding-left: 0;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.11);
    border-left: 0;
  }
}

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