:root {
  --cream:   #FFF9F4;
  --ink:     #2E2230;
  --ink-soft:#6E5F72;
  --pink:    #FF6FA5;
  --pink-lt: #FFE3EE;
  --lilac:   #C9A3FF;
  --mint:    #B6E3B7;
  --butter:  #FFE7B0;
  --line:    rgba(46, 34, 48, .10);
  --card:    #FFFFFF;
  --radius:  26px;
  --shadow:  0 18px 44px -22px rgba(46,34,48,.38);
  --mix:     #F3E7F3;
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  background: var(--cream);
  color: var(--ink);
  font-family: Manrope, ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, .cta, .btn, .num, .kicker { font-family: Fredoka, Manrope, sans-serif; }

/* --- tlo --- */
.blobs { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.blobs span {
  position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5;
  animation: float 18s ease-in-out infinite;
}
.blobs span:nth-child(1) { width: 46vw; height: 46vw; background: var(--pink-lt);  top: -12vw; left: -10vw; }
.blobs span:nth-child(2) { width: 38vw; height: 38vw; background: #E6DBFF; top: 40vh; right: -12vw; animation-delay: -6s; }
.blobs span:nth-child(3) { width: 34vw; height: 34vw; background: #DFF3E0; bottom: -14vw; left: 22vw; animation-delay: -12s; }
@keyframes float { 50% { transform: translate3d(0, -4vh, 0) scale(1.08); } }

/* --- layout --- */
.lab { max-width: 1140px; margin: 0 auto; padding: 56px 22px 80px; }

.lab__head { max-width: 640px; margin-bottom: 40px; }
.kicker {
  margin: 0 0 12px; font-size: 13px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--pink); font-weight: 600;
}
.lab__head h1 { margin: 0 0 14px; font-size: clamp(38px, 6.4vw, 64px); line-height: 1.02; font-weight: 600; }
.lab__head h1 em { font-style: normal; color: var(--pink); }
.lede { margin: 0; font-size: 17px; line-height: 1.6; color: var(--ink-soft); }

.stage { display: grid; grid-template-columns: 420px 1fr; gap: 36px; align-items: start; }
@media (max-width: 900px) { .stage { grid-template-columns: 1fr; } }

/* --- sloik --- */
.stage__jar {
  position: sticky; top: 24px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; text-align: center;
}
@media (max-width: 900px) { .stage__jar { position: static; } }
#jar { width: 100%; height: auto; display: block; }
.jar__code {
  margin-top: 6px; font-family: Fredoka, sans-serif; font-size: 13px;
  letter-spacing: .3em; color: var(--ink-soft);
}

/* --- panel --- */
.stage__panel { display: flex; flex-direction: column; gap: 26px; }
.step {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px;
}
.step__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.step h2 { margin: 0; font-size: 21px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.num {
  display: grid; place-items: center; width: 27px; height: 27px; border-radius: 50%;
  background: var(--pink); color: #fff; font-size: 14px; font-weight: 600;
}
.counter { font-size: 13px; color: var(--ink-soft); font-weight: 700; }
.hint { margin: 8px 0 0; font-size: 13.5px; color: var(--ink-soft); line-height: 1.5; }

.chips { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 16px; }
.chip {
  position: relative; display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px 9px 11px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  font: 500 14.5px Manrope, sans-serif; transition: transform .16s, border-color .16s, background .16s;
}
.chip:hover { transform: translateY(-2px); }
.chip .dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.chip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }
.chip[aria-pressed="true"]::after {
  content: attr(data-order); position: absolute; top: -7px; right: -5px;
  width: 20px; height: 20px; border-radius: 50%; background: var(--pink); color: #fff;
  font: 600 11px Fredoka, sans-serif; display: grid; place-items: center;
}
.chip[disabled] { opacity: .35; cursor: not-allowed; transform: none; }

.moods { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 16px; }
.mood {
  cursor: pointer; border-radius: 16px; border: 1.5px solid var(--line); background: #fff;
  padding: 11px 15px; text-align: left; transition: transform .16s, border-color .16s;
  font-family: Manrope, sans-serif;
}
.mood:hover { transform: translateY(-2px); }
.mood b { display: block; font: 600 14.5px Fredoka, sans-serif; }
.mood small { color: var(--ink-soft); font-size: 12px; }
.mood[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }

/* --- cta --- */
.cta {
  position: relative; border: 0; cursor: pointer; border-radius: 999px;
  background: var(--ink); color: #fff; padding: 18px 30px;
  font-size: 18px; font-weight: 600; box-shadow: var(--shadow);
  transition: transform .16s, opacity .16s;
}
.cta:hover:not([disabled]) { transform: translateY(-2px); }
.cta[disabled] { opacity: .4; cursor: not-allowed; }
.cta__spinner { display: none; }
.cta.is-busy .cta__label { opacity: .35; }
.cta.is-busy .cta__spinner {
  display: block; position: absolute; inset: 0; margin: auto; width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error { margin: 0; color: #C2185B; font-size: 14px; font-weight: 600; }

/* --- wynik --- */
.result { margin-top: 56px; animation: rise .5s cubic-bezier(.2,.7,.3,1); }
@keyframes rise { from { opacity: 0; transform: translateY(22px); } }
.result__grid { display: grid; grid-template-columns: 380px 1fr; gap: 32px; align-items: start; }
@media (max-width: 900px) { .result__grid { grid-template-columns: 1fr; } }

#labelSlot canvas { width: 100%; height: auto; border-radius: 22px; box-shadow: var(--shadow); display: block; }
.result__actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 16px; }

.btn {
  cursor: pointer; border-radius: 999px; border: 1.5px solid var(--line); background: #fff;
  color: var(--ink); padding: 11px 18px; font: 600 14px Fredoka, sans-serif;
  transition: transform .16s, border-color .16s;
}
.btn:hover { transform: translateY(-2px); border-color: var(--ink); }
.btn--primary { background: var(--pink); border-color: var(--pink); color: #fff; }
.btn--ghost { background: transparent; }
.btn--vote {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  background: var(--butter); border-color: transparent; padding: 15px 20px; font-size: 15px;
}
.btn--vote b { font-size: 17px; }
.btn--vote.is-voted { background: var(--mint); }

.result__side { display: flex; flex-direction: column; gap: 18px; }

.aura { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.aura__kicker { margin: 0 0 6px; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--pink); font-weight: 700; }
.aura h3 { margin: 0 0 8px; font-size: 27px; font-weight: 600; }
.aura p { margin: 0; color: var(--ink-soft); line-height: 1.6; }
.aura__tag { margin-top: 12px !important; color: var(--pink) !important; font-weight: 700; }

.exists { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.exists__top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.exists__top p { margin: 0; color: var(--ink-soft); font-size: 15px; }
.exists__top strong { font: 600 32px Fredoka, sans-serif; color: var(--pink); }
.exists__bar { height: 10px; border-radius: 999px; background: var(--pink-lt); margin: 12px 0 0; overflow: hidden; }
.exists__bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--pink); transition: width .9s cubic-bezier(.2,.7,.3,1); }

.matches { display: flex; flex-direction: column; gap: 10px; }
.match {
  display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit;
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 15px 18px;
  transition: transform .16s;
}
.match:hover { transform: translateY(-2px); }
.match__fit {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: var(--pink-lt); color: var(--pink); font: 600 14px Fredoka, sans-serif;
}
.match__body { min-width: 0; }
.match__body b { display: block; font-size: 14.5px; font-weight: 700; line-height: 1.3; }
.match__body small { color: var(--ink-soft); font-size: 12.5px; }
.match__price { margin-left: auto; font: 600 15px Fredoka, sans-serif; white-space: nowrap; }

/* --- ranking --- */
.board { margin-top: 64px; }
.board__head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.board__head h2 { margin: 0; font-size: 26px; font-weight: 600; }
.board__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.board__item {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 14px 18px;
}
.board__rank { font: 600 15px Fredoka, sans-serif; color: var(--ink-soft); width: 22px; }
.board__swatch { width: 34px; height: 34px; border-radius: 12px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.07); }
.board__name { font-weight: 700; font-size: 14.5px; }
.board__meta { color: var(--ink-soft); font-size: 12.5px; }
.board__votes { margin-left: auto; font: 600 15px Fredoka, sans-serif; }
.board__empty { color: var(--ink-soft); font-size: 14.5px; padding: 18px; }

.lab__foot { margin-top: 56px; color: var(--ink-soft); font-size: 13px; }
#modeBadge { font-weight: 700; }

/* --- tryb embed (iframe na stronie marki) --- */
body.is-embed .lab { padding: 26px 18px 40px; }
body.is-embed .lab__head h1 { font-size: clamp(30px, 5vw, 42px); }
body.is-embed .lab__foot { display: none; }

@media (prefers-reduced-motion: reduce) {
  .blobs span, .cta__spinner, .render-status__visual::before, .render-status__visual i { animation: none; }
  .result { animation: none; }
}

/* --- mobile: elementy gridu musza moc sie kurczyc ponizej swojej szerokosci wewnetrznej --- */
.stage__jar, .stage__panel, .result__label, .result__side { min-width: 0; }
#jar { max-width: 100%; }
.match__body { flex: 1 1 auto; }
.match__body b, .board__name { overflow-wrap: anywhere; }

@media (max-width: 560px) {
  .lab { padding: 34px 16px 64px; }
  .step { padding: 19px; }
  .chips, .moods { gap: 7px; }
  .chip { padding: 8px 12px 8px 10px; font-size: 13.5px; }
  .mood { padding: 10px 13px; flex: 1 1 100%; }
  .cta { padding: 16px 24px; font-size: 17px; }
  .aura, .exists { padding: 20px; }
  .result__actions .btn { flex: 1 1 auto; }
}

/* --- chwila tworzenia finalnej etykiety --- */
.render-status {
  display: flex; align-items: center; gap: 13px; margin: 14px 0 0;
  padding: 12px 14px; border-radius: 18px; background: linear-gradient(110deg, var(--pink-lt), #f2eaff 54%, #e4f6e5);
  color: var(--ink-soft);
}
.render-status__visual {
  position: relative; width: 46px; height: 46px; flex: 0 0 46px;
  border-radius: 16px; background: rgba(255,255,255,.7); overflow: hidden;
}
.render-status__visual::before {
  content: ''; position: absolute; inset: 12px; border-radius: 50%;
  background: conic-gradient(var(--pink), var(--lilac), var(--mint), var(--pink));
  animation: mix-glow 1.8s linear infinite;
}
.render-status__visual i {
  position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--pink);
  box-shadow: 0 0 0 3px rgba(255,111,165,.14); animation: orbit 1.5s ease-in-out infinite;
}
.render-status__visual i:nth-child(1) { top: 7px; left: 20px; }
.render-status__visual i:nth-child(2) { top: 29px; left: 7px; background: var(--lilac); animation-delay: -.5s; }
.render-status__visual i:nth-child(3) { top: 29px; right: 7px; background: var(--mint); animation-delay: -1s; }
.render-status__visual span { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 16px; }
.render-status__copy { min-width: 0; }
.render-status__copy strong { display: block; color: var(--ink); font: 600 15px Fredoka, sans-serif; }
.render-status__copy span { display: block; margin-top: 2px; font-size: 12.5px; line-height: 1.35; }
@keyframes mix-glow { to { transform: rotate(360deg); } }
@keyframes orbit { 50% { transform: translateY(-4px) scale(1.15); } }
.render-status.is-done { background: #e8f7e8; }
.render-status.is-done .render-status__visual::before { animation: none; background: var(--mint); }
.render-status.is-done .render-status__visual i { display: none; }
.render-status.is-done .render-status__visual span { color: var(--ink); }
.render-status.is-failed { background: #f6f1f3; }
.render-status.is-failed .render-status__visual::before { animation: none; background: var(--line); }
.render-status.is-failed .render-status__visual i { display: none; }
.render-status.is-failed .render-status__visual span { color: var(--ink-soft); }
.render-status.is-failed .render-status__visual span { font-size: 0; }
.render-status.is-failed .render-status__visual span::after { content: '…'; font-size: 24px; }
.render-status b { color: var(--pink); text-decoration: underline; }
.render-status[style*="pointer"]:hover b { color: var(--ink); }
