:root {
  --bg: #0a0604;
  --panel: rgba(20, 12, 8, 0.85);
  --panel-border: rgba(255, 140, 80, 0.3);
  --accent: #e07a3a;
  --accent-bright: #ff9a55;
  --text: #f4ece4;
  --text-dim: #c8b8a8;
  --hit: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#cesiumContainer {
  position: absolute;
  inset: 0;
}

#cesiumContainer canvas { outline: none; }

.cesium-viewer-bottom,
.cesium-viewer-toolbar,
.cesium-viewer-animationContainer,
.cesium-viewer-timelineContainer,
.cesium-viewer-fullscreenContainer { display: none !important; }

#topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent);
  pointer-events: none;
  z-index: 10;
}

#topbar h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 300;
  letter-spacing: 4px;
  pointer-events: auto;
}

#lang-switch {
  display: flex;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 4px;
  pointer-events: auto;
}

#lang-switch button {
  min-width: 56px;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
  border-radius: 999px;
  cursor: pointer;
}

#lang-switch button.active {
  background: var(--accent);
  color: #fff;
}

#sidebar {
  position: absolute;
  top: 80px;
  left: 16px;
  width: 320px;
  max-height: calc(100% - 160px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  z-index: 9;
  backdrop-filter: blur(8px);
}

#sidebar h2 {
  margin: 0;
  padding: 16px 20px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--panel-border);
}

#site-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#site-list li {
  min-height: var(--hit);
  padding: 12px 16px;
  margin: 2px 0;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#site-list li:active,
#site-list li.active {
  background: rgba(224, 122, 58, 0.2);
}

#site-list .site-name {
  font-size: 16px;
  font-weight: 500;
}

#site-list .site-meta {
  font-size: 12px;
  color: var(--text-dim);
}

#home-btn {
  position: absolute;
  bottom: 24px;
  left: 24px;
  min-width: var(--hit);
  min-height: var(--hit);
  padding: 0 24px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 1px;
  border-radius: 999px;
  cursor: pointer;
  z-index: 9;
  backdrop-filter: blur(8px);
}

#home-btn:active { background: rgba(224, 122, 58, 0.3); }

#zoom-controls {
  position: absolute;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9;
}

#zoom-controls button {
  width: 64px;
  height: 64px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-size: 32px;
  font-weight: 300;
  border-radius: 50%;
  cursor: pointer;
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

#zoom-controls button:active {
  background: rgba(224, 122, 58, 0.3);
}

#popup {
  position: absolute;
  inset: 5% 5% 5% auto;
  width: min(640px, 50%);
  max-height: 90%;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 24px;
  z-index: 20;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  backdrop-filter: blur(12px);
}

#popup[hidden] { display: none; }

#popup-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: var(--hit);
  height: var(--hit);
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 32px;
  cursor: pointer;
  border-radius: 999px;
}

#popup-close:active { background: rgba(255,255,255,0.1); }

#popup-body h3 {
  margin: 0 0 4px 0;
  font-size: 28px;
  font-weight: 400;
}

#popup-body .agency {
  color: var(--accent-bright);
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 16px;
}

#popup-body .description {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
}

#popup-body .gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

#popup-body .gallery figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#popup-body .gallery .thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}

#popup-body .gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#popup-body .gallery .thumb.video::after {
  content: "▶";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
  background: rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

#popup-body .gallery .thumb.video .play { display: none; } /* using ::after now */

#popup-body .gallery figcaption {
  font-size: 12px;
  line-height: 1.3;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#popup-body .gallery .cap { color: var(--text); }
#popup-body .gallery .credit { color: var(--text-dim); font-size: 11px; }

#popup-body .gallery figure {
  cursor: pointer;
}
#popup-body .gallery figure:active img { transform: scale(0.97); }
#popup-body .gallery img { transition: transform 120ms ease; }

#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(5, 3, 2, 0.92);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  backdrop-filter: blur(4px);
}

#lightbox[hidden] { display: none; }

#lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: var(--hit);
  height: var(--hit);
  border: 0;
  background: rgba(0, 0, 0, 0.4);
  color: var(--text);
  font-size: 32px;
  line-height: 1;
  border-radius: 999px;
  cursor: pointer;
}
#lightbox-close:active { background: rgba(255, 255, 255, 0.15); }

#lightbox-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
}

#lightbox-content img,
#lightbox-content video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  background: #000;
}

#lightbox-caption {
  margin: 16px 0 0;
  max-width: 80ch;
  text-align: center;
  font-size: 16px;
  color: var(--text-dim);
}

#loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 100;
  font-size: 18px;
  letter-spacing: 2px;
  color: var(--text-dim);
  transition: opacity 0.6s;
}

#loading.hidden {
  opacity: 0;
  pointer-events: none;
}
