/* Spatial Recon — Celestial Synergy Terminal (aligned with openstrate-viewport / Stitch) */
:root {
  --osn-surface-lowest: #0a0a0c;
  --osn-surface-container-low: #1b1b20;
  --osn-surface-container-high: #2a292f;
  --osn-primary: #00f0ff;
  --osn-primary-soft: #dbfcff;
  --osn-primary-container: #00c8dc;
  --osn-on-primary-container: #0e0e13;
  --osn-secondary-soft: #d1bcff;
  --osn-synergy-magenta: #ff00ff;
  --osn-on-surface: #e4e1e9;
  --osn-on-surface-muted: #9a99a3;
  --osn-outline-variant: rgba(219, 252, 255, 0.14);
  --osn-crystalline-edge: linear-gradient(135deg, rgba(0, 240, 255, 0.4) 0%, rgba(255, 0, 255, 0.4) 100%);
  --osn-glass-blur: blur(20px) saturate(180%);
  --osn-synergy-gradient: linear-gradient(135deg, var(--osn-primary) 0%, var(--osn-synergy-magenta) 38%, var(--osn-primary-container) 100%);
  --osn-celestial-bg:
    radial-gradient(ellipse 120% 80% at 8% 12%, rgba(85, 48, 163, 0.14) 0%, transparent 55%),
    radial-gradient(ellipse 90% 70% at 92% 88%, rgba(0, 240, 255, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse 70% 50% at 50% -5%, rgba(219, 252, 255, 0.04) 0%, transparent 45%),
    var(--osn-surface-lowest);
  --osn-synergy-panel-glow:
    0 0 0 1px rgba(0, 240, 255, 0.08),
    0 0 56px rgba(85, 48, 163, 0.12),
    0 0 36px rgba(0, 240, 255, 0.05);
  --osn-font-mono: 'Space Mono', 'JetBrains Mono', ui-monospace, monospace;
  --osn-font-display: 'Space Grotesk', system-ui, sans-serif;
  --osn-radius: 0px;

  /* Legacy aliases used in older rules */
  --bg: var(--osn-surface-lowest);
  --surface: var(--osn-surface-container-low);
  --border: var(--osn-outline-variant);
  --accent: var(--osn-primary-container);
  --accent-dim: rgba(0, 240, 255, 0.12);
  --text: var(--osn-on-surface);
  --text-subtle: var(--osn-on-surface-muted);
  --mono: var(--osn-font-mono);
  --sans: var(--osn-font-display);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Crawlable / screen-reader intro (SEO + a11y); keeps layout unchanged */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

#osn-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(0, 240, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}

body {
  background: var(--osn-celestial-bg);
  color: var(--osn-primary-soft);
  font-family: var(--osn-font-mono);
  font-size: 13px;
  min-height: 100vh;
}

body.mode-landing {
  display: flex;
  align-items: center;
  justify-content: center;
}

body.mode-viewer {
  overflow: hidden;
  height: 100vh;
}

#app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
  padding: 40px;
  max-width: 520px;
  width: 100%;
}

.admin-upload-badge {
  align-self: stretch;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: rgba(0, 240, 255, 0.92);
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.28);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-upload-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: rgba(180, 180, 180, 0.35);
  box-shadow: none;
  transition: background 180ms ease, box-shadow 180ms ease;
}

.admin-upload-dot.ok {
  background: #1aff7a;
  box-shadow: 0 0 6px rgba(26, 255, 122, 0.8);
}

.admin-upload-dot.down {
  background: #ff4d4d;
  box-shadow: 0 0 4px rgba(255, 77, 77, 0.6);
}

.admin-upload-badge a {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.admin-upload-badge a:hover {
  color: rgba(0, 240, 255, 1);
}

/* Deep link target + scroll anchor for #scan / #capture (dropzone + SCAN).
 * Soft glassy backdrop so the capture flow reads as a defined area against
 * the dark page bg. Intensity stays well below #scan-settings' prismatic
 * border so the inner card still owns the visual focus. */
.landing-capture-anchor {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
  border-radius: 18px;
  background:
    radial-gradient(120% 100% at 50% 0%,
      rgba(120, 200, 255, 0.07) 0%,
      rgba(140, 100, 220, 0.05) 35%,
      rgba(255, 255, 255, 0.02) 70%,
      transparent 100%),
    linear-gradient(180deg,
      rgba(255, 255, 255, 0.035) 0%,
      rgba(255, 255, 255, 0.015) 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 16px 44px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(3px) saturate(1.1);
  -webkit-backdrop-filter: blur(3px) saturate(1.1);
}

#logo {
  position: relative;
  /* Width bumped 280→420 for the inline "openstrate αlpha" wordmark.
   * New aspect is ~8.5:1; at 280px the logo would render only ~33px
   * tall, 420 gives ~50px which keeps visual presence in the hero. */
  width: 420px;
  max-width: 100%;
  user-select: none;
  animation: osn-logo-glow 18s ease-in-out infinite;
}

@keyframes osn-logo-glow {
  0%, 100% {
    filter:
      drop-shadow(0 0 18px rgba(58, 85, 196, 0.32))
      drop-shadow(0 0 44px rgba(110, 69, 189, 0.18));
  }
  50% {
    filter:
      drop-shadow(0 0 26px rgba(201, 58, 140, 0.36))
      drop-shadow(0 0 60px rgba(201, 58, 140, 0.18));
  }
}

@media (prefers-reduced-motion: reduce) {
  #logo { animation: none; filter: drop-shadow(0 0 20px rgba(110, 69, 189, 0.25)); }
}

#logo .landing-logo-text {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible; /* Let the SVG inner glow halo extend past the viewBox edge. */
}

#logo .landing-logo-link {
  cursor: pointer;
}

#logo .landing-logo-link:focus {
  outline: none;
}

#logo .landing-logo-link:focus-visible {
  outline: 2px solid rgba(0, 240, 255, 0.55);
  outline-offset: 6px;
  border-radius: 2px;
}

/* Drop zone — refractive energy frame */
#dropzone {
  position: relative;
  width: 100%;
  min-height: 180px;
  background: rgba(0, 0, 0, 0.2);
  border: 2px dashed rgba(0, 240, 255, 0.25);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

#dropzone:hover,
#dropzone.dragover {
  border-color: rgba(0, 240, 255, 0.5);
  background: rgba(0, 240, 255, 0.03);
  box-shadow:
    inset 0 0 60px rgba(0, 240, 255, 0.04),
    inset 0 0 30px rgba(120, 0, 255, 0.03),
    0 0 20px rgba(0, 240, 255, 0.1);
  transform: translateY(-1px);
}

#dropzone-content {
  text-align: center;
  pointer-events: none;
}

/* Collapsed dropzone: just the Upload button is visible, no dashed frame.
 * Expanded (default) behaviour matches the rules above. */
#dropzone.dropzone-collapsed {
  min-height: auto;
  background: transparent;
  border: none;
  cursor: default;
}
#dropzone.dropzone-collapsed:hover {
  background: transparent;
  border: none;
  box-shadow: none;
  transform: none;
}
#dropzone.dropzone-collapsed #dropzone-content,
#dropzone.dropzone-collapsed #file-input {
  display: none;
}
#dropzone:not(.dropzone-collapsed) #dropzone-upload-btn {
  display: none;
}

/* Upload button — same brand vocabulary as #scan-btn but a hair quieter
 * since this is a precursor to SCAN, not the primary action. */
#dropzone-upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px 24px;
  font-family: var(--osn-font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: linear-gradient(135deg,
    rgba(0, 240, 255, 0.10) 0%,
    rgba(120, 0, 255, 0.06) 50%,
    rgba(255, 0, 180, 0.05) 100%);
  color: #fff;
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.45);
  border: 1px solid rgba(0, 240, 255, 0.28);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow:
    0 0 14px rgba(0, 240, 255, 0.08),
    0 0 28px rgba(120, 0, 255, 0.04);
}
#dropzone-upload-btn:hover {
  background: linear-gradient(135deg,
    rgba(0, 240, 255, 0.18) 0%,
    rgba(120, 0, 255, 0.12) 50%,
    rgba(255, 0, 180, 0.08) 100%);
  border-color: rgba(0, 240, 255, 0.5);
  box-shadow:
    0 0 22px rgba(0, 240, 255, 0.18),
    0 0 44px rgba(120, 0, 255, 0.08);
  transform: translateY(-1px);
}
#dropzone-upload-btn:active {
  transform: scale(0.98) translateY(0);
}

#dropzone-content p:first-of-type {
  font-family: var(--osn-font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--osn-primary-soft);
}

#drop-icon {
  font-size: 48px;
  color: var(--osn-on-surface-muted);
  margin-bottom: 12px;
  line-height: 1;
}

#dropzone-content p {
  color: var(--osn-on-surface-muted);
  font-size: 13px;
  margin: 4px 0;
}

.filetypes {
  font-family: var(--osn-font-mono) !important;
  font-size: 11px !important;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--osn-primary) !important;
  margin-top: 14px !important;
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.35);
}

#file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ── Scan Settings: Celestial Synergy Terminal — Refractive Energy ── */
#scan-settings {
  margin-top: 0;
  padding: 18px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  background:
    linear-gradient(135deg,
      rgba(0, 240, 255, 0.06) 0%,
      rgba(120, 0, 255, 0.04) 40%,
      rgba(255, 0, 180, 0.03) 70%,
      rgba(0, 240, 255, 0.05) 100%);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 12px;
  overflow: visible;
  box-shadow:
    0 0 30px rgba(0, 240, 255, 0.08),
    0 0 60px rgba(120, 0, 255, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 rgba(0, 240, 255, 0.05);
}
/* Animated prismatic border shimmer */
#scan-settings::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 13px;
  background: linear-gradient(
    var(--prism-angle, 0deg),
    rgba(0, 240, 255, 0.3),
    rgba(120, 0, 255, 0.2),
    rgba(255, 0, 180, 0.2),
    rgba(0, 240, 255, 0.3)
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 1px;
  pointer-events: none;
  animation: prismRotate 4s linear infinite;
}
@keyframes prismRotate {
  to { --prism-angle: 360deg; }
}
@property --prism-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}
/* Terminal header */
#scan-settings .scan-terminal-header {
  font-family: var(--osn-font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 4px;
  background: linear-gradient(90deg, #00f0ff, #a855f7, #ff0090, #00f0ff);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: headerShimmer 3s ease-in-out infinite;
}
@keyframes headerShimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
#scan-settings .scan-terminal-header::before,
#scan-settings .scan-terminal-header::after {
  content: '';
  display: inline-block;
  width: 24px;
  height: 1px;
  vertical-align: middle;
  margin: 0 10px;
}
#scan-settings .scan-terminal-header::before {
  background: linear-gradient(90deg, transparent, rgba(0, 240, 255, 0.5), rgba(168, 85, 247, 0.3));
}
#scan-settings .scan-terminal-header::after {
  background: linear-gradient(90deg, rgba(168, 85, 247, 0.3), rgba(255, 0, 144, 0.4), transparent);
}
.scan-setting-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.scan-setting-row--calibrate {
  align-items: stretch;
  margin-top: 2px;
}
.scan-settings-calibrate-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.scan-settings-calibrate-wrap #calibrate-btn {
  flex: 1;
  min-width: 0;
  width: auto;
  padding: 10px 14px;
  font-size: 11px;
  letter-spacing: 0.12em;
}
.scan-qr-png-link {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 10px 12px;
  font-family: var(--osn-font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: rgba(0, 240, 255, 0.85);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(0, 240, 255, 0.22);
  border-radius: 8px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.scan-qr-png-link:hover {
  color: #fff;
  border-color: rgba(0, 240, 255, 0.45);
  background: rgba(0, 240, 255, 0.08);
}
.scan-setting-label {
  font-family: var(--osn-font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(0, 240, 255, 0.5);
  min-width: 42px;
  text-align: right;
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.2);
}
.scan-pills {
  display: flex;
  gap: 3px;
  flex: 1;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 3px;
  backdrop-filter: blur(4px);
  position: relative;
  isolation: isolate;
}
/* Liquid indicator — a single blob that morphs between active pills.
 * Sits behind the pill text via z-index, sized to one pill (50% minus
 * half the inter-pill gap), translated into position based on which
 * pill carries .active. Bouncy easing + idle blur breathing gives the
 * "flowing liquid" feel; :has() drives the position so the CSS stays
 * declarative (no JS coupling). */
.scan-pills::before {
  content: '';
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc(50% - 4.5px);
  border-radius: 6px;
  background: linear-gradient(135deg,
    rgba(0, 240, 255, 0.22) 0%,
    rgba(120, 0, 255, 0.18) 50%,
    rgba(255, 0, 180, 0.14) 100%);
  box-shadow:
    0 0 16px rgba(0, 240, 255, 0.22),
    0 0 32px rgba(120, 0, 255, 0.10),
    inset 0 0 14px rgba(120, 0, 255, 0.08),
    inset 0 0 0 1px rgba(0, 240, 255, 0.32);
  z-index: 0;
  pointer-events: none;
  transform: translateX(0);
  transition:
    transform 0.65s cubic-bezier(0.65, 0, 0.15, 1.18),
    width 0.65s cubic-bezier(0.65, 0, 0.15, 1.18);
  animation: liquid-breathe 4.2s ease-in-out infinite;
  opacity: 1;
}
/* Breathing: subtle blur + brightness pulse so the blob feels alive
 * even when stationary. Doubles as a soft squish-and-settle texture
 * during transit. */
@keyframes liquid-breathe {
  0%, 100% { filter: blur(0px) brightness(1); }
  50%      { filter: blur(0.6px) brightness(1.10); }
}
/* Three-pill row (Scene): the blob is one-third wide. */
.scan-pills:has(> .scan-pill:nth-child(3))::before {
  width: calc((100% - 6px - 6px) / 3);
}
/* No active pill yet: hide the blob so the row reads as "no choice made". */
.scan-pills:not(:has(> .scan-pill.active))::before { opacity: 0; }
/* Position the blob to match whichever pill is .active. */
.scan-pills:has(> .scan-pill:nth-child(1).active)::before { transform: translateX(0); }
.scan-pills:has(> .scan-pill:nth-child(2).active)::before { transform: translateX(calc(100% + 3px)); }
.scan-pills:has(> .scan-pill:nth-child(3).active)::before { transform: translateX(calc(200% + 6px)); }

@media (prefers-reduced-motion: reduce) {
  .scan-pills::before { animation: none; transition: transform 0.2s linear; }
}

.scan-pill {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  font-family: var(--osn-font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.4);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition:
    color 0.35s ease,
    text-shadow 0.35s ease,
    transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 1; /* above the liquid blob */
  overflow: hidden;
}
.scan-pill:hover {
  color: rgba(255, 255, 255, 0.85);
  transform: translateY(-1px);
}
/* Active pill: just emphasize text/icon — the blob owns the box. */
.scan-pill.active {
  color: #fff;
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}
.scan-pill svg {
  opacity: 0.4;
  flex-shrink: 0;
  transition: all 0.25s;
  width: 15px;
  height: 15px;
}
.scan-pill:hover svg { opacity: 0.7; }
.scan-pill.active svg {
  opacity: 1;
  stroke: #00f0ff;
  filter: drop-shadow(0 0 5px rgba(0, 240, 255, 0.6));
}

/* ── Capture Area: Refractive Energy Panel ── */
#capture-area {
  overflow: hidden;
  margin-top: 14px;
  padding: 16px;
  background:
    linear-gradient(160deg,
      rgba(0, 240, 255, 0.04) 0%,
      rgba(120, 0, 255, 0.03) 50%,
      rgba(255, 0, 180, 0.02) 100%);
  backdrop-filter: blur(10px) saturate(1.3);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  border: 1px solid rgba(0, 240, 255, 0.15);
  border-radius: 12px;
  position: relative;
  box-shadow:
    0 0 24px rgba(0, 240, 255, 0.06),
    0 0 48px rgba(120, 0, 255, 0.03),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: opacity 0.3s ease;
}
#capture-area.show {
  display: block !important;
  animation: captureReveal 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes captureReveal {
  from { opacity: 0; transform: translateY(-10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
/* Prismatic edge — matches scan-settings */
#capture-area::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 13px;
  background: linear-gradient(
    var(--prism-angle, 0deg),
    rgba(0, 240, 255, 0.2),
    rgba(120, 0, 255, 0.15),
    rgba(255, 0, 180, 0.15),
    rgba(0, 240, 255, 0.2)
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 1px;
  pointer-events: none;
  animation: prismRotate 4s linear infinite;
}

/* Scan button row (calibrate lives in #scan-settings) */
.capture-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

/* Scan button — energetic gradient */
#scan-btn,
#calibrate-btn {
  display: block;
  width: 100%;
  margin-top: 0;
  padding: 15px 24px;
  font-family: var(--osn-font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: linear-gradient(135deg,
    rgba(0, 240, 255, 0.12) 0%,
    rgba(120, 0, 255, 0.08) 50%,
    rgba(255, 0, 180, 0.06) 100%);
  color: #fff;
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.5);
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  box-shadow:
    0 0 16px rgba(0, 240, 255, 0.1),
    0 0 32px rgba(120, 0, 255, 0.05);
}
/* Shine sweep — scan button only; calibration button stays static */
#scan-btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0, 240, 255, 0.2) 30%,
    rgba(255, 255, 255, 0.3) 50%,
    rgba(168, 85, 247, 0.2) 70%,
    transparent 100%
  );
  animation: scan-shine 2.2s ease-in-out infinite;
}
@keyframes scan-shine {
  0% { left: -100%; }
  100% { left: 200%; }
}
#scan-btn:hover,
#calibrate-btn:hover {
  background: linear-gradient(135deg,
    rgba(0, 240, 255, 0.2) 0%,
    rgba(120, 0, 255, 0.14) 50%,
    rgba(255, 0, 180, 0.1) 100%);
  border-color: rgba(0, 240, 255, 0.5);
  box-shadow:
    0 0 24px rgba(0, 240, 255, 0.2),
    0 0 48px rgba(120, 0, 255, 0.08);
  transform: translateY(-1px);
}
#scan-btn:active,
#calibrate-btn:active {
  transform: scale(0.98) translateY(0);
}

/* Scan toast warning */
.scan-toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9002;
  font-family: var(--osn-font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  padding: 8px 16px;
  background: rgba(14, 14, 19, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 180, 60, 0.3);
  color: #ffb43c;
  white-space: nowrap;
  transition: opacity 0.3s;
  text-shadow: 0 0 6px rgba(255, 180, 60, 0.3);
}
.scan-toast.hidden { opacity: 0; pointer-events: none; }
.scan-toast.error { border-color: rgba(255, 68, 68, 0.4); color: #ff4444; text-shadow: 0 0 6px rgba(255,68,68,0.3); }

/* ── Scan / calibrate camera overlay — Refracted Terminal ─────────── */
#scan-overlay,
#calibrate-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: #020205;
}
#scan-overlay.hidden,
#calibrate-overlay.hidden { display: none; }

#scan-preview,
#calibrate-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#calibrate-capture-canvas {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 4px;
  height: 4px;
  opacity: 0;
  pointer-events: none;
}

#calibrate-scanline {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(to bottom, transparent 50%, rgba(110, 69, 189, 0.04) 51%);
  background-size: 100% 4px;
  pointer-events: none;
}

/* ── Calibration overlay: refractive-glass surfaces ──
 * Each text/button surface is its own glassmorphic chip so contrast stays
 * legible regardless of what the camera sees (dark room → white cardboard).
 * Vocabulary mirrors #scan-settings: dark underlay → brand-tinted linear
 * gradient → 16px backdrop-blur saturate(1.5) → 1px cyan border → animated
 * prismatic ring via ::before. */
#calibrate-topbar {
  position: fixed;
  top: max(12px, env(safe-area-inset-top, 12px));
  left: 12px;
  right: 12px;
  z-index: 9001;
  min-height: 0;
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 12px;
  background:
    linear-gradient(135deg,
      rgba(0, 240, 255, 0.10) 0%,
      rgba(120, 0, 255, 0.07) 50%,
      rgba(255, 0, 180, 0.05) 100%),
    rgba(14, 14, 19, 0.58);
  backdrop-filter: blur(16px) saturate(1.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  border: 1px solid rgba(0, 240, 255, 0.28);
  box-shadow:
    0 0 22px rgba(0, 240, 255, 0.10),
    0 0 44px rgba(120, 0, 255, 0.05),
    0 6px 24px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.10),
    inset 0 -1px 0 rgba(0, 240, 255, 0.05);
}
#calibrate-topbar::before,
#calibrate-hint::before,
.calibrate-show-qr-btn::before,
#calibrate-cancel-btn::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(
    var(--prism-angle, 0deg),
    rgba(0, 240, 255, 0.30),
    rgba(120, 0, 255, 0.20),
    rgba(255, 0, 180, 0.20),
    rgba(0, 240, 255, 0.30)
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 1px;
  pointer-events: none;
  animation: prismRotate 4s linear infinite;
}

#calibrate-status {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-family: var(--osn-font-mono);
  position: relative;
  z-index: 1;
}

#calibrate-dot {
  width: 8px;
  height: 8px;
  background: #00f0ff;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
  animation: calib-dot-pulse 1.4s ease-in-out infinite;
}
@keyframes calib-dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

#calibrate-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: #00f0ff;
  /* Text-shadow halo + cyan glow: halo guarantees legibility even if the
   * glass card somehow loses its tint; cyan glow keeps the brand feel. */
  text-shadow:
    0 0 6px rgba(0, 240, 255, 0.5),
    0 1px 2px rgba(0, 0, 0, 0.85),
    0 0 4px rgba(0, 0, 0, 0.7);
}

#calibrate-edge-readout {
  font-size: 11px;
  color: #fff;
  letter-spacing: 0.06em;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.9),
    0 0 4px rgba(0, 0, 0, 0.7);
}

#calibrate-controls {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom, 20px));
  left: 12px;
  right: 12px;
  z-index: 9001;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

#calibrate-hint {
  position: relative;
  font-family: var(--osn-font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  line-height: 1.5;
  text-align: center;
  color: #fff;
  max-width: 360px;
  padding: 10px 16px;
  border-radius: 12px;
  background:
    linear-gradient(135deg,
      rgba(0, 240, 255, 0.08) 0%,
      rgba(120, 0, 255, 0.06) 50%,
      rgba(255, 0, 180, 0.04) 100%),
    rgba(14, 14, 19, 0.58);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid rgba(0, 240, 255, 0.22);
  box-shadow:
    0 0 18px rgba(0, 240, 255, 0.08),
    0 4px 18px rgba(0, 0, 0, 0.30),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.85),
    0 0 4px rgba(0, 0, 0, 0.7);
}

.calibrate-controls-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.calibrate-show-qr-btn {
  position: relative;
  font-family: var(--osn-font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 12px 24px;
  border-radius: 10px;
  color: #fff;
  background:
    linear-gradient(135deg,
      rgba(0, 240, 255, 0.20) 0%,
      rgba(120, 0, 255, 0.14) 50%,
      rgba(255, 0, 180, 0.10) 100%),
    rgba(14, 14, 19, 0.50);
  border: 1px solid rgba(0, 240, 255, 0.45);
  cursor: pointer;
  backdrop-filter: blur(16px) saturate(1.6);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-block;
  box-sizing: border-box;
  text-shadow:
    0 0 8px rgba(0, 240, 255, 0.4),
    0 1px 2px rgba(0, 0, 0, 0.85);
  box-shadow:
    0 0 16px rgba(0, 240, 255, 0.14),
    0 4px 20px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.calibrate-show-qr-btn:hover {
  color: #fff;
  border-color: rgba(0, 240, 255, 0.6);
  background:
    linear-gradient(135deg,
      rgba(0, 240, 255, 0.30) 0%,
      rgba(120, 0, 255, 0.20) 50%,
      rgba(255, 0, 180, 0.14) 100%),
    rgba(14, 14, 19, 0.50);
  box-shadow:
    0 0 24px rgba(0, 240, 255, 0.22),
    0 6px 26px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
}

#calibrate-cancel-btn {
  position: relative;
  font-family: var(--osn-font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 12px 24px;
  border-radius: 10px;
  color: #fff;
  background: rgba(14, 14, 19, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.20);
  cursor: pointer;
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.9),
    0 0 4px rgba(0, 0, 0, 0.7);
  box-shadow:
    0 4px 18px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
#calibrate-cancel-btn:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(14, 14, 19, 0.78);
  box-shadow:
    0 6px 22px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

/* Animated scanline effect over camera feed */
#scan-scanline {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(to bottom, transparent 50%, rgba(0, 240, 255, 0.03) 51%);
  background-size: 100% 4px;
  pointer-events: none;
}

/* ── Scan overlay: celestial refracted glass ───────────────────────────
 * Mirrors the vocabulary of #scan-settings: brand-tinted gradient underlay,
 * 12-16px backdrop-blur saturate(1.4-1.5), 1px cyan border, animated
 * prismatic ::before ring. Each surface is its own glass chip so contrast
 * stays legible against the live camera feed. */
.scan-glass {
  position: relative;
  background:
    linear-gradient(135deg,
      rgba(0, 240, 255, 0.08) 0%,
      rgba(120, 0, 255, 0.05) 40%,
      rgba(255, 0, 180, 0.04) 70%,
      rgba(0, 240, 255, 0.06) 100%),
    rgba(8, 10, 16, 0.55);
  backdrop-filter: blur(14px) saturate(1.5);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  border: 1px solid rgba(0, 240, 255, 0.22);
  border-radius: 12px;
  box-shadow:
    0 0 30px rgba(0, 240, 255, 0.08),
    0 0 60px rgba(120, 0, 255, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 rgba(0, 240, 255, 0.05);
}
.scan-glass::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 13px;
  background: linear-gradient(
    var(--prism-angle, 0deg),
    rgba(0, 240, 255, 0.3),
    rgba(120, 0, 255, 0.2),
    rgba(255, 0, 180, 0.2),
    rgba(0, 240, 255, 0.3)
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 1px;
  pointer-events: none;
  animation: prismRotate 4s linear infinite;
}

/* Top bar: status pill (REC/READY indicator + timer) */
#scan-topbar {
  position: fixed;
  top: max(12px, env(safe-area-inset-top, 12px));
  left: 0;
  right: 0;
  z-index: 9001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  pointer-events: none;
}

#scan-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--osn-font-mono);
  padding: 8px 14px;
  pointer-events: auto;
}

#scan-rec-dot {
  width: 8px;
  height: 8px;
  background: #ff4444;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(255, 68, 68, 0.6);
  transition: background 0.2s, box-shadow 0.2s;
}
#scan-overlay.scan-recording #scan-rec-dot {
  animation: rec-pulse 1s ease-in-out infinite;
}
#scan-overlay.scan-armed #scan-rec-dot {
  background: #00f0ff;
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.6);
  animation: rec-pulse 1.6s ease-in-out infinite;
}
@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

#scan-rec-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: #ff4444;
  text-shadow: 0 0 6px rgba(255, 68, 68, 0.4);
  transition: color 0.2s, text-shadow 0.2s;
}
#scan-overlay.scan-armed #scan-rec-label {
  color: #00f0ff;
  text-shadow: 0 0 6px rgba(0, 240, 255, 0.4);
}

#scan-timer {
  font-family: var(--osn-font-mono);
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  letter-spacing: 0.08em;
  text-shadow: 0 0 8px rgba(0,0,0,0.8);
}

#scan-cancel-btn {
  font-family: var(--osn-font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 10px 16px;
  background:
    linear-gradient(135deg,
      rgba(0, 240, 255, 0.06) 0%,
      rgba(120, 0, 255, 0.04) 100%),
    rgba(8, 10, 16, 0.55);
  color: rgba(255,255,255,0.75);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 10px;
  cursor: pointer;
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  transition: all 0.15s;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
#scan-cancel-btn:hover {
  color: #fff;
  border-color: rgba(0, 240, 255, 0.4);
  background:
    linear-gradient(135deg,
      rgba(0, 240, 255, 0.12) 0%,
      rgba(120, 0, 255, 0.08) 100%),
    rgba(8, 10, 16, 0.7);
}
#scan-cancel-btn:active {
  transform: scale(0.94);
}

/* Grid wave canvas — lower center, only during recording */
#scan-grid-wave {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  width: min(320px, 80vw);
  height: 100px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
#scan-overlay.scan-recording #scan-grid-wave { opacity: 0.6; }

/* Bottom-center controls — glass panel, thumb reach zone */
#scan-controls {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom, 24px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9001;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  min-width: min(320px, 92vw);
}

#scan-hint {
  font-family: var(--osn-font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(0, 240, 255, 0.85);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
  text-align: center;
  line-height: 1.5;
  max-width: 280px;
}

/* State-driven button visibility */
#scan-overlay.scan-armed #scan-stop-btn { display: none; }
#scan-overlay.scan-recording #scan-record-btn { display: none; }

.scan-controls-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

#scan-record-btn,
#scan-stop-btn {
  width: 68px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(135deg,
      rgba(0, 240, 255, 0.08) 0%,
      rgba(120, 0, 255, 0.05) 100%),
    rgba(8, 10, 16, 0.55);
  border: 2px solid;
  border-image: linear-gradient(135deg, rgba(0,240,255,0.5), rgba(209,188,255,0.5)) 1;
  border-radius: 999px;
  color: var(--osn-primary, #00f0ff);
  cursor: pointer;
  backdrop-filter: blur(16px) saturate(1.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  transition: all 0.15s;
  box-shadow:
    0 0 24px rgba(0, 240, 255, 0.1),
    inset 0 0 20px rgba(0, 240, 255, 0.05);
}
#scan-record-btn:hover,
#scan-stop-btn:hover {
  background:
    linear-gradient(135deg,
      rgba(0, 240, 255, 0.15) 0%,
      rgba(120, 0, 255, 0.08) 100%),
    rgba(8, 10, 16, 0.65);
  box-shadow:
    0 0 32px rgba(0, 240, 255, 0.22),
    inset 0 0 24px rgba(0, 240, 255, 0.08);
}
#scan-record-btn:active,
#scan-stop-btn:active {
  transform: scale(0.9);
}

/* Pulsing red record dot (armed state) */
.scan-record-dot {
  animation: stop-pulse 1.4s ease-in-out infinite;
  filter: drop-shadow(0 0 6px rgba(255, 68, 68, 0.7));
}

/* Pulsing red stop square */
.scan-stop-square {
  animation: stop-pulse 1.2s ease-in-out infinite;
  filter: drop-shadow(0 0 4px rgba(255, 68, 68, 0.6));
}
@keyframes stop-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

/* Edge glow: thick pulsating purple-blue-red gradient on all edges */
#scan-edge-streak {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  animation: edge-pulse 2.5s ease-in-out infinite;
  border-top: 3px solid rgba(100, 60, 220, 0.6);
  border-right: 3px solid rgba(220, 40, 80, 0.5);
  border-bottom: 3px solid rgba(220, 40, 80, 0.4);
  border-left: 3px solid rgba(100, 60, 220, 0.5);
  box-shadow:
    inset 0 80px 80px -20px rgba(80, 40, 200, 0.3),
    inset 0 -70px 80px -20px rgba(220, 40, 80, 0.2),
    inset 70px 0 80px -20px rgba(220, 40, 80, 0.2),
    inset -70px 0 80px -20px rgba(80, 40, 200, 0.2);
}
@keyframes edge-pulse {
  0%, 100% {
    box-shadow:
      inset 0 80px 80px -20px rgba(80, 40, 200, 0.3),
      inset 0 -70px 80px -20px rgba(220, 40, 80, 0.2),
      inset 70px 0 80px -20px rgba(220, 40, 80, 0.2),
      inset -70px 0 80px -20px rgba(80, 40, 200, 0.2);
    border-top-color: rgba(100, 60, 220, 0.6);
    border-right-color: rgba(220, 40, 80, 0.5);
  }
  50% {
    box-shadow:
      inset 0 110px 110px -25px rgba(80, 40, 200, 0.5),
      inset 0 -100px 110px -25px rgba(220, 40, 80, 0.4),
      inset 100px 0 110px -25px rgba(220, 40, 80, 0.35),
      inset -100px 0 110px -25px rgba(80, 40, 200, 0.35);
    border-top-color: rgba(120, 70, 240, 0.8);
    border-right-color: rgba(240, 50, 90, 0.7);
  }
}

/* Progress — sits inside #capture-area, replacing the #dropzone slot
 * during upload. The card itself is the progress track; the gradient
 * fill grows horizontally to span the full card height, with the
 * status text floating centred on top. min-height: 180px matches the
 * dropzone so capture-area doesn't reflow on idle ↔ uploading flips. */
#upload-progress {
  position: relative;
  width: 100%;
  min-height: 180px;
  border-radius: 10px;
  overflow: hidden;
  background:
    linear-gradient(135deg,
      rgba(0, 240, 255, 0.07) 0%,
      rgba(120, 0, 255, 0.05) 50%,
      rgba(255, 0, 180, 0.04) 100%),
    rgba(14, 14, 19, 0.55);
  border: 1px solid rgba(0, 240, 255, 0.22);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  box-shadow:
    0 0 22px rgba(0, 240, 255, 0.08),
    0 6px 24px rgba(0, 0, 0, 0.30),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
#upload-progress.hidden { display: none; }

/* The bar element becomes a full-card track via absolute positioning;
 * #progress-fill grows from left to right at the full card height. */
#upload-progress > #progress-bar {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  background: transparent;
  border: none;
  border-radius: 0;
  margin: 0;
  overflow: hidden;
  z-index: 0;
}
#upload-progress > #progress-bar > #progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--osn-primary-container), var(--osn-synergy-magenta), var(--osn-primary-soft));
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.35), 0 0 20px rgba(255, 0, 255, 0.12);
  border-radius: 0;
  transition: width 0.15s;
}

/* Reconstruct-progress retains its original thin-bar layout for now —
 * its container has no min-height so the inset-trick wouldn't work
 * without further restructuring. */
#progress-bar-recon {
  width: 100%;
  height: 6px;
  background: rgba(2, 2, 5, 0.55);
  border: 1px solid rgba(0, 240, 255, 0.12);
  border-radius: var(--osn-radius);
  overflow: hidden;
  margin-bottom: 0;
}
#progress-fill-recon {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--osn-primary-container), var(--osn-synergy-magenta), var(--osn-primary-soft));
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.35), 0 0 20px rgba(255, 0, 255, 0.12);
  border-radius: var(--osn-radius);
  transition: width 0.3s;
}

/* Status copy floats over the fill, centred. Strong text-shadow stack
 * so it reads on both the dark unfilled portion and the bright cyan/
 * magenta gradient. */
#upload-progress > #progress-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  z-index: 1;
  pointer-events: none;
  font-family: var(--osn-font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: #fff;
  text-transform: uppercase;
  text-shadow:
    0 0 8px rgba(0, 240, 255, 0.45),
    0 1px 2px rgba(0, 0, 0, 0.95),
    0 0 4px rgba(0, 0, 0, 0.85);
}

#recon-text {
  margin: 0;
  font-family: var(--osn-font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.92);
  text-transform: uppercase;
  text-shadow:
    0 0 6px rgba(0, 240, 255, 0.35),
    0 1px 2px rgba(0, 0, 0, 0.85);
}

/* Result */
#upload-result {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 1.5rem;
  background: rgba(23, 23, 27, 0.45);
  backdrop-filter: var(--osn-glass-blur);
  -webkit-backdrop-filter: var(--osn-glass-blur);
  border: 1px solid transparent;
  border-image: var(--osn-crystalline-edge) 1;
  border-radius: var(--osn-radius);
  box-shadow: var(--osn-synergy-panel-glow);
}

#result-filename {
  font-family: var(--osn-font-mono);
  font-size: 12px;
  color: var(--osn-on-surface-muted);
}

#link-row {
  display: flex;
  width: 100%;
  gap: 8px;
}

#result-link {
  flex: 1;
  background: var(--osn-surface-lowest);
  border: 1px solid var(--osn-outline-variant);
  border-radius: var(--osn-radius);
  padding: 10px 14px;
  color: var(--osn-on-surface);
  font-family: var(--osn-font-mono);
  font-size: 12px;
  outline: none;
}

#result-link:focus {
  border-color: rgba(255, 0, 255, 0.35);
  box-shadow: 0 0 0 1px rgba(0, 240, 255, 0.2);
}

#copy-btn {
  background: var(--osn-synergy-gradient);
  color: var(--osn-on-primary-container);
  border: none;
  border-radius: var(--osn-radius);
  padding: 10px 20px;
  font-family: var(--osn-font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: filter 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(219, 252, 255, 0.22), 0 0 18px rgba(255, 0, 255, 0.1);
}

#copy-btn:hover,
#share-btn:hover {
  filter: brightness(1.08);
}

#copy-btn.copied {
  background: linear-gradient(135deg, #00c8a0, #00f0ff);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.35);
}

#share-btn {
  background: var(--osn-surface-container-high);
  color: var(--osn-primary-soft);
  border: 1px solid var(--osn-outline-variant);
  border-radius: var(--osn-radius);
  padding: 10px 20px;
  font-family: var(--osn-font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

#share-btn:hover {
  border-color: rgba(0, 240, 255, 0.35);
  color: var(--osn-on-surface);
}

#upload-another {
  background: transparent;
  border: 1px solid var(--osn-outline-variant);
  border-radius: var(--osn-radius);
  padding: 8px 20px;
  color: var(--osn-on-surface-muted);
  font-family: var(--osn-font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

#upload-another:hover {
  border-color: rgba(255, 0, 255, 0.35);
  color: var(--osn-primary-soft);
}

/* Error — celestial-refractive surface, red-shifted.
 * Follows DESIGN.md's five-ingredient recipe (dark base → tinted
 * gradient → backdrop blur+saturate → 1px border → halo+shadow+insets)
 * with the brand cyan/violet/magenta swapped for red/magenta/violet so
 * the chip reads as "alarming" instead of "celebratory". The
 * prismatic ::before ring is intentionally omitted — DESIGN.md says
 * skip it for small/transient UI, and a spinning rainbow on an error
 * would compete with the red urgency cue. */
.error-msg {
  position: relative;
  margin-top: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  font-family: var(--osn-font-mono);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  color: #ffd1d1;
  background:
    linear-gradient(135deg,
      rgba(255, 80, 80, 0.16) 0%,
      rgba(220, 40, 130, 0.10) 50%,
      rgba(120, 0, 255, 0.06) 100%),
    rgba(20, 12, 14, 0.62);
  backdrop-filter: blur(14px) saturate(1.45);
  -webkit-backdrop-filter: blur(14px) saturate(1.45);
  border: 1px solid rgba(255, 100, 100, 0.42);
  box-shadow:
    0 0 22px rgba(255, 80, 80, 0.14),
    0 0 44px rgba(220, 40, 130, 0.06),
    0 6px 20px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.10),
    inset 0 -1px 0 rgba(255, 100, 100, 0.06);
  text-shadow:
    0 0 6px rgba(255, 80, 80, 0.4),
    0 1px 2px rgba(0, 0, 0, 0.85),
    0 0 4px rgba(0, 0, 0, 0.7);
}

#reconstruct-progress {
  width: 100%;
  text-align: center;
}

.hidden {
  display: none !important;
}

/* ── Embedded 3D viewer (same page as upload / recon) ───────────── */
#viewer-stage {
  position: fixed;
  inset: 0;
  z-index: 50;
}

#viewer-grid {
  position: fixed;
  inset: 0;
  z-index: 51;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(0, 240, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}

#viewer-viewport {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 50;
}

#viewer-toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(10, 10, 12, 0.72);
  backdrop-filter: var(--osn-glass-blur);
  -webkit-backdrop-filter: var(--osn-glass-blur);
  border-bottom: 1px solid rgba(0, 240, 255, 0.2);
  box-shadow: 0 8px 40px rgba(10, 10, 12, 0.5), var(--osn-synergy-panel-glow);
}

#viewer-toolbar-logo {
  height: 22px;
  opacity: 0.9;
}

#viewer-logo-link {
  display: flex;
}

#viewer-filename {
  flex: 1;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--osn-on-surface-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#viewer-download-btn {
  background: var(--osn-surface-container-high);
  color: var(--osn-primary-soft);
  border: 1px solid var(--osn-outline-variant);
  border-radius: var(--osn-radius);
  padding: 8px 18px;
  font-family: var(--osn-font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s, filter 0.15s;
}

#viewer-download-btn:hover {
  border-color: rgba(0, 240, 255, 0.35);
  filter: brightness(1.05);
}

/* Point size slider — cosmic glass style */
#point-size-slider {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: rgba(14, 14, 19, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(0, 240, 255, 0.12);
  border-radius: 20px;
  touch-action: none;
}
#point-size-slider.hidden { display: none; }

#point-size-label {
  font-family: var(--osn-font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: rgba(0, 240, 255, 0.5);
  white-space: nowrap;
}

#point-size-range {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 4px;
  background: linear-gradient(90deg, rgba(0, 240, 255, 0.2), rgba(209, 188, 255, 0.3));
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
#point-size-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle, #00f0ff 30%, rgba(0, 240, 255, 0.3) 100%);
  border: 2px solid rgba(0, 240, 255, 0.5);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
  cursor: pointer;
}
#point-size-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle, #00f0ff 30%, rgba(0, 240, 255, 0.3) 100%);
  border: 2px solid rgba(0, 240, 255, 0.5);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
  cursor: pointer;
}

/* Hidden for now — re-enable display when stream fallback is ready */
#viewer-stream-btn {
  display: none !important;
  position: fixed;
  bottom: 24px;
  right: 120px;
  z-index: 100;
  background: rgba(0, 229, 255, 0.08);
  color: #00e5ff;
  border: 1px solid rgba(0, 229, 255, 0.25);
  border-radius: var(--osn-radius);
  padding: 12px 20px;
  font-family: var(--osn-font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3), 0 0 12px rgba(0, 229, 255, 0.08);
  transition: background 0.15s, border-color 0.15s;
}

#viewer-stream-btn:hover {
  background: rgba(0, 229, 255, 0.16);
  border-color: rgba(0, 229, 255, 0.4);
}

#viewer-embed-btn {
  position: fixed;
  bottom: 24px;
  right: 110px;
  z-index: 100;
  background: rgba(19, 19, 24, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--osn-on-surface);
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: var(--osn-radius);
  padding: 12px 24px;
  font-family: var(--osn-font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
}
#viewer-embed-btn:hover {
  border-color: rgba(0, 240, 255, 0.4);
  color: #dbfcff;
}

/* Embed modal */
#viewer-embed-modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
}
#viewer-embed-modal.hidden { display: none; }
#viewer-embed-card {
  background: rgba(19, 19, 24, 0.95);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(0, 240, 255, 0.15);
  border-radius: 12px;
  padding: 28px 32px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  max-width: 560px; width: 90%;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.6);
}
#viewer-embed-title {
  font-family: var(--osn-font-mono);
  font-size: 13px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: #dbfcff;
}
#viewer-embed-sub {
  font-family: var(--osn-font-mono);
  font-size: 10px; color: #849495;
  letter-spacing: 0.08em;
}
#viewer-embed-code {
  width: 100%; padding: 14px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 240, 255, 0.1);
  border-radius: 8px;
  font-family: var(--osn-font-mono);
  font-size: 11px; color: #00f0ff;
  white-space: pre-wrap; word-break: break-all;
  line-height: 1.5; margin: 0;
  max-height: 200px; overflow-y: auto;
}
#viewer-embed-copy, #viewer-embed-close {
  padding: 8px 24px;
  border-radius: var(--osn-radius);
  font-family: var(--osn-font-mono);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; cursor: pointer;
  transition: background 0.12s;
}
#viewer-embed-copy {
  background: rgba(0, 240, 255, 0.15);
  border: 1px solid rgba(0, 240, 255, 0.3);
  color: #dbfcff;
}
#viewer-embed-copy:hover { background: rgba(0, 240, 255, 0.25); }
#viewer-embed-close {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #849495;
}
#viewer-embed-close:hover { background: rgba(255, 255, 255, 0.05); }

#viewer-share-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  background: var(--osn-synergy-gradient);
  color: var(--osn-on-primary-container);
  border: none;
  border-radius: var(--osn-radius);
  padding: 12px 24px;
  font-family: var(--osn-font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.45),
    0 0 20px rgba(255, 0, 255, 0.12),
    inset 0 0 0 1px rgba(219, 252, 255, 0.22);
  transition: filter 0.15s;
}

#viewer-share-btn:hover {
  filter: brightness(1.08);
}

/* Share pop-up menu */
#viewer-share-menu {
  position: fixed;
  bottom: 72px;
  right: 24px;
  z-index: 101;
  display: none;
  flex-direction: column;
  gap: 4px;
  background: rgba(19, 19, 24, 0.92);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(0, 240, 255, 0.12);
  border-radius: var(--osn-radius);
  padding: 6px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
#viewer-share-menu.open { display: flex; }
#viewer-share-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: transparent;
  border: none;
  color: var(--osn-on-surface);
  font-family: var(--osn-font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s;
}
#viewer-share-menu button:hover {
  background: rgba(0, 240, 255, 0.06);
  color: #dbfcff;
}

/* QR modal */
#viewer-qr-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
}
#viewer-qr-modal.hidden { display: none; }
#viewer-qr-card {
  background: rgba(19, 19, 24, 0.95);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(0, 240, 255, 0.15);
  border-radius: 12px;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.6);
}
#viewer-qr-title {
  font-family: var(--osn-font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #dbfcff;
}
#viewer-qr-sub {
  font-family: var(--osn-font-mono);
  font-size: 10px;
  color: #849495;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
#viewer-qr-img {
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}
#viewer-qr-link {
  font-family: var(--osn-font-mono);
  font-size: 10px;
  color: #00f0ff;
  word-break: break-all;
  max-width: 260px;
  text-align: center;
  margin-top: 4px;
}
#viewer-qr-close {
  margin-top: 12px;
  padding: 8px 24px;
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: var(--osn-radius);
  color: #dbfcff;
  font-family: var(--osn-font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.12s;
}
#viewer-qr-close:hover { background: rgba(0, 240, 255, 0.15); }

#viewer-share-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(23, 23, 27, 0.92);
  backdrop-filter: var(--osn-glass-blur);
  -webkit-backdrop-filter: var(--osn-glass-blur);
  color: var(--osn-primary-soft);
  border: 1px solid transparent;
  border-image: var(--osn-crystalline-edge) 1;
  font-family: var(--osn-font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  padding: 10px 22px;
  border-radius: var(--osn-radius);
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  box-shadow: var(--osn-synergy-panel-glow);
}

#viewer-share-toast.visible {
  opacity: 1;
}

/* ── Mobile layout for the /view/ Share + Embed buttons ──────────────────── */
/* On mobile the splat-viewer's Crop slider sits at the bottom-center
 * (defined inside the iframe at openstrate-viewport/splat-viewer.html
 * — `position: fixed; bottom: 16px; left: 50%`). The default Share +
 * Embed positions (bottom: 24px right: 24px / 110px) overlap that slider
 * on a 390px-wide iPhone screen, blocking the right portion of the slider
 * from receiving touch events.
 *
 * On ≤ 640px:
 *   • Lift both buttons above the Crop slider (bottom: 96px)
 *   • Right-align as a single horizontal row, mv-pill-style — rounded
 *     pill, mono caps, smaller padding — to match the visual language
 *     of the mobile view pills on /viewer/.
 *   • Share keeps the synergy gradient (it's the primary action).
 *   • Embed keeps the dark glass background, but matches Share's pill
 *     proportions so they read as a single button row.
 *   • Bump the Share pop-up menu so it stays above the relocated Share
 *     button instead of floating mid-canvas. */
@media (max-width: 640px) {
  #viewer-share-btn,
  #viewer-embed-btn {
    bottom: 96px;
    padding: 10px 18px;
    font-size: 11px;
    letter-spacing: 0.08em;
    border-radius: 24px;
  }
  #viewer-share-btn {
    right: 16px;
    box-shadow:
      0 4px 16px rgba(0, 0, 0, 0.45),
      0 0 16px rgba(255, 0, 255, 0.1),
      inset 0 0 0 1px rgba(219, 252, 255, 0.22);
  }
  #viewer-embed-btn {
    right: 96px;
    background: rgba(19, 19, 24, 0.78);
    border: 1px solid rgba(0, 240, 255, 0.18);
  }
  #viewer-share-menu {
    bottom: 144px;
    right: 16px;
  }
}

#viewer-loading {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--osn-celestial-bg);
}

#viewer-loading.hidden {
  display: none;
}

#viewer-logo-loading {
  position: relative;
  overflow: hidden;
  animation: viewer-logo-pulse 2.5s ease-in-out infinite;
}

#viewer-logo-loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0, 240, 255, 0.15) 40%,
    rgba(255, 255, 255, 0.25) 50%,
    rgba(209, 188, 255, 0.15) 60%,
    transparent 100%
  );
  animation: viewer-logo-shine 2.5s ease-in-out infinite;
}

@keyframes viewer-logo-shine {
  0% { left: -100%; }
  100% { left: 200%; }
}

@keyframes viewer-logo-pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); }
}

#viewer-loading-text {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--osn-on-surface-muted);
}

#viewer-error-screen {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: var(--osn-celestial-bg);
  padding: 24px;
}

#viewer-error-screen.hidden {
  display: none;
}

#viewer-error-text {
  color: #f0a0a0;
  font-size: 14px;
  text-align: center;
  max-width: 360px;
}

#viewer-back-upload {
  background: var(--osn-surface-container-high);
  color: var(--osn-primary-soft);
  border: 1px solid var(--osn-outline-variant);
  border-radius: var(--osn-radius);
  padding: 10px 22px;
  font-family: var(--osn-font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

#viewer-back-upload:hover {
  border-color: rgba(0, 240, 255, 0.35);
}
