:root {
  color-scheme: light dark;
  --paper: #fff7ee;
  --card: #fffdf8;
  --ink: #2a1e1a;
  --body: #5a4a43;
  --taupe: #7a665d;
  --line: rgba(42, 30, 26, 0.1);
  --action: #d63f2a;
  --coral-text: #c93925;
  --blush: #ffc9bd;
  --gold: #ffb547;
  --scrim: rgba(42, 30, 26, 0.62);
  --skeleton: #f3e9dd;
  --print: 0 1px 0 rgba(42, 30, 26, 0.06), 0 6px 16px rgba(42, 30, 26, 0.08);
  --page: 16px;
  --gap: 12px;
}

/* Set from Telegram.WebApp.colorScheme; the media query covers a browser preview. */
:root[data-theme="dark"] {
  --paper: #1e1512;
  --card: #2a1e1a;
  --ink: #fff7ee;
  --body: #e4d6cc;
  --taupe: #b9a69c;
  --line: rgba(255, 247, 238, 0.1);
  --coral-text: #ff8a76;
  --skeleton: #3a2c26;
  --print: 0 1px 0 rgba(0, 0, 0, 0.3);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1e1512;
    --card: #2a1e1a;
    --ink: #fff7ee;
    --body: #e4d6cc;
    --taupe: #b9a69c;
    --line: rgba(255, 247, 238, 0.1);
    --coral-text: #ff8a76;
    --skeleton: #3a2c26;
    --print: 0 1px 0 rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 500 15px/22px "Plus Jakarta Sans", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
main { padding: var(--page) var(--page) calc(76px + env(safe-area-inset-bottom)); }
h1, h2 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variation-settings: "SOFT" 100, "opsz" 144;
}
h1 { font-size: 28px; line-height: 32px; }
h2 { font-size: 20px; line-height: 26px; margin: 24px 0 12px; }
p { margin: 0; }
.sub { color: var(--taupe); font-size: 14px; line-height: 20px; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--gap); margin-bottom: 12px; }
.pill {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}
.search {
  width: 100%;
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  margin-bottom: 12px;
}
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 calc(var(--page) * -1) 16px;
  padding: 0 var(--page);
  scrollbar-width: none;
}
.chip {
  flex: none;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  font-weight: 600;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.print {
  position: relative;
  display: block;
  padding: 8px 8px 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--print);
  text-align: left;
  transition: transform 120ms;
  min-width: 0;
}
button.print:active { transform: scale(0.98); box-shadow: none; }
.photo {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: 8px;
  overflow: hidden;
  background: var(--skeleton);
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo.failed img { display: none; }
.photo.failed::after { content: "📷"; position: absolute; inset: 0; display: grid; place-items: center; opacity: 0.3; font-size: 32px; }
.badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--gold);
  color: #2a1e1a;
  font-weight: 800;
  font-size: 11px;
  line-height: 14px;
  letter-spacing: 0.06em;
}
.caption { padding: 10px 4px 12px; min-width: 0; }
.caption .title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { margin-top: 6px; display: inline-block; padding: 2px 8px; border-radius: 999px; font-weight: 600; font-size: 12px; line-height: 16px; color: var(--taupe); background: color-mix(in srgb, var(--taupe) 12%, transparent); }
.meta.couple { background: var(--blush); color: #2a1e1a; }

.skeleton .photo { animation: shimmer 1.2s linear infinite; background: linear-gradient(90deg, var(--skeleton) 25%, color-mix(in srgb, var(--skeleton) 60%, var(--card)) 50%, var(--skeleton) 75%); background-size: 200% 100%; }
.skeleton .bar { height: 12px; border-radius: 6px; background: var(--skeleton); margin: 12px 4px 0; width: 60%; }
.skeleton .bar + .bar { width: 35%; margin-bottom: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton .photo { animation: none; } .print { transition: none; } }

.strip { display: flex; gap: var(--gap); overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 calc(var(--page) * -1) 16px; padding: 0 var(--page); scrollbar-width: none; }
.strip .print { flex: none; width: min(78%, 320px); scroll-snap-align: center; padding-bottom: 8px; }
.facts { display: grid; gap: 6px; margin: 12px 0 20px; color: var(--body); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 20px;
  border: 0; border-radius: 999px;
  background: var(--action); color: #fff; font-weight: 800;
  box-shadow: 0 8px 20px rgba(214, 63, 42, 0.28);
}
.btn:active { background: #b8321f; }
.btn.ghost { background: transparent; color: var(--coral-text); box-shadow: none; border: 1px solid var(--line); }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 14px; }
.packs { display: grid; gap: 8px; }
.packs .btn { justify-content: space-between; width: 100%; }
.note { margin-top: 12px; color: var(--taupe); font-size: 13px; }
.empty { text-align: center; padding: 48px 8px; display: grid; gap: 16px; justify-items: center; }
.empty .hand { font-family: "Caveat", cursive; font-weight: 600; font-size: 28px; }
.look .btn { margin: 0 0 8px; width: 100%; }

.tabbar {
  position: fixed; inset: auto 0 0 0;
  display: flex;
  background: var(--paper);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a { flex: 1; text-align: center; padding: 14px 0; color: var(--taupe); font-weight: 600; text-decoration: none; }
.tabbar a[aria-current="page"] { color: var(--ink); font-weight: 800; }
:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
