/* Гостевая полка. Словарь — «Витрина» из app/src/ui/theme.ts: светлый пол, предмет на тоновой плитке,
   цвет только у главного действия, у кружка хозяина и у «Вы дарите». */
/* Onest (SIL OFL 1.1, fonts/OFL.txt) — гротеск, сделанный под кириллицу; свой файл, без внешних CDN. */
@font-face { font-family: "Onest"; font-style: normal; font-display: swap; font-weight: 100 900; src: url(./fonts/onest-cyrillic.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-style: normal; font-display: swap; font-weight: 100 900; src: url(./fonts/onest-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Onest"; font-style: normal; font-display: swap; font-weight: 100 900; src: url(./fonts/onest-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  color-scheme: light dark;
  --ground: #fafafb;
  --tile: #eeeef1;
  --tile-2: #e6e6ea;
  --sheet: #fff;
  --field: rgba(118, 118, 128, .12);
  --label: #000;
  --label-2: rgba(60, 60, 67, .6);
  --label-3: rgba(60, 60, 67, .3);
  --sep: rgba(60, 60, 67, .18);
  --accent: #d63a22;
  --accent-press: #bf2f19;
  --owner: #c92f73;
  --gift: #16794a;
  --gift-tint: #e3f3ea;
  --chip: #000;
  --on-chip: #fff;
  --glass: rgba(250, 250, 251, .78);
  --shadow: rgba(0, 0, 0, .18);
  --sheet-shadow: 0 -10px 60px rgba(0, 0, 0, .16);
  --radius: 24px;
  --gutter: 16px;
  --sans: "Onest", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
  --rounded: var(--sans);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #000;
    --tile: #1c1c1e;
    --tile-2: #232326;
    --sheet: #1c1c1e;
    --field: rgba(118, 118, 128, .24);
    --label: #fff;
    --label-2: rgba(235, 235, 245, .6);
    --label-3: rgba(235, 235, 245, .3);
    --sep: rgba(84, 84, 88, .5);
    --accent: #e5472e;
    --accent-press: #f0604a;
    --owner: #e0549a;
    --gift: #34c77b;
    --gift-tint: rgba(52, 199, 123, .16);
    --chip: #fff;
    --on-chip: #000;
    --glass: rgba(0, 0, 0, .72);
    --shadow: rgba(0, 0, 0, .5);
    --sheet-shadow: 0 -10px 60px rgba(0, 0, 0, .6);
  }
  .sheet .sheet-art, .sheet .art { --tile: #2c2c2e; }
  .hint .button.quiet { background: #3a3a3c; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ground);
  color: var(--label);
  font: 17px/1.3 var(--sans);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, p { margin: 0; }
button, input, a { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; touch-action: manipulation; }
a { text-decoration: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid #6b82ff; outline-offset: 3px; border-radius: 12px; }
[hidden] { display: none !important; }

.wrap { width: min(1120px, 100% - 2 * var(--gutter)); margin-inline: auto; }
@media (min-width: 760px) { :root { --gutter: 40px; } }

/* ——— верх ——— */
.top {
  position: sticky; top: 0; z-index: 10;
  padding-top: env(safe-area-inset-top);
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid transparent;
  transition: border-color .2s;
}
.top.scrolled { border-bottom-color: var(--sep); }
.top-bar { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 650; font-size: 17px; letter-spacing: -.01em; }
.brand img { border-radius: 8px; transform: rotate(-6deg); }
.pill-button {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 14px 0 12px; border-radius: 999px;
  background: var(--field); font-size: 15px; font-weight: 600;
  transition: transform .15s var(--ease), background .2s;
}
.pill-button svg { width: 18px; height: 18px; }
.pill-button:active { transform: scale(.96); }

/* ——— шапка полки ——— */
.hero { padding: 20px 0 18px; }
@media (min-width: 760px) { .hero { padding: 48px 0 28px; } }
.eyebrow { color: var(--label-2); font-size: 15px; line-height: 20px; }
.who { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.avatar {
  display: grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--owner); color: #fff; font-weight: 700; font-size: 18px;
}
.avatar:empty { background: var(--tile); }
h1 { text-wrap: balance; font-size: 30px; line-height: 36px; font-weight: 650; letter-spacing: -.025em; overflow-wrap: anywhere; }
@media (min-width: 760px) { h1 { font-size: 36px; line-height: 42px; } .avatar { width: 48px; height: 48px; font-size: 22px; } .who { gap: 14px; } }
.sub { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; color: var(--label-2); font-size: 15px; line-height: 22px; min-height: 32px; }
.occasion {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px; max-width: 100%; padding: 6px 12px 6px 10px; border-radius: 16px;
  background: var(--field); color: var(--label); font-size: 15px; line-height: 20px; font-weight: 600;
}
.occasion svg { width: 17px; height: 17px; color: var(--owner); }
.occasion span { color: var(--label-2); font-weight: 500; white-space: nowrap; }
.occasion.soon { background: color-mix(in srgb, var(--owner) 14%, transparent); }
.skeleton-text { display: inline-block; width: 6.5em; height: .9em; border-radius: 12px; background: var(--tile); vertical-align: middle; }

/* ——— подсказка гостю ——— */
.hint {
  display: grid; gap: 12px;
  margin-bottom: 18px; padding: 16px 16px 14px;
  border-radius: 22px; background: var(--tile);
}
@media (min-width: 760px) { .hint { grid-template-columns: 1fr auto; align-items: center; padding: 20px 24px; } }
.hint strong { font-size: 17px; font-weight: 600; }
.hint-actions .button { min-height: 40px; }
.hint p { margin-top: 4px; color: var(--label-2); font-size: 15px; line-height: 20px; max-width: 60ch; }
.hint-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
@media (min-width: 760px) { .hint-actions { flex-direction: column; align-items: flex-end; } }
.hint-note { color: var(--label-2); font-size: 14px; }

/* ——— кнопки ——— */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: 16px;
  background: var(--field); font-size: 17px; font-weight: 600;
  transition: transform .15s var(--ease), background .2s, opacity .2s;
}
.button:active { transform: scale(.97); }
.button.primary { background: var(--accent); color: #fff; }
.button.primary:active { background: var(--accent-press); }
.button.quiet { min-height: 44px; background: var(--sheet); border-radius: 999px; font-size: 15px; padding: 0 18px; }
.button[disabled] { opacity: .5; pointer-events: none; }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--field); }
.icon-button svg { width: 18px; height: 18px; stroke-width: 2.4; }
.link-button { display: inline-flex; align-items: center; gap: 6px; margin-top: 16px; color: var(--label-2); font-size: 15px; }
.link-button svg { width: 17px; height: 17px; }

/* ——— фильтры ——— */
.chips {
  position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 5;
  display: flex; gap: 8px; align-items: center;
  margin: 0 calc(-1 * var(--gutter)); padding: 8px var(--gutter) 12px;
  overflow-x: auto; scrollbar-width: none;
  background: linear-gradient(var(--ground) 75%, transparent);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  background: var(--field); font-size: 15px; font-weight: 500; white-space: nowrap;
  transition: background .2s, color .2s, transform .15s var(--ease);
}
.chip:active { transform: scale(.95); }
.chip[aria-pressed="true"] { background: var(--chip); color: var(--on-chip); }
.chip .count { font-weight: 500; opacity: .6; }
.chip.mine[aria-pressed="false"] { color: var(--gift); }
.chips .divider { flex: none; width: 1px; height: 20px; background: var(--sep); margin: 0 2px; }

/* ——— полка: ряды из шести долей (на широком — двенадцати); в ряду плитки одной высоты ——— */
.shelf { display: grid; grid-template-columns: minmax(0, 1fr); gap: 26px; padding: 6px 0 40px; }
@media (min-width: 760px) { .shelf { gap: 40px; } }
.row {
  --gap: 12px;
  container-type: inline-size;
  width: 100%;
  display: grid; gap: var(--gap); align-items: start;
}
@media (min-width: 760px) { .row { --gap: 20px; } }
.tile { display: block; width: 100%; text-align: left; min-width: 0; }
.art {
  position: relative; overflow: hidden; isolation: isolate;
  display: grid; place-items: center;
  aspect-ratio: 1; border-radius: var(--radius);
  background: var(--tile);
}
/* Высота ряда — квадрат самой узкой плитки: (ширина ряда − зазоры) × узкая доля / сумма долей. */
.row .art {
  aspect-ratio: auto;
  height: min(calc((100cqw - var(--gaps)) * var(--min) / var(--total)), 460px);
}
.row.solo .art { height: auto; aspect-ratio: 4 / 3; }
@media (min-width: 760px) { .row.solo .art { aspect-ratio: 21 / 9; } }
.tile.big .art { border-radius: 28px; }
@media (min-width: 760px) { .tile.big .art { border-radius: 32px; } }
.tile.small .art { border-radius: 20px; }
.art img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: 0;
  transition: opacity .35s ease, transform .45s var(--ease), filter .3s;
}
.art img.cutout { inset: 11%; width: 78%; height: 78%; object-fit: contain; filter: drop-shadow(0 12px 14px var(--shadow)); }
.tile.big .art img.cutout { inset: 9%; width: 82%; height: 82%; }
.art img.in { opacity: 1; }
.art .glyph { width: 30%; max-width: 64px; height: auto; color: var(--label-3); stroke-width: 1.6; }
.art.loaded .glyph { display: none; }
@media (hover: hover) { .tile:hover .art img.in { transform: scale(1.04); } }
.tile:active .art { transform: scale(.98); }
.art { transition: transform .2s var(--ease); }

.tile.taken .art img, .tile.taken .art .glyph { opacity: .4; filter: grayscale(.9); }
.tile.taken .art img.cutout { filter: grayscale(.9) drop-shadow(0 12px 14px transparent); }
.badge {
  position: absolute; left: 10px; bottom: 10px; z-index: 1;
  display: inline-flex; align-items: center; gap: 5px; max-width: calc(100% - 20px);
  height: 30px; padding: 0 11px 0 9px; border-radius: 999px;
  background: var(--sheet); color: var(--label); font-size: 14px; font-weight: 600;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .08);
}
.badge span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge svg { width: 15px; height: 15px; stroke-width: 2.6; }
.badge.mine { background: var(--gift); color: #fff; }
.tile.small .badge { left: 6px; bottom: 6px; height: 26px; font-size: 13px; padding: 0 9px 0 7px; }

.caption { display: grid; gap: 2px; padding: 10px 2px 0; overflow-wrap: anywhere; }
.meta { color: var(--label-2); font-size: 14px; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.name {
  text-wrap: pretty;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 15px; line-height: 20px; font-weight: 550; letter-spacing: -.005em;
}
.tile.big .name { font-size: 20px; line-height: 25px; }
@media (min-width: 760px) { .name { font-size: 17px; line-height: 22px; } .tile.big .name { font-size: 24px; line-height: 29px; letter-spacing: -.02em; } }
.price { font-family: var(--rounded); font-weight: 600; font-size: 15px; line-height: 20px; }
.tile.big .price { font-size: 17px; }
.tile.small .name, .tile.small .price { font-size: 14px; line-height: 18px; }

/* появление */
@media (prefers-reduced-motion: no-preference) {
  .tile.enter { animation: rise .55s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }
  @keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }
}

/* скелет */
.ghost .art { background: var(--tile); }
.ghost .line { height: 14px; border-radius: 7px; background: var(--tile); margin-top: 10px; width: 70%; }
.ghost .line + .line { width: 40%; margin-top: 6px; }
@media (prefers-reduced-motion: no-preference) {
  .ghost .art, .ghost .line, .skeleton-text { animation: pulse 1.4s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: .55; } }
}

/* ——— пусто / ошибка ——— */
.state { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 48px 0 80px; }
.state-art { width: 64px; height: 64px; color: var(--label-3); stroke-width: 2; margin-bottom: 6px; }
.state h2 { font-size: 22px; line-height: 28px; font-weight: 700; }
.state p { color: var(--label-2); max-width: 34ch; }
.state .button { margin-top: 10px; }

.foot { display: grid; gap: 6px; padding: 24px 0 calc(110px + env(safe-area-inset-bottom)); border-top: .5px solid var(--sep); color: var(--label-2); font-size: 14px; line-height: 19px; }
.foot p { max-width: 62ch; }

/* ——— «Вы дарите» внизу ——— */
.mine-bar {
  position: fixed; z-index: 20; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 8px; max-width: calc(100% - 32px);
  height: 48px; padding: 0 20px 0 16px; border-radius: 999px;
  background: var(--gift); color: #fff; font-size: 15px; font-weight: 650;
  box-shadow: 0 8px 30px rgba(22, 121, 74, .35);
}
.mine-bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mine-bar svg { width: 18px; height: 18px; stroke-width: 2.6; }
@media (prefers-reduced-motion: no-preference) {
  .mine-bar { animation: pop .4s var(--ease) both; }
  @keyframes pop { from { opacity: 0; transform: translate(-50%, 20px); } }
}

.toast {
  position: fixed; z-index: 30; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px;
  background: var(--chip); color: var(--on-chip); font-size: 15px; font-weight: 600;
  transition: opacity .2s, transform .25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ——— лист желания ——— */
.sheet {
  width: 100%; max-width: 100%; max-height: 92dvh;
  margin: auto auto 0; padding: 0; border: 0;
  border-radius: 28px 28px 0 0;
  background: var(--sheet); color: var(--label);
  box-shadow: var(--sheet-shadow);
  overscroll-behavior: contain;
}
.sheet::backdrop { background: rgba(0, 0, 0, .38); }
.sheet-inner { position: relative; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.grabber { position: absolute; top: 6px; left: 50%; width: 36px; height: 5px; margin-left: -18px; border-radius: 3px; background: var(--label-3); z-index: 2; }
.close { position: absolute; top: 14px; right: 14px; z-index: 2; background: var(--glass); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.sheet-art { padding: 10px 10px 0; }
.sheet-art .art { aspect-ratio: 4 / 3; border-radius: 22px; }
.sheet-art .art.empty { aspect-ratio: 2 / 1; }
.sheet-body { padding: 18px 20px 0; }
.sheet h2 { text-wrap: balance; margin-top: 4px; font-size: 26px; line-height: 31px; font-weight: 650; letter-spacing: -.02em; overflow-wrap: anywhere; }
.sheet-price { margin-top: 6px; font-family: var(--rounded); font-size: 22px; font-weight: 700; }
.sheet-price:empty { display: none; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.sheet-actions .button:only-child { grid-column: 1 / -1; }
.sheet-actions svg { width: 19px; height: 19px; }
.sheet-status {
  display: flex; gap: 12px; align-items: flex-start;
  margin-top: 20px; padding: 14px 16px; border-radius: 16px;
  background: var(--field); font-size: 15px; line-height: 20px;
}
.sheet-status.mine { background: var(--gift-tint); }
.sheet-status .dot { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--label-3); color: #fff; }
.sheet-status.mine .dot { background: var(--gift); }
.sheet-status .dot svg { width: 16px; height: 16px; stroke-width: 2.8; }
.sheet-status b { display: block; font-size: 17px; font-weight: 650; margin-bottom: 2px; }
.sheet-status p { color: var(--label-2); }

.give { display: grid; gap: 14px; margin-top: 20px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 15px; font-weight: 600; }
.give input {
  height: 50px; padding: 0 16px; border: 0; border-radius: 14px;
  background: var(--field); font-size: 17px; outline: none;
}
.give input:focus-visible { box-shadow: 0 0 0 3px #6b82ff; }
.give-note { color: var(--label-2); font-size: 14px; line-height: 18px; }
.give .row { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 2px; }
.give-error { color: var(--accent); font-size: 15px; font-weight: 600; }
.status-actions { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; }
.status-actions button, .status-actions a { color: var(--accent); font-weight: 600; font-size: 15px; }

.give .quiet { min-height: 50px; border-radius: 16px; background: transparent; }

@media (prefers-reduced-motion: no-preference) {
  .sheet[open] { animation: slide-up .42s var(--ease); }
  .sheet[open]::backdrop { animation: fade .3s ease; }
  .sheet.closing { animation: slide-down .25s ease-in forwards; }
  .sheet.closing::backdrop { animation: fade .25s ease reverse forwards; }
  @keyframes slide-up { from { transform: translateY(100%); } }
  @keyframes slide-down { to { transform: translateY(100%); } }
  @keyframes fade { from { opacity: 0; } }
}

@media (min-width: 760px) {
  .sheet { width: min(880px, 100% - 64px); margin: auto; border-radius: 32px; max-height: min(640px, 90dvh); }
  .sheet-inner { display: grid; grid-template-columns: 1.05fr 1fr; padding: 0; min-height: 440px; }
  .grabber { display: none; }
  .sheet-art { padding: 12px; }
  .sheet-art .art { aspect-ratio: auto; height: 100%; min-height: 416px; border-radius: 24px; }
  .sheet-body { padding: 56px 32px 32px 20px; display: flex; flex-direction: column; }
  .sheet h2 { font-size: 30px; line-height: 35px; }
  .sheet-actions { grid-template-columns: 1fr; margin-top: auto; padding-top: 24px; }
  @media (prefers-reduced-motion: no-preference) {
    .sheet[open] { animation: zoom .32s var(--ease); }
    .sheet.closing { animation: zoom .2s ease-in reverse forwards; }
    @keyframes zoom { from { opacity: 0; transform: scale(.96) translateY(8px); } }
  }
}
