:root {
  --ink: #f3efe8;
  --ink-dim: rgba(243, 239, 232, 0.62);
  --accent: #ff7a1a;
  --night: #05070f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--night);
  color: var(--ink);
  font-family: "Barlow", ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

.stage.is-dragging { cursor: grabbing; }

.plate {
  position: fixed;
  top: max(22px, env(safe-area-inset-top, 0px) + 16px);
  left: max(22px, env(safe-area-inset-left, 0px) + 16px);
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 1.1s ease 0.15s, transform 1.1s ease 0.15s;
}

.plate.is-in { opacity: 1; transform: none; }

.plate__eyebrow {
  margin: 0 0 8px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.plate__title {
  margin: 0;
  font-family: "Barlow Condensed", "Barlow", sans-serif;
  font-weight: 800;
  font-size: clamp(44px, 7.2vw, 92px);
  line-height: 0.92;
  letter-spacing: 0.005em;
  text-transform: none;
  text-shadow: 0 2px 26px rgba(0, 0, 0, 0.55);
}

.plate__line {
  margin: 14px 0 0;
  max-width: 34ch;
  font-size: clamp(13px, 1.5vw, 15px);
  font-weight: 500;
  letter-spacing: 0.015em;
  color: var(--ink-dim);
}

.hint {
  position: fixed;
  right: max(22px, env(safe-area-inset-right, 0px) + 16px);
  bottom: max(96px, env(safe-area-inset-bottom, 0px) + 92px);
  z-index: 4;
  margin: 0;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.9s ease;
}

.hint.is-in { opacity: 0.85; }
.hint.is-out { opacity: 0; }

.walkup-controls {
  position: fixed;
  left: 50%;
  /* Standalone Labs have a persistent Lab shell at the bottom. */
  bottom: max(96px, env(safe-area-inset-bottom, 0px) + 92px);
  z-index: 5;
  display: flex;
  gap: 7px;
  transform: translateX(-50%);
}

.walkup-controls__button {
  min-width: 64px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(243, 239, 232, 0.22);
  border-radius: 999px;
  background: rgba(5, 7, 15, 0.76);
  color: var(--ink);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font: 700 12px/1 ui-monospace, "SFMono-Regular", Menlo, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 180ms ease, background-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.walkup-controls__button:hover,
.walkup-controls__button.is-active {
  border-color: rgba(255, 122, 26, 0.85);
  background: rgba(255, 122, 26, 0.18);
  color: #fff;
}

.walkup-controls__button:active { transform: scale(0.96); }

.walkup-controls__button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.veil {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-content: center;
  gap: 14px;
  background: var(--night);
  transition: opacity 0.8s ease;
}

.veil.is-done { opacity: 0; pointer-events: none; }

.veil__mark {
  margin: 0;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
  letter-spacing: 0.34em;
  color: var(--ink-dim);
  text-align: center;
}

.veil__bar {
  width: 168px;
  height: 2px;
  margin: 0 auto;
  background: rgba(243, 239, 232, 0.14);
  overflow: hidden;
}

.veil__fill {
  display: block;
  width: 30%;
  height: 100%;
  background: var(--accent);
  transition: width 0.4s ease;
}

.fallback {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 9;
  margin: 0;
  padding: 0 24px;
  text-align: center;
  color: var(--ink-dim);
}

@media (max-width: 700px), (max-height: 360px) {
  .plate__line { max-width: 26ch; }
  .hint { display: none; }

  .plate {
    top: max(18px, env(safe-area-inset-top, 0px) + 12px);
    left: max(16px, env(safe-area-inset-left, 0px) + 12px);
  }

  .plate__eyebrow { margin-bottom: 5px; font-size: 10px; }
  .plate__title { font-size: clamp(34px, 12vw, 52px); }
  .plate__line { margin-top: 8px; font-size: 12px; }

  .walkup-controls {
    gap: 5px;
  }

  .walkup-controls__button { min-width: 0; padding: 0 10px; font-size: 11px; }
}

html.lab-concept-embed .plate {
  top: max(64px, env(safe-area-inset-top, 0px) + 56px);
}

html.lab-concept-embed .walkup-controls {
  bottom: max(10px, env(safe-area-inset-bottom, 0px) + 8px);
}

/* The reader supplies its own persistent return control. Keep the scene's
   identity visible without competing with that control or the small viewport. */
@media (max-width: 700px) and (max-height: 520px), (max-height: 360px) {
  html.lab-concept-embed .lab-build-disclosure { display: none; }

  html.lab-concept-embed .plate {
    top: max(64px, env(safe-area-inset-top, 0px) + 56px);
  }

  html.lab-concept-embed .plate__eyebrow,
  html.lab-concept-embed .plate__line { display: none; }

  html.lab-concept-embed .plate__title { font-size: clamp(28px, 10vw, 38px); }
}

@media (prefers-reduced-motion: reduce) {
  .walkup-controls__button { transition-duration: 0.01ms; }
}
