:root {
  color-scheme: light;
  --ink: #172126;
  --muted: #617078;
  --line: #d7dedc;
  --paper: #ffffff;
  --panel: #f7faf8;
  --wash: #e8eeeb;
  --blue: #2365a5;
  --cyan: #148c9a;
  --green: #4b875f;
  --gold: #d59a2d;
  --orange: #c8662f;
  --rose: #9b456f;
  --deep: #24313a;
  --shadow: 0 12px 32px rgba(23, 33, 38, 0.14);
}

/* UX exploration: a quiet control panel around a full-height cartographic workspace. */

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--wash);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select,
input {
  font: inherit;
}

button {
  color: inherit;
}

h1,
h2,
p {
  margin: 0;
}

.topbar {
  min-height: 72px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.brand {
  min-width: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.08;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.status {
  padding: 7px 10px;
  border: 1px solid #b9d7d1;
  border-radius: 6px;
  color: #195c58;
  background: #e9f6f3;
  font-size: 13px;
  white-space: nowrap;
}

.appShell {
  height: calc(100vh - 110px);
  min-height: 620px;
  display: grid;
  grid-template-columns: 374px minmax(0, 1fr);
}

.appShell.panelCollapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.appShell.panelCollapsed .sidebar {
  padding: 0;
  border-right: 0;
  overflow: hidden;
}

.sidebar {
  min-width: 0;
  overflow: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 14px;
}

.drawerClose {
  display: none;
}

.controlSection {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.controlSection:first-child {
  padding-top: 0;
}

.controlSection:last-child {
  border-bottom: 0;
}

.sectionTitle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.sectionTitle svg {
  width: 17px;
  height: 17px;
  color: var(--cyan);
  flex: 0 0 auto;
}

h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field {
  display: grid;
  gap: 6px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 13px;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  min-height: 38px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
}

input[type="range"] {
  accent-color: var(--cyan);
}

.microcopy {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.warningCopy {
  margin-top: 10px;
  padding: 9px 10px;
  color: #5f4b12;
  background: #fff7d2;
  border: 1px solid #eadb8b;
  border-radius: 6px;
}

.check {
  min-height: 30px;
  display: grid;
  grid-template-columns: 19px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin: 7px 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.3;
}

.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--cyan);
}

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

.readout {
  max-height: 238px;
  overflow: auto;
  padding: 11px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.4;
}

.readout strong {
  display: block;
  margin-bottom: 5px;
}

.readout span {
  display: block;
  color: var(--muted);
}

.readout dl,
.technicalBody dl {
  display: grid;
  grid-template-columns: minmax(132px, 1fr) auto;
  gap: 5px 12px;
  margin: 10px 0 0;
}

.readout dt,
.technicalBody dt {
  min-width: 0;
  color: var(--muted);
}

.readout dd,
.technicalBody dd {
  min-width: 0;
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.help {
  width: 18px;
  height: 18px;
  margin-left: 5px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #f1f6f4;
  color: var(--muted);
  font-size: 11px;
  line-height: 16px;
  vertical-align: middle;
  cursor: help;
}

.legend {
  display: grid;
  gap: 8px;
  font-size: 13px;
}

.legendItem {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.swatch {
  width: 24px;
  height: 12px;
  border: 1px solid rgba(23, 33, 38, 0.18);
  border-radius: 2px;
}

.swatch.line {
  height: 3px;
  border: 0;
}

.swatch.circle {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  justify-self: center;
}

.swatch.triangle {
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 14px solid var(--deep);
  background: transparent;
  justify-self: center;
}

details {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  font-size: 13px;
}

summary {
  cursor: pointer;
  font-weight: 700;
}

.technicalBody {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.45;
}

.technicalBody p {
  margin: 8px 0;
}

.mapArea {
  position: relative;
  min-width: 0;
  background: #dfe6e4;
}

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

.mapToolbar {
  position: absolute;
  z-index: 5;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 8px;
}

.layerStatus {
  position: absolute;
  z-index: 6;
  top: 12px;
  left: 62px;
  max-width: min(360px, calc(100% - 96px));
  padding: 9px 11px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(23, 33, 38, 0.11);
  font-size: 13px;
}

.mobileReadout {
  display: none;
}

.iconButton {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 4px 16px rgba(23, 33, 38, 0.11);
  cursor: pointer;
}

.iconButton:hover,
.iconButton:focus-visible {
  border-color: #87bbb5;
  outline: 0;
}

.iconButton svg {
  width: 18px;
  height: 18px;
}

footer {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 8px 16px;
  color: #59666d;
  background: var(--paper);
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.35;
}

.maplibregl-popup-content {
  border-radius: 6px;
  box-shadow: var(--shadow);
  font-family: inherit;
}

.maplibregl-ctrl-top-right {
  top: 12px;
  right: 12px;
}

@media (max-width: 768px), (max-height: 520px) {
  html,
  body {
    height: 100dvh;
    overflow: hidden;
  }

  body {
    background: #dfe6e4;
  }

  .topbar {
    position: fixed;
    z-index: 20;
    inset: 0 0 auto;
    min-height: 64px;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  }

  .status {
    display: none;
  }

  .appShell,
  .appShell.panelCollapsed {
    height: 100dvh;
    min-height: 0;
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 22;
    left: 10px;
    right: 10px;
    bottom: calc(44px + env(safe-area-inset-bottom));
    max-height: min(72dvh, 620px);
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    transform: translateY(calc(100% + 72px));
    transition: transform 180ms ease;
    overscroll-behavior: contain;
  }

  .appShell.panelOpen .sidebar {
    transform: translateY(0);
  }

  .drawerClose {
    position: sticky;
    top: 0;
    z-index: 2;
    display: inline-flex;
    float: right;
    margin: 0 0 8px 8px;
  }

  .layerGrid {
    grid-template-columns: 1fr;
  }

  .appShell.panelCollapsed .sidebar {
    max-height: min(72dvh, 620px);
    padding: 14px;
    border: 1px solid var(--line);
  }

  .mapArea {
    position: fixed;
    inset: calc(64px + env(safe-area-inset-top)) 0 calc(38px + env(safe-area-inset-bottom)) 0;
    min-height: 0;
  }

  .mapToolbar {
    top: 10px;
    left: 10px;
  }

  .layerStatus {
    top: 10px;
    left: 64px;
    max-width: calc(100% - 84px);
  }

  .iconButton {
    width: 44px;
    height: 44px;
  }

  .iconButton svg {
    width: 20px;
    height: 20px;
  }

  select {
    min-height: 44px;
  }

  .check {
    min-height: 44px;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 10px;
    margin: 2px 0;
  }

  .check input {
    width: 20px;
    height: 20px;
  }

  .readout {
    max-height: 190px;
  }

  .mobileReadout {
    position: absolute;
    z-index: 10;
    left: 10px;
    right: 10px;
    bottom: 10px;
    display: block;
    max-height: min(36dvh, 280px);
    overflow: auto;
    padding: 12px;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    font-size: 13px;
    line-height: 1.4;
  }

  .mobileReadout[hidden] {
    display: none;
  }

  .closeReadout {
    position: sticky;
    top: 0;
    float: right;
    margin: 0 0 8px 8px;
  }

  .mobileReadout strong,
  .mobileReadout span {
    display: block;
  }

  .mobileReadout span {
    color: var(--muted);
  }

  .mobileReadout dl {
    display: grid;
    grid-template-columns: minmax(112px, 1fr) minmax(0, 1fr);
    gap: 5px 10px;
    margin: 10px 0 0;
  }

  .mobileReadout dt {
    color: var(--muted);
  }

  .mobileReadout dd {
    min-width: 0;
    margin: 0;
    text-align: right;
    overflow-wrap: anywhere;
  }

  .maplibregl-ctrl button {
    width: 44px !important;
    height: 44px !important;
  }

  .maplibregl-ctrl-top-right {
    top: 10px;
    right: 10px;
  }

  footer {
    position: fixed;
    z-index: 18;
    inset: auto 0 0;
    min-height: 38px;
    padding: 7px 12px calc(7px + env(safe-area-inset-bottom));
    align-items: center;
    font-size: 11px;
  }
}

@media (max-width: 520px) {
  .topbar {
    gap: 10px;
  }

  h1 {
    font-size: 18px;
  }

  .topbar p,
  .status {
    font-size: 12px;
  }

  .sidebar {
    padding: 12px;
  }

  .readout dl,
  .technicalBody dl {
    grid-template-columns: 1fr;
  }

  .readout dd,
  .technicalBody dd,
  .mobileReadout dd {
    text-align: left;
  }

  .mobileReadout dl {
    grid-template-columns: 1fr;
  }
}
