:root {
  --cairn-green: #2d6a4f;
  --cairn-green-dark: #1b4332;
  --cairn-sand: #f4f1de;
  --cairn-danger: #d62828;
  --cairn-obstacle: #e85d04;
  --cairn-resource: #0077b6;
  --cairn-view: #7b2cbf;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--cairn-sand);
  color: #1d1d1d;
}

#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(27, 67, 50, 0.92);
  color: #fff;
  backdrop-filter: blur(8px);
}

.top-bar h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.top-bar .user-pill {
  font-size: 0.8rem;
  opacity: 0.9;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-icon-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #fff;
}

.top-link-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 0.8rem;
  opacity: 0.9;
}

.net-badge {
  position: fixed;
  top: 52px;
  right: 12px;
  z-index: 1000;
  padding: 5px 10px;
  border-radius: 999px;
  background: #dc3545;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  display: none;
}

.net-badge.visible { display: block; }

.fab {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 50%;
  background: var(--cairn-green);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  cursor: pointer;
}

.fab:active { transform: translateX(-50%) scale(0.96); }

.locate-btn {
  position: fixed;
  bottom: 28px;
  right: 16px;
  z-index: 1000;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  font-size: 1.25rem;
  cursor: pointer;
}

.nav-toggle-btn {
  position: fixed;
  bottom: 28px;
  right: 72px;
  z-index: 1000;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  font-size: 1.25rem;
  cursor: pointer;
}

.nav-toggle-btn.active {
  background: var(--cairn-green);
  color: #fff;
}

.nav-compass {
  position: fixed;
  bottom: 90px;
  left: 16px;
  z-index: 1000;
  width: 100px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(255,255,255,0.95);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  text-align: center;
}

.nav-compass.hidden { display: none; }

.nav-arrow-wrap {
  width: 72px;
  height: 72px;
  margin: 0 auto 6px;
  border-radius: 50%;
  background: #f0f4f0;
  border: 2px solid var(--cairn-green);
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-arrow {
  font-size: 2rem;
  color: var(--cairn-green-dark);
  line-height: 1;
  transition: transform 0.2s ease-out;
  transform-origin: center center;
}

.nav-distance {
  font-size: 1rem;
  font-weight: 700;
  color: var(--cairn-green-dark);
}

.nav-remaining {
  font-size: 0.7rem;
  color: #666;
  margin-top: 2px;
}

.sync-badge {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff3cd;
  color: #664d03;
  font-size: 0.8rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  display: none;
}

.sync-badge.visible { display: block; }

.tools-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #eee;
}

.tools-section h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.tools-desc {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: #666;
}

.tools-meta {
  margin: 0 0 10px;
  font-size: 0.8rem;
  color: #888;
}

.download-progress {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--cairn-green-dark);
  min-height: 1.2em;
  display: none;
}

.download-progress.visible { display: block; }

.hint-center {
  font-size: 0.75rem;
  color: #888;
  margin-top: 12px;
  text-align: center;
}

a.top-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: inherit;
}

.radar-banner {
  position: fixed;
  top: 52px;
  left: 12px;
  right: 12px;
  z-index: 1001;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #fff3cd;
  border: 2px solid #e85d04;
  color: #7c2d12;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.deviation-banner {
  position: fixed;
  top: 52px;
  left: 12px;
  right: 12px;
  z-index: 1002;
  padding: 10px 14px;
  border-radius: 12px;
  background: #dc3545;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 4px 16px rgba(220, 53, 69, 0.4);
  animation: pulse-deviation 1.5s ease-in-out infinite;
}

.deviation-banner.hidden { display: none; }

@keyframes pulse-deviation {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

.radar-banner.has-deviation-above {
  top: 100px;
}

.route-panel.has-deviation {
  bottom: 108px;
}

.radar-close {
  margin-left: auto;
  border: none;
  background: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: inherit;
  line-height: 1;
}

.route-panel {
  position: fixed;
  bottom: 100px;
  left: 12px;
  right: 12px;
  z-index: 999;
  max-height: 160px;
  background: rgba(255,255,255,0.95);
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  overflow: hidden;
}

.route-panel.hidden { display: none; }
.route-panel.collapsed .route-alerts-list { display: none; }

.route-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--cairn-green-dark);
  border-bottom: 1px solid #eee;
}

.route-panel-toggle {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.8rem;
}

.route-alerts-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  max-height: 110px;
  overflow-y: auto;
}

.route-alerts-list li {
  padding: 8px 14px;
  font-size: 0.8rem;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.route-alerts-list li.warning-item {
  background: #fff8e1;
  font-weight: 600;
}

.marker-on-route {
  outline: 3px solid #e85d04;
  outline-offset: 2px;
  border-radius: 50%;
}

/* Profil */
.profile-page {
  min-height: 100vh;
  padding: 20px 16px 40px;
  background: linear-gradient(160deg, #1b4332 0%, #2d6a4f 30%, #f4f1de 100%);
}

.profile-card {
  max-width: 440px;
  margin: 0 auto;
  background: #fff;
  border-radius: 20px;
  padding: 24px 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
}

.profile-header {
  text-align: center;
  margin-bottom: 20px;
}

.profile-avatar {
  font-size: 3rem;
  line-height: 1;
}

.reputation-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  background: #e8f5e9;
  color: var(--cairn-green-dark);
  font-size: 0.8rem;
  font-weight: 600;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 20px 0;
}

.stat-box {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}

.stat-box .num {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--cairn-green-dark);
}

.stat-box .lbl {
  font-size: 0.75rem;
  color: #666;
  margin-top: 4px;
}

.profile-back {
  display: inline-block;
  margin-bottom: 16px;
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop.open { display: flex; }

.modal-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 20px 20px 32px;
}

.modal-sheet h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
}

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.85rem; margin-bottom: 6px; color: #444; }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 10px;
  font-size: 1rem;
}

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

.category-btn {
  padding: 12px;
  border: 2px solid #e5e5e5;
  border-radius: 12px;
  background: #fafafa;
  text-align: left;
  cursor: pointer;
  font-size: 0.9rem;
}

.category-btn.selected {
  border-color: var(--cairn-green);
  background: #e8f5e9;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary { background: var(--cairn-green); color: #fff; }
.btn-secondary { background: #eee; color: #333; }

.alert-popup h3 { margin: 0 0 6px; font-size: 1rem; }
.alert-popup p { margin: 0 0 8px; font-size: 0.85rem; color: #555; }
.vote-row { display: flex; gap: 8px; margin-top: 8px; }
.vote-row button {
  flex: 1;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 0.8rem;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #1b4332 0%, #2d6a4f 40%, #f4f1de 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 20px;
  padding: 28px 24px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.2);
}

.login-card h1 {
  margin: 0 0 4px;
  color: var(--cairn-green-dark);
}

.login-card .subtitle {
  margin: 0 0 24px;
  color: #666;
  font-size: 0.9rem;
}

.tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.tab {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 10px;
  background: #f0f0f0;
  cursor: pointer;
  font-weight: 600;
}
.tab.active { background: var(--cairn-green); color: #fff; }

.error-msg {
  color: var(--cairn-danger);
  font-size: 0.85rem;
  margin-top: 8px;
  min-height: 1.2em;
}

.leaflet-popup-content { margin: 10px 12px; min-width: 180px; }

.post-thumb {
  width: 100%;
  max-height: 120px;
  object-fit: cover;
  border-radius: 8px;
  margin-top: 6px;
}

.hidden { display: none !important; }

/* Signalement */
.report-row { margin-top: 10px; }
.report-btn {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--cairn-danger, #9b2226);
  border-radius: 8px;
  background: #fff;
  color: var(--cairn-danger, #9b2226);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}
.report-btn.reported {
  border-color: #bbb;
  color: #888;
}
.report-reasons { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.report-reason-btn {
  padding: 12px;
  border: 2px solid #e5e5e5;
  border-radius: 10px;
  background: #fafafa;
  text-align: left;
  cursor: pointer;
  font-weight: 600;
}
.report-reason-btn.selected {
  border-color: var(--cairn-green);
  background: #e8f5e9;
}
.btn-danger { background: #9b2226; color: #fff; }
.btn-danger-outline {
  background: #fff;
  color: #9b2226;
  border: 2px solid #9b2226;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 700;
}
.delete-account-block {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e8e8e8;
}

/* Tracés publics */
.tracks-sheet, .track-detail-sheet { max-height: 85vh; overflow-y: auto; }
.tracks-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.track-list-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px;
  border: 1px solid #e8e8e8;
  border-radius: 12px;
  background: #fafafa;
  cursor: pointer;
  text-align: left;
}
.track-list-item:hover { background: #f0f7f2; border-color: var(--cairn-green); }
.track-list-meta { font-size: 0.8rem; color: #666; }
.track-mini-map { height: 180px; border-radius: 12px; margin: 12px 0; overflow: hidden; }
.track-actions { margin-bottom: 16px; }
.track-reviews-section, .track-comments-section { margin-top: 16px; padding-top: 12px; border-top: 1px solid #eee; }
.track-reviews-section h3, .track-comments-section h3 { margin: 0 0 8px; font-size: 1rem; color: var(--cairn-green-dark); }
.star-rating { display: flex; gap: 4px; }
.star-btn {
  border: none;
  background: none;
  font-size: 1.6rem;
  color: #ddd;
  cursor: pointer;
  padding: 0 2px;
}
.star-btn.filled { color: #e9c46a; }
.star-label { font-size: 0.85rem; color: #666; margin: 4px 0 0; }
.track-comment {
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}
.track-comment-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.track-comment p { margin: 0; font-size: 0.9rem; }
.track-comment-delete {
  margin-top: 6px;
  border: none;
  background: none;
  color: #9b2226;
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
}
.btn-link-back {
  border: none;
  background: none;
  color: var(--cairn-green);
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 8px;
  padding: 0;
}
.gpx-endpoint { pointer-events: none; }
