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

body, html, #app {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f5f5;
}

/* ── Top bar ─────────────────────────────────── */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  z-index: 1000;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

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

#topbar-search {
  flex: 1;
  max-width: 320px;
}

#topbar-search input {
  width: 100%;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 14px;
  outline: none;
  background: #f5f5f5;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
#topbar-search input:focus {
  border-color: #1a1a1a;
  background: #fff;
}

#topbar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.15s;
}
.btn-icon:hover { background: #f0f0f0; }

/* ── Map ─────────────────────────────────────── */
#map {
  position: fixed;
  top: 52px; bottom: 0; left: 0; right: 0;
  z-index: 1;
}

/* ── Spots list drawer ───────────────────────── */
#spots-list-drawer {
  position: fixed;
  top: 52px; bottom: 0; left: 0;
  width: 300px;
  background: #fff;
  z-index: 400;
  overflow-y: auto;
  box-shadow: 2px 0 12px rgba(0,0,0,0.12);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  pointer-events: none;
}
#spots-list-drawer.open {
  transform: translateX(0);
  pointer-events: auto;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  border-bottom: 1px solid #f0f0f0;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.list-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f5f5f5;
  transition: background 0.12s;
}
.list-item:hover { background: #f9f9f9; }

.list-item-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}

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

.list-item-title {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-meta {
  font-size: 11px;
  color: #aaa;
  margin-top: 2px;
}

.list-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.list-empty {
  padding: 32px 16px;
  text-align: center;
  color: #aaa;
  font-size: 14px;
}

/* ── Right detail panel ──────────────────────── */
.panel-right {
  position: fixed;
  top: 52px; right: 0; bottom: 0;
  width: 360px;
  background: #fff;
  box-shadow: -2px 0 16px rgba(0,0,0,0.12);
  z-index: 500;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  pointer-events: none;
}
.panel-right.open {
  transform: translateX(0);
  pointer-events: auto;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
}

.panel-header-title {
  font-size: 17px;
  font-weight: 600;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  margin-right: 8px;
}

.panel-close-btn {
  font-size: 18px;
  color: #888;
  flex-shrink: 0;
}
.panel-close-btn:hover { color: #1a1a1a; background: #f0f0f0; }

#panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 32px;
}

.panel-title {
  font-size: 20px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 4px;
}

/* ── Popular tags bar ────────────────────────── */
#popular-tags-bar {
  position: fixed;
  bottom: 40px;
  left: 10px;
  right: 380px;
  z-index: 400;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  pointer-events: none;
}

.pop-tag {
  pointer-events: auto;
  background: #fff;
  border: none;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: #1a1a1a;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}
.pop-tag:hover { background: #f0f0f0; }
.pop-tag.active { background: #1a1a1a; color: #fff; }

.pop-tag-count {
  display: inline-block;
  background: rgba(255,255,255,0.25);
  border-radius: 10px;
  padding: 0 5px;
  font-size: 10px;
  margin-left: 4px;
}
.pop-tag.active .pop-tag-count { background: rgba(255,255,255,0.2); }

.panel-meta {
  font-size: 12px;
  color: #888;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.panel-desc {
  font-size: 15px;
  color: #333;
  line-height: 1.5;
  margin-bottom: 12px;
}

.tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.tag-chip {
  background: #f0f0f0;
  border-radius: 16px;
  padding: 3px 10px;
  font-size: 12px;
  color: #555;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 8px;
}

.media-thumb {
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  background: #eee;
}

.media-broken {
  aspect-ratio: 1;
  border-radius: 8px;
  background: #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #bbb;
}

.media-video-thumb {
  aspect-ratio: 1;
  border-radius: 8px;
  background: #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.media-play-icon {
  font-size: 28px;
  color: rgba(255,255,255,0.85);
}

.panel-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.btn-delete {
  background: none;
  border: 1px solid #ffcccc;
  color: #e53935;
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}
.btn-delete:hover { background: #fff5f5; }

/* ── Modals ──────────────────────────────────── */
#modal-overlay, #settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 2000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
#modal-overlay.hidden, #settings-overlay.hidden { display: none; }

#modal, #settings-modal {
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 24px 20px 40px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

#modal h3, #settings-modal h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  color: #1a1a1a;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #888;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
  resize: none;
}
.form-group input:focus,
.form-group textarea:focus { border-color: #1a1a1a; }

.coords-chip {
  background: #f5f5f5;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: #666;
}

.tag-input-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.tag-input-row input { flex: 1; }

#tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 4px;
}

.tag-item {
  background: #f0f0f0;
  border-radius: 16px;
  padding: 3px 10px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.tag-item button {
  background: none;
  border: none;
  cursor: pointer;
  color: #888;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}

.btn-sm {
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 18px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.btn-primary {
  flex: 1;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-outline {
  flex: 1;
  background: none;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 14px;
  font-size: 15px;
  cursor: pointer;
  color: #555;
}
.btn-outline:hover { background: #f5f5f5; }

/* ── Leaflet popup tweak ─────────────────────── */
.leaflet-popup-content-wrapper {
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

/* ── Lightbox ────────────────────────────────── */
#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
}
#lightbox.hidden { display: none; }
#lightbox img {
  max-width: 95vw;
  max-height: 90vh;
  border-radius: 8px;
  object-fit: contain;
}
#lightbox-close {
  position: absolute;
  top: 16px; right: 20px;
  color: #fff;
  font-size: 32px;
  cursor: pointer;
  background: none;
  border: none;
  line-height: 1;
}
