:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #17201b;
  --muted: #5d665f;
  --panel: #f7f8f4;
  --line: #d8ded2;
  --field: #ffffff;
  --accent: #116b5b;
  --accent-strong: #0c4e44;
  --sun: #e4b92f;
  --rain: #2362b7;
  --danger: #9c3f2d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #e8ece4;
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.shell {
  min-height: 100vh;
  padding: 16px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  min-height: calc(100vh - 32px);
  border: 1px solid var(--line);
  background: #fff;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  min-width: 0;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(35, 98, 183, 0.95), rgba(17, 107, 91, 0.95)),
    radial-gradient(circle at 30% 30%, #fff 0 18%, transparent 19%);
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.readout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  background: #fff;
}

.readout-grid > div {
  min-height: 74px;
  padding: 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.readout-grid > div:nth-child(2n) {
  border-right: 0;
}

.readout-grid > div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.label,
.slider-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.readout-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 17px;
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

button {
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 760;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.about-link {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 6px 10px;
  border-color: var(--line);
  background: #fff;
  color: var(--accent);
  font-size: 13px;
}

.about-modal[hidden] {
  display: none;
}

.about-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 32, 27, 0.52);
}

.about-card {
  width: min(520px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 40px rgba(23, 32, 27, 0.28);
}

.about-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.about-card h2 {
  margin: 0;
  font-size: 20px;
}

.about-card p {
  margin: 0;
  color: var(--ink);
}

.about-card .about-contact {
  margin-top: 14px;
}

.about-card a {
  color: var(--accent);
  font-weight: 760;
}

.about-close {
  min-height: 34px;
  padding: 6px 10px;
}

#frameSlider {
  width: 100%;
  accent-color: var(--accent);
}

#sliderTime {
  float: right;
  color: var(--ink);
  text-transform: none;
}

.coordinate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.coordinate-grid label,
.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.coordinate-grid input,
.field-label select {
  display: block;
  width: 100%;
  min-height: 40px;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
}

.field-label select {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%) right 14px center / 7px 7px no-repeat,
    linear-gradient(135deg, var(--accent) 50%, transparent 50%) right 9px center / 7px 7px no-repeat,
    var(--field);
  padding-right: 34px;
}

.note {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.map-area {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: calc(100vh - 34px);
  min-height: 580px;
  overflow: hidden;
  background: #d9e0d3;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
}

.prediction-overlay {
  position: absolute;
  top: 16px;
  left: 50%;
  z-index: 900;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  align-items: start;
  width: min(620px, calc(100% - 32px));
  min-height: 76px;
  border: 1px solid rgba(23, 32, 27, 0.16);
  border-left: 5px solid var(--accent);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 32px rgba(23, 32, 27, 0.22);
  transform: translateX(-50%);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.prediction-overlay[hidden] {
  display: none;
}

.prediction-message {
  min-width: 0;
  padding: 15px 14px 15px 16px;
  color: var(--ink);
  font-size: 21px;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.prediction-close {
  position: relative;
  width: 36px;
  min-height: 36px;
  margin: 8px 8px 0 0;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.prediction-close:hover,
.prediction-close:focus-visible {
  background: rgba(17, 107, 91, 0.1);
  color: var(--accent-strong);
}

.prediction-close span::before,
.prediction-close span::after {
  position: absolute;
  top: 17px;
  left: 10px;
  width: 16px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  content: "";
}

.prediction-close span::before {
  transform: rotate(45deg);
}

.prediction-close span::after {
  transform: rotate(-45deg);
}

.leaflet-container {
  width: 100%;
  height: 100%;
}

.timeline {
  position: absolute;
  right: 16px;
  bottom: 12px;
  left: 16px;
  display: grid;
  gap: 5px;
  padding: 8px 10px 6px;
  border: 1px solid rgba(23, 32, 27, 0.18);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  z-index: 500;
}

.timeline-track {
  display: grid;
  grid-template-columns: repeat(25, minmax(0, 1fr));
  gap: 2px;
}

.timeline-track span {
  display: block;
  min-height: 10px;
  border-radius: 2px;
  background: #dfe5dc;
}

.timeline-track .rain {
  background: var(--rain);
}

.timeline-track .dry {
  background: #dfe5dc;
}

.timeline-track .now {
  outline: 2px solid var(--sun);
  outline-offset: 0;
}

.timeline-labels {
  display: grid;
  grid-template-columns: repeat(25, minmax(0, 1fr));
  color: #26302b;
  font-size: 10px;
  font-weight: 760;
  line-height: 1;
}

.timeline-labels span {
  justify-self: center;
  text-align: center;
  white-space: nowrap;
}

.timeline-labels span:first-child {
  justify-self: start;
}

.timeline-labels span:last-child {
  justify-self: end;
}

.target-marker {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

.leaflet-control-attribution {
  font-size: 11px;
}

@media (max-width: 840px) {
  .shell {
    padding: 0;
  }

  .workspace {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    border: 0;
  }

  .panel {
    display: contents;
  }

  .app-header,
  .readout-grid,
  .controls,
  .slider-label,
  #frameSlider,
  .field-label,
  .coordinate-grid,
  .note {
    margin-right: 14px;
    margin-left: 14px;
  }

  .app-header {
    order: 1;
    position: relative;
    margin-top: 10px;
    min-height: 42px;
    padding-right: 72px;
  }

  .brand p {
    display: none;
  }

  .brand {
    max-width: 100%;
  }

  .brand h1 {
    font-size: 22px;
    line-height: 1.05;
  }

  .about-link {
    position: absolute;
    top: 4px;
    right: 0;
    width: auto;
    min-height: 32px;
    padding: 5px 8px;
    font-size: 12px;
    line-height: 1;
  }

  .about-card {
    padding: 16px;
  }

  .controls {
    display: contents;
  }

  #locateButton {
    order: 3;
    min-height: 38px;
    margin: 8px 14px 0;
  }

  .slider-label {
    order: 4;
    margin-top: 10px;
    margin-bottom: 2px;
  }

  #frameSlider {
    order: 5;
    margin-top: 0;
    width: auto;
  }

  .map-area {
    order: 2;
    height: min(44vh, 350px);
    min-height: 240px;
    margin-top: 8px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .prediction-overlay {
    top: 10px;
    right: 10px;
    left: auto;
    width: calc(100% - 72px);
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) 34px;
    transform: none;
  }

  .prediction-message {
    padding: 11px 10px 11px 12px;
    font-size: 15px;
    line-height: 1.3;
  }

  .prediction-close {
    width: 34px;
    min-height: 34px;
    margin: 5px 5px 0 0;
  }

  .field-label {
    order: 7;
    margin-top: 14px;
  }

  .readout-grid {
    order: 8;
    margin-top: 14px;
  }

  .coordinate-grid {
    order: 9;
    margin-top: 14px;
  }

  .note {
    order: 10;
    margin-top: 14px;
    margin-bottom: 16px;
  }
}

@media (max-width: 520px) {
  .controls,
  .coordinate-grid,
  .readout-grid {
    grid-template-columns: 1fr;
  }

  .readout-grid > div,
  .readout-grid > div:nth-child(2n),
  .readout-grid > div:nth-last-child(-n + 2) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .readout-grid > div:last-child {
    border-bottom: 0;
  }

  .timeline {
    right: 10px;
    bottom: 10px;
    left: 10px;
    padding: 7px 8px 5px;
  }
}
