:root {
  --ui-bg: rgba(12, 14, 18, 0.62);
  --ui-bg-soft: rgba(12, 14, 18, 0.44);
  --ui-bg-strong: rgba(12, 14, 18, 0.86);
  --ui-border: rgba(255, 255, 255, 0.16);
  --ui-text: #fff;
  --ui-muted: rgba(255, 255, 255, 0.72);
  --ui-shadow: 0 16px 45px rgba(0, 0, 0, 0.34);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

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

.viewer-shell,
.viewer-canvas,
.hotspot-layer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.viewer-canvas {
  touch-action: none;
}

.viewer-canvas canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hotspot-layer {
  z-index: 12;
  pointer-events: none;
}

.hotspot {
  position: absolute;
  display: grid;
  place-items: center;
  min-width: 42px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(255,255,255,.26);
  border-radius: 999px;
  background: rgba(10, 12, 16, .68);
  color: #fff;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  backdrop-filter: blur(14px);
  cursor: pointer;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  transition: opacity 160ms ease, transform 160ms ease, background 160ms ease;
  font-size: 13px;
  white-space: nowrap;
}

.hotspot:hover {
  background: rgba(255,255,255,.18);
  transform: translate(-50%, -50%) scale(1.04);
}

.hotspot::before {
  content: "";
  width: 10px;
  height: 10px;
  margin-right: 7px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

.hotspot.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 40;
  padding: 18px 22px;
  min-width: min(320px, calc(100vw - 40px));
  border: 1px solid var(--ui-border);
  border-radius: 20px;
  background: var(--ui-bg-strong);
  backdrop-filter: blur(18px);
  box-shadow: var(--ui-shadow);
  text-align: center;
}

.loading-panel.is-hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.loading-title {
  font-weight: 650;
  margin-bottom: 6px;
}

.loading-text {
  color: var(--ui-muted);
  font-size: 14px;
}

.toolbar,
.ui-toggle {
  position: fixed;
  z-index: 25;
  border: 1px solid var(--ui-border);
  background: var(--ui-bg);
  color: var(--ui-text);
  backdrop-filter: blur(18px);
  box-shadow: var(--ui-shadow);
}

.toolbar {
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 8px;
  border-radius: 999px;
  transition: transform 220ms ease, opacity 220ms ease;
}

.viewer-shell.ui-hidden .toolbar,
.viewer-shell.ui-auto-hidden .toolbar {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(18px) scale(0.98);
}

.toolbar button,
.ui-toggle,
.close-info {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

.toolbar button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: transparent;
}

.toolbar button:hover,
.toolbar button.is-active,
.ui-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
}

.ui-toggle {
  right: 16px;
  top: calc(16px + var(--safe-top));
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  transition: background 160ms ease, opacity 220ms ease;
}

.icon {
  width: 22px;
  height: 22px;
  display: inline-block;
}

.icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.side-panel {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 35;
  width: min(390px, calc(100vw - 36px));
  max-height: min(680px, calc(100vh - 36px));
  overflow: auto;
  box-sizing: border-box;
  padding: 20px;
  border: 1px solid var(--ui-border);
  border-radius: 22px;
  background: var(--ui-bg-strong);
  backdrop-filter: blur(18px);
  box-shadow: var(--ui-shadow);
}

.side-panel h1 {
  margin: 0 34px 10px 0;
  font-size: 20px;
}

.side-panel p {
  margin: 0 0 10px 0;
  line-height: 1.45;
}

.side-panel hr {
  border: 0;
  border-top: 1px solid var(--ui-border);
  margin: 14px 0;
}

.muted {
  color: var(--ui-muted);
  font-size: 14px;
}

.close-info {
  position: absolute;
  right: 12px;
  top: 10px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: transparent;
  color: var(--ui-text);
  font-size: 24px;
}

.gallery-list {
  display: grid;
  gap: 10px;
}

.gallery-item {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--ui-border);
  border-radius: 16px;
  background: var(--ui-bg-soft);
  color: var(--ui-text);
  text-align: left;
  cursor: pointer;
}

.gallery-item:hover,
.gallery-item.is-active {
  background: rgba(255,255,255,.14);
}

.gallery-thumb {
  width: 78px;
  height: 52px;
  object-fit: cover;
  border-radius: 11px;
  background: rgba(255,255,255,.1);
}

.gallery-title {
  font-weight: 650;
}

.gallery-subtitle {
  color: var(--ui-muted);
  font-size: 13px;
  margin-top: 3px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + var(--safe-bottom));
  z-index: 60;
  transform: translateX(-50%);
  padding: 10px 14px;
  border: 1px solid var(--ui-border);
  border-radius: 999px;
  background: var(--ui-bg-strong);
  color: var(--ui-text);
  box-shadow: var(--ui-shadow);
  backdrop-filter: blur(18px);
  font-size: 14px;
}

@media (max-width: 560px) {
  .toolbar {
    max-width: calc(100vw - 96px);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .toolbar::-webkit-scrollbar { display: none; }
  .toolbar button,
  .ui-toggle { width: 48px; height: 48px; }
  .side-panel {
    left: 12px;
    right: 12px;
    top: 12px;
    width: auto;
    max-height: calc(100vh - 110px);
  }
  .hotspot {
    min-width: 46px;
    height: 46px;
  }
}
