/* MotoSpots — palette du brief
   Sunset Orange  #FF6B35   CTA, accents
   Throttle Red   #E63946   Accent secondaire, alertes
   Asphalt Navy   #1D3557   Texte principal, navigation
   Midnight       #0F1B2D   Fond sombre, titres
   Headlight Cream #F1FAEE  Fond clair
   Slate Grey     #6B7280   Texte secondaire
*/
:root {
  --orange: #FF6B35;
  --orange-700: #d9542a;
  --red: #E63946;
  --navy: #1D3557;
  --midnight: #0F1B2D;
  --cream: #F1FAEE;
  --slate: #6B7280;
  --slate-200: #E5E7EB;
  --slate-100: #F3F4F6;
  --shadow: 0 10px 30px rgba(15, 27, 45, 0.18);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--navy);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  /* Évite le délai de 300ms du tap mobile, prévient le double-tap-zoom du navigateur,
     et laisse MapLibre gérer ses propres gestes sur le canvas. */
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
/* iOS Safari zoome automatiquement sur un input avec font-size < 16px → on impose 16. */
input, textarea, select { font-size: 16px; }

main {
  position: absolute;
  inset: 64px 0 0 0;
}
#map { position: absolute; inset: 0; }

/* ─── Topbar ────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 64px;
  background: var(--midnight); color: var(--cream);
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  z-index: 30;
  box-shadow: 0 2px 0 rgba(255, 107, 53, 0.6), 0 4px 18px rgba(0,0,0,0.25);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit;
}
.brand-mark { width: 28px; height: 34px; flex: none; }
.brand-text {
  display: inline-flex; align-items: baseline; gap: 6px;
  min-width: 0;
}
.brand-name {
  font-weight: 800; font-size: 20px; letter-spacing: 0.5px;
  background: linear-gradient(90deg, #fff, var(--orange));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-tag {
  font-size: 11px; letter-spacing: 2px; color: var(--slate);
  text-transform: uppercase;
}

.scope-tabs {
  display: flex; gap: 4px;
  background: rgba(255,255,255,0.04);
  border-radius: 999px;
  padding: 4px;
}
.scope-tabs button {
  border: 0; background: transparent; color: rgba(241,250,238,0.7);
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
  font-size: 13px; font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.scope-tabs button:hover { color: var(--cream); }
.scope-tabs button.active {
  background: var(--orange); color: white;
  box-shadow: 0 4px 12px rgba(255,107,53,0.35);
}

.topbar-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 10px;
}
.user-zone { display: flex; align-items: center; gap: 8px; position: relative; }
.guest-zone { display: flex; gap: 8px; }
.user-zone-logged { display: flex; align-items: center; gap: 8px; position: relative; }
.user-pill { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--orange); color: white;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  overflow: hidden;
  flex: none;
}
.avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.user-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: white; color: var(--navy);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 180px; padding: 6px; z-index: 40;
}
.menu-item {
  width: 100%; text-align: left;
  background: transparent; border: 0; padding: 10px 12px;
  border-radius: 8px; cursor: pointer; font-size: 14px;
}
.menu-item:hover { background: var(--slate-100); }

.badge {
  background: var(--red); color: white; border-radius: 999px;
  font-size: 11px; padding: 1px 6px; margin-left: 4px;
  font-weight: 700;
}

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 10px; cursor: pointer;
  font-size: 14px; font-weight: 600;
  border: 0; transition: filter 0.15s, transform 0.05s, background 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--orange); color: white;
  box-shadow: 0 4px 14px rgba(255,107,53,0.4);
}
.btn-primary:hover { background: var(--orange-700); }
.btn-secondary {
  background: var(--cream); color: var(--navy);
}
.btn-secondary:hover { filter: brightness(0.96); }
.btn-ghost {
  background: rgba(255,255,255,0.06); color: var(--cream);
}
.btn-ghost:hover { background: rgba(255,255,255,0.12); }
.btn-danger {
  background: var(--red); color: white;
}
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ─── Map controls ──────────────────────────────────────── */
.map-controls {
  position: absolute; top: 16px; right: 16px; z-index: 10;
  display: flex; flex-direction: column; gap: 8px;
}
.control-group {
  background: white; border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; padding: 4px;
  gap: 2px;
}
.ctrl {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; border: 0; cursor: pointer;
  padding: 9px 12px; font-size: 13px; font-weight: 600;
  color: var(--navy); border-radius: 8px;
}
.ctrl:hover { background: var(--slate-100); }
.ctrl.active { background: var(--orange); color: white; }
.ctrl-icon { width: 18px; height: 18px; flex: none; display:inline-block; background-size: contain; background-repeat: no-repeat; background-position: center; }

/* SVG icons via background — pas de dépendance externe */
.icon-layers { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%231D3557'><path d='M12 2 1 8l11 6 11-6-11-6Zm0 8.5L4.13 8 12 4l7.87 4L12 10.5ZM1 13l11 6 11-6-1.87-1.02L12 16.5 3.87 11.98 1 13Zm0 5 11 6 11-6-1.87-1.02L12 21.5 3.87 16.98 1 18Z'/></svg>"); }
.icon-3d { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%231D3557'><path d='M12 2 2 7v10l10 5 10-5V7L12 2Zm0 2.18 7.5 3.75L12 11.68 4.5 7.93 12 4.18ZM4 9.46l7 3.5v6.6l-7-3.5v-6.6Zm9 10.1v-6.6l7-3.5v6.6l-7 3.5Z'/></svg>"); }
.icon-target { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%231D3557'><path d='M12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8Zm0 6a2 2 0 1 1 0-4 2 2 0 0 1 0 4Zm9-3h-2.06A7 7 0 0 0 13 5.06V3h-2v2.06A7 7 0 0 0 5.06 11H3v2h2.06A7 7 0 0 0 11 18.94V21h2v-2.06A7 7 0 0 0 18.94 13H21v-2Zm-9 6a5 5 0 1 1 0-10 5 5 0 0 1 0 10Z'/></svg>"); }
.icon-people { width:18px; height:18px; display:inline-block; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23F1FAEE'><path d='M16 11a4 4 0 1 0-4-4 4 4 0 0 0 4 4Zm-8 0a4 4 0 1 0-4-4 4 4 0 0 0 4 4Zm0 2c-2.67 0-8 1.34-8 4v3h10.5v-3c0-1.18.7-2.27 1.83-3.1A14.5 14.5 0 0 0 8 13Zm8 0c-.6 0-1.27.07-1.97.2A5.5 5.5 0 0 1 16 17v3h8v-3c0-2.66-5.33-4-8-4Z'/></svg>"); background-size: contain; background-repeat: no-repeat; }

/* ─── Side panel ────────────────────────────────────────── */
.side-panel {
  position: absolute; top: 16px; left: 16px; bottom: 16px;
  width: 420px; max-width: calc(100vw - 32px);
  background: white; color: var(--navy);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 20;
  overflow-y: auto;
  padding: 18px 20px;
}
.side-panel-flush { padding: 0; }
.side-panel h2 { margin: 0 0 12px; color: var(--midnight); font-size: 22px; }
.side-panel h3 { margin: 14px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--slate); }
.side-panel section + section { margin-top: 18px; }
.panel-close {
  position: absolute; top: 10px; right: 10px;
  background: transparent; border: 0;
  font-size: 24px; cursor: pointer; line-height: 1;
  color: var(--slate);
  z-index: 5;
}
.panel-close:hover { color: var(--midnight); }
.panel-close-floating {
  background: rgba(15, 27, 45, 0.55);
  color: white;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: background 0.15s, transform 0.05s;
}
.panel-close-floating:hover { background: var(--midnight); color: white; transform: scale(1.05); }

/* ─── Spot detail (refactored) ──────────────────────────── */
.spot-detail { display: flex; flex-direction: column; }

.spot-hero {
  position: relative;
  width: 100%; height: 260px;
  background: linear-gradient(135deg, var(--navy), var(--midnight));
  overflow: hidden;
  flex: none;
}
.spot-hero.no-photo {
  background: linear-gradient(135deg, var(--orange), var(--red));
}
.spot-hero-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.spot-hero-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(15,27,45,0) 25%, rgba(15,27,45,0.85) 100%);
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 16px 20px;
  color: var(--cream);
}
.spot-hero-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 10px;
}
.vis-pill.on-dark {
  background: rgba(241,250,238,0.95) !important;
  color: var(--navy) !important;
}
.rating-pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--orange);
  color: white;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(255,107,53,0.4);
}
.rating-pill small { font-weight: 500; opacity: 0.9; font-size: 11px; }
.spot-hero-title {
  margin: 0 0 4px;
  font-size: 28px; line-height: 1.1;
  font-weight: 800; letter-spacing: -0.5px;
  color: white;
  text-shadow: 0 2px 12px rgba(0,0,0,0.5);
}
.spot-hero-author {
  margin: 0;
  font-size: 13px;
  color: rgba(241,250,238,0.85);
}
.spot-hero-author strong { color: white; font-weight: 700; }

/* Strip de vignettes sous la hero */
.spot-photo-strip {
  display: flex; gap: 8px;
  padding: 12px 20px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  background: var(--cream);
  border-bottom: 1px solid var(--slate-200);
}
.spot-photo-strip::-webkit-scrollbar { height: 4px; }
.spot-photo-strip::-webkit-scrollbar-thumb { background: var(--slate-200); border-radius: 2px; }
.strip-thumb {
  flex: 0 0 auto;
  width: 64px; height: 64px;
  padding: 0; margin: 0;
  background: transparent;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  scroll-snap-align: start;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.15s;
}
.strip-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.strip-thumb.active { border-color: var(--orange); }
.strip-thumb:hover { transform: scale(1.05); }

.spot-body {
  padding: 18px 20px 20px;
  display: flex; flex-direction: column; gap: 16px;
}
.spot-meta-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--cream);
  border: 1px solid var(--slate-200);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--navy);
  font-weight: 500;
  max-width: 100%;
}
.chip-icon { font-size: 13px; flex: none; }

.spot-description {
  margin: 0;
  font-size: 14px; line-height: 1.55;
  color: var(--navy);
  white-space: pre-wrap;
}

.spot-section { display: flex; flex-direction: column; gap: 10px; }
.spot-section-head {
  display: flex; align-items: center; justify-content: space-between;
}
.spot-section-head h3 {
  margin: 0; font-size: 13px;
  text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--slate);
  font-weight: 700;
}
.rating-block {
  display: flex; align-items: center; gap: 8px;
}
.rating-num {
  font-size: 24px; font-weight: 800; line-height: 1;
  color: var(--midnight);
}
.rating-block .stars {
  color: var(--orange); font-size: 13px; letter-spacing: 1.5px;
}

.reviews-list { display: flex; flex-direction: column; gap: 8px; }
.review-card {
  background: var(--cream);
  border-left: 3px solid var(--orange);
  padding: 10px 12px;
  border-radius: 0 10px 10px 0;
}
.review-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
  font-size: 13px;
}
.review-card-head strong { color: var(--midnight); }
.review-card-head .stars {
  color: var(--orange); font-size: 13px; letter-spacing: 1px;
}
.review-card p {
  margin: 0;
  font-size: 13px; line-height: 1.5;
  color: var(--navy);
}
.muted.small { font-size: 13px; }

.spot-actions-bar {
  display: flex; gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--slate-200);
  margin-top: 4px;
}
.spot-actions-bar .btn-secondary { flex: 1; justify-content: center; }
.spot-actions-bar .btn-danger { flex: 0 0 auto; }
.spot-meta {
  display: flex; flex-wrap: wrap; gap: 8px 14px;
  font-size: 13px; color: var(--slate);
  margin: 4px 0 12px;
}
.rating {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 700; color: var(--midnight);
}
.rating .stars { color: var(--orange); letter-spacing: 1px; }

.review-list { display: flex; flex-direction: column; gap: 10px; }
.review {
  background: var(--slate-100); border-radius: 10px; padding: 10px 12px;
}
.review-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; margin-bottom: 4px;
}
.review-head strong { color: var(--midnight); }
.review-head .stars { color: var(--orange); }
.review p { margin: 0; font-size: 14px; line-height: 1.45; }

.review-form {
  background: var(--cream); border-radius: 10px; padding: 12px;
  margin-top: 10px;
}
.review-form .stars-input { display: flex; gap: 2px; margin: 4px 0 8px; }
.review-form .stars-input button {
  background: transparent; border: 0; cursor: pointer;
  font-size: 22px; color: var(--slate-200);
  padding: 0 2px;
}
.review-form .stars-input button.active,
.review-form .stars-input button:hover { color: var(--orange); }
.review-form textarea {
  width: 100%; min-height: 60px; resize: vertical;
  border: 1px solid var(--slate-200); border-radius: 8px;
  padding: 8px; font: inherit;
}

/* ─── User list (friends panel) ─────────────────────────── */
.user-list { display: flex; flex-direction: column; gap: 6px; }
.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  background: var(--slate-100);
}
.user-row .avatar { background: var(--navy); }
.user-row .user-meta { flex: 1; min-width: 0; }
.user-row .user-meta strong { display: block; }
.user-row .user-meta small { color: var(--slate); }
.user-row .row-actions { display: flex; gap: 6px; }
.muted { color: var(--slate); font-weight: 400; font-size: 12px; }
.search-row { display: flex; gap: 8px; margin-bottom: 8px; }
.search-row input {
  flex: 1; padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--slate-200);
  font: inherit;
}

/* ─── Visibility pill (used in many places) ─────────────── */
.vis-pill {
  display: inline-block;
  font-size: 11px; padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700; letter-spacing: 0.2px;
  white-space: nowrap;
}
.vis-pill.public  { background: rgba(255,107,53,0.15); color: var(--orange-700); }
.vis-pill.friends { background: rgba(29,53,87,0.14); color: var(--navy); }
.vis-pill.private { background: rgba(107,114,128,0.18); color: var(--slate); }

/* ─── Profile panel (refactored) ────────────────────────── */
.profile-content { display: flex; flex-direction: column; }

.profile-hero {
  background:
    radial-gradient(ellipse at top right, rgba(255,107,53,0.25), transparent 60%),
    linear-gradient(135deg, var(--midnight) 0%, var(--navy) 100%);
  color: var(--cream);
  padding: 24px 20px 22px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.avatar-xl {
  width: 64px; height: 64px;
  font-size: 28px;
  background: var(--orange);
  flex: none;
  box-shadow: 0 4px 18px rgba(255,107,53,0.4);
}
.profile-hero-info { flex: 1; min-width: 0; }
.profile-hero-info h2 {
  margin: 0;
  color: white;
  font-size: 24px; font-weight: 800;
  letter-spacing: -0.3px;
}
.profile-handle {
  margin: 2px 0 0;
  font-size: 13px;
  color: rgba(241,250,238,0.65);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.profile-bio {
  margin: 10px 0 0;
  font-size: 13px; line-height: 1.45;
  color: rgba(241,250,238,0.92);
  font-style: italic;
}
.profile-moto {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--orange);
  font-weight: 700;
  letter-spacing: 0.3px;
}

/* Stats grid */
.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 16px 20px 0;
}
.profile-stat {
  background: var(--cream);
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 10px 6px 8px;
  text-align: center;
  transition: transform 0.05s;
}
.profile-stat:hover { transform: translateY(-1px); }
.profile-stat .stat-icon {
  display: block;
  font-size: 18px;
  margin-bottom: 4px;
  filter: grayscale(0.15);
}
.profile-stat strong {
  display: block;
  font-size: 20px; line-height: 1;
  font-weight: 800;
  color: var(--midnight);
}
.profile-stat small {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 700;
}
.profile-stat.stat-public strong { color: var(--orange); }
.profile-stat.stat-friends strong { color: var(--navy); }
.profile-stat.stat-private strong { color: var(--slate); }

.profile-section {
  padding: 18px 20px 24px;
  display: flex; flex-direction: column; gap: 12px;
}
.profile-section-head {
  display: flex; align-items: center; justify-content: space-between;
}
.profile-section-head h3 {
  margin: 0;
  font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--slate);
}

/* Filter pills */
.filter-pills {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.filter-pill {
  font: inherit;
  font-size: 12px; font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--cream);
  border: 1.5px solid var(--slate-200);
  color: var(--navy);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
}
.filter-pill:hover { border-color: var(--orange); }
.filter-pill.active {
  background: var(--orange);
  border-color: var(--orange);
  color: white;
  box-shadow: 0 4px 10px rgba(255,107,53,0.3);
}

/* Spot cards (in profile) */
.profile-spots-grid {
  display: flex; flex-direction: column; gap: 8px;
}
.spot-card {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 12px;
  align-items: center;
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.05s, box-shadow 0.15s;
}
.spot-card:hover {
  border-color: var(--orange);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(255,107,53,0.12);
}
.spot-card:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.spot-card-thumb {
  position: relative;
  width: 80px; height: 80px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--slate-100);
  flex: none;
}
.spot-card-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.spot-card-noimg {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  font-size: 24px; color: var(--slate);
  background: var(--slate-100);
}
.vis-pill.on-thumb {
  position: absolute;
  top: 4px; left: 4px;
  font-size: 9px;
  padding: 1px 6px;
  background: rgba(15,27,45,0.75) !important;
  color: white !important;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.spot-card-info { min-width: 0; }
.spot-card-info strong {
  display: block;
  color: var(--midnight);
  font-size: 14px; font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.spot-card-info small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--navy);
}
.spot-card-info small.muted { color: var(--slate); font-style: italic; }
.stars-mini { color: var(--orange); }
.spot-card-actions {
  display: flex; flex-direction: column; gap: 4px; flex: none;
}
.icon-btn {
  width: 30px; height: 30px;
  border: 0; border-radius: 8px;
  background: var(--slate-100);
  color: var(--navy);
  cursor: pointer;
  font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--orange); color: white; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 30px 20px;
  background: var(--cream);
  border-radius: 12px;
  color: var(--slate);
}
.empty-state .empty-icon {
  display: block;
  font-size: 36px;
  margin-bottom: 8px;
  opacity: 0.5;
}
.empty-state p { margin: 0; font-size: 13px; }

/* ─── Modal ─────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; background: rgba(15,27,45,0.6);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-card {
  background: white; border-radius: var(--radius);
  width: 520px; max-width: 100%; max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-card.narrow { width: 380px; }
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--slate-200);
}
.modal-head h2 { margin: 0; color: var(--midnight); font-size: 18px; }
.modal-close {
  background: transparent; border: 0; font-size: 24px;
  cursor: pointer; color: var(--slate); line-height: 1;
}
.modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.modal-body label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 13px; font-weight: 600; color: var(--midnight);
}
.modal-body input, .modal-body textarea {
  font: inherit; padding: 9px 12px;
  border: 1px solid var(--slate-200); border-radius: 8px;
  background: white; color: var(--navy);
}
.modal-body input:focus, .modal-body textarea:focus {
  outline: 2px solid var(--orange); outline-offset: 0; border-color: transparent;
}
.modal-body textarea { resize: vertical; }
.modal-body input[readonly] { background: var(--slate-100); }
.modal-body label.checkbox {
  flex-direction: row; align-items: center; gap: 8px; font-weight: 500;
}
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--slate-200);
}
.modal-foot .btn-ghost { background: var(--slate-100); color: var(--navy); }
.modal-foot .btn-ghost:hover { background: var(--slate-200); }

/* ─── Visibility radio group ────────────────────────────── */
.visibility-group {
  border: 0; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.visibility-group legend {
  font-size: 13px; font-weight: 600; color: var(--midnight);
  margin-bottom: 4px;
}
.vis-opt { position: relative; cursor: pointer; }
.vis-opt input { position: absolute; opacity: 0; pointer-events: none; }
.vis-card {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border-radius: 10px;
  border: 1.5px solid var(--slate-200);
  background: white;
  transition: border-color 0.15s, background 0.15s;
}
.vis-card strong { font-size: 14px; color: var(--midnight); }
.vis-card small { font-size: 12px; color: var(--slate); }
.vis-opt input:checked + .vis-card {
  border-color: var(--orange);
  background: rgba(255,107,53,0.06);
}
.vis-opt input:focus-visible + .vis-card {
  outline: 2px solid var(--orange); outline-offset: 2px;
}

/* ─── Existing photos in edit modal ─────────────────────── */
.existing-photos {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.existing-photo {
  position: relative;
  width: 80px; height: 80px;
  border-radius: 8px; overflow: hidden;
  background: var(--slate-100);
}
.existing-photo img {
  width: 100%; height: 100%; object-fit: cover;
}
.existing-photo button {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  border: 0; border-radius: 50%;
  background: rgba(15,27,45,0.8); color: white;
  cursor: pointer; font-size: 14px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.existing-photo button:hover { background: var(--red); }

.address-row { display: flex; gap: 6px; }
.address-row input { flex: 1; }
.coords-row { display: flex; gap: 8px; }
.coord { flex: 1; }
.coord input { width: 100%; }
.hint { font-size: 12px; color: var(--slate); margin-top: -4px; }
.photo-previews {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.photo-previews img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px;
}

/* ─── Settings modal ────────────────────────────────────── */
.settings-avatar {
  display: flex; align-items: center; gap: 14px;
  padding: 4px 0 14px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--slate-200);
}
.settings-avatar .avatar {
  box-shadow: 0 4px 16px rgba(255, 107, 53, 0.35);
}
.settings-avatar-actions {
  display: flex; flex-direction: column; gap: 6px;
  flex: 1;
}
#settingsForm {
  display: flex; flex-direction: column; gap: 12px;
}
#settingsForm label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 13px; font-weight: 600;
}
#settingsForm input, #settingsForm textarea {
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
}
#settingsForm textarea { resize: vertical; }

.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.auth-form input { padding: 10px 12px; border: 1px solid var(--slate-200); border-radius: 8px; font: inherit; }
.auth-toggle { font-size: 13px; text-align: center; color: var(--slate); margin: 4px 0 0; }
.auth-toggle a { color: var(--orange); text-decoration: none; font-weight: 600; }

/* ─── Toast ────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--midnight); color: white;
  padding: 10px 16px; border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 200; font-size: 14px;
}
.toast.error { background: var(--red); }
.toast.ok { background: var(--orange); }

/* ─── Map markers ───────────────────────────────────────── */
/* La racine .spot-marker est positionnée par MapLibre via inline transform.
   On NE met PAS de transition dessus → sinon le navigateur anime chaque pan/zoom
   et le marker flotte. L'enfant .spot-marker-pin porte tout le visuel. */
.spot-marker {
  width: 30px; height: 36px;
  cursor: pointer;
  /* pas de transform / transition ici — réservé à MapLibre */
}
.spot-marker-pin {
  width: 100%; height: 100%;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 36'><path d='M15 0 C7 0 0 7 0 15 C0 24 15 36 15 36 S30 24 30 15 C30 7 23 0 15 0Z' fill='%23FF6B35' stroke='%230F1B2D' stroke-width='1.5'/><circle cx='15' cy='15' r='5' fill='%230F1B2D'/></svg>") no-repeat center / contain;
  transition: transform 0.15s ease-out;
  transform-origin: 50% 100%;
  pointer-events: none;
}
.spot-marker-pin.mine {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 36'><path d='M15 0 C7 0 0 7 0 15 C0 24 15 36 15 36 S30 24 30 15 C30 7 23 0 15 0Z' fill='%23E63946' stroke='%230F1B2D' stroke-width='1.5'/><circle cx='15' cy='15' r='5' fill='%230F1B2D'/></svg>");
}
.spot-marker-pin.friend {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 36'><path d='M15 0 C7 0 0 7 0 15 C0 24 15 36 15 36 S30 24 30 15 C30 7 23 0 15 0Z' fill='%231D3557' stroke='%230F1B2D' stroke-width='1.5'/><circle cx='15' cy='15' r='5' fill='%23F1FAEE'/></svg>");
}
.spot-marker-pin.adding {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 36'><path d='M15 0 C7 0 0 7 0 15 C0 24 15 36 15 36 S30 24 30 15 C30 7 23 0 15 0Z' fill='%23FF6B35' stroke='%23E63946' stroke-width='2'/><text x='15' y='20' font-size='14' text-anchor='middle' fill='white' font-family='sans-serif' font-weight='bold'>+</text></svg>");
}
.spot-marker:hover .spot-marker-pin { transform: scale(1.15); }

/* MapLibre ctrl theming */
.maplibregl-ctrl-group { box-shadow: var(--shadow) !important; border-radius: 8px !important; }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; background: rgba(15,27,45,0.92);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 20px; cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* ─── Responsive ─────────────────────────────────────────
   Stratégie mobile :
   • topbar = 2 lignes, sticky, ne se compresse plus :
       Ligne 1 : logo + (add, friends, user)
       Ligne 2 : tabs de scope (scroll horizontal si besoin)
   • side-panels = bottom sheets (slide depuis le bas)
   • modale = bottom sheet
   • controls map en bas-droite
   • safe-area-inset pour notch / home indicator
   • touch-action et user-scalable=no → seul MapLibre zoome
*/
@media (max-width: 768px) {
  /* La topbar passe en 2 rangées via flex-wrap. La rangée 1 contient le brand
     et la zone d'actions ; la rangée 2 est la scope-tabs (flex-basis 100%). */
  .topbar {
    height: auto;
    min-height: 52px;
    flex-wrap: wrap;
    align-items: center;
    align-content: flex-start;
    column-gap: 8px;
    row-gap: 4px;
    padding: 6px 10px;
    padding-top: max(6px, env(safe-area-inset-top));
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }
  main {
    /* hauteur effective du topbar mobile = ~52 (rangée 1) + 40 (rangée 2) + safe-top */
    top: calc(94px + env(safe-area-inset-top));
  }

  .brand { flex: 0 0 auto; min-width: 0; gap: 8px; }
  /* Brand stacké : nom au-dessus, baseline en-dessous → équilibre la rangée 1 */
  .brand-text {
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    line-height: 1;
  }
  .brand-name { font-size: 19px; line-height: 1; }
  .brand-tag {
    font-size: 8.5px;
    letter-spacing: 1.4px;
    color: rgba(241, 250, 238, 0.45);
    margin: 0;
  }
  .brand-mark { width: 26px; height: 32px; }

  /* Bloc actions à droite */
  .topbar-right {
    margin-left: auto;
    gap: 6px;
    flex: 0 0 auto;
  }
  .topbar-right .btn-secondary { display: none; }
  #addSpotBtn {
    padding: 8px 10px;
    width: 40px; height: 40px;
    justify-content: center;
  }
  #addSpotBtn .btn-label { display: none; }
  #userMenuBtn {
    padding: 4px;
    width: 40px; height: 40px;
    justify-content: center;
  }
  #userMenuBtn #userName { display: none; }
  .user-menu { right: 0; }

  /* Login button compact mais texte conservé */
  #loginBtn { padding: 8px 10px; }

  /* Friends button = juste l'icône, badge en pastille */
  #friendsBtn {
    padding: 8px 10px;
    width: 40px; height: 40px;
    justify-content: center;
    position: relative;
  }
  #friendsBtn .badge {
    position: absolute;
    top: 2px; right: 2px;
    margin: 0;
    min-width: 18px; height: 18px;
    border-radius: 9px;
    padding: 0 4px;
    line-height: 18px;
    text-align: center;
  }

  /* Scope tabs : 2e rangée, pleine largeur, segmented control */
  .scope-tabs {
    order: 99;                     /* force le placement en bas */
    flex-basis: 100%;
    flex-shrink: 0;
    margin: 0;
    padding: 4px;
    height: 40px;
    border-radius: 999px;
    gap: 2px;
  }
  /* Chaque onglet prend une part égale du rail → no empty space */
  .scope-tabs button {
    flex: 1;
    padding: 6px 8px;
    font-size: 12px;
    white-space: nowrap;
    min-height: 30px;
    text-align: center;
  }

  /* ── Side panels = bottom sheets ── */
  .side-panel {
    top: auto;
    left: 0; right: 0;
    bottom: 0;
    width: 100%; max-width: 100%;
    max-height: 78vh;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 28px rgba(15, 27, 45, 0.25);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .side-panel::before {
    content: "";
    position: absolute;
    left: 50%; top: 6px;
    transform: translateX(-50%);
    width: 36px; height: 4px;
    background: var(--slate-200);
    border-radius: 2px;
    z-index: 4;
    pointer-events: none;
  }
  .side-panel-flush { padding: 0; }
  .side-panel-flush::before { background: rgba(255,255,255,0.5); }

  /* Map controls en bas-droite */
  .map-controls {
    top: auto;
    bottom: calc(16px + env(safe-area-inset-bottom));
    right: 12px;
    left: auto;
  }
  .control-group { flex-direction: column; }

  /* Modale = bottom sheet */
  .modal { padding: 0; align-items: flex-end; }
  .modal-card {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-card.narrow { width: 100%; }
  .modal-head { padding: 14px 16px; }
  .modal-body { padding: 16px; }
  .modal-foot { padding: 12px 16px; flex-wrap: wrap; }
  .modal-foot .btn { flex: 1; justify-content: center; }
  .modal-foot .btn-danger { flex: 0 0 auto; }

  .spot-hero { height: 220px; }
  .spot-hero-title { font-size: 22px; }

  .profile-stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* Cibles tactiles élargies */
  .filter-pill { padding: 8px 14px; font-size: 13px; min-height: 36px; }
  .icon-btn { width: 36px; height: 36px; font-size: 16px; }
  .ctrl { padding: 11px 14px; min-height: 44px; }
}

@media (max-width: 380px) {
  .brand-name { font-size: 17px; }
  .brand-tag { font-size: 7.5px; letter-spacing: 1.2px; }
  .scope-tabs button { padding: 5px 4px; font-size: 11px; }
  .visibility-group .vis-card { padding: 8px 10px; }
  .vis-card strong { font-size: 13px; }
  .vis-card small { font-size: 11px; }
  /* Boutons d'action légèrement plus serrés */
  .topbar-right { gap: 4px; }
  #addSpotBtn, #userMenuBtn, #friendsBtn { width: 38px; height: 38px; }
}

/* Tablette : panel un poil plus large */
@media (min-width: 769px) and (max-width: 1100px) {
  .side-panel { width: 380px; }
}

.hidden { display: none !important; }
[hidden] { display: none !important; }
