/* ===== Design Tokens ===== */
:root {
  --bg-primary: #0d0d0f;
  --bg-secondary: #161618;
  --bg-card: #1c1c1f;
  --bg-card-hover: #252528;
  --bg-surface: #2a2a2e;
  --text-primary: #e8e8ec;
  --text-secondary: #9a9aa0;
  --text-dim: #65656c;
  --accent: #00c6a7;
  --accent-glow: rgba(0, 198, 167, 0.15);
  --accent-hover: #00debb;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-card: 0 2px 12px rgba(0,0,0,0.4);
  --shadow-hover: 0 8px 32px rgba(0,0,0,0.5);
  --font-sans: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-surface); border-radius: 3px; }

/* ===== Layout ===== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 13, 15, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), #0088ff);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cam-thumb::after {
    content: "📷";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: rgba(255, 255, 255, 0.2);
    z-index: 0;
    pointer-events: none;
}


.header-nav a {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.header-nav a:hover, .header-nav a.active {
  color: var(--text-primary);
  background: var(--bg-surface);
}

/* ===== Hero / Map Section ===== */
.hero {
  padding: 40px 0 20px;
  text-align: center;
}

.hero h1 {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #fff 30%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.hero p {
  color: var(--text-secondary);
  font-size: 15px;
  max-width: 500px;
  margin: 0 auto;
}


.map-label {
  position: absolute;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  pointer-events: none;
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 600;
}



/* ===== Category Grid (Homepage) ===== */
.categories-section {
  padding: 20px 0 60px;
  content-visibility: auto;
  contain-intrinsic-size: 1000px;
}

.categories-section h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
  padding-left: 4px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.category-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
}

.category-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.category-card .cat-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.category-card .cat-info h3 {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.category-card .cat-info span {
  font-size: 11px;
  color: var(--text-dim);
}

/* ===== Category Page ===== */
.page-header {
  padding: 32px 0 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 18px;
  flex-shrink: 0;
}

.back-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.page-header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-header .badge {
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 3px 10px;
  border-radius: 99px;
  font-weight: 600;
  margin-left: 4px;
}

.cam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding: 16px 0 60px;
}

.cam-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all var(--transition);
  cursor: pointer;
}

.cam-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.cam-card .cam-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    background: linear-gradient(90deg, #1e1e1e 25%, #2a2a2a 50%, #1e1e1e 75%);
    background-size: 400% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    position: relative;
    overflow: hidden;
}

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

.cam-thumb img, .cam-thumb iframe {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border: none;
    position: absolute;
    inset: 0;
    z-index: 1;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.cam-card:hover .cam-thumb img {
  transform: scale(1.05);
}

.preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  z-index: 1;
}

.load-more-btn {
  display: block;
  width: 100%;
  max-width: 200px;
  margin: 24px auto 0;
  padding: 12px 20px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.load-more-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  color: var(--accent);
}

.cam-card .cam-thumb .live-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(220, 38, 38, 0.9);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.cam-card .cam-thumb .live-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.cam-card .cam-body {
  padding: 12px 14px;
}

.cam-card .cam-body h3 {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cam-card .cam-body .cam-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ===== Video Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 800px;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.3s;
}

.modal-overlay.open .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.modal-video {
  position: relative;
  padding-bottom: 56.25%;
  background: #000;
}

.modal-video iframe,
.modal-video img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.modal-video img {
  object-fit: contain;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-footer .source-link {
  font-size: 12px;
  color: var(--accent);
  transition: color var(--transition);
}

.modal-footer .source-link:hover {
  color: var(--accent-hover);
}

/* ===== Global Search Section ===== */
.global-search-section {
  padding: 48px 0 24px;
  text-align: center;
}

.search-title {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #fff 30%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}

.search-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 24px;
}

.search-subtitle strong {
  color: var(--accent);
  font-weight: 700;
}

.global-search-wrapper {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
}

.global-search-bar {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 0 16px;
  transition: all 0.25s ease;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

.global-search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow), 0 4px 20px rgba(0,0,0,0.3);
}

.gs-icon {
  color: var(--text-dim);
  flex-shrink: 0;
  transition: color 0.2s;
}

.global-search-bar:focus-within .gs-icon {
  color: var(--accent);
}

.global-search-bar input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 16px;
  font-family: var(--font-sans);
  padding: 14px 12px;
  outline: none;
  min-width: 0;
}

.global-search-bar input::placeholder {
  color: var(--text-dim);
}

.gs-shortcut {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  pointer-events: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.gs-clear {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}

.gs-clear:hover {
  background: rgba(255,255,255,0.15);
  color: var(--text-primary);
}

/* Search Results Dropdown */
.gs-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-hover);
  border-radius: 14px;
  max-height: 420px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  animation: gsSlideIn 0.15s ease-out;
}

@keyframes gsSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.gs-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  text-decoration: none;
  color: var(--text-primary);
  transition: background 0.12s;
  border-bottom: 1px solid var(--border);
}

.gs-result-item:last-child {
  border-bottom: none;
}

.gs-result-item:hover {
  background: var(--bg-card-hover);
}

.gs-result-icon {
  flex-shrink: 0;
  color: var(--accent);
  opacity: 0.7;
}

.gs-result-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  text-align: left;
}

.gs-result-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gs-result-meta {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gs-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}

.gs-more {
  display: block;
  padding: 12px 16px;
  text-align: center;
  color: var(--accent);
  font-size: 13px;
  border-top: 1px solid var(--border);
  text-decoration: none;
  font-weight: 500;
}
.gs-more:hover {
  background: var(--hover);
  color: #fff;
}

/* Old search bar kept for category page */
.search-bar {
  position: relative;
  margin: 0 0 20px;
}

.search-input {
  width: 100%;
  padding: 12px 40px 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-primary);
  font-size: 15px;
  transition: var(--transition);
}
.search-input-large {
  width: 100%;
  padding: 16px 20px;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: 24px;
  color: var(--text-primary);
  font-size: 18px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
  transition: var(--transition);
}
.search-input-large:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.search-bar input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-bar .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 16px;
  pointer-events: none;
}

/* ===== Footer ===== */
.site-footer {
  padding: 24px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .hero h1 { font-size: 26px; }
  .taiwan-map-wrapper { width: 320px; }
  .category-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .cam-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .header-nav { display: none; }
  .map-tooltip { width: 260px; }
}

@media (max-width: 480px) {
  .cam-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .container { padding: 0 16px; }
}

/* ===== Loading Spinner ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
}

.spinner {
  width: 32px;
  height: 32px;
  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); }
}



/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* ===== Leaflet Map Styles ===== */
.map-section-full {
  width: 100%;
  height: 600px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 1; /* Keep map below modal */
}

.leaflet-map-container {
  width: 100%;
  height: 100%;
}

/* Map Controls */
.map-controls {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: rgba(30, 30, 35, 0.85);
  backdrop-filter: blur(10px);
  padding: 12px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-hover);
}

.mode-toggle {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 999px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--transition);
}

.mode-btn:hover {
  color: var(--text-primary);
}

.mode-btn.active {
  background: var(--accent);
  color: #000;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.road-select {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 14px;
  outline: none;
  width: 200px;
}

/* Route Loading UI */
.route-loading {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 30, 35, 0.9);
  backdrop-filter: blur(5px);
  border: 1px solid var(--accent);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1000;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  font-size: 14px;
  font-weight: 500;
}

.route-spinner {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.cam-marker-container {
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
  font-size: 14px;
}

.km-marker-container {
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: 12px;
  border: 2px solid var(--accent);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.km-marker-icon {
  padding: 0 4px;
}

.custom-cluster {
  background-clip: padding-box;
  border-radius: 50%;
  font-family: var(--font-family);
  font-weight: bold;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.custom-cluster div {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.cluster-sm {
  background-color: rgba(66, 133, 244, 0.6);
  border: 3px solid rgba(66, 133, 244, 0.8);
}
.cluster-md {
  background-color: rgba(251, 188, 5, 0.6);
  border: 3px solid rgba(251, 188, 5, 0.8);
}
.cluster-lg {
  background-color: rgba(234, 67, 53, 0.6);
  border: 3px solid rgba(234, 67, 53, 0.8);
}

/* Fix leaflet popup in dark mode */
.leaflet-tooltip {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
}
.leaflet-tooltip-top:before {
  border-top-color: var(--border);
}

/* Featured Marker Styles */
.featured-marker-container {
  background: rgba(255, 215, 0, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.featured-marker-icon {
  font-size: 24px;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.8));
}

.pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  background: rgba(255, 215, 0, 0.6);
  border-radius: 50%;
  z-index: 1;
  animation: featured-pulse 2s infinite;
}

@keyframes featured-pulse {
  0% { transform: translate(-50%, -50%) scale(0.8); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

.featured-tooltip {
  background: rgba(30, 30, 35, 0.95);
  border: 1px solid rgba(255, 215, 0, 0.5);
  color: #ffd700;
  text-align: center;
}
.featured-tooltip-top:before {
  border-top-color: rgba(255, 215, 0, 0.5);
}

/* Nearby Cameras */
.nearby-preview-section {
    margin-top: 1.5rem;
}

.nearby-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

@media (max-width: 900px) {
    .nearby-grid {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        padding-bottom: 10px;
        -webkit-overflow-scrolling: touch;
    }
    .nearby-card {
        flex: 0 0 80%;
        scroll-snap-align: start;
    }
}

.nearby-card {
    background: #111;
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    transition: transform 0.2s;
    border: 1px solid rgba(255,255,255,0.05);
}

.nearby-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
}

.nearby-card-img {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    background: #222;
}

.nearby-card-info {
    padding: 10px 12px;
}

.nearby-card-title {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.nearby-card-dist {
    color: var(--text-dim);
    font-size: 12px;
}

.loading-nearby {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-dim);
    font-size: 14px;
    padding: 2rem 0;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin { 100% { transform: rotate(360deg); } }

/* Fix for long text overflowing in category cards */
.cat-info {
    min-width: 0;
    overflow: hidden;
}

.category-card .cat-info h3 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.category-card .cat-info span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    width: 100%;
}
