/* ===========================
   Pikmin Bloom Decor Map
   Google Maps-style UI
   =========================== */

:root {
  --primary: #FF6B9D;
  --primary-dark: #E85A8A;
  --secondary: #7ED321;
  --accent: #4ECDC4;
  --bg-dark: #1a1a2e;
  --bg-sidebar: #16213e;
  --bg-card: #1e2a47;
  --bg-input: #0f1729;
  --text-primary: #ffffff;
  --text-secondary: #8892a6;
  --border-color: rgba(255, 255, 255, 0.08);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(255, 107, 157, 0.3);
  --sidebar-width: 380px;
  --radius: 12px;
  --radius-sm: 8px;
}

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

html,
body {
  height: 100%;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow: hidden;
}

#app {
  height: 100%;
  position: relative;
}

/* ===========================
   Left Sidebar (Desktop)
   =========================== */
.sidebar {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100%;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  z-index: 1000;
  transition: transform 0.3s ease;
  overflow: hidden;
}

.sidebar.sidebar-collapsed {
  transform: translateX(-100%);
}

/* Sidebar toggle button (desktop only) */
.sidebar-toggle {
  display: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: var(--sidebar-width);
  z-index: 1001;
  width: 24px;
  height: 48px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-left: none;
  border-radius: 0 8px 8px 0;
  color: var(--text-secondary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: left 0.3s ease, background 0.2s ease;
  padding: 0;
}

.sidebar-toggle:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.sidebar-toggle svg {
  transition: transform 0.3s ease;
}

.sidebar.sidebar-collapsed ~ .sidebar-toggle {
  left: 0;
}

.sidebar.sidebar-collapsed ~ .sidebar-toggle svg {
  transform: rotate(180deg);
}

@media (min-width: 769px) {
  .sidebar-toggle {
    display: flex;
  }
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

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

.logo-icon {
  font-size: 28px;
  animation: float 3s ease-in-out infinite;
}

.logo-text {
  font-weight: 700;
  font-size: 20px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===========================
   Tab Bar
   =========================== */
.tab-bar {
  display: flex;
  gap: 4px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

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

.tab-btn.tab-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ===========================
   Tab Panels
   =========================== */
.tab-panel {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow-y: auto;
  min-height: 0;
}

.tab-panel.active {
  display: flex;
}

/* ===========================
   Search Tab
   =========================== */
.search-area {
  padding: 16px 20px;
  flex-shrink: 0;
  position: relative;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 4px;
  transition: all 0.2s ease;
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

#address-input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 12px 14px;
  font-size: 15px;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
}

#address-input::placeholder {
  color: var(--text-secondary);
}

.search-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.search-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(255, 107, 157, 0.4);
}

.search-btn:active {
  transform: scale(0.95);
}

/* Autocomplete */
.autocomplete-list {
  position: absolute;
  left: 20px;
  right: 20px;
  top: 72px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 100;
  max-height: 240px;
  overflow-y: auto;
}

.autocomplete-list.hidden {
  display: none;
}

.autocomplete-item {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.autocomplete-item:hover,
.autocomplete-item.active {
  background: rgba(255, 107, 157, 0.15);
}

.locate-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.locate-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* ===========================
   Browse Tab
   =========================== */
.browse-area {
  padding: 16px 20px;
  flex-shrink: 0;
}

.browse-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.5;
}

.browse-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding-right: 4px;
}

.browse-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  font-family: inherit;
}

.browse-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary);
  transform: scale(1.02);
}

.browse-card.active {
  border-color: var(--primary);
  background: rgba(255, 107, 157, 0.1);
  box-shadow: 0 0 0 1px var(--primary);
}

.browse-card-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.browse-card-icon img {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.browse-card-name {
  text-align: center;
  line-height: 1.3;
  word-break: break-word;
}

/* Browse grid disabled state (zoom < 13) */
#browse-grid.too-zoomed-out .browse-card {
  opacity: 0.35;
  filter: grayscale(0.6);
  cursor: not-allowed;
}

/* Floating tooltip shown on hover/click when browse cards are disabled.
   position:fixed avoids being clipped by any overflow:hidden ancestor. */
.browse-zoom-tooltip {
  position: fixed;
  z-index: 9000;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  white-space: normal;
  max-width: 220px;
  line-height: 1.4;
  pointer-events: none;
  transform: translate(-50%, -100%);
}

/* Browse Action Buttons — hidden; buttons live on the map overlay instead */
.browse-actions {
  display: none;
  gap: 8px;
  margin-top: 12px;
}

.browse-refresh-btn,
.browse-clear-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.browse-refresh-btn:hover {
  background: rgba(78, 205, 196, 0.12);
  border-color: rgba(78, 205, 196, 0.3);
  color: var(--accent);
}

.browse-clear-btn:hover {
  background: rgba(255, 80, 80, 0.12);
  border-color: rgba(255, 80, 80, 0.3);
  color: #ff6b6b;
}

.browse-refresh-btn.hidden,
.browse-clear-btn.hidden {
  display: none;
}

.browse-actions:has(.browse-refresh-btn.hidden):has(.browse-clear-btn.hidden) {
  display: none;
}

/* Browse results flows below the grid; tab-panel handles the scrolling */
#browse-results {
  flex: none;
  overflow: visible;
}

#browse-results .results-content {
  flex: none;
  overflow: visible;
}

/* ===========================
   Results Section (shared)
   =========================== */
.results-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fadeIn 0.3s ease;
}

.results-section.hidden {
  display: none;
}

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

.results-location {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.results-count {
  background: var(--primary);
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  flex-shrink: 0;
  margin-left: 12px;
}

.results-count.is-loading {
  background: var(--bg-card);
  color: var(--text-secondary);
  box-shadow: none;
  pointer-events: none;
  opacity: 0.7;
}

.results-count.is-loading::after {
  display: none;
}

/* "X found" — button-like styling */
.results-count.has-tooltip {
  cursor: pointer;
  position: relative;
  padding: 6px 14px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  box-shadow: 0 2px 8px rgba(255, 107, 157, 0.3);
  transition: all 0.2s ease;
  user-select: none;
}

.results-count.has-tooltip:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 14px rgba(255, 107, 157, 0.45);
}

.results-count.has-tooltip:active {
  transform: scale(0.97);
}

/* Arrow indicator on the count badge */
.results-count.has-tooltip::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid white;
  margin-left: 6px;
  vertical-align: middle;
  opacity: 0.8;
}

/* Category Badges */
.decor-summary {
  padding: 12px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  max-height: 120px;
  overflow-y: auto;
}

.decor-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
  cursor: pointer;
}

.decor-badge:hover {
  transform: scale(1.05);
  background: rgba(255, 255, 255, 0.1);
}

.decor-badge .count {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 11px;
}

/* Results List */
.results-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.decor-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.decor-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
  cursor: pointer;
}

.decor-item:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateX(4px);
  border-color: var(--primary);
}

.decor-item:active {
  transform: scale(0.98);
}

.decor-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.decor-icon img {
  width: 60px;
  height: 60px;
  object-fit: contain;
}

/* Two icons side by side for double-decor list items */
.decor-icon-multi {
  flex-wrap: wrap;
  gap: 4px;
}

.decor-icon-multi img {
  width: 28px;
  height: 28px;
}

.decor-info {
  flex: 1;
  min-width: 0;
}

.decor-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.decor-category {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.decor-distance {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  flex-shrink: 0;
}

/* Empty State */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 30px;
  text-align: center;
  color: var(--text-secondary);
}

.empty-state.hidden {
  display: none;
}

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

.empty-state p {
  font-size: 15px;
  line-height: 1.6;
}

/* No Results */
.no-results {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.no-results-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* Generic retry button (used in search error states) */
.retry-btn {
  margin-top: 12px;
  padding: 8px 20px;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.retry-btn:hover {
  background: var(--primary-dark);
}

/* Count Tooltip — dropdown with emoji grid */
.count-tooltip {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 8px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 50;
  animation: fadeIn 0.15s ease;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.count-tooltip-icon {
  font-size: 22px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: default;
  position: relative;
  transition: background 0.15s ease;
}

.count-tooltip-icon:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Tooltip for each emoji */
.count-tooltip-icon .emoji-label {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 6px;
  padding: 4px 10px;
  background: var(--bg-sidebar);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  border-radius: 6px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  pointer-events: none;
  z-index: 60;
}

.count-tooltip-icon .emoji-label::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 4px;
  border-style: solid;
  border-color: var(--bg-sidebar) transparent transparent transparent;
}

.count-tooltip-icon:hover .emoji-label {
  display: block;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  flex-shrink: 0;
  line-height: 1.5;
}

/* ===========================
   Map
   =========================== */
#map {
  position: absolute;
  inset: 0;
  background: var(--bg-dark);
  z-index: 0;
}

.leaflet-control-attribution {
  background: rgba(22, 33, 62, 0.9) !important;
  color: var(--text-secondary) !important;
  font-size: 10px;
}

.leaflet-control-attribution a {
  color: var(--accent) !important;
}

.leaflet-control-zoom {
  border: none !important;
  box-shadow: var(--shadow) !important;
}

.leaflet-control-zoom a {
  background: var(--bg-sidebar) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color) !important;
}

.leaflet-control-zoom a:hover {
  background: var(--bg-card) !important;
}

/* ===========================
   Search Loading Overlay
   =========================== */
.loading {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2000;
  background: var(--bg-sidebar);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 36px 48px 32px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  pointer-events: all;
  min-width: 200px;
}

.loading .loading-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
}

.loading.hidden {
  display: none;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ===========================
   Browse Multi-query Progress Card
   =========================== */
.browse-loading {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2000;
  background: var(--bg-sidebar);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.55);
  min-width: 260px;
  max-width: 340px;
  width: calc(100vw - 48px);
  overflow: hidden;
  pointer-events: all;
}

.browse-loading.hidden {
  display: none;
}

.browse-loading-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.browse-loading-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.loading-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}

.loading-close-btn:hover {
  background: rgba(255, 80, 80, 0.15);
  color: #ff6b6b;
}

.loading-query-list {
  list-style: none;
  padding: 8px 0;
  margin: 0;
  max-height: 240px;
  overflow-y: auto;
}

.qtrack-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-size: 13px;
}

.qtrack-status {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.qtrack-label {
  flex: 1;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qtrack-item.qtrack-success .qtrack-label {
  color: var(--text-secondary);
}

.qtrack-icon.qtrack-success {
  color: #4ecdc4;
}

.qtrack-icon.qtrack-error {
  color: #ff6b6b;
}

.qtrack-retry {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  padding: 3px 10px;
  border-radius: 5px;
  background: rgba(255, 107, 157, 0.15);
  border: 1px solid rgba(255, 107, 157, 0.3);
  color: var(--primary);
  cursor: pointer;
  transition: background 0.15s ease;
}

.qtrack-retry:hover {
  background: rgba(255, 107, 157, 0.28);
}

.qtrack-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ===========================
   Custom Markers — Pin style with arrow pointer
   =========================== */
.search-marker {
  background: linear-gradient(135deg, #FF6B9D 0%, #FF8E53 100%);
  border: 4px solid white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255, 107, 157, 0.3), 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: pulse 2s ease-in-out infinite;
}

.decor-marker-wrapper {
  background: none !important;
  border: none !important;
  overflow: visible !important;
}

/* Positions the pin so the arrow tip sits on the lat/lon point.
   translate(-50%) centers it horizontally; translate(-100%) moves it up
   so the bottom edge (arrow tip) is at the coordinate, not the top-left. */
.decor-marker-anchor {
  position: absolute;
  transform: translate(-50%, -100%);
}

.decor-marker-pin {
  display: flex;
  flex-direction: column;
  align-items: center;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.2s ease;
}

/* When any pin is expanded, dim all other pins to 50% */
#map.pins-have-selection .decor-marker-pin {
  opacity: 0.4;
}

#map.pins-have-selection .decor-marker-pin.expanded {
  opacity: 1;
}

.decor-marker-pin:hover {
  transform: scale(1.1) translateY(-2px);
}

/* Navy circle pin — the map icon sits inside a circular badge */
.decor-marker-pill {
  display: inline-flex;
  align-items: center;
  gap: 0;
  background: var(--bg-sidebar);  /* navy, matches sidebar */
  border-radius: 20px;            /* large fixed value: keeps end-caps circular while pill widens */
  padding: 5px;
  line-height: 1;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  /* Clamp to a perfect circle in collapsed state.
     Total = icon(26) + padding(5*2) + border(2*2) = 40px.
     Without this, stacked content inside .marker-details inflates the height
     even when its max-width is 0. */
  max-height: 40px;
  transition: max-height 0.25s ease;
}

/* Expanded: allow the pill to grow taller to show pikmin sprites + text */
.decor-marker-pin.expanded .decor-marker-pill {
  max-height: 160px;
}

/* The datamined map icon — white/transparent sprites on the navy circle */
.map-icon-img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.decor-marker-arrow {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--bg-sidebar);
  margin-top: -1px;
}

/* Expandable detail panel — slides out to the right of the circle on click */
.marker-details {
  max-width: 0;
  overflow: hidden;
  transition: max-width 0.25s ease;
  display: flex;
  align-items: flex-start;
}

.decor-marker-pin.expanded .marker-details {
  max-width: 240px;
}

.marker-details-inner {
  padding: 2px 8px 2px 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  white-space: nowrap;
}

/* Pikmin sprites shown in expanded view */
.marker-pikmin-row {
  display: flex;
  gap: 2px;
  margin-bottom: 3px;
}

.marker-pikmin-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.marker-detail-row {
  padding: 1px 0;
}

.marker-detail-name {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}

.marker-detail-cats {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.3;
}

/* At zoom < 18 pins shrink so they don't overwhelm the map */
#map.map-zoomed-out .map-icon-img {
  width: 16px;
  height: 16px;
}

#map.map-zoomed-out .decor-marker-pill {
  padding: 3px;
  border-width: 1px;
  /* Recalculate circle clamp: icon(16) + padding(3*2) + border(1*2) = 24px */
  max-height: 24px;
}

/* When a zoomed-out pin is expanded, let it grow to full expanded height.
   Needs higher specificity than the collapsed rule above. */
#map.map-zoomed-out .decor-marker-pin.expanded .decor-marker-pill {
  max-height: 160px;
  /* Also restore full-size icon so expanded content doesn't look shrunken */
  padding: 5px;
  border-width: 2px;
}

#map.map-zoomed-out .decor-marker-pin.expanded .map-icon-img {
  width: 26px;
  height: 26px;
}

#map.map-zoomed-out .decor-marker-arrow {
  border-left-width: 4px;
  border-right-width: 4px;
  border-top-width: 5px;
}

/* ===========================
   Sheet Handle (mobile)
   =========================== */
.sheet-handle {
  display: none;
}

/* ===========================
   Animations
   =========================== */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

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

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255, 107, 157, 0.3), 0 4px 12px rgba(0, 0, 0, 0.3); }
  50% { box-shadow: 0 0 0 10px rgba(255, 107, 157, 0), 0 4px 12px rgba(0, 0, 0, 0.3); }
}

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

/* slideUp removed — initial mid state set by JS on load */

/* Pull-up tab — desktop: always hidden */
.sheet-tab {
  display: none;
}

/* Map-overlay browse buttons — float on map, all screen sizes */
.map-browse-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 500;
}

.map-browse-actions.hidden {
  display: none;
}

.map-browse-btn {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(22, 33, 62, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: background 0.15s ease, color 0.15s ease;
}

.map-browse-btn:hover {
  background: rgba(22, 33, 62, 0.85);
  color: white;
}

.map-browse-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.map-browse-btn[data-tooltip] {
  position: relative;
}

.map-browse-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.map-browse-btn[data-tooltip]:hover::after {
  opacity: 1;
}

/* ===========================
   Mobile — Google Maps Bottom Sheet
   =========================== */
@media (max-width: 768px) {

  /* Sidebar fully off-screen by default; JS adds .mid on load.
     top + bottom:0 means height = 100vh - top (always fills the visible area). */
  .sidebar {
    position: fixed;
    top: 100vh;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    max-height: none;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transition: top 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  }

  /* Mid — sidebar visible, ~90vh content showing */
  .sidebar.mid {
    top: 10vh;
  }

  /* Handle pill shown at top of sheet on mobile */
  .sheet-handle {
    display: flex;
    justify-content: center;
    padding: 12px 0 6px;
    flex-shrink: 0;
    cursor: grab;
    touch-action: none;
  }

  .handle-bar {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
  }

  .sidebar-header {
    padding: 12px 16px;
  }

  .logo {
    margin-bottom: 10px;
  }

  .logo-icon { font-size: 22px; }
  .logo-text { font-size: 17px; }

  .search-area {
    padding: 12px 16px;
  }

  .browse-area {
    padding: 12px 16px;
  }

  .sidebar-footer {
    padding: 8px 16px;
    font-size: 10px;
  }

  /* Pull-up tab: protrudes from the bottom edge when the sidebar is off-screen.
     position:fixed + bottom:env(safe-area-inset-bottom) handles both cases:
       - Safari with browser chrome: fixed bottom=0 sits above the chrome naturally
       - Homescreen PWA: safe-area-inset-bottom pads above the home indicator */
  .sheet-tab {
    display: flex; /* shown/hidden via JS inline style; default shown */
    align-items: center;
    gap: 7px;
    position: fixed;
    bottom: env(safe-area-inset-bottom, 0px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    padding: 10px 22px 12px;
    background: var(--bg-sidebar);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-bottom: none;
    border-radius: 16px 16px 0 0;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.45);
    white-space: nowrap;
    transition: background 0.15s ease;
  }

  .sheet-tab:active {
    background: var(--bg-card);
  }

  /* Hide zoom buttons on mobile — users pinch to zoom */
  .leaflet-control-zoom {
    display: none !important;
  }

  .map-browse-btn:active {
    background: rgba(22, 33, 62, 0.85);
    color: white;
  }

  .browse-loading {
    top: auto;
    bottom: 80px;
    transform: translateX(-50%);
  }
}

/* Touch-friendly */
@media (pointer: coarse) {
  .decor-item {
    padding: 14px 16px;
  }

  .decor-badge {
    padding: 8px 14px;
  }

  .browse-card {
    padding: 12px 14px;
  }
}

/* Custom scrollbar */
.results-content::-webkit-scrollbar,
.decor-summary::-webkit-scrollbar,
.browse-grid::-webkit-scrollbar,
.tab-panel::-webkit-scrollbar {
  width: 6px;
}

.results-content::-webkit-scrollbar-track,
.decor-summary::-webkit-scrollbar-track,
.browse-grid::-webkit-scrollbar-track,
.tab-panel::-webkit-scrollbar-track {
  background: transparent;
}

.results-content::-webkit-scrollbar-thumb,
.decor-summary::-webkit-scrollbar-thumb,
.browse-grid::-webkit-scrollbar-thumb,
.tab-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.results-content::-webkit-scrollbar-thumb:hover,
.decor-summary::-webkit-scrollbar-thumb:hover,
.browse-grid::-webkit-scrollbar-thumb:hover,
.tab-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Leaflet popup override */
.leaflet-popup-content {
  margin: 10px 14px;
}