
@theme inline {
  --font-sans: var(--font-body);
  --font-serif: var(--font-brand);
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-primary: var(--primary);
  --color-primary-foreground: var(--primary-foreground);
  --color-muted: var(--muted);
  --color-muted-foreground: var(--muted-foreground);
  --color-border: var(--border);
  --color-stage: var(--stage);
  --color-surface: var(--surface);
  --color-gold: var(--gold);
  --color-gold-deep: var(--gold-deep);
}

:root {
  --font-body: "Manrope", sans-serif;
  --font-brand: "Cormorant Garamond", serif;
  --background: oklch(0.965 0.003 90);
  --foreground: oklch(0.245 0.045 254);
  --primary: oklch(0.245 0.055 250);
  --primary-foreground: oklch(0.99 0 0);
  --muted: oklch(0.955 0.006 255);
  --muted-foreground: oklch(0.45 0.025 250);
  --border: oklch(0.89 0.012 255);
  --stage: oklch(0.955 0 0);
  --surface: oklch(1 0 0);
  --gold: oklch(0.78 0.14 78);
  --gold-deep: oklch(0.58 0.11 63);
  --navy: oklch(0.3 0.08 258);
  --shadow-soft: 0 5px 18px oklch(0.22 0.025 250 / 0.12);
  --shadow-control: 0 2px 8px oklch(0.22 0.025 250 / 0.14);
}

@layer base {
  * { box-sizing: border-box; }
  html { background: var(--background); }
  body {
    margin: 0;
    background: var(--background);
    color: var(--foreground);
    font-family: var(--font-body);
  }
  button { font: inherit; }
}

.app-background {
  min-height: 100svh;
  background: var(--background);
}

.phone-shell {
  width: min(100%, 440px);
  min-height: 100svh;
  margin-inline: auto;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.preview-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  min-height: 80px;
  padding: 10px 14px 6px;
  background: var(--surface);
}

.header-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  justify-self: start;
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
}

.header-icon svg { width: 27px; height: 27px; stroke-width: 1.8; }
.header-actions { display: flex; align-items: center; justify-self: end; }

.brand-lockup {
  position: relative;
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 9px;
  justify-self: center;
  padding-bottom: 10px;
}

.brand-lockup::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 30px;
  height: 1px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, var(--gold-deep), transparent);
}

.brand-logo-slot {
  display: flex;
  align-items: center;
  color: var(--gold-deep);
}

.brand-logo-slot:empty { display: none; }
.brand-logo-slot img:not(.brand-logo-image) { display: block; width: auto; height: 26px; }
.brand-logo-image { width: clamp(138px, 38vw, 168px); height: clamp(43px, 12vw, 52px); object-fit: contain; object-position: center; }
.brand-name--hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.brand-name {
  min-width: 0;
  color: var(--primary);
  font-family: var(--font-brand);
  font-size: clamp(15px, 4.4vw, 19px);
  font-weight: 600;
  letter-spacing: 0.28em;
  line-height: 1;
  overflow: hidden;
  padding-left: 0.28em;
  text-align: center;
  text-transform: uppercase;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 52px;
  margin: 0 14px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-control);
  position: relative;
  z-index: 4;
}

.mode-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  transition: background-color 180ms ease, color 180ms ease;
}

.mode-tab svg { width: 25px; height: 25px; stroke-width: 1.7; }
.mode-tab[data-active="true"] { background: var(--primary); color: var(--primary-foreground); }

.stage-shell {
  position: relative;
  height: 500px;
  margin-top: -1px;
  isolation: isolate;
}

.stage-shell[data-mode="try-on"] { height: calc(100svh - 132px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); min-height: 540px; }

.try-on-signature {
  position: absolute;
  z-index: 2;
  top: 22px;
  left: 50%;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transform: translateX(-50%);
  color: var(--navy);
  pointer-events: none;
}
.stage-shell[data-mode="try-on"] .try-on-signature { display: flex; }

.try-on-signature strong {
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}
.try-on-signature strong span { color: var(--gold-deep); }
.try-on-signature small { font-size: 6px; font-weight: 600; letter-spacing: 0.18em; opacity: 0.58; }

.preview-slot {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  background: var(--stage);
}

.preview-slot.try-frame {
  border: 0;
  display: block;
  background: #000;
}
.stage-shell[data-mode="3d"] .preview-slot.try-frame,
.stage-shell[data-mode="try-on"] #jpHost { display: none !important; }
.stage-shell[data-mode="try-on"] .preview-slot.try-frame { display: block; }
.stage-shell[data-mode="3d"] .camera-controls,
.stage-shell[data-mode="3d"] .tool-try-on { display: none !important; }
.stage-shell[data-mode="try-on"] .spin-caption,
.stage-shell[data-mode="try-on"] .tool-3d { display: none !important; }
.stage-shell[data-mode="try-on"] ~ .product-controls { display: none !important; }

.stage-tools {
  position: absolute;
  z-index: 2;
  top: 26px;
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}

.tool-button {
  display: flex;
  width: 50px;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font-size: 9px;
  font-weight: 500;
}

.tool-button__icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-control);
}

.tool-button__icon svg { width: 17px; height: 17px; stroke-width: 2; }

.spin-caption {
  position: absolute;
  z-index: 2;
  bottom: 10px;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 230px;
  transform: translateX(-50%);
  color: var(--navy);
  font-size: 12px;
  pointer-events: auto;
}

.spin-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  height: 21px;
}

.spin-mark svg {
  width: 24px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.62;
}

.spin-mark strong {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
}

.spin-mark strong span {
  margin-left: 1px;
  font-size: 13px;
  vertical-align: top;
}

.spin-caption__text {
  font-size: 9px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.1em;
  opacity: 0.72;
}

.spin-caption__dot {
  width: 3px;
  height: 3px;
  margin-top: -1px;
  border-radius: 50%;
  background: var(--navy);
  opacity: 0.2;
}

.camera-controls {
  position: absolute;
  z-index: 2;
  right: 18px;
  bottom: 24px;
  left: 18px;
  display: none;
  grid-template-columns: 1fr 90px 1fr;
  align-items: center;
  pointer-events: auto;
}
.stage-shell[data-mode="try-on"] .camera-controls { display: grid; }

.camera-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-self: center;
  gap: 6px;
  min-width: 64px;
  min-height: 58px;
  padding: 8px 6px;
  border: 0;
  border-radius: 8px;
  background: color-mix(in oklch, var(--surface) 88%, transparent);
  color: var(--primary);
  cursor: pointer;
  font-size: 9px;
  font-weight: 600;
  line-height: 1.15;
  box-shadow: var(--shadow-control);
  backdrop-filter: blur(8px);
}

.camera-side svg { width: 20px; height: 20px; stroke-width: 1.7; }

.shutter {
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  justify-self: center;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--navy);
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--navy), var(--shadow-control);
}

.shutter span { width: 50px; height: 50px; border: 1px solid var(--gold-deep); border-radius: 50%; background: var(--surface); }

.product-controls { padding: 12px 14px 18px; background: var(--surface); }

.swatch-panel {
  --swatch-size: clamp(30px, 9vw, 38px);
  --swatch-gap: clamp(6px, 2vw, 11px);
  display: grid;
  grid-template-columns: max-content 1px minmax(0, 1fr);
  gap: clamp(8px, 2.5vw, 12px);
  padding: 12px;
  border-radius: 13px;
  box-shadow: var(--shadow-control);
}

.swatch-group { min-width: 0; }
.swatch-group strong { display: block; margin-bottom: 8px; font-size: 12px; }
.swatch-divider { width: 1px; background: var(--border); }
.swatch-row { display: flex; min-width: 0; align-items: center; justify-content: flex-start; gap: var(--swatch-gap); }

.swatch {
  position: relative;
  width: var(--swatch-size);
  height: var(--swatch-size);
  flex: 0 0 var(--swatch-size);
  border: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 25%, oklch(1 0 0 / 0.8) 0 10%, transparent 32%),
    conic-gradient(from 210deg, var(--m1), var(--m2), var(--m1), var(--m2), var(--m1));
  box-shadow:
    inset 0 0 0 1px oklch(1 0 0 / 0.55),
    inset 0 -3px 5px oklch(0 0 0 / 0.16),
    inset 0 2px 4px oklch(1 0 0 / 0.4),
    0 1px 3px oklch(0 0 0 / 0.14);
  cursor: pointer;
}

.swatch[data-selected="true"]::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 1.5px solid var(--navy);
  border-radius: 50%;
}

.swatch-yellow { --m1: oklch(0.91 0.11 92); --m2: oklch(0.66 0.15 72); }
.swatch-white { --m1: oklch(0.99 0 0); --m2: oklch(0.8 0.012 250); }
.swatch-rose { --m1: oklch(0.92 0.07 45); --m2: oklch(0.68 0.11 33); }

/* Real gemstone photos: faceted round brilliant, top view */
.stone {
  width: var(--swatch-size);
  height: var(--swatch-size);
  flex-basis: var(--swatch-size);
  border-radius: 50%;
  background: none;
  border: 0;
  box-shadow: none;
  filter: drop-shadow(0 1.5px 2px oklch(0 0 0 / 0.28));
  transition: transform 0.15s ease, filter 0.15s ease;
}
.stone::before {
  content: none;
}
/* selected stone: thin navy ring hugging the gem */
.stone[data-selected="true"]::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 1.5px solid var(--navy);
  border-radius: 50%;
}
.stone img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  /* the gem photos carry ~23% transparent padding: scale up so the
     visible stone matches the metal circles' diameter */
  transform: scale(1.3);
  pointer-events: none;
  user-select: none;
}
.stone[data-selected="true"] {
  transform: scale(1.06);
  filter: drop-shadow(0 1.5px 2.5px oklch(0 0 0 / 0.32));
}

.thumbnail-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.thumbnail { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.thumbnail-frame { position: relative; width: 100%; aspect-ratio: 1; overflow: hidden; border: 1px solid var(--border); border-radius: 9px; background: var(--stage); }
.thumbnail[data-selected="true"] .thumbnail-frame { border: 2px solid var(--navy); }
.thumbnail-image { position: absolute; width: 200%; height: 200%; max-width: none; object-fit: cover; }
.thumbnail-image-0 { top: 0; left: 0; }
.thumbnail-image-1 { top: 0; left: -100%; }
.thumbnail-image-2 { top: -100%; left: 0; }
.thumbnail-image-3 { top: -100%; left: -100%; }
.thumbnail-angle { color: var(--muted-foreground); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; }
.thumbnail[data-selected="true"] .thumbnail-angle { color: var(--navy); }

.save-row { display: flex; justify-content: flex-end; margin-top: 14px; }
.save-button { display: grid; width: 46px; height: 46px; place-items: center; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--primary); box-shadow: var(--shadow-control); cursor: pointer; transition: color 180ms ease, border-color 180ms ease; }
.save-button svg { width: 22px; height: 22px; stroke-width: 1.7; }
.save-button[data-saved="true"] { border-color: var(--gold-deep); color: var(--gold-deep); }
.save-button[data-saved="true"] svg { fill: currentColor; }

@media (max-width: 380px) {
  .preview-header { padding-inline: 8px; }
  .brand-name { letter-spacing: 0.2em; }
  .mode-tabs { margin-inline: 10px; }
  .stage-shell { height: 440px; }
  .product-controls { padding-inline: 10px; }
  .swatch-panel { padding-inline: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
