:root {
  --bg: #f4efe6;
  --bg-2: #e7dfd1;
  --ink: #241910;
  --muted: #6f6256;
  --card: #fffaf3;
  --line: rgba(36, 25, 16, 0.1);
  --cheese: #e4b23c;
  --stamp: #9c3418;
  --shadow: 0 18px 40px rgba(60, 36, 12, 0.14);
  --sans: "Avenir Next", "Segoe UI", sans-serif;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #14110e;
  --bg-2: #0d0b09;
  --ink: #f6efe4;
  --muted: #b3a496;
  --card: #221c17;
  --line: rgba(246, 239, 228, 0.12);
  --cheese: #e4b23c;
  --stamp: #e07a55;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100dvh;
  background:
    radial-gradient(1200px 400px at 50% -10%, rgba(228, 178, 60, 0.28), transparent 60%),
    var(--bg-2);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.app {
  width: min(480px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px calc(92px + var(--safe-b));
}

.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.mark {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  letter-spacing: 0.08em;
  color: var(--stamp);
}
.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -0.03em;
  line-height: 1;
}
.top-actions { display: flex; gap: 8px; }

.chip {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  min-height: 36px;
  padding: 0 12px;
  max-width: 148px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip-strong {
  background: var(--ink);
  color: var(--bg);
  border-color: transparent;
  font-variant-numeric: tabular-nums;
}

.guest-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(228, 178, 60, 0.22);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
}

.tools { margin-top: 16px; }
.search input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 14px;
  min-height: 46px;
  padding: 0 14px;
  outline: none;
}
.search input:focus { border-color: var(--cheese); }

.cats {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 0 4px;
  scrollbar-width: none;
}
.cats::-webkit-scrollbar { display: none; }
.cat {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  min-height: 36px;
  padding: 0 12px;
  color: var(--muted);
}
.cat.is-on {
  background: var(--ink);
  color: var(--bg);
  border-color: transparent;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}
.card {
  position: relative;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  aspect-ratio: 3 / 4;
  border: 0;
  border-radius: 18px;
  padding: 12px;
  text-align: left;
  overflow: hidden;
  color: #fffaf3;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset;
}
.card-kicker {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 40px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.85;
}
.card-title {
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.05;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}
.card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card .veil {
  position: absolute;
  inset: auto 0 0;
  height: 55%;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.62));
}
.card-kicker, .card-title, .heart { position: relative; z-index: 1; }
.card-kicker { position: absolute; z-index: 1; }
.heart {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.28);
  color: #fff;
  font-size: 16px;
}
.heart.is-on { color: #ffd0c2; }

.sk {
  border-radius: 18px;
  aspect-ratio: 3 / 4;
  background: linear-gradient(100deg, var(--bg-2), var(--card), var(--bg-2));
  background-size: 200% 100%;
  animation: sheen 1.2s ease-in-out infinite;
}
@keyframes sheen {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.empty {
  margin-top: 28px;
  padding: 22px 8px 8px;
  text-align: center;
}
.empty h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 26px;
  margin: 0 0 8px;
}
.empty p { margin: 0; color: var(--muted); line-height: 1.4; }
.linkish {
  margin-top: 16px;
  border: 0;
  background: var(--ink);
  color: var(--bg);
  border-radius: 999px;
  min-height: 44px;
  padding: 0 18px;
}

.wallet { margin-top: 8px; }
.balance-hero {
  background: var(--ink);
  color: var(--bg);
  border-radius: 22px;
  padding: 18px 18px 16px;
}
.balance-hero p { margin: 0; color: rgba(244, 239, 230, 0.72); font-size: 13px; }
.balance-hero strong {
  display: block;
  margin-top: 4px;
  font-family: var(--serif);
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.balance-hero span { color: var(--cheese); }
.pack {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  margin-top: 10px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--card);
}
.pack b { display: block; }
.pack small { color: var(--muted); }
.pack em {
  font-style: normal;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--stamp);
}
.pack:disabled { opacity: 0.55; }

.tabs {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(480px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  padding: 8px 12px calc(10px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  border: 0;
  background: transparent;
  min-height: 42px;
  border-radius: 12px;
  color: var(--muted);
}
.tab.is-on { background: var(--card); color: var(--ink); }

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 12, 6, 0.46);
  z-index: 20;
}
.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(480px, 100%);
  max-height: min(88dvh, 760px);
  overflow: auto;
  background: var(--card);
  color: var(--ink);
  border-radius: 22px 22px 0 0;
  padding: 8px 16px calc(18px + var(--safe-b));
  box-shadow: var(--shadow);
  z-index: 21;
}
.grab {
  width: 42px;
  height: 4px;
  border-radius: 99px;
  background: var(--line);
  margin: 4px auto 8px;
}
.sheet-x {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 3;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 12, 6, 0.62);
  color: #fffaf3;
}
.poster {
  margin-top: 8px;
  width: 100%;
  height: min(48dvh, 460px);
  border-radius: 18px;
  position: relative;
  overflow: hidden;
  background: #1c1410;
}
.poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 16%;
  display: block;
}
.sheet h2 {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.05;
  margin: 14px 0 4px;
}
.kicker { margin: 0; color: var(--muted); font-size: 13px; }
.pitch { margin: 10px 0 0; line-height: 1.4; }
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.meta i {
  font-style: normal;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 999px;
  background: var(--bg);
}
.cta {
  position: sticky;
  bottom: 0;
  width: 100%;
  margin-top: 16px;
  min-height: 50px;
  border: 0;
  border-radius: 14px;
  background: var(--ink);
  color: var(--bg);
  font-size: 16px;
}
.cta:disabled { opacity: 0.5; }
.cta.alt { background: var(--stamp); color: #fffaf3; }

.avatar-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  margin-top: 8px;
  min-height: 52px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg);
}
.avatar-row.is-on { border-color: var(--cheese); }
.avatar-row small { color: var(--muted); }
.avatar-row:disabled { opacity: 0.55; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(78px + var(--safe-b));
  transform: translateX(-50%) translateY(12px);
  width: min(440px, calc(100% - 24px));
  background: var(--ink);
  color: var(--bg);
  border-radius: 14px;
  padding: 12px 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 30;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .sk { animation: none; }
  .toast { transition: none; }
}
