:root {
  color-scheme: light;
  --bg: #f5f3ed;
  --panel: #fffdf8;
  --ink: #202523;
  --muted: #66736d;
  --line: #d9ded8;
  --accent: #0f7a68;
  --accent-ink: #05352f;
  --danger: #b44435;
  --shadow: 0 12px 36px rgba(38, 43, 39, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell,
#map {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  min-height: 100%;
}

.map-wrap {
  position: relative;
  min-width: 0;
}

.panel {
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--panel);
  padding: 18px;
  box-shadow: var(--shadow);
}

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

.header-actions {
  display: flex;
  gap: 8px;
}

.kicker {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 25px;
  line-height: 1.12;
}

h2 {
  margin-bottom: 8px;
  font-size: 14px;
}

.icon-button,
#fit-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  display: grid;
  width: 40px;
  place-items: center;
  font-size: 22px;
}

#fit-button {
  padding: 0 12px;
  white-space: nowrap;
}

button:hover {
  border-color: var(--accent);
}

.icon-button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.icon-button:disabled {
  color: var(--muted);
  cursor: wait;
  opacity: 0.72;
}

.search-box {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.search-box input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.basemap-list {
  display: grid;
  gap: 8px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.segmented button {
  min-height: 38px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 750;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: var(--accent);
  color: #fff;
}

.segmented button:disabled {
  background: #f0f1ee;
  color: #9ba49f;
  cursor: not-allowed;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.site-meta {
  display: grid;
  gap: 4px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
  color: var(--muted);
  font-size: 12px;
}

.site-meta strong {
  color: var(--ink);
  font-weight: 750;
}

.field-panel {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.location-readout {
  display: grid;
  gap: 2px;
  border: 1px solid #b7d8d1;
  border-radius: 8px;
  padding: 9px 10px;
  background: #eef8f5;
}

.location-readout[hidden] {
  display: none;
}

.location-readout span,
.location-readout small,
.field-header p,
.field-status {
  color: var(--muted);
  font-size: 12px;
}

.location-readout strong {
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 800;
}

.field-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.field-primary,
.field-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
}

.field-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.field-primary:disabled,
.field-actions button:disabled {
  border-color: var(--line);
  background: #f0f1ee;
  color: #9ba49f;
  cursor: not-allowed;
}

.field-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.field-point-list {
  display: grid;
  gap: 4px;
  max-height: 126px;
  margin: 0;
  overflow: auto;
  padding-left: 22px;
  color: var(--ink);
  font-size: 12px;
}

.field-point-list:empty {
  display: none;
}

.field-point-list li::marker {
  color: var(--accent);
  font-weight: 800;
}

.layer-list {
  display: grid;
  gap: 8px;
}

.layer-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-left: 7px solid var(--layer-color, var(--accent));
  border-radius: 8px;
  padding: 8px 10px 8px 7px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--layer-color, var(--accent)) 13%, transparent), transparent 72%),
    #fff;
}

.layer-item input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.layer-copy {
  min-width: 0;
}

.layer-name {
  overflow: hidden;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  border-radius: 99px;
  padding: 3px 8px;
  background: #edf5f2;
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 750;
}

.badge.missing {
  background: #faece8;
  color: var(--danger);
}

.details {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.empty,
.source-note {
  color: var(--muted);
}

.property-table {
  display: grid;
  gap: 6px;
  max-height: 280px;
  overflow: auto;
}

.property-row {
  display: grid;
  grid-template-columns: minmax(135px, 0.45fr) minmax(0, 1fr);
  gap: 10px;
  border-bottom: 1px solid #edf0ec;
  padding-bottom: 6px;
}

.property-key {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
  word-break: normal;
}

.property-value {
  min-width: 0;
  overflow-wrap: anywhere;
}

.maplibregl-popup-content .property-row {
  grid-template-columns: minmax(105px, 0.48fr) minmax(0, 1fr);
}

.source-note {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  font-size: 12px;
}

.maplibregl-popup-content {
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}

.map-credits {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 1;
  max-width: min(88vw, 760px);
  border-radius: 8px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.92);
  color: #222;
  font-size: 12px;
  line-height: 1.35;
  box-shadow: 0 2px 8px rgba(38, 43, 39, 0.12);
}

.map-credits a {
  color: inherit;
  text-decoration: none;
}

.map-credits a:hover {
  text-decoration: underline;
}

.cookie-notice {
  position: fixed;
  right: 18px;
  bottom: 28px;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  width: min(520px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

.cookie-notice[hidden] {
  display: none;
}

.cookie-notice p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.cookie-notice button {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 750;
}

@media (max-width: 820px) {
  html,
  body,
  .app-shell {
    min-height: 100%;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(58dvh, 1fr) minmax(0, 42dvh);
  }

  .panel {
    max-height: 42dvh;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .field-header,
  .field-actions {
    grid-template-columns: 1fr;
  }

  .map-credits {
    left: auto;
    right: 8px;
    bottom: 8px;
    max-width: calc(100vw - 148px);
    padding: 3px 6px;
    font-size: 9px;
    line-height: 1.2;
    text-align: right;
  }

  .maplibregl-ctrl-bottom-left {
    bottom: 8px;
  }

  .cookie-notice {
    right: 12px;
    bottom: 12px;
    grid-template-columns: 1fr;
    width: calc(100vw - 24px);
  }

}
