/* =========================================================================
   Invengic Studio — visual system (docs/VISUAL_RESTRUCTURE_PROMPT.json)
   Warm, crafted, honest: birch & kraft surfaces, char ink, ember action,
   burn-brown engraving. Every id/class/data-attribute the JS uses is kept
   (docs/UI_MAP.md); this file only changes how things look.
   ========================================================================= */

/* ----------------------------------------------------------------- tokens */
:root {
  --birch: #f7f0e3;
  --paper: #fffbf4;
  --kraft: #e8d5b5;
  --kraft-soft: #f0e4cf;
  --line: #e2d3bc;
  --line-strong: #cdb896;
  --char: #1f1410;
  --walnut: #6b4226;
  --smoke: #6f645b;
  --burn: #3a2317;
  --ember: #ff5b1f;
  --ember-press: #e84c12;
  --ember-deep: #c2410c;
  --beam: #3346ff;
  --leaf: #25683f;
  --wood: #e8c898;
  /* Assumed: tuned toward the product photos; check against a real blank. */
  --wood-light: #dcb685;
  --wood-grain: #9c6a3f;
  --wood-edge: #b88b5a;
  --white: #ffffff;
  --danger: #b42318;
  --danger-soft: #fbe9e5;
  --leaf-soft: #e7f3ea;
  --leaf-light: #8fd3a5;
  --warn: #5a3a12;

  --font-display: "Bricolage Grotesque", "Anek Latin", system-ui, sans-serif;
  --font-ui: "Anek Latin", system-ui, -apple-system, "Segoe UI", sans-serif;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-pill: 999px;

  --on-char-soft: rgba(247, 240, 227, 0.86);
  --on-char-muted: rgba(247, 240, 227, 0.72);
  --on-char-faint: rgba(247, 240, 227, 0.6);
  --on-char-line: rgba(247, 240, 227, 0.14);
  --on-char-fill: rgba(247, 240, 227, 0.08);
  --scrim: rgba(31, 20, 16, 0.55);
  --scrim-strong: rgba(31, 20, 16, 0.72);
  --focus-glow: rgba(255, 91, 31, 0.25);
  --paper-veil: rgba(255, 251, 244, 0.35);
  --piece-shadow: rgba(58, 35, 23, 0.22);

  --shadow-card: 0 1px 0 rgba(31, 20, 16, 0.06), 0 10px 26px -14px rgba(31, 20, 16, 0.28);
  --shadow-tab: 0 1px 0 rgba(31, 20, 16, 0.1), 0 4px 10px -6px rgba(31, 20, 16, 0.4);
  --shadow-bar: 0 -10px 24px -18px rgba(31, 20, 16, 0.35);
  --shadow-lift: 0 2px 0 rgba(31, 20, 16, 0.08), 0 22px 44px -20px rgba(31, 20, 16, 0.38);
  --stamp: 0 2px 0 var(--char);

  --header-h: 60px;
  --gutter: 16px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  /* Legacy names some inline styles still use. */
  --radius-md: var(--r-md);
  --radius-lg: var(--r-lg);
}

/* ------------------------------------------------------------------- base */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 12px);
}

html,
body {
  background: var(--birch);
  color: var(--char);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* clip, not hidden: hidden would make <body> a scroll container and
   break the sticky preview and the sticky price bar. */
body {
  min-height: 100svh;
  overflow-x: clip;
}

img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
}

a {
  color: var(--ember-deep);
}

:focus-visible {
  outline: 2px solid var(--char);
  outline-offset: 2px;
  border-radius: 6px;
}

.app-footer :focus-visible,
.camera-box :focus-visible,
.success-banner-card :focus-visible {
  outline-color: var(--birch);
}

::selection {
  background: var(--ember);
  color: var(--char);
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------------------------------------------------------------- screens */
.screen {
  display: none;
  min-height: 100svh;
  padding-top: var(--header-h);
}

.screen.active {
  display: block;
  animation: screen-in 0.28s var(--ease);
}

@keyframes screen-in {
  from {
    opacity: 0;
  }
}

/* Wood-grain pattern source (index.html). Not display:none: some engines
   drop paint servers that live in an undisplayed <svg>. */
.studio-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.wood-base {
  fill: var(--wood-light);
}

.wood-band {
  fill: var(--wood-grain);
  opacity: 0.1;
}

.wood-grain {
  fill: none;
  stroke: var(--wood-grain);
  stroke-width: 0.3;
  opacity: 0.55;
}

.wood-grain-faint {
  stroke-width: 0.18;
  opacity: 0.4;
}

.wood-grain-bold {
  stroke-width: 0.5;
  opacity: 0.45;
}

/* ----------------------------------------------------------------- header */
.app-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 var(--gutter);
  background: var(--birch);
  border-bottom: 1px solid var(--line);
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--char);
  text-decoration: none;
  flex-shrink: 0;
}

.brand-mark {
  width: 17px;
  height: 36px;
  flex-shrink: 0;
}

.brand-text {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}

.brand-word {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.03em;
  line-height: 1;
}

.brand-sub {
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  color: var(--walnut);
}

.footer-logo .brand-sub {
  color: var(--kraft);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.user-auth-bar {
  display: flex;
  align-items: center;
}

.header-auth-btn,
.header-help-btn,
.cart-nav-btn,
.home-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  min-width: 40px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  color: var(--char);
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease);
}

.header-auth-btn:hover,
.header-help-btn:hover,
.cart-nav-btn:hover,
.home-btn:hover {
  background: var(--kraft-soft);
}

.cart-nav-btn {
  border-color: var(--line-strong);
  background: var(--paper);
}

.cart-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--ember);
  color: var(--char);
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 4px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--paper);
  font-size: 14px;
  font-weight: 600;
}

.user-logout-btn {
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--walnut);
}

.user-logout-btn:hover {
  background: var(--kraft-soft);
}

/* On phones the header keeps icons only, so nothing wraps or overflows. */
@media (max-width: 719px) {
  .header-auth-btn span,
  .header-help-btn span,
  .cart-nav-btn > span:not(.cart-badge),
  .home-btn span {
    display: none;
  }

  .header-auth-btn,
  .header-help-btn,
  .home-btn {
    padding: 0;
    width: 40px;
  }

  .cart-nav-btn {
    padding: 0 10px;
  }

  .user-phone-tag {
    display: none;
  }

}

@media (max-width: 389px) {
  .brand-sub {
    display: none;
  }
}

body[data-screen="welcome"] .home-btn {
  display: none;
}

/* #btn-header-help has no JS listener (the help modal cannot open), so the
   dead button is not shown. Flagged in docs/UI_MAP.md. */
.header-help-btn {
  display: none;
}

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 22px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--char);
  font-family: var(--font-ui);
  font-size: 17px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s var(--ease), box-shadow 0.12s var(--ease), background 0.18s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: var(--ember);
  color: var(--char);
  box-shadow: var(--stamp);
}

.btn-primary:hover {
  background: var(--ember-press);
}

.btn-secondary {
  background: var(--paper);
  color: var(--char);
  border-color: var(--wood-edge);
}

.btn-secondary:hover {
  background: var(--kraft-soft);
  border-color: var(--walnut);
}

.btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 0 0 var(--char);
}

.btn:disabled {
  cursor: not-allowed;
  background: var(--kraft-soft);
  color: var(--smoke);
  border-color: var(--line-strong);
  box-shadow: none;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  min-height: 40px;
  padding: 0 14px;
  font-size: 15px;
}

.btn-arrow {
  flex-shrink: 0;
}

/* ------------------------------------------------------------------ welcome */
.welcome-wrapper {
  display: flex;
  flex-direction: column;
}

.hero-canvas {
  position: relative;
  display: grid;
  gap: 28px;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px var(--gutter) 40px;
}

.canvas-grid-bg {
  display: none;
}

.welcome-container {
  max-width: 560px;
}

.welcome-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--paper);
  font-size: 13px;
  font-weight: 600;
  color: var(--walnut);
}

.welcome-label-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ember);
}

.welcome-title {
  font-size: clamp(40px, min(11vw, 13svh), 72px);
  font-weight: 800;
  line-height: 0.98;
  letter-spacing: -0.035em;
  color: var(--char);
  text-wrap: balance;
}

.title-accent {
  color: var(--walnut);
  text-decoration: underline;
  text-decoration-color: var(--ember);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.1em;
}

.welcome-sub {
  margin-top: 16px;
  max-width: 440px;
  font-size: clamp(17px, 4.4vw, 20px);
  line-height: 1.45;
  color: var(--walnut);
}

.welcome-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  margin-top: 26px;
}

.welcome-actions .btn {
  min-height: 56px;
  padding: 0 26px;
  font-size: 18px;
}

.hero-scroll-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  font-size: 15px;
  font-weight: 600;
  color: var(--walnut);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 4px;
}

.hero-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 22px;
  padding: 0;
  list-style: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--smoke);
}

.hero-facts li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hero-facts li::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--wood-edge);
}

/* The keychain gallery: real pieces, no floating. */
.hero-samples-composition {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.hero-sample-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-height: 200px;
  padding: 14px 10px 12px;
  border-radius: var(--r-lg);
  background: var(--kraft-soft);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.hero-sample-item:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-card);
}

.hero-sample-item:focus-visible {
  outline: 2px solid var(--char);
  outline-offset: 3px;
}

.sample-image-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.sample-png {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 150px;
  object-fit: contain;
}

.sample-pos-br .sample-png {
  max-height: 110px;
}

.sample-glow {
  display: none;
}

.sample-badge {
  font-size: 13px;
  font-weight: 600;
  color: var(--walnut);
  text-align: center;
}

.sample-dimmed {
  opacity: 1;
}

/* ------------------------------------------------------------ how it works */
.how-section {
  padding: 8px var(--gutter) 56px;
}

.how-container {
  max-width: 1180px;
  margin: 0 auto;
}

.how-title {
  font-size: clamp(26px, 6vw, 40px);
  font-weight: 800;
  margin-bottom: 20px;
}

.how-steps {
  list-style: none;
  display: grid;
  gap: 0;
}

.how-step {
  position: relative;
  display: grid;
  grid-template-columns: 40px 1fr;
  column-gap: 14px;
  padding-bottom: 22px;
}

/* The toolpath: a dashed burn line from one step to the next. */
.how-step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 19px;
  top: 40px;
  bottom: 0;
  border-left: 2px dashed var(--wood-edge);
}

.how-num {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--char);
  color: var(--birch);
  font-family: var(--font-display);
  font-weight: 800;
}

.how-step h3 {
  align-self: center;
  font-size: 20px;
  font-weight: 700;
}

.how-step p {
  margin-top: 2px;
  color: var(--walnut);
}

@media (min-width: 720px) {
  .how-steps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
  }

  .how-step {
    grid-template-columns: 1fr;
    row-gap: 10px;
    padding-bottom: 0;
  }

  .how-num {
    grid-row: auto;
  }

  .how-step:not(:last-child)::before {
    left: 52px;
    right: -16px;
    top: 19px;
    bottom: auto;
    border-left: 0;
    border-top: 2px dashed var(--wood-edge);
  }
}

/* ------------------------------------------------------------- testimonial */
.testimonial-section {
  padding: 8px var(--gutter) 56px;
}

.testimonial-container {
  max-width: 820px;
  margin: 0 auto;
}

.testimonial-ambient-glow,
.testimonial-quote-mark {
  display: none;
}

.testimonial-card {
  position: relative;
  padding: 32px 24px;
  border-radius: var(--r-lg);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}

.testimonial-section.in-view .testimonial-card,
.testimonial-card.in-view,
.in-view .testimonial-card {
  opacity: 1;
  transform: none;
}

.testimonial-rating {
  display: flex;
  gap: 2px;
  color: var(--ember-deep);
  font-size: 18px;
  margin-bottom: 14px;
}

.testimonial-quote {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(22px, 5.6vw, 34px);
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--char);
}

.testimonial-accent {
  color: var(--walnut);
}

.desktop-br {
  display: none;
}

.testimonial-author {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
}

.author-avatar-wrap {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--kraft);
  color: var(--walnut);
}

.author-info {
  display: flex;
  flex-direction: column;
  font-size: 14px;
  line-height: 1.3;
}

.author-name {
  font-weight: 600;
}

.author-brand {
  color: var(--smoke);
}

/* ------------------------------------------------------------------ footer */
.app-footer {
  background: var(--char);
  color: var(--birch);
  padding: 44px var(--gutter) 28px;
}

.footer-container {
  max-width: 1120px;
  margin: 0 auto;
}

.footer-grid {
  display: grid;
  gap: 28px;
}

.footer-logo {
  color: var(--birch);
}

.footer-desc {
  margin-top: 12px;
  max-width: 360px;
  font-size: 15px;
  color: var(--on-char-muted);
}

.footer-status-pill {
  display: none;
}

.footer-col-title {
  margin-bottom: 4px;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  color: var(--on-char-faint);
}

.footer-links {
  list-style: none;
  display: grid;
}

.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--birch);
  text-decoration: none;
  font-size: 15px;
}

.footer-links a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer-trust-badges {
  display: grid;
  gap: 8px;
  font-size: 15px;
  color: var(--on-char-soft);
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--on-char-line);
  font-size: 13px;
  color: var(--on-char-faint);
}

.footer-bottom-meta {
  display: flex;
  gap: 8px;
}

/* ------------------------------------------------------------ studio screen */
.create-container {
  max-width: 1180px;
  padding-top: 12px;
  padding-bottom: 32px;
}

.configurator-grid {
  display: grid;
  gap: 16px;
}

.preview-column {
  position: sticky;
  top: var(--header-h);
  z-index: 5;
  margin: 0 calc(var(--gutter) * -1);
  padding: 8px var(--gutter) 10px;
  background: var(--birch);
}

.preview-box {
  position: relative;
  padding: 14px 16px 12px;
  border-radius: var(--r-lg);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  text-align: center;
}

.preview-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preview-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--walnut);
}

.preview-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ember);
}

.keychain-preview {
  width: 100%;
  max-width: 420px;
  margin: 6px auto 0;
}

.keychain-svg {
  width: 100%;
  height: auto;
  max-height: 26svh;
  display: block;
  margin: 0 auto;
  overflow: visible;
  filter: drop-shadow(0 10px 12px var(--piece-shadow));
}

/* The blank: wood-grain fill inside the engraved border (outlineSvg from
   keychain-layout.js; geometry untouched, only paint). The hole is the
   only r="2.5" circle; the circle blank's outline is r="23". */
.keychain-svg rect,
.keychain-svg circle,
.keychain-svg path {
  fill: url(#studio-wood);
  stroke: var(--burn);
  stroke-width: 0.45;
}

.keychain-svg circle[r="2.5"] {
  fill: var(--paper);
  stroke: var(--burn);
  stroke-width: 0.35;
}

/* Engraving: burn-brown outline, as the laser traces it. */
.keychain-svg text#keychain-text,
.preview-box[data-material] .keychain-svg text#keychain-text {
  fill: none;
  stroke: var(--burn);
  stroke-width: 0.26;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.keychain-svg text#keychain-text.dragging {
  cursor: grabbing !important;
}

/* Dimension annotations stay hidden in the product view. */
.preview-box.view-product line,
.preview-box.view-product text:not(#keychain-text) {
  opacity: 0;
}

.preview-box.view-technical .keychain-svg rect,
.preview-box.view-technical .keychain-svg circle,
.preview-box.view-technical .keychain-svg path {
  fill: none !important;
  stroke: var(--char) !important;
}

.preview-hint {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--smoke);
}

/* Image preview. JS sets an inline aspect-ratio (viewBoxW / viewBoxH) and
   places #img-canvas in % of this box, so the box keeps its ratio: no
   height or max-height here, only a width cap. */
.img-keychain {
  position: relative;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 72 / 35;
  margin: 6px auto 0;
}

.img-keychain.has-image {
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.img-keychain.has-image:active,
.img-keychain.has-image.dragging {
  cursor: grabbing;
}

.img-canvas {
  position: absolute;
  display: none;
  pointer-events: none;
  /* The display copy is white = burn on transparent. Partial invert turns
     white into a dark grey, sepia + saturate make it burn-brown; the wood
     overlay above multiplies onto it. Display only: the print bitmap is
     imageProcessor.canvas, which CSS never touches. */
  filter: invert(0.78) sepia(1) saturate(2.2);
}

.img-keychain.has-image .img-canvas {
  display: block;
}

.img-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* The overlay sits above the canvas. Its wood fill is multiplied, so the
   burn pixels underneath show through as dark brown on wood. */
.img-overlay {
  mix-blend-mode: multiply;
}

.img-overlay rect,
.img-overlay circle,
.img-overlay path {
  fill: url(#studio-wood);
  stroke: var(--burn);
  stroke-width: 0.35;
}

/* White is neutral under multiply: the hole shows the card behind it. */
.img-overlay circle[r="2.5"] {
  fill: var(--white);
}

.img-overlay line,
.img-overlay text {
  display: none;
}

.img-dropzone {
  position: absolute;
  inset: 8%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: var(--r-md);
  color: var(--burn);
  cursor: pointer;
  text-align: center;
  transition: background 0.18s var(--ease);
}

.img-dropzone:hover {
  background: var(--paper-veil);
}

.img-dropzone-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--char);
}

.img-dropzone-hint {
  font-size: 12px;
}

.img-keychain.has-image .img-dropzone {
  display: none;
}

.configurator-grid:has(.shape-card.selected[data-shape-id="heart"]) .img-dropzone {
  inset: 34% 22% 20%;
}

.configurator-grid:has(.shape-card.selected[data-shape-id="circle"]) .img-dropzone {
  inset: 32% 20% 18%;
}

.configurator-grid:has(.shape-card.selected:not([data-shape-id="rectangle"])) .img-dropzone-hint {
  display: none;
}

/* Controls */
.controls-column {
  display: grid;
  gap: 18px;
}

.create-section {
  display: grid;
  gap: 10px;
}

.create-section-label,
.font-picker-label,
.input-label-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--char);
}

.create-section-label {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

.step-num {
  display: none;
}

.create-section-label::before {
  counter-increment: studio-step;
  content: counter(studio-step);
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--char);
  color: var(--birch);
  font-size: 12px;
  letter-spacing: 0;
}

.controls-column {
  counter-reset: studio-step;
}

.shape-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.shape-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 92px;
  padding: 12px 6px 10px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--line-strong);
  background: var(--paper);
  color: var(--walnut);
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease), transform 0.12s var(--ease);
}

.shape-card:hover {
  border-color: var(--walnut);
}

.shape-card.selected {
  border-color: var(--char);
  background: var(--kraft-soft);
  color: var(--char);
  box-shadow: var(--stamp);
}

.shape-card-icon {
  display: grid;
  place-items: center;
  height: 32px;
}

.shape-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--char);
}

.shape-card-desc {
  font-size: 12px;
  color: var(--smoke);
  font-variant-numeric: tabular-nums;
}

.mode-segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-md);
  background: var(--kraft-soft);
  border: 1px solid var(--line);
}

.mode-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 6px 10px;
  border-radius: 10px;
  color: var(--walnut);
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}

.mode-tab.active {
  background: var(--paper);
  color: var(--char);
  box-shadow: var(--shadow-tab);
}

.mode-tab-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}

.mode-tab-title {
  font-size: 15px;
  font-weight: 600;
}

.mode-tab-sub {
  display: none;
}

.mode-panel {
  display: grid;
  gap: 16px;
}

.input-group {
  display: grid;
  gap: 8px;
}

.input-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-center-text {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--walnut);
  font-size: 13px;
  font-weight: 600;
}

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

#name-input {
  width: 100%;
  height: 58px;
  padding: 0 16px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--smoke);
  background: var(--paper);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--char);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

#name-input::placeholder {
  font-family: var(--font-ui);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--smoke);
}

#name-input:focus {
  outline: none;
  border-color: var(--char);
  box-shadow: 0 0 0 3px var(--focus-glow);
}

.input-sub-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--smoke);
}

.drag-text-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.char-count {
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.emoji-section {
  display: grid;
  gap: 8px;
}

.emoji-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: start;
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--paper);
  font-size: 15px;
  font-weight: 600;
  color: var(--char);
}

.emoji-toggle-icon {
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  color: var(--walnut);
}

.emoji-toggle[aria-expanded="true"] {
  background: var(--kraft-soft);
  border-color: var(--walnut);
}

.emoji-panel {
  display: grid;
  gap: 12px;
  max-height: 260px;
  overflow-y: auto;
  padding: 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--paper);
}

.emoji-cat-name {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--smoke);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 4px;
}

.emoji-btn {
  display: grid;
  place-items: center;
  height: 44px;
  border-radius: 10px;
  font-size: 20px;
  font-family: "Noto Emoji", system-ui, sans-serif;
  color: var(--burn);
}

.emoji-btn:hover {
  background: var(--kraft-soft);
}

.font-picker {
  display: grid;
  gap: 10px;
}

.font-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px var(--gutter) 6px;
  margin: 0 calc(var(--gutter) * -1);
  scroll-padding-inline: var(--gutter);
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.font-chip {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 96px;
  padding: 10px 12px 8px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--line-strong);
  background: var(--paper);
  scroll-snap-align: start;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}

.font-chip:hover {
  border-color: var(--walnut);
}

.font-chip.selected {
  border-color: var(--char);
  background: var(--kraft-soft);
  box-shadow: var(--stamp);
}

.font-chip-text {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  line-height: 1.4;
  color: var(--burn);
}

.font-chip-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--smoke);
}

/* Sticky price + action bar */
.studio-bar {
  position: sticky;
  bottom: 0;
  z-index: 6;
  display: grid;
  gap: 10px;
  margin: 4px calc(var(--gutter) * -1) 0;
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: var(--birch);
  border-top: 1px solid var(--line);
}

.price-tag {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.price-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--char);
}

.price-subtitle {
  font-size: 13px;
  color: var(--smoke);
}

.price-right {
  display: flex;
  align-items: baseline;
  gap: 2px;
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--char);
  font-variant-numeric: tabular-nums;
}

.price-currency {
  font-size: 18px;
}

.price-amount {
  font-size: 28px;
  letter-spacing: -0.02em;
}

.configurator-actions {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 10px;
}

.configurator-actions .btn {
  min-height: 52px;
  padding: 0 14px;
}

/* Says why the actions are greyed out; shown only while they are. */
.studio-bar-hint {
  display: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--walnut);
}

.studio-bar:has(.btn-primary:disabled) .studio-bar-hint {
  display: block;
}

/* Image mode controls */
/* Labels never break mid-phrase; "Remove" drops to its own line when the
   row is too narrow for all three. */
.image-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.image-action-row .btn {
  flex: 1 1 130px;
  min-height: 48px;
  font-size: 16px;
  white-space: nowrap;
}

.image-action-row #remove-image {
  flex: 0 0 auto;
  margin-left: auto;
  border-color: transparent;
  background: none;
  box-shadow: none;
  color: var(--danger);
}

.img-error {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
}

.img-controls {
  display: grid;
  gap: 14px;
  padding: 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--paper);
}

.control-row {
  display: grid;
  gap: 6px;
}

.control-row > label {
  font-size: 14px;
  font-weight: 600;
  color: var(--walnut);
}

.control-row-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mode-chips-row {
  display: flex;
  gap: 6px;
}

.mode-chip {
  flex: 1;
  min-height: 40px;
  padding: 0 8px;
  border-radius: 10px;
  border: 1.5px solid var(--line-strong);
  background: var(--paper);
  font-size: 14px;
  font-weight: 600;
  color: var(--walnut);
}

.mode-chip.active {
  border-color: var(--char);
  background: var(--kraft-soft);
  color: var(--char);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--ember-deep);
}

input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--ember-deep);
}

.img-coverage {
  font-size: 13px;
  color: var(--smoke);
}

/* Block, not grid: a closed <details> in a grid still reserves a row. */
.img-adjust {
  display: block;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.img-adjust[open] > summary {
  margin-bottom: 12px;
}

.img-adjust > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  font-size: 15px;
  font-weight: 600;
  color: var(--char);
  cursor: pointer;
  list-style: none;
}

.img-adjust > summary::-webkit-details-marker {
  display: none;
}

.img-adjust > summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-right: 2px solid var(--walnut);
  border-bottom: 2px solid var(--walnut);
  transform: rotate(45deg) translateY(-3px);
  transition: transform 0.18s var(--ease);
}

.img-adjust[open] > summary::after {
  transform: rotate(-135deg) translateY(-2px);
}

.img-adjust .control-row + .control-row {
  margin-top: 14px;
}

#btn-reset-img-adjust {
  width: 100%;
}

/* ---------------------------------------------------------- payment screen */
#screen-payment .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100svh - var(--header-h));
  max-width: 480px;
  text-align: center;
  padding-bottom: 40px;
}

.loader-ring {
  width: 56px;
  height: 56px;
  margin-bottom: 22px;
  border-radius: 50%;
  border: 4px solid var(--kraft);
  border-top-color: var(--ember);
  animation: spin 0.9s linear infinite;
}

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

.section-title {
  font-size: clamp(26px, 7vw, 36px);
  font-weight: 800;
}

.payment-sub {
  margin-top: 10px;
  font-size: 17px;
  color: var(--walnut);
}

.payment-actions {
  display: grid;
  gap: 12px;
  width: 100%;
  max-width: 360px;
  margin-top: 28px;
}

#screen-payment .btn {
  width: 100%;
  min-height: 52px;
  padding: 10px 18px;
  line-height: 1.25;
}

/* ---------------------------------------------------------- success screen */
.success-dashboard-wrapper {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px var(--gutter) 40px;
  display: grid;
  gap: 14px;
}

.success-banner-card {
  display: grid;
  gap: 16px;
  padding: 22px 20px;
  border-radius: var(--r-lg);
  background: var(--char);
  color: var(--birch);
  box-shadow: var(--shadow-lift);
}

.banner-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.success-icon-ring {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
}

.checkmark-svg {
  width: 100%;
  height: 100%;
}

.checkmark-circle {
  fill: none;
  stroke: var(--leaf);
  stroke-width: 6;
}

.checkmark-tick {
  fill: none;
  stroke: var(--leaf-light);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 60;
  stroke-dashoffset: 60;
  animation: tick 0.5s 0.15s var(--ease) forwards;
}

@keyframes tick {
  to {
    stroke-dashoffset: 0;
  }
}

.success-title {
  font-size: clamp(24px, 6vw, 32px);
  font-weight: 800;
  color: var(--birch);
}

.success-sub {
  margin-top: 4px;
  font-size: 15px;
  color: var(--on-char-muted);
}

.queue-badge-box {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--on-char-fill);
  border: 1px solid var(--on-char-line);
}

.queue-badge-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--on-char-muted);
}

.queue-position-val {
  font-family: var(--font-display);
  font-size: clamp(40px, 12vw, 64px);
  font-weight: 800;
  line-height: 1;
  color: var(--ember);
  font-variant-numeric: tabular-nums;
}

.success-dashboard-grid {
  display: grid;
  gap: 14px;
}

.dashboard-card {
  padding: 20px;
  border-radius: var(--r-lg);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
}

.card-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.card-header-bar h3 {
  font-size: 19px;
  font-weight: 700;
}

.live-status-pill,
.info-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--kraft-soft);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--walnut);
  white-space: nowrap;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--leaf);
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.live-queue {
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--birch);
  border: 1px solid var(--line);
}

.live-queue-text {
  font-size: 15px;
  color: var(--char);
}

.live-queue-sub {
  margin-top: 4px;
  font-size: 14px;
  color: var(--walnut);
}

.live-queue.your-turn {
  background: var(--leaf-soft);
  border-color: var(--leaf);
}

.live-queue.your-turn .live-queue-text {
  color: var(--leaf);
  font-weight: 700;
}

.order-progress {
  display: grid;
  margin-top: 18px;
}

.progress-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.progress-step:not(.completed):not(.active) .progress-icon {
  opacity: 0.55;
}

.progress-step:not(.completed):not(.active) .progress-title {
  color: var(--smoke);
}

.progress-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--kraft-soft);
  border: 1.5px solid var(--line-strong);
  font-size: 15px;
  color: var(--walnut);
}

.progress-step.completed .progress-icon {
  background: var(--leaf);
  border-color: var(--leaf);
  color: var(--white);
}

.progress-step.active .progress-icon {
  background: var(--paper);
  border-color: var(--ember-deep);
}

.progress-title {
  font-size: 15px;
  font-weight: 600;
}

.progress-sub {
  font-size: 13px;
  color: var(--smoke);
}

.progress-line {
  width: 2px;
  height: 18px;
  margin: 4px 0 4px 16px;
  background: var(--line-strong);
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2.5px solid var(--kraft);
  border-top-color: var(--ember-deep);
  animation: spin 0.8s linear infinite;
}

.verify-banner {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--kraft-soft);
  font-size: 14px;
}

.tracker-action-row {
  margin-top: 18px;
}

.btn-notify {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  border-radius: var(--r-md);
  border: 1.5px dashed var(--line-strong);
  font-size: 15px;
  font-weight: 600;
  color: var(--walnut);
}

.btn-notify.enabled {
  border-style: solid;
  border-color: var(--leaf);
  color: var(--leaf);
}

.info-preview-box {
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--birch);
  border: 1px solid var(--line);
}

.info-wood-chip {
  display: inline-block;
  margin-bottom: 8px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--kraft);
  font-size: 12px;
  font-weight: 600;
  color: var(--walnut);
}

.info-item-title {
  font-size: 18px;
  font-weight: 700;
}

.success-footer-text {
  margin-top: 4px;
  font-size: 14px;
  color: var(--walnut);
}

.info-details-table {
  display: grid;
  margin-top: 14px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.info-label {
  color: var(--smoke);
}

.info-val {
  font-weight: 600;
  text-align: right;
}

.status-green {
  color: var(--leaf);
}

.highlight-badge {
  color: var(--char);
}

.studio-pickup-note {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--kraft-soft);
  font-size: 14px;
  color: var(--walnut);
}

.note-icon {
  flex-shrink: 0;
  padding-top: 1px;
}

.btn-another {
  margin-top: 18px;
}

/* ------------------------------------------------------ modals (auth, help) */
/* Stack (same order as before): header 50 < cart overlay 1000 < drawer
   1001 < camera 1050 < crop = auth/help 1060 < toast 1100. */
.phone-modal,
.camera-modal {
  position: fixed;
  inset: 0;
  z-index: 1060;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.camera-modal {
  z-index: 1050;
}

.phone-modal-backdrop,
.camera-backdrop {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  animation: fade-in 0.2s var(--ease);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.phone-modal-box,
.camera-box {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 92svh;
  overflow-y: auto;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--paper);
  box-shadow: var(--shadow-lift);
  animation: sheet-up 0.26s var(--ease);
}

@keyframes sheet-up {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
}

.phone-modal-header {
  position: relative;
  padding-right: 44px;
  margin-bottom: 18px;
}

.phone-modal-icon {
  display: none;
}

.phone-modal-header h3,
.camera-header h3,
.crop-header h3 {
  font-size: 24px;
  font-weight: 800;
  text-transform: none;
}

.phone-modal-sub {
  margin-top: 6px;
  font-size: 15px;
  color: var(--walnut);
}

.phone-modal-close-btn,
.camera-close-btn,
.crop-close-btn,
.cart-close-btn {
  position: absolute;
  top: -4px;
  right: -6px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 26px;
  line-height: 1;
  color: var(--walnut);
}

.phone-modal-close-btn:hover,
.camera-close-btn:hover,
.crop-close-btn:hover,
.cart-close-btn:hover {
  background: var(--kraft-soft);
  color: var(--char);
}

.phone-input-group {
  display: grid;
  gap: 6px;
}

.phone-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--char);
}

.phone-input-wrapper {
  display: flex;
  align-items: stretch;
  height: 54px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--smoke);
  background: var(--white);
  overflow: hidden;
}

.phone-input-wrapper:focus-within {
  border-color: var(--char);
  box-shadow: 0 0 0 3px var(--focus-glow);
}

.country-code {
  display: grid;
  place-items: center;
  padding: 0 12px;
  background: var(--kraft-soft);
  border-right: 1px solid var(--line);
  font-weight: 600;
  font-size: 15px;
  color: var(--char);
  white-space: nowrap;
}

.phone-field {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 14px;
  border: 0;
  background: transparent;
  font-size: 18px;
  font-weight: 500;
}

.phone-field:focus {
  outline: none;
}

.otp-field {
  height: 58px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--smoke);
  background: var(--white);
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.4em;
  text-align: center;
}

.otp-field:focus {
  border-color: var(--char);
  box-shadow: 0 0 0 3px var(--focus-glow);
}

.phone-hint {
  font-size: 13px;
  color: var(--smoke);
}

.otp-sent-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 15px;
}

.btn-change-phone,
.btn-resend-otp {
  min-height: 36px;
  padding: 0 8px;
  font-weight: 600;
  color: var(--ember-deep);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.resend-otp-row {
  margin-top: 10px;
  text-align: center;
}

.help-steps-list {
  display: grid;
  gap: 10px;
}

.help-step-card {
  display: flex;
  gap: 14px;
  padding: 14px;
  border-radius: var(--r-md);
  background: var(--birch);
  border: 1px solid var(--line);
}

.help-step-num {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--char);
  color: var(--birch);
  font-family: var(--font-display);
  font-weight: 800;
}

.help-step-content h4 {
  font-size: 17px;
  font-weight: 700;
}

.help-step-content p {
  margin-top: 2px;
  font-size: 14px;
  color: var(--walnut);
}

#recaptcha-container {
  position: fixed;
  bottom: 0;
  left: 0;
  z-index: 1100;
}

/* ------------------------------------------------------------ camera, crop */
.camera-box {
  background: var(--char);
  color: var(--birch);
}

.camera-header {
  position: relative;
  margin-bottom: 14px;
  padding-right: 44px;
}

.camera-close-btn {
  color: var(--birch);
}

.camera-close-btn:hover {
  background: var(--on-char-line);
  color: var(--birch);
}

.camera-container {
  overflow: hidden;
  border-radius: var(--r-md);
  background: var(--char);
}

.camera-container video {
  width: 100%;
  height: auto;
}

.camera-actions,
.crop-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.camera-actions .btn,
.crop-actions .btn {
  flex: 1 1 auto;
  padding: 0 12px;
  white-space: nowrap;
}

.crop-modal {
  position: fixed;
  inset: 0;
  z-index: 1060;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--scrim-strong);
}

.crop-box {
  width: 100%;
  max-width: 540px;
  max-height: 94svh;
  overflow-y: auto;
  padding: 20px;
  border-radius: var(--r-lg);
  background: var(--paper);
  box-shadow: var(--shadow-lift);
}

.crop-header {
  position: relative;
  margin-bottom: 14px;
  padding-right: 44px;
}

.crop-container {
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 52svh;
  overflow: hidden;
  border-radius: var(--r-md);
  background: var(--birch);
}

.crop-container img {
  max-width: 100%;
}

.crop-modal .cropper-view-box {
  outline-color: var(--ember-deep);
}

.crop-modal .cropper-line,
.crop-modal .cropper-point {
  background-color: var(--ember-deep);
}

.crop-modal .cropper-modal {
  background-color: var(--char);
}

.crop-shape-circle .cropper-view-box,
.crop-shape-circle .cropper-face {
  border-radius: 50% !important;
}

.crop-shape-heart .cropper-view-box,
.crop-shape-heart .cropper-face {
  clip-path: path("M 50 90 C 25 70 0 50 0 28 C 0 12 12 0 28 0 C 38 0 45 6 50 14 C 55 6 62 0 72 0 C 88 0 100 12 100 28 C 100 50 75 70 50 90 Z");
}

/* ------------------------------------------------------------------ toasts */
/* Phones: toasts drop in under the header so they never cover the sticky
   price bar or the cart's checkout button. */
.toast-container {
  position: fixed;
  left: 50%;
  top: calc(var(--header-h) + 10px);
  z-index: 1100;
  display: grid;
  gap: 8px;
  width: min(92vw, 420px);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: var(--char);
  color: var(--birch);
  font-size: 15px;
  font-weight: 500;
  box-shadow: var(--shadow-lift);
  animation: toast-in 0.26s var(--ease), toast-out 0.3s 3.7s var(--ease) forwards;
}

body[data-screen="success"] .toast-container,
body[data-screen="payment"] .toast-container {
  top: auto;
  bottom: calc(16px + env(safe-area-inset-bottom));
}

.toast {
  border: 1px solid var(--walnut);
}

.toast-warning {
  background: var(--warn);
}

.toast-error {
  background: var(--danger);
  color: var(--white);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* -------------------------------------------------------------------- cart */
/* JS un-hides and adds .active in the same tick, so opening uses keyframes
   (a transition from display:none would not run). Closing removes .active
   and hides after 350 ms, so the close transition must finish sooner. */
.cart-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--scrim);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

.cart-overlay.active {
  opacity: 1;
  animation: fade-in 0.3s var(--ease);
}

.cart-drawer {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  max-height: 88svh;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--paper);
  box-shadow: var(--shadow-lift);
  transform: translateY(100%);
  transition: transform 0.3s var(--ease);
}

.cart-drawer.active {
  transform: none;
  animation: drawer-up 0.3s var(--ease);
}

@keyframes drawer-up {
  from {
    transform: translateY(100%);
  }
}

@keyframes drawer-in {
  from {
    transform: translateX(100%);
  }
}

.cart-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.cart-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.cart-icon {
  display: none;
}

.cart-title-wrap h3 {
  font-size: 22px;
  font-weight: 800;
  text-transform: none;
}

.cart-header-count {
  font-size: 14px;
  color: var(--smoke);
}

.cart-close-btn {
  position: static;
}

.cart-limit-banner {
  margin: 12px 20px 0;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--kraft-soft);
  font-size: 14px;
  color: var(--walnut);
}

.cart-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 20px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.cart-empty-state {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 28px 0;
  text-align: center;
  color: var(--walnut);
}

.cart-empty-icon {
  font-size: 30px;
  filter: grayscale(1);
  opacity: 0.6;
}

.cart-item-card {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--birch);
  border: 1px solid var(--line);
}

.cart-item-thumb-wrap {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 76px;
  height: 64px;
  border-radius: 10px;
  background: var(--kraft-soft);
}

.cart-item-thumb {
  max-width: 64px;
  max-height: 52px;
  object-fit: contain;
}

/* Image thumbnails are the print bitmap (white = burn on transparent),
   invisible on a light tile; tint them like the preview. */
img.cart-item-thumb {
  filter: invert(0.78) sepia(1) saturate(2.2);
}

svg.cart-item-thumb rect,
svg.cart-item-thumb circle,
svg.cart-item-thumb path {
  stroke: var(--walnut) !important;
}

svg.cart-item-thumb text {
  fill: var(--burn) !important;
}

.cart-item-info {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 8px;
}

.cart-item-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.cart-item-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cart-item-details {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 13px;
  color: var(--smoke);
}

.cart-item-badge {
  padding: 1px 8px;
  border-radius: var(--r-pill);
  background: var(--kraft);
  font-size: 12px;
  font-weight: 600;
  color: var(--walnut);
}

.cart-item-price {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.cart-item-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.cart-qty-control {
  display: inline-flex;
  align-items: center;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--paper);
}

.cart-qty-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  font-weight: 600;
}

.cart-qty-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.cart-qty-num {
  min-width: 24px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.cart-item-actions {
  display: flex;
  gap: 2px;
}

.cart-action-btn {
  min-height: 36px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--walnut);
}

.cart-action-btn:hover {
  background: var(--kraft-soft);
}

.btn-remove {
  color: var(--danger);
}

.cart-footer {
  display: grid;
  gap: 10px;
  padding: 14px 20px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}

/* "Checkout · ₹" and the amount span are separate flex items; no gap
   between them, only before the arrow. */
#cart-checkout-btn {
  gap: 0;
}

#cart-checkout-btn .btn-arrow {
  margin-left: 8px;
}

.cart-subtotal-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 15px;
}

.cart-subtotal-price {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.cart-shipping-note {
  font-size: 13px;
  color: var(--smoke);
}

.cart-continue-link {
  min-height: 44px;
  font-weight: 600;
  color: var(--walnut);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* -------------------------------------------------------------- responsive */
@media (min-width: 720px) {
  :root {
    --gutter: 28px;
    --header-h: 68px;
  }

  .phone-modal,
  .camera-modal {
    align-items: center;
    padding: 24px;
  }

  .phone-modal-box,
  .camera-box {
    border-radius: var(--r-lg);
    padding: 26px 26px 24px;
  }

  .hero-samples-composition {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .footer-grid {
    grid-template-columns: 1.4fr 1fr 1fr 1fr;
  }

  .success-banner-card {
    grid-template-columns: 1fr auto;
    align-items: center;
    padding: 26px 28px;
  }

  .queue-badge-box {
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    min-width: 220px;
  }

  .toast-container {
    top: auto;
    bottom: 28px;
  }

  /* Line the header up with the page content. */
  .app-header {
    padding: 0 max(var(--gutter), calc((100% - 1180px) / 2 + var(--gutter)));
  }

  .cart-drawer {
    inset: 0 0 0 auto;
    width: 420px;
    max-height: none;
    border-radius: var(--r-lg) 0 0 var(--r-lg);
    transform: translateX(100%);
  }

  .cart-drawer.active {
    transform: none;
    animation-name: drawer-in;
  }
}

@media (min-width: 1024px) {
  .hero-canvas {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    align-items: center;
    gap: 48px;
    min-height: calc(100svh - var(--header-h) - 40px);
    padding-top: 40px;
    padding-bottom: 56px;
  }

  .hero-samples-composition {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .hero-sample-item {
    min-height: 250px;
  }

  .sample-png {
    max-height: 190px;
  }

  .sample-pos-br .sample-png {
    max-height: 140px;
  }

  .desktop-br {
    display: inline;
  }

  .testimonial-card {
    padding: 44px 48px;
  }

  .configurator-grid {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: 40px;
    align-items: start;
    padding-top: 12px;
  }

  .preview-column {
    top: calc(var(--header-h) + 20px);
    margin: 0;
    padding: 0;
    background: none;
  }

  .preview-box {
    padding: 22px 28px 20px;
    min-height: 460px;
    display: flex;
    flex-direction: column;
  }

  .keychain-preview,
  .img-keychain {
    margin-top: auto;
    margin-bottom: auto;
    max-width: 520px;
  }

  .keychain-svg {
    max-height: 340px;
  }

  .studio-bar {
    margin: 4px 0 0;
    padding: 16px 0;
  }

  .success-dashboard-grid {
    grid-template-columns: 1.1fr 1fr;
    align-items: start;
  }
}

@media (max-width: 1023px) {
  /* The keyboard is open (input focused): give the controls room. */
  .create-container:has(#name-input:focus) .keychain-svg {
    max-height: 18svh;
  }
}

/* Cap the image preview's height by capping its width per shape (the height
   follows from the JS aspect-ratio: 86/49, 64/64, 69/64), so it matches the
   text preview and the sticky column stays short on phones. */
.preview-column {
  --img-h: 24svh;
  --img-w: 420px;
}

@media (min-width: 1024px) {
  .preview-column {
    --img-h: 340px;
    --img-w: 520px;
  }
}

.img-keychain {
  max-width: min(var(--img-w), calc(var(--img-h) * 86 / 49));
}

.configurator-grid:has(.shape-card.selected[data-shape-id="circle"]) .img-keychain {
  max-width: var(--img-h);
}

.configurator-grid:has(.shape-card.selected[data-shape-id="heart"]) .img-keychain {
  max-width: calc(var(--img-h) * 69 / 64);
}

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

  .testimonial-card {
    opacity: 1;
    transform: none;
  }
}

/* ------------------------------------------------------------ touch targets */
/* Every control reachable by a finger is at least 44 x 44 px (measured at
   360-1024 px widths). */
.brand-logo,
.header-auth-btn,
.header-help-btn,
.cart-nav-btn,
.home-btn,
.emoji-toggle,
.mode-chip,
.btn-center-text,
.img-adjust > summary,
.cart-action-btn,
.btn-change-phone,
.btn-resend-otp,
.user-logout-btn {
  min-height: 44px;
}

.cart-qty-btn {
  width: 44px;
  height: 44px;
}

.header-auth-btn,
.header-help-btn,
.cart-nav-btn,
.home-btn,
.cart-action-btn {
  min-width: 44px;
}

.btn-sm {
  min-height: 44px;
}

@media (max-width: 719px) {
  .header-auth-btn,
  .header-help-btn,
  .home-btn {
    width: 44px;
  }
}

/* ---------------------------------------------------- short (landscape) */
/* On a phone held sideways a sticky preview plus the sticky price bar would
   leave ~110 px for the controls, so the preview scrolls with the page. */
@media (max-height: 540px) and (max-width: 1023px) {
  .preview-column {
    position: static;
    --img-h: 52svh;
  }

  /* Not sticky here, so the piece can be shown bigger. */
  .keychain-svg,
  .create-container:has(#name-input:focus) .keychain-svg {
    max-height: 52svh;
  }
}

/* ------------------------------------------------------ phone studio bar */
/* Below the two-column layout the price bar is fixed to the screen bottom:
   a sticky bar cannot rise above the top of its panel, so it was cut off at
   360 x 740 and missing in landscape. Each panel keeps its own bar; the
   hidden panel's bar is not displayed. */
@media (max-width: 1023px) {
  .studio-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    margin: 0;
    padding-inline: max(var(--gutter), calc((100% - 640px) / 2));
    box-shadow: var(--shadow-bar);
  }

  .create-container {
    padding-bottom: calc(190px + env(safe-area-inset-bottom));
  }

  /* Compact preview card: the badge sits in the empty band above the blank
     (the SVG keeps 7 mm of hidden dimension lines on every side). */
  .preview-top-bar {
    position: absolute;
    top: 10px;
    left: 14px;
    z-index: 1;
  }

  .preview-box {
    padding: 6px 12px 8px;
  }

  .preview-hint {
    margin-top: -6px;
  }
}

@media (max-width: 719px) {
  :root {
    --header-h: 52px;
  }
}

@media (max-height: 540px) and (max-width: 1023px) {
  .studio-bar {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 16px;
    padding-block: 8px calc(8px + env(safe-area-inset-bottom));
  }

  .studio-bar .price-subtitle,
  .studio-bar-hint {
    display: none !important;
  }

  .create-container {
    padding-bottom: calc(100px + env(safe-area-inset-bottom));
  }

  /* Sign-in: name and number side by side so "Send code" stays on screen. */
  #auth-step-phone {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 12px;
    align-items: start;
  }

  #auth-step-phone #auth-name-group {
    margin-bottom: 0 !important;
  }

  #btn-send-otp {
    grid-column: 1 / -1;
  }

  .phone-modal-sub {
    display: none;
  }

  .phone-modal-header {
    margin-bottom: 10px;
  }
}

/* Crop: a full-screen editor with the actions in a bottom toolbar. */
@media (max-width: 719px) {
  .crop-modal {
    padding: 0;
  }

  .crop-box {
    display: flex;
    flex-direction: column;
    max-width: none;
    height: 100svh;
    max-height: none;
    border-radius: 0;
    padding: 16px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  }

  .crop-container {
    flex: 1;
    min-height: 0;
    max-height: none;
  }

  .crop-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  #crop-confirm {
    grid-column: 1 / -1;
  }
}

/* --------------------------------------------------------- tablet 720-1023 */
@media (min-width: 720px) and (max-width: 1023px) {
  .welcome-container {
    max-width: none;
  }

  .create-container {
    max-width: calc(640px + 2 * var(--gutter));
  }
}

@media (min-width: 1024px) {
  .font-chips {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    overflow: visible;
    margin: 0;
    padding: 2px 0 6px;
  }

  .font-chip {
    min-width: 0;
  }

  .success-dashboard-wrapper {
    max-width: 1180px;
  }

  .success-dashboard-grid {
    align-items: stretch;
  }
}
