* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: Arial, sans-serif;
  background: #f5f5f5;
  color: #222;
}

#app {
  display: grid;
  grid-template-columns: 420px 1fr;
  height: 100vh;
}

#sidebar {
  background: #fff;
  border-right: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel {
  padding: 16px;
  border-bottom: 1px solid #ddd;
}

.panel h1 {
  margin: 0 0 12px 0;
  font-size: 22px;
}

.site-header {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 8px;
  margin-bottom: 14px;
  background: #fff;
  border: 1px solid #dbe3ef;
  border-radius: 16px;
  padding: 10px 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.site-logo {
  max-width: 360px;
  width: min(82%, 320px);
  height: auto;
  object-fit: contain;
  display: block;
  filter: none !important;
  mix-blend-mode: normal;
}

#searchBox {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #bbb;
  border-radius: 8px;
  font-size: 14px;
}

.mobile-view-tabs {
  display: none;
}

.mobile-view-btn {
  border: 1px solid #999;
  background: #fff;
  border-radius: 999px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 14px;
}

.mobile-view-btn.active {
  background: #222;
  color: #fff;
  border-color: #222;
}

.slideshow-toolbar {
  margin-top: 12px;
  border: 1px solid #d6d6d6;
  border-radius: 12px;
  padding: 10px 12px;
  background: #fafafa;
}

.slideshow-toolbar-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #666;
  margin-bottom: 8px;
}

.slideshow-toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-btn,
#clearAreaFilterBtn,
#saveSlideshowSettingsBtn,
#startSlideshowFromSettingsBtn,
#loadMoreBtn {
  border: 1px solid #999;
  background: #fff;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 14px;
}

.toolbar-btn-primary {
  background: #222;
  color: #fff;
  border-color: #222;
}

.filters {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn {
  border: 1px solid #999;
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}

.filter-btn.active {
  background: #222;
  color: #fff;
  border-color: #222;
}

.counts {
  margin-top: 12px;
  font-size: 13px;
  color: #555;
}

.hint {
  margin-top: 10px;
  font-size: 12px;
  color: #777;
  line-height: 1.4;
}

.area-filter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: #eef5ff;
  border: 1px solid #c8dcff;
  border-radius: 10px;
  font-size: 13px;
}

.hidden {
  display: none !important;
}

#results {
  overflow: auto;
  padding: 10px;
}

.result-card {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 14px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 14px;
  margin-bottom: 12px;
  padding: 12px;
  cursor: pointer;
  align-items: start;
}

.result-card:hover {
  border-color: #999;
}

.result-thumb {
  width: 100%;
  height: auto;
  max-height: 120px;
  object-fit: contain;
  border-radius: 12px;
  background: transparent;
  display: block;
}

.result-title {
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 16px;
  line-height: 1.2;
}

.result-meta {
  font-size: 12px;
  color: #666;
  line-height: 1.35;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  margin-right: 6px;
  background: #ececec;
}

.badge.video {
  background: #dff1ff;
}

.badge.photo {
  background: #e8f7e8;
}

#loadMoreWrap {
  padding: 12px 0 20px 0;
  text-align: center;
}

#mapWrap {
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
}

#viewer,
#slideshowSettingsModal {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

#viewerBackdrop,
#slideshowSettingsBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

#viewerContent,
#slideshowSettingsContent {
  position: absolute;
  inset: 5% 8%;
  background: #fff;
  border-radius: 16px;
  overflow: auto;
  padding: 20px;
}

#viewerContent.viewer-fullscreen-media {
  inset: 0;
  border-radius: 0;
  padding: 0;
  background: #000;
}

#slideshowSettingsContent {
  inset: 12% 20%;
}

#viewerClose,
#slideshowSettingsClose,
#viewerFullscreenBtn {
  position: absolute;
  top: 12px;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  font-size: 28px;
  cursor: pointer;
  border-radius: 10px;
  width: 44px;
  height: 44px;
  z-index: 50;
}

#viewerClose {
  right: 14px;
}

#slideshowSettingsClose {
  right: 14px;
}

#viewerFullscreenBtn {
  right: 66px;
  font-size: 20px;
}

.viewer-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
}

.viewer-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 12px;
}

.viewer-desc {
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 14px;
}

.viewer-section {
  margin-bottom: 14px;
}

.viewer-section strong {
  display: block;
  margin-bottom: 4px;
}

.viewer-links a,
.viewer-links button {
  display: inline-block;
  margin-right: 10px;
  margin-bottom: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #222;
  color: #fff;
  text-decoration: none;
  border: none;
  cursor: pointer;
}

.popup-thumb {
  width: 180px;
  height: auto;
  max-height: 120px;
  object-fit: contain;
  border-radius: 8px;
  display: block;
  margin-bottom: 8px;
  background: transparent;
}

.popup-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.settings-group {
  margin-bottom: 18px;
  font-size: 14px;
}

.settings-group label {
  margin-right: 14px;
}

.settings-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.slideshow-indicator {
  position: absolute;
  left: 10px;
  top: 10px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  z-index: 60;
}

.viewer-media {
  position: relative;
  overflow: hidden;
  min-height: 70vh;
  background: transparent;
}

.viewer-media.is-fading img:not(.watermark-logo),
.viewer-media.is-fading video {
  opacity: 0;
}

.viewer-media.viewer-media-crossfade {
  min-height: 70vh;
  background: transparent;
}

.viewer-media.viewer-media-crossfade .media-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}

.viewer-media.viewer-media-crossfade .media-layer.active {
  opacity: 1;
  pointer-events: auto;
}

.photo-stage,
.video-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

.photo-frame {
  position: relative;
  display: inline-block;
  line-height: 0;
  max-width: 100%;
  max-height: 70vh;
}

.photo-frame img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 12px;
  background: transparent;
}

.video-stage video {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 12px;
  background: transparent;
}

.viewer-fullscreen-media .viewer-grid {
  display: block;
  height: 100vh;
}

.viewer-fullscreen-media .viewer-media {
  height: 100vh;
  min-height: 100vh;
}

.viewer-fullscreen-media .photo-frame {
  max-height: 100vh;
}

.viewer-fullscreen-media .photo-frame img {
  max-height: 100vh;
  border-radius: 0;
}

.viewer-fullscreen-media .video-stage video {
  max-height: 100vh;
  border-radius: 0;
}

.viewer-fullscreen-media .viewer-info-panel {
  display: none;
}

.image-watermark {
  position: absolute;
  right: 10px;
  bottom: 10px;
  pointer-events: none;
  z-index: 70;
}

.image-watermark .watermark-logo {
  display: block;
  width: 72px;
  height: auto;
  max-width: none;
  opacity: 0.32;
  object-fit: contain;
  border-radius: 0;
  background: transparent;
  filter:
    drop-shadow(0 0 2px rgba(255, 255, 255, 0.55))
    drop-shadow(0 0 3px rgba(0, 0, 0, 0.55));
}

.viewer-fullscreen-media .image-watermark .watermark-logo {
  width: 96px;
  opacity: 0.28;
}

.photo-frame.no-watermark .image-watermark {
  display: none;
}

@media (max-width: 1100px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: 45vh 55vh;
  }

  .viewer-grid {
    grid-template-columns: 1fr;
  }

  #slideshowSettingsContent {
    inset: 8% 5%;
  }
}

@media (max-width: 768px) {
  html,
  body {
    height: 100dvh;
    overflow: hidden;
    background: #f5f5f5 !important;
    color: #222 !important;
  }

  #app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
  }

  #sidebar {
    border-right: none;
    border-bottom: 1px solid #ddd;
    overflow: visible;
    background: #fff;
  }

  .panel {
    padding: 12px;
  }

  .site-header {
    margin-top: 0;
    margin-bottom: 10px;
    padding: 10px 12px;
    background: linear-gradient(180deg, #1b2431 0%, #243247 100%);
    border: 1px solid #32455f;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  }

  .site-logo {
    width: min(72vw, 260px);
    max-width: 260px;
  }

  #searchBox {
    font-size: 16px;
    padding: 12px 14px;
  }

  .mobile-view-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
    margin-bottom: 10px;
  }

  .slideshow-toolbar {
    display: block;
    margin-top: 10px;
    padding: 10px 12px;
    background: #fafafa;
  }

  .slideshow-toolbar-label {
    display: block;
    margin-bottom: 8px;
  }

  .slideshow-toolbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .slideshow-toolbar-actions .toolbar-btn {
    width: 100%;
    justify-content: center;
  }

  .filters {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .filter-btn {
    text-align: center;
    padding: 10px 8px;
  }

  .counts {
    margin-top: 10px;
    font-size: 14px;
  }

  #downloadResultsBtn {
    width: auto;
  }

  .hint {
    display: none !important;
  }

  #mapWrap {
    flex: 1;
    min-height: 0;
  }

  #map {
    width: 100%;
    height: 100%;
  }

  #results {
    padding: 10px;
    overflow: auto;
    max-height: none;
  }

  .result-card {
    grid-template-columns: 92px 1fr;
    gap: 10px;
    padding: 10px;
  }

  .result-title {
    font-size: 15px;
  }

  .result-meta {
    font-size: 12px;
  }

  body.mobile-view-map #results {
    display: none;
  }

  body.mobile-view-map #mapWrap {
    display: block;
  }

  body.mobile-view-results #mapWrap {
    display: none;
  }

  body.mobile-view-results #results {
    display: block;
    height: calc(100dvh - 390px);
  }

  .leaflet-top.leaflet-left {
    top: 8px;
    left: 8px;
  }

  #viewerContent {
    inset: 0;
    border-radius: 0;
    padding: 8px;
    background: rgba(0, 0, 0, 0.96);
  }

  #viewerContent.viewer-native-video-fs {
    inset: 0;
    padding: 0;
    border-radius: 0;
    background: #000;
  }

  #viewerContent.viewer-native-video-fs #viewerClose,
  #viewerContent.viewer-native-video-fs #viewerFullscreenBtn {
    opacity: 0;
    pointer-events: none;
  }

  #slideshowSettingsContent {
    inset: 4% 4%;
    padding: 16px;
  }

  .viewer-grid {
    height: 100%;
    grid-template-columns: 1fr;
    gap: 0;
  }

  .viewer-media {
    min-height: auto;
    height: calc(100dvh - 16px);
    background: #000;
  }

  .viewer-info-panel {
    display: none !important;
  }

  .video-stage {
    inset: 0;
  }

  .video-stage video {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 0;
    background: #000;
  }

  #viewerFullscreenBtn {
    display: none !important;
  }

  .settings-actions {
    flex-direction: column;
  }

  .settings-actions button,
  #saveSlideshowSettingsBtn,
  #startSlideshowFromSettingsBtn {
    width: 100%;
  }

  .area-filter {
    align-items: flex-start;
    flex-direction: column;
  }

  #clearAreaFilterBtn {
    width: 100%;
  }

  .viewer-title {
    font-size: 22px;
  }

  .viewer-desc {
    font-size: 14px;
  }

  .photo-frame,
  .photo-frame img {
    max-height: 100dvh;
  }

  .image-watermark .watermark-logo {
    width: 56px;
    opacity: 0.28;
  }
}

.viewer-media {
  position: relative;
}

.viewer-share-floating {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 30;
}

.action-buttons {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.action-buttons button {
  flex: 1;
}

.viewer-share-search-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.viewer-inline-search-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.viewer-slideshow-search-actions {
  position: absolute;
  top: 66px;
  right: 14px;
  z-index: 55;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 320px;
}

.viewer-slideshow-search-btn {
  background: rgba(255, 255, 255, 0.94);
  color: #111;
  border: 1px solid rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(4px);
}

.viewer-slideshow-search-btn:hover {
  background: #fff;
}

@media (max-width: 768px) {
  .viewer-share-search-row {
    flex-direction: column;
    align-items: stretch;
  }

  .viewer-inline-search-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  .viewer-inline-search-actions .toolbar-btn {
    width: 100%;
  }

  .viewer-slideshow-search-actions {
    top: 66px;
    right: 14px;
    left: 14px;
    max-width: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .viewer-slideshow-search-actions .viewer-slideshow-search-btn {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    font-size: 13px;
  }
}

@media (max-width: 420px) {
  .viewer-inline-search-actions,
  .viewer-slideshow-search-actions {
    grid-template-columns: 1fr;
  }
}

