:root {
  color-scheme: light;
  --bg: #f6f3ed;
  --panel: #fffdfa;
  --ink: #202124;
  --muted: #686f72;
  --line: #ddd7cd;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --coral: #e46f55;
  --gold: #b98212;
  --shadow: 0 18px 50px rgba(32, 33, 36, 0.14);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  min-height: 100vh;
}

.map-stage {
  position: relative;
  min-height: 100vh;
  background: #d8e6df;
}

.map-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 690;
  pointer-events: none;
  opacity: 0;
  background: rgba(12, 18, 22, 0.22);
  backdrop-filter: blur(7px);
  transition: opacity 220ms ease;
}

.map-only-mode:not(.has-started-shared-playback) .map-stage::after {
  opacity: 1;
}

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

.leaflet-container {
  font-family: inherit;
}

.control-panel {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 100vh;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--panel);
  padding: 20px;
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 7px;
  min-height: 158px;
  border: 1.5px dashed #a7b3ad;
  border-radius: 8px;
  background: #f8faf7;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--accent);
  background: #edf8f5;
  transform: translateY(-1px);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 1.9rem;
  line-height: 1;
}

.drop-title {
  color: var(--ink);
  font-weight: 800;
}

.drop-meta {
  max-width: 250px;
  font-size: 0.86rem;
  line-height: 1.35;
}

.controls-row {
  display: grid;
  grid-template-columns: 48px 48px 48px 1fr;
  gap: 10px;
  align-items: center;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.15rem;
}

.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.icon-button.is-muted {
  color: #9a4a36;
}

.link-button {
  min-height: 44px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 800;
}

.link-button:disabled {
  border-color: var(--line);
  background: #e8e4dc;
  color: var(--muted);
  cursor: not-allowed;
}

.speed-control {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

input[type="range"] {
  accent-color: var(--accent);
}

.progress-wrap {
  display: grid;
  gap: 8px;
}

#timelineRange {
  width: 100%;
}

.time-readout {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.84rem;
}

.photo-card {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 12px;
}

.photo-card img,
.photo-card video {
  width: 108px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: #e6e2da;
}

.photo-card h1 {
  margin: 0 0 5px;
  overflow-wrap: anywhere;
  font-size: 1rem;
  line-height: 1.2;
}

.photo-card p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.cinema-photo {
  position: absolute;
  right: 24px;
  bottom: 24px;
  z-index: 650;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: min(380px, calc(100vw - 48px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.92);
  box-shadow: 0 24px 70px rgba(32, 33, 36, 0.28);
  pointer-events: none;
  transform: translateY(10px) scale(0.98);
  opacity: 0;
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

.cinema-photo img,
.cinema-photo video {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: none;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #e6e2da;
}

.cinema-photo img[hidden],
.cinema-photo video[hidden] {
  display: none;
}

.cinema-photo div {
  display: grid;
  gap: 3px;
  padding: 12px 14px 14px;
}

.cinema-photo strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1rem;
}

.cinema-photo span {
  color: var(--muted);
  font-size: 0.84rem;
}

.map-play-button {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 700;
  display: grid;
  place-items: center;
  gap: 0;
  min-width: 0;
  min-height: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: transparent;
  cursor: pointer;
  font-size: 0;
  padding: 0;
  transform: translate(-50%, -50%);
}

.map-play-button[hidden],
.has-started-shared-playback .map-play-button {
  display: none;
}

.map-play-button span {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow:
    0 0 0 10px rgba(255, 255, 255, 0.72),
    0 24px 70px rgba(32, 33, 36, 0.36);
  color: white;
  font-size: 2rem;
  line-height: 1;
}

.map-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 700;
  display: grid;
  place-items: center;
  gap: 12px;
  min-width: 176px;
  min-height: 116px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.92);
  box-shadow: 0 24px 70px rgba(32, 33, 36, 0.28);
  color: var(--ink);
  font-weight: 800;
  transform: translate(-50%, -50%);
}

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

.map-loader span {
  width: 38px;
  height: 38px;
  border: 4px solid rgba(15, 118, 110, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.is-playing-video .cinema-photo,
.cinema-photo.is-kept-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.map-only-mode .app-shell {
  display: block;
}

.map-only-mode .map-stage {
  width: 100vw;
  min-height: 100vh;
}

.map-only-mode #map {
  width: 100vw;
  height: 100vh;
}

.map-only-mode .control-panel {
  display: none;
}

.status-box {
  display: grid;
  gap: 4px;
  border-left: 4px solid var(--gold);
  background: #fff7e8;
  padding: 12px 14px;
  color: #5d471c;
  font-size: 0.88rem;
}

.status-box strong {
  color: #422f08;
}

.log-panel {
  display: grid;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
  padding: 10px 12px;
  font-size: 0.78rem;
}

.log-panel > strong {
  color: var(--ink);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.log-panel ol {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.log-panel li {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 8px;
  color: var(--muted);
  line-height: 1.3;
}

.log-panel time {
  color: #8a8174;
  font-variant-numeric: tabular-nums;
}

.photo-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.photo-list li {
  min-width: 0;
}

.photo-list button {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 8px;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.photo-list button:hover,
.photo-list button.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12);
}

.photo-list img,
.photo-list video {
  width: 58px;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  background: #e6e2da;
}

.photo-list span {
  min-width: 0;
}

.photo-list strong,
.photo-list small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-list small {
  margin-top: 3px;
  color: var(--muted);
}

.rejected-photo {
  display: grid;
  gap: 3px;
  min-height: 54px;
  border: 1px solid #efd2c7;
  border-radius: 8px;
  background: #fff5f1;
  padding: 10px 12px;
}

.rejected-photo strong,
.rejected-photo small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rejected-photo small {
  color: #9a4a36;
}

.photo-marker {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 3px solid white;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 4px 18px rgba(32, 33, 36, 0.28);
  color: white;
  font-size: 0.7rem;
  font-weight: 900;
}

.photo-marker.is-active {
  width: 34px;
  height: 34px;
  background: var(--gold);
}

.pulse-marker {
  width: 22px;
  height: 22px;
  border: 4px solid white;
  border-radius: 50%;
  background: var(--gold);
  box-shadow:
    0 0 0 8px rgba(185, 130, 18, 0.24),
    0 10px 30px rgba(185, 130, 18, 0.38);
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .map-stage {
    min-height: 58vh;
  }

  .map-only-mode .map-stage {
    min-height: 100vh;
  }

  .control-panel {
    max-height: none;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .cinema-photo {
    right: 14px;
    bottom: 14px;
    width: min(320px, calc(100vw - 28px));
  }
}

@media (max-width: 520px) {
  .control-panel {
    padding: 14px;
  }

  .cinema-photo {
    right: 12px;
    bottom: 12px;
    width: min(280px, calc(100vw - 24px));
  }

  .cinema-photo div {
    padding: 10px 12px 12px;
  }

  .controls-row {
    grid-template-columns: 48px 48px 48px minmax(0, 1fr);
  }

  .photo-card {
    grid-template-columns: 84px 1fr;
  }

  .photo-card img,
  .photo-card video {
    width: 84px;
  }

}
