/* Media Viewer - Fullscreen lightbox modal
   Time & Place
   Supports images now, extensible to video/3D/360 */

/* ── Overlay ── */
.mv-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  overflow: hidden;
  touch-action: none;
}

.mv-overlay.mv-open {
  opacity: 1;
  visibility: visible;
}

.mv-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
}

[data-theme="light"] .mv-backdrop {
  background: rgba(0, 0, 0, 0.85);
}

/* ── Main container ── */
.mv-container {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  z-index: 1;
  overflow: visible;
  background: #000;
}

/* ── Image area ── */
.mv-media {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #000;
}

.mv-media img {
  max-width: 100vw;
  max-height: 100vh;
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  cursor: zoom-in;
}

.mv-media.mv-zoomed img {
  cursor: grabbing;
}

.mv-media img.mv-loading {
  opacity: 0.3;
}

/* ── Caption bar (overlaid at bottom) ── */
.mv-caption-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: #fff;
  padding: 32px 16px 12px;
  font-size: 13px;
  line-height: 1.4;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  z-index: 3;
  pointer-events: none;
}

.mv-caption-hidden {
  display: none !important;
}

.mv-caption-text {
  flex: 1;
  min-width: 0;
}

.mv-caption-date {
  font-size: 12px;
  opacity: 0.7;
  white-space: nowrap;
  flex-shrink: 0;
}

.mv-counter {
  font-size: 12px;
  opacity: 0.5;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Navigation zones (full-height edge click areas) ── */
.mv-nav {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  width: 10vw;
  min-width: 60px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.mv-nav svg {
  opacity: 0;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
}

.mv-nav:hover svg {
  opacity: 1;
}

.mv-nav:active svg {
  opacity: 0.6;
}

.mv-nav[disabled] {
  display: none;
}

.mv-prev {
  left: 0;
  justify-content: flex-start;
  padding-left: 16px;
}

.mv-prev:hover {
  background: linear-gradient(to right, rgba(0, 0, 0, 0.25), transparent);
}

.mv-next {
  right: 0;
  justify-content: flex-end;
  padding-right: 16px;
}

.mv-next:hover {
  background: linear-gradient(to left, rgba(0, 0, 0, 0.25), transparent);
}

/* ── Close buttons (top-left on hover, top-right always) ── */
.mv-close {
  position: absolute;
  top: 12px;
  z-index: 4;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, background 0.15s ease, color 0.15s ease;
  backdrop-filter: blur(4px);
}

.mv-close:hover {
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
}

.mv-close-left {
  left: 0;
  top: 0;
  opacity: 0;
  width: 72px;
  height: 72px;
  border-radius: 0;
  background: none;
  backdrop-filter: none;
}

.mv-close-left svg {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 50%;
  padding: 10px;
  backdrop-filter: blur(4px);
}

.mv-close-left:hover {
  opacity: 1;
}

.mv-close-left:hover svg {
  background: rgba(0, 0, 0, 0.6);
}

.mv-close-right {
  right: 12px;
}

/* ── Responsive: small screens ── */
@media (max-width: 767px) {
  .mv-media img {
    max-width: 100vw;
    max-height: 100vh;
    cursor: default;
  }

  /* Hide edge nav buttons on mobile — swipe gestures replace them */
  .mv-nav {
    display: none;
  }

  /* Show nav buttons for pano/3D/splat where swipe is disabled */
  .mv-no-swipe .mv-nav {
    display: flex;
  }
  .mv-no-swipe .mv-nav svg {
    opacity: 0.7;
  }

  .mv-close {
    top: 8px;
    width: 36px;
    height: 36px;
  }

  .mv-close-left {
    left: 0;
    top: 0;
    width: 52px;
    height: 52px;
    opacity: 1;
  }

  .mv-close-left svg {
    top: 10px;
    left: 10px;
    padding: 8px;
  }

  .mv-close-right {
    right: 8px;
  }
}

/* Touch device: no hover-to-reveal on close button */
@media (hover: none) {
  .mv-close-left {
    opacity: 1;
  }
}

/* ── Swipe peek (adjacent image during swipe) ── */
.mv-peek {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  pointer-events: none;
}

.mv-peek img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

/* ── Image gallery (thumbnail grid) ── */
.media-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 6px;
  padding: 12px 0;
}

.media-gallery-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.5;
  margin: 16px 0 4px;
}

.media-gallery-thumb {
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  background: rgba(128, 128, 128, 0.1);
}

.media-gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}

.media-gallery-thumb:hover img {
  transform: scale(1.05);
}

/* ── Hero image display ── */
.media-hero {
  width: 100%;
  margin: 0 0 12px;
  overflow: hidden;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
}

.media-hero img {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  display: block;
}

/* ── Hero live player (pano/3d/audio/doc rendered inline) ── */
.media-hero-player {
  width: 100%;
  height: 280px;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-hero-player canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Type classes are added directly to the player container by render functions */
.media-hero-player.mv-pano {
  cursor: grab;
}

.media-hero-player.mv-audio {
  flex-direction: column;
  padding: 20px;
  gap: 12px;
}

.media-hero-player.mv-audio .mv-audio-art {
  width: 120px;
  height: 120px;
}

.media-hero-player.mv-audio .mv-audio-player {
  max-width: 100%;
}

/* When hero player is promoted to fullscreen */
.media-hero-player.is-promoted {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary, #1a1a1a);
}

.media-hero-player.is-promoted::after,
.media-embed-player.is-promoted::after {
  content: 'Viewing fullscreen';
  color: var(--fg-tertiary, #888);
  font-size: 12px;
}

/* Hero with live player shouldn't have pointer cursor on the whole area */
.media-hero:has(.media-hero-player) {
  cursor: default;
}

/* ── Hero video (muted autoplay inline) ── */
.media-hero-video {
  width: 100%;
  height: 280px;
  border: none;
  display: block;
  background: #000;
}

.media-hero-video-overlay {
  position: absolute;
  inset: 0;
  cursor: pointer;
}

/* Hero overlay buttons (expand, mute) */
.media-hero-expand-btn,
.media-hero-mute-btn {
  position: absolute;
  bottom: 8px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  backdrop-filter: blur(4px);
  transition: background 0.15s ease;
}

.media-hero-expand-btn:hover,
.media-hero-mute-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

.media-hero-expand-btn svg,
.media-hero-mute-btn svg {
  width: 16px;
  height: 16px;
}

.media-hero-expand-btn { right: 48px; }
.media-hero-mute-btn { right: 8px; }

/* Toggle icon visibility based on muted state */
.media-hero-mute-btn[data-muted="1"] .mute-icon-on { display: none; }
.media-hero-mute-btn[data-muted="1"] .mute-icon-off { display: block; }
.media-hero-mute-btn[data-muted="0"] .mute-icon-on { display: block; }
.media-hero-mute-btn[data-muted="0"] .mute-icon-off { display: none; }

/* ── Inline image embeds in markdown ── */
.media-embed {
  margin: 12px 0;
  clear: both;
}

.media-embed img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
  cursor: pointer;
}

.media-embed figcaption {
  font-size: 12px;
  opacity: 0.6;
  margin-top: 4px;
  font-style: italic;
}

.media-embed.media-right {
  float: right;
  margin: 0 0 12px 16px;
  max-width: 50%;
}

.media-embed.media-left {
  float: left;
  margin: 0 16px 12px 0;
  max-width: 50%;
}

.media-embed.media-wide {
  width: 100%;
}

.media-embed.media-wide img {
  width: 100%;
}

/* ── Inline media player container (non-image embeds) ── */
.media-embed-player {
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  background: #000;
}

.media-embed-player canvas,
.media-embed-player iframe {
  display: block;
  width: 100%;
}

/* Poster (click-to-activate for non-image embeds) */
.media-embed-poster {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000 center / cover no-repeat;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Type badge on poster */
.media-embed-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  pointer-events: none;
}

/* Play icon for video posters */
.media-embed-play {
  width: 56px;
  height: 56px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: background 0.15s ease;
}

.media-embed-poster:hover .media-embed-play {
  background: rgba(0, 0, 0, 0.75);
}

.media-embed-play::after {
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 11px 0 11px 20px;
  border-color: transparent transparent transparent #fff;
  margin-left: 3px;
}

/* Expand button (inline → fullscreen) */
.media-embed-expand {
  position: absolute;
  bottom: 8px;
  right: 8px;
  z-index: 2;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: 4px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  transition: background 0.15s ease;
}

.media-embed-expand:hover {
  background: rgba(0, 0, 0, 0.85);
}

.media-embed-expand svg {
  width: 16px;
  height: 16px;
}

/* Pano/3D inline — auto aspect ratio once canvas is rendered */
.media-embed-player:has(canvas) {
  aspect-ratio: auto;
}

/* Audio inline */
.media-embed[data-media-type="audio"] .media-embed-player {
  background: var(--bg-secondary, #1a1a1a);
  padding: 12px;
  border-radius: 4px;
}

.media-embed[data-media-type="audio"] audio {
  width: 100%;
}

/* Doc placeholder */
.media-embed-doc {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  background: var(--bg-secondary, #1a1a1a);
  border: 1px solid var(--border-color, rgba(128, 128, 128, 0.2));
  border-radius: 4px;
}

/* Active inline player (poster removed, content rendered) */
.media-embed-player.is-active {
  aspect-ratio: auto;
}

.media-embed-player.is-active .media-embed-poster {
  display: none;
}

/* When content is promoted to fullscreen, hide the inline container */
.media-embed-player.is-promoted {
  aspect-ratio: 16 / 9;
  background: var(--bg-secondary, #1a1a1a);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Upload zone ── */
.media-upload-zone {
  border: 2px dashed var(--border-color-strong, rgba(128, 128, 128, 0.2));
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  margin: 12px 0;
  position: relative;
}

.media-upload-zone:hover,
.media-upload-zone.drag-over {
  border-color: var(--accent, #4a90d9);
  background: rgba(74, 144, 217, 0.05);
}

.media-upload-zone-icon {
  font-size: 28px;
  opacity: 0.3;
  margin-bottom: 6px;
}

.media-upload-zone-text {
  font-size: 13px;
  opacity: 0.5;
}

.media-upload-zone-hint {
  font-size: 11px;
  opacity: 0.35;
  margin-top: 4px;
}

.media-upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

/* Upload progress */
.media-upload-progress {
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.media-upload-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 4px 0;
}

.media-upload-item-thumb {
  width: 36px;
  height: 36px;
  border-radius: 3px;
  object-fit: cover;
  flex-shrink: 0;
}

.media-upload-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-upload-item-bar {
  width: 60px;
  height: 4px;
  background: rgba(128, 128, 128, 0.2);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

.media-upload-item-bar-fill {
  height: 100%;
  background: var(--accent, #4a90d9);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.media-upload-item-status {
  font-size: 11px;
  opacity: 0.5;
  flex-shrink: 0;
}

.media-upload-item-status.error {
  color: var(--danger, #d9534f);
  opacity: 1;
}

/* ── Edit form media manager ── */
.media-manager {
  margin: 8px 0;
}

.media-manager-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}

.media-manager-item {
  border-radius: 4px;
  background: rgba(128, 128, 128, 0.1);
}

.media-manager-img-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 4px 4px 0 0;
}

.media-manager-item.is-hero .media-manager-img-wrap {
  outline: 2px solid var(--accent, #4a90d9);
  outline-offset: -2px;
  border-radius: 4px 4px 0 0;
}

.media-manager-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.media-manager-item-actions {
  position: absolute;
  top: 2px;
  right: 2px;
  left: 2px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.media-manager-item:hover .media-manager-item-actions {
  opacity: 1;
}

/* Highlight gallery item when its map marker is hovered */
.media-manager-item.is-map-hover {
  outline: 2px solid var(--accent, #4a90d9);
  outline-offset: -2px;
  border-radius: 4px;
}

.media-manager-btn {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-manager-btn:hover {
  background: rgba(0, 0, 0, 0.9);
}

.media-manager-btn.danger:hover {
  background: var(--danger, #d9534f);
}

.media-manager-hero-badge {
  position: absolute;
  bottom: 2px;
  left: 2px;
  background: var(--accent, #4a90d9);
  color: #fff;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.media-manager-caption {
  margin-top: 4px;
}

.media-manager-caption input {
  width: 100%;
  font-size: 11px;
  padding: 3px 6px;
  border: 1px solid var(--border-color, rgba(128, 128, 128, 0.2));
  border-radius: 3px;
  background: transparent;
  color: inherit;
}

.media-manager-meta {
  margin-top: 2px;
  font-size: 10px;
  opacity: 0.5;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ── Media metadata (expanded EXIF info in edit mode) ── */
.media-meta-primary {
  margin-top: 2px;
  font-size: 10px;
  opacity: 0.5;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.media-meta-details {
  margin-top: 2px;
}

.media-meta-details summary {
  font-size: 10px;
  color: var(--fg-tertiary, #888);
  cursor: pointer;
  user-select: none;
}

.media-meta-details summary:hover {
  color: var(--fg-secondary, #bbb);
}

.media-meta-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1px 8px;
  font-size: 10px;
  color: var(--fg-secondary, #aaa);
  margin-top: 4px;
  padding: 4px 0;
}

.media-meta-grid .meta-label {
  color: var(--fg-tertiary, #888);
  font-weight: 500;
  white-space: nowrap;
}

/* ── Media viewer info panel ── */
.mv-info-btn {
  position: absolute;
  bottom: 52px;
  right: 12px;
  z-index: 10004;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  transition: background 0.15s;
}

.mv-info-btn:hover {
  background: rgba(0, 0, 0, 0.85);
}

.mv-info-panel {
  position: absolute;
  bottom: 52px;
  right: 56px;
  z-index: 10004;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  color: #e0e0e0;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 12px;
  line-height: 1.5;
  max-width: 340px;
  min-width: 200px;
  pointer-events: auto;
}

.mv-info-hidden {
  display: none !important;
}

.mv-info-row {
  display: flex;
  gap: 8px;
  padding: 2px 0;
}

.mv-info-label {
  color: rgba(255, 255, 255, 0.5);
  font-weight: 500;
  white-space: nowrap;
  min-width: 60px;
  flex-shrink: 0;
}

/* ── HTML content type (cheatsheet, help) ── */
.mv-html-content {
  max-width: 560px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding: 24px 32px;
  background: var(--bg-surface-solid, #1a1a1a);
  color: var(--fg-primary, #e0e0e0);
  border-radius: 3px;
  font-size: 14px;
  line-height: 1.6;
}

[data-theme="light"] .mv-html-content {
  background: #fff;
  color: #222;
}

.mv-html-content h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}

.mv-html-content h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 16px 0 8px;
  color: var(--fg-secondary, #aaa);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mv-html-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}

.mv-html-content th,
.mv-html-content td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(128, 128, 128, 0.15);
  vertical-align: top;
}

.mv-html-content th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-tertiary, #888);
}

.mv-html-content code {
  font-family: 'SF Mono', Monaco, 'Consolas', monospace;
  font-size: 12px;
  padding: 2px 5px;
  background: rgba(128, 128, 128, 0.15);
  border-radius: 3px;
}

.mv-html-content .md-result {
  font-size: 13px;
  color: var(--fg-secondary, #bbb);
}

/* ── 360 badge on thumbnails/hero ── */
.media-360-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 600;
  letter-spacing: 0.3px;
  backdrop-filter: blur(4px);
  pointer-events: none;
  line-height: 1.4;
}

/* ── 360 Panorama viewer ── */
.mv-media.mv-pano {
  cursor: grab;
  flex: 1;
  width: 100%;
}

.mv-media.mv-pano canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.mv-pano-loading {
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  padding: 40px;
  text-align: center;
}

/* Pano loader with progress bar */
.mv-pano-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 20px;
  min-height: 200px;
}
.mv-pano-loader-icon {
  font-size: 32px;
  animation: mv-pano-spin 3s linear infinite;
}
@keyframes mv-pano-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.mv-pano-loader-label {
  color: var(--fg-secondary, rgba(255,255,255,0.6));
  font-size: 13px;
}
.mv-pano-loader-bar {
  width: 160px;
  height: 4px;
  background: var(--border-color, rgba(255,255,255,0.15));
  border-radius: 2px;
  overflow: hidden;
}
.mv-pano-loader-fill {
  width: 0%;
  height: 100%;
  background: var(--accent-primary, #4a90d9);
  border-radius: 2px;
  transition: width 0.2s ease;
}

/* Pano error display */
.mv-pano-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 24px;
  min-height: 200px;
  text-align: center;
}
.mv-pano-error-icon {
  font-size: 32px;
  opacity: 0.7;
}
.mv-pano-error-msg {
  color: var(--fg-primary, #fff);
  font-size: 14px;
  line-height: 1.4;
  max-width: 300px;
}
.mv-pano-error-hint {
  color: var(--fg-secondary, rgba(255,255,255,0.5));
  font-size: 12px;
  line-height: 1.4;
  max-width: 280px;
}

.mv-model-host {
  position: relative;
  width: 100%;
  height: 100%;
}

.mv-model-canvas-host {
  width: 100%;
  height: 100%;
}

.mv-model-canvas-host canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.mv-model-loading {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 28px));
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: opacity 220ms ease;
  z-index: 2;
}

.mv-model-loading.is-fading,
.media-config-model-loading.is-fading {
  opacity: 0;
}

.mv-model-loading.is-error,
.media-config-model-loading.is-error {
  border-color: rgba(240, 92, 92, 0.75);
  box-shadow: 0 0 0 1px rgba(240, 92, 92, 0.3) inset;
}

.mv-model-loading.is-warning,
.media-config-model-loading.is-warning {
  border-color: rgba(235, 178, 63, 0.75);
  box-shadow: 0 0 0 1px rgba(235, 178, 63, 0.25) inset;
}

.mv-model-loading.is-error .mv-model-loading-fill,
.media-config-model-loading.is-error .media-config-model-loading-fill {
  background: linear-gradient(90deg, #ff9f9f, #ef5555);
}

.mv-model-loading.is-warning .mv-model-loading-fill,
.media-config-model-loading.is-warning .media-config-model-loading-fill {
  background: linear-gradient(90deg, #f7d27c, #e3a427);
}

.mv-model-loading.is-hidden,
.media-config-model-loading.is-hidden {
  display: none;
}

.mv-model-loading-step {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.65;
  margin-bottom: 2px;
}

.mv-model-loading-title {
  font-size: 12px;
  font-weight: 600;
}

.mv-model-loading-size {
  font-size: 11px;
  opacity: 0.8;
  margin-top: 2px;
  min-height: 14px;
}

.mv-model-loading-bar {
  margin-top: 8px;
  height: 5px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.16);
}

.mv-model-loading-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8db6ff, #4a90d9);
  transition: width 120ms linear;
}

.mv-model-loading-row {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
}

.mv-model-loading-percent {
  font-size: 11px;
  opacity: 0.9;
}

.mv-model-loading-overall {
  font-size: 10px;
  opacity: 0.6;
}

/* ── Video badge on thumbnails/hero ── */
.media-video-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 600;
  backdrop-filter: blur(4px);
  pointer-events: none;
  line-height: 1.4;
}

/* ── Shared media badge on gallery thumbnails ── */
.media-shared-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 11px;
  line-height: 1;
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 4px;
  border-radius: 3px;
  pointer-events: none;
  backdrop-filter: blur(4px);
}

/* ── Shared badge in media manager grid ── */
.media-manager-shared-badge {
  position: absolute;
  bottom: 2px;
  left: 2px;
  background: var(--accent-secondary, #7c3aed);
  color: #fff;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.media-manager-item.is-shared .media-manager-img-wrap {
  outline: 2px dashed var(--accent-secondary, #7c3aed);
  outline-offset: -2px;
}

/* ── Caption empty hint (orange dot) ── */
.media-manager-caption.is-empty {
  position: relative;
}
.media-manager-caption.is-empty::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fg-warning, #e6a817);
  opacity: 0.7;
  pointer-events: none;
}

/* ── Import media panel ── */
.media-import-panel {
  border: 1px solid var(--border-color, rgba(128, 128, 128, 0.2));
  border-radius: 6px;
  overflow: hidden;
  margin-top: 6px;
}

.media-import-header {
  display: flex;
  gap: 6px;
  padding: 6px;
  border-bottom: 1px solid var(--border-color, rgba(128, 128, 128, 0.2));
}

.media-import-search {
  flex: 1;
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid var(--border-color, rgba(128, 128, 128, 0.2));
  border-radius: 4px;
  background: transparent;
  color: inherit;
}

.media-import-results {
  max-height: 200px;
  overflow-y: auto;
}

.media-import-result {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  border-bottom: 1px solid var(--border-color, rgba(128, 128, 128, 0.1));
}

.media-import-result:hover {
  background: var(--bg-hover, rgba(128, 128, 128, 0.1));
}

.media-import-result-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.media-import-result-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-import-result-type {
  font-size: 10px;
  opacity: 0.5;
  text-transform: capitalize;
  flex-shrink: 0;
}

.media-import-gallery-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-color, rgba(128, 128, 128, 0.2));
  font-size: 12px;
  font-weight: 600;
}

.media-import-back {
  background: none;
  border: none;
  color: var(--accent-primary, #4a90d9);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 12px;
}

.media-import-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 4px;
  padding: 6px;
}

.media-import-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
}

.media-import-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media-import-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary, rgba(128, 128, 128, 0.1));
  font-size: 20px;
}

.media-import-check {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

.media-import-thumb.selected {
  border-color: var(--accent-primary, #4a90d9);
}

.media-import-thumb.selected .media-import-check {
  background: var(--accent-primary, #4a90d9);
  border-color: var(--accent-primary, #4a90d9);
}

.media-import-thumb.selected .media-import-check::after {
  content: '\2713';
  color: #fff;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.media-import-actions {
  padding: 6px;
  text-align: center;
  border-top: 1px solid var(--border-color, rgba(128, 128, 128, 0.2));
}

/* ── Video player in modal ── */
.mv-media.mv-video {
  flex: 1;
  width: 100%;
}

.mv-video-player {
  width: 100%;
  height: 100%;
  border: none;
  background: #000;
}

/* ── Audio player in modal ── */
.mv-media.mv-audio {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 40px;
}

.mv-audio-art {
  width: 280px;
  height: 280px;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-tertiary, #222);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

.mv-audio-player {
  width: 100%;
  max-width: 360px;
}

.mv-audio-player audio {
  width: 100%;
  border-radius: 6px;
}

.mv-audio-embed {
  width: 100%;
  height: 300px;
  border: none;
  border-radius: 8px;
}

@media (max-width: 767px) {
  .mv-audio-art {
    width: 200px;
    height: 200px;
  }

  .mv-media.mv-audio {
    padding: 24px 16px;
    gap: 16px;
  }
}

/* ── Video play button overlay on thumbnails ── */
.media-video-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 50%;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-video-play::after {
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 10px 0 10px 18px;
  border-color: transparent transparent transparent #fff;
  margin-left: 3px;
}

.media-video-play-sm {
  width: 32px;
  height: 32px;
}

.media-video-play-sm::after {
  border-width: 7px 0 7px 12px;
  margin-left: 2px;
}

.media-hero:hover .media-video-play,
.media-gallery-thumb:hover .media-video-play {
  background: rgba(0, 0, 0, 0.7);
}

/* ── Video badge in media manager grid ── */
.media-manager-video-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  pointer-events: none;
}

/* ── Show on map button active state ── */
.media-manager-btn.active {
  background: var(--accent, #4a90d9);
}
.media-manager-btn.active:hover {
  background: var(--accent, #4a90d9);
  filter: brightness(1.15);
}
.media-manager-btn svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}
.media-manager-config-btn {
  font-size: 13px;
}

/* ── Media config modal ── */
.media-config-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 10010;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.media-config-modal {
  width: min(980px, 96vw);
  max-height: min(90vh, 860px);
  display: flex;
  flex-direction: column;
  background: var(--bg-surface-solid, #1a1a1a);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.14));
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.media-config-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color, rgba(128, 128, 128, 0.2));
}
.media-config-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}
.media-config-subtitle {
  opacity: 0.7;
  font-size: 12px;
  margin-top: 2px;
}
.media-config-close {
  border: 0;
  background: transparent;
  color: inherit;
  opacity: 0.7;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.media-config-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color, rgba(128, 128, 128, 0.2));
}
.media-config-tab {
  border: 1px solid var(--border-color, rgba(128, 128, 128, 0.25));
  background: transparent;
  color: inherit;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.media-config-tab.active {
  background: var(--accent, #4a90d9);
  color: #fff;
  border-color: transparent;
}
.media-config-body {
  padding: 12px;
  overflow: auto;
}
.media-config-footer {
  border-top: 1px solid var(--border-color, rgba(128, 128, 128, 0.2));
  padding: 10px 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.media-config-layout {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  align-items: start;
}
.media-config-preview {
  position: sticky;
  top: 0;
}
.media-config-section {
  margin-bottom: 10px;
}
.media-config-section h4 {
  margin: 0 0 8px;
  font-size: 13px;
}
.media-config-help {
  margin: 0 0 8px;
  font-size: 12px;
  opacity: 0.7;
}
.media-config-field {
  display: block;
  margin-bottom: 8px;
}
.media-config-field-label {
  display: block;
  font-size: 12px;
  margin-bottom: 3px;
  opacity: 0.8;
}
.media-config-field-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  gap: 8px;
  align-items: center;
}
.media-config-num {
  width: 100%;
  font-size: 12px;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-color, rgba(128, 128, 128, 0.2));
  background: transparent;
  color: inherit;
}
.media-config-preview-title {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
}
.media-config-pano-preview-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color, rgba(128, 128, 128, 0.2));
  background: rgba(0, 0, 0, 0.35);
}
.media-config-pano-preview-host {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  opacity: 0.7;
}
.media-config-pano-preview-host canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.media-config-pano-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center center;
}
.media-config-horizon-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 0;
  border-top: 2px solid #47d16b;
  box-shadow: 0 0 8px rgba(71, 209, 107, 0.6);
}
.media-config-horizon-line-soft {
  border-top-width: 1px;
  border-top-style: dashed;
  opacity: 0.55;
  box-shadow: none;
}
.media-config-horizon-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.55;
  background-image:
    linear-gradient(to right, rgba(71, 209, 107, 0.22), rgba(71, 209, 107, 0.22)),
    repeating-linear-gradient(to bottom, rgba(71, 209, 107, 0.1), rgba(71, 209, 107, 0.1) 1px, transparent 1px, transparent 18%);
  background-size: 1px 100%, 100% 100%;
  background-position: 50% 0, 0 0;
}
.media-config-grid-hidden .media-config-horizon-grid {
  display: none;
}
.media-config-assist-bar {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.media-config-assist-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.media-config-horizon-locked {
  box-shadow: inset 0 0 0 2px rgba(71, 209, 107, 0.4);
}
.media-config-asset-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.media-config-asset-row {
  border: 1px solid var(--border-color, rgba(128, 128, 128, 0.2));
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.media-config-asset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.media-config-asset-grid input,
.media-config-asset-grid select {
  width: 100%;
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--border-color, rgba(128, 128, 128, 0.2));
  border-radius: 4px;
  background: transparent;
  color: inherit;
}
.media-config-asset-grid label {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.media-config-code {
  width: 100%;
  min-height: 160px;
  font-size: 12px;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  border: 1px solid var(--border-color, rgba(128, 128, 128, 0.2));
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
  color: inherit;
  padding: 8px;
  resize: vertical;
}
.media-config-code-small {
  min-height: 100px;
}
.media-config-inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  margin-bottom: 8px;
}
.media-config-select {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--border-color, rgba(128, 128, 128, 0.2));
  border-radius: 4px;
  background: transparent;
  color: inherit;
}

@media (max-width: 900px) {
  .media-config-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ── Draggable media marker on map (edit mode) ── */
.media-manager-drag-marker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--accent, #4a90d9);
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  background: var(--color-media, #78c8a8);
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
.media-manager-drag-marker:active {
  cursor: grabbing;
}
.media-manager-drag-marker:hover .tap-photo-marker-preview {
  opacity: 1;
  transform: scale(var(--preview-scale));
}
.media-manager-drag-marker:hover > .tap-photo-marker-icon {
  opacity: 0;
}
/* Suppress preview during drag for precise placement */
.media-manager-drag-marker.is-dragging .tap-photo-marker-preview {
  opacity: 0 !important;
  transform: scale(1) !important;
}
.media-manager-drag-marker.is-dragging > .tap-photo-marker-icon {
  opacity: 1 !important;
}

/* Geodot variant — keeps 28px hit area but renders as small centered dot */
.media-manager-drag-marker.is-geodot {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.media-manager-drag-marker.is-geodot::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: white;
  border: 1px solid rgba(0,0,0,0.35);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.media-manager-drag-marker.is-geodot > .tap-photo-marker-icon {
  display: none;
}
.media-manager-drag-marker.is-geodot .tap-photo-marker-preview {
  --preview-border: 1px;
}
.media-manager-drag-marker.is-geodot:hover .tap-photo-marker-preview,
.media-manager-drag-marker.is-geodot.is-hover .tap-photo-marker-preview {
  opacity: 1;
  transform: scale(var(--preview-scale));
}

/* Highlight state — triggered by gallery hover */
.media-manager-drag-marker.is-hover:not(.is-geodot) {
  box-shadow: 0 0 0 3px var(--accent, #4a90d9), 0 2px 6px rgba(0,0,0,0.35);
}
.media-manager-drag-marker.is-hover:not(.is-geodot) .tap-photo-marker-preview {
  opacity: 1;
  transform: scale(var(--preview-scale));
}
.media-manager-drag-marker.is-hover:not(.is-geodot) > .tap-photo-marker-icon {
  opacity: 0;
}

/* ── Attribution input in media manager ── */
.media-manager-attribution {
  margin-top: 3px;
}
.media-manager-attribution input {
  width: 100%;
  font-size: 11px;
  padding: 3px 6px;
  border: 1px solid var(--border-color, rgba(128, 128, 128, 0.2));
  border-radius: 3px;
  background: transparent;
  color: inherit;
  box-sizing: border-box;
}

/* ── Shared photo marker styles (standalone, geodot, and UGC photo items) ── */

/* Camera emoji icon inside markers */
.tap-photo-marker-icon {
  font-size: 14px;
  line-height: 1;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

/* Thumbnail preview — shared across all photo marker types */
.tap-photo-marker-preview {
  --preview-size: 28px;
  --preview-border: 2px;
  --preview-scale: 4;
  position: absolute;
  width: var(--preview-size);
  height: var(--preview-size);
  top: 50%;
  left: 50%;
  margin-top: calc(var(--preview-size) / -2);
  margin-left: calc(var(--preview-size) / -2);
  border-radius: 50%;
  background-color: #666;
  background-size: cover;
  background-position: center;
  border: var(--preview-border) solid white;
  box-shadow: 0 3px 12px rgba(0,0,0,0.45);
  pointer-events: none;
  opacity: 0;
  transform: scale(1);
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              opacity 0.15s ease;
}
.tap-photo-marker-preview::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border: 1.5px solid rgba(255,255,255,0.3);
  border-top-color: rgba(255,255,255,0.9);
  border-radius: 50%;
  animation: tap-preview-spin 0.6s linear infinite;
}
.tap-photo-marker-preview.thumb-loaded::after {
  display: none;
}
@keyframes tap-preview-spin {
  to { transform: rotate(360deg); }
}

/* ── Standalone media_photo markers (from spatial endpoint) ── */
.tap-ugc-marker-media-photo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  background: var(--color-media, #78c8a8);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
  box-sizing: border-box;
}
.tap-ugc-marker-media-photo:hover .tap-photo-marker-preview,
.tap-ugc-marker-media-photo.is-hover .tap-photo-marker-preview {
  opacity: 1;
  transform: scale(var(--preview-scale));
}
/* Only hide icon when a thumbnail preview exists to replace it */
.tap-ugc-marker-media-photo:has(.tap-photo-marker-preview):hover > .tap-photo-marker-icon,
.tap-ugc-marker-media-photo:has(.tap-photo-marker-preview).is-hover > .tap-photo-marker-icon {
  opacity: 0;
}

/* ── Geodot markers (item panel geotagged media) ── */
.tap-media-geodot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tap-media-geodot::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: white;
  border: 1px solid rgba(0,0,0,0.35);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.tap-media-geodot .tap-photo-marker-preview {
  --preview-border: 1px;
}
.tap-media-geodot:hover .tap-photo-marker-preview,
.tap-media-geodot.is-hover .tap-photo-marker-preview {
  opacity: 1;
  transform: scale(var(--preview-scale));
}
.tap-media-geodot:hover::after,
.tap-media-geodot.is-hover::after {
  display: none;
}
/* ── UGC items with hero thumbs (hover, extent-hover, or highlight to expand) ── */
.tap-ugc-marker:hover .tap-photo-marker-preview,
.tap-ugc-marker.tap-ugc-marker-hover .tap-photo-marker-preview,
.tap-ugc-marker.tap-ugc-marker-highlight .tap-photo-marker-preview {
  opacity: 1;
  transform: scale(var(--preview-scale));
}
/* Active marker: suppress preview — item is showing in the panel */
.tap-ugc-marker.tap-ugc-marker-active .tap-photo-marker-preview,
.tap-ugc-marker.tap-ugc-marker-active:hover .tap-photo-marker-preview {
  opacity: 0;
  transform: scale(1);
}
.tap-ugc-marker.has-preview:hover,
.tap-ugc-marker.has-preview.tap-ugc-marker-hover,
.tap-ugc-marker.has-preview.tap-ugc-marker-highlight {
  color: transparent;
}
.tap-ugc-marker.has-preview:hover > img,
.tap-ugc-marker.has-preview.tap-ugc-marker-hover > img,
.tap-ugc-marker.has-preview.tap-ugc-marker-highlight > img {
  opacity: 0;
}
/* Active marker: restore icon visibility (preview is suppressed) */
.tap-ugc-marker.has-preview.tap-ugc-marker-active,
.tap-ugc-marker.has-preview.tap-ugc-marker-active:hover {
  color: inherit;
}
.tap-ugc-marker.has-preview.tap-ugc-marker-active > img,
.tap-ugc-marker.has-preview.tap-ugc-marker-active:hover > img {
  opacity: 1;
}

/* ── Disable photo previews toggle ── */
.no-photo-previews .tap-photo-marker-preview {
  display: none !important;
}
.no-photo-previews .tap-ugc-marker.has-preview:hover,
.no-photo-previews .tap-ugc-marker.has-preview.tap-ugc-marker-hover,
.no-photo-previews .tap-ugc-marker.has-preview.tap-ugc-marker-highlight {
  color: inherit;
}
.no-photo-previews .tap-ugc-marker.has-preview:hover > img,
.no-photo-previews .tap-ugc-marker.has-preview.tap-ugc-marker-hover > img,
.no-photo-previews .tap-ugc-marker.has-preview.tap-ugc-marker-highlight > img {
  opacity: 1;
}
.no-photo-previews .tap-ugc-marker-media-photo:hover > .tap-photo-marker-icon,
.no-photo-previews .tap-ugc-marker-media-photo.is-hover > .tap-photo-marker-icon {
  opacity: 1;
}

/* ── Overflow + z-index for ALL markers with photo previews ── */
.maplibregl-marker:has(.tap-photo-marker-preview),
.ol-overlay-container:has(.tap-photo-marker-preview) {
  overflow: visible !important;
}
.maplibregl-marker:has(.tap-photo-marker-preview) .tap-ugc-marker-wrapper,
.ol-overlay-container:has(.tap-photo-marker-preview) .tap-ugc-marker-wrapper {
  overflow: visible !important;
}
/* Hovered marker with preview must render above all other markers,
   including the active/selected item marker (z-index: 9999 inline) */
.maplibregl-marker:has(.tap-ugc-marker:hover),
.maplibregl-marker:has(.tap-ugc-marker-hover),
.maplibregl-marker:has(.tap-ugc-marker-highlight),
.maplibregl-marker:has(.tap-media-geodot:hover),
.maplibregl-marker:has(.media-manager-drag-marker:hover),
.maplibregl-marker:has(.is-hover),
.maplibregl-marker:has(.tap-ugc-marker-media-photo:hover),
.ol-overlay-container:has(.tap-ugc-marker:hover),
.ol-overlay-container:has(.tap-ugc-marker-hover),
.ol-overlay-container:has(.tap-ugc-marker-highlight),
.ol-overlay-container:has(.tap-media-geodot:hover),
.ol-overlay-container:has(.media-manager-drag-marker:hover),
.ol-overlay-container:has(.is-hover),
.ol-overlay-container:has(.tap-ugc-marker-media-photo:hover) {
  z-index: 10000 !important;
}
/* ── Media action buttons (video URL, audio URL, audio file) ── */
.media-manager-actions {
  margin-top: 6px;
  padding: 2px 0;
}

.media-manager-actions-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.media-action-btn {
  font-size: 12px;
  padding: 4px 10px;
  min-height: 28px;
  gap: 4px;
  display: inline-flex;
  align-items: center;
}

.media-action-btn.drag-over {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

.media-manager-url-form {
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}

.media-manager-url-input {
  flex: 1;
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid var(--border-color, rgba(128, 128, 128, 0.2));
  border-radius: 4px;
  background: var(--bg-secondary, #1a1a1a);
  color: var(--fg-primary, #e0e0e0);
  min-width: 0;
}

/* ── Audio badge in media manager grid ── */
.media-manager-audio-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  pointer-events: none;
}

/* ── Audio placeholder (no thumbnail) ── */
.media-manager-audio-placeholder {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  background: var(--bg-tertiary, #222);
  opacity: 0.4;
}

/* ── 3D Config Editor (inside media-config modal) ── */
.media-config-model-loading {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  width: min(280px, calc(100% - 20px));
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: opacity 220ms ease;
  z-index: 2;
  font-size: 11px;
}
.media-config-model-loading .mv-model-loading-title {
  font-size: 11px;
  font-weight: 600;
}
.media-config-model-loading .mv-model-loading-size {
  font-size: 10px;
  opacity: 0.8;
  margin-top: 2px;
}
.media-config-model-loading .mv-model-loading-bar {
  margin-top: 6px;
  height: 4px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.16);
}
.media-config-model-loading .mv-model-loading-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8db6ff, #4a90d9);
  transition: width 120ms linear;
}
.media-config-model-loading .mv-model-loading-percent {
  margin-top: 4px;
  font-size: 10px;
  text-align: right;
  opacity: 0.9;
}

.config-3d-preview-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color, rgba(128, 128, 128, 0.2));
  background: rgba(0, 0, 0, 0.35);
}
.config-3d-preview-frame .mv-model-host {
  position: absolute;
  inset: 0;
}
.config-3d-preview-frame .mv-model-canvas-host {
  width: 100%;
  height: 100%;
}
.config-3d-preview-frame .mv-model-canvas-host canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.config-3d-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}
.config-3d-section-toggle::after {
  content: '\25BC';
  font-size: 9px;
  opacity: 0.5;
  transition: transform 0.15s ease;
}
.config-3d-section.is-collapsed .config-3d-section-toggle::after {
  transform: rotate(-90deg);
}
.config-3d-section.is-collapsed .config-3d-section-body {
  display: none;
}

.config-3d-asset-entry {
  border: 1px solid var(--border-color, rgba(128, 128, 128, 0.2));
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 6px;
  position: relative;
}
.config-3d-asset-entry .media-config-asset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.config-3d-asset-entry .media-config-asset-grid input,
.config-3d-asset-entry .media-config-asset-grid select {
  width: 100%;
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--border-color, rgba(128, 128, 128, 0.2));
  border-radius: 4px;
  background: transparent;
  color: inherit;
}
.config-3d-asset-entry .media-config-asset-grid label {
  font-size: 11px;
  display: block;
  opacity: 0.7;
  margin-bottom: 2px;
}
.config-3d-asset-url {
  grid-column: 1 / -1;
}
.config-3d-asset-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  border: none;
  background: transparent;
  color: var(--danger, #d9534f);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  opacity: 0.6;
  padding: 2px 4px;
}
.config-3d-asset-remove:hover {
  opacity: 1;
}

.config-3d-raw-json {
  margin-top: 8px;
}
.config-3d-raw-json summary {
  cursor: pointer;
  font-size: 12px;
  opacity: 0.6;
  margin-bottom: 4px;
}
