/* ============================================
   Pillow Order Form — Simplified 3-step flow
   ============================================ */

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

:root {
  color-scheme: light only;
  --color-primary: #F38181;
  --color-primary-hover: #E06B6B;
  --color-text: #1A1A1A;
  --color-text-light: #666666;
  --color-text-muted: #999999;
  --color-bg-light: rgba(255, 255, 255, 0.3);
  --color-input-border: #CCCCCC;
  --color-input-focus: #F38181;
  --color-success: #4CAF50;
  --color-error: #F44336;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;

  --spacing-xs: 8px;
  --spacing-sm: 12px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

/* ---- Body / Background ---- */

body {
  font-family: var(--font-family);
  color: var(--color-text);
  background: linear-gradient(135deg, #B5E0E8 0%, #FFDAB3 50%, #B5E0E8 100%);
  background-attachment: fixed;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Progress Bar (fixed top) ---- */

.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(0, 0, 0, 0.1);
  z-index: 1000;
}

.progress-fill {
  height: 100%;
  background: #000;
  width: 0%;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---- Form Container ---- */

.form-container {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: var(--spacing-lg);
  padding-bottom: var(--spacing-xl);
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Step Transitions ---- */

.step {
  display: none;
  width: 100%;
  opacity: 0;
  will-change: transform, opacity;
  transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.step.entering-forward {
  display: block;
  opacity: 0;
  transform: translate3d(0, 60px, 0);
}

.step.entering-backward {
  display: block;
  opacity: 0;
  transform: translate3d(0, -60px, 0);
}

.step.active {
  display: block;
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.step.exiting-forward {
  display: block;
  position: absolute;
  width: 100%;
  opacity: 0;
  transform: translate3d(0, -50px, 0) scale(0.97);
}

.step.exiting-backward {
  display: block;
  position: absolute;
  width: 100%;
  opacity: 0;
  transform: translate3d(0, 50px, 0) scale(0.97);
}

/* Staggered children entrance */
.step.active .step-content > * {
  animation: stepChildIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.step.active .step-content > *:nth-child(1) { animation-delay: 0.03s; }
.step.active .step-content > *:nth-child(2) { animation-delay: 0.07s; }
.step.active .step-content > *:nth-child(3) { animation-delay: 0.11s; }
.step.active .step-content > *:nth-child(4) { animation-delay: 0.15s; }
.step.active .step-content > *:nth-child(5) { animation-delay: 0.19s; }
.step.active .step-content > *:nth-child(6) { animation-delay: 0.23s; }
.step.active .step-content > *:nth-child(7) { animation-delay: 0.27s; }

@keyframes stepChildIn {
  from { opacity: 0; transform: translate3d(0, 16px, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}

/* ---- Question Header ---- */

.question-header {
  margin-bottom: var(--spacing-lg);
}

.question-text {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.35;
}

.question-text .emoji {
  margin-left: 6px;
}

.step-subtitle {
  font-size: 1rem;
  color: var(--color-text-light);
  margin-top: var(--spacing-xs);
}

/* ---- Text Inputs ---- */

.text-input {
  width: 100%;
  max-width: 420px;
  padding: var(--spacing-sm) 0;
  font-size: 1.25rem;
  font-family: var(--font-family);
  color: var(--color-text);
  border: none;
  border-bottom: 2px solid var(--color-input-border);
  background: transparent;
  outline: none;
  transition: border-color var(--transition-fast);
}

.text-input:focus {
  border-bottom-color: var(--color-text);
}

.text-input::placeholder {
  color: var(--color-text-muted);
}

.text-input.error {
  border-bottom-color: var(--color-error);
}

.error-message {
  color: var(--color-error);
  font-size: 0.8125rem;
  margin-top: var(--spacing-xs);
}

/* ---- Email input row on preview step ---- */

.email-input-row {
  margin-bottom: var(--spacing-lg);
}

.email-input-row .text-input {
  font-size: 1rem;
  max-width: 100%;
}

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-family);
  padding: var(--spacing-md) var(--spacing-lg);
  min-height: 48px;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  transform: scale(1.02);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-continue {
  width: 100%;
  max-width: 300px;
  min-height: 52px;
}

.btn-secondary,
.btn-retry {
  width: 100%;
  max-width: 300px;
  min-height: 44px;
  background: transparent;
  color: var(--color-text);
  border: 2px solid var(--color-input-border);
  margin-top: var(--spacing-sm);
}

.btn-retry:hover {
  border-color: var(--color-text);
}

/* ---- 3D Viewer Container ---- */

/* Warm neutral interior tones — replaces the cartoony sky/cloud bg.
   Subtle vignette + faux floor-line gradient gives "object on a surface"
   feel without needing a real product photo. */
.viewer-container {
  width: 100%;
  height: 450px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background:
    radial-gradient(ellipse 60% 35% at 50% 88%, rgba(0, 0, 0, 0.10) 0%, transparent 60%),
    linear-gradient(180deg, #f5ede2 0%, #f0e3d3 55%, #e8d6c1 100%);
  position: relative;
  touch-action: pan-y;
  margin-bottom: var(--spacing-md);
}

/* Drop-shadow under the pillow grounds it as a real object. Applied to the
   canvas itself so the shadow tracks rotation/scale. */
.viewer-container canvas {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 16px 22px rgba(60, 30, 10, 0.22))
          drop-shadow(0 4px 8px rgba(60, 30, 10, 0.12));
}

.product-subtitle {
  font-size: 0.85rem;
  color: var(--color-text-muted, #6b6056);
  margin: 4px 0 8px;
  line-height: 1.4;
}

@media (min-width: 768px) {
  .viewer-container { height: 550px; }
}

/* ---- Preview Layout (Cinematic Buy Box) ---- */

.preview-layout {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.viewer-wrap {
  position: relative;
  margin-bottom: 12px;
}

/* Floating toolbar overlay */
.viewer-toolbar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-full);
  padding: 6px 10px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.12);
  z-index: 10;
}

.vtool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}

.vtool-btn svg {
  width: 20px;
  height: 20px;
}

.vtool-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

.vtool-btn.active {
  background: rgba(243, 129, 129, 0.15);
  color: var(--color-primary);
}

/* "Drag to rotate" badge */
.viewer-badge {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.45);
  letter-spacing: 0.03em;
  pointer-events: none;
  z-index: 10;
  animation: badgeFadeOut 4s ease forwards;
}

@keyframes badgeFadeOut {
  0%, 60% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---- Buy Box ---- */

.buy-box {
  background: linear-gradient(180deg, rgba(212, 238, 243, 0.5) 0%, rgba(255, 255, 255, 0.95) 40%, #fff 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px 20px 24px;
  margin-top: -12px;
  position: relative;
  z-index: 5;
}

.buy-box-header {
  margin-bottom: 16px;
}

.product-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: 4px;
}

.product-rating {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rating-stars {
  color: #F5A623;
  font-size: 0.875rem;
  letter-spacing: 1px;
}

.rating-count {
  font-size: 0.8125rem;
  color: var(--color-text-light);
}

/* ---- Buy Size Selector (segmented control) ---- */

.buy-size-selector {
  display: flex;
  position: relative;
  background: rgba(243, 129, 129, 0.08);
  border: 1px solid rgba(243, 129, 129, 0.15);
  border-radius: 14px;
  padding: 3px;
  margin-bottom: 16px;
}

/* Sliding pill behind selected tab */
.buy-size-selector::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(25% - 1.5px);
  height: calc(100% - 6px);
  background: #fff;
  border-radius: 11px;
  box-shadow: 0 2px 8px rgba(243, 129, 129, 0.25), 0 1px 3px rgba(0,0,0,0.08);
  border: 1px solid rgba(243, 129, 129, 0.2);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
}

.buy-size-selector[data-selected="0"]::before { transform: translateX(0); }
.buy-size-selector[data-selected="1"]::before { transform: translateX(100%); }
.buy-size-selector[data-selected="2"]::before { transform: translateX(200%); }
.buy-size-selector[data-selected="3"]::before { transform: translateX(300%); }

.size-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 8px 0 7px;
  font-family: var(--font-family);
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 1;
}

.size-tab:hover {
  color: var(--color-text);
}

.size-tab.selected {
  color: var(--color-text);
}

.size-tab-label {
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.size-tab-dim {
  font-size: 0.6875rem;
  font-weight: 500;
  opacity: 0.7;
}

/* ---- Buy Email ---- */


/* ---- Buy CTA Button ---- */

.buy-cta {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 24px;
  background: linear-gradient(135deg, #F38181, #e66767, #F38181);
  background-size: 200% 200%;
  animation: ctaShimmer 3s ease-in-out infinite;
  color: #fff;
  border: none;
  border-radius: 16px;
  font-family: var(--font-family);
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  margin-bottom: 16px;
  box-shadow: 0 6px 20px rgba(243, 129, 129, 0.4), 0 2px 6px rgba(0,0,0,0.08);
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

@keyframes ctaShimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.buy-cta:hover {
  transform: scale(1.03);
  box-shadow: 0 8px 28px rgba(243, 129, 129, 0.5), 0 2px 8px rgba(0,0,0,0.1);
}

.buy-cta:active {
  transform: scale(0.97);
  box-shadow: 0 3px 10px rgba(243, 129, 129, 0.3);
}

.buy-cta-text {
  /* inherits */
}

.buy-cta-pricing {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.buy-cta-was {
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0.45;
  text-decoration: line-through;
}

.buy-cta-price {
  font-weight: 600;
}

/* ---- Trust Badges ---- */

.trust-row {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.trust-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-light);
}

.trust-badge svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ---- Buy Secondary Actions ---- */

.buy-secondary {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.link-btn {
  font-family: var(--font-family);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 4px;
  transition: color var(--transition-fast);
}

.link-btn:hover {
  color: var(--color-text);
}

.dot-sep {
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

/* ---- Size Selector (legacy) ---- */

.size-selector {
  display: flex;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-lg);
}

.size-option {
  flex: 1;
  padding: var(--spacing-sm) var(--spacing-xs);
  border: 2px solid var(--color-input-border);
  border-radius: var(--radius-md);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--color-bg-light);
}

.size-option:hover {
  border-color: var(--color-text);
}

.size-option.selected {
  border-color: var(--color-text);
  background: rgba(0, 0, 0, 0.05);
}

.size-option .size-label {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--color-text);
}

.size-option .size-dim {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.size-option .size-price {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-top: 4px;
}

/* ---- Color Picker ---- */

.color-picker-row {
  margin-bottom: var(--spacing-md);
}

.color-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 8px;
  display: block;
}

.color-swatches {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.color-swatch {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  border: 2px solid #ccc;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  padding: 0;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-clip: padding-box;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.selected {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary);
}

.color-custom {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  border: 2px solid #ccc;
  cursor: pointer;
  padding: 0;
  background: none;
  -webkit-appearance: none;
  appearance: none;
  overflow: hidden;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.color-custom:hover {
  transform: scale(1.15);
}

.color-custom.selected {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary);
}

.color-custom::-webkit-color-swatch-wrapper { padding: 0; }
.color-custom::-webkit-color-swatch { border: none; border-radius: 50%; }

/* ---- Checkout / Processing Step ---- */

.checkout-loading {
  text-align: center;
  padding: var(--spacing-2xl) 0;
}

.checkout-spinner {
  width: 56px;
  height: 56px;
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto var(--spacing-lg);
}

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

.checkout-status-text {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--spacing-sm);
}

.checkout-substatus {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-lg);
}

.checkout-progress {
  width: 100%;
  max-width: 300px;
  height: 6px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin: 0 auto;
}

.checkout-progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  transition: width 0.5s ease-out;
  width: 0%;
}

.checkout-fallback {
  display: none;
  text-align: center;
  margin-top: var(--spacing-lg);
}

.checkout-fallback.visible {
  display: block;
}

.checkout-fallback a {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: underline;
}

/* ---- Success Screen ---- */

.success-content {
  text-align: center;
  max-width: 480px;
  margin: 0 auto;
}

.success-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--spacing-lg);
  border-radius: 50%;
  background: var(--color-success);
  display: flex;
  align-items: center;
  justify-content: center;
}

.success-icon svg {
  width: 40px;
  height: 40px;
  color: white;
}

.success-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: var(--spacing-sm);
}

.success-message {
  font-size: 1.0625rem;
  color: var(--color-text-light);
  line-height: 1.6;
  margin-bottom: var(--spacing-lg);
}

.success-order-id {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* ---- Loading Overlay ---- */

/* ---- Loading Overlay (segmentation) ---- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: #0A0E2A;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  transition: opacity 0.4s ease, visibility 0s 0s;
  overflow: hidden;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0s 0.4s;
}

/* Floating paw prints */
.loading-paws {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.loading-paw {
  position: absolute;
  fill: rgba(255, 143, 143, 0.06);
  animation: pawFloat linear infinite;
}

.loading-paw.p1 { width: 40px; left: 8%;  top: -40px; animation-duration: 14s; animation-delay: 0s; }
.loading-paw.p2 { width: 28px; left: 30%; top: -28px; animation-duration: 18s; animation-delay: 2s; }
.loading-paw.p3 { width: 48px; left: 55%; top: -48px; animation-duration: 16s; animation-delay: 5s; }
.loading-paw.p4 { width: 32px; left: 78%; top: -32px; animation-duration: 20s; animation-delay: 1s; }
.loading-paw.p5 { width: 36px; left: 42%; top: -36px; animation-duration: 22s; animation-delay: 8s; }

@keyframes pawFloat {
  0%   { transform: translateY(0) rotate(0deg); opacity: 0; }
  5%   { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translateY(calc(100dvh + 60px)) rotate(25deg); opacity: 0; }
}

/* Center content */
.loading-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  width: 85%;
  max-width: 300px;
  z-index: 1;
}

/* Icon ring with spinner */
.loading-icon-ring {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-paw-icon {
  width: 44px;
  height: 44px;
  opacity: 0.85;
  animation: pawBreathe 3s ease-in-out infinite;
}

@keyframes pawBreathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.1); }
}

.loading-ring-spinner {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 143, 143, 0.12);
  border-top-color: #FF8F8F;
  animation: ringSpinLoad 1.1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes ringSpinLoad {
  to { transform: rotate(360deg); }
}

/* Status text */
.loading-status {
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  margin: 0;
  min-height: 1.5em;
  transition: opacity 0.3s ease;
}

/* Progress track */
.loading-progress-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.loading-progress-track::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.08) 50%, transparent 100%);
  animation: shimmerBar 2s ease-in-out infinite;
}

@keyframes shimmerBar {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.loading-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #FF8F8F, #ffb8b8);
  border-radius: 2px;
  transition: width 0.3s ease;
  position: relative;
  z-index: 1;
}

/* Percentage */
.loading-pct {
  font-family: var(--font-family);
  font-size: 0.8125rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.1em;
  margin: -12px 0 0;
}

/* ---- Honeypot ---- */

.hp-field {
  position: absolute;
  left: -9999px;
  top: -9999px;
}

/* ---- Responsive ---- */

@media (max-width: 375px) {
  .question-text { font-size: 1.25rem; }
  .text-input { font-size: 1.125rem; }
  .size-option { padding: var(--spacing-xs) 4px; }
  .size-option .size-label { font-size: 1rem; }
}

@media (min-width: 768px) {
  .form-container {
    padding-bottom: 120px;
  }
}

/* ---- Reduced Motion ---- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: high) {
  :root {
    --color-input-border: #555;
    --color-text-light: #444;
    --color-text-muted: #666;
  }
}

/* ---- Preview Toolbar ---- */

.preview-toolbar {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: var(--spacing-sm);
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 0.6875rem;
  font-weight: 600;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.tool-btn svg {
  width: 26px;
  height: 26px;
}

.tool-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.tool-btn.active {
  background: rgba(243, 129, 129, 0.15);
  color: var(--color-primary);
  border-radius: var(--radius-md);
}

/* ---- Tool Panels ---- */

.tool-panels-wrap {
  overflow: hidden;
}

.tool-panel {
  display: none;
  background: rgba(255, 255, 255, 0.45);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  animation: panelSlideIn 0.25s ease-out;
}

.tool-panel.open {
  display: block;
}

@keyframes panelSlideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tool-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
}

.tool-panel-header span {
  font-weight: 700;
  font-size: 0.9375rem;
}

.tool-panel-done {
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--color-text);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 8px;
}

.tool-panel-desc {
  font-size: 0.8125rem;
  color: var(--color-text-light);
  margin-bottom: var(--spacing-sm);
}

.tool-panel-action {
  max-width: 100%;
  width: auto;
  margin: 0;
}

/* ---- History Grid ---- */

.history-grid {
  display: flex;
  gap: var(--spacing-sm);
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.history-empty {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.history-thumb {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  overflow: hidden;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.5);
  transition: border-color var(--transition-fast);
}

.history-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-thumb:hover,
.history-thumb.active {
  border-color: var(--color-primary);
}

/* ---- Notes Textarea ---- */

.notes-textarea {
  width: 100%;
  padding: var(--spacing-sm);
  font-family: var(--font-family);
  font-size: 0.9375rem;
  color: var(--color-text);
  border: 2px solid var(--color-input-border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.6);
  resize: vertical;
  outline: none;
  transition: border-color var(--transition-fast);
}

.notes-textarea:focus {
  border-color: var(--color-text);
}

.notes-textarea::placeholder {
  color: var(--color-text-muted);
}

/* ---- Size Comparison Scene ---- */

.size-compare-scene {
  width: 100%;
  height: 350px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--spacing-md);
  position: relative;
}

.size-compare-scene.hidden {
  display: none;
}

.room-interior {
  width: 100%;
  height: 100%;
  position: relative;
  background: linear-gradient(180deg, #f5efe8 0%, #ebe4db 60%, #d4ccc2 100%);
  overflow: hidden;
}

/* CSS Couch */
.room-couch {
  position: absolute;
  bottom: 8%;
  left: 10%;
  width: 55%;
  height: 48%;
}

.couch-back {
  position: absolute;
  top: 0;
  left: -2%;
  right: -2%;
  height: 45%;
  background: #d6cfc6;
  border-radius: 12px 12px 0 0;
  box-shadow: inset 0 -4px 8px rgba(0,0,0,0.06);
}

.couch-seat {
  position: absolute;
  bottom: 12%;
  left: 0;
  right: 0;
  height: 38%;
  background: #e8e0d6;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.couch-legs {
  position: absolute;
  bottom: 0;
  left: 8%;
  right: 8%;
  height: 10%;
}

.couch-legs::before,
.couch-legs::after {
  content: '';
  position: absolute;
  bottom: 0;
  width: 8px;
  height: 100%;
  background: #b8ad9e;
  border-radius: 2px;
}

.couch-legs::before { left: 0; }
.couch-legs::after { right: 0; }

.pillow-on-couch {
  max-width: 50%;
  max-height: 90%;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
  transition: max-width 0.3s ease, max-height 0.3s ease;
}

/* Silhouette */
.room-silhouette {
  position: absolute;
  right: 8%;
  bottom: 8%;
  height: 82%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.room-silhouette svg {
  height: 100%;
  width: auto;
}

.silhouette-label {
  position: absolute;
  top: -18px;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
}

@media (min-width: 768px) {
  .size-compare-scene { height: 450px; }
}

/* ---- Size Compare Cards ---- */

.size-compare-cards {
  display: flex;
  gap: var(--spacing-sm);
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.sc-card {
  flex: 1;
  min-width: 72px;
  padding: var(--spacing-xs);
  border: 2px solid var(--color-input-border);
  border-radius: var(--radius-md);
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.5);
  transition: all var(--transition-fast);
}

.sc-card:hover {
  border-color: var(--color-text);
}

.sc-card.selected {
  border-color: var(--color-primary);
  background: rgba(243, 129, 129, 0.1);
}

.sc-thumb {
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.sc-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.sc-info {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-text);
}

.sc-price {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-top: 2px;
}

/* ---- Embedded mode (inside iframe on landing page) ---- */
html.embedded,
html.embedded body {
  background: transparent;
  overflow-x: hidden;
  min-height: 0;
}
html.embedded .progress-bar {
  display: none;
}
html.embedded .form-container {
  max-width: 100%;
  padding: 0;
}
html.embedded .step-content {
  padding: 0;
}
html.embedded .viewer-wrap {
  margin-bottom: 0;
  border-radius: 0;
}
html.embedded .viewer-container,
html.embedded #pillowViewer {
  border-radius: 0;
  margin-bottom: 0;
}
html.embedded .preview-layout {
  gap: 0;
}
html.embedded .buy-box {
  background: #fff;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-radius: 0;
  margin-top: 0;
  padding: 20px 16px 24px;
  box-shadow: none;
}
/* Kill all spacing so content sits flush and fills naturally */
html.embedded .form-container {
  padding: 0 !important;
  margin: 0 !important;
  max-width: 100% !important;
  min-height: 0 !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
}
html.embedded .step-content {
  padding: 0 !important;
  margin: 0 !important;
}
/* Loading overlay fills the iframe seamlessly */
html.embedded .loading-overlay {
  border-radius: 0;
}

/* ==================== QUANTITY UPSELL ==================== */
.qty-upsell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: rgba(243, 129, 129, 0.06);
  border-radius: 12px;
  border: 1px solid rgba(243, 129, 129, 0.12);
}

.qty-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.qty-label {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-text);
}

.qty-save {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--color-primary);
  transition: opacity 0.2s, color 0.2s;
}

.qty-selector {
  display: flex;
  align-items: center;
  gap: 12px;
}

.qty-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--color-input-border);
  background: #fff;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-family);
  padding: 0;
  line-height: 1;
}

.qty-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.qty-value {
  font-size: 1rem;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

/* ==================== BUNDLE UPSELL ==================== */
.bundle-upsell {
  margin-bottom: 14px;
}

.bundle-header {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bundle-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 10px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.bundle-item:hover {
  border-color: rgba(243, 129, 129, 0.3);
  background: rgba(243, 129, 129, 0.04);
}

.bundle-check {
  accent-color: var(--color-primary);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.bundle-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: 1;
}

.bundle-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text);
}

.bundle-price {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--color-text-light);
}

/* ==================== GUARANTEE ROW ==================== */
.guarantee-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  padding: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #4CAF50;
  background: rgba(76, 175, 80, 0.06);
  border-radius: 10px;
}

.guarantee-row svg {
  flex-shrink: 0;
}

/* ==================== PRE-CHECKOUT UPSELL OVERLAY ==================== */
.checkout-upsell-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.checkout-upsell-overlay.hidden {
  display: none;
}

.checkout-upsell-card {
  background: #fff;
  width: 100%;
  max-width: 420px;
  border-radius: 20px;
  padding: 28px 24px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  max-height: 90dvh;
  overflow-y: auto;
}

.cu-title {
  font-size: 1.25rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 20px;
  color: var(--color-text);
}

.cu-shipping-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.cu-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 2px solid #e8e8e8;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.cu-option.selected,
.cu-option:has(input:checked) {
  border-color: var(--color-primary);
  background: rgba(243, 129, 129, 0.04);
}

.cu-option input[type="radio"] {
  accent-color: var(--color-primary);
  margin-top: 2px;
  flex-shrink: 0;
}

.cu-option-content {
  flex: 1;
}

.cu-option-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.cu-option-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
}

.cu-option-badge {
  font-size: 0.625rem;
  font-weight: 800;
  color: #fff;
  background: var(--color-primary);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cu-option-price {
  font-size: 0.8125rem;
  color: var(--color-text-light);
}

.cu-addons {
  margin-bottom: 16px;
}

.cu-addon {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(76, 175, 80, 0.04);
  border: 1px solid rgba(76, 175, 80, 0.15);
  border-radius: 10px;
  cursor: pointer;
}

.cu-addon input[type="checkbox"] {
  accent-color: #4CAF50;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.cu-addon-content {
  display: flex;
  justify-content: space-between;
  flex: 1;
}

.cu-addon-name {
  font-size: 0.8125rem;
  font-weight: 600;
}

.cu-addon-price {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--color-text-light);
}

.cu-summary {
  border-top: 1px solid #e8e8e8;
  padding-top: 12px;
  margin-bottom: 16px;
}

.cu-summary-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--color-text-light);
  margin-bottom: 6px;
}

.cu-summary-total {
  display: flex;
  justify-content: space-between;
  font-size: 1rem;
  font-weight: 800;
  color: var(--color-text);
  padding-top: 8px;
  border-top: 1px solid #e8e8e8;
  margin-top: 8px;
}

.cu-checkout-btn {
  width: 100%;
  padding: 16px;
  background: var(--color-primary);
  color: #fff;
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 8px;
}

.cu-checkout-btn:hover {
  background: var(--color-primary-hover);
}

.cu-skip {
  width: 100%;
  padding: 10px;
  background: none;
  border: none;
  font-family: var(--font-family);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cu-skip:hover {
  color: var(--color-text);
}
