:root {
  --sidebar-bg: rgba(20, 35, 60, 0.82);
  --sidebar-border: rgba(255, 255, 255, 0.14);
  --text: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.6);
  --accent: #5eead4;
  --accent-bg: rgba(94, 234, 212, 0.12);
  --toggle-bg: #0f172a;
  --sidebar-width: 360px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  overflow: hidden;
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#tour-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.viewer__home {
  position: absolute;
  inset: 0;
}

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

.hotspots {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: #0092CA;
  color: #fff;
  font: inherit;
  border: 3px solid #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  display: grid;
  place-items: center;
  pointer-events: auto;
  z-index: 5;
  transition: transform 0.15s ease;
}

.hotspot__icon {
  width: 18px;
  height: 18px;
  display: block;
}

.hotspot__label {
  position: absolute;
  bottom: 100%;
  left: 50%;
  margin-bottom: 12px;
  padding: 7px 12px;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  white-space: nowrap;
  transform: translateX(-50%) translateY(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 6;
}

.hotspot__label::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(15, 23, 42, 0.92);
}

.hotspot:hover .hotspot__label,
.hotspot:focus-visible .hotspot__label {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hotspot::before,
.hotspot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid #0092CA;
  pointer-events: none;
  animation: hotspot-pulse 2.4s cubic-bezier(0.16, 0.84, 0.44, 1) infinite;
}

.hotspot::after { animation-delay: 1.2s; }

.hotspot:hover {
  transform: translate(-50%, -50%) scale(1.12);
  background: #00a8e8;
}

@keyframes hotspot-pulse {
  0% {
    transform: scale(1);
    opacity: 0.9;
  }
  100% {
    transform: scale(2.2);
    opacity: 0;
  }
}

/* --- Editor mode --- */

body[data-editor="true"] .editor-hotspot { cursor: grab; }
body[data-editor="true"] .editor-hotspot:active { cursor: grabbing; }
body[data-editor="true"] .editor-hotspot::before,
body[data-editor="true"] .editor-hotspot::after { animation: none; opacity: 0; }
body[data-editor="true"] .editor-hotspot { outline: 2px dashed #fde047; outline-offset: 4px; }

.editor-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #fde047;
  color: #1a1d21;
  padding: 10px 16px;
  font-size: 13px;
  z-index: 100;
  text-align: center;
  font-family: "Inter", sans-serif;
}
.editor-banner code {
  background: rgba(0,0,0,0.12);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 12px;
}

.editor-panel {
  position: fixed;
  right: 16px;
  top: 56px;
  bottom: 16px;
  width: 380px;
  background: #fff;
  color: #1a1d21;
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.3);
  z-index: 100;
  display: flex;
  flex-direction: column;
  font-family: "Inter", sans-serif;
  font-size: 13px;
}

.editor-panel__head {
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 600;
  font-size: 14px;
}

.editor-panel__rows {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  min-height: 0;
}

.editor-row {
  display: grid;
  grid-template-columns: 36px 80px 1fr 28px;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid #f1f5f9;
}

.editor-row__id { font-weight: 600; color: #0892CA; }
.editor-row__coords { font-family: ui-monospace, monospace; font-size: 12px; color: #64748b; }
.editor-row__loc {
  font: inherit;
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  background: #fff;
  min-width: 0;
}
.editor-row__del {
  width: 24px;
  height: 24px;
  border: 0;
  background: #fee2e2;
  color: #b91c1c;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.editor-row__del:hover { background: #fecaca; }

.editor-panel__actions {
  padding: 12px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.editor-btn {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #1a1d21;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.editor-btn:hover { background: #f1f5f9; }
.editor-btn.is-active { background: #0892CA; color: #fff; border-color: #0892CA; }
.editor-btn--primary {
  background: #0892CA;
  color: #fff;
  border-color: #0892CA;
}
.editor-btn--primary:hover { background: #00a8e8; }

.editor-panel__code {
  padding: 10px 12px;
  margin: 0;
  background: #0f172a;
  color: #94e0ff;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  border-radius: 0 0 8px 8px;
  white-space: pre;
  overflow: auto;
  max-height: 200px;
  flex-shrink: 0;
}

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--sidebar-width);
  max-width: 90vw;
  background: var(--sidebar-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: 10;
  color: var(--text);
}

.sidebar.is-open { transform: translateX(0); }

.sidebar__brand {
  padding: 40px 40px 32px;
  flex-shrink: 0;
}

.sidebar__logo {
  display: block;
  width: 100%;
  max-width: 220px;
  height: auto;
}

.sidebar__back {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 8px 40px 0;
  padding: 12px 0;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--sidebar-border);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-style: italic;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar__back-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--toggle-bg);
  position: relative;
  flex-shrink: 0;
}

.sidebar__back-icon::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 55%;
  width: 7px;
  height: 7px;
  border-top: 2px solid #fff;
  border-left: 2px solid #fff;
  transform: translate(-50%, -50%) rotate(-45deg);
}

.sidebar__locations {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar__locations li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 40px;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
  border-bottom: 1px solid var(--sidebar-border);
  transition: background 0.15s ease;
}

.sidebar__locations li::after {
  content: '›';
  font-size: 22px;
  font-weight: 300;
  color: var(--text-muted);
  transition: transform 0.15s ease, color 0.15s ease;
}

.sidebar__locations li:hover { background: rgba(255, 255, 255, 0.05); }
.sidebar__locations li:hover::after { color: var(--text); transform: translateX(2px); }

.sidebar__scenes {
  list-style: none;
  margin: 0;
  padding: 16px 24px 24px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar__scenes li {
  position: relative;
  cursor: pointer;
  border-radius: 2px;
  overflow: hidden;
  outline: 2px solid transparent;
  outline-offset: 0;
  transition: outline-color 0.15s ease;
  flex-shrink: 0;
}

.scene-card__thumb {
  width: 100%;
  aspect-ratio: 16 / 7;
  background-size: cover;
  background-position: center;
  background-color: #1e293b;
}

.scene-card__title {
  display: block;
  padding: 10px 14px 12px;
  background: rgba(15, 23, 42, 0.55);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  text-align: center;
}

.sidebar__scenes li:hover { outline-color: rgba(255, 255, 255, 0.3); }

.sidebar__scenes li.is-active {
  outline-color: #e11d48;
}

.sidebar__scenes li.is-active .scene-card__title {
  background: linear-gradient(180deg, rgba(225, 29, 72, 0) 0%, rgba(225, 29, 72, 0.9) 100%);
  font-weight: 700;
}

.sidebar__lang {
  display: flex;
  gap: 16px;
  padding: 20px 40px 28px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar__lang button {
  background: none;
  border: 0;
  padding: 4px 0;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.sidebar__lang button:hover { color: var(--text); }
.sidebar__lang button.is-active { color: var(--text); }

.sidebar__toggle {
  position: absolute;
  top: 50%;
  right: -22px;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--toggle-bg);
  border: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 11;
}

.sidebar__toggle-icon {
  width: 10px;
  height: 10px;
  border-top: 2px solid #fff;
  border-left: 2px solid #fff;
  transform: rotate(-45deg) translate(2px, 2px);
  transition: transform 0.3s ease;
}

.sidebar:not(.is-open) .sidebar__toggle {
  right: -52px;
}

.sidebar:not(.is-open) .sidebar__toggle-icon {
  transform: rotate(135deg) translate(-2px, -2px);
}

@media (max-width: 768px) {
  :root { --sidebar-width: 320px; }
  .sidebar__brand { padding: 28px 28px 24px; }
  .sidebar__brand h1 { font-size: 28px; }
  .sidebar__sections,
  .sidebar__tours li,
  .sidebar__lang { padding-left: 28px; padding-right: 28px; }

  .hotspots { display: none; }
}
