@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --red: #1B4332;
  --orange: #2D6A4F;
  --yellow: #40916C;
  --green: #52B788;
  --blue: #F0F4F0;
  --primary: #FF6B6B;
  --primary-dark: #e55555;
  --bg: #FFF8F6;
  --bg-card: #FFFFFF;
  --bg-warm: #FFF0ED;
  --text: #2D2D3A;
  --text-light: #6B6B80;
  --text-muted: #9B9BAE;
  --border: #F0E4E1;
  --border-light: #F8EDEA;
  --shadow-sm: 0 1px 3px rgba(45, 45, 58, 0.06);
  --shadow-md: 0 4px 12px rgba(45, 45, 58, 0.08);
  --shadow-lg: 0 8px 30px rgba(45, 45, 58, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'DM Sans', sans-serif;
}

::selection {
  background: var(--primary);
  color: white;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== HEADER ===== */
.app-header {
  background: linear-gradient(135deg, var(--red) 0%, var(--orange) 50%, var(--yellow) 100%);
  padding: 24px 20px 20px;
  position: relative;
  overflow: hidden;
}

.app-header::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 70%);
  border-radius: 50%;
}

.header-content {
  max-width: 900px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.logo-icon {
  font-size: 28px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.app-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: white;
  letter-spacing: -0.5px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.app-subtitle {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 300;
  margin-left: 40px;
}

/* ===== TAB NAV ===== */
.tab-nav {
  display: flex;
  gap: 0;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.25s ease;
}

.tab-btn:hover {
  color: var(--text);
  background: var(--bg-warm);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.tab-icon {
  font-size: 18px;
}

/* ===== MAIN ===== */
.main-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 20px 40px;
}

/* ===== ROUTE PLANNER ===== */
.route-planner {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.toolbar-instructions {
  flex: 1;
  min-width: 200px;
}

.instruction-text {
  font-size: 13px;
  color: var(--text-light);
  line-height: 1.4;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-undo {
  background: var(--bg-warm);
  color: var(--text);
}

.btn-undo:hover:not(:disabled) {
  background: var(--border);
}

.btn-clear {
  background: var(--bg-warm);
  color: var(--red);
}

.btn-clear:hover:not(:disabled) {
  background: #ffe0dc;
}

.btn-save {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
}

.btn-save:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
}

.btn-primary {
  background: var(--primary);
  color: white;
  padding: 10px 20px;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-cancel {
  background: var(--bg-warm);
  color: var(--text-light);
  padding: 10px 20px;
  font-size: 14px;
}

.btn-cancel:hover {
  background: var(--border);
}

.btn-load {
  background: var(--blue);
  color: white;
  font-size: 12px;
  padding: 7px 12px;
  box-shadow: 0 2px 6px rgba(77, 150, 255, 0.25);
}

.btn-load:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(77, 150, 255, 0.35);
}

.btn-delete {
  background: var(--bg-warm);
  color: var(--red);
  font-size: 12px;
  padding: 7px 10px;
}

.btn-delete:hover {
  background: #ffe0dc;
}

.confirm-delete {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--red);
  font-weight: 500;
}

.btn-confirm-yes {
  background: var(--red);
  color: white;
  font-size: 11px;
  padding: 4px 10px;
}

.btn-confirm-no {
  background: var(--bg-warm);
  color: var(--text-light);
  font-size: 11px;
  padding: 4px 10px;
}

/* ===== MAP ===== */
.map-wrapper {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.map-container {
  width: 100%;
  height: 55vh;
  min-height: 350px;
  background: #e8e8e8;
}

.stats-overlay {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  z-index: 1000;
  pointer-events: none;
}

.stat-card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.6);
  pointer-events: auto;
}

.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.stat-pace {
  flex: 1;
  min-width: 140px;
}

.pace-slider {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  margin: 4px 0;
}

.pace-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(255, 107, 107, 0.4);
}

.pace-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
}

/* ===== WAYPOINT MARKERS ===== */
.waypoint-marker {
  background: none !important;
  border: none !important;
}

.marker-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(255, 107, 107, 0.5);
  border: 2px solid white;
  cursor: grab;
  transition: transform 0.15s ease;
}

.marker-dot:hover {
  transform: scale(1.15);
}

.marker-dot.marker-start {
  background: var(--green);
  box-shadow: 0 2px 8px rgba(107, 203, 119, 0.5);
  font-size: 16px;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(45, 45, 58, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-warm);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--border);
  color: var(--text);
}

.modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-footer {
  padding: 0 24px 20px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ===== FORMS ===== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
}

.form-input,
.form-textarea {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  transition: all 0.2s ease;
  outline: none;
}

.form-input:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 72px;
}

.difficulty-selector {
  display: flex;
  gap: 6px;
}

.difficulty-btn {
  flex: 1;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.2s ease;
}

.difficulty-btn:hover {
  border-color: var(--primary);
  background: var(--bg-warm);
}

.difficulty-btn.active {
  border-color: var(--primary);
  background: var(--bg-warm);
  box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.15);
}

.difficulty-number {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.difficulty-label {
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.terrain-selector {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.terrain-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-card);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s ease;
}

.terrain-btn:hover {
  border-color: var(--green);
  color: var(--text);
}

.terrain-btn.active {
  background: var(--green);
  color: white;
  border-color: var(--green);
}

.route-summary {
  display: flex;
  gap: 16px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.summary-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-light);
  font-weight: 500;
}

.summary-icon {
  font-size: 16px;
}

/* ===== SAVED ROUTES ===== */
.saved-routes {
  animation: fadeIn 0.3s ease;
}

.routes-header {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.search-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-width: 200px;
  transition: all 0.2s ease;
}

.search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
}

.search-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.sort-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sort-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.sort-select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text);
  outline: none;
  cursor: pointer;
}

.sort-select:focus {
  border-color: var(--primary);
}

/* ===== ROUTE CARDS ===== */
.routes-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.route-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  transition: all 0.25s ease;
  animation: cardFadeIn 0.4s ease both;
  border-left: 4px solid var(--primary);
}

@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.route-card:nth-child(1) { animation-delay: 0s; }
.route-card:nth-child(2) { animation-delay: 0.05s; }
.route-card:nth-child(3) { animation-delay: 0.1s; }
.route-card:nth-child(4) { animation-delay: 0.15s; }
.route-card:nth-child(5) { animation-delay: 0.2s; }
.route-card:nth-child(6) { animation-delay: 0.25s; }

.route-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.route-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.route-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.difficulty-badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: color-mix(in srgb, var(--badge-color) 15%, white);
  color: var(--badge-color);
  border: 1px solid color-mix(in srgb, var(--badge-color) 30%, white);
  white-space: nowrap;
}

.route-card-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.route-stat {
  display: flex;
  align-items: center;
  gap: 5px;
}

.route-stat-icon {
  font-size: 14px;
}

.route-stat-value {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
}

.route-notes {
  font-size: 13px;
  color: var(--text-light);
  line-height: 1.5;
  margin-bottom: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--yellow);
}

.route-card-meta {
  margin-bottom: 12px;
}

.route-date {
  font-size: 12px;
  color: var(--text-muted);
}

.route-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
}

.empty-icon {
  font-size: 56px;
  margin-bottom: 16px;
  opacity: 0.7;
}

.empty-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-text {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 320px;
  margin: 0 auto;
}

/* ===== SKELETON ===== */
.skeleton-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skeleton-card {
  height: 120px;
  background: linear-gradient(90deg, var(--bg-warm) 25%, #fff5f2 50%, var(--bg-warm) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .app-header {
    padding: 18px 16px 16px;
  }

  .app-title {
    font-size: 22px;
  }

  .app-subtitle {
    font-size: 12px;
    margin-left: 36px;
  }

  .main-content {
    padding: 12px 12px 32px;
  }

  .map-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-actions {
    justify-content: stretch;
  }

  .toolbar-actions .btn {
    flex: 1;
    justify-content: center;
  }

  .map-container {
    height: 45vh;
    min-height: 280px;
  }

  .stats-overlay {
    bottom: 8px;
    left: 8px;
    right: 8px;
    gap: 6px;
  }

  .stat-card {
    padding: 6px 10px;
  }

  .stat-value {
    font-size: 14px;
  }

  .route-card {
    padding: 14px 16px;
  }

  .route-name {
    font-size: 16px;
  }

  .route-card-stats {
    gap: 10px;
  }

  .difficulty-selector {
    gap: 4px;
  }

  .difficulty-btn {
    padding: 6px 2px;
  }

  .difficulty-label {
    font-size: 8px;
  }

  .routes-header {
    flex-direction: column;
  }

  .sort-control {
    width: 100%;
  }

  .sort-select {
    flex: 1;
  }

  .modal-content {
    max-height: 85vh;
  }

  .modal-body {
    padding: 16px 18px;
  }

  .route-summary {
    flex-wrap: wrap;
    gap: 10px;
  }
}

<!-- WALKTHROUGH_SCRIPT:
[
  {
    "step": 1,
    "narration": "Welcome to RunRoute! This is your personal running route planner. Let's start by drawing a route on the map.",
    "view": "planner",
    "highlight_selector": ".map-container",
    "wait_for": "tap_to_continue"
  },
  {
    "step": 2,
    "narration": "Tap anywhere on the map to place waypoints. Each tap adds a new point to your route. The first point gets a green start marker.",
    "view": "planner",
    "highlight_selector": ".map-container",
    "wait_for": "user_interaction"
  },
  {
    "step": 3,
    "narration": "As you add waypoints, the distance and estimated time update automatically in the stats bar at the bottom of the map.",
    "view": "planner",
    "highlight_selector": ".stats-overlay",
    "wait_for": "tap_to_continue"
  },
  {
    "step": 4,
    "narration": "Adjust your running pace with the slider to get accurate time estimates. Drag waypoints to fine-tune your route, or right-click to remove them.",
    "view": "planner",
    "highlight_selector": ".stat-pace",
    "wait_for": "tap_to_continue"
  },
  {
    "step": 5,
    "narration": "When you're happy with your route, tap 'Save Route' to give it a name, difficulty rating, terrain type, and notes.",
    "view": "planner",
    "highlight_selector": ".btn-save",
    "wait_for": "user_interaction"
  },
  {
    "step": 6,
    "narration": "Switch to the Saved Routes tab to see all your saved routes. You can search, sort, load them back onto the map, or delete them.",
    "view": "saved",
    "highlight_selector": ".tab-btn:nth-child(2)",
    "wait_for": "tap_to_continue"
  }
]
-->

/* ===== AUTH GATE ===== */
.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, var(--bg) 0%, #fff 100%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px;
  text-align: center;
}

.auth-logo {
  font-size: 42px;
  margin-bottom: 12px;
}

.auth-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.auth-copy {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-light);
  margin-bottom: 22px;
}

.auth-button {
  width: 100%;
  justify-content: center;
}

.auth-userbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.auth-user {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
}

.auth-logout {
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.18);
  color: white;
}

.auth-logout:hover {
  background: rgba(255, 255, 255, 0.28);
}

.btn-photo {
  background: var(--bg-warm);
  color: var(--text);
  font-size: 12px;
  padding: 7px 12px;
}

.btn-photo:hover:not(:disabled) {
  background: var(--border);
}

.route-card-edit {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.route-card-actions-edit {
  margin-top: 12px;
}

.route-photos-section {
  margin: 12px 0 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border-light);
}

.route-photos-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.route-photos-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.route-photos-copy {
  font-size: 12px;
  color: var(--text-light);
  line-height: 1.4;
}

.route-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
}

.route-photo-card {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.route-photo-img {
  width: 100%;
  height: 96px;
  object-fit: cover;
  display: block;
}

.route-photo-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  background: rgba(45, 45, 58, 0.75);
  color: white;
  cursor: pointer;
}

.route-photo-empty {
  font-size: 12px;
  color: var(--text-muted);
}

.route-photo-strip {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}

.route-photo-thumb {
  width: 54px;
  height: 54px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.route-photo-more {
  width: 54px;
  height: 54px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-warm);
  color: var(--text-light);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
}

.routes-analytics {
  margin-bottom: 20px;
  animation: fadeIn 0.3s ease;
}

.routes-analytics-header {
  margin-bottom: 14px;
}

.analytics-section-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.analytics-section-copy {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-light);
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.analytics-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.analytics-card-header {
  margin-bottom: 12px;
}

.analytics-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.analytics-subtitle {
  font-size: 12px;
  color: var(--text-light);
  line-height: 1.4;
}

.analytics-chart-wrap {
  position: relative;
  width: 100%;
}

.analytics-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.analytics-empty {
  height: 100%;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  padding: 16px;
}

@media (max-width: 900px) {
  .analytics-grid {
    grid-template-columns: 1fr;
  }
}

.public-route-directory { margin-bottom: 20px; }
.public-route-filters { margin-bottom: 14px; }
.public-route-card { border-left-color: var(--blue); }
.public-route-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.public-route-meta-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.public-route-actions { flex-wrap: wrap; }
.route-discovery-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.published-pill { font-size: 11px; font-weight: 700; color: var(--blue); background: rgba(77, 150, 255, 0.12); border: 1px solid rgba(77, 150, 255, 0.2); padding: 4px 8px; border-radius: 999px; }
.discover-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-radius: var(--radius-md); background: linear-gradient(135deg, rgba(77, 150, 255, 0.12), rgba(107, 203, 119, 0.12)); border: 1px solid rgba(77, 150, 255, 0.18); margin-bottom: 16px; }
.discover-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; color: var(--text); }
.discover-copy { font-size: 13px; color: var(--text-light); margin-top: 2px; }
.discover-banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.share-toast { margin: 10px 0 14px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg-warm); border: 1px solid var(--border); color: var(--text); font-size: 13px; }
.public-route-loading { padding: 16px 0; color: var(--text-light); font-size: 14px; }
@media (max-width: 640px) { .discover-banner { flex-direction: column; align-items: stretch; } .discover-banner-actions { width: 100%; } .discover-banner-actions .btn { flex: 1; justify-content: center; } }

.route-ai-panel {
  margin-bottom: 20px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.08), rgba(77, 150, 255, 0.08));
  border: 1px solid rgba(255, 107, 107, 0.14);
  box-shadow: var(--shadow-sm);
}

.ai-preference-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.ai-checkbox-row {
  justify-content: flex-end;
}

.ai-checkbox-row .terrain-btn {
  width: 100%;
  justify-content: center;
}

.ai-selected-route-row {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.8);
}

.ai-suggestion-card {
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.ai-suggestion-summary {
  margin-top: 8px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}

.ai-suggestion-list {
  margin: 10px 0 0 18px;
  color: var(--text-light);
  font-size: 13px;
  line-height: 1.6;
}

.ai-suggestion-list li + li {
  margin-top: 4px;
}

.ai-suggestion-rationale {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}

.route-discovery-panel {
  margin-top: 20px;
}

@media (max-width: 900px) {
  .ai-preference-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .ai-preference-grid {
    grid-template-columns: 1fr;
  }
}

.route-discovery-card-actions .btn-photo {
  background: var(--bg-warm);
  color: var(--text);
  font-size: 12px;
  padding: 7px 12px;
}

.route-discovery-card-actions .btn-photo:hover:not(:disabled) {
  background: var(--border);
}

@media print {
  .map-toolbar,
  .route-ai-panel,
  .route-discovery-panel,
  .modal-overlay,
  .route-photo-strip {
    display: none !important;
  }

  .route-planner {
    padding: 0 !important;
  }

  .map-wrapper {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
  }

  .stats-overlay {
    position: static !important;
    margin-top: 12px;
    pointer-events: auto !important;
  }
}
