/* ═══════════════════════════════════════════════
   Rotas — Design System
   ═══════════════════════════════════════════════ */

:root {
  --bg-dark: #1a1f2e;
  --bg-card: #232939;
  --bg-card-hover: #2a3148;
  --accent: #e8a838;
  --accent-light: #f0c060;
  --accent-dim: rgba(232, 168, 56, 0.15);
  --text: #e8e6e1;
  --text-muted: #8b8d95;
  --text-dim: #5c5e66;
  --border: rgba(255,255,255,0.06);
  --green: #4ade80;
  --blue: #60a5fa;
  --red: #f87171;
  --orange: #fbbf24;
  --cyan: #22d3ee;
  --shadow: 0 8px 32px rgba(0,0,0,0.3);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  padding-top: 48px;
}

/* --- Auth Header Bar --- */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 16px;
  z-index: 2000;
  gap: 10px;
}

.app-header .header-greeting {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.app-header .header-greeting strong {
  color: var(--accent);
  font-weight: 600;
}

.app-header .header-login-btn {
  padding: 6px 16px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--bg-dark);
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 0.78rem;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.app-header .header-login-btn:hover {
  background: var(--accent-light);
}

.app-header .header-logout-btn {
  padding: 4px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.2s;
}

.app-header .header-logout-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

/* ─── Sidebar ─── */
.sidebar {
  width: 380px;
  min-width: 380px;
  background: var(--bg-dark);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  position: relative;
  height: calc(100vh - 48px);
}

.sidebar-header {
  padding: 28px 24px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.6rem;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.sidebar-header h1 span { color: var(--accent); }

.sidebar-header p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ─── Search ─── */
.search-container {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  transition: border-color 0.2s;
}

.search-box:focus-within {
  border-color: var(--accent);
}

.search-box svg {
  width: 16px;
  height: 16px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
}

.search-box input::placeholder {
  color: var(--text-dim);
}

/* ─── Filters ─── */
.filters-container {
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chip {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.filter-chip:hover {
  border-color: var(--accent);
  color: var(--text);
}

.filter-chip.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.filter-dropdown {
  position: relative;
}

.filter-dropdown-btn {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.filter-dropdown-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.filter-dropdown-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.filter-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 180px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 100;
  display: none;
}

.filter-dropdown-menu.open {
  display: block;
}

.filter-dropdown-menu .filter-option {
  padding: 8px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}

.filter-dropdown-menu .filter-option:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

.filter-dropdown-menu .filter-option.selected {
  color: var(--accent);
  font-weight: 600;
}

.filter-dropdown-menu::-webkit-scrollbar { width: 4px; }
.filter-dropdown-menu::-webkit-scrollbar-track { background: transparent; }
.filter-dropdown-menu::-webkit-scrollbar-thumb { background: var(--text-dim); border-radius: 4px; }

/* ─── Results Count ─── */
.results-count {
  padding: 8px 16px;
  font-size: 0.75rem;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

.results-count strong {
  color: var(--accent);
  font-weight: 600;
}

/* ─── Breadcrumb ─── */
.breadcrumb {
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}

.breadcrumb-item {
  cursor: pointer;
  transition: color 0.2s;
}

.breadcrumb-item:hover { color: var(--accent); }
.breadcrumb-item.active { color: var(--accent); font-weight: 600; }
.breadcrumb-sep { opacity: 0.3; font-size: 0.7rem; }

/* ─── Sidebar Content / List ─── */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

.sidebar-content::-webkit-scrollbar { width: 4px; }
.sidebar-content::-webkit-scrollbar-track { background: transparent; }
.sidebar-content::-webkit-scrollbar-thumb { background: var(--text-dim); border-radius: 4px; }

/* ─── Route Card ─── */
.route-card {
  padding: 14px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 4px;
  border: 1px solid transparent;
}

.route-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border);
}

.route-card.active {
  background: var(--accent-dim);
  border-color: rgba(232, 168, 56, 0.25);
}

.route-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.route-card-ref {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.04em;
}

.route-card-ref.type-PR { background: rgba(96,165,250,0.18); color: var(--blue); }
.route-card-ref.type-GR { background: rgba(251,191,36,0.18); color: var(--orange); }
.route-card-ref.type-BTT { background: rgba(74,222,128,0.18); color: var(--green); }
.route-card-ref.type-Ecopista { background: rgba(34,211,238,0.18); color: var(--cyan); }
.route-card-ref.type-Ecovia { background: rgba(34,211,238,0.18); color: var(--cyan); }
.route-card-ref.type-Diogo { background: rgba(217,79,0,0.18); color: #f97316; }
.route-card-ref.type-default { background: rgba(139,141,149,0.15); color: var(--text-muted); }

.route-card-title {
  font-weight: 600;
  font-size: 0.92rem;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-card-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 6px;
}

.route-card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.05);
  color: var(--text-muted);
  font-size: 0.72rem;
}

.meta-tag .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.diff-easy .dot { background: var(--green); }
.diff-moderate .dot { background: var(--orange); }
.diff-hard .dot { background: var(--red); }
.diff-easy { color: var(--green); }
.diff-moderate { color: var(--orange); }
.diff-hard { color: var(--red); }

/* ─── Map ─── */
#map {
  flex: 1;
  height: calc(100vh - 48px);
}

/* ─── Leaflet Overrides ─── */
.leaflet-control-zoom a {
  background: var(--bg-card) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
.leaflet-control-zoom a:hover { background: var(--bg-card-hover) !important; }

.district-label {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  font-family: 'DM Serif Display', serif;
  font-size: 13px;
  color: var(--accent);
  text-shadow: 0 1px 4px rgba(0,0,0,0.8), 0 0 8px rgba(0,0,0,0.5);
  white-space: nowrap;
  pointer-events: none !important;
}

.elev-tooltip {
  background: rgba(26, 31, 46, 0.92) !important;
  border: 1px solid rgba(232, 168, 56, 0.3) !important;
  border-radius: 6px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4) !important;
  padding: 4px 10px !important;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #e8e6e1 !important;
  white-space: nowrap;
  pointer-events: none !important;
}

.elev-tooltip::before {
  border-top-color: rgba(26, 31, 46, 0.92) !important;
}

/* ─── Trail Popup ─── */
.trail-popup {
  font-family: 'DM Sans', sans-serif;
}

.trail-popup h3 {
  font-family: 'DM Serif Display', serif;
  margin-bottom: 4px;
  font-size: 1rem;
  color: #1a1f2e;
}

.trail-popup p {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 2px;
}

.trail-popup .popup-meta {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.trail-popup .popup-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 5px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

/* ─── Loading ─── */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease;
}

.loading-overlay.fade-out { opacity: 0; pointer-events: none; }

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Back Button ─── */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  margin: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.back-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

.back-btn svg { width: 16px; height: 16px; }

/* ─── Trail Detail (rota.html) ─── */
.trail-detail-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.trail-detail-header h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.3rem;
  margin-bottom: 6px;
}

.trail-detail-header .trail-ref {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  display: inline-block;
  margin-bottom: 8px;
}

.trail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 16px 24px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--border);
}

.stat-card .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.stat-card .value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

/* ─── GPX Button ─── */
.gpx-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--bg-dark);
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.gpx-btn:hover { background: var(--accent-light); transform: translateY(-1px); }

/* ─── Elevation Chart ─── */
.elevation-container {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.elevation-container h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 1rem;
  margin-bottom: 12px;
}

.elevation-chart-wrap {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 12px;
  height: 200px;
  position: relative;
}

/* ─── Feedback Section ─── */
.feedback-section {
  padding: 16px 24px;
}

.feedback-section h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 1rem;
  margin-bottom: 12px;
}

.feedback-card {
  background: linear-gradient(135deg, rgba(30,37,56,0.95), rgba(24,30,46,0.98));
  border: 1px solid rgba(232,168,56,0.08);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}

.feedback-card:hover {
  border-color: rgba(232,168,56,0.2);
}

.feedback-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.feedback-author {
  background: rgba(232,168,56,0.12);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.feedback-time {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.feedback-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.feedback-tag {
  background: rgba(78,203,113,0.08);
  color: var(--green);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 0.68rem;
  font-weight: 500;
}

.feedback-text {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 10px;
}

.feedback-estado {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.estado-excelente { background: rgba(78,203,113,0.12); color: var(--green); }
.estado-bom { background: rgba(78,203,113,0.08); color: #8bc78b; }
.estado-razoavel { background: rgba(232,168,56,0.12); color: var(--accent); }
.estado-mau { background: rgba(240,96,80,0.12); color: var(--red); }
.estado-fechado { background: rgba(139,141,149,0.12); color: var(--text-muted); }

.confirm-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.confirm-btn:hover {
  border-color: var(--green);
  color: var(--green);
}

.confirm-btn.confirmed {
  background: rgba(78,203,113,0.12);
  border-color: var(--green);
  color: var(--green);
}

/* ─── Auth Forms ─── */
.auth-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
}

.auth-form h4 {
  font-family: 'DM Serif Display', serif;
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--accent);
}

.form-textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px 14px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  outline: none;
  resize: vertical;
  transition: border-color 0.2s;
}

.form-textarea:focus {
  border-color: var(--accent);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--bg-dark);
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.btn-primary:hover { background: var(--accent-light); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

/* --- Auth Modal --- */
.auth-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-modal {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 380px;
  position: relative;
}

.auth-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.auth-modal-close:hover {
  color: var(--text);
}

/* --- Password Strength --- */
.password-strength {
  margin: 6px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.password-strength-bar {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  position: relative;
  overflow: hidden;
}

.password-strength-bar::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: var(--strength, 0%);
  background: var(--strength-color, var(--red));
  border-radius: 2px;
  transition: width 0.3s, background 0.3s;
}

.password-strength-text {
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ─── Tag Selector ─── */
.tag-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tag-chip {
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.tag-chip:hover {
  border-color: var(--green);
  color: var(--green);
}

.tag-chip.active {
  background: rgba(78,203,113,0.12);
  border-color: var(--green);
  color: var(--green);
  font-weight: 600;
}

/* ─── Empty State ─── */
.empty-state {
  text-align: center;
  padding: 40px 24px;
  color: var(--text-dim);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
}

.empty-state p {
  font-size: 0.88rem;
}

/* ─── Sheet Handle (bottom sheet on mobile) ─── */
.sheet-handle {
  display: none;
}

.sheet-handle-bar {
  width: 40px;
  height: 4px;
  background: var(--text-dim);
  border-radius: 2px;
}

/* ─── Sidebar Scroll Wrapper ─── */
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--text-dim); border-radius: 4px; }

/* ─── Floating Elements (rota.html) ─── */
.float-back-btn {
  display: none;
  position: fixed;
  top: 64px;
  left: 16px;
  z-index: 1001;
  padding: 8px 16px;
  border-radius: 20px;
  background: rgba(35, 41, 57, 0.92);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  align-items: center;
  gap: 6px;
  transition: opacity 0.2s;
}

.float-back-btn svg { width: 14px; height: 14px; }

.float-locate-btn {
  display: flex;
  position: fixed;
  top: 64px;
  right: 16px;
  z-index: 1001;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(35, 41, 57, 0.92);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.2s;
}

/* Inside nav-controls, reset positioning (parent is the container) */
.nav-controls .float-locate-btn {
  position: static;
}

.float-locate-btn svg { width: 18px; height: 18px; }

.float-locate-btn.active {
  color: #4a90d9;
  border-color: rgba(74, 144, 217, 0.4);
}

.float-locate-btn.loading {
  color: var(--accent);
  animation: pulse-locate 1s ease infinite;
}

@keyframes pulse-locate {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.elev-float-overlay {
  position: fixed;
  bottom: 48px;
  left: 0;
  right: 0;
  height: 120px;
  z-index: 999;
  background: rgba(26, 31, 46, 0.92);
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  display: none;
}

/* ─── Rota.html specific layout ─── */
body.rota-page {
  flex-direction: row;
}

body.rota-page .sidebar {
  overflow: hidden;
}


body.rota-page .sidebar::-webkit-scrollbar { width: 4px; }
body.rota-page .sidebar::-webkit-scrollbar-track { background: transparent; }
body.rota-page .sidebar::-webkit-scrollbar-thumb { background: var(--text-dim); border-radius: 4px; }

/* ─── Mobile Responsive ─── */
@media (max-width: 768px) {
  body {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: 100%;
    border-right: none;
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40vh;
    max-height: 95vh;
    z-index: 1000;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
    overflow: visible;
    display: flex;
    flex-direction: column;
  }

  .sheet-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 0 6px;
    cursor: grab;
    touch-action: none;
    flex-shrink: 0;
    user-select: none;
  }

  .sheet-handle-bar {
    width: 44px;
    height: 4px;
  }

  .sidebar-header {
    padding: 4px 16px 10px;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-header h1 {
    font-size: 1.25rem;
    margin-bottom: 2px;
  }

  .sidebar-header p {
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .search-container {
    padding: 8px 12px;
  }

  .search-box {
    padding: 8px 12px;
  }

  .search-box input {
    font-size: 0.85rem;
  }

  .filters-container {
    padding: 8px 12px 10px;
    gap: 6px 6px;
  }

  .filter-chip,
  .filter-dropdown-btn {
    padding: 6px 14px;
    font-size: 0.78rem;
  }

  .filter-dropdown-menu {
    right: 0;
    left: auto;
    max-height: 260px;
  }

  .results-count {
    padding: 6px 12px;
    font-size: 0.72rem;
  }

  .sidebar-content {
    padding: 6px 10px 16px;
    -webkit-overflow-scrolling: touch;
  }

  .route-card {
    padding: 12px 14px;
    margin-bottom: 6px;
  }

  .route-card-title {
    font-size: 0.88rem;
  }

  .route-card-subtitle {
    font-size: 0.74rem;
    margin-bottom: 4px;
  }

  /* Sidebar in collapsed state: only handle + title peek */
  .sidebar[data-state="collapsed"] .sidebar-content,
  .sidebar[data-state="collapsed"] .filters-container,
  .sidebar[data-state="collapsed"] .results-count,
  .sidebar[data-state="collapsed"] .search-container,
  .sidebar[data-state="collapsed"] .sidebar-header p {
    display: none;
  }

  .sidebar[data-state="collapsed"] .sidebar-header {
    border-bottom: none;
    padding: 2px 16px 6px;
  }

  .sidebar[data-state="collapsed"] .sidebar-header h1 {
    font-size: 1.05rem;
    margin-bottom: 0;
  }

  #map {
    height: calc(100vh - 48px);
    width: 100%;
  }

  /* rota.html mobile */
  body.rota-page {
    flex-direction: column;
  }

  body.rota-page .sidebar {
    position: fixed;
    max-height: 95vh;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
    order: unset;
    overflow: visible;
  }

  body.rota-page #map {
    height: calc(100vh - 48px);
    min-height: calc(100vh - 48px);
    order: unset;
  }

  .trail-stats {
    grid-template-columns: 1fr 1fr;
  }

  .elevation-chart-wrap {
    height: 150px;
  }

  .elev-float-overlay.visible {
    display: block;
  }
}

@media (max-width: 380px) {
  .sidebar-header p {
    display: none;
  }

  .trail-stats {
    grid-template-columns: 1fr;
  }
}

/* ─── Navigation Active: hide header ─── */
body.nav-active .app-header {
  display: none;
}

body.nav-active .sidebar {
  top: 0;
  height: 100vh;
}

body.nav-active #map {
  top: 0;
  height: 100vh;
}

/* ═══════════════════════════════════════════════
   Navigation Mode
   ═══════════════════════════════════════════════ */

/* ─── HUD (Heads-Up Display) ─── */
.nav-hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1002;
  display: none;
  justify-content: space-around;
  padding: 8px 12px;
  background: rgba(26, 31, 46, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  gap: 4px;
}

.nav-hud-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 60px;
}

.nav-hud-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.nav-hud-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.nav-accuracy-bad {
  color: var(--red) !important;
}

/* ─── User Marker ─── */
.nav-user-marker {
  background: none !important;
  border: none !important;
}

.nav-arrow {
  transition: transform 0.3s ease;
}


/* ─── Battery Warning ─── */
.nav-battery-warn {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1003;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: rgba(251, 191, 36, 0.92);
  color: var(--bg-dark);
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(251, 191, 36, 0.3);
  animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ─── Navigation Controls ─── */
.nav-controls {
  position: fixed;
  top: 64px;
  right: 16px;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.float-nav-btn {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(74, 144, 217, 0.92);
  border: 1px solid rgba(74, 144, 217, 0.6);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.2s;
}

.float-nav-btn svg { width: 18px; height: 18px; }
.float-nav-btn:hover { background: rgba(74, 144, 217, 1); transform: scale(1.05); }

.float-nav-stop {
  background: rgba(248, 113, 113, 0.92);
  border-color: rgba(248, 113, 113, 0.6);
}
.float-nav-stop:hover { background: rgba(248, 113, 113, 1); }

.float-nav-btn-sm {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(35, 41, 57, 0.92);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.2s;
}

.float-nav-btn-sm svg { width: 16px; height: 16px; }

.float-nav-btn-sm.active {
  color: #4a90d9;
  border-color: rgba(74, 144, 217, 0.4);
  background: rgba(74, 144, 217, 0.15);
}

.float-nav-btn-sm:hover {
  color: var(--text);
  border-color: rgba(255,255,255,0.15);
}

/* ═══════════════════════════════════════════════
   Media Gallery & Upload
   ═══════════════════════════════════════════════ */

/* ─── Media Section ─── */
.media-section {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.media-section h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 1rem;
  margin-bottom: 12px;
}

.media-empty {
  font-size: 0.82rem;
  color: var(--text-dim);
  text-align: center;
  padding: 16px 0;
}

.media-login-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 16px;
  margin-top: 8px;
  background: var(--bg-card);
  border: 2px dashed var(--text-dim);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* ─── Media Grid ─── */
.media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.media-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}

.media-thumb:hover {
  border-color: var(--accent);
}

.media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}

.media-thumb-placeholder svg {
  width: 28px;
  height: 28px;
}

.media-badge-video {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

/* ─── Dropzone ─── */
.media-dropzone {
  background: var(--bg-card);
  border: 2px dashed var(--text-dim);
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 10px;
}

.media-dropzone:hover,
.media-dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.media-dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.85rem;
  min-height: 60px;
}

.media-dropzone-content svg {
  color: var(--accent);
  width: 28px;
  height: 28px;
}

/* ─── Preview ─── */
.media-preview {
  position: relative;
  max-height: 200px;
  overflow: hidden;
  border-radius: var(--radius-sm);
}

.media-preview img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.media-preview-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── Progress bar ─── */
.media-progress {
  height: 4px;
  background: var(--bg-card);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}

.media-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
}

/* ─── Lightbox ─── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: none;
  align-items: center;
  justify-content: center;
}

.lightbox.visible {
  display: flex;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  cursor: pointer;
}

.lightbox-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 95vw;
  max-height: 95vh;
}

.lightbox-media {
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.lightbox-close:hover { background: rgba(255,255,255,0.25); }

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.lightbox-prev { left: -50px; }
.lightbox-next { right: -50px; }
.lightbox-prev:hover,
.lightbox-next:hover { background: rgba(255,255,255,0.2); }

.lightbox-caption {
  color: #fff;
  font-size: 0.9rem;
  margin-top: 12px;
  text-align: center;
}

.lightbox-author {
  color: var(--text-dim);
  font-size: 0.75rem;
  margin-top: 4px;
}

/* ─── Mobile adjustments for nav & media ─── */
@media (max-width: 768px) {
  .nav-hud {
    padding: 6px 8px;
  }

  .nav-hud-value {
    font-size: 0.82rem;
  }

  .nav-controls {
    top: 60px;
    right: 12px;
  }

  .lightbox-prev { left: 8px; }
  .lightbox-next { right: 8px; }
  .lightbox-close { top: 8px; right: 8px; }

  .media-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
  }
}
