:root {
  --bg-0: #05080d;
  --bg-1: #091019;
  --panel-stroke: rgba(208, 235, 255, 0.14);
  --panel-fill: rgba(8, 14, 24, 0.38);
  --text-strong: #f8fbff;
  --accent: #9debb6;
  --accent-strong: #74d896;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
  --ring-shadow: 0 0 0 1px rgba(219, 237, 252, 0.08), 0 12px 40px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100svh;
  overflow: hidden;
  color: var(--text-strong);
  font-family: "Avenir Next", "Segoe UI Variable", "Helvetica Neue", sans-serif;
  background:
    radial-gradient(circle at top, rgba(57, 120, 111, 0.22), transparent 42%),
    radial-gradient(circle at 20% 80%, rgba(28, 58, 83, 0.44), transparent 34%),
    linear-gradient(180deg, #061019 0%, var(--bg-0) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(6, 11, 18, 0.18), transparent 18%, transparent 78%, rgba(2, 3, 7, 0.54)),
    radial-gradient(circle at center, transparent 50%, rgba(2, 4, 8, 0.64) 100%);
}

.app-shell {
  position: relative;
  min-height: 100svh;
  isolation: isolate;
}

#viewerCanvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.05), transparent 44%);
}

#viewerCanvas:active {
  cursor: grabbing;
}

.brand-mark,
.idle-anchor,
.control-dock,
.toast {
  position: relative;
  z-index: 2;
}

.brand-mark {
  position: absolute;
  top: clamp(1rem, 2vw, 1.6rem);
  left: clamp(1rem, 2vw, 1.6rem);
}

.brand-mark span {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(157, 235, 182, 0.95), rgba(116, 216, 150, 0.65));
  box-shadow:
    0 0 0 10px rgba(157, 235, 182, 0.06),
    0 0 32px rgba(116, 216, 150, 0.2);
}

.idle-anchor {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

.orb-button,
.dock-button {
  appearance: none;
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition:
    transform 180ms ease,
    background-color 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    opacity 180ms ease;
}

.orb-button {
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: min(18vw, 164px);
  height: min(18vw, 164px);
  min-width: 112px;
  min-height: 112px;
  border-radius: 999px;
  background: rgba(8, 14, 24, 0.16);
  box-shadow:
    var(--ring-shadow),
    0 0 0 34px rgba(157, 235, 182, 0.035);
  backdrop-filter: blur(20px) saturate(145%);
}

.orb-button::before,
.orb-button::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.orb-button::before {
  inset: 12px;
  border: 1px solid rgba(219, 237, 252, 0.12);
}

.orb-button::after {
  inset: -14px;
  border: 1px dashed rgba(157, 235, 182, 0.14);
}

.orb-core {
  display: grid;
  place-items: center;
  width: 54%;
  height: 54%;
  border-radius: 999px;
  color: #08110d;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 18px 34px rgba(104, 212, 149, 0.22);
}

.orb-button:hover,
.dock-button:hover {
  transform: translateY(-1px);
}

.orb-button:disabled {
  pointer-events: none;
  cursor: default;
}

.dock-button:disabled {
  pointer-events: none;
  cursor: default;
  opacity: 0.34;
  box-shadow: none;
}

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

.button-icon--large {
  width: 28px;
  height: 28px;
}

.control-dock {
  position: absolute;
  top: 50%;
  right: clamp(1rem, 2vw, 1.6rem);
  display: grid;
  gap: 0.75rem;
  padding: 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(208, 235, 255, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 30%),
    var(--panel-fill);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(140%);
  transform: translateY(-50%);
}

.dock-button {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 999px;
  border: 1px solid rgba(221, 236, 249, 0.14);
  color: rgba(248, 251, 255, 0.88);
  background: rgba(7, 14, 23, 0.38);
  backdrop-filter: blur(14px);
}

.dock-button:hover {
  border-color: rgba(221, 236, 249, 0.28);
  background: rgba(11, 20, 31, 0.48);
}

.dock-button--accent {
  color: #08110d;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 14px 28px rgba(104, 212, 149, 0.18);
}

.has-panorama .idle-anchor {
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
}

.is-busy .orb-button,
.is-busy .dock-button--accent {
  animation: breathing 1.3s ease-in-out infinite;
}

.drag-overlay {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  background:
    radial-gradient(circle at center, rgba(8, 17, 28, 0.14), rgba(3, 8, 14, 0.76)),
    rgba(7, 12, 19, 0.26);
}

.drag-panel {
  display: grid;
  place-items: center;
  width: min(36vw, 220px);
  height: min(36vw, 220px);
  min-width: 132px;
  min-height: 132px;
  border-radius: 999px;
  border: 1px dashed rgba(157, 235, 182, 0.34);
  background: rgba(10, 18, 29, 0.6);
  color: var(--accent);
  box-shadow: 0 0 0 22px rgba(157, 235, 182, 0.04);
  transform: scale(0.92);
  transition: transform 220ms ease;
  backdrop-filter: blur(18px);
}

.dragging .drag-overlay {
  opacity: 1;
}

.dragging .drag-panel {
  transform: scale(1);
}

.toast {
  position: absolute;
  top: clamp(1rem, 2vw, 1.6rem);
  left: 50%;
  z-index: 5;
  min-height: 3rem;
  max-width: min(32rem, calc(100vw - 2rem));
  padding: 0.9rem 1.1rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 201, 151, 0.24);
  background: rgba(27, 13, 5, 0.76);
  color: #ffd9b9;
  backdrop-filter: blur(18px);
  transform: translate(-50%, -1rem);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 200ms ease,
    opacity 200ms ease;
}

.toast.visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 720px) {
  .control-dock {
    top: auto;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    left: 50%;
    right: auto;
    grid-auto-flow: column;
    transform: translateX(-50%);
  }

  .orb-button {
    width: 120px;
    height: 120px;
  }
}

@media (max-width: 520px) {
  .control-dock {
    gap: 0.55rem;
    padding: 0.55rem;
  }

  .dock-button {
    width: 48px;
    height: 48px;
  }

  .button-icon {
    width: 20px;
    height: 20px;
  }
}

@keyframes breathing {
  0%,
  100% {
    box-shadow:
      var(--ring-shadow),
      0 0 0 0 rgba(157, 235, 182, 0.14);
  }

  50% {
    box-shadow:
      var(--ring-shadow),
      0 0 0 18px rgba(157, 235, 182, 0);
  }
}
