/* ==========================
   0. CSS VARIABLES
   ========================== */
:root {
  --primary-color: #0077cc;
  --primary-hover: #005fa3;
  --primary-active: #004d82;
  --success-color: #4CAF50;
  --success-hover: #45a049;
  --success-active: #388e3c;
  --danger-color: #d32f2f;
  --danger-hover: #c62828;
  --danger-active: #b71c1c;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 3px 6px rgba(0, 0, 0, 0.3);
  --transition-fast: 0.1s;
  --transition-normal: 0.2s;
  --transition-slow: 0.3s;
  --border-radius: 6px;
  --border-radius-sm: 4px;
}

/* ==========================
   1. BASE STYLES & RESET
   ========================== */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: sans-serif;
  overflow: hidden; /* Prevent scrolling */
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
  touch-action: none; /* Disable default gestures */
}

/* ==========================
   2. DARK MODE
   ========================== */
body.dark-mode {
  background: #222; /* Dark background for contrast */
  color: #eee;     /* Light text for readability */
}
body.dark-mode .sidebar {
  background: #333;
  color: #eee;
}
body.dark-mode .tab-bar {
  background: #444;
}
body.dark-mode .tab {
  background: #555;
  color: #eee;
}
body.dark-mode .tab.active {
  background: #333;
  border-bottom-color: #66aaff; /* Lighter blue for dark mode */
}
body.dark-mode .activity,
body.dark-mode .history {
  border-color: #666;
}
body.dark-mode .activity:hover,
body.dark-mode .history:hover {
  background: #444;
}
body.dark-mode .activity.seen,
body.dark-mode .history.seen {
  color: #66ff66; /* Lighter green for dark mode */
}
body.dark-mode .seen-toggle-btn {
  background: #444;
  border-color: #666;
  color: #eee;
}
body.dark-mode .seen-toggle-btn:hover {
  background: #0077cc;
  border-color: #0077cc;
  color: white;
}
body.dark-mode .activity.seen .seen-toggle-btn,
body.dark-mode .history.seen .seen-toggle-btn {
  background: #4CAF50;
  border-color: #4CAF50;
  color: white;
}
body.dark-mode .activity.seen .seen-toggle-btn:hover,
body.dark-mode .history.seen .seen-toggle-btn:hover {
  background: #45a049;
  border-color: #45a049;
}
body.dark-mode .tab-filters select {
  background: #444;
  color: #eee;
  border-color: #666;
}
body.dark-mode .tab-filters-header {
  background: #444;
  color: #eee;
}
body.dark-mode .tab-filters-header .clear-filters-btn {
  background: #d32f2f;
  color: white;
}
body.dark-mode .tab-filters-header .clear-filters-btn:hover {
  background: #c62828;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}
body.dark-mode .tab-filters-header .clear-filters-btn:active {
  background: #b71c1c;
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
body.dark-mode .bulk-mark-btn {
  background: #388e3c;
  color: white;
}
body.dark-mode .bulk-mark-btn:hover {
  background: #2e7d32;
}
body.dark-mode .bulk-mark-btn:active {
  background: #1b5e20;
}
body.dark-mode .bulk-mark-progress-bar {
  background: rgba(255, 255, 255, 0.25);
}

/* ==========================
   3. MAP CONTAINER
   ========================== */
#map-container {
  position: relative;
  width: 100%;
  height: 100vh; /* Full viewport height for fullscreen map - fallback for older browsers */
  height: 100dvh; /* Dynamic viewport height (excludes browser UI) - better for mobile Firefox/Chrome */
  overflow: hidden;
}
#map {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
}

/* ==========================
   4. SIDEBAR
   ========================== */
.sidebar {
  position: absolute;
  top: 0;
  right: 0;
  width: 300px;
  height: 100%;
  background: white;
  z-index: 1000;
  box-shadow: -2px 0 5px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  transition: transform 0.3s ease; /* Slide in/out animation */
  will-change: transform;
  box-sizing: border-box;
}
.sidebar.resizing {
  transition: none; /* Disable transition during resize for smoother dragging */
}
.sidebar-resize-handle {
  position: absolute;
  left: 0;
  top: 0;
  width: 4px;
  height: 100%;
  cursor: ew-resize;
  z-index: 1001;
  background: transparent;
  transition: background 0.2s;
}
.sidebar-resize-handle:hover {
  background: rgba(0, 119, 204, 0.3); /* Primary color with transparency */
}
.sidebar-resize-handle.resizing {
  background: rgba(0, 119, 204, 0.5); /* Primary color with more opacity */
}
/* Hide resize handle on mobile */
@media (max-width: 600px) {
  .sidebar-resize-handle {
    display: none;
  }
}
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--primary-color);
  color: white;
  padding: 12px;
  font-size: 18px;
}

/* ==========================
   5. TABS & NAVIGATION
   ========================== */
.dark-toggle,
.expand-toggle {
  cursor: pointer;
  font-size: 24px;
  user-select: none;
  padding: 6px;
}
.expand-toggle {
  display: none; /* Hidden on desktop */
  transition: background 0.2s, transform 0.1s;
}

.expand-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.1);
}

.expand-toggle:active {
  transform: scale(0.95);
}
.tab-bar {
  display: flex;
  width: 100%;
  background: #eee;
}
.tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  background: #ddd;
  color: #222;
  min-width: 0; /* Allow tabs to shrink if needed */
}
.tab.active {
  background: #fff;
  font-weight: bold;
  border-bottom: 2px solid #0077cc; /* Visual indicator */
}

/* ==========================
   5.5. SEARCH BAR
   ========================== */
.search-container {
  width: 100%;
  padding: 8px 12px;
  background: #f5f5f5;
  border-bottom: 1px solid #ddd;
  position: relative;
}
.search-input {
  width: 100%;
  padding: 8px 36px 8px 12px; /* Extra padding on right for clear button */
  font-size: 16px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: white;
  color: #222;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input:focus {
  border-color: #0077cc;
  box-shadow: 0 0 0 2px rgba(0, 119, 204, 0.1);
}
.search-input::placeholder {
  color: #999;
}
.search-clear {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: #999;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  margin: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s, color 0.2s, transform 0.1s, box-shadow 0.2s;
  z-index: 10;
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
}
.search-clear:hover {
  background: #f0f0f0;
  color: #666;
  transform: translateY(-50%) translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}
.search-clear:active {
  background: #e0e0e0;
  transform: translateY(-50%) translateY(0);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
}

/* Dark mode support for search bar */
body.dark-mode .search-container {
  background: #444;
  border-bottom-color: #666;
}
body.dark-mode .search-input {
  background: #555;
  color: #eee;
  border-color: #666;
}
body.dark-mode .search-input:focus {
  border-color: #66aaff;
  box-shadow: 0 0 0 2px rgba(102, 170, 255, 0.1);
}
body.dark-mode .search-input::placeholder {
  color: #aaa;
}
body.dark-mode .search-clear {
  color: #aaa;
}
body.dark-mode .search-clear:hover {
  background: #555;
  color: #eee;
  transform: translateY(-50%) translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
body.dark-mode .search-clear:active {
  background: #666;
  transform: translateY(-50%) translateY(0);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
}

/* ==========================
   6. TAB CONTENT PANELS
   ========================== */
.tab-content {
  position: relative;
  width: 100%;
  height: calc(100% - 133px); /* Adjusted for search bar (80px header + 53px search) */
  display: flex;
  transition: transform 0.3s ease; /* Smooth horizontal slide */
}
.tab-panel {
  min-width: 0;
  flex-shrink: 0;
  padding: 12px;
  overflow-y: auto;
  padding-bottom: 80px; /* Extra space for bottom content */
  box-sizing: border-box;
}
.tab-list {
  margin-top: 10px;
}

/* ==========================
   7. LIST ITEMS
   ========================== */
.activity,
.history {
  margin-bottom: 12px;
  cursor: pointer;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.activity:hover,
.history:hover {
  background: #f0f0f0; /* Highlight on hover */
}
.activity.seen,
.history.seen {
  color: #4CAF50; /* Green text for seen entries */
  font-weight: 500;
}
.seen-toggle-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: 2px solid #0077cc;
  border-radius: 50%;
  background: white;
  color: #0077cc;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: all 0.2s;
}
.seen-toggle-btn:hover {
  background: #0077cc;
  color: white;
}
.activity.seen .seen-toggle-btn,
.history.seen .seen-toggle-btn {
  border-color: #4CAF50;
  color: #4CAF50;
  background: #4CAF50;
  color: white;
}
.activity.seen .seen-toggle-btn:hover,
.history.seen .seen-toggle-btn:hover {
  background: #45a049;
  border-color: #45a049;
}
.category {
  font-weight: bold;
  margin-top: 10px;
  margin-bottom: 5px;
}

/* ==========================
   8. FILTER CONTROLS
   ========================== */
.tab-filters-wrapper {
  margin-bottom: 10px;
}
.bulk-mark-row {
  margin-bottom: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}
.tab-filters-header {
  display: flex; /* Show on all devices */
  padding: 8px 10px;
  background: #f5f5f5;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 0;
}
.tab-filters-header .filters-title {
  flex: 1;
}
.tab-filters-header .filters-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tab-filters-header .clear-filters-btn {
  padding: 4px 8px;
  font-size: 12px;
  background: #d32f2f;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  font-weight: 500;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.tab-filters-header .clear-filters-btn:hover {
  background: #c62828;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}
.tab-filters-header .clear-filters-btn:active {
  background: #b71c1c;
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.bulk-mark-btn {
  position: relative;
  padding: 4px 8px;
  font-size: 12px;
  background: #388e3c;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  font-weight: 500;
  overflow: hidden;
  width: 98%;
  max-width: 98%;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.bulk-mark-btn:hover {
  background: #2e7d32;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}
.bulk-mark-btn:active {
  background: #1b5e20;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transform: translateY(0);
}
.bulk-mark-progress-bar {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: rgba(255, 255, 255, 0.3);
  transition: width 0.3s ease;
  z-index: 1;
}
.bulk-mark-text {
  position: relative;
  z-index: 2;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.tab-filters-header .filters-toggle {
  font-size: 12px;
  transition: transform 0.2s;
  cursor: pointer;
}
.tab-filters {
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* Ensure minimized filters are hidden on all devices */
.tab-filters-wrapper .tab-filters.minimized {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}
.tab-filters select {
  width: 100%;
  font-size: 16px;
  padding: 6px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  box-sizing: border-box;
}

/* Legacy support for old filter IDs (if any remain) */
#category-filter,
#time-filter {
  margin-bottom: 10px;
  width: 100%;
  font-size: 16px;
  padding: 6px;
}

/* ==========================
   9. MAP BUTTONS
   ========================== */
.location-btn,
.center-btn,
.hamburger-btn,
.tutorial-btn {
  position: absolute;
  z-index: 1100;
  background: #0077cc;
  color: white;
  padding: 10px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  user-select: none;
  pointer-events: auto;
  touch-action: manipulation;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.location-btn:hover,
.center-btn:hover,
.hamburger-btn:hover,
.tutorial-btn:hover {
  background: #005fa3;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}
.location-btn:active,
.center-btn:active,
.hamburger-btn:active,
.tutorial-btn:active {
  background: #004d82;
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.location-btn { bottom: 60px; left: 10px; }
.center-btn   { bottom: 20px; left: 10px; }
.tutorial-btn { bottom: 10px; right: 10px; font-size: 16px; padding: 8px 10px; color: white !important; }
.hamburger-btn { display: none; }

/* Dark mode support for map control buttons */
body.dark-mode .location-btn,
body.dark-mode .center-btn,
body.dark-mode .tutorial-btn {
  background: #0077cc;
  color: white;
}

body.dark-mode .location-btn:hover,
body.dark-mode .center-btn:hover,
body.dark-mode .tutorial-btn:hover {
  background: #005fa3;
}

body.dark-mode .location-btn:active,
body.dark-mode .center-btn:active,
body.dark-mode .tutorial-btn:active {
  background: #004d82;
}

/* ==========================
   10. LEAFLET POPUP SUPPORT
   ========================== */
.leaflet-popup-content {
  touch-action: pan-x pan-y; /* Enable swipe gestures */
  user-select: none;         /* Prevent text selection during drag */
  color: #222;               /* Match sidebar text color in light mode */
}
.leaflet-popup-content-wrapper {
  pointer-events: auto;
  touch-action: pan-x pan-y;
  background: white;         /* Match sidebar background in light mode */
  color: #222;               /* Match sidebar text color in light mode */
}

/* Scrollable popup wrapper */
.popup-scroll-wrapper {
  transition: max-height 0.1s ease-out;
  position: relative;
  max-height: 400px; /* Will be set dynamically to fit tallest entry */
}

/* Scrollable popup container for multiple entries */
.popup-scroll-container {
  position: relative;
  max-height: 400px; /* Will be set dynamically to fit tallest entry */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
  touch-action: pan-y; /* Allow vertical scrolling */
  /* Ensure scroll container handles its own events and stops propagation */
  pointer-events: auto;
  padding-right: 8px; /* Reserve space for scrollbar to prevent content overlap */
  box-sizing: border-box;
}

.popup-scroll-container::-webkit-scrollbar {
  width: 8px;
}

.popup-scroll-container::-webkit-scrollbar-track {
  background: transparent;
}

.popup-scroll-container::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}

/* Gradient overlays to indicate scrollable direction */
.leaflet-popup-content {
  position: relative;
}

.popup-gradient-top,
.popup-gradient-bottom {
  position: absolute;
  left: 0;
  right: 0;
  width: 100%;
  height: 30px;
  pointer-events: none;
  z-index: 10;
  transition: opacity 0.2s;
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.popup-gradient-top {
  top: 0;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.4), transparent);
}

.popup-gradient-bottom {
  bottom: 0;
  background: linear-gradient(to top, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.4), transparent);
}

/* Dark mode support for gradients */
body.dark-mode .popup-gradient-top {
  background: linear-gradient(to bottom, rgba(51, 51, 51, 1), rgba(51, 51, 51, 0.8), rgba(51, 51, 51, 0.4), transparent);
}

body.dark-mode .popup-gradient-bottom {
  background: linear-gradient(to top, rgba(51, 51, 51, 1), rgba(51, 51, 51, 0.8), rgba(51, 51, 51, 0.4), transparent);
}

/* Animated scroll indicators - visible but not obtrusive */
.popup-scroll-indicator {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 28px;
  background: rgba(0, 119, 204, 0.75);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 15;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition: opacity 0.3s ease;
  border: 2px solid rgba(255, 255, 255, 0.9);
}

.popup-scroll-indicator.visible {
  opacity: 1;
}

.popup-scroll-indicator-top {
  top: 2px;
}

.popup-scroll-indicator-bottom {
  bottom: 2px;
}

.popup-scroll-indicator::before {
  content: '';
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
}

.popup-scroll-indicator-top::before {
  border-bottom: 10px solid white;
  animation: bounceUp 1.5s ease-in-out infinite;
}

.popup-scroll-indicator-bottom::before {
  border-top: 10px solid white;
  animation: bounceDown 1.5s ease-in-out infinite;
}

@keyframes bounceUp {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

@keyframes bounceDown {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(3px);
  }
}

/* Consistent styling for both light and dark modes */
body.dark-mode .popup-scroll-indicator {
  background: rgba(0, 119, 204, 0.75);
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* Button container for popups - ensures buttons are not covered by gradients */
.popup-buttons-container {
  position: relative;
  z-index: 20;
  background: inherit;
  margin-top: 8px;
  padding-top: 0;
}

/* Popup button styles - Mark as Seen and Open in Google Maps */
.popup-seen-btn,
.popup-google-maps-btn {
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.popup-seen-btn:hover,
.popup-google-maps-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.popup-seen-btn:active,
.popup-google-maps-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Mark as Seen button hover states */
.popup-seen-btn:hover {
  background: #005fa3 !important;
}

.popup-seen-btn.seen:hover {
  background: #45a049 !important;
}

.popup-seen-btn:active {
  background: #004d82 !important;
}

.popup-seen-btn.seen:active {
  background: #388e3c !important;
}

/* Open in Google Maps button hover states */
.popup-google-maps-btn:hover {
  background: #2e7d32 !important;
}

.popup-google-maps-btn:active {
  background: #1b5e20 !important;
}

/* Dark mode support for popup buttons */
body.dark-mode .popup-seen-btn:hover {
  background: #005fa3 !important;
}

body.dark-mode .popup-seen-btn.seen:hover {
  background: #45a049 !important;
}

body.dark-mode .popup-seen-btn:active {
  background: #004d82 !important;
}

body.dark-mode .popup-seen-btn.seen:active {
  background: #388e3c !important;
}

body.dark-mode .popup-google-maps-btn:hover {
  background: #2e7d32 !important;
}

body.dark-mode .popup-google-maps-btn:active {
  background: #1b5e20 !important;
}

/* Dark mode popup styling to match sidebar */
body.dark-mode .leaflet-popup-content-wrapper {
  background: #333;          /* Match sidebar background in dark mode */
  color: #eee;               /* Match sidebar text color in dark mode */
}

body.dark-mode .leaflet-popup-content {
  color: #eee;               /* Match sidebar text color in dark mode */
}

/* Popup tip (arrow) styling to match popup background */
body.dark-mode .leaflet-popup-tip {
  background: #333;          /* Match popup background in dark mode */
}

/* Minimize button for mobile popups - positioned where Leaflet close button was */
.popup-minimize-btn {
  position: absolute !important;
  top: -12px !important;
  right: -12px !important;
  width: 40px !important;
  height: 40px !important;
  border: 3px solid white !important;
  border-radius: 50% !important;
  background: #0077cc !important;
  color: white !important;
  font-size: 26px !important;
  font-weight: bold !important;
  line-height: 1 !important;
  cursor: pointer !important;
  z-index: 10000 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s !important;
  margin: 0 !important;
}

/* Hide Leaflet's default close button on mobile and make popup narrower */
@media (max-width: 600px) {
  .leaflet-popup-close-button {
    display: none !important;
  }
  
  /* Make popup narrower on mobile to leave more room on screen */
  .leaflet-popup-content-wrapper {
    max-width: 280px !important;
    min-width: 200px !important;
  }
  
  .leaflet-popup-content {
    max-width: 280px !important;
  }
}

.popup-minimize-btn:hover {
  background: #005fa3 !important;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3) !important;
}

.popup-minimize-btn:active {
  background: #004d82 !important;
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
}

body.dark-mode .popup-minimize-btn {
  background: #0077cc !important;
  border-color: rgba(255, 255, 255, 0.95) !important;
  color: white !important;
}

body.dark-mode .popup-minimize-btn:hover {
  background: #005fa3 !important;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3) !important;
}

body.dark-mode .popup-minimize-btn:active {
  background: #004d82 !important;
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
}

/* ==========================
   11. RESPONSIVE (MOBILE)
   ========================== */
@media (max-width: 600px) {
  .sidebar {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60%;
    width: 100% !important;
    max-width: 100% !important;
    transform: translateY(100%); /* Hidden by default */
    transition: transform 0.3s ease, height 0.3s ease;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.2);
    touch-action: pan-y;
    box-sizing: border-box;
  }
  .sidebar.open {
    transform: translateY(0); /* Slide up into view */
    height: 60%; /* Default height when open */
  }
  .sidebar.open.fullscreen {
    height: 100%; /* Fullscreen when expanded */
  }
  .sidebar-header {
    padding: 10px;
    font-size: 16px;
  }
  .expand-toggle {
    display: block; /* Visible on mobile */
    margin-right: 8px;
  }
  .tab-bar {
    font-size: 14px;
  }
  .tab {
    padding: 8px;
    font-size: 14px;
  }
  .location-btn,
  .center-btn,
  .hamburger-btn {
    left: auto;
    right: 10px;
    padding: 6px 8px;
    font-size: 12px;
  }
  .location-btn { top: 8px; bottom: auto; }
  .center-btn   { top: 40px; bottom: auto; }
  .hamburger-btn {
    top: 72px;
    display: block; /* Only visible on mobile */
  }
  .tutorial-btn {
    left: 10px !important;
    right: auto !important;
    bottom: 10px !important;
    top: auto !important;
    padding: 6px 8px;
    font-size: 14px;
    color: white !important;
    z-index: 10000 !important;
    display: block !important;
    pointer-events: auto !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: rgba(0, 119, 204, 0.3);
  }
  /* Hide buttons when sidebar is in fullscreen mode */
  body.sidebar-fullscreen .location-btn,
  body.sidebar-fullscreen .center-btn,
  body.sidebar-fullscreen .tutorial-btn,
  body.sidebar-fullscreen .hamburger-btn {
    display: none;
  }
  
  /* Filter header adjustments for mobile */
  .tab-filters-header {
    font-size: 13px;
    padding: 6px 8px;
  }
  .tab-filters-header .clear-filters-btn {
    font-size: 11px;
    padding: 3px 6px;
  }
}

/* ==========================
   12.5. LEAFLET ATTRIBUTION CONTROL
   ========================== */
/* Move attribution container to lower left on desktop (to avoid sidebar on right) */
.leaflet-bottom.leaflet-right,
.leaflet-bottom.leaflet-left {
  z-index: 1001 !important;
}

/* On desktop, position attribution on the left */
@media (min-width: 601px) {
  .leaflet-bottom.leaflet-right,
  .leaflet-bottom.leaflet-left {
    right: auto !important;
    left: 0 !important;
  }
}

/* Style the attribution control itself - ensure it's visible */
.leaflet-control-attribution {
  margin: 0 !important;
  padding: 2px 5px !important;
  background: rgba(255, 255, 255, 0.8) !important;
  border-radius: 0 4px 0 0 !important;
  font-size: 11px !important;
  z-index: 1001 !important;
  max-width: none !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Keep attribution on right for mobile (sidebar is at bottom on mobile) */
@media (max-width: 600px) {
  .leaflet-bottom.leaflet-right,
  .leaflet-bottom.leaflet-left {
    right: 0 !important;
    left: auto !important;
    bottom: 0 !important;
  }
  .leaflet-control-attribution {
    border-radius: 4px 0 0 0 !important;
    margin: 0 !important;
  }
}

/* Dark mode support for attribution */
body.dark-mode .leaflet-control-attribution {
  background: rgba(0, 0, 0, 0.8) !important;
  color: #eee !important;
}

/* ==========================
   13. DEBUG BOX POSITION
   ========================== */
#coord-debug {
  position: fixed;
  z-index: 1100;
  bottom: 100px;
  left: 10px;
  right: auto;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-family: monospace;
  display: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  max-width: calc(100% - 32px);
  box-sizing: border-box;
  pointer-events: auto;
}

.coord-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
}

.coord-copy-btn {
  padding: 2px 6px;
  font-size: 13px;
  cursor: pointer;
  background: #444;
  color: #fff;
  border: none;
  border-radius: 4px;
  margin-left: auto;
  transition: background 0.2s;
}

.coord-copy-btn:hover {
  background: #555;
}

.coord-copy-btn:active {
  background: #333;
}
@media (max-width: 600px) {
  #coord-debug {
    bottom: 20px;
    right: 10px;
    left: auto;
  }
  #coord-debug.above-sidebar {
    bottom: calc(60% + 4px); /* 4px gap between top of menu and bottom of debug box when partially expanded sidebar (60% height) */
  }
  body.sidebar-fullscreen #coord-debug {
    display: none !important; /* Hide when sidebar is fullscreen */
  }
}

/* ==========================
   14. FULLSCREEN IMAGE OVERLAY
   ========================== */
.image-expanded-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-top: 70px; /* Space for close button at top */
  padding-bottom: 80px; /* Space for navigation buttons at bottom */
  box-sizing: border-box;
  cursor: pointer;
  overflow: hidden; /* Prevent scrolling */
  touch-action: none; /* Prevent all touch gestures */
  -webkit-overflow-scrolling: none; /* Disable momentum scrolling on iOS */
}

.image-expanded-overlay.active {
  display: flex;
}

.image-expanded-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  touch-action: none; /* Prevent touch gestures on image container */
  pointer-events: auto; /* Ensure it can receive events */
}

/* Allow touch events on navigation buttons */
.image-expanded-prev,
.image-expanded-next,
.image-expanded-close {
  touch-action: manipulation !important;
  pointer-events: auto !important;
}

.image-expanded-container img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  touch-action: none; /* Prevent touch gestures on image */
  pointer-events: auto; /* Ensure it can receive events */
  -webkit-user-select: none; /* Prevent text selection */
  user-select: none;
  transform-origin: center center;
  transition: transform 0.1s ease-out, opacity 0.3s ease-in-out;
  cursor: default;
  will-change: transform;
  opacity: 1;
}

.image-expanded-container img.zoomed {
  cursor: grab;
}

.image-expanded-container img.zoomed:active {
  cursor: grabbing;
}

.image-expanded-close {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  background: #0077cc;
  color: white;
  border: 3px solid white;
  border-radius: 50%;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  z-index: 10001;
}

.image-expanded-close:hover {
  background: #005fa3;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.image-expanded-close:active {
  background: #004d82;
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

body.dark-mode .image-expanded-close {
  background: #0077cc;
  border-color: rgba(255, 255, 255, 0.95);
}

body.dark-mode .image-expanded-close:hover {
  background: #005fa3;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

body.dark-mode .image-expanded-close:active {
  background: #004d82;
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Make images in popups clickable */
.leaflet-popup-content img {
  cursor: pointer;
  transition: opacity 0.2s;
}

.leaflet-popup-content img:hover {
  opacity: 0.9;
}

/* Ensure images in popup containers with navigation have proper opacity */
.leaflet-popup-content img[data-images] {
  opacity: 1;
  transition: opacity 0.3s ease-in-out;
}

/* Navigation buttons in popup for multiple images */
.popup-image-next-btn,
.popup-image-prev-btn {
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  line-height: 1.2;
  box-sizing: border-box;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.popup-image-next-btn:hover,
.popup-image-prev-btn:hover {
  background: #005fa3 !important;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.popup-image-next-btn:active,
.popup-image-prev-btn:active {
  background: #004d82 !important;
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Navigation buttons container in expanded image modal */
.image-expanded-nav-buttons {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  gap: 12px;
  z-index: 10001;
  pointer-events: auto;
}

/* Navigation buttons in expanded image modal */
.image-expanded-prev,
.image-expanded-next {
  width: 50px;
  height: 50px;
  background: #0077cc;
  color: white;
  border: 3px solid white;
  border-radius: 50%;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.image-expanded-prev:hover,
.image-expanded-next:hover {
  background: #005fa3;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.image-expanded-prev:active,
.image-expanded-next:active {
  background: #004d82;
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

@media (max-width: 600px) {
  .image-expanded-close {
    top: 10px;
    right: 10px;
    width: 44px;
    height: 44px;
    font-size: 28px;
  }
  
  .image-expanded-prev,
  .image-expanded-next {
    width: 44px;
    height: 44px;
    font-size: 24px;
  }
  
  .image-expanded-overlay {
    padding: 10px;
    padding-top: 64px; /* Space for close button at top on mobile */
    padding-bottom: 70px; /* Space for navigation buttons at bottom on mobile */
  }
  
  .image-expanded-nav-buttons {
    bottom: 10px;
    gap: 10px;
  }
  
  .image-expanded-container {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
  }
}

/* ==========================
   15. TUTORIAL OVERLAY
   ========================== */
.tutorial-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 12000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  animation: fadeIn 0.3s ease;
}

.tutorial-overlay.show {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.tutorial-container {
  background: white;
  border-radius: 12px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
  position: relative;
}

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

.tutorial-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 2px solid #eee;
  background: #0077cc;
  color: white;
  border-radius: 12px 12px 0 0;
}

.tutorial-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.tutorial-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tutorial-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.tutorial-close:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.tutorial-content {
  padding: 20px;
}

.tutorial-step {
  margin-bottom: 20px;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 8px;
  border-left: 4px solid #0077cc;
}

.tutorial-step:last-child {
  margin-bottom: 0;
}

.tutorial-step h3 {
  margin: 0 0 8px 0;
  font-size: 18px;
  color: #0077cc;
  font-weight: 600;
}

.tutorial-step p {
  margin: 0;
  font-size: 15px;
  color: #555;
  line-height: 1.5;
}

.tutorial-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-top: 1px solid #eee;
  background: #f8f9fa;
  border-radius: 0 0 12px 12px;
}

.tutorial-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #555;
  user-select: none;
}

.tutorial-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.tutorial-button {
  background: #0077cc;
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tutorial-button:hover {
  background: #005fa3;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.tutorial-button:active {
  transform: translateY(0);
  background: #004d82;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Dark mode styles for tutorial */
body.dark-mode .tutorial-container {
  background: #333;
  color: #eee;
}

body.dark-mode .tutorial-step {
  background: #444;
  border-left-color: #66aaff;
}

body.dark-mode .tutorial-step h3 {
  color: #66aaff;
}

body.dark-mode .tutorial-step p {
  color: #ccc;
}

body.dark-mode .tutorial-footer {
  background: #444;
  border-top-color: #666;
}

body.dark-mode .tutorial-checkbox {
  color: #ccc;
}

@media (max-width: 600px) {
  .tutorial-container {
    max-width: 100%;
    max-height: 95vh;
    border-radius: 12px 12px 0 0;
  }

  .tutorial-header {
    padding: 16px;
  }

  .tutorial-header h2 {
    font-size: 20px;
    white-space: normal; /* Allow wrapping on mobile */
  }

  .tutorial-content {
    padding: 16px;
  }

  .tutorial-step {
    padding: 12px;
    margin-bottom: 16px;
  }

  .tutorial-step h3 {
    font-size: 16px;
  }

  .tutorial-step p {
    font-size: 14px;
  }

  .tutorial-footer {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .tutorial-button {
    width: 100%;
  }
}

/* ==========================
   14. SETTINGS OVERLAY
   ========================== */

.settings-toggle {
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s, transform 0.1s;
  user-select: none;
}

.settings-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.1);
}

.settings-toggle:active {
  transform: scale(0.95);
}

.settings-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 12000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  animation: fadeIn 0.3s ease;
}

.settings-overlay.show {
  display: flex;
}

.settings-container {
  background: white;
  border-radius: 12px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
  position: relative;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 2px solid #eee;
  background: #0077cc;
  color: white;
  border-radius: 12px 12px 0 0;
  position: sticky;
  top: 0;
  z-index: 1;
}

.settings-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.settings-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.settings-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.settings-close:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.settings-content {
  padding: 20px;
}

.settings-section {
  margin-bottom: 24px;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 8px;
  border-left: 4px solid #0077cc;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section h3 {
  margin: 0 0 16px 0;
  font-size: 18px;
  color: #0077cc;
  font-weight: 600;
}

.settings-item {
  margin-bottom: 16px;
}

.settings-item:last-child {
  margin-bottom: 0;
}

.settings-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-weight: 500;
  color: #333;
  gap: 12px;
}

.settings-label span:first-child {
  flex: 1;
}

.settings-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.settings-label select {
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  background: white;
  color: #333;
  cursor: pointer;
  min-width: 150px;
}

.settings-label input[type="range"] {
  flex: 1;
  margin: 0 12px;
  cursor: pointer;
}

.settings-label input[type="range"] + span {
  min-width: 60px;
  text-align: right;
  font-size: 14px;
  color: #0077cc;
  font-weight: 600;
}

.settings-description {
  margin: 4px 0 0 0;
  font-size: 13px;
  color: #666;
  line-height: 1.4;
}

.settings-button {
  background: #0077cc;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.settings-button:hover {
  background: #005fa3;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.settings-button:active {
  transform: translateY(0);
  background: #004d82;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.settings-button-danger {
  background: #d32f2f;
}

.settings-button-danger:hover {
  background: #c62828;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.settings-button-danger:active {
  background: #b71c1c;
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.settings-button-primary {
  background: #0077cc;
  color: white;
  border: none;
  padding: 12px 32px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  width: 100%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.settings-button-primary:hover {
  background: #005fa3;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.settings-button-primary:active {
  transform: translateY(0);
  background: #004d82;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.settings-footer {
  padding: 16px 20px;
  border-top: 1px solid #eee;
  background: #f8f9fa;
  border-radius: 0 0 12px 12px;
  position: sticky;
  bottom: 0;
}

/* Dark mode styles for settings */
body.dark-mode .settings-container {
  background: #333;
  color: #eee;
}

body.dark-mode .settings-section {
  background: #444;
  border-left-color: #66aaff;
}

body.dark-mode .settings-section h3 {
  color: #66aaff;
}

body.dark-mode .settings-label {
  color: #eee;
}

body.dark-mode .settings-label select {
  background: #555;
  color: #eee;
  border-color: #666;
}

body.dark-mode .settings-description {
  color: #ccc;
}

body.dark-mode .settings-footer {
  background: #444;
  border-top-color: #666;
}

@media (max-width: 600px) {
  .settings-container {
    max-width: 100%;
    max-height: 95vh;
    border-radius: 12px 12px 0 0;
  }

  .settings-header {
    padding: 16px;
  }

  .settings-header h2 {
    font-size: 20px;
    white-space: normal;
  }

  .settings-content {
    padding: 16px;
  }

  .settings-section {
    padding: 12px;
    margin-bottom: 16px;
  }

  .settings-section h3 {
    font-size: 16px;
  }

  .settings-label {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .settings-label select {
    width: 100%;
    min-width: auto;
  }

  .settings-label input[type="range"] {
    width: 100%;
    margin: 8px 0;
  }

  .settings-description {
    font-size: 12px;
  }

  .settings-footer {
    padding: 12px 16px;
  }
  
  /* Hide sidebar width setting on mobile */
  #settings-sidebar-width-item {
    display: none;
  }
}

/* ==========================
   16. QR CODE GENERATION
   ========================== */
.qr-code-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 20000;
  overflow-y: auto;
  padding: 20px;
  box-sizing: border-box;
}

.qr-code-header {
  color: white;
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 20px;
  text-align: center;
}

.qr-code-close-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 10px 20px;
  background: #0077cc;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  z-index: 20001;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.qr-code-close-btn:hover {
  background: #005fa3;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.qr-code-close-btn:active {
  background: #004d82;
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.qr-code-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.qr-code-card {
  background: white;
  padding: 15px;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.qr-code-title {
  font-weight: bold;
  margin-bottom: 10px;
  font-size: 14px;
  word-wrap: break-word;
  color: #222;
}

.qr-code-canvas {
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  display: block;
}

.qr-code-download-btn {
  margin-top: 10px;
  padding: 8px 16px;
  background: #0077cc;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  width: 100%;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.qr-code-download-btn:hover {
  background: #005fa3;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.qr-code-download-btn:active {
  background: #004d82;
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Dark mode support for QR code modal */
body.dark-mode .qr-code-card {
  background: #444;
  color: #eee;
}

body.dark-mode .qr-code-title {
  color: #eee;
}

@media (max-width: 600px) {
  .qr-code-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    padding: 10px;
  }
  
  .qr-code-header {
    font-size: 20px;
    margin-bottom: 15px;
  }
  
  .qr-code-close-btn {
    top: 10px;
    right: 10px;
    padding: 8px 16px;
    font-size: 14px;
  }
}