:root {
  --forest: #1F3B2C;
  --forest-dark: #14281D;
  --forest-light: #2E5641;
  --brass: #B8863B;
  --brass-light: #D9AE6D;
  --paper: #F1EAD6;
  --paper-card: #F7F1E3;
  --paper-dark: #E4D8B8;
  --ink: #241F17;
  --ink-soft: #4A4234;
  --stamp-red: #8C3B34;
  --radius: 3px;
  --shadow-card: 0 2px 0 rgba(0,0,0,0.06), 0 6px 16px rgba(20,20,10,0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
}

h1, h2, .card-label, .stamp {
  font-family: 'Fraunces', serif;
}

/* ---------- Header ---------- */

.site-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 18px 28px;
  background: var(--forest);
  color: var(--paper-card);
  border-bottom: 4px solid var(--brass);
}

.stamp {
  flex-shrink: 0;
  border: 2px solid var(--brass-light);
  color: var(--brass-light);
  padding: 6px 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  transform: rotate(-4deg);
  border-radius: var(--radius);
  font-size: 0.85rem;
}

.site-header h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 0.92rem;
  color: var(--paper-dark);
  font-family: 'IBM Plex Mono', monospace;
}

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 0;
  height: calc(100vh - 84px);
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .map-wrap { height: 60vh; }
}

.map-wrap {
  position: relative;
  height: 100%;
}

#map {
  width: 100%;
  height: 100%;
}

.map-controls {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 1000;
  display: flex;
  gap: 10px;
}

.add-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: var(--forest);
  color: var(--paper-card);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85rem;
  box-shadow: var(--shadow-card);
}

.hidden { display: none !important; }

/* ---------- Buttons ---------- */

.btn {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.88rem;
  border: none;
  border-radius: var(--radius);
  padding: 10px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.08s ease, filter 0.15s ease;
  box-shadow: var(--shadow-card);
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn .icon { font-size: 1rem; line-height: 1; }

.btn-forest { background: var(--forest); color: var(--paper-card); }
.btn-brass { background: var(--brass); color: var(--forest-dark); }
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  box-shadow: none;
  border: 1px solid var(--paper-dark);
}

/* ---------- Sidebar / fiches ---------- */

.sidebar {
  position: relative;
  background: var(--paper-card);
  border-left: 3px solid var(--paper-dark);
  overflow-y: auto;
  padding: 24px 20px 40px;
}

.card-index-tab {
  position: absolute;
  top: 20px;
  right: -1px;
  background: var(--brass);
  color: var(--forest-dark);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 8px 4px 10px;
  writing-mode: vertical-rl;
  border-radius: 0 0 0 var(--radius);
  display: none;
}

.sidebar-block + .sidebar-block {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px dashed var(--paper-dark);
}

.sidebar h2 {
  font-size: 1.05rem;
  margin: 0 0 6px;
  color: var(--forest);
  display: flex;
  align-items: center;
  gap: 8px;
}

.count-badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  background: var(--forest);
  color: var(--paper-card);
  padding: 1px 8px;
  border-radius: 10px;
}

.hint {
  margin: 0 0 14px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.index-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.index-cards li {
  background: var(--paper);
  border: 1px solid var(--paper-dark);
  border-left: 4px solid var(--brass);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.08s ease;
}
.index-cards li:hover {
  background: #fff;
  transform: translateX(2px);
}

.card-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--forest-dark);
}

.card-distance {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  color: var(--stamp-red);
  float: right;
}

.card-desc {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--ink-soft);
  clear: both;
}

.empty-note {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-style: italic;
}

/* ---------- Modal (fiche d'ajout) ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 40, 29, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.index-card.add-card,
.index-card.confirm-card {
  background: var(--paper-card);
  background-image:
    repeating-linear-gradient(transparent, transparent 27px, rgba(184,134,59,0.15) 28px);
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius);
  border: 1px solid var(--paper-dark);
  padding: 22px 24px 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}

.confirm-actions {
  flex-wrap: wrap;
}

.btn-danger-solid {
  background: var(--stamp-red);
  color: var(--paper-card);
}

.confirm-distance-ok { color: var(--forest); font-weight: 600; }
.confirm-distance-far { color: var(--stamp-red); font-weight: 600; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 2px solid var(--brass);
  padding-bottom: 8px;
  margin-bottom: 16px;
}

.card-label {
  font-weight: 600;
  color: var(--forest);
  font-size: 1.05rem;
}

.card-number {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.add-card label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 14px;
}

.optional {
  font-weight: 400;
  font-style: italic;
  color: #9a9078;
}

.add-card input,
.add-card textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 0.92rem;
  padding: 8px 10px;
  border: 1px solid var(--paper-dark);
  border-radius: var(--radius);
  background: #fff;
  resize: vertical;
}

.coords-preview {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  color: var(--forest);
  margin: 4px 0 16px;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---------- Footer ---------- */

.site-footer {
  text-align: center;
  padding: 10px;
  background: var(--forest-dark);
}

.site-footer a {
  color: var(--paper-dark);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  text-decoration: none;
  letter-spacing: 0.05em;
  opacity: 0.7;
}
.site-footer a:hover { opacity: 1; text-decoration: underline; }

/* ---------- Badges de statut (carte + fiches) ---------- */

.status-pill {
  display: inline-block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 9px;
  letter-spacing: 0.02em;
}
.status-pill.presente { background: #dcecdf; color: var(--forest-dark); }
.status-pill.disparue { background: #f6dede; color: var(--stamp-red); }
.status-pill.a_verifier { background: #f5e6c8; color: #8a5a12; }
.status-pill.inconnu { background: #e7e2d3; color: var(--ink-soft); }

.card-photo-thumb {
  display: block;
  width: 100%;
  max-height: 120px;
  object-fit: cover;
  border-radius: var(--radius);
  margin: 6px 0;
  border: 1px solid var(--paper-dark);
}

.btn-confirm-onsite {
  margin-top: 8px;
  width: 100%;
  justify-content: center;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--forest-dark);
  color: var(--paper-card);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  z-index: 3000;
  box-shadow: var(--shadow-card);
}

/* ---------- Leaflet popup theming ---------- */

.leaflet-popup-content-wrapper {
  background: var(--paper-card);
  border-radius: var(--radius);
  border: 1px solid var(--paper-dark);
}

.leaflet-popup-tip {
  background: var(--paper-card);
}

.popup-card .popup-title {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  color: var(--forest);
  margin: 0 0 4px;
}

.popup-card .popup-desc {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0 0 6px;
}

.popup-card .popup-meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: var(--brass);
  border-top: 1px dashed var(--paper-dark);
  padding-top: 4px;
}
