/* =========================================================
   Surfin' Designer — clean, technical, monochrome
   Apple x Balenciaga: bone background, ink type, hairlines.
   No accent colors. No gradients. No emojis.
   ========================================================= */

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

:root {
  --bg:        #f4f3ef;       /* bone */
  --bg-card:   #ffffff;
  --bg-deep:   #ebe9e3;
  --ink:       #0a0a0a;
  --ink-2:    #4a4a4a;
  --ink-3:    #8a8a86;
  --line:     rgba(10,10,10,0.10);
  --line-2:   rgba(10,10,10,0.18);
  --hair:     0.5px;

  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', ui-monospace, Menlo, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-feature-settings: "ss01", "cv11";
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 17px;
  line-height: 1.55;
  font-weight: 450;
}

body { overflow-x: hidden; }
html.intro-active, html.intro-active body { overflow: hidden; }

p { font-weight: 450; }
strong, b { font-weight: 600; }
.design-hero-text p, .welcome-message p { font-weight: 500; }

/* Tiny utility */
.kicker {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.muted { color: var(--ink-3); }

/* ============================================================
   Top bar
   ============================================================ */
#tab-navigation {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 18px 32px;
  border-bottom: var(--hair) solid var(--line);
  background: rgba(244,243,239,0.85);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  position: sticky; top: 0; z-index: 50;
}

#tab-navigation .brand {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--ink);
}
#tab-navigation .brand em {
  font-style: normal;
  font-weight: 300;
  color: var(--ink-3);
  margin-left: 4px;
}

#tab-navigation .tabs {
  display: flex; gap: 4px;
  margin-left: 20px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 8px 14px;
  cursor: pointer;
  border-radius: 999px;
  transition: color 0.25s var(--ease), background 0.25s var(--ease);
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--ink); background: rgba(10,10,10,0.06); }

/* Cart icon */
.cart-icon {
  position: relative;
  margin-left: auto;
  padding: 8px 14px;
  border: var(--hair) solid var(--line-2);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease);
}
.cart-icon:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.cart-dropdown {
  position: absolute;
  top: calc(100% + 10px); right: 0;
  background: var(--bg-card);
  border: var(--hair) solid var(--line-2);
  border-radius: 14px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.18);
  min-width: 380px;
  max-height: 480px;
  overflow-y: auto;
  z-index: 1000;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--sans);
}
#cart-items { padding: 14px; }
.cart-footer {
  border-top: var(--hair) solid var(--line);
  padding: 16px;
}
.cart-total-row {
  display: flex; justify-content: space-between;
  font-family: var(--mono);
  font-size: 12px; letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 14px;
}
.checkout-btn {
  width: 100%;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.25s var(--ease);
}
.checkout-btn:hover { background: #1f1f1f; }

/* ============================================================
   Tab content
   ============================================================ */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================================
   Store — editorial hero (Apple × Balenciaga)
   ============================================================ */
.store-page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 56px 32px 120px;
}

/* Headline at top — full width, oversized */
.store-hero-head {
  margin-bottom: 48px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.store-headline {
  font-family: var(--sans);
  font-weight: 600;
  font-size: clamp(56px, 9.5vw, 156px);
  line-height: 0.9;
  letter-spacing: -0.05em;
  color: var(--ink);
  display: block;
}
.store-headline span { display: block; }
.store-headline .thin { font-weight: 200; color: var(--ink-2); }
.store-sub {
  font-size: 18px;
  font-weight: 500;
  color: var(--ink-2);
  max-width: 520px;
  line-height: 1.5;
  margin-left: 4px;
}

/* Two-column hero card */
.design-hero {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 1.3fr;
  gap: 0;
  border: var(--hair) solid var(--line-2);
  border-radius: 22px;
  background: var(--bg-card);
  overflow: hidden;
}
.design-hero-text {
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: var(--hair) solid var(--line);
}
.design-hero-spec {
  list-style: none;
}
.design-hero-spec li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 16px 0;
  border-bottom: var(--hair) solid var(--line);
  font-family: var(--sans);
  color: var(--ink);
}
.design-hero-spec li:first-child { padding-top: 6px; }
.design-hero-spec li:last-child  { border-bottom: none; padding-bottom: 6px; }
.design-hero-spec li span:first-child {
  color: var(--ink-3);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.design-hero-spec li span:last-child {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
  text-align: right;
}

/* Right side — framed spinning fin */
.design-hero-visual {
  position: relative;
  background: var(--bg-deep);
  display: grid;
  place-items: stretch;
  min-height: 520px;
}
.visual-frame {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.visual-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(to right, var(--line) var(--hair), transparent var(--hair)),
    linear-gradient(to bottom, var(--line) var(--hair), transparent var(--hair));
  background-size: 56px 56px;
  opacity: 0.7;
  pointer-events: none;
}
.hero-fin-canvas {
  position: relative;
  display: block;
  width: 92%;
  height: 92%;
  cursor: grab;
}
.hero-fin-canvas:active { cursor: grabbing; }

/* CTA row — full width below the card */
.store-cta-row {
  margin-top: 28px;
  display: grid;
  grid-template-columns: 1fr;
}
.hero-cta {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  background: var(--ink) !important;
  color: var(--bg) !important;
  border: none !important;
  padding: 28px 36px !important;
  border-radius: 22px !important;
  font-family: var(--sans) !important;
  font-size: 22px !important;
  font-weight: 500 !important;
  letter-spacing: -0.015em !important;
  text-transform: none !important;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.3s var(--ease), background 0.3s var(--ease), box-shadow 0.4s var(--ease);
  isolation: isolate;
}
.hero-cta::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(120% 120% at 50% 110%, rgba(255,255,255,0.16) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.4s var(--ease);
  z-index: -1;
}
.hero-cta:hover {
  background: #1a1a1a !important;
  transform: translateY(-1px);
  box-shadow: 0 30px 70px -22px rgba(0,0,0,0.45);
}
.hero-cta:hover::before { opacity: 1; }
.hero-cta-label { line-height: 1; }
.hero-cta-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  transition: transform 0.4s var(--ease), background 0.3s var(--ease);
}
.hero-cta:hover .hero-cta-arrow {
  transform: translateX(6px);
  background: rgba(255,255,255,0.14);
}

/* Catalogue — quiet, secondary */
.catalogue {
  margin-top: 96px;
  padding-top: 48px;
  border-top: var(--hair) solid var(--line);
}
.catalogue-title {
  font-family: var(--sans);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin-bottom: 28px;
}
.catalogue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
.catalogue-card {
  background: var(--bg-card);
  border: var(--hair) solid var(--line);
  border-radius: 18px;
  padding: 22px;
  display: flex; flex-direction: column; gap: 16px;
  transition: border-color 0.3s var(--ease), transform 0.4s var(--ease);
}
.catalogue-card:hover {
  border-color: var(--line-2);
  transform: translateY(-2px);
}
.catalogue-card h3 {
  font-weight: 500;
  font-size: 20px;
  letter-spacing: -0.02em;
}
.catalogue-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: auto;
}
.catalogue-row span {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.005em;
}

@media (max-width: 900px) {
  .design-hero { grid-template-columns: 1fr; }
  .design-hero-text { border-right: none; border-bottom: var(--hair) solid var(--line); padding: 28px 24px; }
  .design-hero-visual { min-height: 380px; }
  .store-headline { font-size: clamp(48px, 14vw, 96px); }
  .hero-cta { padding: 22px 24px !important; font-size: 18px !important; }
}

/* ============================================================
   Buttons
   ============================================================ */
.primary-btn,
button.buy-btn.primary-btn,
.control-btn.primary-btn,
#addToCartBtn {
  background: var(--ink) !important;
  color: var(--bg-card) !important;
  border: var(--hair) solid var(--ink) !important;
  font-family: var(--mono) !important;
  font-size: 11px !important;
  letter-spacing: 0.2em !important;
  text-transform: uppercase;
  font-weight: 500 !important;
  padding: 14px 24px !important;
  border-radius: 999px !important;
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease), transform 0.25s var(--ease);
  height: auto;
}
.primary-btn:hover,
button.buy-btn.primary-btn:hover,
.control-btn.primary-btn:hover,
#addToCartBtn:hover {
  background: #1f1f1f !important;
  transform: translateY(-1px);
}

.ghost-btn,
.buy-btn:not(.primary-btn) {
  background: transparent;
  border: var(--hair) solid var(--line-2);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 12px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease), border-color 0.25s var(--ease);
  align-self: flex-start;
}
.ghost-btn:hover,
.buy-btn:not(.primary-btn):hover {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

/* ============================================================
   Editor / Studio
   ============================================================ */
#design-content { background: var(--bg); }

#main {
  position: relative;
  width: 100%;
  height: calc(100vh - 64px);
  /* ponytail: 100dvh accounts for mobile browser chrome that 100vh ignores.
     Browsers without dvh support fall back to the calc() above. */
  height: calc(100dvh - 64px);
  overflow: hidden;
  background: var(--bg-deep);
}

#threeCanvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  /* ponytail: let single-touch drag drive the existing mouse handlers
     (rotate + sculpt) via touch->mouse synthesis, stop the page from
     scrolling/pinching while sculpting on touch screens. */
  touch-action: none;
}

/* WebGL fallback notice (task M4) — shown when the browser can't render 3D.
   Full-screen version for the studio, plus an inline variant for the spin
   viewers. Monochrome glass card, matches the studio frame. */
.sd-webgl-fallback--inline {
  margin: 0;
  padding: 1rem 1.25rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: var(--bg-card);
  border: var(--hair) solid var(--line);
}
.sd-webgl-fallback {
  position: absolute; inset: 24px;
  z-index: 5;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card);
  border: var(--hair) solid var(--line-2);
}
.sd-webgl-fallback__inner {
  max-width: 30rem; padding: 0 1.5rem;
  text-align: center;
}
.sd-webgl-fallback__label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 1rem;
}
.sd-webgl-fallback__title {
  font-family: var(--sans);
  font-size: 1.5rem; line-height: 1.2;
  color: var(--ink);
  margin-bottom: 1rem;
}
.sd-webgl-fallback__body {
  font-family: var(--sans);
  font-size: 0.95rem; line-height: 1.6;
  color: var(--ink-2);
}

#main::after {
  content: "";
  position: absolute; inset: 24px;
  pointer-events: none;
  border: var(--hair) solid var(--line-2);
  border-radius: 18px;
}

/* Welcome / Design messages */
.welcome-message, .design-message {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 5;
  padding: 40px 56px;
  max-width: 640px;
  pointer-events: none;
}
.welcome-message .kicker { margin-bottom: 16px; }
.welcome-message h2, .design-message h2 {
  font-weight: 300;
  font-size: clamp(36px, 4.4vw, 60px);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 14px;
  color: var(--ink);
}
.welcome-message p {
  font-size: 16px;
  color: var(--ink-2);
  line-height: 1.55;
  margin: 6px 0;
}
.welcome-message strong { color: var(--ink); font-weight: 500; }

/* Fin selector pill */
#fin-selector {
  position: absolute;
  top: 24px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: var(--hair) solid var(--line-2);
  border-radius: 999px;
  z-index: 30;
}
.selector-group { display: flex; align-items: center; gap: 8px; }
.selector-group label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding-left: 12px;
}
#fin-selector select {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  outline: none;
  transition: background 0.25s var(--ease);
}
#fin-selector select:hover:not([disabled]) { background: rgba(10,10,10,0.05); }
#fin-selector select:disabled { opacity: 0.4; cursor: not-allowed; }
#fin-selector select option { background: var(--bg-card); color: var(--ink); }
#fin-selector .control-btn {
  height: 36px;
  padding: 8px 18px;
  font-size: 11px;
  letter-spacing: 0.18em;
}

/* ============================================================
   Floating control bar
   ============================================================ */
/* Legacy intro overlay (main.js's createSimpleIntro) — keep neutral, don't let it block anything */
#design-content #intro-overlay { display: none !important; }

#ui {
  position: absolute;
  bottom: 28px; left: 50%;
  transform: translateX(-50%);
  opacity: 1 !important;
  visibility: visible !important;
  background: rgba(255,255,255,0.78);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: var(--hair) solid var(--line-2);
  box-shadow: 0 24px 60px -20px rgba(0,0,0,0.18);
  padding: 10px;
  border-radius: 999px;
  z-index: 30;
  display: flex; gap: 6px; align-items: center;
  max-width: calc(100vw - 48px);
  flex-wrap: nowrap; overflow-x: auto;
  scrollbar-width: none;
}
#ui::-webkit-scrollbar { display: none; }

#ui label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex; flex-direction: column;
  gap: 6px;
  padding: 0 14px;
  border-right: var(--hair) solid var(--line);
  min-width: 88px;
}

#ui input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 84px;
  height: 2px;
  background: rgba(10,10,10,0.18);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
#ui input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--bg-card);
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
  transition: transform 0.2s var(--ease);
  cursor: grab;
}
#ui input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.15); }
#ui input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--bg-card);
}

#brushSlider, #strengthSlider { opacity: 0.4; transition: opacity 0.3s var(--ease); }
.edit-mode #brushSlider, #brushSlider:hover,
.edit-mode #strengthSlider, #strengthSlider:hover { opacity: 1; }

/* Generic control button (secondary, hollow) */
.control-btn {
  appearance: none;
  background: transparent;
  border: var(--hair) solid var(--line);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease), border-color 0.25s var(--ease);
  white-space: nowrap;
  height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
}
.control-btn:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.control-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.control-btn:disabled:hover { background: transparent; color: var(--ink); border-color: var(--line); }

#editBtn.active, #wireframeBtn.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

/* Measure tool — active state when placing points */
#measureBtn.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

/* Floating cart */
.floating-cart-btn {
  position: fixed;
  bottom: 28px; right: 28px;
  background: var(--ink);
  color: var(--bg);
  border: var(--hair) solid var(--ink);
  border-radius: 999px;
  padding: 12px 22px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 500;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 18px 40px -12px rgba(0,0,0,0.28);
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}
.floating-cart-btn:hover { transform: translateY(-1px); background: #1f1f1f; }

/* ---- Mirror preview badge ---- */
.sd-mirror-badge {
  position: absolute;
  top: 168px; left: 50%;
  transform: translate(-50%, -6px);
  z-index: 24;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 8px;
  opacity: 0;
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}
.sd-mirror-badge.on { opacity: 1; transform: translate(-50%, 0); }
.sd-mirror-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--bg);
  animation: sd-mirror-pulse 1.6s ease-in-out infinite;
}
@keyframes sd-mirror-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* While in mirror mode, dim the editor controls so the action moves to the step bar */
#main.sd-mirror-mode #ui label { opacity: 0.35; }
#main.sd-mirror-mode #ui .control-btn { opacity: 0.35; }
#main.sd-mirror-mode #ui #addToCartBtn { opacity: 1; }
#main.sd-mirror-mode #ui {
  border-color: var(--ink) !important;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Cart bundle entry
   ============================================================ */
.cart-bundle {
  padding: 16px;
  border: var(--hair) solid var(--line);
  border-radius: 12px;
  margin-bottom: 12px;
  background: var(--bg-card);
  color: var(--ink);
}
.cart-bundle .bundle-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 8px;
}
.cart-bundle .bundle-name {
  font-size: 15px; font-weight: 500; letter-spacing: -0.01em;
}
.cart-bundle .bundle-price {
  font-family: var(--mono); font-size: 13px; color: var(--ink);
}
.cart-bundle .bundle-meta {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px;
}
.cart-bundle .bundle-row {
  display: flex; justify-content: space-between;
  padding: 8px 0;
  border-top: var(--hair) solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
}
.cart-bundle .bundle-row span:last-child {
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 10px;
}
.cart-bundle .bundle-actions { display: flex; gap: 8px; margin-top: 14px; }
.cart-bundle .bundle-actions button {
  flex: 1;
  background: transparent;
  border: var(--hair) solid var(--line-2);
  color: var(--ink);
  padding: 9px 10px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.cart-bundle .bundle-actions button:hover {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
}
.cart-bundle .bundle-actions button.danger:hover {
  background: var(--ink); color: var(--bg);
}

/* ============================================================
   Wizard / Setup picker — neutralized
   ============================================================ */
.setup-option {
  background: var(--bg-card) !important;
  border: var(--hair) solid var(--line-2) !important;
  color: var(--ink) !important;
  border-radius: 14px !important;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease), transform 0.25s var(--ease) !important;
}
.setup-option:hover {
  border-color: var(--ink) !important;
  background: var(--bg) !important;
  transform: none !important;
}
/* Override main.js inline selection styles */
.setup-option[style*="667eea"],
.setup-option[style*="764ba2"] {
  background: var(--ink) !important;
  color: var(--bg) !important;
  border-color: var(--ink) !important;
}
.setup-option[style*="667eea"] h3,
.setup-option[style*="667eea"] p,
.setup-option[style*="764ba2"] h3,
.setup-option[style*="764ba2"] p {
  color: var(--bg) !important;
}
.setup-option h3 { color: var(--ink) !important; font-weight: 500 !important; }
.setup-option p { color: var(--ink-2) !important; }

.wizard-btn {
  background: var(--ink) !important;
  color: var(--bg) !important;
  border: var(--hair) solid var(--ink) !important;
  border-radius: 999px !important;
  font-family: var(--mono) !important;
  font-size: 11px !important;
  letter-spacing: 0.2em !important;
  text-transform: uppercase;
  font-weight: 500 !important;
  padding: 14px 28px !important;
}
.wizard-btn:hover { background: #1f1f1f !important; }
.wizard-btn.secondary {
  background: transparent !important;
  color: var(--ink) !important;
  border: var(--hair) solid var(--line-2) !important;
}
.wizard-btn.secondary:hover { background: var(--ink) !important; color: var(--bg) !important; }
.wizard-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* Modal frame from main.js — soften it */
[id*="wizard-modal"],
[class*="wizard-overlay"] {
  background: rgba(10,10,10,0.55) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* Status messages */
#status-message, .status-message {
  font-family: var(--mono) !important;
  font-size: 11px !important;
  letter-spacing: 0.16em !important;
  text-transform: uppercase;
  background: var(--ink) !important;
  color: var(--bg) !important;
  border-radius: 12px !important;
  border: none !important;
  box-shadow: 0 18px 40px -12px rgba(0,0,0,0.28) !important;
}

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

/* ============================================================
   Intro overlay
   ============================================================ */
.intro-screen {
  position: fixed; inset: 0;
  background: var(--ink);
  color: #f4f3ef;
  z-index: 99998;
  display: flex; flex-direction: column;
  padding: 28px 32px;
  justify-content: space-between;
  font-family: var(--sans);
  overflow: hidden;
  transition: clip-path 1s var(--ease), opacity 0.6s var(--ease) 0.4s;
  clip-path: inset(0 0 0 0);
}
.intro-screen.intro-leaving {
  clip-path: inset(0 0 100% 0);
  opacity: 0;
  pointer-events: none;
}

.intro-meta {
  display: flex;
  gap: 24px;
  align-items: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(244,243,239,0.55);
}
.intro-meta span + span::before {
  content: ""; display: inline-block;
  width: 4px; height: 4px;
  background: rgba(244,243,239,0.4);
  border-radius: 50%; margin-right: 24px; margin-left: -12px;
  vertical-align: middle;
}
.intro-meta [data-intro-clock] { margin-left: auto; color: rgba(244,243,239,0.85); font-variant-numeric: tabular-nums; }

.intro-stack {
  margin: auto 0;
  max-width: 1200px;
}
.intro-kicker {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(244,243,239,0.55);
  margin-bottom: 28px;
  padding-bottom: 10px;
  border-bottom: var(--hair) solid rgba(244,243,239,0.18);
}

.intro-title {
  font-family: var(--sans);
  font-size: clamp(56px, 11vw, 168px);
  line-height: 0.92;
  letter-spacing: -0.045em;
  font-weight: 600;
  color: #f4f3ef;
  margin: 0;
}
.intro-line {
  display: block;
  overflow: hidden;
  padding-bottom: 0.04em;
}
.intro-word {
  display: inline-block;
  transform: translateY(110%);
  animation: introRise 1.1s var(--ease) forwards;
}
.intro-line:nth-child(2) .intro-word { animation-delay: 0.18s; }
.intro-word.thin { font-weight: 200; color: rgba(244,243,239,0.55); }

@keyframes introRise {
  to { transform: translateY(0); }
}

.intro-lede {
  margin-top: 20px;
  font-size: 16px;
  font-weight: 500;
  color: rgba(244,243,239,0.7);
  max-width: 540px;
  opacity: 0;
  animation: introFade 0.8s var(--ease) 0.6s forwards;
}
@keyframes introFade { to { opacity: 1; } }

.intro-foot {
  display: flex;
  align-items: center;
  gap: 20px;
}
.intro-progress {
  flex: 1;
  height: 1px;
  background: rgba(244,243,239,0.18);
  position: relative;
  overflow: hidden;
}
.intro-progress-fill {
  position: absolute; inset: 0;
  background: rgba(244,243,239,0.95);
  transform-origin: left center;
  transform: scaleX(0);
}
.intro-skip {
  background: transparent;
  border: var(--hair) solid rgba(244,243,239,0.4);
  color: rgba(244,243,239,0.85);
  padding: 8px 16px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}
.intro-skip:hover { background: #f4f3ef; color: var(--ink); }

/* Caustic shimmer overlay on intro */
.intro-screen::before {
  content: "";
  position: absolute; inset: -10%;
  pointer-events: none;
  background:
    radial-gradient(2px 2px at 23% 17%, rgba(255,255,255,0.5), transparent 60%),
    radial-gradient(2px 2px at 71% 42%, rgba(255,255,255,0.4), transparent 60%),
    radial-gradient(2px 2px at 12% 81%, rgba(255,255,255,0.4), transparent 60%),
    radial-gradient(2px 2px at 88% 73%, rgba(255,255,255,0.35), transparent 60%);
  animation: introDrift 18s linear infinite;
  opacity: 0.5;
}
@keyframes introDrift {
  0%, 100% { transform: translate3d(0,0,0); }
  50% { transform: translate3d(-2%, 1%, 0); }
}

/* ============================================================
   STL viewer canvases
   ============================================================ */
.hero-fin-canvas {
  display: block;
  cursor: grab;
}
.hero-fin-canvas:active { cursor: grabbing; }

.catalogue-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  background:
    radial-gradient(circle at 50% 60%, rgba(10,10,10,0.04), transparent 60%);
  cursor: grab;
}
.catalogue-canvas:active { cursor: grabbing; }

/* Fin-dive transition overlay */
.fin-dive-fade {
  position: fixed; inset: 0;
  background: var(--ink);
  z-index: 99996;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}
.fin-dive-fade.on { opacity: 1; transition-delay: 0.45s; }
.fin-dive-fade.out { opacity: 0; transition-delay: 0s; transition-duration: 0.6s; }

/* ---- Line streamers (DOM lines flying from page edges to the fin) ---- */
.sd-line-streamer {
  position: fixed;
  height: 1px;
  background: var(--ink);
  pointer-events: none;
  z-index: 99995;
  opacity: 0;
  transform-origin: 0 50%;
  will-change: transform, opacity;
  box-shadow: 0 0 6px rgba(10,10,10,0.18);
}

/* =========================================================================
   Whole-site WIREFRAME mode — applied for the Enter Studio transition.
   Strips fills/shadows, keeps only ink outlines on shapes and text.
   ========================================================================= */

/* Smoothly transition the page into the wireframe look */
html, body, .design-hero, .design-hero-text, .design-hero-visual,
.visual-frame, .catalogue-card, #tab-navigation, .hero-cta,
.tab-btn, .cart-icon, .ghost-btn, .buy-btn, .control-btn,
button, input, select,
h1, h2, h3, h4, p, span, label, li, em, strong {
  transition: background-color 0.45s var(--ease),
              background-image 0.45s var(--ease),
              border-color 0.45s var(--ease),
              color 0.45s var(--ease),
              box-shadow 0.45s var(--ease),
              opacity 0.45s var(--ease);
}

html.sd-wireframe { background: var(--bg) !important; }

/* Kill all backgrounds + shadows */
html.sd-wireframe body { background: var(--bg) !important; }
html.sd-wireframe body::before,
html.sd-wireframe body::after { opacity: 0 !important; }

html.sd-wireframe *,
html.sd-wireframe *::before,
html.sd-wireframe *::after {
  background-color: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  filter: none !important;
  text-shadow: none !important;
}

/* Outline the major shapes in ink */
html.sd-wireframe #tab-navigation,
html.sd-wireframe .design-hero,
html.sd-wireframe .design-hero-text,
html.sd-wireframe .design-hero-visual,
html.sd-wireframe .visual-frame,
html.sd-wireframe .catalogue-card,
html.sd-wireframe .hero-cta,
html.sd-wireframe .ghost-btn,
html.sd-wireframe .buy-btn,
html.sd-wireframe .tab-btn,
html.sd-wireframe .cart-icon,
html.sd-wireframe .control-btn,
html.sd-wireframe .hero-cta-arrow {
  border: 1px solid var(--ink) !important;
}

/* Reinforce the spec-row hairlines */
html.sd-wireframe .design-hero-spec li,
html.sd-wireframe .design-hero-text {
  border-color: var(--ink) !important;
}

/* Outline the visual-frame's grid more aggressively */
html.sd-wireframe .visual-grid {
  background-image:
    linear-gradient(to right, var(--ink) 0.5px, transparent 0.5px),
    linear-gradient(to bottom, var(--ink) 0.5px, transparent 0.5px) !important;
  opacity: 0.35 !important;
}

/* Type becomes hollow — outlined ink letters */
html.sd-wireframe h1,
html.sd-wireframe h2,
html.sd-wireframe h3,
html.sd-wireframe h4,
html.sd-wireframe p,
html.sd-wireframe span,
html.sd-wireframe label,
html.sd-wireframe a,
html.sd-wireframe li,
html.sd-wireframe em,
html.sd-wireframe strong,
html.sd-wireframe button,
html.sd-wireframe .hero-cta-label,
html.sd-wireframe .store-headline,
html.sd-wireframe .store-headline span,
html.sd-wireframe .store-sub {
  color: transparent !important;
  -webkit-text-stroke: 0.6px var(--ink) !important;
  text-stroke: 0.6px var(--ink) !important;
}

/* CTA stays prominent — bigger stroke */
html.sd-wireframe .hero-cta,
html.sd-wireframe .hero-cta * {
  color: transparent !important;
}
html.sd-wireframe .hero-cta {
  border: 1.5px solid var(--ink) !important;
}
html.sd-wireframe .hero-cta-arrow svg {
  stroke: var(--ink) !important;
}

/* Hide other catalogue fins so the hero is the focal point */
html.sd-wireframe .catalogue-canvas { opacity: 0.25 !important; }

/* Lock interactions during the transition */
html.sd-wireframe { pointer-events: none; }

/* ============================================================
   Setup picker — board diagrams
   ============================================================ */
.setup-option.sd-setup-card,
.setup-option {
  padding: 28px 24px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 20px !important;
  text-align: left !important;
}
.sd-setup-visual {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  background: var(--bg);
  border: var(--hair) solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.setup-option:hover .sd-setup-visual { background: var(--bg-deep); }
.setup-option[style*="667eea"] .sd-setup-visual,
.setup-option[style*="764ba2"] .sd-setup-visual {
  background: rgba(244,243,239,0.08);
  border-color: rgba(244,243,239,0.18);
}

.board-diagram {
  width: 82%;
  height: 90%;
}
.bd-board {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.4;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.bd-stringer {
  stroke: var(--ink);
  stroke-width: 0.4;
  stroke-dasharray: 1.5 1.5;
  vector-effect: non-scaling-stroke;
  opacity: 0.5;
}
.bd-fin {
  fill: var(--ink);
}
/* When card is selected (main.js inline gradient triggers) flip the diagram colors */
.setup-option[style*="667eea"] .bd-board,
.setup-option[style*="764ba2"] .bd-board { stroke: #f4f3ef; }
.setup-option[style*="667eea"] .bd-stringer,
.setup-option[style*="764ba2"] .bd-stringer { stroke: #f4f3ef; opacity: 0.5; }
.setup-option[style*="667eea"] .bd-fin,
.setup-option[style*="764ba2"] .bd-fin { fill: #f4f3ef; }

.sd-setup-text { display: flex; flex-direction: column; gap: 6px; }
.sd-setup-text h3 {
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.sd-setup-text p {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
  font-weight: 450;
}
.setup-option[style*="667eea"] .sd-setup-text h3,
.setup-option[style*="764ba2"] .sd-setup-text h3 { color: #f4f3ef; }
.setup-option[style*="667eea"] .sd-setup-text p,
.setup-option[style*="764ba2"] .sd-setup-text p { color: rgba(244,243,239,0.65); }

/* ============================================================
   Payment modal skin
   ============================================================ */
.sd-payment-modal,
.payment-modal {
  background: rgba(10,10,10,0.55) !important;
  backdrop-filter: blur(18px) !important;
  -webkit-backdrop-filter: blur(18px) !important;
}
.sd-payment-modal .payment-form,
.payment-modal .payment-form {
  background: var(--bg-card) !important;
  border-radius: 22px !important;
  padding: 40px 36px !important;
  border: var(--hair) solid var(--line-2) !important;
  box-shadow: 0 40px 100px -20px rgba(0,0,0,0.4) !important;
  font-family: var(--sans) !important;
  color: var(--ink) !important;
}
.payment-modal h1, .payment-modal h2, .payment-modal h3 {
  font-family: var(--sans) !important;
  color: var(--ink) !important;
  font-weight: 600 !important;
  letter-spacing: -0.02em !important;
}
.payment-modal h2 {
  font-size: 24px !important;
  border: none !important;
  padding-bottom: 0 !important;
  text-align: left !important;
}
.payment-modal h2 + * { margin-top: 8px !important; }
/* The product banner box gets re-skinned */
.payment-modal [style*="667eea"],
.payment-modal [style*="764ba2"] {
  background: var(--bg) !important;
  border: var(--hair) solid var(--line) !important;
  color: var(--ink) !important;
  border-radius: 14px !important;
  padding: 22px !important;
  box-shadow: none !important;
}
.payment-modal [style*="667eea"] *,
.payment-modal [style*="764ba2"] * { color: var(--ink) !important; opacity: 1 !important; }
.payment-modal button {
  font-family: var(--mono) !important;
  font-size: 11px !important;
  letter-spacing: 0.2em !important;
  text-transform: uppercase !important;
  border-radius: 999px !important;
  font-weight: 600 !important;
}
.payment-modal button[type="submit"],
.payment-modal .pay-btn,
.payment-modal button:not(.cancel-btn):not([data-secondary]) {
  background: var(--ink) !important;
  color: var(--bg) !important;
  border: var(--hair) solid var(--ink) !important;
}
.payment-modal input, .payment-modal .StripeElement {
  border: var(--hair) solid var(--line-2) !important;
  border-radius: 10px !important;
  padding: 14px !important;
  font-family: var(--sans) !important;
  font-size: 14px !important;
}

/* ============================================================
   Cart bundle row (per-component preview)
   ============================================================ */
.cart-bundle .bundle-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
}
.cart-bundle .bundle-row > span:first-child {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.cart-bundle .bundle-row .bundle-row-meta {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.cart-bundle .bundle-row-preview {
  background: transparent;
  border: var(--hair) solid var(--line-2);
  color: var(--ink);
  padding: 7px 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.cart-bundle .bundle-row-preview:hover {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
}

.cart-bundle .bundle-actions button.danger {
  flex: 1;
}

/* ============================================================
   Cart modal (clean, slide-in from right)
   ============================================================ */
.sd-cart-modal {
  position: fixed; inset: 0; z-index: 99996;
  display: grid;
  pointer-events: none;
  font-family: var(--sans);
}
.sd-cart-modal.open { pointer-events: auto; }
.sd-cart-backdrop {
  position: absolute; inset: 0;
  background: rgba(10,10,10,0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  transition: opacity 0.36s var(--ease);
}
.sd-cart-modal.open .sd-cart-backdrop { opacity: 1; }

.sd-cart-panel {
  position: absolute;
  top: 16px; right: 16px; bottom: 16px;
  width: min(520px, calc(100vw - 32px));
  background: var(--bg-card);
  border: var(--hair) solid var(--line-2);
  border-radius: 22px;
  box-shadow: 0 40px 100px -20px rgba(0,0,0,0.4);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform: translateX(110%);
  transition: transform 0.5s var(--ease);
}
.sd-cart-modal.open .sd-cart-panel { transform: translateX(0); }

.sd-cart-header {
  padding: 26px 28px 20px;
  border-bottom: var(--hair) solid var(--line);
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
}
.sd-cart-header .kicker { display: block; margin-bottom: 8px; }
.sd-cart-header h2 {
  font-family: var(--sans);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1;
}
.sd-cart-close {
  background: transparent;
  border: var(--hair) solid var(--line-2);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.sd-cart-close:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.sd-cart-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 28px 28px;
}

.sd-cart-empty {
  padding: 56px 0;
  text-align: center;
}
.sd-cart-empty p {
  margin-top: 10px;
  color: var(--ink-2);
  font-size: 15px;
}

.sd-cart-item {
  padding: 22px 0;
  border-bottom: var(--hair) solid var(--line);
}
.sd-cart-item:first-child { padding-top: 6px; }
.sd-cart-item:last-child { border-bottom: none; }

.sd-cart-item-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px;
  margin-bottom: 4px;
}
.sd-cart-item-head .kicker { display: block; margin-bottom: 6px; }
.sd-cart-item-head h3 {
  font-family: var(--sans);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.05;
}
.sd-cart-item-price {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.04em;
}
.sd-cart-item-meta {
  display: flex;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 6px 0 14px;
}

.sd-cart-lines {
  list-style: none;
  border-top: var(--hair) solid var(--line);
}
.sd-cart-line {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0;
  border-bottom: var(--hair) solid var(--line);
  gap: 12px;
}
.sd-cart-line:last-child { border-bottom: none; }
.sd-cart-line-main {
  display: flex; flex-direction: column; gap: 4px;
}
.sd-cart-line-name {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}
.sd-cart-line-meta {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.sd-cart-item-actions { margin-top: 12px; }

.sd-cart-footer {
  border-top: var(--hair) solid var(--line);
  padding: 22px 28px 24px;
  background: var(--bg);
}
.sd-cart-totals {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 18px;
}
.sd-cart-row {
  display: flex; justify-content: space-between;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink);
}
.sd-cart-row.muted { color: var(--ink-3); }
.sd-cart-row.total {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 8px;
  padding-top: 12px;
  border-top: var(--hair) solid var(--line);
}

.sd-cart-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
}

/* Buttons */
.sd-btn {
  appearance: none;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 500;
  border-radius: 999px;
  padding: 14px 20px;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease), opacity 0.2s var(--ease);
  border: var(--hair) solid transparent;
  white-space: nowrap;
}
.sd-btn.primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.sd-btn.primary:hover:not(:disabled) { background: #1f1f1f; }
.sd-btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-2);
}
.sd-btn.ghost:hover:not(:disabled) { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.sd-btn.ghost.xs { padding: 8px 14px; font-size: 11px; letter-spacing: 0.18em; }
.sd-btn.link {
  background: transparent;
  color: var(--ink-3);
  border: none;
  padding: 4px 0;
  font-size: 11px;
  letter-spacing: 0.18em;
}
.sd-btn.link.danger:hover { color: #c93030; }
.sd-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* The legacy cart-dropdown — neutralize it; users now use the panel */
#cart-dropdown { display: none !important; }

/* Checkout-config notice (Stripe not set up) */
.sd-config-modal {
  position: fixed; inset: 0; z-index: 99997;
  display: grid; place-items: center;
  pointer-events: none;
  font-family: var(--sans);
}
.sd-config-modal.open { pointer-events: auto; }
.sd-config-backdrop {
  position: absolute; inset: 0;
  background: rgba(10,10,10,0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.sd-config-modal.open .sd-config-backdrop { opacity: 1; }
.sd-config-panel {
  position: relative;
  width: min(480px, calc(100vw - 32px));
  background: var(--bg-card);
  border: var(--hair) solid var(--line-2);
  border-radius: 22px;
  padding: 36px 32px 28px;
  box-shadow: 0 40px 100px -20px rgba(0,0,0,0.4);
  transform: translateY(12px);
  opacity: 0;
  transition: transform 0.4s var(--ease), opacity 0.4s var(--ease);
}
.sd-config-modal.open .sd-config-panel {
  transform: translateY(0); opacity: 1;
}
.sd-config-panel h3 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}
.sd-config-panel p {
  color: var(--ink-2);
  font-size: 16px;
  line-height: 1.55;
  margin-bottom: 12px;
}
.sd-config-panel code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  border: var(--hair) solid var(--line);
}
.sd-config-actions { margin-top: 18px; display: flex; justify-content: flex-end; }

/* Responsive */
@media (max-width: 900px) {
  .design-hero { grid-template-columns: 1fr; }
  .design-hero-text { border-right: none; border-bottom: var(--hair) solid var(--line); padding: 40px 32px; }
  .design-hero-visual { min-height: 320px; }
}
@media (max-width: 640px) {
  #tab-navigation { padding: 14px 18px; gap: 14px; }
  #ui label { min-width: 70px; padding: 0 8px; }
  #ui input[type="range"] { width: 64px; }
  .control-btn { padding: 7px 10px; font-size: 10px; }
}

/* ============================================================
   Set Builder rail — live board + per-step copy
   ============================================================ */
.sd-set-rail {
  position: absolute;
  top: 88px;
  left: 50%;
  transform: translate(-50%, -8px);
  z-index: 26;
  display: none;
  align-items: center;
  gap: 18px;
  padding: 14px 18px 14px 14px;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: var(--hair) solid var(--line-2);
  border-radius: 18px;
  box-shadow: 0 18px 60px -22px rgba(0,0,0,0.18);
  font-family: var(--sans);
  opacity: 0;
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
  max-width: min(92vw, 720px);
}
.sd-set-rail.visible {
  display: flex;
  opacity: 1;
  transform: translate(-50%, 0);
}

.sd-rail-board {
  width: 64px;
  height: 84px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.sd-rail-board .board-diagram { width: 100%; height: 100%; }

.sd-rail-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.sd-rail-kicker {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.sd-rail-title {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
  line-height: 1.1;
}
.sd-rail-body {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.4;
  font-weight: 450;
  max-width: 380px;
}

.sd-rail-restart {
  appearance: none;
  background: transparent;
  border: var(--hair) solid var(--line-2);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-3);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: center;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.sd-rail-restart:hover { color: var(--ink); border-color: var(--ink-2); }
.sd-rail-restart.armed {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

/* ---- Board-fin states (progressive fill) ---- */
.bd-fin.ghost {
  fill: rgba(10,10,10,0.04);
  stroke: var(--line-2);
  stroke-width: 0.6;
  stroke-dasharray: 1.4 1.4;
  vector-effect: non-scaling-stroke;
}
.bd-fin.active {
  fill: rgba(10,10,10,0.42);
  animation: bdPulse 1.8s var(--ease) infinite;
}
.bd-fin.filled { fill: var(--ink); }
@keyframes bdPulse {
  0%, 100% { fill: rgba(10,10,10,0.30); }
  50%      { fill: rgba(10,10,10,0.52); }
}
.bd-complete {
  font-family: var(--mono);
  font-size: 4px;
  letter-spacing: 0.35em;
  fill: var(--ink-3);
}

/* ============================================================
   Review-your-set overlay — the climax before buy
   ============================================================ */
.sd-review-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  font-family: var(--sans);
}
.sd-review-overlay.open { display: block; }

.sd-review-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(244,243,239,0.72);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.sd-review-overlay.open .sd-review-backdrop { opacity: 1; }

.sd-review-panel {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -46%);
  width: min(92vw, 560px);
  background: var(--bg-card);
  border: var(--hair) solid var(--line-2);
  border-radius: 22px;
  box-shadow: 0 40px 100px -24px rgba(0,0,0,0.28);
  padding: 36px 36px 28px;
  opacity: 0;
  transition: opacity 0.34s var(--ease) 0.04s, transform 0.34s var(--ease) 0.04s;
}
.sd-review-overlay.open .sd-review-panel {
  opacity: 1;
  transform: translate(-50%, -50%);
}

.sd-review-board {
  width: 150px;
  height: 200px;
  margin: 0 auto 22px;
  display: grid;
  place-items: center;
}
.sd-review-board .board-diagram { width: 100%; height: 100%; }

.sd-review-copy { text-align: center; }
.sd-review-copy .kicker {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.sd-review-copy h2 {
  font-family: var(--sans);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 16px;
}

.sd-review-lines {
  list-style: none;
  margin: 0 auto 16px;
  padding: 0;
  max-width: 360px;
  border-top: var(--hair) solid var(--line);
}
.sd-review-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 11px 2px;
  border-bottom: var(--hair) solid var(--line);
}
.sd-review-line-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}
.sd-review-line-meta {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.sd-review-total {
  display: flex;
  justify-content: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 24px;
}

.sd-review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}
.sd-review-actions .sd-btn {
  /* The primary CTA label can be long ("Add Quad Set to cart · 4 fins · $239.96").
     Let the back button take its natural width; the primary flexes and wraps
     its label rather than overflowing the panel. */
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  justify-content: center;
  text-align: center;
  white-space: normal;
  line-height: 1.35;
}
.sd-review-actions .sd-review-back {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* ============================================================
   Cart item mini board diagram
   ============================================================ */
.sd-cart-item-head-text { min-width: 0; }
.sd-cart-item-head-text .kicker { display: block; margin-bottom: 6px; }
.sd-cart-item-board {
  width: 44px;
  height: 58px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.sd-cart-item-board .board-diagram { width: 100%; height: 100%; }

/* On small screens, fold the rail's text under the board */
@media (max-width: 640px) {
  .sd-set-rail { flex-wrap: wrap; max-width: 92vw; padding: 12px; }
  .sd-rail-restart { order: 3; }
  .sd-rail-body { font-size: 12px; }
  .sd-review-panel { padding: 28px 22px 22px; }
  .sd-review-copy h2 { font-size: 24px; }
  .sd-review-board { width: 120px; height: 160px; }
  /* Stack the review actions vertically so the long primary CTA never
     overflows the panel; back button sits on top, full width. */
  .sd-review-actions { flex-direction: column; align-items: stretch; }
  .sd-review-actions .sd-btn,
  .sd-review-actions .sd-review-back { flex: 1 1 auto; width: 100%; white-space: normal; }
}

/* ============================================================
   Fin loader spinner — shown while a saved fin is being parsed
   and placed in the studio. Monochrome glass card + ink arc.
   ============================================================ */
.sd-fin-loader {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 22px 30px;
  background: rgba(255,255,255,0.86);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: var(--hair) solid var(--line-2);
  border-radius: 18px;
  box-shadow: 0 18px 60px -22px rgba(0,0,0,0.22);
  font-family: var(--sans);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s var(--ease), transform 0.22s var(--ease);
}
.sd-fin-loader.on {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}
.sd-fin-loader-spin {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--ink);
  animation: sdSpin 0.7s linear infinite;
}
@keyframes sdSpin { to { transform: rotate(360deg); } }
.sd-fin-loader-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-2);
  white-space: nowrap;
}

/* ============================================================
   Mobile (touch) Studio
   Scoped so desktop is untouched. The store/Index tab is already
   responsive; this only reflows the 3D editor on phones.
   ============================================================ */

/* Rotate-to-landscape prompt.
   ponytail: shown ONLY on portrait + coarse pointer (a real phone),
   never on a narrow desktop window. dismissible; stays hidden after. */
#rotate-prompt {
  display: none;
  position: fixed; inset: 0;
  z-index: 9999;
  background: var(--bg-deep);
  align-items: center; justify-content: center;
  text-align: center;
  padding: 40px 28px;
}
#rotate-prompt.visible { display: flex; }
/* Dismissed overrides the show rule so it stays hidden for the session. */
#rotate-prompt.dismissed,
#rotate-prompt.dismissed.show-on-portrait { display: none !important; }
.rotate-prompt-inner { max-width: 320px; }
.rotate-prompt-icon {
  width: 72px; height: 72px; margin: 0 auto 24px;
  color: var(--ink);
}
.rotate-prompt-icon svg { width: 100%; height: 100%; }
.rotate-prompt-kicker {
  font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 12px;
}
.rotate-prompt-title {
  font-family: var(--sans);
  font-weight: 300;
  font-size: clamp(28px, 8vw, 40px);
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 14px;
}
.rotate-prompt-body {
  font-family: var(--sans);
  font-size: 15px; line-height: 1.6;
  color: var(--ink-2);
  margin-bottom: 26px;
}
.rotate-prompt-dismiss {
  background: transparent;
  border: var(--hair) solid var(--line);
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
}
.rotate-prompt-dismiss:hover { color: var(--ink); border-color: var(--ink); }

/* The 3D editor on phones: stack the control bar at the top so it
   doesn't overlap the bottom system-gesture area, shrink buttons. */
@media (max-width: 640px) {
  #ui {
    bottom: auto;
    top: 88px;
    padding: 6px;
    gap: 4px;
    border-radius: 16px;
    max-width: calc(100vw - 24px);
  }
  #ui .control-btn { padding: 7px 9px; font-size: 9px; letter-spacing: 0.1em; }
  #ui label { min-width: 60px; padding: 0 6px; }
  #ui input[type="range"] { width: 56px; }
  /* The set-builder rail sits just below the control bar on phones. */
  .sd-set-rail.visible { top: 150px; }
}

/* PHONE PORTRAIT: show the rotate prompt over the Studio tab only.
   @media (pointer: coarse) excludes mouse/trackpad. orientation: portrait
   excludes landscape phones AND narrow desktop windows. */
@media (pointer: coarse) and (orientation: portrait) {
  #design-content.active ~ #rotate-prompt,
  #rotate-prompt.show-on-portrait { display: flex; }
}

