:root {
  --cream: #FBF5EE;
  --paper: #FFFDF9;
  --blush: #F8E4E7;
  --blush-2: #F1CBD2;
  --rose: #C98E8A;
  --lav: #9B72C0;
  --lav-2: #B794D6;
  --lav-d: #6B4590;
  --plum: #3B2647;
  --gold: #F2A60C;
  --gold-2: #F7C35A;
  --tan: #CC9A5A;
  --ink: #3B2647;
  --muted: #7C6A80;
  --line: rgba(59, 38, 71, .12);
  --shadow: 0 18px 40px -18px rgba(80, 40, 90, .35);
  --radius: 22px;
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.45;
  background: radial-gradient(1200px 700px at 10% -10%, #FCE9EC 0%, transparent 60%),
              radial-gradient(900px 600px at 110% 10%, #EFE3F7 0%, transparent 55%), var(--cream);
  min-height: 100vh;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--lav-d); }
[hidden] { display: none !important; }

/* ---------- header */
.top { display: flex; align-items: center; gap: 18px; padding: 14px clamp(16px, 3vw, 36px); position: sticky; top: 0; z-index: 30;
  background: rgba(251, 245, 238, .82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand img { display: block; height: 56px; width: auto; }
.tagline { margin: 0; color: var(--muted); font-size: 13px; max-width: 180px; line-height: 1.3; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.lang { display: flex; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.lang button { border: 0; background: none; padding: 6px 10px; border-radius: 999px; font-weight: 800; font-size: 12px; letter-spacing: .04em; color: var(--muted); }
.lang button[aria-pressed="true"] { background: var(--lav); color: #fff; }
.how-btn { border: 0; background: none; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.how-btn .q { width: 22px; height: 22px; border: 1.5px solid currentColor; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.bag-btn { border: 0; background: var(--plum); color: #fff; border-radius: 999px; padding: 9px 9px 9px 16px; display: flex; align-items: center; gap: 10px; font-weight: 700; box-shadow: var(--shadow); }
.bag-btn .count { background: var(--gold); color: var(--plum); min-width: 28px; height: 28px; border-radius: 999px; display: grid; place-items: center; font-weight: 800; padding: 0 8px; transition: transform .3s; }
.bag-btn.bump .count { transform: scale(1.3); }

/* ---------- designer layout */
.designer { display: grid; grid-template-columns: minmax(330px, 1.05fr) minmax(300px, .95fr) minmax(320px, 400px); gap: clamp(16px, 2.4vw, 36px);
  padding: clamp(16px, 3vw, 36px); max-width: 1440px; margin: 0 auto; align-items: start; }
h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(30px, 3.4vw, 44px); margin: 0 0 4px; letter-spacing: -.01em; }
.sub { margin: 0 0 14px; color: var(--muted); }
.help { color: var(--muted); font-size: 13px; margin: 10px 4px 0; }

/* ---------- wheel */
.wheel-wrap { position: relative; width: 100%; max-width: 520px; margin: 0 auto; }
.wheel { position: relative; width: 100%; aspect-ratio: 1; border-radius: 50%; outline: none; touch-action: none; user-select: none; -webkit-user-select: none; }
.wheel:focus-visible { box-shadow: 0 0 0 4px var(--lav-2); }
#wheelSvg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 16px 28px rgba(110, 60, 120, .22)); cursor: grab; }
#wheelSvg.dragging { cursor: grabbing; }
#wheelSvg .seg { cursor: pointer; }
#wheelSvg text { font-family: var(--sans); font-weight: 700; fill: var(--plum); pointer-events: none; }
#wheelSvg .seg.sel path { fill: #FFE3A3; }
#wheelSvg .seg.sel text { fill: #8A4B00; }
.wheel-center { position: absolute; inset: 30%; border-radius: 50%; background: radial-gradient(circle at 50% 35%, #fff, #FBEFF2); display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 6px var(--rose), inset 0 0 0 9px #fff, 0 6px 18px rgba(0,0,0,.08); pointer-events: none; text-align: center; padding: 6%; }
.wheel-center canvas { width: 58%; height: auto; }
.wheel-center strong { font-family: var(--serif); font-weight: 600; font-size: clamp(13px, 1.4vw, 17px); line-height: 1.1; margin-top: 2px; }
.wheel-center span { font-size: 11px; letter-spacing: .14em; color: var(--muted); font-weight: 800; }
.pointer { position: absolute; right: -30px; top: 50%; width: 46px; height: 30px; transform: translateY(-50%);
  background: linear-gradient(180deg, var(--gold-2), var(--gold)); clip-path: polygon(0 50%, 100% 0, 88% 50%, 100% 100%); filter: drop-shadow(0 2px 2px rgba(0,0,0,.2)); }
.pointer::after { content: ''; position: absolute; right: 9px; top: 50%; width: 9px; height: 9px; margin-top: -4.5px; border-radius: 50%; background: #fff; }

.search { position: relative; margin-top: 16px; }
.search svg { position: absolute; left: 16px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--muted); }
.search input { width: 100%; border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 13px 16px 13px 44px; font: inherit; color: var(--ink); outline: none; }
.search input:focus { border-color: var(--lav); box-shadow: 0 0 0 3px rgba(155, 114, 192, .2); }
.search-list { position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none; background: #fff; border-radius: 16px; box-shadow: var(--shadow); max-height: 260px; overflow: auto; }
.search-list li { padding: 9px 12px; border-radius: 10px; cursor: pointer; }
.search-list li:hover, .search-list li.active { background: var(--blush); }
.search-list li.none { color: var(--muted); cursor: default; }

/* ---------- preview card */
.card { background: var(--paper); border-radius: 6px; box-shadow: 0 30px 60px -30px rgba(80, 40, 90, .45), 0 2px 0 rgba(0,0,0,.03); padding: 18px 20px 22px; position: relative; text-align: center; }
.card::before { content: ''; position: absolute; inset: 8px; border: 1px dashed rgba(201, 142, 138, .45); border-radius: 3px; pointer-events: none; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.card-logo { height: 30px; width: auto; opacity: .9; }
.card-tag { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; font-weight: 800; color: var(--muted); max-width: 110px; text-align: right; line-height: 1.35; }
.hang { position: relative; padding-top: 12px; margin-top: 4px; }
.hook { position: absolute; left: 50%; top: 0; width: 34px; height: 14px; margin-left: -17px; border-radius: 4px; background: linear-gradient(180deg, var(--gold-2), #C9860A); }
#previewCanvas { display: block; width: 100%; max-width: 360px; height: auto; margin: 0 auto; transform-origin: 50% 0; }
#previewCanvas.swing { animation: swing 1.1s ease-out; }
@keyframes swing { 0% { transform: rotate(0); } 20% { transform: rotate(4deg); } 45% { transform: rotate(-3deg); } 70% { transform: rotate(1.4deg); } 100% { transform: rotate(0); } }
.pet-name { font-family: var(--sans); font-weight: 800; letter-spacing: .14em; text-transform: uppercase; font-size: 22px; margin: 8px 0 2px; }
.pet-size { margin: 0; color: var(--muted); font-size: 12px; }
.pet-choice { margin: 12px auto 0; display: inline-block; background: var(--blush); color: var(--lav-d); font-weight: 700; font-size: 12.5px; border-radius: 999px; padding: 6px 14px; }

/* ---------- personalizer panel */
.panel { background: linear-gradient(180deg, #A97FCF, #8458AC); border-radius: 26px; padding: 14px 14px 16px; box-shadow: var(--shadow), inset 0 2px 0 rgba(255,255,255,.25); position: relative; }
.panel::before { content: ''; position: absolute; left: 50%; top: -14px; width: 70px; height: 26px; margin-left: -35px; border-radius: 26px 26px 0 0; background: linear-gradient(180deg, var(--gold-2), var(--gold)); z-index: -1; }
.screen { background: #2B1A35; color: #FFE7B0; border-radius: 14px; padding: 10px 14px; text-align: center; font-family: ui-monospace, 'SF Mono', Menlo, monospace; box-shadow: inset 0 2px 10px rgba(0,0,0,.5); display: flex; flex-direction: column; }
.screen-small { font-size: 11px; letter-spacing: .12em; opacity: .75; text-transform: uppercase; }
.screen-big { font-size: 20px; font-weight: 700; color: var(--gold-2); }
.opts { background: linear-gradient(180deg, #FFF8EC, #F6E9D3); border-radius: 14px; padding: 10px 12px; margin-top: 12px; display: grid; gap: 10px; }
.opt-head, .keys-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--lav-d); margin-bottom: 6px; }
.opt-head em, .keys-head em { font-style: normal; letter-spacing: 0; text-transform: none; font-weight: 700; color: var(--muted); font-size: 12px; }
.swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.sw { width: 28px; height: 28px; border-radius: 50%; border: 0; padding: 0; position: relative; box-shadow: inset 0 -3px 0 rgba(0,0,0,.18), 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.sw.white { box-shadow: inset 0 -3px 0 rgba(0,0,0,.1), 0 0 0 1px rgba(0,0,0,.15); }
.sw:hover { transform: translateY(-2px); }
.sw[aria-pressed="true"]::after { content: ''; position: absolute; inset: -5px; border-radius: 50%; border: 2.5px solid var(--plum); }
.shapes { display: flex; gap: 8px; margin-bottom: 8px; }
.shape { width: 52px; height: 42px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; display: grid; place-items: center; }
.shape i { width: 30px; height: 26px; background: var(--tan); -webkit-mask: center/contain no-repeat; mask: center/contain no-repeat; }
.shape[aria-pressed="true"] { border-color: var(--plum); box-shadow: 0 0 0 2px var(--plum); }
.keys-head { color: #fff; margin: 14px 4px 8px; }
.keys-head em { color: var(--gold-2); font-family: 'Fredoka', var(--sans); font-size: 18px; line-height: 1; }
.keys { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; }
.key { aspect-ratio: 1; border-radius: 50%; border: 0; background: radial-gradient(circle at 50% 35%, #fff, #F1E6F7); font-family: 'Fredoka', var(--sans); font-weight: 600; font-size: 14px; color: var(--plum);
  box-shadow: 0 3px 0 #5E3A80, 0 4px 6px rgba(0,0,0,.25); transition: transform .08s, box-shadow .08s; padding: 0; }
.key:active { transform: translateY(2px); box-shadow: 0 1px 0 #5E3A80; }
.key[aria-pressed="true"] { background: var(--gold-2); color: var(--plum); transform: translateY(2px); box-shadow: 0 1px 0 #9a6400, 0 0 0 3px #fff; }
.add { width: 100%; margin-top: 14px; border: 0; border-radius: 14px; padding: 15px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; font-size: 13px;
  background: linear-gradient(180deg, #FFF8EC, #F3E3C7); color: var(--plum); box-shadow: 0 4px 0 #5E3A80; }
.add:active { transform: translateY(3px); box-shadow: 0 1px 0 #5E3A80; }
.add.need { animation: nudge .4s; }
@keyframes nudge { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.mini-bag { margin-top: 16px; background: rgba(255,255,255,.7); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px; }
.mini-head { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.mini-head strong { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.mini-head span { color: var(--muted); }
.link { margin-left: auto; border: 0; background: none; color: var(--lav-d); font-weight: 800; font-size: 13px; }
.mini-items { display: flex; gap: 8px; overflow-x: auto; margin-top: 8px; min-height: 8px; padding-bottom: 2px; }
.mini-items img { width: 58px; height: 70px; object-fit: contain; background: var(--cream); border-radius: 10px; padding: 4px; border: 1px solid var(--line); flex: none; }

/* ---------- drawer */
.scrim { position: fixed; inset: 0; background: rgba(40, 20, 50, .35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100%); background: var(--paper); z-index: 50; transform: translateX(105%); transition: transform .35s cubic-bezier(.2,.8,.2,1);
  display: flex; flex-direction: column; box-shadow: -20px 0 60px rgba(40,20,50,.2); }
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: baseline; gap: 10px; padding: 22px 22px 10px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-family: var(--serif); font-weight: 600; margin: 0; font-size: 26px; }
.drawer-count { color: var(--muted); }
.x { margin-left: auto; border: 0; background: var(--blush); width: 36px; height: 36px; border-radius: 50%; font-size: 22px; line-height: 1; }
.bag-list { list-style: none; margin: 0; padding: 10px 22px; overflow: auto; flex: 1; }
.bag-list li { display: grid; grid-template-columns: 84px 1fr; gap: 14px; padding: 14px 0; border-bottom: 1px dashed var(--line); }
.bag-list img { width: 84px; height: 100px; object-fit: contain; background: var(--cream); border-radius: 12px; padding: 6px; }
.bag-list h3 { margin: 2px 0 4px; font-size: 16px; }
.bag-list dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 13px; color: var(--muted); }
.bag-list dt { font-weight: 700; color: var(--ink); }
.bag-list dd { margin: 0; display: flex; align-items: center; gap: 6px; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 1px rgba(0,0,0,.15); flex: none; }
.row-actions { display: flex; gap: 14px; margin-top: 6px; }
.row-actions button { border: 0; background: none; padding: 0; font-size: 13px; font-weight: 700; color: var(--lav-d); text-decoration: underline; text-underline-offset: 3px; }
.empty { padding: 30px 22px; color: var(--muted); text-align: center; }
.drawer-foot { padding: 16px 22px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.primary { border: 0; background: var(--plum); color: #fff; border-radius: 999px; padding: 15px 26px; font-weight: 800; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; box-shadow: var(--shadow); }
.primary:disabled { opacity: .45; cursor: not-allowed; }
.primary svg { width: 20px; height: 20px; }
.drawer-foot .primary { width: 100%; }
.secondary { border: 1.5px solid var(--plum); background: #fff; color: var(--plum); border-radius: 999px; padding: 13px 22px; font-weight: 800; }
.ghost { border: 0; background: none; color: var(--muted); font-weight: 700; margin-top: 18px; }

/* ---------- wrapped */
.wrapped { max-width: 980px; margin: 0 auto; padding: 30px 16px 40px; text-align: center; }
.gift-scene { position: relative; display: flex; justify-content: center; align-items: flex-end; gap: 90px; min-height: 380px; padding-top: 60px; }
.gift { position: relative; width: min(340px, 82vw); }
.gift .box { width: 100%; display: block; position: relative; z-index: 2; filter: drop-shadow(0 22px 22px rgba(80,40,90,.25)); }
.gift .lid { position: absolute; width: 100%; left: 0; top: -60px; z-index: 3; transform-origin: 85% 100%; animation: lid 1.2s .3s cubic-bezier(.3,1.4,.5,1) forwards; }
@keyframes lid { to { transform: translate(6%, -95%) rotate(14deg); } }
.peek { position: absolute; left: 6%; right: 6%; bottom: 72%; display: flex; justify-content: center; align-items: flex-end; z-index: 1; }
.peek img { width: 30%; max-width: 112px; margin: 0 -5%; transform: translateY(60%); animation: pop .8s cubic-bezier(.3,1.5,.5,1) forwards; }
@keyframes pop { to { transform: translateY(0); } }
.heart { position: absolute; color: #E58FA5; font-size: 20px; animation: float 3s ease-in-out infinite; z-index: 4; }
.h1 { left: 4%; top: -40px; } .h2 { right: 8%; top: -90px; animation-delay: .8s; font-size: 14px; } .h3 { left: 30%; top: -120px; animation-delay: 1.4s; font-size: 16px; }
@keyframes float { 50% { transform: translateY(-10px); } }
.note { background: #fff; padding: 14px 18px 12px; border-radius: 4px; box-shadow: var(--shadow); transform: rotate(3deg); text-align: left; max-width: 240px; align-self: flex-start; margin-top: 10px; font-size: 13px; }
.note strong { font-family: var(--serif); font-size: 18px; font-weight: 600; }
.note ol { margin: 6px 0 0; padding-left: 18px; color: var(--muted); }
.wrapped-title { margin-top: 34px; }
.wrapped-sub { color: var(--muted); max-width: 520px; margin: 4px auto 20px; }
.wrapped-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.send-note { max-width: 540px; margin: 16px auto 0; background: var(--blush); border-radius: 16px; padding: 14px 18px; font-weight: 600; }
.send-note a { font-weight: 800; }
.summary-preview { margin: 24px auto 0; max-width: 420px; }
.summary-preview img { width: 100%; border-radius: 12px; box-shadow: var(--shadow); }

/* ---------- misc */
.how { border: 0; border-radius: 24px; padding: 26px 28px; max-width: 460px; width: calc(100% - 32px); color: var(--ink); background: var(--paper); box-shadow: var(--shadow); }
.how::backdrop { background: rgba(40, 20, 50, .4); }
.how h2 { font-family: var(--serif); font-weight: 600; margin: 0 0 10px; }
.how ol { padding-left: 20px; margin: 0 0 18px; }
.how li { margin: 10px 0; }
.how li b { display: block; }
.how li span { color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, calc(100% + 60px)); visibility: hidden; background: var(--plum); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 700; z-index: 60; transition: transform .35s, visibility .35s; box-shadow: var(--shadow); max-width: calc(100% - 32px); text-align: center; }
.toast.show { transform: translate(-50%, 0); visibility: visible; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 20px 16px 30px; }

/* ---------- responsive */
@media (max-width: 1180px) {
  .designer { grid-template-columns: 1fr 1fr; }
  .col-wheel { grid-column: 1 / -1; max-width: 620px; margin: 0 auto; width: 100%; }
}
@media (max-width: 760px) {
  .top { gap: 10px; padding: 10px 16px; }
  .brand img { height: 40px; }
  .tagline, .how-btn span:first-child { display: none; }
  .bag-btn { padding: 7px 7px 7px 12px; font-size: 13px; }
  .designer { grid-template-columns: 1fr; padding: 16px; }
  .col-preview { order: 2; } .col-panel { order: 3; }
  .pointer { right: -16px; width: 34px; height: 24px; }
  .gift-scene { flex-direction: column; align-items: center; min-height: 0; padding-top: 110px; gap: 40px; }
  .note { align-self: center; transform: rotate(-2deg); }
}
@media (max-width: 400px) {
  .lang button { padding: 6px 7px; }
  .bag-btn > span:first-child { display: none; }
  .keys { gap: 5px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
