* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Archivo', system-ui, sans-serif;
  background: #f4f2ef;
  color: #111;
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- top bar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 58px; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px;
}
.top-left { display: flex; gap: 22px; flex: 1; }
.top-left a {
  text-decoration: none; color: #111; font-size: 11px; font-weight: 600;
  letter-spacing: .18em;
}
.wordmark {
  flex: 1; text-align: center; font-weight: 800; font-size: 17px;
  letter-spacing: .34em; cursor: pointer; padding-left: .34em;
}
.top-right { flex: 1; display: flex; justify-content: flex-end; gap: 6px; }
.icon-btn { position: relative; background: none; border: none; cursor: pointer; padding: 6px; color: #111; }
.bag-count {
  position: absolute; top: -1px; right: -3px; min-width: 16px; height: 16px; padding: 0 4px;
  background: #111; color: #fff; border-radius: 999px; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- rail stage ---------- */
.stage {
  position: fixed; inset: 58px 0 30px 0; overflow: hidden;
  touch-action: none; cursor: grab; perspective: 1400px;
}
.stage.dragging { cursor: grabbing; }
.rail-rod {
  position: absolute; top: 34px; left: 4%; right: 4%; height: 2px; z-index: 5;
  background: #b9b6b1; border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.rail-rod::before, .rail-rod::after {
  content: ""; position: absolute; top: -3px; width: 8px; height: 8px; border-radius: 50%;
  background: #a5a29d;
}
.rail-rod::before { left: -4px; }
.rail-rod::after { right: -4px; }

.track { position: absolute; inset: 0; transform-style: preserve-3d; }
.item {
  position: absolute; top: 26px; left: 50%;
  width: 168px; height: 300px; margin-left: -84px;
  transform-origin: 50% 0;
  will-change: transform, opacity;
  cursor: pointer;
}
.item img {
  width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none;
  filter: drop-shadow(0 14px 14px rgba(0,0,0,.16));
}
.item .tag {
  position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%);
  font-size: 10px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  color: #555; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .2s;
}
.item.center .tag { opacity: 1; }

.rail-note {
  position: absolute; left: 0; right: 0; bottom: 26px; text-align: center;
  font-size: 10px; letter-spacing: .26em; color: #9a968f; pointer-events: none;
  white-space: nowrap;
}

/* ---------- product view ---------- */
.product {
  position: fixed; inset: 0; z-index: 60; display: none;
  background: #ece9e4; overflow: hidden;
}
.product.open { display: block; }
.edge-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 5;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,.25); background: transparent; color: #111;
  font-size: 26px; line-height: 1; cursor: pointer; transition: .15s;
  display: flex; align-items: center; justify-content: center; padding-bottom: 3px;
}
.edge-arrow:hover { background: #111; color: #fff; }
.edge-arrow.left { left: 26px; }
.edge-arrow.right { right: 26px; }
.prod-close {
  position: absolute; top: 74px; right: 26px; z-index: 5;
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid rgba(0,0,0,.25);
  background: transparent; font-size: 14px; cursor: pointer;
}
.prod-close:hover { background: #111; color: #fff; }

.prod-stage {
  position: absolute; top: 58px; left: 0; right: 0; bottom: 276px;
  display: flex; align-items: flex-start; justify-content: center;
  cursor: grab; touch-action: none; perspective: 1300px;
}
.prod-stage.dragging { cursor: grabbing; }
.prod-hook {
  position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  width: 2px; height: 26px; background: #b9b6b1;
}
.prod-flip { height: 100%; margin-top: 8px; perspective: 1200px; }
.prod-flip.swap { animation: prodColorSwap .34s ease; }
@keyframes prodColorSwap {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: .25; transform: scale(.94); }
  100% { opacity: 1; transform: scale(1); }
}
.prod-flip.enter { animation: prodIn .35s cubic-bezier(.2,1.2,.4,1); }
@keyframes prodIn { from { transform: translateY(14px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.prod-flip-inner { position: relative; height: 100%; transform-style: preserve-3d; }
.prod-face {
  height: 100%; max-width: 62vw; object-fit: contain; display: block;
  backface-visibility: hidden; pointer-events: none;
  filter: drop-shadow(0 26px 26px rgba(0,0,0,.20));
  transition: opacity .1s;
}
.prod-face.back {
  position: absolute; top: 0; left: 50%;
  transform: translateX(-50%) rotateY(180deg) scaleX(-1);
}
.prod-face.back.real-back {
  transform: translateX(-50%) rotateY(180deg);
}

.prod-variants {
  position: absolute; top: 34%; right: max(90px, 16vw);
  display: flex; flex-direction: column; gap: 12px;
}
.variant-thumb {
  width: 44px; height: 56px; border: 1px solid rgba(0,0,0,.18); background: #f6f4f1;
  padding: 3px; cursor: pointer; transition: .15s;
}
.variant-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.variant-thumb.active { border-color: #111; box-shadow: 0 0 0 1px #111; }

.prod-info {
  position: absolute; left: 0; right: 0; bottom: 0; height: 276px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding-top: 8px; gap: 0;
}
.prod-name { font-size: 19px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.prod-price { font-size: 14px; color: #666; margin-top: 5px; letter-spacing: .06em; }
.prod-sizes { display: flex; gap: 10px; margin: 14px 0 16px; }
.prod-size {
  min-width: 44px; height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid rgba(0,0,0,.3); background: transparent;
  font-size: 12px; font-weight: 600; letter-spacing: .08em; cursor: pointer; transition: .15s;
}
.prod-size.active, .prod-size:hover { background: #111; color: #fff; border-color: #111; }
.prod-add {
  min-width: 300px; padding: 14px 40px; border: none; border-radius: 999px;
  background: #111; color: #fff; font-size: 13px; font-weight: 700;
  letter-spacing: .18em; cursor: pointer; transition: .15s;
}
.prod-rot-row { display: flex; gap: 8px; margin: 0 0 14px; }
.rot-pill {
  padding: 7px 15px; border-radius: 999px; border: 1px solid rgba(0,0,0,.3);
  background: transparent; color: #111; font-size: 11px; font-weight: 700;
  letter-spacing: .12em; cursor: pointer; transition: .15s;
}
.rot-pill.active, .rot-pill:hover { background: #111; color: #fff; }
.prod-add:hover { transform: scale(1.03); }
.prod-meta { font-size: 10px; letter-spacing: .2em; color: #9a968f; margin-top: 14px; }

/* ---------- toast / footer ---------- */
.toast {
  position: fixed; left: 50%; bottom: 60px; transform: translateX(-50%) translateY(20px);
  background: #111; color: #fff; padding: 12px 26px; border-radius: 999px; font-weight: 700; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .3s; z-index: 90; box-shadow: 0 12px 30px rgba(0,0,0,.3);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.foot {
  position: fixed; left: 0; right: 0; bottom: 0; height: 30px; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #9a968f; letter-spacing: .04em;
}
.foot a { color: #111; font-weight: 700; }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  .top-left { display: none; }
  .wordmark { text-align: left; padding-left: 0; }
  .item { width: 132px; height: 236px; margin-left: -66px; }
  .edge-arrow { width: 38px; height: 38px; }
  .edge-arrow.left { left: 10px; }
  .edge-arrow.right { right: 10px; }
  .prod-variants { right: 16px; top: 30%; }
  .prod-stage { bottom: 288px; }
  .prod-add { min-width: 260px; }
  .rail-note { font-size: 9px; letter-spacing: .18em; }
}
