@font-face { font-family: "Balsamiq Sans"; font-weight: 400; font-display: swap;
  src: url(/fonts/bs-400-cyr.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Balsamiq Sans"; font-weight: 400; font-display: swap;
  src: url(/fonts/bs-400-lat.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+20BD, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Balsamiq Sans"; font-weight: 700; font-display: swap;
  src: url(/fonts/bs-700-cyr.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Balsamiq Sans"; font-weight: 700; font-display: swap;
  src: url(/fonts/bs-700-lat.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+20BD, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --ink: #2A2140;
  --night: #26306B;
  --snow: #F2F6FD;
  --frost: #D6E3F6;
  --paper: #FFFDF7;
  --holly: #E24A3B;
  --spruce: #2E8A5A;
  --gold: #FFC23A;
  --muted: #5E5878;
  --line: 3px solid var(--ink);
  --pop: 5px 5px 0 var(--ink);
  --pop-sm: 3px 3px 0 var(--ink);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); background: var(--snow);
  font: 400 17px/1.5 "Balsamiq Sans", "Comic Sans MS", system-ui, sans-serif;
  background-image: radial-gradient(#DCE6F6 1.6px, transparent 1.8px);
  background-size: 26px 26px;
}
button, input, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px dashed var(--holly); outline-offset: 3px; }

body:not(.is-owner) .owner-only { display: none !important; }
body.is-owner .guest-only { display: none !important; }

/* ---------- шапка ---------- */
.hero {
  position: relative; min-height: 560px; overflow: hidden; background: var(--night);
}
.scene { position: absolute; inset: 0; width: 100%; height: 100%; }
.snow { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
.hero-text {
  position: relative; z-index: 2; width: min(1180px, 100% - 40px); margin: 0 auto;
  padding: clamp(96px, 13vh, 130px) 0 clamp(200px, 22vw, 290px);
}
.title {
  margin: 0; max-width: 11ch; font-weight: 700; line-height: .98; letter-spacing: -.01em;
  font-size: clamp(44px, 7.4vw, 96px); color: var(--paper);
  -webkit-text-stroke: .14em var(--ink); paint-order: stroke fill;
  text-shadow: 0 .09em 0 var(--ink);
  transform: rotate(-2deg); transform-origin: left center;
}
.subtitle {
  margin: 22px 0 0; max-width: 34ch; font-size: clamp(17px, 1.6vw, 21px); color: #EEF1FF;
  text-shadow: 0 2px 0 var(--night), 0 0 12px var(--night);
}
.stats {
  display: inline-block; margin: 14px 0 0; padding: 6px 14px; border: var(--line); border-radius: 999px;
  background: var(--gold); box-shadow: var(--pop-sm); font-weight: 700;
}
.stats:empty { display: none; }
.hero .link-btn { display: block; margin-top: 14px; color: #CFD6FF; }

.bulb ellipse { animation: glow 2.4s ease-in-out infinite; }
.b2 ellipse { animation-delay: .6s; } .b3 ellipse { animation-delay: 1.2s; } .b4 ellipse { animation-delay: 1.8s; }
@keyframes glow { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.twinkle { animation: tw 3.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.t2 { animation-delay: 1s; } .t3 { animation-delay: 2.1s; }
@keyframes tw { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.4); opacity: .5; } }

/* ---------- основная колонка ---------- */
.wrap { width: min(1180px, 100% - 32px); margin: 0 auto; padding-bottom: 60px; }

.adder, .guest-note {
  position: relative; z-index: 3; margin: -64px 0 28px; padding: 22px 24px 18px;
  background: var(--paper); border: var(--line); border-radius: 26px; box-shadow: 7px 7px 0 var(--ink);
}
.adder-label { display: block; font-weight: 700; font-size: 20px; margin-bottom: 10px; }
.adder-row { display: flex; gap: 12px; }
.adder-input {
  flex: 1; min-width: 0; padding: 14px 18px; border: var(--line); border-radius: 16px;
  background: #fff; font-size: 18px;
}
.adder-input::placeholder { color: #A39DBA; }
.adder-hint { margin: 12px 0 0; color: var(--muted); font-size: 15px; max-width: 75ch; }
.guest-note p { margin: 0; max-width: 70ch; font-size: 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 22px; border: var(--line); border-radius: 14px; background: var(--paper);
  box-shadow: var(--pop-sm); font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; color: var(--ink);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-red { background: var(--holly); color: #fff; }
.btn-green { background: var(--spruce); color: #fff; }
.btn-ghost { background: #fff; }
.btn-sm { padding: 7px 13px; font-size: 15px; border-radius: 12px; }
.btn.danger { color: var(--holly); }
.link-btn {
  padding: 0; border: 0; background: none; cursor: pointer; color: var(--muted);
  text-decoration: underline; text-decoration-style: wavy; text-underline-offset: 4px; font-size: 15px;
}

/* ---------- панель сортировки ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px 22px; align-items: center; margin: 0 0 26px; }
.tool-group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tool-end { margin-left: auto; gap: 18px; }
.pill {
  padding: 6px 14px; border: 2.5px solid var(--ink); border-radius: 999px; background: #fff; cursor: pointer;
  font-size: 15px; font-weight: 700;
}
.pill[aria-checked="true"] { background: var(--ink); color: var(--paper); }
.pill .count { opacity: .6; font-weight: 400; margin-left: 4px; }
.chip-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; border: 2px solid var(--ink); vertical-align: -1px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 700; font-size: 15px; }
.switch input { position: absolute; opacity: 0; }
.switch-track {
  width: 44px; height: 26px; border: 2.5px solid var(--ink); border-radius: 999px; background: #fff; position: relative;
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%;
  background: var(--ink); transition: transform .15s;
}
.switch input:checked + .switch-track { background: var(--spruce); }
.switch input:checked + .switch-track::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .switch-track { outline: 3px dashed var(--holly); outline-offset: 3px; }
.price-cap { font-size: 15px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.price-cap input {
  width: 118px; padding: 5px 10px; border: 2.5px solid var(--ink); border-radius: 10px; background: #fff; font-size: 15px;
}

/* ---------- карточки ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 30px 26px; }
.card {
  display: flex; flex-direction: column; background: var(--paper); border: var(--line); border-radius: 24px;
  box-shadow: var(--pop); overflow: hidden;
}
.card:nth-child(3n+1) { transform: rotate(-.6deg); }
.card:nth-child(3n+2) { transform: rotate(.5deg); }
.card-pic {
  position: relative; margin: 12px 12px 0; aspect-ratio: 1; border: var(--line); border-radius: 18px;
  background: #fff; overflow: hidden;
}
.card-pic img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.card-pic.no-img {
  background: repeating-linear-gradient(45deg, #FDEDEA 0 14px, #fff 14px 28px);
}
.card-pic.no-img::after {
  content: "🎁"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 72px;
}
.store {
  position: absolute; top: 10px; left: 10px; z-index: 2; padding: 3px 11px; border: 2.5px solid var(--ink);
  border-radius: 10px; font-size: 13px; font-weight: 700; color: #fff; background: #8A8FB3; transform: rotate(-5deg);
  box-shadow: 2px 2px 0 var(--ink);
}
.store[data-s="wb"] { background: #A43BF0; }
.store[data-s="ozon"] { background: #0062FF; }
.store[data-s="ym"] { background: #FFD21F; color: var(--ink); }
.store[data-s="ali"] { background: #F2463A; }
.store[data-s="lamoda"] { background: #1C1C1C; }
.store[data-s="goldapple"] { background: #C9A227; color: var(--ink); }
.store[data-s="mm"] { background: #7C3AED; }
.store[data-s="avito"] { background: #00AAFF; }
.store[data-s="dns"] { background: #F48120; }
.store[data-s="mvideo"] { background: #E41E26; }
.store[data-s="detmir"] { background: #3966E6; }
.stamp {
  position: absolute; z-index: 3; top: 50%; left: 50%; display: none;
  padding: 8px 18px; border: 4px double var(--holly); border-radius: 12px; color: var(--holly);
  background: rgba(255, 253, 247, .92); font-size: 22px; font-weight: 700;
  transform: translate(-50%, -50%) rotate(-12deg);
}
.card.is-reserved .stamp { display: block; }
.card.is-reserved .card-pic img { filter: grayscale(.7) opacity(.65); }

.card-body { display: flex; flex-direction: column; flex: 1; padding: 12px 16px 16px; }
.prio { display: flex; align-items: center; gap: 3px; min-height: 26px; }
.prio button { padding: 0; border: 0; background: none; cursor: default; line-height: 0; }
body.is-owner .prio button { cursor: pointer; }
.prio svg { width: 24px; height: 24px; stroke: var(--ink); stroke-width: 2.2; fill: #fff; stroke-linejoin: round; }
.prio .on svg { fill: var(--holly); }
.prio-label { margin-left: 6px; font-size: 13px; color: var(--muted); font-weight: 700; }
.card-title {
  margin: 6px 0 0; font-size: 17px; line-height: 1.3; font-weight: 700;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-note { margin: 6px 0 0; font-size: 15px; color: var(--muted); }
.card-note:empty { display: none; }
.card-price { margin: auto 0 0; padding-top: 10px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.price { font-size: 26px; font-weight: 700; }
.price.unknown { font-size: 16px; color: var(--muted); }
.price[data-approx]::before { content: "≈ "; font-weight: 400; color: var(--muted); }
.old { color: var(--muted); font-size: 15px; }
.old:empty { display: none; }
.cheaper { font-size: 13px; font-weight: 700; color: #fff; background: var(--spruce); border: 2px solid var(--ink); border-radius: 8px; padding: 1px 7px; }
.card-reserved { margin: 6px 0 0; font-size: 14px; font-weight: 700; color: var(--holly); }
.card-reserved:empty { display: none; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.owner-tools { display: none; margin-left: auto; gap: 6px; }
body.is-owner .owner-tools { display: inline-flex; }
body.is-owner .give, body.is-owner .ungive { display: none; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border: 2.5px solid var(--ink);
  border-radius: 12px; background: #fff; cursor: pointer; box-shadow: 2px 2px 0 var(--ink);
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.spin svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.card.is-loading { opacity: .7; }
.card.is-new { animation: drop .5s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes drop { from { transform: translateY(-24px) rotate(-4deg); opacity: 0; } }

.empty {
  padding: 46px 24px; text-align: center; border: 3px dashed #9AA3C7; border-radius: 26px; color: var(--muted);
  font-size: 19px; background: rgba(255, 255, 255, .6);
}
.empty b { display: block; font-size: 24px; color: var(--ink); margin-bottom: 6px; }

.foot { display: flex; flex-wrap: wrap; gap: 14px 26px; justify-content: center; margin-top: 56px; }

/* ---------- диалоги ---------- */
.dlg {
  width: min(520px, 100% - 24px); padding: 0; border: var(--line); border-radius: 26px; background: var(--paper);
  box-shadow: 8px 8px 0 var(--ink); color: var(--ink);
}
.dlg::backdrop { background: rgba(31, 39, 96, .55); }
.dlg-body { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.dlg-title { margin: 0; font-size: 26px; }
.dlg-text { margin: 0; color: var(--muted); }
.dlg-warn { margin: 0; padding: 10px 14px; border: 2.5px solid var(--ink); border-radius: 14px; background: #FFF1C7; }
.field { display: flex; flex-direction: column; gap: 5px; font-weight: 700; font-size: 15px; }
.field input, .field textarea {
  padding: 10px 14px; border: 2.5px solid var(--ink); border-radius: 12px; background: #fff; font-weight: 400; font-size: 16px;
}
.prio-field { border: 0; padding: 0; margin: 0; flex-direction: row; flex-wrap: wrap; gap: 8px 16px; }
.prio-field legend { padding: 0; margin-bottom: 6px; }
.prio-field label { font-weight: 400; display: inline-flex; gap: 6px; align-items: center; }
.prio-field input { accent-color: var(--holly); width: 18px; height: 18px; }
.dlg-actions { display: flex; flex-direction: row-reverse; gap: 10px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.spacer { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translateX(-50%);
  max-width: min(560px, 100% - 32px); padding: 12px 18px; border: var(--line); border-radius: 16px;
  background: var(--ink); color: var(--paper); box-shadow: 4px 4px 0 var(--holly); font-weight: 700;
}

@media (max-width: 720px) {
  .hero { min-height: 0; }
  .hero-text { padding: 92px 0 190px; }
  .adder-row { flex-direction: column; }
  .tool-end { margin-left: 0; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 18px 14px; }
  .card-body { padding: 10px 12px 12px; }
  .price { font-size: 21px; }
  .card-title { font-size: 15px; }
  .card { transform: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .snow { display: none; }
}

/* ---------- кнопка-закладка ---------- */
.bm { display: flex; gap: 16px; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 2.5px dashed #C9CFE6; }
.bm-btn {
  flex: none; padding: 9px 16px; border: var(--line); border-radius: 14px; background: var(--gold); color: var(--ink);
  box-shadow: var(--pop-sm); font-weight: 700; text-decoration: none; cursor: grab; transform: rotate(-2deg);
}
.bm-text { margin: 0; font-size: 15px; color: var(--muted); max-width: 70ch; }
@media (max-width: 720px) { .bm { flex-direction: column; align-items: flex-start; } }
