/* === TOKENS & THEMES === */
:root {
  color-scheme: dark light;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --fs-display: clamp(1.75rem, 3.2vw, 2.35rem);
  --fs-h1: 1.35rem;
  --fs-h2: 1.125rem;
  --fs-body: 0.9375rem;
  --fs-sm: 0.8125rem;
  --fs-xs: 0.75rem;

  --radius-card: 1.5rem;
  --radius-control: 0.875rem;
  --radius-sm: 0.625rem;
  --radius-pill: 9999px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-press: 100ms;
  --dur-base: 300ms;

  --bg: #0a0b0e;
  --surface: #14161c;
  --surface-elevated: #1c1f28;
  --surface-glass: rgba(20, 22, 28, 0.76);
  --stage-bg: #0b0d12;
  --stage-glass: rgba(16, 18, 24, 0.74);
  --stage-solid: rgba(14, 16, 22, 0.82);

  --text: #f5f5f7;
  --text-secondary: #9ba1b0;
  --text-tertiary: #8a90a0;

  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.18);
  --glass-edge: rgba(255, 255, 255, 0.14);

  --accent: #ff5c39;
  --accent-fill: #ff5c39;
  --accent-fill-hover: #ff7152;
  --on-accent: #0d0b0a;
  --accent-text: #ff7d5e;
  --accent-ring: #ff5c39;
  --accent-soft: rgba(255, 92, 57, 0.14);

  --status-info: #5ac8fa;
  --status-info-bg: rgba(90, 200, 250, 0.12);
  --status-ok: #32d74b;
  --status-ok-bg: rgba(50, 215, 75, 0.12);
  --status-warn: #ffd60a;
  --status-warn-bg: rgba(255, 214, 10, 0.12);
  --status-err: #ff453a;
  --status-err-bg: rgba(255, 69, 58, 0.12);

  --shadow-card: 0 12px 36px rgba(0, 0, 0, 0.35);
  --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.45);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f5f7;
    --surface: #ffffff;
    --surface-elevated: #eef0f4;
    --surface-glass: rgba(255, 255, 255, 0.80);

    --text: #1d1d1f;
    --text-secondary: #515154;
    --text-tertiary: #626268;

    --line: rgba(0, 0, 0, 0.08);
    --line-strong: rgba(0, 0, 0, 0.16);
    --glass-edge: rgba(255, 255, 255, 0.78);

    --accent-fill: #ff5c39;
    --accent-fill-hover: #e84d2a;
    --on-accent: #0d0b0a;
    --accent-text: #b83214;
    --accent-ring: #b83214;
    --accent-soft: rgba(184, 50, 20, 0.10);

    --status-info: #0055b3;
    --status-info-bg: rgba(0, 85, 179, 0.09);
    --status-ok: #17702f;
    --status-ok-bg: rgba(23, 112, 47, 0.09);
    --status-warn: #8a5a00;
    --status-warn-bg: rgba(138, 90, 0, 0.10);
    --status-err: #c92a2a;
    --status-err-bg: rgba(201, 42, 42, 0.09);

    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.06);
    --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.14);
  }
}

/* === BASE & RESET === */
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  font-family: var(--font-sans);
  font-optical-sizing: auto;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-body);
  line-height: 1.5;
  letter-spacing: 0;
  padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0px));
}

:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
}

/* === HEADER & WAYFINDING === */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: calc(0.75rem + env(safe-area-inset-top, 0px)) calc(1.25rem + env(safe-area-inset-right, 0px)) 1.1rem calc(1.25rem + env(safe-area-inset-left, 0px));
  background: var(--surface-glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: inset 0 1px 0 var(--glass-edge);
  -webkit-mask-image: linear-gradient(to bottom, #000 82%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 82%, transparent 100%);
}

.header-inner {
  max-width: 60rem;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
}

.brand-group { display: flex; flex-direction: column; gap: 0.125rem; }

.wordmark {
  margin: 0;
  font-size: var(--fs-h1);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.1;
  color: var(--text);
}

.tagline {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  letter-spacing: 0.005em;
}

.step-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--surface-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 0.25rem;
}

.step-nav-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.25rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-pill);
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out), opacity var(--dur-base) var(--ease-out);
}

.step-nav-item:disabled { opacity: 0.45; cursor: default; }

.step-nav-num {
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: var(--radius-pill);
  background: var(--line);
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  font-weight: 600;
}

.step-nav-item.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14);
}

.step-nav-item.is-active .step-nav-num {
  background: var(--accent-fill);
  color: var(--on-accent);
}

.step-nav-item.is-complete { color: var(--text-secondary); }
.step-nav-item.is-complete .step-nav-num {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.header-restart-btn {
  min-height: 2.5rem;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 500;
}

.header-restart-btn:hover { color: var(--text); border-color: var(--accent-ring); }

/* === MAIN LAYOUT & STEP CARDS === */
.app-main {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1rem calc(1.25rem + env(safe-area-inset-right, 0px)) 0 calc(1.25rem + env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.step {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: clamp(1.25rem, 3vw, 2rem);
  box-shadow: var(--shadow-card);
  opacity: 1;
  transform: translateY(0);
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}

@starting-style {
  .step:not(.hidden) {
    opacity: 0;
    transform: translateY(14px);
  }
}

.step.is-collapsing {
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
}

.step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.step h2, .step-title {
  margin: 0;
  font-size: var(--fs-h2);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.num {
  display: inline-grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.hint {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  margin: 0 0 1rem;
  letter-spacing: 0.005em;
}

/* === BUTTONS & PRESS FEEDBACK === */
button {
  font-family: inherit;
  font-size: var(--fs-body);
  font-weight: 600;
  min-height: 2.75rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-control);
  border: 0;
  background: var(--accent-fill);
  color: var(--on-accent);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out), opacity var(--dur-base) var(--ease-out);
}

button:hover:not(:disabled) { background: var(--accent-fill-hover); }

button:active:not(:disabled),
.step-nav-item:active:not(:disabled),
.step3-tab:active:not(:disabled),
.chip:active:not(:disabled),
.room-hotspot:active,
.minimap-room-dot:active,
.demo-card:active,
.drop-zone:active {
  transform: scale(0.97);
}

button:disabled { opacity: 0.42; cursor: not-allowed; }

button.secondary, .sample-plan-btn {
  background: var(--surface-elevated);
  border: 1px solid var(--line-strong);
  color: var(--text);
}

button.secondary:hover:not(:disabled), .sample-plan-btn:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--accent-ring);
}

/* === STEP 1: UPLOAD DROP ZONE & DEMO PICKER === */
.drop-zone {
  position: relative;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-card);
  background: var(--surface-elevated);
  padding: clamp(1.75rem, 4vw, 2.75rem) 1.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  transition: transform var(--dur-press) var(--ease-out), border-color var(--dur-base) var(--ease-out), background-color var(--dur-base) var(--ease-out);
}

.drop-zone:hover, .drop-zone.drop-zone-active {
  border-color: var(--accent-ring);
  background: var(--accent-soft);
}

.drop-zone-icon {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-control);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--accent-text);
  display: grid;
  place-items: center;
}

.drop-zone-title {
  margin: 0;
  font-size: var(--fs-h2);
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
}

.drop-zone-meta {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  letter-spacing: 0.01em;
}

.drop-zone-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

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

.upload-retention-note {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  margin-top: 0.5rem;
  text-align: center;
}

.drop-zone.is-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.demo-plan-picker { margin-top: 1rem; }
.demo-plan-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin-top: 0.75rem;
}

.demo-card {
  background: var(--surface-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0;
  transition: transform var(--dur-press) var(--ease-out), border-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}

.demo-card:hover { border-color: var(--accent-ring); }
.demo-card.selected {
  border-color: var(--accent-ring);
  box-shadow: 0 0 0 2px var(--accent-ring);
}

.demo-card-img {
  width: 100%;
  height: 9rem;
  object-fit: contain;
  background: #14161c;
  display: block;
}

.demo-card-body {
  padding: 0.875rem 1rem;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.5rem;
}

.demo-card-title { font-weight: 600; font-size: var(--fs-body); color: var(--text); }
.demo-card-desc { font-size: var(--fs-xs); color: var(--text-secondary); line-height: 1.4; }
.demo-card-meta { font-size: var(--fs-xs); color: var(--accent-text); font-weight: 600; }

/* === INLINE FEEDBACK & NOTICES === */
.status {
  margin: 0.75rem 0 0;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  min-height: 1.25rem;
}
.status.ok { color: var(--status-ok); }
.status.warn { color: var(--status-warn); }
.status.error { color: var(--status-err); }

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-control);
  border: 1px solid var(--line);
  background: var(--surface-elevated);
  font-size: var(--fs-sm);
  margin-top: 0.875rem;
}

.notice-body {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--text);
}

.notice-icon {
  flex-shrink: 0;
  width: 1.125rem;
  height: 1.125rem;
}

.notice-status { background: var(--status-info-bg); border-color: var(--status-info); }
.notice-status .notice-icon { color: var(--status-info); }

.notice-success { background: var(--status-ok-bg); border-color: var(--status-ok); }
.notice-success .notice-icon { color: var(--status-ok); }

.notice-warning { background: var(--status-warn-bg); border-color: var(--status-warn); }
.notice-warning .notice-icon { color: var(--status-warn); }

.notice-error { background: var(--status-err-bg); border-color: var(--status-err); }
.notice-error .notice-icon { color: var(--status-err); }

.notice-retry-btn {
  min-height: 2.125rem;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: 600;
  flex-shrink: 0;
}

/* === STEP 2: REVIEW & CALIBRATION === */
.auto-scale-card {
  background: var(--surface-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  padding: clamp(1.125rem, 2.5vw, 1.5rem);
  margin-bottom: 1.25rem;
}

.auto-scale-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.footprint-hero { display: flex; flex-direction: column; gap: 0.2rem; }
.footprint-label, .auto-scale-title {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
}

.footprint-value, #auto-footprint {
  display: block;
  font-size: var(--fs-display);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge svg { width: 0.95rem; height: 0.95rem; flex-shrink: 0; }
.badge-high { background: var(--status-ok-bg); color: var(--status-ok); border: 1px solid var(--status-ok); }
.badge-medium { background: var(--status-warn-bg); color: var(--status-warn); border: 1px solid var(--status-warn); }
.badge-low { background: var(--status-err-bg); color: var(--status-err); border: 1px solid var(--status-err); }

.evidence-details, .manual-details, .details-disclosure {
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 0.875rem;
}

.evidence-details summary, .manual-details summary, .details-disclosure summary {
  cursor: pointer;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 500;
  min-height: 2.25rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  user-select: none;
}

.evidence-details summary:hover, .manual-details summary:hover, .details-disclosure summary:hover {
  color: var(--text);
}

.evidence-list {
  margin: 0.5rem 0 0 1.25rem;
  padding: 0;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}
.evidence-list li { margin-bottom: 0.25rem; }

.primary-controls {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.option-list { display: flex; flex-direction: column; gap: 0.625rem; }

.toggle-label, .option-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0.875rem;
  border-radius: var(--radius-control);
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: pointer;
}

.toggle-label input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.125rem;
  accent-color: var(--accent-fill);
  cursor: pointer;
  flex-shrink: 0;
}

.option-copy { display: flex; flex-direction: column; gap: 0.15rem; }
.option-title { font-size: var(--fs-body); font-weight: 600; color: var(--text); }
.option-helper { font-size: var(--fs-xs); color: var(--text-secondary); letter-spacing: 0.005em; }

.demo-prebuilt-note { font-size: var(--fs-sm); color: var(--text-secondary); margin: 0; }
.primary-btn { width: 100%; min-height: 3rem; }

/* Secondary Card: Detected Layout */
.section-card, .plan2d-details {
  background: var(--surface-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  padding: 1.125rem;
  margin-top: 1rem;
}

.section-card-header, .plan2d-details summary {
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  margin: 0;
}

.plan2d { margin-top: 0.875rem; }
.plan2d svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 60vh;
  background: #fafafa;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.plan2d text {
  fill: #111;
  stroke: #fafafa;
  paint-order: stroke;
  text-anchor: middle;
  font-family: var(--font-sans);
  font-weight: 600;
}
.plan2d-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 0.875rem 0 0;
  font-size: var(--fs-xs);
}
.plan2d-legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-secondary);
  font-weight: 500;
}
.plan2d-legend i {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

/* Manual Calibration */
.manual-details {
  background: var(--surface-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  padding: 0.875rem 1.125rem;
  margin-top: 1rem;
}
.canvas-wrap {
  width: 100%;
  background: #ffffff;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  overflow: hidden;
  line-height: 0;
  margin-top: 0.75rem;
}
#plan-canvas { max-width: 100%; cursor: crosshair; display: block; }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.875rem;
  align-items: flex-end;
  margin-top: 1rem;
}
.controls label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-secondary);
}
.unit { color: var(--text-tertiary); font-weight: 400; }
.controls input, .controls select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  font-size: var(--fs-body);
  min-height: 2.75rem;
  min-width: 8.5rem;
}

@media (max-width: 36rem) {
  .controls label, .controls input, .controls select, .controls button { width: 100%; }
  .controls { flex-direction: column; align-items: stretch; }
}

.step3-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.step3-tab {
  background: #11141c;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.step3-tab:hover {
  color: var(--text);
  border-color: rgba(255, 92, 57, 0.4);
}
.step3-tab.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(255, 92, 57, 0.35);
}

/* Stage Materialization (Blur + Scale + Opacity) */
.stage-materialize {
  opacity: 0;
  transform: scale(0.975);
  filter: blur(12px);
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out), filter var(--dur-base) var(--ease-out);
}
.stage-materialize.is-ready {
  opacity: 1;
  transform: scale(1);
  filter: blur(0px);
}

.tabletop-canvas-wrap {
  position: relative;
  width: 100%;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--stage-bg);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-float);
}

model-viewer {
  width: 100%;
  height: 64vh;
  min-height: 24rem;
  background: radial-gradient(circle at 50% 35%, #191d28 0%, #090b10 100%);
  border-radius: var(--radius-card);
  --poster-color: transparent;
  display: block;
}

/* Prominent AR Button Pill inside model-viewer */
#ar-button {
  position: absolute;
  bottom: 1.125rem;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  border-radius: var(--radius-pill);
  padding: 0.7rem 1.35rem;
  background: var(--accent-fill);
  color: var(--on-accent);
  font-size: var(--fs-body);
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-base) var(--ease-out);
}
#ar-button:hover { background: var(--accent-fill-hover); }
#ar-button:active { transform: translateX(-50%) scale(0.97); }

/* Orbit Segmented Bar (Blurred Layer 1 of 2 on Tabletop) */
.view-toggles {
  display: inline-flex;
  gap: 0.25rem;
  margin-top: 0.75rem;
  padding: 0.25rem;
  border-radius: var(--radius-pill);
  background: var(--stage-glass);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.chip {
  background: transparent;
  border: 0;
  color: #c7ccd8;
  min-height: 2.25rem;
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out);
}
.chip:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}
.chip.is-active {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

/* Room Hotspot & Popover Scaling From Dot (Blurred Layer 2 of 2 on Tabletop) */
.room-hotspot {
  background: transparent;
  border: none;
  padding: 0.625rem;
  margin: 0;
  min-width: 2.75rem;
  min-height: 2.75rem;
  cursor: pointer;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 10;
}

.room-dot {
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 50%;
  background: var(--accent-fill);
  border: 2px solid #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
  transition: transform var(--dur-base) var(--ease-out), background-color var(--dur-base) var(--ease-out);
  flex-shrink: 0;
}

.room-hotspot:hover .room-dot { transform: scale(1.25); }

.room-card {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  background: var(--stage-glass);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 6px 20px rgba(0, 0, 0, 0.6);
  color: #f5f5f7;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-pill);
  padding: 0.3rem 0.75rem;
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
  position: absolute;
  left: 2.35rem;
  top: 50%;
  transform-origin: -0.95rem 50%;
  transform: translateY(-50%) scale(0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}

.room-hotspot.active .room-card {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
}

.room-hotspot.active .room-dot {
  transform: scale(1.3);
  background: #ffffff;
  border-color: var(--accent-fill);
}

.room-card strong { color: #ffffff; font-weight: 600; }
.room-card span { color: #ff9d85; font-size: var(--fs-xs); font-weight: 600; }

/* Walkthrough Viewer Container */
#walkthrough-canvas-wrap {
  position: relative;
  width: 100%;
  height: 62vh;
  min-height: 440px;
  max-height: 700px;
  background: #0e1015;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}
#walkthrough-canvas-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  outline: none;
}

/* Walkthrough HUD */
#walkthrough-hud {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 20;
  display: flex;
  gap: 10px;
  pointer-events: none;
}
.hud-pill {
  background: rgba(14, 16, 21, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 18px;
  padding: 6px 14px;
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
.hud-pill strong {
  color: var(--text);
  font-weight: 600;
}
#hud-compass-needle {
  display: inline-block;
  color: var(--accent);
  font-size: 0.85rem;
  transition: transform 0.1s linear;
}

/* Minimap Card — Street View Style */
#walkthrough-minimap-card {
  position: absolute;
  bottom: 14px;
  left: 14px;
  width: 170px;
  max-width: 60%;
  max-height: 60%;
  background: rgba(14, 16, 21, 0.90);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  overflow: hidden;
  z-index: 20;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
  pointer-events: auto;
  transition: width 0.2s ease, height 0.2s ease, box-shadow 0.2s ease;
  transform-origin: bottom left;
  user-select: none;
  -webkit-user-select: none;
}
#walkthrough-minimap-card.expanded {
  width: 374px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.75);
}
#walkthrough-minimap {
  width: 100%;
  height: 100%;
  position: relative;
}
#walkthrough-minimap svg {
  width: 100%;
  height: 100%;
  background: #191c24;
  display: block;
}

/* Dots and Labels */
.minimap-room-dot {
  cursor: pointer;
  transition: transform 0.15s ease, fill 0.15s ease, opacity 0.2s ease;
  pointer-events: none;
  opacity: 0.65;
}
#walkthrough-minimap-card.expanded .minimap-room-dot {
  pointer-events: auto;
  opacity: 1;
}
.minimap-room-dot:hover {
  filter: brightness(1.35);
}

/* Current Room Highlight: White ring + dark outer stroke + soft glow */
.minimap-room-dot.active {
  stroke: #ffffff !important;
  stroke-width: 2.8px !important;
  opacity: 1 !important;
  filter: drop-shadow(0 0 2px #0e1015) drop-shadow(0 0 5px rgba(255, 255, 255, 0.95)) !important;
}
.minimap-active-ring {
  fill: none;
  stroke: #ffffff;
  stroke-width: 2.5px;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.95));
  pointer-events: none;
}
.minimap-active-halo {
  fill: none;
  stroke: #0e1015;
  stroke-width: 4.8px;
  pointer-events: none;
}

/* Room Labels beside dots */
.minimap-room-label {
  fill: #f1f5f9;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95), 0 0 2px rgba(0, 0, 0, 0.9);
}
#walkthrough-minimap-card.expanded .minimap-room-label {
  opacity: 1;
}

/* Pegman Marker */
.pegman-figure {
  transform-origin: center;
  pointer-events: none;
}
@keyframes pegman-teleport-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.45); }
  100% { transform: scale(1); }
}
.pegman-pulsing {
  animation: pegman-teleport-pulse 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Floating Zoom Controls */
.minimap-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
#walkthrough-minimap-card.expanded .minimap-controls {
  opacity: 1;
  pointer-events: auto;
}
.minimap-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 6px;
  background: rgba(30, 34, 45, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  line-height: 24px;
  text-align: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.minimap-btn:hover {
  background: rgba(255, 92, 57, 0.9);
  border-color: rgba(255, 92, 57, 1);
  transform: scale(1.05);
}
.minimap-btn:active {
  transform: scale(0.95);
}
.walkthrough-fade-overlay {
  position: absolute;
  inset: 0;
  background: #0e1015;
  opacity: 0;
  pointer-events: none;
  z-index: 25;
  transition: opacity 0.12s ease;
}
.walkthrough-fade-overlay.visible {
  opacity: 1;
}

/* Walkthrough Hints — centered at bottom, fades after first interaction */
#walkthrough-hints {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(14, 16, 21, 0.75);
  border-radius: 12px;
  padding: 4px 12px;
  font-size: 0.75rem;
  color: var(--muted);
  pointer-events: none;
  z-index: 20;
  white-space: nowrap;
  transition: opacity 0.5s ease;
}
#walkthrough-hints.faded {
  opacity: 0;
  pointer-events: none;
}

/* Walkthrough Loading Overlay */
.walkthrough-overlay {
  position: absolute;
  inset: 0;
  background: rgba(14, 16, 21, 0.92);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  z-index: 30;
  color: var(--text);
  font-size: 0.92rem;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 92, 57, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Solid Translucent Fill (No Blur): Fullscreen Button */
.viewer-fullscreen-btn {
  position: absolute;
  bottom: 0.875rem;
  right: 0.875rem;
  width: 2.75rem;
  height: 2.75rem;
  min-height: 2.75rem;
  border-radius: 50%;
  background: var(--stage-solid);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f5f5f7;
  padding: 0;
  z-index: 20;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
.viewer-fullscreen-btn:hover:not(:disabled) {
  background: rgba(30, 34, 46, 0.92);
  border-color: var(--accent-fill);
  color: var(--accent-fill);
}

/* Fullscreen States */
.viewer-fullscreen-wrap:fullscreen,
.viewer-fullscreen-wrap:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  border-radius: 0 !important;
  border: none !important;
  margin: 0 !important;
  background: var(--stage-bg) !important;
}

.viewer-fullscreen-wrap.pseudo-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100dvh !important;
  max-width: none !important;
  max-height: none !important;
  border-radius: 0 !important;
  border: none !important;
  z-index: 9999 !important;
  margin: 0 !important;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  background: var(--stage-bg) !important;
}

body.fullscreen-locked { overflow: hidden !important; }

#tabletop-view:fullscreen,
#tabletop-view:-webkit-full-screen,
#tabletop-view.pseudo-fullscreen {
  display: flex !important;
  flex-direction: column !important;
}
#tabletop-view:fullscreen .tabletop-canvas-wrap,
#tabletop-view:-webkit-full-screen .tabletop-canvas-wrap,
#tabletop-view.pseudo-fullscreen .tabletop-canvas-wrap {
  width: 100% !important;
  height: 100% !important;
  flex: 1 1 auto;
  border-radius: 0 !important;
  border: 0 !important;
}
#tabletop-view:fullscreen model-viewer,
#tabletop-view:-webkit-full-screen model-viewer,
#tabletop-view.pseudo-fullscreen model-viewer {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  border-radius: 0 !important;
}
#tabletop-view:fullscreen #orbit-toggles,
#tabletop-view:-webkit-full-screen #orbit-toggles,
#tabletop-view.pseudo-fullscreen #orbit-toggles {
  position: absolute;
  top: 0.875rem;
  left: 0.875rem;
  z-index: 20;
  margin-top: 0;
}

#walkthrough-canvas-wrap:fullscreen,
#walkthrough-canvas-wrap:-webkit-full-screen,
#walkthrough-canvas-wrap.pseudo-fullscreen {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  border-radius: 0 !important;
}

/* === STEP 3 STATS SUMMARY & DETAILS DISCLOSURE === */
.stats {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stats-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0.75rem;
}

.stat-pill {
  background: var(--surface-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat-label {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  font-weight: 500;
}

.stat-value {
  font-size: var(--fs-h2);
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.details-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin-top: 0.65rem;
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}
.details-item strong { color: var(--text); font-weight: 600; }

.step3-footer {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

/* === AR DEBUG PANEL (?debug) === */
.ar-debug-panel {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  max-width: 21.25rem;
  width: calc(100vw - 1.5rem);
  background: var(--stage-solid);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-control);
  padding: 0.65rem 0.85rem;
  z-index: 10000;
  box-shadow: var(--shadow-float);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}
.ar-debug-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.ar-debug-header strong { font-size: var(--fs-xs); color: var(--accent-fill); }
.ar-debug-panel pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  color: #e2e8f0;
  line-height: 1.4;
  max-height: 13.75rem;
  overflow-y: auto;
}

/* === ACCESSIBILITY MEDIA QUERIES === */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .stage-materialize {
    transform: none !important;
    filter: none !important;
    transition: opacity 150ms linear !important;
  }
  .segmented-thumb {
    transition: none !important;
  }
  .step,
  button,
  .step-nav-item,
  .step3-tab,
  .chip,
  .room-dot,
  .room-card,
  #walkthrough-minimap-card,
  .minimap-room-dot,
  .minimap-room-label,
  .minimap-controls,
  #walkthrough-hints,
  .walkthrough-fade-overlay {
    transform: none;
    transition: opacity 150ms linear, background-color 150ms linear, color 150ms linear, border-color 150ms linear !important;
  }
  .room-hotspot { transform: translate(-50%, -50%) !important; }
  .room-card {
    transform: translateY(-50%) !important;
    transition: opacity 150ms linear !important;
  }
  .room-hotspot.active .room-card { transform: translateY(-50%) !important; }
  #ar-button, #ar-button:active { transform: translateX(-50%) !important; }
  #walkthrough-hints { transform: translateX(-50%) !important; }
  .pegman-pulsing, .spinner { animation: none !important; }
}

@media (prefers-reduced-transparency: reduce) {
  :root {
    --surface-glass: var(--surface);
    --stage-glass: #12151e;
    --stage-solid: #12151e;
  }
  .site-header,
  .view-toggles,
  .room-card,
  .hud-pill,
  #walkthrough-minimap-card {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    -webkit-mask-image: none !important;
    mask-image: none !important;
  }
  .site-header { border-bottom: 1px solid var(--line-strong); }
}

@media (prefers-contrast: more) {
  :root {
    --line: rgba(255, 255, 255, 0.38);
    --line-strong: rgba(255, 255, 255, 0.65);
    --surface-glass: #101218;
    --stage-glass: #0c0e14;
    --stage-solid: #0c0e14;
  }
  @media (prefers-color-scheme: light) {
    :root {
      --line: rgba(0, 0, 0, 0.35);
      --line-strong: rgba(0, 0, 0, 0.65);
      --surface-glass: #ffffff;
    }
  }
  .step,
  .auto-scale-card,
  .section-card,
  .manual-details,
  .stat-pill,
  .notice,
  .step-nav,
  .step3-tabs.segmented-control {
    border-width: 1.5px;
    border-color: var(--line-strong);
  }
}

.hidden { display: none !important; }
