:root {
  color-scheme: dark;
  --bg: #0c0d14;
  --panel: rgba(18, 20, 32, 0.92);
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8e9ef;
  --muted: #8b8fa3;
  --accent: #ff6b1a;
  --accent-hover: #ff8137;
  --accent-soft: rgba(255, 107, 26, 0.16);
  --accent-soft-hover: rgba(255, 107, 26, 0.28);
  --accent-border: rgba(255, 107, 26, 0.35);
  --danger: #f07178;
  --ok: #7ee787;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

body.app {
  position: relative;
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
}

aside.panel {
  position: absolute;
  top: 16px;
  left: 16px;
  /* Above mobile-touch-layer (50) so panel buttons remain tappable on phones. */
  z-index: 60;
  width: 188px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: rgba(10, 10, 10, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  font-family: "Segoe UI", system-ui, sans-serif;
}

@media (max-width: 640px) {
  aside.panel {
    top: 10px;
    left: 10px;
    width: 168px;
    padding: 10px;
  }
}

/* Scene loader: covers the canvas until the splat is fully ready.
   z-index sits above canvas (0) but below vinvr-chrome (40) and panel (60)
   so the brand cards and panel actions stay visible while loading. */
.scene-loader {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: #0a0a0a;
  color: rgba(255, 255, 255, 0.65);
  font-family: "Segoe UI", system-ui, sans-serif;
  transition: opacity 0.4s ease, visibility 0s linear 0s;
}

.scene-loader.is-hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0s linear 0.4s;
}

.scene-loader-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid rgba(255, 107, 26, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: scene-loader-spin 0.9s linear infinite;
}

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

.scene-loader-text {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.scene-loader-pct {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.4);
  font-variant-numeric: tabular-nums;
  min-height: 1em;
}

body[data-launcher-active] .scene-loader { display: none; }

/* Phone-only "Move / Look" onboarding hint — shows for 5s on first Ready. */
.touch-onboard {
  position: absolute;
  inset: 0;
  z-index: 55; /* below jump button (60) + panel (60), above touch zones (50) */
  display: none;
  pointer-events: none; /* let movement / look touches pass through */
  font-family: "Segoe UI", system-ui, sans-serif;
  color: rgba(255, 255, 255, 0.92);
  user-select: none;
  -webkit-user-select: none;
}

.touch-onboard.is-visible {
  display: flex;
  animation: touch-onboard-fade-in 0.35s ease-out, touch-onboard-fade-out 0.6s ease-in 4.4s forwards;
}

@keyframes touch-onboard-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes touch-onboard-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

.touch-onboard-half {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px 18px;
  text-align: center;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.touch-onboard-half--move {
  border-right: 1px solid rgba(255, 255, 255, 0.18);
}

.touch-onboard-icon {
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.92);
  animation: touch-onboard-pulse 1.6s ease-in-out infinite;
}

.touch-onboard-half--look .touch-onboard-icon {
  animation-delay: 0.4s;
}

@keyframes touch-onboard-pulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(255, 107, 26, 0)); }
  50%      { transform: scale(1.08); filter: drop-shadow(0 0 12px rgba(255, 107, 26, 0.5)); }
}

.touch-onboard-label {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.touch-onboard-sub {
  font-size: 12px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.72);
  max-width: 14ch;
  line-height: 1.35;
}

body[data-launcher-active] .touch-onboard { display: none !important; }

/* Segmented quality switcher (replaces stacked radio-col) */
.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 3px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.seg-item {
  position: relative;
  margin: 0;
  padding: 0.4rem 0.25rem;
  border-radius: 6px;
  text-align: center;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.seg-item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.seg-item span {
  display: block;
  white-space: nowrap;
}

.seg-item:hover:not(:has(input:checked)) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.seg-item:has(input:checked) {
  color: var(--text);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-border);
  font-weight: 600;
}

.seg-item input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.action-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

button.ghost.compact {
  padding: 0.45rem 0.6rem;
  font-size: 0.75rem;
  border-radius: 6px;
  text-align: center;
  width: 100%;
}

/* On-brand "Choose world" CTA */
.brand-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: #ffd9bf;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.05s ease;
}

.brand-cta:hover {
  background: var(--accent-soft-hover);
  border-color: rgba(255, 107, 26, 0.6);
  color: #fff;
}

.brand-cta:active { transform: translateY(1px); }
.brand-cta svg { flex-shrink: 0; }

h1 {
  font-size: 0.98rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
  letter-spacing: -0.02em;
}

.sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 1.25rem;
  line-height: 1.45;
}

.sub a {
  color: var(--accent);
}

label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0.75rem 0 0.35rem;
}

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 0.85rem;
}

textarea {
  min-height: 3.25rem;
  resize: vertical;
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
}

.row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.75rem;
}

button.primary {
  flex: 1;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: none;
  background: linear-gradient(180deg, #5b8fd9, #447bca);
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

button.primary:hover {
  filter: brightness(1.05);
}

button.ghost {
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
}

button.ghost:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.status {
  margin-top: 0;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.4);
  font-size: 0.74rem;
  line-height: 1.4;
  color: var(--muted);
}

.status .state {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.status strong {
  color: var(--text);
}

.status.ok .state {
  color: var(--ok);
}

.status.err .state {
  color: var(--danger);
}

#viewport {
  position: absolute;
  inset: 0;
  min-height: 320px;
}

#viewport canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  outline: none;
  position: relative;
  z-index: 0;
}

.overlay-hint {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 2;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 0.75rem;
  color: var(--muted);
  pointer-events: none;
}

.launcher {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(48px, 12vh, 120px) 24px clamp(96px, 14vh, 128px);
  overflow: auto;
  background: var(--bg);
  color: var(--text);
}

.launcher-head {
  width: 100%;
  max-width: 480px;
  margin: 0 0 20px;
}

.launcher h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.launcher ul {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.launcher button.world {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.launcher button.world:hover,
.launcher button.world:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
  outline: none;
}

.launcher .name {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

.launcher .err {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 16px 0 0;
}

.launcher-footer {
  position: absolute;
  left: 50%;
  bottom: clamp(20px, 4vh, 32px);
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.launcher-footer:hover,
.launcher-footer:focus-visible {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.05);
  outline: none;
}

.launcher-footer .powered {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.65rem;
}

.launcher-footer .brand {
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.launcher-footer img {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.panel-section {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 1.25rem 0 0.35rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  letter-spacing: -0.02em;
}

.muted-inline {
  font-size: 0.75rem;
  color: var(--muted);
  min-width: 2.5rem;
  text-align: right;
}

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

.measure-readout {
  margin-top: 0.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
}

.panel-details {
  margin-top: 0.65rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--border);
}

.panel-details summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.panel-details summary::-webkit-details-marker {
  display: none;
}

.panel-details summary::before {
  content: "▸";
  font-size: 0.65rem;
  color: var(--muted);
  transition: transform 0.12s ease;
}

.panel-details[open] summary::before {
  transform: rotate(90deg);
}

.panel-details .sub {
  margin-bottom: 0.5rem;
}

.labelish {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0.65rem 0 0.35rem;
}

.radio-col {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.radio-col label {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  margin: 0;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.8rem;
  cursor: pointer;
}

.radio-col input {
  margin-top: 0.2rem;
}

select {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 0.85rem;
}

.guide-list {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.55;
}

.guide-list strong {
  color: var(--text);
}

input[type="number"] {
  font-family: ui-monospace, monospace;
}

body[data-fake-fs] aside.panel,
body[data-launcher-active] aside.panel {
  display: none;
}

body[data-fake-fs] aside.panel {
  display: none;
}

body[data-fake-fs] #viewport {
  position: fixed;
  inset: 0;
  z-index: 9999;
  width: 100vw;
  height: 100vh;
  background: var(--bg);
}

.dev-overlay {
  position: fixed;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 10000;
  display: none;
  min-width: 240px;
  max-width: 320px;
  padding: 0.55rem 0.7rem 0.65rem;
  background: rgba(8, 9, 14, 0.82);
  border: 1px solid rgba(110, 168, 255, 0.35);
  border-radius: 6px;
  color: #d8dbe6;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.35;
  pointer-events: none;
  backdrop-filter: blur(4px);
}

.dev-overlay.active {
  display: block;
}

.dev-overlay-title {
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.dev-overlay-keys {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.55rem;
  row-gap: 0.18rem;
}

.dev-overlay-keys li {
  display: contents;
}

.dev-overlay-keys kbd {
  font-family: inherit;
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  padding: 0 0.32rem;
  color: #e8e9ef;
  white-space: nowrap;
}

.dev-overlay-keys span {
  color: var(--muted);
}

.dev-overlay-control {
  margin-top: 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  /* Overlay root has pointer-events: none so the world stays clickable; slider must capture input. */
  pointer-events: auto;
}
.dev-overlay-control * {
  pointer-events: auto;
}
.dev-overlay-control-label {
  font-size: 0.66rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.dev-overlay-control-value {
  color: #fff;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}
.dev-overlay-control-range {
  width: 100%;
  accent-color: #4da3ff;
}

.dev-overlay-note {
  margin-top: 0.45rem;
  font-size: 0.62rem;
  color: var(--muted);
  opacity: 0.7;
  font-style: italic;
}

.dev-overlay-status {
  margin-top: 0.45rem;
  min-height: 1em;
  font-size: 0.7rem;
  color: var(--muted);
}

.dev-overlay-status.ok {
  color: var(--ok);
}

.dev-overlay-status.err {
  color: var(--danger);
}

/* —— Phone: half-screen move + drag-look overlay —— */
.mobile-touch-layer {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  display: none;
  user-select: none;
  -webkit-user-select: none;
}

.mobile-touch-layer.mobile-touch-layer--visible {
  display: block;
}

.touch-zone {
  position: absolute;
  top: 0;
  height: 100%;
  pointer-events: auto;
  touch-action: none;
}

.touch-zone--move {
  left: 0;
  width: 50%;
}

.touch-zone--look {
  left: 50%;
  width: 50%;
}

.mobile-touch-jump {
  position: absolute;
  bottom: max(0.85rem, env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  pointer-events: auto;
  touch-action: manipulation;
  padding: 0.45rem 0.95rem;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid rgba(130, 178, 255, 0.45);
  background: rgba(10, 14, 26, 0.55);
  color: #e8ecff;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* —— VinVR chrome: top-right CTA + bottom-right Live Demo card (always visible) —— */
.vinvr-chrome {
  --vinvr-accent: #ff6b1a;
  --vinvr-accent-hover: #ff8137;
  --vinvr-panel: rgba(10, 10, 10, 0.78);
  --vinvr-panel-border: rgba(255, 255, 255, 0.08);
  --vinvr-text: #f5f5f5;
  --vinvr-muted: #b8b8b8;
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  font-family: "Segoe UI", system-ui, sans-serif;
}

.vinvr-cta-row {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.vinvr-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.05s ease;
  font-family: inherit;
}
.vinvr-btn:active { transform: translateY(1px); }

.vinvr-btn-primary {
  background: var(--vinvr-accent);
  color: #0a0a0a;
}
.vinvr-btn-primary:hover { background: var(--vinvr-accent-hover); }

.vinvr-btn-ghost {
  background: var(--vinvr-panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--vinvr-text);
  border-color: var(--vinvr-panel-border);
}
.vinvr-btn-ghost:hover { border-color: rgba(255, 255, 255, 0.22); }

.vinvr-card {
  position: absolute;
  right: 24px;
  bottom: 24px;
  max-width: 420px;
  background: var(--vinvr-panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--vinvr-panel-border);
  border-radius: 14px;
  padding: 18px 20px;
  pointer-events: auto;
  color: var(--vinvr-text);
}
.vinvr-card-eyebrow {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--vinvr-accent);
  font-weight: 700;
  margin-bottom: 8px;
}
.vinvr-card-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 6px;
}
.vinvr-card-sub {
  font-size: 13px;
  color: var(--vinvr-muted);
  line-height: 1.5;
  margin: 0 0 14px;
}
.vinvr-controls-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  font-size: 11px;
  color: var(--vinvr-muted);
  letter-spacing: 0.04em;
}
.vinvr-controls-hint > span { display: inline-flex; align-items: center; gap: 3px; }
.vinvr-kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px;
  color: var(--vinvr-text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 4px;
}

/* Phone / short viewports — hide the top CTA, shrink the card so it doesn't dominate the touch zones */
@media (max-width: 640px), (max-height: 500px) {
  .vinvr-cta-row { display: none; }
  .vinvr-card {
    right: 12px;
    bottom: 12px;
    max-width: 240px;
    padding: 10px 12px;
  }
  .vinvr-card-title { font-size: 13px; }
  .vinvr-card-sub { font-size: 11px; margin-bottom: 8px; }
  .vinvr-controls-hint { display: none; }
}

