:root {
  --soot: #14100c;
  --soot-2: #1c1611;
  --soot-3: #261e17;
  --line: #3a2e23;
  --parchment: #eadfc8;
  --muted: #a8987c;
  --faint: #6f6250;
  --blood: #b3261e;
  --blood-deep: #7d1a14;
  --ember: #e08a3c;
  --gold: #c9a45c;
  --radius: 10px;
  --display: "Pirata One", "UnifrakturCook", serif;
  --caps: "IM Fell English SC", Georgia, serif;
  --body: "Spectral", Georgia, serif;
  --bar-h: 72px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 16px; }

body {
  margin: 0;
  background: var(--soot);
  color: var(--parchment);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.has-cart { padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom)); }

/* Grain over everything, very subtle */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: .06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: var(--ember); }

button { font: inherit; color: inherit; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4em;
  min-height: 44px;
  padding: 0 1.2em;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: var(--caps);
  font-size: 1rem;
  letter-spacing: .03em;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--blood); color: #fff3e6; border-color: var(--blood); }
.btn-primary:hover:not(:disabled) { background: #c92f25; }
.btn-ghost { background: transparent; color: var(--parchment); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--muted); }
.btn-sm { min-height: 36px; padding: 0 .9em; font-size: .9rem; }

:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: 72px 16px 56px;
  text-align: center;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 60% at 50% 110%, rgba(224, 138, 60, .28), transparent 70%),
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(179, 38, 30, .18), transparent 70%),
    var(--soot);
  border-bottom: 1px solid var(--line);
}
.hero::after {
  /* Embers */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 12% 80%, var(--ember), transparent),
    radial-gradient(1.5px 1.5px at 28% 65%, #ffb36b, transparent),
    radial-gradient(2px 2px at 47% 88%, var(--ember), transparent),
    radial-gradient(1.5px 1.5px at 63% 72%, #ffb36b, transparent),
    radial-gradient(2px 2px at 81% 84%, var(--ember), transparent),
    radial-gradient(1.5px 1.5px at 90% 60%, #ffb36b, transparent);
  animation: rise 9s linear infinite;
  opacity: .8;
}
@keyframes rise {
  from { transform: translateY(0); opacity: .9; }
  to { transform: translateY(-60%); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .hero::after { animation: none; } }

.hero-inner { position: relative; z-index: 1; max-width: 720px; margin: 0 auto; }

.kicker {
  margin: 0 0 12px;
  font-family: var(--caps);
  color: var(--gold);
  letter-spacing: .08em;
  font-size: .95rem;
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(3.4rem, 15vw, 7.5rem);
  line-height: .95;
  color: var(--parchment);
  text-shadow: 0 0 40px rgba(224, 138, 60, .35), 0 2px 0 var(--blood-deep);
}

.tagline {
  margin: 18px auto 10px;
  max-width: 34ch;
  font-size: 1.15rem;
  font-style: italic;
  color: var(--parchment);
}

.meta { margin: 0; color: var(--muted); font-size: .9rem; }

.hero-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }

.tally { margin-top: 34px; }
.tally p { margin: 10px 0 0; color: var(--muted); font-size: .95rem; }
.tally-avatars { display: flex; justify-content: center; flex-wrap: wrap; }
.tally-avatars .avatar { width: 34px; height: 34px; font-size: .8rem; margin: 0 -4px; border: 2px solid var(--soot); }
.tally-avatars .avatar.is-pending { filter: grayscale(1) brightness(.5); }

/* ---------- Sections ---------- */
main { max-width: 860px; margin: 0 auto; padding: 0 16px; }

.section { padding: 56px 0 8px; }
#liste { padding-bottom: 48px; }

.section-num {
  margin: 0;
  font-family: var(--display);
  font-size: 1.6rem;
  color: var(--blood);
  line-height: 1;
}

h2 {
  margin: 4px 0 6px;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2rem, 7vw, 2.8rem);
  line-height: 1.1;
}

h3 { font-family: var(--caps); font-weight: 400; font-size: 1.25rem; margin: 0; letter-spacing: .02em; }

.section-lead { margin: 0 0 22px; color: var(--muted); }

/* ---------- Avatars / people ---------- */
.avatar {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  flex: none;
  font-family: var(--caps);
  font-size: 1.4rem;
  color: var(--parchment);
  background: var(--soot-3);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.people {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
}

.person {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 6px 12px;
  background: var(--soot-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
}
.person:hover { border-color: var(--faint); }
.person:active { transform: scale(.97); }
.person.is-me { border-color: var(--ember); background: var(--soot-3); box-shadow: 0 0 0 1px var(--ember), 0 0 24px rgba(224, 138, 60, .2); }
.person-name { font-size: .95rem; line-height: 1.2; }
.person-sum { font-size: .8rem; color: var(--muted); min-height: 1.2em; }

.seal {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 35%, #d23a30, var(--blood-deep));
  color: #ffe9d6;
  font-size: .8rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .5), inset 0 0 0 2px rgba(0, 0, 0, .15);
}

/* ---------- Toolbar ---------- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: 0 -16px 8px;
  padding: 12px 16px 10px;
  background: rgba(20, 16, 12, .94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

#search {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--soot-2);
  color: var(--parchment);
  font: inherit;
  font-size: 16px;
}
#search::placeholder { color: var(--faint); }

.chips, .jump { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin-top: 10px; }
.chips::-webkit-scrollbar, .jump::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  font-size: .9rem;
  cursor: pointer;
}
.chip.is-active { background: var(--parchment); color: var(--soot); border-color: var(--parchment); }

.jump a {
  flex: none;
  font-family: var(--caps);
  font-size: .95rem;
  color: var(--muted);
  text-decoration: none;
  padding: 2px 0;
  margin-right: 10px;
}
.jump a:hover { color: var(--parchment); }

/* ---------- Menu ---------- */
.category { padding-top: 22px; scroll-margin-top: 150px; }
.category h3 { color: var(--gold); padding-bottom: 8px; border-bottom: 1px solid var(--line); }

.items { list-style: none; margin: 0; padding: 0; }

.item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 14px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 170px;
}
.item.has-qty .item-name { color: #fff; }
.item.has-qty { background: linear-gradient(90deg, rgba(179, 38, 30, .12), transparent 70%); margin: 0 -16px; padding-left: 16px; padding-right: 16px; }

.item-name { font-weight: 600; font-size: 1.02rem; }
.item-desc { margin: 2px 0 0; color: var(--muted); font-size: .92rem; line-height: 1.4; }

.tag { font-size: .75rem; margin-left: 6px; vertical-align: 2px; }

.controls { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

.add {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 118px;
  height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--soot-2);
  font-variant-numeric: tabular-nums;
  font-size: .92rem;
  cursor: pointer;
  white-space: nowrap;
}
.add:hover:not(:disabled) { border-color: var(--ember); }
.add:disabled { opacity: .4; cursor: not-allowed; }
.add-plus { color: var(--ember); font-weight: 600; }
.add-size { font-family: var(--caps); color: var(--muted); }

.stepper {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  min-width: 118px;
  height: 38px;
  border-radius: 999px;
  background: var(--blood);
  color: #fff3e6;
  font-variant-numeric: tabular-nums;
}
.stepper button {
  width: 38px;
  height: 38px;
  border: 0;
  background: transparent;
  font-size: 1.2rem;
  cursor: pointer;
}
.stepper-qty { font-weight: 600; font-size: .92rem; text-align: center; line-height: 1.1; }
.stepper-qty small { display: block; font-family: var(--caps); font-weight: 400; font-size: .7rem; opacity: .85; }

.empty-search { color: var(--muted); font-style: italic; text-align: center; padding: 24px 0; }

.note-box { margin-top: 28px; }
.note-box label { display: block; font-family: var(--caps); font-size: 1.1rem; margin-bottom: 6px; }
.note-box textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--soot-2);
  color: var(--parchment);
  font: inherit;
  font-size: 16px;
  resize: vertical;
}
.note-box textarea:disabled { opacity: .5; }

/* ---------- Ledger ---------- */
.ledger {
  position: relative;
  padding: 22px 20px 18px;
  border-radius: 4px;
  color: #2b2016;
  background:
    radial-gradient(ellipse at 0% 0%, rgba(120, 80, 30, .25), transparent 50%),
    radial-gradient(ellipse at 100% 100%, rgba(120, 80, 30, .3), transparent 50%),
    #e9dbbb;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5), inset 0 0 60px rgba(110, 70, 20, .25);
}
.ledger-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.ledger h3 { font-family: var(--display); font-size: 1.8rem; color: var(--blood-deep); }
.ledger .btn-ghost { color: #2b2016; border-color: rgba(43, 32, 22, .35); }

.ledger-lines, .ledger-notes { list-style: none; margin: 0; padding: 0; }
.ledger-lines li {
  display: grid;
  grid-template-columns: 2.4em 1fr auto;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(43, 32, 22, .25);
  font-variant-numeric: tabular-nums;
}
.ledger-lines .qty { font-weight: 600; color: var(--blood-deep); }
.ledger-lines .who { display: block; font-size: .8rem; color: #6b5a44; }
.ledger-notes li { padding: 6px 0 0; font-size: .9rem; font-style: italic; }
.ledger-notes li:first-child { padding-top: 12px; }
.ledger-lines li.ledger-empty { display: block; font-style: italic; color: #6b5a44; padding: 6px 0; border: 0; }
.ledger-total {
  display: flex;
  justify-content: space-between;
  margin: 14px 0 0;
  padding-top: 10px;
  border-top: 2px solid #2b2016;
  font-family: var(--caps);
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
}

.rebels { display: grid; gap: 10px; margin-top: 22px; }

.rebel {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 4px 14px;
  align-items: start;
  padding: 14px;
  background: var(--soot-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.rebel .avatar { width: 44px; height: 44px; font-size: 1rem; }
.rebel.is-pending { opacity: .55; }
.rebel-name { font-weight: 600; }
.rebel-lines { margin: 2px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: .92rem; }
.rebel-note { margin: 4px 0 0; font-size: .88rem; font-style: italic; color: var(--gold); }
.rebel-total { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

.foot { padding: 48px 0 40px; text-align: center; color: var(--faint); font-size: .85rem; }
.foot p { margin: 4px 0; }

/* ---------- Cart bar ---------- */
.cartbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--bar-h);
  padding: 12px max(16px, calc((100vw - 860px) / 2)) calc(12px + env(safe-area-inset-bottom));
  background: rgba(28, 22, 17, .97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .4);
}
.cartbar[hidden] { display: none; }
.cartbar-info { display: flex; flex-direction: column; min-width: 0; }
.cartbar-who { font-family: var(--caps); color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cartbar-sum { font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.cartbar .btn { flex: none; }
.cartbar.is-saved .btn-primary { background: transparent; border-color: var(--line); color: var(--muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bar-h) + 20px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--parchment);
  color: var(--soot);
  font-size: .95rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .5);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--blood); color: #fff3e6; }

@media (min-width: 640px) {
  .people { grid-template-columns: repeat(5, 1fr); }
  .item.has-qty { margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
  .controls { flex-direction: row; }
}
.ledger-total strong { font-family: var(--body); font-weight: 600; }
