:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.1);

  /* Palette de statut (fixe, ne suit pas le thème) */
  --status-ok: #0ca30c;
  --status-attention: #fab219;
  --status-cassee: #d03b3b;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text-primary);
  background: var(--page);
}

/* Grand écran : bandeau, puis colonne latérale et carte sur toute la hauteur restante, quelle que
   soit la hauteur du bandeau (ses tuiles passent à la ligne). */
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}

#topbar h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 600;
}

#data-date {
  margin: 0;
  font-size: 13px;
}

#layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* toute la colonne défile : filtres, évolution et liste restent atteignables */
#sidebar {
  width: 360px;
  flex: none;
  border-right: 1px solid var(--border);
  background: var(--surface-1);
  overflow-y: auto;
}

#filters {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gridline);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#filters label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.color-mode {
  margin: 6px 0;
  font-size: 12px;
}
.color-mode select {
  width: 100%;
  margin-top: 2px;
  font: inherit;
}
.color-legend {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
}
.color-legend li {
  display: flex;
  align-items: center;
  gap: 4px;
}
.color-legend .swatch {
  display: inline-block;
  width: 14px;
  height: 4px;
  border-radius: 2px;
}
.color-legend .swatch--gap {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(208, 59, 59, 0.3);
  border: 1.5px solid #d03b3b;
}

.status-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

#search,
#kind-search {
  margin-top: 4px;
  padding: 6px 8px;
  border: 1px solid var(--gridline);
  border-radius: 4px;
  font-size: 13px;
}

#relation-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

#relation-table thead {
  position: sticky;
  top: 0;
  background: var(--surface-1);
}

#relation-table th {
  text-align: left;
  padding: 6px 8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--gridline);
}

#relation-table tbody tr {
  cursor: pointer;
  border-bottom: 1px solid var(--gridline);
}

#relation-table tbody tr:hover {
  background: var(--page);
}

#relation-table td {
  padding: 6px 8px;
  color: var(--text-secondary);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  font-size: 11px;
}

.status-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

#map {
  flex: 1;
  min-width: 0;
}

.maplibregl-popup-content {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 13px;
  max-width: 320px;
}

.maplibregl-popup-content h3,
#relation-sheet .sheet-body h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.maplibregl-popup-content .ref-network,
#relation-sheet .sheet-body .ref-network {
  margin: 0 0 8px;
  color: var(--text-secondary);
  font-size: 12px;
}

.maplibregl-popup-content ul.issues,
#relation-sheet .sheet-body ul.issues {
  margin: 0 0 8px;
  padding-left: 18px;
}

.maplibregl-popup-content ul.issues li,
#relation-sheet .sheet-body ul.issues li {
  margin-bottom: 6px;
}

.maplibregl-popup-content .issue-meta,
#relation-sheet .sheet-body .issue-meta {
  color: var(--text-muted);
  font-size: 11px;
}

#data-source {
  margin: 10px 0;
  padding: 0 12px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.maplibregl-popup-content .relation-meta,
#relation-sheet .sheet-body .relation-meta {
  color: var(--text-muted);
  font-size: 11px;
  margin: 0 0 8px;
}/* juste sous le titre : les actions restent visibles même avec une longue liste d'anomalies */
.maplibregl-popup-content .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 8px;
}

.maplibregl-popup-content .actions a,
#relation-sheet .sheet-body .actions a {
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-decoration: none;
  color: var(--text-primary);
}

.hidden {
  display: none;
}

/* Liste des types de relation à cocher */
.kind-actions {
  display: flex;
  gap: 6px;
  margin: 4px 0;
}

.kind-actions button {
  font: inherit;
  font-size: 12px;
  padding: 2px 8px;
  cursor: pointer;
}

#kind-checklist {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--gridline);
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 12px;
}

.kind-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1px 0;
}

.kind-row[hidden] {
  display: none;
}

#kind-match {
  display: block;
  font-size: 12px;
  min-height: 1em;
}

.kind-row label {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  cursor: pointer;
}

.kind-row .kind-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kind-row .kind-only {
  font: inherit;
  font-size: 11px;
  padding: 0 5px;
  cursor: pointer;
}

#evolution {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gridline);
  font-size: 13px;
}

.evolution-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

#share-chart {
  font: inherit;
  font-size: 12px;
  padding: 3px 8px;
  cursor: pointer;
}

.evolution-scale {
  font: inherit;
  font-size: 12px;
  padding: 3px 8px;
  margin-top: 6px;
  cursor: pointer;
}

.evolution-legend {
  display: flex;
  gap: 12px;
  font-size: 12px;
}

.evolution-legend .dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 4px;
}

#share-feedback {
  margin: 4px 0 0;
  font-size: 12px;
  word-break: break-all;
}

.muted {
  color: #6b6b6b;
}

/* ---------- Petits écrans : la page défile, carte en tête en pleine largeur ---------- */
@media (max-width: 899px) {
  body {
    display: block;
    height: auto;
  }

  #topbar {
    padding: 10px 12px;
    gap: 8px;
  }


  #layout {
    display: flex;
    flex-direction: column;
  }

  #map {
    order: -1;
    flex: none;
    width: 100%;
    height: 55vh;
    height: 55svh;
    min-height: 280px;
  }

  #sidebar {
    width: 100%;
    border-right: 0;
    border-top: 1px solid var(--border);
    overflow: visible;
  }

  /* 16 px : sous ce seuil, iOS zoome la page à la saisie */
  #kind-search,
  #search,
  .place-search__input {
    font-size: 16px;
  }

  #relation-table {
    font-size: 13px;
  }

  #relation-table td,
  #relation-table th {
    padding: 9px 10px;
  }

  /* une longue liste d'anomalies déborderait de la carte : elle défile dans la popup */
  .maplibregl-popup-content {
    max-width: none;
    max-height: calc(55svh - 70px);
    overflow-y: auto;
  }
}

/* ---------- Liste des relations à revoir (juste après le suivi) ---------- */
#relation-table caption {
  text-align: left;
  padding: 10px 12px 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

#relation-table tbody tr.is-selected {
  background: var(--page);
  box-shadow: inset 3px 0 0 var(--text-primary);
}

/* ---------- Répartition des erreurs (fin de page) ---------- */
#distribution {
  position: relative;
  padding: 12px;
  border-top: 1px solid var(--gridline);
  font-size: 12px;
}

#distribution h2 {
  font-size: 13px;
  margin: 0 0 4px;
}

#distribution-summary {
  margin: 0 0 8px;
}

.distribution-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.distribution-legend .swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: -1px;
}

.dist-row {
  display: grid;
  grid-template-columns: minmax(0, 45%) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  border-radius: 4px;
  outline: none;
}

.dist-row:hover,
.dist-row:focus-visible {
  background: var(--page);
}

.dist-row:focus-visible {
  box-shadow: 0 0 0 2px var(--text-secondary);
}

.dist-label {
  color: var(--text-secondary);
  line-height: 1.25;
}

.dist-track {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

/* barre fine, extrémité arrondie côté valeur, carrée sur la ligne de base */
.dist-bar {
  display: block;
  flex: none;
  height: 14px;
  border-radius: 0 4px 4px 0;
}

.dist-value {
  flex: none;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.chart-tooltip {
  position: absolute;
  z-index: 5;
  max-width: 260px;
  padding: 6px 8px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(11, 11, 11, 0.12);
  color: var(--text-secondary);
  pointer-events: none;
}

.chart-tooltip strong {
  color: var(--text-primary);
  font-size: 13px;
}

#about-data {
  padding: 0 0 12px;
  border-top: 1px solid var(--gridline);
}

#data-meta {
  margin: 10px 0 0;
  padding: 0 12px;
  font-size: 12px;
}

/* Recherche d'un lieu (js/basemaps.js, PlaceSearchControl) */
.place-search {
  position: relative;
  width: min(260px, calc(100vw - 80px));
}

.place-search__input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  font: inherit;
  font-size: 13px;
  background: #fff;
}

.place-search__results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  z-index: 30;
}

.place-search__results li {
  display: flex;
  flex-direction: column;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.place-search__results li:hover,
.place-search__results li[aria-selected="true"] {
  background: rgba(25, 118, 210, 0.1);
}

.place-search__results .muted {
  font-size: 11px;
}

/* Choix du fond de carte (js/basemaps.js, repris de libre-charge-map) */
.basemap-ctrl {
  position: relative;
  margin: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
.basemap-ctrl__toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 10px 6px 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  background: linear-gradient(180deg, #fff 0%, #f3f5f7 100%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  font: 600 13px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #1a1a1a;
}
.basemap-ctrl__toggle:hover {
  border-color: rgba(25, 118, 210, 0.45);
}
.basemap-ctrl__toggle-text {
  max-width: 9rem;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.basemap-ctrl__icon {
  opacity: 0.75;
}
.basemap-ctrl__chevron {
  font-size: 0.625rem;
  opacity: 0.65;
  transition: transform 0.2s ease;
}
.basemap-ctrl--open .basemap-ctrl__chevron {
  transform: rotate(-180deg);
}
.basemap-ctrl__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: min(260px, calc(100vw - 24px));
  max-height: min(70vh, 520px);
  overflow-y: auto;
  padding: 6px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
  z-index: 30;
}
.maplibregl-ctrl-group.basemap-ctrl button.basemap-ctrl__toggle,
.maplibregl-ctrl-group.basemap-ctrl button.basemap-ctrl__option {
  width: auto;
  height: auto;
}
.maplibregl-ctrl-group.basemap-ctrl button.basemap-ctrl__option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}
.basemap-ctrl__option:hover {
  background: rgba(25, 118, 210, 0.08);
}
.maplibregl-ctrl-group.basemap-ctrl button.basemap-ctrl__option--active {
  background: rgba(25, 118, 210, 0.12);
  outline: 1px solid rgba(25, 118, 210, 0.35);
}
.basemap-ctrl__option-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.basemap-ctrl__option-title {
  font-weight: 600;
  font-size: 0.8125rem;
  color: #111;
}
.basemap-ctrl__option-sub {
  font-size: 0.6875rem;
  color: #666;
}
.basemap-ctrl__swatch {
  flex-shrink: 0;
  width: 44px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.15);
}
.basemap-swatch--grey {
  background: linear-gradient(135deg, #f0f0f0 0%, #c8ccd0 50%, #e8eaec 100%);
}
.basemap-swatch--osm {
  background: linear-gradient(135deg, #acd89a 0%, #7cba6b 40%, #b8dcb0 100%);
}
.basemap-swatch--transport {
  background: linear-gradient(135deg, #9ecae9 0%, #6baed6 45%, #fdd0a2 100%);
}
.basemap-swatch--ortho {
  background: linear-gradient(145deg, #d4c4a8 0%, #9a8b72 50%, #c9b896 100%);
}
.basemap-ctrl__ign {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  padding: 6px 8px 2px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 0.75rem;
  color: #555;
}
.basemap-ctrl__ign select {
  width: 100%;
  font-size: 0.8125rem;
}

/* Alertes Osmose de la relation, dans sa popup */
.osmose-alerts {
  margin: 6px 0;
  font-size: 12px;
}

.osmose-alerts ul {
  margin: 2px 0 0;
  padding-left: 18px;
}

/* Historique de la zone : changements de statut des relations visibles, par jour et par changeset */
#zone-history {
  padding: 12px;
  border-top: 1px solid var(--gridline);
  font-size: 12px;
}
#zone-history h2 {
  font-size: 13px;
  margin: 0 0 4px;
}
#zone-history-summary {
  margin: 0 0 6px;
}
#zone-history-list {
  max-height: 340px;
  overflow-y: auto;
}
.zh-day > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 3px 0;
}
.zh-changeset {
  margin: 4px 0 8px 10px;
  padding-left: 8px;
  border-left: 3px solid var(--gridline);
}
.zh-changeset.zh-breaks { border-left-color: var(--status-cassee); }
.zh-changeset.zh-fixes { border-left-color: var(--status-ok); }
.zh-changeset ul {
  margin: 2px 0 0;
  padding-left: 16px;
}
.zh-links a + a::before {
  content: " · ";
  color: var(--text-muted);
}
.zh-tag {
  display: inline-block;
  padding: 0 5px;
  border-radius: 3px;
  font-size: 11px;
  color: #fff;
}
.zh-tag--casse { background: var(--status-cassee); }
.zh-tag--attention { background: var(--status-attention); color: #0b0b0b; }
.zh-tag--repare { background: var(--status-ok); }
.zh-rel {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  text-decoration: underline dotted;
  cursor: pointer;
}

/* Complétion des itinéraires « nature » (section sous la répartition des erreurs, et popup) */
#completion {
  padding: 12px;
  border-top: 1px solid var(--gridline);
  font-size: 12px;
}
#completion h2 {
  font-size: 13px;
  margin: 0 0 4px;
}
#completion-summary {
  margin: 0 0 8px;
}
#completion-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.completion-card {
  border: 1px solid var(--gridline);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--surface-1);
}
.completion-title { color: var(--text-secondary); }
.completion-value { font-size: 18px; font-weight: 600; }
.completion-track { height: 6px; border-radius: 3px; background: var(--gridline); overflow: hidden; margin: 4px 0; }
.completion-track span { display: block; height: 100%; }
.completion-detail { font-size: 11px; color: var(--text-secondary); }
.popup-completion {
  margin: 6px 0;
  padding: 6px 8px;
  border-left: 3px solid var(--gridline);
  font-size: 0.85rem;
}/* Liens vers les outils spécialisés (popup) et panneau Filum à côté de la carte */
.maplibregl-popup-content .actions button.filum-link {
  font: inherit;
  cursor: pointer;
}

.maplibregl-popup-content .tool-links,
#relation-sheet .sheet-body .tool-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 4px 0;
  font-size: 0.8125rem;
}
#filum-panel {
  display: flex;
  flex-direction: column;
  width: min(32vw, 480px);
  min-width: 340px;
  border-left: 1px solid #ccc;
  background: #fff;
}
#filum-panel[hidden] {
  display: none;
}
#filum-panel header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid #ddd;
}
#filum-panel .filum-title {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#filum-panel .filum-open,
#filum-panel .filum-close {
  font-size: 1.25rem;
  line-height: 1;
  text-decoration: none;
  background: none;
  border: 0;
  cursor: pointer;
  color: inherit;
}
#filum-panel iframe {
  flex: 1;
  width: 100%;
  border: 0;
}
@media (max-width: 800px) {
  #filum-panel {
    position: fixed;
    inset: 0;
    z-index: 50;
    width: 100%;
    min-width: 0;
    border-left: 0;
  }
}

/* Panneau gauche rétractable (grand écran) */
#sidebar-toggle {
  flex: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
body.sidebar-collapsed #sidebar {
  display: none;
}

/* Bouton « Noms » de la carte (comme le bouton kW de Libre Charge Map) */
.maplibregl-ctrl-group .names-map-btn {
  display: block;
  width: auto;
  min-width: 29px;
  height: 29px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  color: #444;
  cursor: pointer;
  border: 0;
  background: #fff;
}
.maplibregl-ctrl-group .names-map-btn--active {
  background: #cfe8ff;
  color: #0a5cad;
}

/* Petit écran : fiche de la relation dans un panneau bas, relevable */
#relation-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  height: 36vh;
  background: #fff;
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.22);
  transition: height 0.2s ease;
}
#relation-sheet[hidden] {
  display: none;
}
#relation-sheet.sheet--dragging {
  transition: none;
}
#relation-sheet .sheet-handle {
  flex: none;
  display: flex;
  justify-content: center;
  padding: 10px 0 8px;
  cursor: grab;
  touch-action: none;
}
#relation-sheet .sheet-handle span {
  width: 44px;
  height: 5px;
  border-radius: 3px;
  background: #b9bec7;
}
#relation-sheet .sheet-close {
  position: absolute;
  top: 4px;
  right: 8px;
  width: 36px;
  height: 36px;
  border: 0;
  background: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: inherit;
}
#relation-sheet .sheet-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 14px 18px;
}
#relation-sheet .sheet-body h3 {
  margin-right: 36px;
}
@media (min-width: 900px) {
  #relation-sheet {
    display: none;
  }
}
@media (max-width: 899px) {
  #sidebar-toggle {
    display: none;
  }
  body.sidebar-collapsed #sidebar {
    display: block;
  }
}

#topbar {
  justify-content: flex-start;
}
#topbar #data-date {
  margin-left: auto;
}

/* Anomalies : icône et origine (validateur JOSM) */
.issue-icon {
  width: 1.1em;
  text-align: center;
}
.issue-origin {
  margin-left: 2px;
  padding: 0 3px;
  border-radius: 3px;
  background: #ede3f5;
  color: #5b2c83;
  font-size: 9px;
  font-weight: 700;
  vertical-align: 1px;
}

/* Historique de la relation (fiche) et panneau des tracés passés */
.history-summary {
  margin: 4px 0;
  font-size: 12px;
}
.history-summary.is-never {
  color: #9b1c1c;
}
.history-actions button {
  font: inherit;
  cursor: pointer;
}
#history-panel {
  display: flex;
  flex-direction: column;
  width: min(32vw, 480px);
  min-width: 340px;
  border-left: 1px solid #ccc;
  background: #fff;
}
#history-panel[hidden] {
  display: none;
}
#history-panel header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid #ddd;
}
#history-panel .history-title {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#history-panel .history-close {
  font-size: 1.25rem;
  line-height: 1;
  background: none;
  border: 0;
  cursor: pointer;
  color: inherit;
}
#history-panel .history-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 16px;
  font-size: 13px;
}
.history-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}
.history-buttons button {
  font: inherit;
  cursor: pointer;
}
.history-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 4px 0 8px;
  padding: 0;
  list-style: none;
  font-size: 12px;
}
.history-legend span {
  display: inline-block;
  width: 14px;
  height: 4px;
  margin-right: 4px;
  border-radius: 2px;
  vertical-align: middle;
}
.history-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.history-card {
  margin: 0;
  padding: 6px;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  background: #fafafa;
}
.history-card:hover,
.history-card:focus-visible {
  border-color: #2b6cb0;
}
.history-card.is-continuous {
  border-color: #2f855a;
  box-shadow: inset 0 0 0 1px #2f855a;
}
.history-card svg {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
}
.history-card figcaption {
  margin-top: 4px;
  font-size: 11px;
}
@media (max-width: 899px) {
  #history-panel {
    position: fixed;
    inset: 0;
    z-index: 50;
    width: 100%;
    min-width: 0;
    border-left: 0;
  }
}

/* Modification d'une relation (js/editor.js) : panneau latéral comme celui des tracés passés */
#edit-panel {
  display: flex;
  flex-direction: column;
  width: min(36vw, 560px);
  min-width: 360px;
  border-left: 1px solid #ccc;
  background: #fff;
}
#edit-panel[hidden] {
  display: none;
}
#edit-panel header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid #ddd;
}
#edit-panel .edit-title {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#edit-panel .edit-close {
  font-size: 1.25rem;
  line-height: 1;
  background: none;
  border: 0;
  cursor: pointer;
  color: inherit;
}
#edit-panel .edit-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 16px;
  font-size: 13px;
}
#edit-panel details {
  margin: 8px 0;
}
#edit-panel summary {
  font-weight: 600;
  cursor: pointer;
}
#edit-panel input,
#edit-panel textarea {
  font: inherit;
  padding: 2px 4px;
  width: 100%;
  box-sizing: border-box;
}
#edit-panel button {
  font: inherit;
  cursor: pointer;
}
.edit-state {
  padding: 6px 8px;
  border-radius: 4px;
  background: #f3f3ef;
}
.edit-state.is-broken {
  border-left: 4px solid var(--status-cassee);
}
.edit-state.is-ok {
  border-left: 4px solid var(--status-ok);
}
.edit-tags {
  width: 100%;
  border-collapse: collapse;
}
.edit-tags td {
  padding: 1px 2px;
}
.edit-tags td:last-child {
  width: 28px;
}
.edit-add {
  display: grid;
  grid-template-columns: 1fr 90px auto;
  gap: 4px;
  margin: 4px 0;
}
.edit-members {
  margin: 4px 0;
  padding-left: 28px;
}
.edit-members li {
  display: grid;
  grid-template-columns: 92px 90px 1fr auto;
  gap: 4px;
  align-items: center;
  padding: 1px 0;
  border-bottom: 1px solid #f0f0f0;
}
.edit-members .m-label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--text-muted);
}
.edit-members .m-tools button {
  padding: 0 5px;
}
.edit-diff {
  margin: 4px 0;
  padding-left: 18px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}
.edit-send {
  border-top: 1px solid #ddd;
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.edit-account label {
  display: block;
  margin: 2px 0;
}
.edit-account input[type=radio] {
  width: auto;
}
.edit-result pre {
  max-height: 260px;
  overflow: auto;
  background: #f6f6f2;
  padding: 6px;
  font-size: 11px;
}
.edit-warn {
  color: var(--status-cassee);
}
@media (max-width: 899px) {
  #edit-panel {
    position: fixed;
    inset: 0;
    z-index: 55;
    width: 100%;
    min-width: 0;
    border-left: 0;
  }
}

/* Éditeur : vues, trous, proposition de chemin, point de passage OSRM */
.edit-views {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 6px 0;
}
.edit-views input[type=radio] {
  width: auto;
}
.edit-gaps ol {
  margin: 4px 0;
  padding-left: 22px;
}
.edit-gaps li button {
  padding: 0 6px;
  margin-left: 4px;
}
.edit-proposal {
  border-left: 4px solid #7b2cbf;
  background: #f7f1fc;
  padding: 6px 8px;
  margin: 6px 0;
}
.edit-josm-steps li {
  margin: 3px 0;
}
.edit-josm-steps a.is-done::after {
  content: " ✓";
  color: var(--status-ok);
}
.edit-via {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #7b2cbf;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px #7b2cbf;
  cursor: grab;
}

/* Explosions des trous visibles (bouton des options) */
.champignon {
  width: 80px;
  height: 100px;
  pointer-events: none;
}
#explode-gaps {
  font: inherit;
  cursor: pointer;
  margin: 6px 0 2px;
}
#explode-status {
  display: block;
  font-size: 12px;
}
@keyframes map-shake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-9px, 5px); }
  20% { transform: translate(8px, -7px); }
  30% { transform: translate(-7px, -4px); }
  40% { transform: translate(6px, 6px); }
  50% { transform: translate(-5px, 3px); }
  60% { transform: translate(4px, -4px); }
  70% { transform: translate(-3px, 2px); }
  80% { transform: translate(2px, -2px); }
  90% { transform: translate(-1px, 1px); }
}
.map-shake {
  animation: map-shake 1.2s ease-out;
}

.basemap-swatch--bleu {
  background: linear-gradient(135deg, #f1f7fc 0%, #cfe2f2 55%, #8fb6d8 100%);
}

/* Tags de la relation dans la fiche : liens vers le wiki OSM, Wikidata mis en valeur */
.popup-tags {
  margin: 4px 0 6px;
  font-size: 12px;
  line-height: 1.7;
}
.popup-tags code {
  background: #f1f4f8;
  border-radius: 3px;
  padding: 1px 4px;
  margin-right: 2px;
}
.popup-wikidata {
  margin: 4px 0;
  padding: 4px 6px;
  border-left: 4px solid #339966;
  background: #eef8f2;
}
.wd-logo {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: #339966;
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  text-align: center;
  line-height: 16px;
  margin-right: 4px;
}
.edit-tags .tag-doc {
  width: 34px;
  white-space: nowrap;
  font-size: 12px;
}

.edit-cert {
  background: #2f855a;
  color: #fff;
  border-radius: 3px;
  padding: 0 4px;
  font-size: 11px;
}

.popup-wikidata.is-missing {
  border-left-color: var(--status-cassee);
  background: #fdeeee;
}
.popup-wikidata.is-missing .wd-label {
  color: var(--status-cassee);
}
