* { box-sizing: border-box; }
html, body, #root { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #fff;
  color: #1a1a1e;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}

.cf-app {
  display: grid;
  grid-template-columns: 440px 1fr;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  --accent: #3D6BFF;
  --line: #ececea;
  --muted: #8a8a90;
}

/* LEFT PANEL */
.cf-left {
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.cf-header {
  padding: 22px 28px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.cf-brand { display: flex; align-items: center; gap: 10px; }
.cf-brand-link { display: inline-block; line-height: 0; transition: opacity 0.15s; }
.cf-brand-link:hover { opacity: 0.75; }
.cf-brand-logo { height: 28px; width: auto; display: block; }
.cf-step {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
}

.cf-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 28px 24px;
  scrollbar-width: thin;
  scrollbar-color: #ee8b1a transparent;
}
.cf-scroll::-webkit-scrollbar { width: 8px; }
.cf-scroll::-webkit-scrollbar-track { background: transparent; }
.cf-scroll::-webkit-scrollbar-thumb { background: #ee8b1a; border-radius: 4px; }

.cf-section {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.cf-section:last-child { border-bottom: none; }

.cf-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}
.cf-label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.cf-value {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.cf-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.cf-swatch {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1.5px solid rgba(0,0,0,0.06);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  transition: transform 0.12s, box-shadow 0.12s;
  padding: 0;
}
.cf-swatch:hover { transform: scale(1.05); }
.cf-swatch.is-on {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent);
  transform: scale(1.05);
}

.cf-extras {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.cf-extra-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #1a1a1e;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.cf-extra-btn:hover { background: #fafaf8; border-color: #d8d8d4; }
.cf-extra-btn.is-on { border-color: var(--accent); color: var(--accent); }

.cf-footer {
  padding: 18px 28px 22px;
  padding-bottom: calc(22px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #fff;
}
.cf-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.cf-price-label {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}
.cf-price-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.cf-price {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.cf-checkout {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: filter 0.15s, transform 0.1s;
}
.cf-checkout:hover { filter: brightness(1.08); }
.cf-checkout:active { transform: scale(0.98); }

/* RIGHT — STAGE */
.cf-right {
  background: linear-gradient(180deg, #fbfbf9 0%, #f4f3ef 100%);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.cf-stage-meta {
  position: absolute;
  top: 24px; left: 28px; right: 28px;
  display: flex; justify-content: space-between;
  z-index: 5;
}
.cf-stage-title {
  display: flex; align-items: center; gap: 12px;
}
.cf-stage-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 600;
}
.cf-stage-sku {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  background: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.cf-legend {
  position: absolute;
  bottom: 24px; left: 28px;
  display: flex; gap: 16px;
  z-index: 5;
}
.cf-chip {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px;
  color: #555;
  font-weight: 500;
}
.cf-chip-dot {
  width: 14px; height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.08);
}

/* 3D STAGE */
.kb-stage {
  flex: 1;
  min-height: 420px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  user-select: none;
  touch-action: none;
}
.kb-platter {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.three-mount {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.three-mount canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
.kb-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: rgba(0,0,0,0.4);
  letter-spacing: 0.04em;
  pointer-events: none;
  z-index: 2;
}

/* Comic-style hint bubble over the 3D viewer. Disappears on first press. */
.cf-hint-bubble {
  position: absolute;
  top: 28%;
  left: 50%;
  z-index: 4;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.82);
  border: 2px solid rgba(0, 0, 0, 0.12);
  border-radius: 28px;
  font-size: 17px;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.6);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.07);
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -6px);
  animation: cfHintIn 0.5s ease 0.6s forwards;
  transition: opacity 0.35s ease;
}
.cf-hint-bubble.is-hidden {
  opacity: 0 !important;
  animation: none;
}
.cf-hint-bubble::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 50%;
  margin-left: -9px;
  width: 18px;
  height: 18px;
  background: rgba(255, 255, 255, 0.82);
  border-right: 2px solid rgba(0, 0, 0, 0.12);
  border-bottom: 2px solid rgba(0, 0, 0, 0.12);
  transform: rotate(45deg);
  border-bottom-right-radius: 4px;
}
.cf-hint-icon { margin-left: 4px; font-size: 1.05em; }
@keyframes cfHintIn {
  from { opacity: 0; transform: translate(-50%, -6px); }
  to   { opacity: 0.9; transform: translate(-50%, 0); }
}

/* responsive guard */
@media (max-width: 880px) {
  .cf-app { grid-template-columns: 1fr; grid-template-rows: 50dvh 1fr; }
  .cf-right { order: 1; }
  .cf-left {
    order: 2;
    border-right: none;
    border-top: 1px solid var(--line);
    border-bottom: none;
  }
  .cf-scroll { overflow-y: scroll; }
  /* Hide native scrollbar on mobile — we render an always-visible custom one. */
  .cf-scroll { scrollbar-width: none; }
  .cf-scroll::-webkit-scrollbar { width: 0; }
  .cf-fake-sb {
    position: absolute;
    right: 4px;
    width: 6px;
    background: rgba(238, 139, 26, 0.18);
    border-radius: 3px;
    pointer-events: none;
    z-index: 6;
  }
  .cf-fake-sb-thumb {
    position: absolute;
    left: 0;
    right: 0;
    min-height: 28px;
    background: #ee8b1a;
    border-radius: 3px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  }
  .kb-hint { display: none; }
}
/* Desktop: no custom scrollbar (native works fine). */
@media (min-width: 881px) {
  .cf-fake-sb { display: none; }
}
