:root {
  --bg: #f5f7f4;
  --surface: #ffffff;
  --text: #1d2520;
  --muted: #66716a;
  --line: #d9e0da;
  --accent: #0f8b6f;
  --accent-dark: #09634f;
  --danger: #b42318;
  --marker: #e43f2f;
  --quiet: #eef1ee;
  --shadow: 0 14px 40px rgba(28, 45, 36, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--text);
  background: var(--surface);
  font: inherit;
  cursor: pointer;
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

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

.primary:hover:not(:disabled) {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.app {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0;
}

.header {
  margin-bottom: 16px;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 40px);
  font-weight: 700;
  letter-spacing: 0;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.map-wrap,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.map-wrap {
  overflow: hidden;
}

.leaflet-container {
  position: relative;
  overflow: hidden;
  background: #ddd;
  outline: 0;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-tile {
  filter: grayscale(1) contrast(1.08) brightness(1.04);
}

#map {
  width: 100%;
  height: min(70vh, 680px);
  min-height: 460px;
}

.panel {
  padding: 18px;
}

.status {
  margin-bottom: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.section-title {
  margin: 16px 0 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.load-status {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.load-status.is-error {
  color: var(--danger);
}

.reload-btn {
  width: 100%;
  margin-bottom: 10px;
}

.download-btn {
  width: 100%;
  margin-top: 10px;
}

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

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

.export-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

.text-field input,
.export-grid input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  background: #ffffff;
  font: inherit;
}

.export-grid input:focus {
  border-color: var(--accent);
  outline: none;
}

.place-name {
  display: block;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.place-type {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.point-list {
  display: grid;
  gap: 10px;
  min-height: 48px;
  margin: 0 0 18px;
  padding-left: 0;
  list-style: none;
}

.point-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.point-label-input {
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  background: #ffffff;
  font: inherit;
  font-size: 14px;
}

.point-icon-select {
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  background: #ffffff;
  font: inherit;
  font-size: 14px;
}

.point-label-input:focus,
.point-icon-select:focus {
  border-color: var(--accent);
  outline: none;
}

.point-number {
  display: none;
}

.coords {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
}

.delete-btn {
  color: var(--danger);
}

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

.marker-pin {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 3px solid #ffffff;
  border-radius: 999px;
  color: #ffffff;
  background: var(--marker);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.32);
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
}

.marker-icon-badge {
  display: none;
}

.card-marker {
  position: relative;
  display: block;
  width: 34px;
  height: 34px;
}

.card-marker-label {
  position: absolute;
  --label-gap: 10px;
  max-width: 220px;
  padding: 5px 8px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 6px;
  color: #111111;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  white-space: normal;
}

.label-right {
  left: calc(34px + var(--label-gap));
  top: 50%;
  transform: translateY(-50%);
}

.label-left {
  right: calc(34px + var(--label-gap));
  top: 50%;
  transform: translateY(-50%);
}

.label-top {
  left: 50%;
  bottom: calc(34px + var(--label-gap));
  transform: translateX(-50%);
}

.label-bottom {
  left: 50%;
  top: calc(34px + var(--label-gap));
  transform: translateX(-50%);
}

.label-top-right {
  left: calc(17px + var(--label-gap));
  bottom: calc(34px + var(--label-gap));
}

.label-top-left {
  right: calc(17px + var(--label-gap));
  bottom: calc(34px + var(--label-gap));
}

.label-bottom-right {
  left: calc(17px + var(--label-gap));
  top: calc(34px + var(--label-gap));
}

.label-bottom-left {
  right: calc(17px + var(--label-gap));
  top: calc(34px + var(--label-gap));
}

.place-pin {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  color: #ffffff;
  background: #4d5550;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.poi-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.place-pin .poi-icon {
  width: 15px;
  height: 15px;
}

.back-btn {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 800;
  border-color: var(--accent);
  color: #ffffff;
  background: var(--accent);
  box-shadow: var(--shadow);
}

.card-mode {
  width: min(980px, calc(100% - 32px));
  padding: 20px 0 78px;
}

.card-mode .header {
  text-align: center;
}

.card-mode .workspace {
  display: block;
}

.card-mode .panel {
  display: none;
}

.card-mode .place-pin {
  display: none;
}

.card-mode .map-wrap {
  border-width: 2px;
}

.card-mode #map {
  height: min(76vh, 760px);
  min-height: 520px;
}

@media (max-width: 820px) {
  .app {
    width: min(100% - 20px, 720px);
    padding: 14px 0;
  }

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

  #map {
    height: 55vh;
    min-height: 340px;
  }

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

  .point-row {
    grid-template-columns: 1fr;
  }

  .delete-btn {
    justify-self: start;
  }

  .card-mode #map {
    height: 70vh;
    min-height: 420px;
  }

  .back-btn {
    right: 12px;
    bottom: 12px;
  }
}
