:root {
  color-scheme: light;
  --ink: #1f2527;
  --muted: #667176;
  --line: #d8dedb;
  --surface: #f6f7f4;
  --panel: #ffffff;
  --field: #eef2ef;
  --accent: #b53d2d;
  --accent-strong: #7d2a21;
  --green: #2f6f5e;
  --blue: #315f84;
  --shadow: 0 18px 45px rgba(31, 37, 39, 0.16);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: var(--surface);
}

body {
  min-width: 320px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand strong,
.brand small {
  display: block;
  white-space: nowrap;
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  background: var(--ink);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topnav a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  padding: 10px 12px;
  border-radius: 6px;
}

.topnav a:hover {
  background: var(--field);
}

.app-shell {
  height: calc(100vh - 72px);
  min-height: 640px;
  display: grid;
  grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
}

.sidebar {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-right: 1px solid var(--line);
  background: var(--panel);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.search-panel {
  padding: 24px;
  border-bottom: 1px solid var(--line);
}

.section-heading h1,
.admin-panel h1,
.admin-toolbar h1 {
  margin: 4px 0 20px;
  font-size: 28px;
  line-height: 1.08;
  max-width: 640px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  color: var(--ink);
  background: var(--field);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 12px;
  outline: none;
}

.field textarea {
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--green);
  background: #fff;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

.actions,
.panel-title,
.admin-toolbar,
.toolbar-actions,
.editor-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.actions {
  margin-top: 16px;
}

.icon-button,
.primary-button,
.icon-only {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--ink);
  background: #fff;
  font-weight: 800;
}

.icon-button,
.primary-button {
  padding: 0 13px;
}

.icon-only {
  width: 40px;
  padding: 0;
}

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

.icon-button:hover,
.icon-only:hover {
  border-color: var(--green);
}

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

.danger {
  color: var(--accent);
}

.icon-button svg,
.primary-button svg,
.icon-only svg {
  width: 18px;
  height: 18px;
}

#resultCount {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.results-panel {
  padding: 18px 18px 24px;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.panel-title {
  padding: 0 6px 12px;
}

.panel-title h2 {
  margin: 0;
  font-size: 18px;
}

.location-list {
  overflow: auto;
  display: grid;
  gap: 10px;
  padding: 0 6px 12px;
}

.location-card {
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 8px;
  box-shadow: none;
}

.location-card:hover,
.location-card.active {
  border-color: var(--green);
  box-shadow: 0 10px 24px rgba(47, 111, 94, 0.14);
}

.location-card h3 {
  margin: 0;
  font-size: 16px;
}

.location-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.meta-row,
.tag-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--ink);
  background: var(--field);
  font-size: 12px;
  font-weight: 800;
}

.map-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #dce5df;
}

.map,
.map-fallback {
  position: absolute;
  inset: 0;
}

.map-fallback {
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  padding: 24px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(31, 37, 39, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(31, 37, 39, 0.08) 1px, transparent 1px),
    #dfe8e0;
  background-size: 48px 48px;
}

.leaflet-container {
  font: inherit;
}

.marker {
  width: 24px;
  height: 24px;
  border-radius: 50% 50% 50% 3px;
  transform: rotate(-45deg);
  background: var(--accent);
  border: 3px solid #fff;
  box-shadow: var(--shadow);
}

.marker::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: #fff;
}

.leaflet-popup-content-wrapper {
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.leaflet-popup-content {
  margin: 14px;
}

.leaflet-popup-tip {
  box-shadow: var(--shadow);
}

.place-label {
  border: 1px solid rgba(31, 37, 39, 0.16);
  border-radius: 6px;
  padding: 5px 7px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 22px rgba(31, 37, 39, 0.16);
  backdrop-filter: blur(8px);
}

.place-label::before {
  display: none;
}

.place-label strong,
.place-label span {
  display: block;
  white-space: nowrap;
}

.place-label strong {
  font-size: 12px;
}

.place-label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.kml-label {
  border: 1px solid rgba(49, 95, 132, 0.28);
  border-radius: 6px;
  color: var(--blue);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 20px rgba(49, 95, 132, 0.14);
  font-size: 12px;
  font-weight: 800;
}

.kml-label::before {
  display: none;
}

.popup h3 {
  margin: 0 0 6px;
}

.popup p {
  margin: 0 0 10px;
  color: var(--muted);
}

.popup button {
  border: 0;
  background: var(--green);
  color: #fff;
  border-radius: 6px;
  min-height: 36px;
  padding: 0 10px;
  font-weight: 800;
}

.viewer-panel {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: min(420px, calc(100% - 36px));
  max-height: calc(100% - 36px);
  overflow: auto;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.close-viewer {
  position: absolute;
  top: 12px;
  right: 12px;
}

.viewer-panel h2 {
  margin: 4px 44px 8px 0;
  font-size: 22px;
}

.viewer-panel p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.5;
}

.viewer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.viewer-links a,
.viewer-links span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.viewer-links a {
  color: #fff;
  background: var(--green);
  text-decoration: none;
}

.viewer-links span {
  color: var(--blue);
  background: #eaf1f5;
}

.viewer-visual {
  height: 150px;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background:
    radial-gradient(circle at 30% 40%, rgba(181, 61, 45, 0.28), transparent 24%),
    radial-gradient(circle at 72% 52%, rgba(47, 111, 94, 0.34), transparent 20%),
    linear-gradient(135deg, #263238, #5d7066);
}

.viewer-visual span {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f7d796;
  box-shadow: 40px 18px 0 #fff, 84px 46px 0 #9fc3b5, 170px 28px 0 #fff, 260px 80px 0 #f7d796;
}

.viewer-visual span:nth-child(1) { left: 34px; top: 28px; }
.viewer-visual span:nth-child(2) { left: 86px; top: 92px; }
.viewer-visual span:nth-child(3) { left: 158px; top: 54px; }
.viewer-visual span:nth-child(4) { left: 214px; top: 112px; }

.site-disclaimer {
  border-top: 1px solid var(--line);
  background: #fff;
  padding: 14px 24px;
}

.site-disclaimer p {
  width: min(1180px, 100%);
  margin: 0 auto;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.admin-body {
  background: var(--surface);
}

.admin-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 32px auto;
}

.admin-panel,
.admin-workspace {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.admin-panel {
  max-width: 460px;
}

.admin-form {
  display: grid;
  gap: 16px;
}

.form-message {
  min-height: 22px;
  color: var(--muted);
  font-weight: 700;
}

.toolbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.editor-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fff;
}

.editor-card-header {
  align-items: flex-start;
  margin-bottom: 14px;
}

.editor-card h2 {
  margin: 0;
  min-height: 34px;
  flex: 1;
  outline: none;
}

.editor-card h2:focus {
  background: var(--field);
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.wide {
  grid-column: span 2;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

@media (max-width: 980px) {
  .app-shell {
    height: auto;
    min-height: 0;
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

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

@media (max-width: 640px) {
  .topbar {
    height: auto;
    min-height: 68px;
    padding: 12px 14px;
  }

  .brand strong {
    white-space: normal;
  }

  .brand small {
    display: none;
  }

  .topnav a {
    padding: 9px 8px;
  }

  .search-panel {
    padding: 18px 14px;
  }

  .section-heading h1,
  .admin-panel h1,
  .admin-toolbar h1 {
    font-size: 23px;
  }

  .filter-grid,
  .editor-grid {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: auto;
  }

  .results-panel {
    padding-inline: 8px;
  }

  .map-stage {
    height: 74vh;
    min-height: 540px;
  }

  .viewer-panel {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-height: 58%;
  }

  .site-disclaimer {
    padding: 12px 14px;
  }

  .admin-shell {
    width: min(100% - 20px, 1180px);
    margin: 20px auto;
  }

  .admin-panel,
  .admin-workspace {
    padding: 16px;
  }

  .admin-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar-actions {
    justify-content: flex-start;
  }
}
