﻿/* Lomenu glassmorphism theme */

@font-face {
  font-family: "Playfair Display";
  src: url("./fonts/PlayfairDisplay-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Lora";
  src: url("./fonts/Lora-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Lora";
  src: url("./fonts/Lora-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg1: #f3d9c8;
  --bg2: #dfe7df;
  --glass: rgba(255, 255, 255, 0.58);
  --glass2: rgba(255, 255, 255, 0.78);
  --stroke: rgba(0, 0, 0, 0.08);
  --text: rgba(0, 0, 0, 0.82);
  --muted: rgba(0, 0, 0, 0.55);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.16);
  --radius: 18px;
  --radius2: 22px;
  --accent: #d1a25d;
  --accent2: #b98943;
  --storyTop: 72px;
  --storyTapTopOffset: 120px;
  --storyTapBottomOffset: 180px;
  --font-title: "Playfair Display", serif;
  --font-body: "Lora", serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: #fdf8f3;
  font-family: var(--font-body);
  font-size: clamp(16px, 1.15vw, 19px);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

body.storyLocked {
  overflow: hidden;
  height: 100%;
  touch-action: none;
  overscroll-behavior: none;
}

.hidden {
  display: none !important;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1100px 700px at 15% 10%, var(--bg1), transparent 60%),
    radial-gradient(1000px 650px at 75% 75%, var(--bg2), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.34));
  filter: saturate(1.05);
}

.view {
  padding: clamp(24px, 3vw, 64px) 0 clamp(42px, 4vw, 84px);
}

.container {
  width: min(1480px, calc(100% - clamp(48px, 8vw, 160px)));
  margin: 0 auto;
}

@media (min-width: 1600px) {
  .container {
    width: min(1680px, calc(100% - clamp(60px, 6vw, 220px)));
  }
}

#storiesGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 28px;
  align-items: stretch;
  width: 100%;
  margin: 0;
}

#viewStories .storiesGrid {
  width: 100%;
  max-width: none;
  margin: 0;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

#viewStories .homeCard {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 22px 20px 18px;
  min-height: 180px;
  text-align: left;
  align-items: flex-start;
  gap: 12px;
}

.brandTitle,
.homeTitle,
.sectionTitle,
.cardTitle,
.sheetTitle,
.storyTitle {
  font-family: var(--font-title);
  font-weight: 700;
  letter-spacing: 0.2px;
  margin: 0;
  color: var(--text);
  line-height: 1.2;
  text-rendering: optimizeLegibility;
}

#storyTitle,
.storyTitle {
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.brandTitle {
  font-size: clamp(26px, 3vw, 44px);
}

.brandSub {
  font-family: var(--font-body);
  font-style: italic;
  font-size: clamp(12px, 1.5vw, 20px);
  color: var(--muted);
  margin-top: 2px;
  opacity: 0.85;
}

.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  padding: 0 6px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.08);
  font-size: clamp(12px, 1vw, 16px);
}

.pillBtn {
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.6);
  padding: 9px 12px;
  font-size: clamp(14px, 1.1vw, 18px);
  border-radius: 999px;
  cursor: pointer;
  color: var(--text);
  backdrop-filter: blur(10px);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.pillBtn.active {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(0, 0, 0, 0.12);
}

.pillBtn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(196, 145, 72, 0.22);
  border-color: rgba(196, 145, 72, 0.55);
}

.pillBtn.tiny {
  padding: 7px 10px;
  font-size: clamp(12px, 1vw, 16px);
}

.pillBtn.hasNewStories {
  border-color: rgba(196, 145, 72, 0.75);
  box-shadow: 0 0 0 3px rgba(196, 145, 72, 0.2);
}

.pillBtn.isNewStory {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.storyNewMark,
.storyCardNew {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(196, 145, 72, 0.65);
  background: rgba(196, 145, 72, 0.2);
  color: #5c3a15;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  vertical-align: middle;
  text-transform: uppercase;
}

.chipsRow,
#chipsRow {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.catPill {
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  padding: 10px 18px;
  min-height: 42px;
  font-size: clamp(14px, 1.1vw, 16px);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.75);
  color: var(--text);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease, color 0.2s ease, border-color 0.2s ease;
}

.catPill:hover {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.08);
}

.catPill:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.catPill:focus-visible {
  outline: 2px solid rgba(255, 160, 67, 0.6);
  outline-offset: 2px;
}

.catPill.isActive {
  background: linear-gradient(180deg, rgba(255, 244, 232, 0.98), rgba(255, 235, 212, 0.95));
  border-color: rgba(255, 166, 92, 0.4);
  color: rgba(104, 60, 18, 0.92);
  box-shadow: 0 18px 40px rgba(202, 124, 45, 0.18);
}

.btnPrimary {
  border: none;
  background: linear-gradient(180deg, var(--accent), var(--accent2));
  color: rgba(0, 0, 0, 0.82);
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 900;
  box-shadow: 0 12px 26px rgba(177, 132, 60, 0.26);
}

.btnPrimary:active {
  transform: translateY(1px);
}

.btnPrimary:disabled,
.btnPrimary.isDisabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.searchInput,
.note {
  flex: 1;
  min-width: 220px;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  padding: 10px 12px;
  outline: none;
  background: rgba(255, 255, 255, 0.92);
}

.noteInput {
  width: 100%;
  min-height: 84px;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.85);
  padding: 12px 16px;
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
  resize: vertical;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  color: inherit;
}

.noteInput:focus {
  border-color: rgba(255, 176, 94, 0.9);
  box-shadow: 0 0 0 3px rgba(255, 184, 120, 0.35);
  background: #fffdf8;
  outline: none;
}

.noteInput::placeholder {
  color: rgba(0, 0, 0, 0.4);
}

.noteInput:disabled {
  opacity: 0.6;
}

.smallMuted {
  font-size: 12px;
  color: var(--muted);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(255, 255, 255, 0.42);
  border-bottom: 1px solid var(--stroke);
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
}

.topbarInner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  gap: 14px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
}

.logoDot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #fff, var(--accent));
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}

.topbarRight {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  scrollbar-width: none;
  flex: 0 0 auto;
  min-width: 0;
}

.topbarRight::-webkit-scrollbar {
  display: none;
}

.toTopBtn {
  position: fixed;
  right: calc(20px + env(safe-area-inset-right));
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 95;
}

.toTopBtn.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.homeCard {
  width: min(900px, 100%);
  margin: clamp(80px, 8vw, 140px) auto 0;
  padding: 28px 28px 22px;
  border-radius: var(--radius2);
  background: var(--glass2);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  text-align: center;
}

.homeTitle {
  font-size: clamp(20px, 2.6vw, 36px);
  margin-bottom: clamp(6px, 1.2vw, 16px);
}

.homeText {
  font-size: clamp(14px, 1.6vw, 22px);
  color: var(--muted);
  margin-bottom: clamp(14px, 1.4vw, 22px);
}

.section {
  margin: 14px 0 18px;
}

.sectionTitle {
  font-size: clamp(20px, 2.3vw, 32px);
  font-weight: 700;
  margin: 8px 0 10px;
}

.sectionTitleRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chipsRow,
.filtersRow {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-start;
}

.filtersRow {
  margin-top: 10px;
}

.filtersHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.filtersPanel {
  margin-top: 10px;
}

.filtersPanel.collapsed {
  display: none;
}

.searchRow {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

#clearFiltersBtn {
  flex: 0 0 auto;
}

.searchWrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.searchWrap .searchInput {
  width: 100%;
  min-width: 0;
}

.searchPlaceholder {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 1;
  color: rgba(0, 0, 0, 0.45);
  font-size: 16px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 32px);
}

.grid {
  display: grid;
  gap: 14px;
  align-items: stretch;
}

.grid.mode-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid.mode-large {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.mode-list {
  grid-template-columns: 1fr;
}

/* fallback до тех пор, пока JS не навесит режим */
.grid:not(.mode-grid):not(.mode-large):not(.mode-list) {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card {
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--stroke);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  min-height: 210px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.card:hover {
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.14);
}

.cardImg {
  position: relative;
  overflow: hidden;
  height: 148px;
  background-color: #f7f4ef;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 10px 10px 8px;
  gap: 10px;
  border: 1px solid rgba(23, 23, 23, 0.05);
  border-radius: calc(var(--radius) - 6px);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.4),
    0 12px 28px rgba(12, 12, 12, 0.08);
}

.cardImg.hasReal {
  background-size: cover;
  background-position: center;
}

.cardImg::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(220px 120px at 20% 20%, rgba(209, 162, 93, 0.22), transparent 60%),
    radial-gradient(220px 120px at 90% 90%, rgba(155, 190, 165, 0.18), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.65), rgba(255, 255, 255, 0.15));
}

.cardImg::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0));
}

.cardImg > * {
  position: relative;
  z-index: 2;
}

.cardEmoji {
  font-size: 20px;
  filter: saturate(1.1);
}

.favBtn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
  color: rgba(20, 20, 20, 0.28);
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.favBtn .favIcon {
  width: 18px;
  height: 18px;
  display: block;
}

.favBtn .favIcon path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}

.favBtn:hover {
  transform: scale(1.06);
}

.favBtn.active {
  color: #d53b3b;
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(0, 0, 0, 0.18);
}

.favBtn.active .favIcon path {
  fill: currentColor;
  stroke: currentColor;
}

.cardBody {
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  flex: 1;
}

.cardTitle {
  font-size: clamp(18px, 2.2vw, 28px);
  line-height: 1.12;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: calc(1.12em * 2);
}

.cardMeta {
  padding-right: 44px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
}

.kisses {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: clamp(12px, 1.3vw, 18px);
  color: var(--muted);
  line-height: 1;
}

.badge {
  font-size: clamp(11px, 1vw, 15px);
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.06);
  white-space: nowrap;
}

img.emojiSvg {
  width: 1em;
  height: 1em;
  max-width: 1em;
  max-height: 1em;
  display: inline-block;
  vertical-align: -0.12em;
  object-fit: contain;
  opacity: 1 !important;
}

.kisses img.emojiSvg {
  width: 22px;
  height: 22px;
  max-width: 22px;
  max-height: 22px;
  vertical-align: -3px;
}

.quickAdd {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 999px;
  padding: 3px 6px;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
  z-index: 6;
}

.quickAdd.needsSheet {
  padding: 4px;
}

.qaBtn,
.qaPlus {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  font-weight: 950;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.qaBtn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}

.qaVal {
  min-width: 18px;
  text-align: center;
  font-weight: 950;
  font-size: 12px;
  opacity: 0.85;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(6px);
  z-index: 50;
}

.overlay.isEditing {
  background: rgba(0, 0, 0, 0.42);
}

.sheet {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(820px, calc(100vw - 24px));
  max-height: min(82vh, 760px);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
  z-index: 60;
  display: flex;
  flex-direction: column;
}

.sheet.isEditing {
  outline: 2px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.2);
}

.sheetHead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.iconBtn {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  padding: 6px;
  cursor: pointer;
  color: rgba(0, 0, 0, 0.45);
  border-radius: 999px;
}

.iconBtn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.75);
}

.iconBtn:active {
  background: rgba(0, 0, 0, 0.1);
}


.sheetTitleRow {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sheetTitle {
  font-size: 20px;
}

.editBadge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.72);
  user-select: none;
}

.sheetSub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.sheetBody {
  padding: 14px;
  overflow: auto;
}

.sheetBottom {
  padding: 12px 14px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.optBlock {
  margin-bottom: 14px;
}

.optTitle {
  font-weight: 950;
  margin-bottom: 8px;
}

.optRow {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.chipOpt {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.72);
  color: rgba(0, 0, 0, 0.82);
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.02s ease;
}

.chipOpt:hover {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(0, 0, 0, 0.16);
}

.chipOpt.active {
  color: #2b1e10;
  background: rgba(196, 145, 72, 0.18);
  border-color: rgba(196, 145, 72, 0.55);
  box-shadow: 0 0 0 3px rgba(196, 145, 72, 0.22);
  transform: translateY(-1px);
}

.chipOpt:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(196, 145, 72, 0.22);
}

.chipOpt:active {
  transform: translateY(1px);
}

.storiesRow {
  display: flex;
  gap: 12px;
  overflow: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.storiesRow::-webkit-scrollbar {
  display: none;
}

.storyTile {
  min-width: 220px;
  border-radius: 18px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.1);
  padding: 12px;
  cursor: pointer;
}

.storySub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.storiesGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.storyOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 40;
}

.checkoutOverlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 80;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.checkoutOverlay.visible {
  opacity: 1;
}

.checkoutCard {
  width: min(420px, 90vw);
  border-radius: 32px;
  background: #fffdf8;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 35px 80px rgba(0, 0, 0, 0.16);
  padding: clamp(28px, 4vw, 42px);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-family: var(--font-body);
}

.checkoutIcon {
  font-size: clamp(52px, 8vw, 72px);
  line-height: 1;
}

.checkoutTitle {
  font-family: var(--font-title);
  font-size: clamp(24px, 4vw, 32px);
  color: var(--accent2);
  margin: 0;
}

.checkoutText {
  font-size: 16px;
  line-height: 1.6;
  margin: 0;
  color: rgba(0, 0, 0, 0.7);
}

.checkoutCard .btnPrimary {
  width: min(260px, 100%);
  margin: 12px auto 0;
}

.storyModal {
  position: fixed;
  inset: 0;
  width: clamp(420px, 40vw, 640px);
  max-width: calc(100vw - 32px);
  height: min(94dvh, 860px);
  max-height: calc(100dvh - 40px);
  margin: auto;
  background: #fefaf7;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 40px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.22);
  z-index: 45;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-top: 10px;
}

.storyTop {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 24px 8px;
  flex: 0 0 auto;
  position: relative;
  z-index: 60;
}

.storyBars {
  display: flex;
  gap: 6px;
  flex: 1;
  pointer-events: none;
}

.storyBar {
  height: 3px;
  flex: 1;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.storyBarFill {
  height: 100%;
  width: 0%;
  background: rgba(0, 0, 0, 0.55);
  transition: width 0.25s ease;
}

.storyHeader,
.storyTopbar,
#storyHeader {
  position: relative;
  z-index: 40;
}

#storyCloseBtn {
  position: relative;
  z-index: 50;
  pointer-events: auto;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

#storyCloseBtn:active {
  transform: scale(0.96);
  opacity: 0.85;
}

.storyStage {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  padding: 0 clamp(24px, 4vw, 36px) clamp(24px, 3vw, 36px);
  color: var(--text);
  overflow: hidden;
}

.storyCard {
  display: flex;
  flex-direction: column;
  gap: clamp(18px, 2vw, 28px);
  padding: clamp(30px, 3.4vw, 40px) clamp(24px, 2.8vw, 34px) clamp(22px, 2.8vw, 32px);
  border-radius: 32px;
  background: #fffdfb;
  flex: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.storyCopy {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.storyImageWrap {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  gap: 14px;
}

.storyStage.hasImage .storyImageWrap {
  display: flex;
}

.storyImageWrap.is-empty {
  display: none;
}

.storyImageFrame {
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(240, 235, 228, 0.9));
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.12);
  max-height: min(54vh, 520px);
}

#storyImage {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  will-change: opacity, transform;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

.storyMeta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 0;
  min-height: 42px;
}

.storyMeta .storyActions,
.storyMeta .storyVoteHint {
  margin-top: 0;
}

#storyTitle,
#storyText {
  position: relative;
  z-index: 2;
  color: inherit;
  text-shadow: none;
  will-change: opacity, transform;
}

.storyText {
  font-family: var(--font-body);
  font-size: clamp(15px, 3vw, 17px);
  margin: 0;
  line-height: 1.45;
  color: rgba(0, 0, 0, 0.75);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.storyBottom {
  padding: 12px 24px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  flex: 0 0 auto;
  position: relative;
  z-index: 60;
  background: transparent;
}

.storyBottom .btnPrimary {
  width: min(280px, 100%);
  border-radius: 999px;
  color: rgba(32, 21, 10, 0.88);
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.storyBottom .btnPrimary:hover {
  filter: saturate(0.96) brightness(1.02);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.14);
}

.storyBottom .btnPrimary:active {
  transform: translateY(1px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
}

.storyFadeUnit {
  animation: storyFadeUnit 0.35s ease;
}

.storyImageFade {
  animation: storyImageFade 0.45s ease;
}

@keyframes storyFadeUnit {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes storyImageFade {
  from {
    opacity: 0;
    transform: scale(1.02);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.storyTap {
  position: absolute;
  top: calc(var(--storyTapTopOffset) + env(safe-area-inset-top));
  bottom: calc(var(--storyTapBottomOffset) + env(safe-area-inset-bottom));
  width: 35%;
  cursor: pointer;
  z-index: 30;
  transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

.storyTapLeft {
  left: 0;
}

.storyTapRight {
  right: 0;
}

.storyTap:active {
  transform: scale(0.98);
  background: rgba(0, 0, 0, 0.06);
}

.storyActions {
  position: relative;
  z-index: 60;
  margin-top: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

.storyActions.hasPoll {
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.storyPollQuestion {
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  color: rgba(0, 0, 0, 0.85);
  width: 100%;
}

.storyPollOptions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  width: 100%;
}

.storyPollOption {
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 999px;
  padding: 8px 18px;
  background: rgba(255, 255, 255, 0.78);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.storyPollOption:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.storyPollOption.isLocked {
  cursor: default;
  opacity: 0.65;
}

.storyPollOption.isSelected {
  background: linear-gradient(180deg, var(--accent), var(--accent2));
  border-color: rgba(0, 0, 0, 0.12);
  color: rgba(0, 0, 0, 0.85);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
  opacity: 1;
}

.storyPollStatus {
  font-size: 13px;
  text-align: center;
  color: rgba(0, 0, 0, 0.6);
}

.storyActions .chipOpt {
  cursor: pointer;
}

.storyVoteHint {
  font-size: 14px;
  line-height: 1.45;
  color: rgba(0, 0, 0, 0.72);
  opacity: 0.92;
  margin-top: 8px;
}

.storyVoteHint,
.storyActions {
  color: inherit;
}

.cartBox {
  border-radius: var(--radius2);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  padding: 14px;
}

.cartItem {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius2);
  background: var(--glass2);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.06);
  width: 100%;
}

.cartItem:last-child {
  margin-bottom: 0;
}

.cLeft {
  flex: 1;
}

.cRight {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.cTitle,
.cartItemTitle {
  font-weight: 950;
  font-family: var(--font-title);
}

.cSub,
.cartItemOptions {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.cartItemTop {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 15px;
}

.cartItemInfo {
  flex: 1;
}

.cartItemTotals {
  text-align: right;
  flex-shrink: 0;
}

.cartItemKisses {
  font-family: var(--font-title);
  font-size: 18px;
  color: var(--accent2);
}

.cartItemBottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 5px;
  padding-top: 15px;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.cartActions {
  display: flex;
  gap: 8px;
}

.cartActBtn {
  background: none;
  border: none;
  padding: 0;
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

.cartActBtn.remove {
  opacity: 0.5;
}

.cartKissesInfo {
  background: rgba(209, 162, 93, 0.1);
  padding: 8px 12px;
  border-radius: 12px;
  text-align: right;
  min-width: 70px;
}

.stepper {
  display: flex;
  gap: 8px;
  align-items: center;
}

.stepBtn {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  font-weight: 950;
}

.stepVal {
  min-width: 22px;
  text-align: center;
  font-weight: 950;
}

.cartEmptyMessage {
  padding: 30px;
  text-align: center;
}

.kissesRaw {
  opacity: 0.7;
}

.cartFooter {
  margin-top: 25px;
  background: var(--glass2);
  padding: clamp(24px, 2.8vw, 38px);
  border-radius: 24px;
  border: 1px solid var(--stroke);
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: stretch;
}

.totals {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 260px;
}

.tRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding: 4px 0;
}

.tLabel {
  font-size: 14px;
  opacity: 0.7;
}

.tValue {
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 700;
}

.totalKissesRow .tLabel {
  opacity: 1;
  font-weight: 700;
}

.totalKissesRow .tValue {
  font-size: 22px;
  color: var(--accent2);
}

.tRow .tLabel {
  font-size: 12px;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tRow .tValue {
  opacity: 1;
  text-transform: none;
  letter-spacing: 0;
}

.tRow b {
  font-family: var(--font-title);
  font-size: 20px;
  color: var(--text);
}

#totalKisses {
  color: var(--accent2);
}

.cartActions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.cartFooter .cartActions {
  margin-top: 0;
  justify-content: flex-start;
  width: 100%;
}

.cartActionsGroup {
  display: flex;
  gap: 8px;
}

.btn-icon {
  background: none;
  border: 1px solid var(--stroke);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.2s ease;
}

.btn-icon:hover {
  background: #fff;
}

.btn-icon.edit {
  color: var(--accent2);
}

.btn-icon.remove {
  color: #e63946;
  opacity: 0.6;
}

#cartList {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 10px 0 20px;
}

#viewCart {
  padding-bottom: 40px;
}

#viewCart .container,
#cartView .container {
  width: min(960px, calc(100% - clamp(48px, 8vw, 180px)));
  margin: 0 auto;
  padding: clamp(20px, 3vw, 48px) clamp(18px, 4vw, 56px);
}

@media (min-width: 1400px) {
  #viewCart .container,
  #cartView .container {
    width: min(1100px, calc(100% - clamp(80px, 8vw, 220px)));
  }
}

.cart-back-container {
  margin-bottom: 24px;
}

#backToMenuBtn {
  background: var(--glass2);
  border: 1px solid var(--accent);
  color: var(--accent2);
  font-weight: 700;
  width: 100%;
  padding: 14px;
  border-radius: 18px;
  cursor: pointer;
}

.back-full {
  width: 100%;
  margin-bottom: 25px;
  padding: 14px;
  font-weight: bold;
}

#clearCartBtn {
  flex: 1;
  padding: clamp(12px, 1.2vw, 18px);
  font-size: clamp(14px, 1.1vw, 18px);
}

#checkoutBtn {
  flex: 2;
  padding: clamp(12px, 1.4vw, 20px);
  font-size: clamp(16px, 1.3vw, 20px);
}

.viewToggle {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* список: карточка горизонтально */
.grid.mode-list .card {
  flex-direction: row;
  align-items: center;
  min-height: 140px;
  gap: 16px;
  padding: 16px 18px;
  flex-wrap: nowrap;
}

.grid.mode-list .cardImg {
  height: 120px;
  width: 160px;
  flex: 0 0 160px;
  align-items: center;
  border-radius: 16px;
  overflow: hidden;
}

.grid.mode-list .cardBody {
  padding: 0;
  gap: 8px;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  justify-content: space-between;
  min-width: 0;
}

.grid.mode-list .cardTitle {
  font-size: 18px;
  line-height: 1.3;
}

.grid.mode-list .cardMeta {
  padding-right: 0;
  font-size: 13px;
  opacity: 0.8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.grid.mode-list .kisses {
  font-size: 12px;
}

.grid.mode-list .quickAdd {
  position: static;
  right: auto;
  bottom: auto;
  margin-left: auto;
  transform: none;
}

/* в “крупно” режимах карточки выше и с более крупным текстом */
.grid.mode-large .card {
  min-height: 330px;
}

.grid.mode-large .cardImg {
  height: 260px;
}

.grid.mode-large .cardBody {
  gap: 16px;
}

.grid.mode-large .cardTitle {
  font-size: 22px;
  line-height: 1.25;
}

.grid.mode-large .cardMeta {
  font-size: 14px;
}

.grid.mode-large .kisses {
  font-size: 14px;
}

.grid.mode-large .quickAdd {
  right: 18px;
  bottom: 18px;
  transform: scale(1.05);
}

/* Media queries */
@media (max-width: 1180px) {
  .grid.mode-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .grid.mode-large {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .grid.mode-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .grid.mode-large {
    grid-template-columns: 1fr;
  }
  .storiesGrid {
    grid-template-columns: 1fr;
  }
  #viewStories .storiesGrid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .storyModal {
    width: min(380px, calc(100vw - 20px));
    height: min(94dvh, 760px);
    border-radius: 28px;
  }
  .storyStage {
    padding: 0 18px 20px;
  }
  .storyCard {
    padding: 26px 20px 22px;
    gap: 16px;
  }
}

@media (max-width: 600px) {
  :root {
    --storyTapTopOffset: calc(var(--storyTop) + 36px);
    --storyTapBottomOffset: 150px;
  }
  .grid.mode-list .card {
    gap: 12px;
    padding: 14px 16px;
  }
  .grid.mode-list .cardImg {
    width: 130px;
    flex: 0 0 130px;
    height: 110px;
  }
  .grid.mode-list .cardTitle {
    font-size: 16px;
  }
  .storyImageFrame {
    aspect-ratio: 7 / 10;
    padding: 10px;
    max-height: min(60vh, 460px);
  }
  .viewToggle {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .viewToggle::-webkit-scrollbar {
    display: none;
  }
  .viewToggle .pillBtn {
    flex: 0 0 auto;
  }
}

@media (max-width: 560px) {
  .topbarInner {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .brand {
    min-width: 0;
    width: 100%;
  }
  .topbarRight {
    width: 100%;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
    padding-left: calc(6px + env(safe-area-inset-left));
    padding-right: calc(6px + env(safe-area-inset-right));
    margin: 0 -6px;
  }
  .topbarRight .pillBtn {
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

@media (max-width: 480px) {
  #cartView .container {
    width: 100%;
    padding: 0 12px;
  }
  .storyModal {
    width: min(360px, calc(100vw - 16px));
    border-radius: 24px;
  }
  .storyCard {
    padding: 24px 18px 20px;
  }
}

@media (max-width: 420px) {
  .grid.mode-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1100px) {
  .storyModal {
    width: clamp(420px, 28vw, 540px);
    border-radius: 44px;
  }
  .storyCard {
    padding: 36px 34px 30px;
    gap: 24px;
  }
  .storyImageFrame {
    padding: 10px;
    aspect-ratio: 3 / 4;
    max-height: min(65vh, 620px);
  }
}

@media (min-width: 1400px) {
  .storyModal {
    width: clamp(520px, 32vw, 700px);
    border-radius: 48px;
  }
  .storyCard {
    padding: 40px 40px 34px;
    gap: 30px;
  }
  .storyImageFrame {
    max-height: min(68vh, 640px);
  }
}
#closeSheetBtn{
  align-self: flex-start;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.1;
  border-radius: 999px;
  flex: 0 0 auto;
  white-space: nowrap;
}
#sheetSub{
  opacity: .72;
  font-size: 13px;
  margin-top: 6px;
}

#sheetDesc{
  margin-top: 10px;
  padding: 10px 12px;
  border-left: 3px solid rgba(0,0,0,.12); /* под тёмную тему потом заменим */
  background: rgba(0,0,0,.03);
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.45;
  color: rgba(0,0,0,.78);
}
.cardImg.isCover {
  background-size: cover;
  background-position: center;
}
