#map-wrap { position: relative; height: calc(100vh - 58px); }
#map { position: absolute; inset: 0; }

/* Marker */
.custom-marker {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 2px 6px rgba(0,0,0,.6);
  border: 2px solid #0a0a0a;
}
.custom-marker span { transform: rotate(45deg); font-size: 17px; line-height: 1; }
.custom-marker.has-media { position: relative; }
.custom-marker.has-media::after {
  content: "📷"; position: absolute; bottom: -4px; right: -6px; transform: rotate(45deg);
  background: #0a0a0a; border: 1px solid #333; border-radius: 50%;
  width: 16px; height: 16px; font-size: 9px; display: flex; align-items: center; justify-content: center;
}

/* Popup (leaflet) */
.leaflet-popup-content-wrapper { background: #131313; color: #e9e9e4; border: 1px solid #2c2c2a; border-radius: 2px; }
.leaflet-popup-tip { background: #131313; }
.leaflet-popup-content { margin: 10px 12px; min-width: 180px; font-family: 'Oswald', sans-serif; }
.popup-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; display:flex; align-items:center; gap:6px; text-transform: uppercase; letter-spacing: .5px; }
.popup-category { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #9a9a92; margin-bottom: 6px; display: inline-flex; align-items: center; gap: 4px; background: #1a1a1a; padding: 2px 7px; border-radius: 10px; }
.popup-note { font-size: 12px; color: #c9c9bd; margin-bottom: 8px; white-space: pre-wrap; }
.popup-media-grid { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.popup-media-grid .thumb { width: 52px; height: 52px; border-radius: 2px; object-fit: cover; cursor: pointer; border: 1px solid #2c2c2a; }
.popup-actions { display: flex; gap: 6px; }
.popup-actions button {
  border: 1px solid #2c2c2a; background: #1a1a1a; color: #e9e9e4; border-radius: 2px; padding: 5px 9px;
  font-size: 11px; cursor: pointer; text-transform: uppercase; letter-spacing: .5px;
}
.popup-actions .popup-delete { border-color: #7a1f1f; color: #f2c9c9; }
.leaflet-container a.leaflet-popup-close-button { color: #9a9a92; }

/* Floating buttons */
.fab {
  position: absolute; top: 16px; z-index: 500;
  width: 42px; height: 42px; border-radius: 2px;
  border: 1px solid #2c2c2a; background: rgba(10,10,10,.9); color: #e9e9e4;
  font-size: 17px; cursor: pointer;
}
.fab:hover { border-color: #6b7a2f; }

/* Search */
#search-box {
  position: absolute; top: 16px; left: 68px; z-index: 500;
  background: rgba(10,10,10,.95); border: 1px solid #2c2c2a; border-radius: 2px;
  width: min(380px, calc(100vw - 100px)); overflow: hidden;
}
.search-box-row { display: flex; align-items: center; padding: 4px 4px 4px 12px; }
#search-box input { border: none; outline: none; background: transparent; color: #e9e9e4; flex: 1; font-size: 14px; padding: 8px 4px; font-family: inherit; }
#search-box button { border: none; background: transparent; cursor: pointer; font-size: 14px; color: #9a9a92; padding: 6px 8px; }
#search-results { max-height: 280px; overflow-y: auto; border-top: 1px solid #2c2c2a; }
.search-result-item { display: flex; gap: 8px; padding: 9px 12px; cursor: pointer; font-size: 12px; border-bottom: 1px solid #1a1a1a; }
.search-result-item:hover { background: #1a1a1a; }
.search-result-text { color: #c9c9bd; line-height: 1.35; }
.search-result-empty { padding: 12px; font-size: 12px; color: #9a9a92; text-align: center; }

/* Filter / story side panels */
.side-panel {
  position: absolute; top: 68px; left: 16px; z-index: 500;
  background: rgba(10,10,10,.96); border: 1px solid #2c2c2a; border-radius: 2px;
  width: 280px; max-width: calc(100vw - 32px); max-height: 75vh; overflow-y: auto; padding: 14px 16px;
}
.side-panel.side-panel-right { left: auto; right: 16px; }

#points-list-panel { width: 320px; max-height: calc(100vh - 58px - 88px); }
#points-list { display: flex; flex-direction: column; gap: 8px; }
.point-list-item {
  background: #1a1a1a; border: 1px solid #2c2c2a; border-radius: 2px; padding: 10px 12px; cursor: pointer;
}
.point-list-item:hover { border-color: #6b7a2f; }
.point-list-item .pli-title { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
.point-list-item .pli-title .pli-color-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.point-list-item .pli-category { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #9a9a92; margin-top: 4px; }
.point-list-item .pli-note { font-size: 12px; color: #c9c9bd; margin-top: 6px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.point-list-item .pli-meta { font-size: 11px; color: #9a9a92; margin-top: 6px; display: flex; gap: 10px; }
.point-list-item .pli-actions { display: flex; gap: 6px; margin-top: 8px; }
.point-list-item .pli-actions button {
  border: 1px solid #2c2c2a; background: #0d0d0d; color: #e9e9e4; border-radius: 2px; padding: 4px 8px;
  font-size: 10px; cursor: pointer; text-transform: uppercase; letter-spacing: .5px;
}
.point-list-item .pli-actions .pli-delete { border-color: #7a1f1f; color: #f2c9c9; }
.points-list-empty { color: #9a9a92; font-size: 12px; text-align: center; padding: 20px 10px; }

@media (max-width: 640px) {
  .fab { width: 38px; height: 38px; font-size: 15px; }
  .side-panel { top: 60px; left: 8px; padding: 12px; }
  .side-panel.side-panel-right { left: auto; right: 8px; }
  #points-list-panel { width: calc(100vw - 16px); }
  #search-box { left: 56px; }
  #story-bar { width: calc(100vw - 16px); padding: 8px 10px; gap: 8px; }
  #modal { padding: 18px 16px; }
}
.side-panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.side-panel-header h3 { margin: 0; font-size: 14px; }
.side-panel-header button { border: none; background: transparent; cursor: pointer; font-size: 14px; color: #9a9a92; }
.filter-actions { display: flex; gap: 12px; margin-bottom: 10px; }
.filter-actions button { border: none; background: none; color: #6b7a2f; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; cursor: pointer; text-decoration: underline; }
#category-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.category-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.category-row .cat-label { flex: 1; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.category-row .cat-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.category-row .cat-delete { border: none; background: none; color: #b23a3a; cursor: pointer; font-size: 11px; }
#add-category-form { border-top: 1px solid #2c2c2a; padding-top: 10px; }
.new-cat-row { display: flex; gap: 4px; align-items: center; }
.new-cat-row input[type=text] { background: #0d0d0d; border: 1px solid #2c2c2a; color: #e9e9e4; border-radius: 2px; padding: 5px 6px; font-size: 11px; min-width: 0; }
#new-cat-emoji { width: 34px; }
#new-cat-name { flex: 1; }
.new-cat-row input[type=color] { width: 28px; height: 28px; padding: 0; border: none; background: none; }
.new-cat-row button[type=submit] { width: 28px; height: 28px; padding: 0; border-radius: 2px; }

.story-hint { font-size: 11px; color: #9a9a92; margin: 0 0 10px; line-height: 1.4; }
#story-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.story-item { display: flex; align-items: center; gap: 6px; font-size: 12px; background: #1a1a1a; border-radius: 2px; padding: 5px 7px; }
.story-item .story-item-index { font-weight: 700; color: #9a9a92; width: 18px; text-align: center; }
.story-item .story-item-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story-item button { border: none; background: none; cursor: pointer; font-size: 12px; color: #c9c9bd; padding: 2px 4px; }
.story-item .story-item-remove { color: #b23a3a; }
.story-add-row { display: flex; gap: 6px; margin-bottom: 12px; }
.story-add-row select { flex: 1; min-width: 0; padding: 6px; background: #0d0d0d; border: 1px solid #2c2c2a; color: #e9e9e4; border-radius: 2px; font-size: 11px; }
.story-add-row button { width: 30px; border-radius: 2px; }
.story-play-btn { width: 100%; padding: 10px; }

/* Playback bar */
#story-bar {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 900;
  background: rgba(10,10,10,.96); color: #e9e9e4; border: 1px solid #4b5320; border-radius: 2px;
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; width: min(460px, calc(100vw - 32px));
}
#story-bar button { border: 1px solid #2c2c2a; background: #1a1a1a; color: #e9e9e4; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 15px; flex-shrink: 0; }
#story-prev, #story-next { width: 42px; height: 42px; font-size: 22px; font-weight: 700; }
#story-bar button:hover { border-color: #6b7a2f; }
#story-stop { background: rgba(122,31,31,.4) !important; }
.story-bar-info { flex: 1; min-width: 0; }
#story-bar-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: uppercase; letter-spacing: .5px; }
#story-bar-progress { font-size: 11px; color: #9a9a92; margin-top: 2px; }

/* Modal (add/edit point) */
#modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 1000; display: flex; align-items: center; justify-content: center; }
#modal { background: #131313; border: 1px solid #2c2c2a; border-radius: 2px; padding: 22px 24px; width: min(360px, 90vw); max-height: 88vh; overflow-y: auto; }
#modal h2 { margin: 0 0 16px; font-size: 18px; }
#modal label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #9a9a92; margin: 12px 0 5px; }
#modal input[type=text], #modal textarea, #modal select {
  width: 100%; padding: 9px 10px; background: #0d0d0d; border: 1px solid #2c2c2a; color: #e9e9e4;
  border-radius: 2px; font-size: 13px; font-family: inherit; resize: vertical;
}
#modal input[type=color] { width: 100%; height: 36px; border: 1px solid #2c2c2a; border-radius: 2px; padding: 2px; margin-top: 8px; cursor: pointer; background: #0d0d0d; }
.emoji-suggestions, .color-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.emoji-suggestions button { border: 1px solid #2c2c2a; background: #0d0d0d; border-radius: 2px; font-size: 16px; width: 32px; height: 32px; cursor: pointer; }
.emoji-suggestions button:hover { border-color: #6b7a2f; }
.color-suggestions button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #131313; outline: 1px solid #2c2c2a; cursor: pointer; }
.color-suggestions button.selected { outline: 2px solid #e9e9e4; }
.category-fixed-note { font-size: 11px; background: #1a1a1a; border: 1px solid #2c2c2a; border-radius: 2px; padding: 9px 10px; color: #c9c9bd; margin-top: 4px; }
.media-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.media-grid .media-item { position: relative; width: 60px; height: 60px; }
.media-grid .media-item img, .media-grid .media-item video { width: 100%; height: 100%; object-fit: cover; border-radius: 2px; border: 1px solid #2c2c2a; }
.media-grid .media-item .media-remove { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; border: none; background: #7a1f1f; color: #fff; font-size: 11px; line-height: 1; cursor: pointer; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* Lightbox */
#lightbox { position: fixed; inset: 0; z-index: 3000; background: rgba(0,0,0,.94); display: flex; align-items: center; justify-content: center; }
#lightbox-content { max-width: 88vw; max-height: 84vh; display: flex; align-items: center; justify-content: center; }
#lightbox-content img, #lightbox-content video { max-width: 88vw; max-height: 84vh; border-radius: 2px; }
#lightbox-close { position: absolute; top: 18px; right: 22px; background: none; border: none; color: #e9e9e4; font-size: 26px; cursor: pointer; }
#lightbox-prev, #lightbox-next { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.1); border: none; color: #e9e9e4; font-size: 30px; width: 46px; height: 46px; border-radius: 50%; cursor: pointer; }
#lightbox-prev { left: 18px; }
#lightbox-next { right: 18px; }
