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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: #2d3748;
}

/* ===== MAP — full screen on mobile ===== */
#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* ===== SIDEBAR WRAP — transparent pass-through on mobile ===== */
#sidebar-wrap { display: contents; }

/* ===== TOP BAR — floating header ===== */
#top-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 8px rgba(0,0,0,0.10);
  z-index: 200;
  gap: 8px;
}

#app-title {
  font-size: 17px;
  font-weight: 700;
  color: #1a202c;
  white-space: nowrap;
}

#controls {
  display: flex;
  gap: 5px;
  align-items: center;
}

/* ===== FIND ME FAB ===== */
#btn-find-me {
  position: fixed;
  right: 16px;
  bottom: 88px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff;
  color: #2d3748;
  font-size: 22px;
  border: none;
  box-shadow: 0 3px 14px rgba(0,0,0,0.22);
  cursor: pointer;
  z-index: 200;
  padding: 0;
  line-height: 1;
}
#btn-find-me:hover { background: #f7fafc; }

/* ===== BOTTOM SHEET ===== */
#bottom-sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 55vh;
  background: #fff;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.14);
  transform: translateY(calc(100% - 72px));
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#bottom-sheet.expanded { transform: translateY(0); }

#sheet-handle {
  flex-shrink: 0;
  padding: 12px 0 6px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
}

#sheet-handle::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  background: #cbd5e0;
  border-radius: 2px;
}

#filters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 12px 8px;
  flex-shrink: 0;
}

#location-list {
  overflow-y: auto;
  flex: 1;
}

/* ===== BUTTONS ===== */
button {
  padding: 7px 11px;
  background: #e53e3e;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}
button:hover { background: #c53030; }
button.secondary { background: #718096; }
button.secondary:hover { background: #4a5568; }
button.icon-btn { padding: 7px 8px; }

/* ===== LOCATION LIST ===== */
.location-item {
  padding: 12px 16px;
  border-bottom: 1px solid #edf2f7;
  cursor: pointer;
}
.location-item:hover  { background: #f7fafc; }
.location-item:active { background: #edf2f7; }

.item-name {
  display: flex;
  align-items: center;
  font-weight: 600;
  color: #1a202c;
  margin-bottom: 3px;
}

.item-notes {
  font-size: 12px;
  color: #718096;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 12px;
  margin-right: 6px;
  flex-shrink: 0;
}

.cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.empty-state {
  padding: 24px 16px;
  text-align: center;
  color: #a0aec0;
  font-size: 13px;
  line-height: 1.6;
}

/* ===== FILTER BADGES ===== */
.filter-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  color: #fff;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s;
}
.filter-badge.inactive { opacity: 0.35; }

/* ===== MAP PINS ===== */
.map-pin {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  border: 2.5px solid rgba(255,255,255,0.9);
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  line-height: 1;
}

/* ===== POPUP ===== */
.leaflet-popup-content { min-width: 170px; padding: 4px 2px; }
.popup-name  { font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.popup-cat   { font-size: 11px; font-weight: 500; text-transform: capitalize; margin-bottom: 6px; }
.popup-notes { font-size: 12px; color: #555; margin-bottom: 8px; line-height: 1.4; }
.popup-actions { display: flex; gap: 6px; }
.popup-actions a {
  font-size: 11px; padding: 4px 9px; border-radius: 4px;
  text-decoration: none; background: #ebf8ff; color: #2b6cb0; font-weight: 500;
}
.popup-actions a:hover { background: #bee3f8; }
.popup-delete {
  font-size: 11px; padding: 4px 9px; border-radius: 4px;
  background: #fff5f5; color: #c53030; border: none; cursor: pointer; font-weight: 500;
}
.popup-delete:hover { background: #fed7d7; }

/* ===== PANELS ===== */
.panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  padding: 24px;
  width: 360px;
  max-width: 92vw;
  z-index: 2000;
}
.panel h2  { font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.panel p   { font-size: 12px; color: #718096; margin-bottom: 10px; line-height: 1.5; }
.panel label {
  display: flex; flex-direction: column; gap: 4px;
  margin-bottom: 11px; font-size: 12px; font-weight: 500; color: #4a5568;
}
.panel input,
.panel select,
.panel textarea {
  padding: 7px 10px; border: 1px solid #e2e8f0; border-radius: 6px;
  font-size: 13px; font-family: inherit; width: 100%; color: #2d3748;
}
.panel input:focus, .panel select:focus, .panel textarea:focus {
  outline: none; border-color: #e53e3e;
}
.panel textarea { resize: vertical; }

#add-coords-hint { font-size: 11px; color: #718096; min-height: 16px; margin-bottom: 6px; }

.panel-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.input-row { display: flex; gap: 6px; }
.input-row input { flex: 1; }
.input-row button { flex-shrink: 0; }

/* Add panel slides up from bottom on mobile */
#add-panel {
  top: auto; bottom: 0; left: 0;
  transform: none;
  width: 100%; max-width: 100%;
  max-height: 62vh;
  overflow-y: auto;
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -10px 40px rgba(0,0,0,0.18);
}

/* ===== CATEGORY MANAGEMENT ===== */
#emoji-grid {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-bottom: 8px;
  max-height: 120px; overflow-y: auto;
  padding: 4px 0;
}
.emoji-opt {
  font-size: 22px; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.1s, background 0.1s;
  flex-shrink: 0;
}
.emoji-opt:hover    { background: #edf2f7; }
.emoji-opt.selected { border-color: #e53e3e; background: #fff5f5; }
.emoji-paste-input  { margin-top: 4px; }

.cat-color-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.cat-color-label { font-size: 12px; font-weight: 500; color: #4a5568; }
.cat-color-swatch {
  width: 28px; height: 28px; border-radius: 50%;
  cursor: pointer; border: 2px solid #e2e8f0;
  flex-shrink: 0; transition: transform 0.1s;
}
.cat-color-swatch:hover { transform: scale(1.15); }
.cat-color-hint { font-size: 11px; color: #a0aec0; }

.cat-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 0; border-bottom: 1px solid #edf2f7;
}
.cat-row-swatch {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.7);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.cat-row-label  { flex: 1; font-weight: 500; font-size: 13px; }
.cat-row-delete {
  background: none; border: none; color: #a0aec0;
  cursor: pointer; font-size: 14px; padding: 4px 6px; border-radius: 4px;
}
.cat-row-delete:hover   { background: #fff5f5; color: #c53030; }
.cat-row-delete.disabled { opacity: 0.3; cursor: not-allowed; }

.divider { border: none; border-top: 1px solid #e2e8f0; margin: 14px 0 10px; }
.panel-section-label { font-size: 12px; font-weight: 600; color: #4a5568; margin-bottom: 8px; }

.hidden { display: none !important; }

/* ===== DESKTOP ≥ 768px — restore sidebar layout ===== */
@media (min-width: 768px) {
  body { display: flex; height: 100vh; overflow: hidden; }

  #map { position: relative; inset: auto; flex: 1; height: 100vh; z-index: auto; }

  #sidebar-wrap {
    display: flex;
    flex-direction: column;
    width: 300px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    overflow: hidden;
    order: -1;
  }

  #top-bar {
    position: static;
    height: auto;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    background: #fff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    border-bottom: 1px solid #e2e8f0;
    padding: 16px;
    gap: 10px;
  }

  #controls { flex-wrap: wrap; }

  #bottom-sheet {
    position: static;
    height: auto;
    transform: none !important;
    border-radius: 0;
    box-shadow: none;
    transition: none;
    flex: 1;
    overflow: hidden;
  }

  #sheet-handle { display: none; }

  #filters { padding: 10px 16px 0; }

  #btn-find-me { bottom: 24px; right: 24px; }

  #add-panel {
    top: 50%;
    bottom: auto;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 380px;
    max-width: 92vw;
    max-height: none;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  }
}
