:root {
  --bg: #000;
  --panel: rgba(26, 26, 28, 0.72);
  --panel-strong: rgba(22, 22, 24, 0.86);
  --panel-border: rgba(255, 255, 255, 0.14);
  --text: #f5f5f7;
  --text-muted: rgba(245, 245, 247, 0.76);
  --text-soft: rgba(245, 245, 247, 0.54);
  --chip: rgba(255, 255, 255, 0.1);
  --chip-active: #f5f5f7;
  --chip-active-text: #111113;
  --tile-fallback: #17171a;
  --blue: #0a84ff;
  --control-radius: 20px;
  --viewer-blend-ms: 320ms;
  --viewer-loading-start: rgba(58, 72, 90, 0.92);
  --viewer-loading-end: rgba(32, 40, 52, 0.94);
  --viewer-loading-glow: rgba(255, 255, 255, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body.viewer-open {
  overflow: hidden;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
}

.top-chrome {
  position: fixed;
  z-index: 30;
  top: 0;
  left: 0;
  right: 0;
  padding: max(0.72rem, env(safe-area-inset-top)) 0.8rem 0.46rem;
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0.46) 70%, rgba(0, 0, 0, 0) 100%);
  backdrop-filter: blur(14px);
}

.top-bar {
  display: flex;
  gap: 0.72rem;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
}

.top-title-wrap {
  min-width: 0;
}

h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2vw, 1.95rem);
  line-height: 1.05;
  letter-spacing: -0.015em;
  font-weight: 620;
}

.status {
  margin: 0.22rem 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 44vw;
}

.filters {
  flex-shrink: 0;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.22rem;
  padding: 0.22rem;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  overflow-x: auto;
  scrollbar-width: none;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter {
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  padding: 0.36rem 0.62rem;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 560;
  cursor: pointer;
  transition: color 120ms ease, background-color 120ms ease;
}

.filter:hover,
.filter:focus-visible {
  color: var(--text);
  background: var(--chip);
  outline: none;
}

.filter.active {
  color: var(--chip-active-text);
  background: var(--chip-active);
}

.app-shell.objects-on .control-deck {
  display: flex;
}

.mobile-controls-toggle {
  display: none;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  padding: 0.34rem 0.72rem;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 560;
  cursor: pointer;
}

.mobile-controls-toggle.active {
  background: rgba(255, 255, 255, 0.92);
  color: #111113;
}

.mobile-controls-toggle:hover,
.mobile-controls-toggle:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.16);
}

.mobile-controls-toggle.active:hover,
.mobile-controls-toggle.active:focus-visible {
  background: #fff;
}

.control-deck {
  display: flex;
  gap: 0.36rem;
  align-items: center;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.08rem;
  scrollbar-width: none;
}

.control-deck::-webkit-scrollbar {
  display: none;
}

.control-group {
  min-width: max-content;
  flex: 0 0 auto;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  padding: 0.36rem 0.62rem;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: rgba(22, 22, 24, 0.6);
  backdrop-filter: blur(16px);
}

.control-group-range {
  min-width: 14.5rem;
}

.control-group-toggle {
  min-width: max-content;
}

.control-label {
  color: var(--text-soft);
  font-size: 0.56rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.control-select {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 560;
  padding: 0;
  min-width: 0;
  max-width: 10.5rem;
  cursor: pointer;
  text-overflow: ellipsis;
}

.control-select:focus-visible {
  outline: none;
}

.control-range-wrap {
  display: flex;
  align-items: center;
  gap: 0.48rem;
  min-width: 10.8rem;
}

.control-range {
  flex: 1 1 auto;
  accent-color: #fff;
}

.density-value {
  flex: 0 0 auto;
  min-width: 4.3rem;
  text-align: right;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 540;
}

.control-toggle {
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.34rem 0.58rem;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.control-toggle.active {
  background: rgba(255, 255, 255, 0.94);
  color: #111113;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.control-toggle:hover,
.control-toggle:focus-visible {
  outline: none;
  color: var(--text);
  background: rgba(255, 255, 255, 0.16);
}

.control-toggle.active:hover,
.control-toggle.active:focus-visible {
  background: #fff;
  color: #111113;
}

.control-clear {
  flex: 0 0 auto;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.44rem 0.78rem;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, opacity 140ms ease;
}

.control-clear:disabled {
  opacity: 0.38;
  cursor: default;
}

.control-clear:not(:disabled):hover,
.control-clear:not(:disabled):focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.28);
}

.spectrum-panel {
  position: fixed;
  z-index: 28;
  right: 0.8rem;
  bottom: calc(max(0.8rem, env(safe-area-inset-bottom) + 0.12rem));
  left: auto;
  top: auto;
  display: grid;
  place-items: center;
  padding: 0.5rem;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: rgba(20, 20, 22, 0.72);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
}

.spectrum-panel[hidden] {
  display: none;
}

.spectrum-shortcuts {
  position: fixed;
  z-index: 29;
  top: calc(max(4.9rem, env(safe-area-inset-top) + 4.1rem));
  left: 0.8rem;
  right: 0.8rem;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.spectrum-shortcuts[hidden] {
  display: none;
}

.spectrum-shortcut-list {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  max-width: min(100%, 48rem);
  overflow-x: auto;
  padding: 0.18rem;
  border-radius: 999px;
  background: rgba(18, 18, 20, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px);
  pointer-events: auto;
  scrollbar-width: none;
}

.spectrum-shortcut-list::-webkit-scrollbar {
  display: none;
}

.spectrum-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.34rem 0.58rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: rgba(245, 245, 247, 0.74);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 560;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 140ms ease, color 140ms ease;
}

.spectrum-shortcut:hover,
.spectrum-shortcut:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.96);
}

.spectrum-shortcut.active {
  background: rgba(255, 255, 255, 0.96);
  color: #111113;
}

.spectrum-shortcut-swatch {
  width: 0.74rem;
  height: 0.74rem;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.28);
  flex: 0 0 auto;
}

.map-view {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: calc(max(5.4rem, env(safe-area-inset-top) + 4.6rem)) 0.75rem max(0.7rem, env(safe-area-inset-bottom));
  gap: 0.72rem;
}

.map-view[hidden] {
  display: none;
}

.app-shell.map-on .map-view {
  display: flex;
}

.app-shell.map-on .gallery-grid,
.app-shell.map-on .control-deck {
  display: none;
}

.map-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0) 34%),
    #101013;
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.34);
}

.map-canvas {
  width: 100%;
  height: 100%;
}

.map-stage .leaflet-container {
  width: 100%;
  height: 100%;
  background: #0f1013;
  font: inherit;
}

.map-stage .leaflet-tile {
  filter: saturate(0.92) contrast(1.02) brightness(0.92);
}

.map-stage .leaflet-control-attribution {
  background: rgba(10, 10, 12, 0.62);
  color: rgba(245, 245, 247, 0.72);
  border-radius: 12px 0 0 0;
  backdrop-filter: blur(10px);
}

.map-stage .leaflet-control-attribution a {
  color: rgba(255, 255, 255, 0.9);
}

.map-stage .leaflet-control-zoom {
  border: none;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

.map-stage .leaflet-control-zoom a {
  width: 34px;
  height: 34px;
  line-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(18, 18, 20, 0.86);
  color: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.map-stage .leaflet-control-zoom a:hover,
.map-stage .leaflet-control-zoom a:focus-visible {
  background: rgba(28, 28, 32, 0.96);
}

.map-pin {
  background: transparent;
  border: none;
}

.map-pin-core {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.34);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.68));
}

.map-pin-live .map-pin-core {
  background: linear-gradient(180deg, rgba(133, 202, 255, 0.98), rgba(90, 170, 255, 0.82));
}

.map-pin-video .map-pin-core {
  background: linear-gradient(180deg, rgba(255, 208, 138, 0.98), rgba(255, 168, 91, 0.82));
}

.map-pin-active .map-pin-core {
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.22), 0 12px 28px rgba(0, 0, 0, 0.42);
  transform: scale(1.08);
}

.map-empty-state {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 0.8rem 1rem;
  border-radius: 18px;
  background: rgba(14, 14, 16, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.9rem;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(14px);
}

.map-hud {
  position: absolute;
  z-index: 500;
  left: 0.85rem;
  right: 0.85rem;
  top: 0.85rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
  pointer-events: none;
}

.map-summary,
.map-fit-button {
  pointer-events: auto;
}

.map-summary {
  margin: 0;
  max-width: min(70vw, 26rem);
  padding: 0.52rem 0.72rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(18, 18, 20, 0.74);
  color: rgba(255, 255, 255, 0.94);
  font-size: 0.78rem;
  font-weight: 560;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px);
}

.map-fit-button,
.map-nav-button,
.map-play-button {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(18, 18, 20, 0.78);
  color: rgba(255, 255, 255, 0.96);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(16px);
}

.map-fit-button {
  padding: 0.52rem 0.74rem;
  border-radius: 999px;
}

.map-timeline-shell {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: 0.55rem;
}

.map-nav-button {
  width: 2.9rem;
  min-width: 2.9rem;
  border-radius: 999px;
  font-size: 1.15rem;
  line-height: 1;
}

.map-nav-button:disabled,
.map-play-button:disabled,
.map-fit-button:disabled {
  opacity: 0.38;
  cursor: default;
}

.map-timeline-panel {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.68rem;
  padding: 0.78rem;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(24, 24, 26, 0.88), rgba(16, 16, 18, 0.9));
  box-shadow: 0 26px 56px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(18px);
}

.map-preview-card {
  display: flex;
  align-items: center;
  gap: 0.78rem;
  width: 100%;
  min-width: 0;
  padding: 0.4rem;
  border: none;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.map-preview-card:hover,
.map-preview-card:focus-visible,
.map-fit-button:hover,
.map-fit-button:focus-visible,
.map-nav-button:not(:disabled):hover,
.map-nav-button:not(:disabled):focus-visible,
.map-play-button:not(:disabled):hover,
.map-play-button:not(:disabled):focus-visible,
.map-speed-select:hover,
.map-speed-select:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.1);
}

.map-preview-image {
  width: 4.4rem;
  height: 4.4rem;
  flex: 0 0 auto;
  border-radius: 18px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.map-preview-copy {
  min-width: 0;
}

.map-preview-eyebrow,
.map-preview-title,
.map-preview-subtitle,
.map-position-label,
.map-speed-label {
  margin: 0;
}

.map-preview-eyebrow {
  color: rgba(245, 245, 247, 0.62);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.map-preview-title {
  margin-top: 0.18rem;
  color: rgba(255, 255, 255, 0.96);
  font-size: 0.98rem;
  font-weight: 620;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-preview-subtitle {
  margin-top: 0.18rem;
  color: rgba(245, 245, 247, 0.7);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-scrubber {
  width: 100%;
  margin: 0;
  accent-color: #fff;
}

.map-timeline-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.map-position-label {
  color: rgba(245, 245, 247, 0.72);
  font-size: 0.76rem;
  font-weight: 540;
}

.map-playback-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.44rem;
}

.map-play-button {
  border-radius: 999px;
  padding: 0.46rem 0.78rem;
}

.map-play-button.active {
  background: rgba(255, 255, 255, 0.94);
  color: #111113;
}

.map-speed-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
  padding: 0.2rem 0.24rem 0.2rem 0.48rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
}

.map-speed-label {
  color: rgba(245, 245, 247, 0.64);
  font-size: 0.64rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.map-speed-select {
  border: none;
  border-radius: 999px;
  padding: 0.22rem 0.48rem;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.96);
  font: inherit;
  font-size: 0.74rem;
}

.spectrum-wheel {
  position: relative;
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(245, 245, 247, 0.96) 0 10%, rgba(245, 245, 247, 0) 58%),
    conic-gradient(from 90deg, #ff3b30, #ff9500, #ffcc00, #34c759, #00c7be, #32ade6, #007aff, #5856d6, #af52de, #ff2d55, #ff3b30);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  cursor: crosshair;
  touch-action: none;
}

.spectrum-wheel:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.spectrum-thumb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: hsl(var(--spectrum-hue, 205) var(--spectrum-saturation, 100%) 54%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.28), 0 2px 8px rgba(0, 0, 0, 0.4);
  transform: translate(calc(-50% + var(--spectrum-x, 0px)), calc(-50% + var(--spectrum-y, 0px)));
}

.gallery-grid {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: calc(max(6.95rem, env(safe-area-inset-top) + 6.1rem)) 0 0;
  display: grid;
  grid-template-columns: repeat(var(--gallery-columns, 4), minmax(0, 1fr));
  gap: 0;
  align-content: start;
  align-items: start;
}

.app-shell.spectrum-on .control-deck {
  display: none;
}

.app-shell.spectrum-on .gallery-grid {
  padding-top: calc(max(8.8rem, env(safe-area-inset-top) + 7.95rem));
}

.gallery-column {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0;
}

.tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: var(--tile-ratio, 3 / 4);
  margin: 0;
  border: none;
  padding: 0;
  overflow: hidden;
  border-radius: 0;
  background: var(--tile-placeholder, var(--tile-fallback));
  cursor: pointer;
  line-height: 0;
  isolation: isolate;
}

.tile.tile-grouped::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 48%, rgba(0, 0, 0, 0.16) 100%);
  pointer-events: none;
}

.tile-object {
  background: rgba(10, 10, 12, 0.92);
}

.tile-object::before {
  opacity: 0.3;
}

.tile-object-media {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-image: var(--object-bg-image);
  background-repeat: no-repeat;
  background-size: var(--object-bg-size, cover);
  background-position: var(--object-bg-position-x, 50%) var(--object-bg-position-y, 50%);
  filter: saturate(1.02) contrast(1.04);
}

.tile-object-copy,
.tile-object-instance-badge {
  position: absolute;
  z-index: 4;
  left: 0.52rem;
  right: 0.52rem;
}

.tile-object-copy {
  bottom: 0.5rem;
  display: grid;
  gap: 0.18rem;
  padding: 0.46rem 0.56rem;
  border-radius: 0.95rem;
  background: rgba(10, 10, 12, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  line-height: 1.2;
}

.tile-object-title {
  display: block;
  color: rgba(255, 255, 255, 0.98);
  font-size: 0.86rem;
  font-weight: 640;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.tile-object-subtitle,
.tile-object-instance-badge {
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.69rem;
  font-weight: 560;
  line-height: 1.2;
}

.tile-object-instance-badge {
  top: 0.5rem;
  right: auto;
  width: max-content;
  max-width: calc(100% - 1.04rem);
  padding: 0.28rem 0.5rem;
  border-radius: 999px;
  background: rgba(10, 10, 12, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--tile-placeholder, linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)));
  opacity: 1;
  transition: opacity 280ms ease;
}

.tile.is-ready::before {
  opacity: 0;
}

.tile:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

.tile img,
.tile video {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 300ms cubic-bezier(0.22, 1, 0.36, 1), opacity 220ms ease, filter 220ms ease;
}

.tile-sequence-count,
.scrub-sequence-count {
  position: absolute;
  top: 0.42rem;
  right: 0.42rem;
  z-index: 4;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.34rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 12, 14, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.96);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  backdrop-filter: blur(10px);
}

.tile img {
  object-fit: cover;
  opacity: 0;
}

.tile.is-ready img {
  opacity: 1;
}

.tile video {
  position: absolute;
  inset: 0;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.02);
}

.tile.previewing video {
  opacity: 1;
  transform: scale(1.04);
  filter: saturate(1.04);
}

.tile.previewing img {
  opacity: 0.32;
  transform: scale(1.04);
}

.object-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.tile.previewing .object-overlay {
  opacity: 0;
}

.object-box {
  position: absolute;
  border: 1.5px solid rgba(90, 220, 255, 0.92);
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(90, 220, 255, 0.12), rgba(90, 220, 255, 0.02));
}

.object-box-label {
  position: absolute;
  top: 0;
  left: 0;
  transform: translateY(-100%);
  max-width: min(100%, 10rem);
  padding: 0.18rem 0.38rem;
  border-radius: 999px;
  background: rgba(16, 20, 24, 0.86);
  color: rgba(255, 255, 255, 0.96);
  font-size: 0.61rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-meta {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.28rem;
  padding: 1.4rem 0.42rem 0.42rem;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.62) 72%, rgba(0, 0, 0, 0.84) 100%);
  transition: opacity 180ms ease, transform 180ms ease;
}

.app-shell.dense-grid .tile-meta {
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
}

.app-shell.dense-grid .tile .object-box-label {
  display: none;
}

.tile-chip,
.viewer-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
  padding: 0.22rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(12, 12, 14, 0.44);
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.67rem;
  font-weight: 560;
  letter-spacing: 0.01em;
  line-height: 1;
  backdrop-filter: blur(8px);
}

.tile-chip-swatch,
.viewer-chip-swatch {
  width: 0.56rem;
  height: 0.56rem;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.24);
}

.tile-meta {
  display: none;
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  background: #000;
}

.viewer.open {
  display: block;
}

.viewer-toolbar {
  position: absolute;
  z-index: 20;
  top: 0;
  left: 0;
  right: 0;
  min-height: 3.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: max(0.75rem, env(safe-area-inset-top)) 0.85rem 0.45rem;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.14) 100%);
  backdrop-filter: blur(14px);
}

.viewer-left {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.viewer-btn {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  padding: 0.3rem 0.66rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 560;
  cursor: pointer;
}

.viewer-actions {
  display: inline-flex;
  gap: 0.18rem;
  padding: 0.18rem;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: rgba(26, 26, 28, 0.54);
}

.viewer-toggle {
  border: none;
  border-radius: 999px;
  padding: 0.26rem 0.5rem;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 560;
  cursor: pointer;
  white-space: nowrap;
}

.viewer-toggle.active {
  background: rgba(255, 255, 255, 0.92);
  color: #111113;
}

.viewer-toggle:disabled {
  opacity: 0.46;
  cursor: default;
}

.viewer-btn:focus-visible,
.viewer-btn:hover,
.viewer-toggle:focus-visible,
.viewer-toggle:hover {
  outline: none;
  background: rgba(255, 255, 255, 0.2);
}

.viewer-toggle.active:hover,
.viewer-toggle.active:focus-visible {
  background: #fff;
}

.viewer-toggle:disabled:hover,
.viewer-toggle:disabled:focus-visible {
  background: transparent;
  color: var(--text-muted);
}

.viewer-meta {
  margin: 0;
  flex: 1;
  text-align: right;
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: pan-y;
  background: radial-gradient(circle at 50% 22%, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0) 42%);
}

.viewer-loading {
  position: absolute;
  inset: 0;
  z-index: 13;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 22% 20%, var(--viewer-loading-glow), rgba(255, 255, 255, 0) 34%),
    radial-gradient(circle at 78% 28%, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 26%),
    linear-gradient(140deg, var(--viewer-loading-start), var(--viewer-loading-end));
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.viewer.is-loading .viewer-loading {
  opacity: 1;
}

.viewer-loading::before,
.viewer-loading::after {
  content: "";
  position: absolute;
  inset: -18%;
  background: conic-gradient(from 0deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0));
  mix-blend-mode: screen;
  animation: viewerLoadingSpin 8s linear infinite;
}

.viewer-loading::after {
  animation-duration: 11s;
  animation-direction: reverse;
  opacity: 0.72;
}

.viewer-loading-orb {
  width: min(30vw, 14rem);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 32%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.02));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16), 0 28px 70px rgba(0, 0, 0, 0.3);
  transform: perspective(900px) rotateX(62deg) rotateZ(18deg);
  animation: viewerLoadingFloat 2.4s ease-in-out infinite;
}

.viewer-loading-copy {
  position: absolute;
  left: 50%;
  bottom: calc(max(6.1rem, env(safe-area-inset-bottom) + 5.25rem));
  transform: translateX(-50%);
  padding: 0.5rem 0.78rem;
  border-radius: 999px;
  background: rgba(14, 14, 16, 0.44);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
}

.viewer-loading-label {
  margin: 0;
  color: rgba(255, 255, 255, 0.96);
  font-size: 0.76rem;
  font-weight: 560;
  letter-spacing: 0.01em;
}

@keyframes viewerLoadingSpin {
  from {
    transform: rotate(0deg) scale(1);
  }

  to {
    transform: rotate(360deg) scale(1.02);
  }
}

@keyframes viewerLoadingFloat {

  0%,
  100% {
    transform: perspective(900px) rotateX(62deg) rotateZ(18deg) translateY(0);
  }

  50% {
    transform: perspective(900px) rotateX(62deg) rotateZ(18deg) translateY(-10px);
  }
}

.viewer-media {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.viewer-video-stack {
  display: none;
  position: absolute;
  inset: 0;
}

.viewer-video-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transform: scale(1.012);
  transition: opacity var(--viewer-blend-ms) cubic-bezier(0.22, 1, 0.36, 1), transform var(--viewer-blend-ms) cubic-bezier(0.22, 1, 0.36, 1);
}

.viewer-video-layer.is-active {
  opacity: 1;
  transform: scale(1);
}

.viewer.video-mode .viewer-video-stack {
  display: block;
}

.viewer.video-mode #viewerImage {
  display: none;
}

.viewer-play {
  position: absolute;
  z-index: 16;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  min-width: 3.25rem;
  height: 3.25rem;
  padding: 0;
  background: rgba(24, 24, 26, 0.68);
  color: #fff;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.viewer.video-mode.paused .viewer-play {
  opacity: 1;
  pointer-events: auto;
}

.viewer.video-mode .viewer-play {
  opacity: 0.88;
  pointer-events: auto;
}

.viewer.video-mode.playing .viewer-play {
  opacity: 0;
  pointer-events: none;
}

.viewer-object-overlay {
  z-index: 15;
}

.viewer-object-overlay[hidden] {
  display: none;
}

.viewer-object-overlay .object-box {
  border-width: 2px;
  border-radius: 14px;
}

.viewer-object-overlay .object-box-label {
  font-size: 0.7rem;
}

.viewer-insights {
  position: absolute;
  z-index: 14;
  left: 0.9rem;
  right: 0.9rem;
  top: calc(max(3.95rem, env(safe-area-inset-top) + 3.15rem));
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
  pointer-events: none;
}

.viewer-chip {
  background: rgba(18, 18, 20, 0.6);
  border-color: rgba(255, 255, 255, 0.16);
  font-size: 0.72rem;
}

.viewer-map-card {
  position: absolute;
  z-index: 14;
  left: 0.9rem;
  bottom: calc(max(4.35rem, env(safe-area-inset-bottom) + 3.75rem));
  width: clamp(9rem, 18vw, 12.5rem);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 1.45rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(180deg, rgba(18, 18, 20, 0.9), rgba(12, 12, 14, 0.82));
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(18px);
  opacity: 0;
  transform: translateY(12px) scale(0.965);
  transition: opacity 200ms ease, transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.viewer-map-card.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.viewer-map-canvas,
.viewer-map-card .leaflet-container {
  width: 100%;
  height: 100%;
  background: #0f1013;
}

.viewer-map-card .leaflet-tile {
  filter: saturate(0.9) contrast(1.02) brightness(0.88);
}

.viewer-map-card .leaflet-control-container {
  display: none;
}

.viewer-map-pin {
  background: transparent;
  border: none;
}

.viewer-map-pin-static .map-pin-core {
  border-width: 1.5px;
  opacity: 0.72;
}

.viewer-map-empty {
  position: absolute;
  inset: auto 0 0 0;
  padding: 0.78rem 0.8rem;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(10, 10, 12, 0.78) 65%, rgba(10, 10, 12, 0.9) 100%);
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.72rem;
  font-weight: 560;
  letter-spacing: 0.01em;
}

.viewer-scrubber-wrap {
  position: absolute;
  z-index: 18;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.3rem 0.55rem max(0.35rem, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.65) 72%, rgba(0, 0, 0, 0.8) 100%);
}

.viewer-scrubber {
  display: flex;
  gap: 0.32rem;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.08rem;
}

.viewer-scrubber::-webkit-scrollbar {
  display: none;
}

.scrub-item {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  overflow: hidden;
  padding: 0;
  background: #0f0f12;
  cursor: pointer;
}

.scrub-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scrub-item.active {
  border-color: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85);
}

.scrub-item.group {
  width: 56px;
  border-radius: 12px;
}

.scrub-item.group-member {
  border-radius: 10px;
}

.scrub-sequence-count {
  top: 4px;
  right: 4px;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.24rem;
  font-size: 0.62rem;
}

.scrub-item.video::after {
  content: "";
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
}

@media (min-width: 900px) {
  .tile {
    border-radius: 0;
  }

  .scrub-item {
    width: 46px;
    height: 46px;
  }
}

@media (max-width: 900px) {
  .control-select {
    max-width: 8.75rem;
  }

  .gallery-grid {
    --gallery-columns: 3;
  }
}

@media (max-width: 560px) {
  .top-chrome {
    padding: max(0.62rem, env(safe-area-inset-top)) 0.6rem 0.34rem;
    gap: 0.3rem;
  }

  .top-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "title refine"
      "filters filters";
    align-items: end;
    gap: 0.34rem 0.42rem;
  }

  .top-title-wrap {
    grid-area: title;
  }

  .mobile-controls-toggle {
    grid-area: refine;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .status {
    margin-top: 0.12rem;
    max-width: 72vw;
    font-size: 0.72rem;
  }

  .filters {
    grid-area: filters;
    width: 100%;
    display: flex;
    flex-wrap: nowrap;
    gap: 0.12rem;
    padding: 0.14rem;
    overflow: hidden;
    border-radius: 0.95rem;
    background: rgba(22, 22, 24, 0.76);
  }

  .filter {
    flex: 1 1 0;
    min-width: 0;
    white-space: nowrap;
    padding: 0.38rem 0.08rem;
    font-size: 0.6rem;
    line-height: 1.05;
    font-weight: 600;
    text-align: center;
  }

  .control-deck {
    position: absolute;
    top: calc(100% + 0.12rem);
    left: 0.6rem;
    right: 0.6rem;
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.38rem;
    overflow: visible;
    padding: 0.14rem;
    border-radius: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(12, 12, 14, 0.86);
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(18px);
  }

  .app-shell.mobile-controls-open .control-deck {
    display: grid;
  }

  .control-group {
    width: 100%;
    min-width: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.34rem;
    padding: 0.54rem 0.62rem;
    border-radius: 1.15rem;
    background: rgba(18, 18, 20, 0.78);
  }

  .control-group-range {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .control-select {
    width: 100%;
    max-width: none;
    font-size: 0.78rem;
  }

  .control-range-wrap {
    width: 100%;
    min-width: 0;
  }

  .control-clear {
    width: 100%;
    min-width: 0;
    border-radius: 1.15rem;
    padding: 0.62rem 0.72rem;
  }

  .map-view {
    padding-inline: 0.6rem;
    padding-top: calc(max(5.25rem, env(safe-area-inset-top) + 4.5rem));
    gap: 0.58rem;
  }

  .map-stage {
    border-radius: 24px;
  }

  .map-hud {
    left: 0.65rem;
    right: 0.65rem;
    top: 0.65rem;
    flex-direction: column;
    align-items: stretch;
  }

  .map-summary {
    max-width: none;
  }

  .map-timeline-shell {
    gap: 0.38rem;
  }

  .map-nav-button {
    width: 2.45rem;
    min-width: 2.45rem;
  }

  .map-timeline-panel {
    padding: 0.66rem;
    border-radius: 22px;
    gap: 0.56rem;
  }

  .map-preview-card {
    gap: 0.58rem;
  }

  .map-preview-image {
    width: 3.6rem;
    height: 3.6rem;
    border-radius: 14px;
  }

  .map-timeline-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .map-playback-controls {
    width: 100%;
    justify-content: space-between;
  }

  .spectrum-panel {
    right: 0.6rem;
    left: auto;
    top: auto;
    bottom: calc(max(0.72rem, env(safe-area-inset-bottom) + 0.1rem));
  }

  .spectrum-shortcuts {
    left: 0.6rem;
    right: 0.6rem;
    top: calc(max(5rem, env(safe-area-inset-top) + 4.2rem));
  }

  .app-shell.spectrum-on .gallery-grid {
    padding-top: calc(max(8.95rem, env(safe-area-inset-top) + 8.15rem));
  }

  .viewer-toolbar {
    align-items: flex-start;
  }

  .viewer-left {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.32rem;
  }

  .viewer-meta {
    max-width: 48vw;
  }

  .viewer-insights {
    top: calc(max(5.95rem, env(safe-area-inset-top) + 5.1rem));
  }

  .viewer-map-card {
    left: 0.7rem;
    bottom: calc(max(4.05rem, env(safe-area-inset-bottom) + 3.55rem));
    width: 8.2rem;
    border-radius: 1.2rem;
  }

  .gallery-grid {
    --gallery-columns: 2;
    padding-top: calc(max(5.55rem, env(safe-area-inset-top) + 4.85rem));
  }

  .app-shell.mobile-controls-open .gallery-grid {
    padding-top: calc(max(14.3rem, env(safe-area-inset-top) + 13.6rem));
  }

  .app-shell.mobile-compact-grid .tile-object-copy,
  .app-shell.mobile-compact-grid .tile-object-instance-badge {
    left: 0.3rem;
    right: 0.3rem;
  }

  .app-shell.mobile-compact-grid .tile-object-copy {
    bottom: 0.28rem;
    gap: 0.08rem;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    backdrop-filter: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95), 0 0 8px rgba(0, 0, 0, 0.86);
  }

  .app-shell.mobile-compact-grid .tile-object-title {
    color: rgba(255, 255, 255, 0.99);
    font-size: 0.58rem;
    font-weight: 650;
    letter-spacing: 0.01em;
    line-height: 1.08;
  }

  .app-shell.mobile-compact-grid .tile-object-subtitle {
    color: rgba(255, 255, 255, 0.86);
    font-size: 0.5rem;
    font-weight: 580;
    line-height: 1.1;
  }

  .app-shell.mobile-compact-grid .tile-object-instance-badge {
    top: 0.28rem;
    max-width: calc(100% - 0.6rem);
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    backdrop-filter: none;
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.5rem;
    font-weight: 650;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95), 0 0 8px rgba(0, 0, 0, 0.86);
  }
}
