:root {
  --forest: #1f5f43;
  --forest-dark: #143f31;
  --lake: #2477a6;
  --rock: #6f513f;
  --village: #605d80;
  --orange: #d56b1d;
  --paper: #fffdf7;
  --ink: #1c2520;
  --muted: #69746d;
  --line: rgba(31, 95, 67, 0.16);
  --shadow: 0 18px 55px rgba(22, 35, 29, 0.18);
  --sidebar: 390px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #d8e2d2;
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar) 10px 1fr;
  width: 100%;
  min-height: 100vh;
  height: 100%;
}

.sidebar {
  position: relative;
  z-index: 500;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: linear-gradient(180deg, var(--paper), #f4efe4);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.sidebar-header {
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.sidebar-header-main {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.sidebar-header-main h1 { flex: 1; }

.header-toggle-btn {
  flex-shrink: 0;
  margin-top: 4px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.62rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color 120ms ease, background 120ms ease;
}

.header-toggle-btn:hover { color: var(--forest); background: rgba(31, 95, 67, 0.08); }

.sidebar-intro {
  overflow: hidden;
  max-height: 120px;
  opacity: 1;
  margin-top: 10px;
  transition: max-height 280ms ease, opacity 200ms ease, margin 280ms ease;
}

.sidebar-intro.collapsed { max-height: 0; opacity: 0; margin-top: 0; }

/* ── Barre d'actions ─────────────────────────────────────────────────────── */
.action-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.action-btn {
  display: grid;
  place-items: center;
  height: 40px;
  border: 1px solid rgba(28, 37, 32, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 1.15rem;
  cursor: pointer;
  transition: background 120ms ease, box-shadow 120ms ease, transform 100ms ease;
}

.action-btn:hover {
  background: white;
  box-shadow: 0 4px 12px rgba(20, 36, 28, 0.12);
  transform: translateY(-1px);
}

.action-btn.active {
  background: var(--forest);
  border-color: transparent;
}

/* ── Onglets ─────────────────────────────────────────────────────────────── */
.sidebar-tabs {
  display: flex;
  padding: 0 14px;
  border-bottom: 2px solid var(--line);
  flex-shrink: 0;
}

.sidebar-tab {
  flex: 1;
  padding: 10px 6px;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 150ms ease, border-color 150ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.sidebar-tab:hover { color: var(--forest-dark); }

.sidebar-tab.active {
  color: var(--forest);
  border-bottom-color: var(--forest);
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--forest);
  color: white;
  font-size: 0.68rem;
  font-weight: 800;
}

.tab-badge[hidden] { display: none; }

.tab-pane { display: none; flex-direction: column; }
.tab-pane.active { display: flex; }

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

h1 {
  margin: 0;
  font-size: clamp(1.65rem, 4vw, 2.25rem);
  line-height: 1.02;
  letter-spacing: 0;
  color: #143f31;
}

.intro {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.55;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.button,
.secondary,
.geolocate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.button {
  background: var(--forest);
  color: white;
  box-shadow: 0 10px 24px rgba(31, 95, 67, 0.22);
}

.button:hover {
  background: var(--forest-dark);
}

.secondary,
.geolocate {
  background: rgba(255, 255, 255, 0.9);
  color: var(--forest-dark);
  border: 1px solid rgba(28, 37, 32, 0.08);
}

.secondary:hover,
.geolocate:hover {
  background: white;
}

.tool-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.search {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(28, 37, 32, 0.12);
  border-radius: 12px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.search:focus {
  outline: none;
  border-color: rgba(31, 95, 67, 0.4);
  box-shadow: 0 0 0 3px rgba(31, 95, 67, 0.1);
}

.filters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
}

/* ── Filter pills ────────────────────────────────────────────────────────── */
.filter-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px 7px;
  border: 1.5px solid rgba(28, 37, 32, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  user-select: none;
  transition: background 130ms ease, border-color 130ms ease, transform 100ms ease;
}

.filter-pill input {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap;
}

.filter-pill:hover {
  background: white;
  transform: translateY(-1px);
}

.filter-pill.active {
  background: color-mix(in srgb, var(--color) 14%, white);
  border-color: color-mix(in srgb, var(--color) 55%, transparent);
}

.filter-pill-icon { font-size: 1.1rem; line-height: 1; }

.filter-pill-count {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--muted);
  line-height: 1;
}

.filter-pill.active .filter-pill-count {
  color: color-mix(in srgb, var(--color) 75%, black);
}

/* ── Filter footer (tout afficher / masquer) ─────────────────────────────── */
.filter-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.filter-footer-btn {
  background: none;
  border: none;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.filter-footer-btn:hover { color: var(--forest); }

/* ── Recherche déclenchable ──────────────────────────────────────────────── */
.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(28, 37, 32, 0.12);
  border-radius: 12px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.9);
  text-align: left;
  cursor: text;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.search-trigger:hover {
  border-color: rgba(31, 95, 67, 0.35);
  box-shadow: 0 0 0 3px rgba(31, 95, 67, 0.08);
}

.search-trigger[hidden] { display: none; }
.search[hidden]         { display: none; }

.filter {
  display: grid;
  grid-template-columns: 18px 18px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid rgba(28, 37, 32, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.76);
  cursor: pointer;
  user-select: none;
}

.filter input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--forest);
}

.dot,
.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color) 18%, transparent);
}

.filter-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 750;
}

.count {
  min-width: 26px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(31, 95, 67, 0.1);
  color: var(--forest-dark);
  font-size: 0.76rem;
  font-weight: 800;
  text-align: center;
}

.legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(28, 37, 32, 0.08);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: white;
  font-size: 0.82rem;
  color: var(--forest-dark);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.sidebar-body {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(31, 95, 67, 0.25) transparent;
}

.sidebar-body::-webkit-scrollbar { width: 5px; }
.sidebar-body::-webkit-scrollbar-track { background: transparent; }
.sidebar-body::-webkit-scrollbar-thumb {
  background: rgba(31, 95, 67, 0.22);
  border-radius: 99px;
}
.sidebar-body::-webkit-scrollbar-thumb:hover {
  background: rgba(31, 95, 67, 0.38);
}

.places-panel {
  padding: 14px 14px 22px;
}

.places-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 4px 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.place-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.place-card {
  width: 100%;
  padding: 13px;
  border: 1px solid rgba(28, 37, 32, 0.08);
  border-left: 5px solid var(--color);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.place-card:hover,
.place-card:focus-visible {
  transform: translateY(-1px);
  background: #fff;
  box-shadow: 0 10px 25px rgba(24, 35, 29, 0.12);
  outline: none;
}

.place-card strong {
  display: block;
  margin-bottom: 5px;
  color: var(--forest-dark);
  font-size: 0.98rem;
  line-height: 1.2;
}

.place-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.place-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 999px;
  background: var(--color);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 900;
}

.map-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 100vh;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: #cad9cc;
}

.leaflet-control-attribution {
  font-size: 0.72rem;
}

.custom-marker {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid #fff;
  border-radius: 999px 999px 999px 6px;
  background: var(--color);
  color: #fff;
  box-shadow: 0 8px 18px rgba(20, 36, 28, 0.35);
  font-size: 17px;
  font-weight: 900;
  transform: rotate(-45deg);
}

.custom-marker span {
  transform: rotate(45deg);
  line-height: 1;
}

.custom-marker.base {
  width: 44px;
  height: 44px;
  border-width: 3px;
  box-shadow: 0 0 0 9px rgba(145, 45, 45, 0.18), 0 12px 25px rgba(20, 36, 28, 0.35);
}

.leaflet-popup-content-wrapper {
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(20, 36, 28, 0.25);
}

.leaflet-popup-content {
  width: min(285px, 70vw) !important;
  margin: 16px;
}

.popup h2 {
  margin: 0 0 8px;
  color: var(--forest-dark);
  font-size: 1.1rem;
  line-height: 1.2;
}

.popup-category {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  padding: 5px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--color) 14%, white);
  color: color-mix(in srgb, var(--color) 68%, black);
  font-size: 0.76rem;
  font-weight: 850;
}

.popup p {
  margin: 8px 0;
  color: #35413b;
  font-size: 0.88rem;
  line-height: 1.45;
}

.popup b {
  color: var(--forest-dark);
}

.osm-link {
  display: inline-flex;
  margin-top: 8px;
  color: var(--forest);
  font-weight: 850;
  text-decoration: none;
}

.osm-link:hover {
  text-decoration: underline;
}

.mobile-toggle {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 700;
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--paper);
  color: var(--forest-dark);
  box-shadow: 0 10px 28px rgba(20, 36, 28, 0.22);
  font-size: 1.35rem;
  cursor: pointer;
}

.resizer {
  width: 10px;
  cursor: ew-resize;
  background: linear-gradient(90deg, transparent, rgba(20,36,28,0.04));
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.resizer::after {
  content: '';
  display: block;
  width: 3px;
  height: 28px;
  border-radius: 99px;
  background: rgba(31, 95, 67, 0.18);
  transition: background 150ms ease;
}

.resizer:hover::after,
body.resizing .resizer::after {
  background: rgba(31, 95, 67, 0.5);
}

body.resizing {
  user-select: none;
  cursor: ew-resize;
}

.filter-section {
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 2px;
}

.filter-section > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 2px;
  cursor: pointer;
  list-style: none;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  user-select: none;
  transition: color 120ms ease;
}

.filter-section > summary::-webkit-details-marker { display: none; }
.filter-section > summary:hover { color: var(--forest); }

.filter-section .chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: transform 220ms ease;
}

.filter-section[open] .chevron { transform: rotate(180deg); }

.filter-section > .filters,
.filter-section > .legend {
  margin-top: 8px;
}

.empty-state {
  padding: 28px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.empty-state strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 0.96rem;
}

.toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 320px;
}

.toast {
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: white;
  font-size: 0.88rem;
  line-height: 1.4;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  pointer-events: auto;
  animation: toast-in 200ms ease forwards;
}

.toast.success { background: var(--forest); }
.toast.error { background: #8b1e1e; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(10px); }
}

.footer {
  padding: 14px 18px;
  font-size: 0.78rem;
  color: var(--muted);
  border-top: 1px solid rgba(28, 37, 32, 0.08);
  text-align: center;
  background: rgba(255, 255, 255, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sync-status {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.sync-status[hidden] { display: none; }

.sync-saving { color: var(--muted); background: rgba(28, 37, 32, 0.07); }
.sync-saved  { color: var(--forest); background: rgba(31, 95, 67, 0.1); }
.sync-error  { color: #8b4a00;       background: rgba(213, 107, 29, 0.1); }

/* ── Bannière carte partagée ─────────────────────────────────────────────── */
.shared-map-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--forest);
  color: white;
  font-size: 0.88rem;
  font-weight: 600;
}

.shared-map-banner[hidden] { display: none; }

.shared-map-banner strong { font-weight: 800; }

.shared-map-banner button {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255,255,255,0.75);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.shared-map-banner button:hover { color: white; }

/* ── Section "ce lien inclura" dans la modale de partage ────────────────── */
.shared-confirm-note {
  margin: 6px 0 0;
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(31, 95, 67, 0.07);
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.share-includes {
  margin: 4px 0 2px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(31, 95, 67, 0.07);
  border: 1px solid rgba(31, 95, 67, 0.14);
}

.share-includes p {
  margin: 0 0 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--forest-dark);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.share-includes ul {
  margin: 0;
  padding: 0 0 0 16px;
}

.share-includes li {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.7;
}

.pin-btn.active {
  background: color-mix(in srgb, var(--forest) 14%, white);
  border-color: rgba(31, 95, 67, 0.35);
  color: var(--forest);
}

.pin-hint {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 700;
  background: var(--forest);
  color: white;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(20, 36, 28, 0.3);
  white-space: nowrap;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.pin-hint[hidden] { display: none; }

.pin-hint button {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.pin-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 36, 28, 0.45);
  z-index: 8000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.pin-modal-backdrop[hidden] { display: none; }

.pin-modal {
  background: var(--paper);
  border-radius: 16px;
  padding: 24px;
  width: min(400px, 90vw);
  box-shadow: 0 24px 60px rgba(20, 36, 28, 0.35);
}

.pin-modal h3 {
  margin: 0 0 18px;
  font-size: 1.1rem;
  color: var(--forest-dark);
}

.pin-field {
  display: block;
  margin-bottom: 14px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--muted);
}

.pin-field input,
.pin-field select,
.pin-field textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 9px 11px;
  border: 1px solid rgba(28, 37, 32, 0.18);
  border-radius: 8px;
  font: inherit;
  font-size: 0.94rem;
  color: var(--ink);
  background: white;
}

.pin-field textarea {
  resize: vertical;
  min-height: 68px;
}

.pin-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: flex-end;
}

.popup-user-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.popup-edit,
.popup-delete {
  flex: 1;
  padding: 6px 10px;
  border-radius: 7px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.popup-edit {
  border: 1px solid rgba(31, 95, 67, 0.28);
  background: rgba(31, 95, 67, 0.07);
  color: var(--forest-dark);
}

.popup-edit:hover { background: rgba(31, 95, 67, 0.14); }

.popup-delete {
  border: 1px solid rgba(139, 30, 30, 0.25);
  background: rgba(139, 30, 30, 0.06);
  color: #8b1e1e;
}

.popup-delete:hover { background: rgba(139, 30, 30, 0.14); }

.popup-reset {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid rgba(28, 37, 32, 0.18);
  border-radius: 7px;
  background: rgba(28, 37, 32, 0.05);
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.popup-reset:hover { background: rgba(28, 37, 32, 0.1); color: var(--ink); }

.place-card.user-pin {
  border-left-style: dashed;
}

/* ── Cross-highlight sidebar ↔ carte ─────────────────────────────────── */
.marker-highlight {
  filter: drop-shadow(0 0 7px rgba(31, 95, 67, 0.85));
  z-index: 9999 !important;
  transition: filter 150ms ease;
}

.place-card.card-highlight {
  background: rgba(31, 95, 67, 0.08) !important;
  box-shadow: 0 0 0 2px var(--forest), 0 6px 18px rgba(31, 95, 67, 0.15) !important;
}

/* ── Highlight texte de recherche ─────────────────────────────────────── */
mark.search-highlight {
  background: rgba(213, 107, 29, 0.22);
  color: inherit;
  border-radius: 2px;
  font-weight: inherit;
}

/* ── Bouton "+" déjà dans l'itinéraire ───────────────────────────────── */
.place-route-add.in-route {
  background: var(--forest);
  color: white;
  border-color: transparent;
  cursor: default;
}

.popup-add-route.in-route {
  background: rgba(31, 95, 67, 0.12);
  color: var(--forest);
  cursor: default;
}

/* ── Place item wrapper (card + bouton itinéraire) ───────────────────── */
.place-item {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.place-item .place-card {
  flex: 1;
  min-width: 0;
  width: auto;
}

.place-route-add {
  flex-shrink: 0;
  width: 32px;
  border: 1px solid rgba(31, 95, 67, 0.22);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--forest);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.place-route-add:hover {
  background: var(--forest);
  color: white;
  border-color: transparent;
}

/* ── Bouton "Ajouter à l'itinéraire" dans les popups ─────────────────── */
.popup-add-route {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  width: 100%;
  padding: 7px 10px;
  border: 1px solid rgba(31, 95, 67, 0.25);
  border-radius: 8px;
  background: rgba(31, 95, 67, 0.06);
  color: var(--forest-dark);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 130ms ease;
}

.popup-add-route:hover {
  background: rgba(31, 95, 67, 0.14);
}

/* ── Découvrir / Overpass ────────────────────────────────────────────── */
.overpass-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 8px 0 10px;
}

.overpass-cat-btn {
  padding: 5px 10px;
  border: 1.5px solid rgba(28, 37, 32, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: background 130ms ease, border-color 130ms ease, color 130ms ease;
}

.overpass-cat-btn:hover:not(.active) {
  background: white;
  color: var(--ink);
}

.overpass-cat-btn.active {
  background: var(--forest);
  color: white;
  border-color: transparent;
}

.overpass-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.overpass-status {
  margin: 6px 0 2px;
  font-size: 0.76rem;
  color: var(--muted);
  text-align: center;
  min-height: 1em;
}

/* Bouton "Ajouter à ma carte" dans les popups Overpass */
.popup-add-to-map {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  width: 100%;
  padding: 7px 10px;
  border: 1px solid rgba(31, 95, 67, 0.25);
  border-radius: 8px;
  background: rgba(31, 95, 67, 0.07);
  color: var(--forest-dark);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 130ms ease;
}

.popup-add-to-map:hover { background: rgba(31, 95, 67, 0.15); }

/* Marqueur circulaire sur la carte (distinct des pins habituels) */
.overpass-marker {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: white;
  border: 2.5px solid var(--color);
  font-size: 0.9rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
  transition: transform 120ms ease;
}

.overpass-marker:hover { transform: scale(1.15); }

/* ── Route panel ─────────────────────────────────────────────────────── */
.route-panel {
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.route-mode-select {
  display: block;
  width: 100%;
  margin: 0;
  padding: 7px 10px;
  border: 1px solid rgba(28, 37, 32, 0.14);
  border-radius: 8px;
  font: inherit;
  font-size: 0.86rem;
  color: var(--ink);
  background: white;
  cursor: pointer;
}

.route-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 8px;
  background: rgba(31, 95, 67, 0.07);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--forest-dark);
}

.route-stats[hidden] { display: none; }
.route-stat strong   { color: var(--forest); }

.route-steps {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.route-step {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border: 1px solid rgba(28, 37, 32, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  cursor: grab;
  user-select: none;
  transition: background 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

.route-step:active        { cursor: grabbing; }
.route-step.dragging      { opacity: 0.4; }
.route-step.drag-over     { box-shadow: 0 0 0 2px var(--forest); background: rgba(31, 95, 67, 0.06); }
.route-step--deleted      { opacity: 0.5; background: rgba(139, 30, 30, 0.04); border-color: rgba(139, 30, 30, 0.18); }

.route-step-handle { color: var(--muted); font-size: 0.88rem; flex-shrink: 0; }

.route-step-num {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--forest);
  color: white;
  font-size: 0.7rem;
  font-weight: 800;
}

.route-step-cat  { font-size: 0.88rem; flex-shrink: 0; }

.route-step-label {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.route-step-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--forest-dark);
}

.route-step-dist {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}

.route-step-remove {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(28, 37, 32, 0.07);
  color: var(--muted);
  font-size: 0.68rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 120ms ease, color 120ms ease;
}

.route-step-remove:hover {
  background: rgba(139, 30, 30, 0.14);
  color: #8b1e1e;
}

.route-drop-target {
  outline: 2px dashed var(--forest);
  outline-offset: 3px;
  background: rgba(31, 95, 67, 0.04);
  border-radius: 10px;
  transition: background 120ms ease;
}

.route-empty {
  padding: 12px 4px;
  text-align: center;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
  margin: 0;
}

.route-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
  margin-bottom: 4px;
}

/* Marqueur numéroté sur la carte */
.route-step-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #1f5f43;
  color: white;
  font-size: 0.72rem;
  font-weight: 800;
  border: 2.5px solid white;
  box-shadow: 0 3px 10px rgba(20, 36, 28, 0.35);
}

/* ── Geocoding dans la modale ────────────────────────────────────────── */
.geocode-wrap {
  position: relative;
  margin-top: 5px;
}

.pin-geocode-input {
  display: block;
  width: 100%;
  padding: 9px 11px 9px 34px;
  border: 1px solid rgba(28, 37, 32, 0.18);
  border-radius: 8px;
  font: inherit;
  font-size: 0.94rem;
  color: var(--ink);
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2369746d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 10px center;
}

.pin-geocode-input:focus {
  outline: none;
  border-color: rgba(31, 95, 67, 0.4);
  box-shadow: 0 0 0 3px rgba(31, 95, 67, 0.1);
}

.geocode-results {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  z-index: 200;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid rgba(28, 37, 32, 0.14);
  border-radius: 8px;
  background: white;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  overflow: hidden;
  max-height: 210px;
  overflow-y: auto;
}

.geocode-results[hidden] { display: none; }

.geocode-result-item {
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(28, 37, 32, 0.06);
}

.geocode-result-item:last-child { border-bottom: none; }
.geocode-result-item:hover { background: rgba(31, 95, 67, 0.07); }

.geocode-result-name {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--forest-dark);
}

.geocode-result-detail {
  display: block;
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 1px;
}

.pin-location-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(31, 95, 67, 0.09);
  font-size: 0.84rem;
  color: var(--forest-dark);
  font-weight: 600;
  line-height: 1.3;
}

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

.pin-location-tag button {
  margin-left: auto;
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
}

.pin-location-tag button:hover { background: rgba(0, 0, 0, 0.07); }

.pin-map-click-btn {
  display: inline-block;
  margin-top: 7px;
  background: none;
  border: none;
  color: var(--forest);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Clusters ─────────────────────────────────────────────────────────── */
.cluster-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--forest);
  color: white;
  font-size: 0.82rem;
  font-weight: 800;
  border: 2.5px solid white;
  box-shadow: 0 4px 14px rgba(20, 36, 28, 0.3);
}

/* ── Sélecteur de fond de carte ───────────────────────────────────────── */
.layer-switcher {
  position: absolute;
  bottom: 92px;
  right: 10px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.layer-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid rgba(28, 37, 32, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
  transition: background 120ms ease;
}

.layer-btn:hover { background: white; }

.layer-btn.active {
  background: var(--forest);
  color: white;
  border-color: transparent;
}

@media (max-width: 820px) {
  body {
    overflow: hidden;
  }

  .app {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(88vw, 390px);
    transform: translateX(-104%);
    transition: transform 220ms ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .map-wrap {
    width: 100vw;
    height: 100vh;
    min-height: 100dvh;
  }

  .mobile-toggle {
    display: inline-flex;
  }

  .sidebar-header {
    padding-top: 68px;
  }

  .resizer {
    display: none;
  }
}

/* ── Badge itinéraire mobile ─────────────────────────────────────────────── */
.route-badge {
  position: absolute;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border: none;
  border-radius: 999px;
  background: var(--forest);
  color: white;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(20, 36, 28, 0.38);
  white-space: nowrap;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.route-badge:hover {
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 10px 28px rgba(20, 36, 28, 0.45);
}

.route-badge[hidden] { display: none; }

@media (min-width: 821px) {
  .route-badge { display: none !important; }
}

/* ── Animation tracé de route ────────────────────────────────────────────── */
@keyframes route-draw {
  to { stroke-dashoffset: 0; }
}

.route-draw-anim {
  animation: route-draw 1s ease-out forwards;
}

/* ── Dark mode ───────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --forest:      #4ea876;
    --forest-dark: #6dc492;
    --paper:       #1a211d;
    --ink:         #dde8e0;
    --muted:       #7a9184;
    --line:        rgba(255, 255, 255, 0.09);
    --shadow:      0 18px 55px rgba(0, 0, 0, 0.55);
    --orange:      #e8843a;
  }

  body { background: #0f1511; }

  .sidebar {
    background: linear-gradient(180deg, #1a211d, #141a16);
    border-right-color: rgba(255, 255, 255, 0.08);
  }

  .sidebar-header { border-bottom-color: rgba(255, 255, 255, 0.08); }

  .action-btn {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.1);
  }
  .action-btn:hover { background: rgba(255, 255, 255, 0.13); }
  .action-btn.active { background: var(--forest); border-color: transparent; }

  .sidebar-tabs { border-bottom-color: rgba(255, 255, 255, 0.1); }
  .sidebar-tab  { color: #5a7a68; }
  .sidebar-tab:hover { color: var(--forest-dark); }
  .sidebar-tab.active { color: var(--forest); border-bottom-color: var(--forest); }

  .filter-pill {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
  }
  .filter-pill:hover { background: rgba(255, 255, 255, 0.12); }

  .search-trigger {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.14);
    color: #5a7a68;
  }

  h1 { color: #6dc492; }

  .place-card {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
  }

  .place-card:hover,
  .place-card:focus-visible {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  }

  .filter {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
  }

  .legend { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.08); }
  .legend-item { background: rgba(255, 255, 255, 0.07); color: var(--ink); }

  .search,
  .pin-field input,
  .pin-field select,
  .pin-field textarea,
  .route-mode-select {
    background: #0f1511;
    color: var(--ink);
    border-color: rgba(255, 255, 255, 0.14);
  }

  .search:focus,
  .pin-field input:focus,
  .pin-field select:focus,
  .pin-field textarea:focus {
    border-color: rgba(78, 168, 118, 0.5);
    box-shadow: 0 0 0 3px rgba(78, 168, 118, 0.12);
  }

  .secondary, .geolocate, .pin-btn {
    background: rgba(255, 255, 255, 0.07);
    color: var(--ink);
    border-color: rgba(255, 255, 255, 0.1);
  }

  .secondary:hover, .geolocate:hover { background: rgba(255, 255, 255, 0.12); }

  .footer { background: rgba(0, 0, 0, 0.35); }

  .pin-modal { background: #1a211d; }
  .pin-modal-backdrop { background: rgba(0, 0, 0, 0.65); }

  .toast { background: #2a3530; }
  .toast.success { background: #1e4d30; }
  .toast.error   { background: #4d1e1e; }

  .layer-btn {
    background: rgba(20, 30, 24, 0.95);
    color: var(--ink);
    border-color: rgba(255, 255, 255, 0.12);
  }

  .layer-btn.active { background: var(--forest); color: #0f1511; }

  .route-step {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.09);
  }

  .place-route-add {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(78, 168, 118, 0.2);
  }

  .pin-location-tag { background: rgba(78, 168, 118, 0.12); }
  .share-includes   { background: rgba(78, 168, 118, 0.08); border-color: rgba(78, 168, 118, 0.15); }

  .leaflet-popup-content-wrapper { background: #1a211d; color: var(--ink); }
  .leaflet-popup-tip             { background: #1a211d; }
  .popup h2, .popup b            { color: var(--forest-dark); }
  .popup p                       { color: #b8cec0; }
}
