:root {
  --olive-dark: #343e29;
  --olive: #526632;
  --sage: #e2e7d5;
  --ground: #f3f2ec;
  --surface: #fafaf7;
  --ink: #252a22;
  --muted: #606657;
  --line: #daddd2;
  --boundary: #d5e58b;
  --measure: #eef6b3;
  --error: #9c3024;
  --radius: .6rem;
  --space: .75rem;
  --shadow: 0 2px 12px #252a2229;
  font-family: system-ui, sans-serif;
  color: var(--ink);
  background: var(--ground);
}
body { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--olive); outline-offset: 2px; }
a { color: var(--olive); }
.login {
  max-width: 24rem;
  margin: 8vh auto;
  padding: 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
}
.login label { display: block; }
.login input { width: 100%; }
button, select, textarea, input { font: inherit; }
button, select, textarea, input:not([type="checkbox"], [type="range"]) {
  box-sizing: border-box;
  padding: .45rem .6rem;
  border: 1px solid #b9bfaf;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
button, summary { cursor: pointer; }
button:not(:disabled):hover { background: var(--sage); }
button:disabled { cursor: default; opacity: .65; }
.primary, button[aria-pressed="true"] { background: var(--olive); color: white; border-color: var(--olive); }
.primary:not(:disabled):hover, button[aria-pressed="true"]:not(:disabled):hover { background: var(--olive-dark); }
input:is([type="checkbox"], [type="range"]) { accent-color: var(--olive); }
.icon {
  flex: none;
  width: 1.2em;
  height: 1.2em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -.2em;
}
.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100dvh;
  font-size: .9rem;
}
.app-header {
  position: relative;
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .55rem 1rem;
  background: var(--olive-dark);
  color: var(--surface);
}
.app-header :focus-visible { outline-color: var(--boundary); }
.wordmark {
  display: flex;
  align-items: center;
  gap: .4rem;
  font: 700 1.5rem Georgia, serif;
  white-space: nowrap;
}
.app-header h1 { min-width: 0; font-size: 1rem; margin: 0; overflow-wrap: anywhere; }
.district-header { display: flex; align-items: center; gap: .45rem; min-width: 0; }
#district-edit { color: inherit; background: transparent; border-color: #ffffff55; }
#district-edit:is(:hover, [aria-pressed="true"]) { background: #ffffff20; }
.panel-toggles { display: flex; gap: .45rem; margin-inline-start: auto; }
.panel-toggles button {
  color: inherit;
  background: transparent;
  border-color: #ffffff55;
}
.panel-toggles button:hover, .panel-toggles button[aria-expanded="true"] { background: #ffffff20; }
.account { position: relative; }
.account form {
  position: absolute;
  right: 0;
  top: calc(100% + .5rem);
  display: grid;
  gap: .5rem;
  min-width: 8rem;
  max-width: 18rem;
  overflow-wrap: anywhere;
  padding: var(--space);
  color: var(--ink);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.account form :focus-visible { outline-color: var(--olive); }
.map-workspace { display: flex; min-height: 0; gap: .5rem; padding: .5rem; }
.side-panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
#tool-panel { flex: 0 0 clamp(13rem, 18vw, 17rem); overflow: auto; }
#context-panel { flex: 0 0 clamp(18rem, 25vw, 23rem); display: grid; grid-template-rows: repeat(2, minmax(0, 1fr)); }
#context-views { min-width: 0; overflow: auto; }
.panel-section { padding: var(--space); }
.panel-section + .panel-section, .tapio { border-top: 1px solid var(--line); }
.panel-section h2, dialog h2 {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin: 0 0 .55rem;
  font-size: 1rem;
  overflow-wrap: anywhere;
}
.panel-section h2 .icon { color: var(--olive); }
.map-layers select { width: 100%; margin-block: .35rem .65rem; }
.map-layers fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.map-layers legend { font-weight: 600; margin-bottom: .3rem; padding: 0; }
.map-layers .layer-row {
  display: grid;
  grid-template-columns: 1rem 1.2rem minmax(0, 1fr);
  align-items: center;
  gap: .3rem;
  margin-block: .35rem;
  min-height: 1.35rem;
}
.layer-row > input { grid-column: 1; grid-row: 1; margin: 0; }
.layer-row > svg { grid-column: 2; grid-row: 1; justify-self: center; }
.layer-row > span { grid-column: 3; grid-row: 1; }
.layer-row small { color: var(--muted); }
.layer-tree { position: relative; }
#facility-all { position: absolute; top: .2rem; left: 0; margin: 0; }
summary.layer-row::-webkit-details-marker { display: none; }
details[open] > summary .tree-chevron { transform: rotate(90deg); }
.map-layers ul { margin: .35rem 0; padding: 0; list-style: none; }
.button-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.status-bar { min-height: 1.3em; padding: .3rem 1rem; background: var(--surface); border-top: 1px solid var(--line); }
.status-bar span:not(:empty), .status-bar button { margin-inline-end: .75rem; }
.status-bar button { padding-block: .2rem; }
#district-name-form { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .25rem; margin: .2rem .5rem .2rem 0; }
#district-name-form button { margin: 0; }
#district-name-form input { max-width: 45vw; padding-block: .2rem; }
#draft-status { font-weight: 600; }
#map-error, #facility-error, .danger { color: var(--error); }
.map-stage { position: relative; flex: 1; min-width: 0; isolation: isolate; }
#map { position: absolute; inset: 0; border-radius: var(--radius); background: #dce2d3; }
#map:focus-visible { outline-offset: -3px; }
.district-boundary, .measurement { filter: drop-shadow(0 0 1px #202713) drop-shadow(0 1px 1px #202713); }
.leaflet-district-mask-pane { z-index: 325; pointer-events: none; }
.district-mask {
  position: absolute;
  inset: 0 auto auto 0;
  background: #34363840;
  backdrop-filter: saturate(.42) brightness(.82);
}
.leaflet-container .leaflet-control-scale-line { color: white; background: #252a22e8; border-color: white; text-shadow: none; }
#map .leaflet-control-attribution { max-width: 65%; text-align: right; }
#map-context {
  position: absolute;
  z-index: 1100;
  max-width: 100%;
  max-height: 100%;
  overflow: auto;
  background: var(--surface);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: .25rem;
  box-sizing: border-box;
}
#map-context button { display: flex; align-items: center; gap: .45rem; width: 100%; text-align: left; border-color: transparent; }
#map-context button:focus-visible { outline-offset: -2px; }
#map.map-placing, #map.map-placing .leaflet-interactive { cursor: crosshair; }
#map.map-placing .facility-marker { pointer-events: none; }
#map .facility-marker {
  display: grid;
  place-items: center;
  color: white;
  font-size: 15px;
  isolation: isolate;
}
.facility-marker::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 1px 1px 2px;
  transform: rotate(-45deg);
  border: 2px solid white;
  border-radius: 50% 50% 50% .25rem;
  background: var(--olive);
  box-shadow: 0 0 0 1px var(--ink), 0 2px 4px #0009;
}
.facility-marker.is-selected::before {
  background: var(--olive-dark);
  border-color: var(--boundary);
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--boundary);
}
#discard-dialog {
  box-sizing: border-box;
  padding: 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: min(25rem, calc(100% - 2rem));
}
#discard-dialog::backdrop { background: #252a2266; }
#point-weather-back, #facility-close { margin-bottom: .7rem; }
#facility-description { overflow-wrap: anywhere; white-space: pre-wrap; }
#facility-form fieldset { min-width: 0; padding: 0; margin: 0; border: 0; }
#facility-form label, #facility-kind { display: block; margin-bottom: .55rem; }
#facility-form :is(input, select, textarea) { display: block; width: 100%; margin-top: .2rem; }
#facility-error:empty, #facility-copy-status:empty { display: none; }
.weather p { margin: .2rem 0; }
.weather { container-type: inline-size; }
.weather-heading { display: inline-flex; align-items: center; gap: .4rem; padding: 0; border: 0; font-weight: inherit; text-align: start; }
.weather-overview { display: grid; grid-template-columns: 1fr 1.15fr auto; align-items: start; gap: .4rem; margin-bottom: .6rem; }
.weather-current, .weather-wind > div { display: flex; align-items: center; gap: .25rem; }
.weather-current { flex-wrap: wrap; line-height: 1.15; font-size: .78rem; }
.weather .weather-temperature { font-size: clamp(1.25rem, 6.5cqw, 1.9rem); white-space: nowrap; font-weight: 700; }
.weather-icon { display: block; color: var(--olive); width: 2.15rem; height: 2.15rem; }
.weather-current .weather-icon { width: 2.45rem; height: 2.45rem; }
.weather-wind { border-inline-start: 1px solid var(--line); padding-inline-start: .4rem; font-size: .7rem; line-height: 1.2; }
.weather-wind > div p { white-space: nowrap; }
.weather-probability small { display: block; color: var(--muted); }
.weather-probability .icon { color: var(--olive); }
.weather button:is(.weather-moon, .weather-event, .weather-hour), .weather-event {
  background: var(--ground); border: 1px solid transparent; border-radius: var(--radius);
}
.weather button:is(.weather-moon, .weather-event, .weather-hour):is(:hover, [aria-expanded="true"]) { background: var(--sage); }
.weather-moon { display: grid; justify-items: center; gap: .2rem; max-width: 5.2rem; padding: .35rem .25rem; font-size: .68rem; font-weight: 600; }
.weather-moon svg { width: 2.25rem; height: 2.25rem; }
.moon-disc { fill: var(--olive-dark); }
.moon-disc.moon-unknown { fill: none; stroke: var(--muted); stroke-dasharray: 2 2; }
.moon-light { fill: var(--surface); stroke: var(--olive-dark); stroke-width: .5; }
.wind-dial { display: block; flex: none; width: 1.4rem; fill: none; stroke: var(--olive); stroke-width: 1.6; stroke-linejoin: round; }
.wind-rose { width: clamp(2rem, 13cqw, 3rem); }
.wind-rose circle { stroke: var(--line); stroke-width: 1; }
.wind-rose text { fill: var(--ink); stroke: none; font-size: 7px; text-anchor: middle; }
.wind-arrow path:first-child { fill: var(--olive); }
.weather-events { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .28rem; list-style: none; padding: 0; margin: 0; }
.weather-event { box-sizing: border-box; display: grid; justify-items: center; align-content: start; gap: .15rem; width: 100%; height: 100%; text-align: center; padding: .4rem .15rem; font-size: .72rem; overflow-wrap: anywhere; }
.weather-event time { color: var(--muted); }
.weather-event b { font-size: 1rem; }
.weather-event-wind { display: flex; align-items: center; gap: .1rem; }
.weather-strip {
  display: flex;
  gap: .25rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  margin: .35rem 0 0;
  padding: .25rem .15rem;
  list-style: none;
}
.weather-strip li { flex: 0 0 auto; }
.weather-hour { display: grid; justify-items: center; gap: .1rem; min-width: 3.5rem; padding: .28rem .4rem; font-size: .72rem; }
.weather-hour .weather-icon { width: 1.45rem; height: 1.45rem; }
.weather-strip button:focus-visible { outline-offset: -2px; }
.weather .weather-credit { margin: .2rem 0 0; text-align: end; font-size: .68rem; color: var(--muted); }
.weather-credit a { color: inherit; }
.weather-note { position: fixed; inset: auto; margin: 0; box-sizing: border-box; max-width: min(19rem, calc(100vw - 16px)); padding: .45rem .6rem; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: var(--surface); font-size: .78rem; }
.weather-note small { display: block; color: var(--muted); }
@container (max-width: 16rem) {
  .weather-overview { grid-template-columns: 1fr auto; }
  .weather-wind { grid-row: 2; grid-column: 1 / -1; display: flex; align-items: center; gap: .6rem; border: 0; padding: 0; }
}
.tapio { min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: .45rem; }
.tapio-heading h2 { margin: 0; }
.tapio-heading span, .tapio-thread small { color: var(--muted); }
.tapio-thread { overflow: auto; padding-inline: .2rem; }
.tapio-thread p { margin: .4rem .15rem .55rem 0; padding: .5rem .65rem; border-radius: var(--radius); background: var(--ground); }
.tapio-thread .tapio-question { margin-left: 1rem; background: var(--sage); }
.tapio-compose { display: flex; gap: .35rem; }
.tapio-compose input { width: 0; flex: 1; }
#precipitation-controls {
  position: absolute;
  z-index: 900;
  left: .65rem;
  bottom: 2.35rem;
  box-sizing: border-box;
  width: min(21rem, calc(100% - 1.3rem));
  max-height: 65%;
  overflow: auto;
  padding: .6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: .8rem;
}
#precipitation-controls p { margin: .25rem 0; }
#precipitation-controls p:empty { display: none; }
#precipitation-controls button { margin-top: .35rem; }
#precipitation-time { display: block; width: 100%; margin: 0; }
.radar-times { display: grid; grid-template-columns: 1fr 1fr 4fr; font-size: .85em; }
.radar-times span:nth-child(2) { justify-self: end; transform: translateX(50%); white-space: nowrap; }
.radar-times span:last-child { justify-self: end; }
@media (max-width: 69.99rem) {
  .workspace { height: auto; min-height: 100dvh; grid-template-rows: auto 1fr auto; }
  .map-workspace { flex-wrap: wrap; }
  .map-stage { min-height: max(24rem, 75dvh); }
  #context-panel { flex: 0 0 100%; box-sizing: border-box; grid-template-rows: auto auto; }
  .tapio-thread { max-height: 10rem; }
  .status-bar { position: sticky; bottom: 0; z-index: 1100; }
}
@media (max-width: 47.99rem) {
  .app-header { gap: .6rem; flex-wrap: wrap; }
  .wordmark { font-size: 1.2rem; }
  .panel-toggles { order: 1; width: 100%; margin: 0; }
  .account { margin-inline-start: auto; }
  .map-workspace { flex-direction: column; }
  #tool-panel, #context-panel { flex: auto; }
  .map-stage { flex: none; min-height: max(20rem, 60dvh); }
  .tapio { display: none; }
}
