/* Retreat Food Sign-Up — mobile-first styles. No external assets. */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light dark;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";

  --bg: #f5f4ef;
  --hero-top: #e2efe9;
  --surface: #ffffff;
  --surface-2: #f3f2ec;
  --surface-3: #e7e5dc;
  --text: #1b201d;
  --text-2: #535c57;
  --border: #e3e1d8;
  --border-strong: #cbc8bd;
  --field-border: #858b86;
  --accent: #0b6e5f;
  --accent-hover: #085a4e;
  --on-accent: #ffffff;
  --accent-soft: #e1f1eb;
  --accent-soft-hover: #d0e8df;
  --accent-ink: #075446;
  --danger: #b3261e;
  --danger-soft: #fcebe9;
  --danger-border: #f0c2bc;
  --notice-bg: #fff5d9;
  --notice-border: #eed79a;
  --notice-ink: #4b3900;
  --notice-icon: #946600;
  --focus: #1d5fd6;
  --backdrop: rgb(17 22 20 / 50%);
  --toast-bg: #1e2622;
  --toast-ink: #f3f7f5;
  --toast-action: #92e3cc;
  --skeleton: #e9e7df;
  --skeleton-hi: #f5f4ee;
  --shadow-card: 0 1px 2px rgb(27 32 29 / 6%), 0 3px 12px rgb(27 32 29 / 5%);
  --shadow-bar: 0 -4px 18px rgb(27 32 29 / 8%);
  --shadow-sheet: 0 -8px 40px rgb(27 32 29 / 20%);
  --shadow-toast: 0 8px 28px rgb(0 0 0 / 22%);

  /* Category accents (strips only — never text). Mirrors the original sheet. */
  --c-blue: #4472c4;   --c-blue-soft: #e9eff9;
  --c-green: #70ad47;  --c-green-soft: #ecf5e5;
  --c-orange: #ed7d31; --c-orange-soft: #fdefe5;
  --c-gray: #a5a5a5;   --c-gray-soft: #f0f0ee;
  --c-purple: #8e6bbf; --c-purple-soft: #f1ecf8;
  --c-teal: #2a9d8f;   --c-teal-soft: #e3f4f2;
  --c-red: #d1495b;    --c-red-soft: #fbe9eb;
  --c-yellow: #e9b824; --c-yellow-soft: #fcf5de;

  /* Avatar backgrounds (white text, all >= 4.5:1). */
  --av-1: #0b6e5f; --av-2: #3b4fb8; --av-3: #7b3f8f; --av-4: #a1442b; --av-5: #5a6814; --av-6: #475467;

  --radius: 18px;
  --radius-sm: 12px;
  --gutter: 16px;
  --maxw: 720px;
  --bar-h: 80px;
  --toolbar-h: 120px;
  --kb: 0px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101412;
    --hero-top: #132019;
    --surface: #1a201d;
    --surface-2: #212925;
    --surface-3: #2b3430;
    --text: #e8eeea;
    --text-2: #a8b2ad;
    --border: #2b3430;
    --border-strong: #3e4944;
    --field-border: #74807a;
    --accent: #4fc4a6;
    --accent-hover: #72d4bb;
    --on-accent: #05241d;
    --accent-soft: #163a31;
    --accent-soft-hover: #1c463b;
    --accent-ink: #93e2cb;
    --danger: #ff9389;
    --danger-soft: #3a1f1c;
    --danger-border: #5e2f2a;
    --notice-bg: #2a2413;
    --notice-border: #4b4020;
    --notice-ink: #f1e3b8;
    --notice-icon: #e6c35f;
    --focus: #86b4ff;
    --backdrop: rgb(0 0 0 / 62%);
    --toast-bg: #eef3f0;
    --toast-ink: #111513;
    --toast-action: #075446;
    --skeleton: #222a26;
    --skeleton-hi: #2b3430;
    --shadow-card: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-bar: 0 -4px 18px rgb(0 0 0 / 40%);
    --shadow-sheet: 0 -8px 40px rgb(0 0 0 / 55%);
    --shadow-toast: 0 8px 28px rgb(0 0 0 / 50%);

    --c-blue: #6a93dc;   --c-blue-soft: #1b2434;
    --c-green: #86c05f;  --c-green-soft: #1c2819;
    --c-orange: #f19158; --c-orange-soft: #30221a;
    --c-gray: #a9a9a9;   --c-gray-soft: #242826;
    --c-purple: #a88bd6; --c-purple-soft: #261f31;
    --c-teal: #3cb8a8;   --c-teal-soft: #142c29;
    --c-red: #e46a79;    --c-red-soft: #321c20;
    --c-yellow: #f0c63f; --c-yellow-soft: #2c2714;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
dialog:not([open]) { display: none; }

html {
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}
html.sheet-open, html.sheet-open body { overflow: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.i {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
[tabindex="-1"]:focus { outline: none; }

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  min-height: 44px;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { top: max(12px, env(safe-area-inset-top)); }

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

/* ---------- Buttons ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  transition: background-color .15s ease, transform .1s ease, box-shadow .15s ease;
}
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--tonal { background: var(--accent-soft); color: var(--accent-ink); }
.btn--quiet { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn--ghost { background: transparent; color: var(--accent-ink); }
.btn--danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.btn--danger-solid { background: var(--danger); color: #fff; }
.btn--lg { min-height: 52px; font-size: 17px; border-radius: 14px; padding: 12px 20px; }
.btn--block { width: 100%; }

@media (hover: hover) {
  .btn--primary:hover { background: var(--accent-hover); }
  .btn--secondary:hover, .btn--quiet:hover { background: var(--surface-2); border-color: var(--field-border); }
  .btn--tonal:hover { background: var(--accent-soft-hover); }
  .btn--ghost:hover { background: var(--accent-soft); }
  .btn--danger:hover { border-color: var(--danger); }
}

.btn[aria-disabled="true"], .btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.is-busy { opacity: .85; }

@media (prefers-color-scheme: dark) {
  .btn--danger-solid { color: #2a0a07; }
}

.spinner {
  display: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  animation: spin .7s linear infinite;
}
.is-busy .spinner { display: inline-block; }
.is-busy > .i { display: none; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-2);
  text-decoration: none;
  touch-action: manipulation;
}
.icon-btn:active { background: var(--surface-3); }
@media (hover: hover) { .icon-btn:hover { background: var(--surface-2); color: var(--text); } }
.icon-btn--pill {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  border-radius: 999px;
  padding: 0 14px;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--text-2);
  font-size: 15px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
@media (hover: hover) { .link-btn:hover { color: var(--text); } }

/* ---------- Header ---------- */
.hero {
  background: linear-gradient(180deg, var(--hero-top) 0%, var(--bg) 100%);
  padding-top: max(20px, env(safe-area-inset-top));
}
.hero__top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "icon date actions" "title title title";
  align-items: center;
  column-gap: 12px;
  row-gap: 14px;
}
.hero__icon {
  grid-area: icon;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  box-shadow: 0 2px 8px rgb(11 110 95 / 25%);
}
.hero__actions { grid-area: actions; display: flex; align-items: center; gap: 6px; }
.hero__title {
  grid-area: title;
  font-size: 30px;
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -.02em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.hero__date {
  grid-area: date;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--text-2);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.3;
}
.hero__date .i { width: 18px; height: 18px; }
.hero__date span { overflow-wrap: anywhere; min-width: 0; }

.notice {
  position: relative;
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--notice-border);
  border-radius: 14px;
  background: var(--notice-bg);
  color: var(--notice-ink);
}
.notice__icon { color: var(--notice-icon); margin-top: 1px; }
.notice__text { font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-line; min-width: 0; }
/* Phones: the notice is clamped to two lines and this button, laid over the
   whole notice, shows the rest (see the phone layout below). */
.notice__more {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 8px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: var(--notice-icon);
  touch-action: manipulation;
}
.notice__more .i { transition: transform .2s ease; }
.notice.is-open .notice__more .i { transform: rotate(180deg); }

.summary {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.summary__text { flex: 1; min-width: 0; }
.summary__main { font-weight: 700; font-size: 15px; }
.summary__status { color: var(--text-2); font-size: 14px; min-height: 20px; }
#refresh-btn .i { transition: transform .3s ease; }
#refresh-btn.is-spinning .i { animation: spin .8s linear infinite; }

/* Organizer panel */
.org-panel {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1.5px dashed var(--accent);
  background: var(--surface);
}
.org-panel__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 800;
  color: var(--accent-ink);
}
.org-panel__hint { margin-top: 4px; font-size: 14px; color: var(--text-2); }
.org-panel__actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.org-panel__actions .btn { font-size: 15px; padding: 8px 10px; }
.org-panel__wide { grid-column: 1 / -1; }

/* Tabs (segmented) */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 18px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-3);
}
.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  font-weight: 700;
  font-size: 16px;
  touch-action: manipulation;
  transition: background-color .15s ease, color .15s ease;
}
.tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgb(0 0 0 / 12%);
}
.tab__count {
  min-width: 24px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 700;
}
.tab__count:empty { display: none; }
.tab[aria-selected="true"] .tab__count { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- Main + toolbar ---------- */
.main {
  padding-bottom: 20px;
  outline: none;
}
.toolbar-sentinel { height: 1px; margin-bottom: -1px; }
.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin-left: calc(-1 * max(var(--gutter), env(safe-area-inset-left)));
  margin-right: calc(-1 * max(var(--gutter), env(safe-area-inset-right)));
  padding: 12px max(var(--gutter), env(safe-area-inset-right)) 10px max(var(--gutter), env(safe-area-inset-left));
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition: box-shadow .2s ease, border-color .2s ease;
}
.toolbar.is-stuck {
  border-bottom-color: var(--border);
  box-shadow: 0 6px 14px -12px rgb(0 0 0 / 35%);
}

.search { position: relative; }
.search__icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-2);
  pointer-events: none;
}
.search__input {
  width: 100%;
  height: 48px;
  padding: 0 48px 0 44px;
  border: 1px solid var(--field-border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}
.search__input::placeholder { color: var(--text-2); opacity: 1; }
.search__input::-webkit-search-cancel-button, .search__input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.search__input:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
.search__clear {
  position: absolute;
  right: 2px;
  top: 2px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-2);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.chip {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  touch-action: manipulation;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.chip[aria-pressed="true"] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}
@media (hover: hover) { .chip[aria-pressed="false"]:hover { border-color: var(--field-border); background: var(--surface-2); } }

/* Section chips (one per category) and, last, the Sort pill: one group that
   wraps onto as many rows as it needs, so every section is visible without
   swiping. It sits below the sticky toolbar (.sections-row) and scrolls away
   with the page. Never give .sections-row a negative margin: the sticky
   toolbar is drawn above it and would cover the chips' top edge. */
.sections {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.chip.chip--sec {
  flex: 0 1 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  max-width: 100%;
  padding: 0 12px;
  text-align: left;
}
/* The first category shares the first row with "All sections", on two lines
   if its name needs them (fitFirstSection in app.js measures the room). */
.chip--sec[data-section="all"] + .chip--sec { max-width: calc(100% - var(--sec-first, 0px)); }
.chip__dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cat, var(--c-gray));
}
/* A long name wraps inside its chip (two lines fit in 44 px); one too long
   even for that ends in "…". Never wider than the chip. */
.chip__text {
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.2;
  text-wrap: balance;
}
.chip--sec[aria-pressed="true"] .chip__dot { box-shadow: 0 0 0 2px var(--bg); }

/* Sort: a pill that shows the current order; the transparent native <select>
   over it opens the phone's own picker. */
.sort {
  position: relative;
  flex: none;
  margin-left: auto; /* at the end of its row: it orders the list, it does not filter it */
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease;
}
.sort__icon { width: 18px; height: 18px; color: var(--text-2); }
.sort__select {
  position: absolute;
  inset: -1px; /* over the border too: the whole 44 px pill is the tap target */
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: inherit;
  opacity: 0;
  font-size: 16px; /* no iOS zoom when it opens */
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.sort:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
@supports selector(:has(*)) {
  .sort:focus-within { outline: none; }
  .sort:has(.sort__select:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
}
.sort.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.sort.is-active .sort__icon { color: currentColor; }
@media (hover: hover) { .sort:hover { border-color: var(--field-border); background: var(--surface-2); } .sort.is-active:hover { background: var(--accent-soft-hover); } }

/* ---------- Category cards ---------- */
/* Every re-render replaces the rows, so browser scroll anchoring has nothing
   stable to hold on to; Chrome could anchor to a row that is being replaced and
   jump the page. Re-renders keep the scroll position by themselves. */
.list { min-height: 40vh; overflow-anchor: none; }
.cat {
  scroll-margin-top: calc(var(--toolbar-h) + 8px);
  margin-top: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  border: 1px solid var(--border);
}
.cat:first-child { margin-top: 6px; }
.cat--blue   { --cat: var(--c-blue);   --cat-soft: var(--c-blue-soft); }
.cat--green  { --cat: var(--c-green);  --cat-soft: var(--c-green-soft); }
.cat--orange { --cat: var(--c-orange); --cat-soft: var(--c-orange-soft); }
.cat--gray   { --cat: var(--c-gray);   --cat-soft: var(--c-gray-soft); }
.cat--purple { --cat: var(--c-purple); --cat-soft: var(--c-purple-soft); }
.cat--teal   { --cat: var(--c-teal);   --cat-soft: var(--c-teal-soft); }
.cat--red    { --cat: var(--c-red);    --cat-soft: var(--c-red-soft); }
.cat--yellow { --cat: var(--c-yellow); --cat-soft: var(--c-yellow-soft); }

.cat__head {
  display: flex;
  align-items: stretch;
  border-top: 6px solid var(--cat);
  background: var(--cat-soft);
}
.cat__title { flex: 1; min-width: 0; font-size: 17px; line-height: 1.3; }
.cat__toggle, .cat__static {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 12px 12px 12px 16px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 800;
  touch-action: manipulation;
}
.cat__toggle:focus-visible { outline-offset: -3px; }
.cat__label {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 10px;
  row-gap: 5px;
}
.cat__name { flex: 1 1 auto; min-width: 0; overflow-wrap: break-word; }
/* Organizer mode: a section a guest made. The badge's own background, not the
   section color, so it reads the same on every heading. */
.cat__name .cat__badge { background: var(--surface); }
.cat__count {
  flex: none;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.cat__chev { color: var(--text-2); transition: transform .2s ease; }
.cat__toggle[aria-expanded="false"] .cat__chev { transform: rotate(-90deg); }
.cat__edit { align-self: center; margin-right: 6px; color: var(--text); }
.cat__edit:focus-visible { outline-offset: -3px; }

.cat__empty { padding: 14px 16px 4px; color: var(--text-2); font-size: 15px; }

.cat__foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border);
}
.add-else {
  flex: 1 1 180px;
  min-height: 46px;
  border: 1.5px dashed var(--field-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 15px;
}
@media (hover: hover) { .add-else:hover { background: var(--accent-soft); border-color: var(--accent); } }

/* ---------- Item rows ---------- */
.item {
  padding: 10px 12px 12px 14px;
  border-top: 1px solid var(--border);
  scroll-margin-top: calc(var(--toolbar-h) + 12px);
  scroll-margin-bottom: calc(var(--bar-h) + 12px);
}
.item:first-child { border-top: 0; }
.item__main { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.item__status {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-top: 11px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
}
.item.is-taken .item__status { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.item__status .i { width: 14px; height: 14px; stroke-width: 3.2; }
.item__text { flex: 1; min-width: 0; padding-top: 10px; line-height: 1.4; }
.item__name { font-weight: 600; overflow-wrap: anywhere; }
.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--c-purple-soft);
  color: var(--text);
  border: 1px solid var(--border-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  vertical-align: 2px;
  white-space: nowrap;
}
.item__edit { flex: none; margin-top: 0; color: var(--text-2); }
.item__btn { flex: none; min-width: 104px; padding: 10px 12px; font-size: 15px; }
.item__btn .i { width: 18px; height: 18px; margin-left: -2px; }
.item.is-taken .item__btn { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
@media (hover: hover) { .item.is-taken .item__btn:hover { background: var(--surface-2); } }

.pledges { display: grid; gap: 6px; margin: 8px 0 0 32px; }
.pledge {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 6px 10px 6px 6px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--text);
  text-align: left;
  touch-action: manipulation;
}
@media (hover: hover) { .pledge:hover { background: var(--accent-soft-hover); } }
.pledge.is-mine { border-color: var(--accent); }
.pledge__text { flex: 1; min-width: 0; font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; }
.pledge__person { font-weight: 700; }
.pledge__meta { color: var(--text-2); }
.pledge__edit { width: 16px; height: 16px; color: var(--text-2); }
.you-tag {
  display: inline-block;
  flex: none;
  margin-left: 6px;
  vertical-align: 1px;
  line-height: 1.35;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 12px;
  font-weight: 800;
}

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--av-1);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}
.avatar--2 { background: var(--av-2); }
.avatar--3 { background: var(--av-3); }
.avatar--4 { background: var(--av-4); }
.avatar--5 { background: var(--av-5); }
.avatar--6 { background: var(--av-6); }
.avatar--lg { width: 40px; height: 40px; font-size: 17px; }

.item.is-flash { animation: flash 1.8s ease-out; }
@keyframes flash {
  0%, 30% { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
  100% { background: transparent; box-shadow: inset 4px 0 0 transparent; }
}

/* ---------- Empty / error / loading states ---------- */
.empty {
  margin-top: 8px;
  padding: 28px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: center;
}
.empty__icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 10px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.empty__title { font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.empty__text { margin-top: 6px; color: var(--text-2); overflow-wrap: anywhere; }
.empty__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
/* "Add “<search text>”" can hold up to 100 characters without spaces: let it wrap inside the button. */
.empty__actions .btn { max-width: 100%; overflow-wrap: anywhere; }
.empty--error .empty__icon { background: var(--danger-soft); color: var(--danger); }

.loading { padding-top: 6px; }
.sk-card {
  margin-top: 14px;
  padding: 0 14px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}
.sk {
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--skeleton) 25%, var(--skeleton-hi) 50%, var(--skeleton) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
.sk--head { height: 20px; width: 55%; margin: 20px 0 10px; }
.sk-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--border); }
.sk--w40 { width: 40%; } .sk--w50 { width: 50%; } .sk--w60 { width: 60%; } .sk--w70 { width: 70%; }
.sk--btn { width: 96px; height: 40px; border-radius: 12px; flex: none; }

/* ---------- People ---------- */
.people-head { padding: 16px 2px 2px; }
.people-head__title { font-size: 18px; font-weight: 800; }
.people-head__text { color: var(--text-2); font-size: 15px; margin-top: 2px; }
.person {
  margin-top: 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.person__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}
.person__name { flex: 1; min-width: 0; font-size: 17px; font-weight: 800; overflow-wrap: anywhere; }
.person__count { flex: none; color: var(--text-2); font-size: 14px; font-weight: 600; }
.person__list { border-top: 1px solid var(--border); }
.person__list li + li { border-top: 1px solid var(--border); }
.entry {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  touch-action: manipulation;
}
.entry:focus-visible { outline-offset: -3px; }
@media (hover: hover) { .entry:hover { background: var(--surface-2); } }
.entry__dot { flex: none; width: 12px; height: 12px; margin-top: 6px; border-radius: 50%; background: var(--cat, var(--c-gray)); }
.entry__text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.entry__name { display: block; font-weight: 600; }
.entry__meta { display: block; color: var(--text-2); font-size: 14px; margin-top: 1px; }
.entry__edit { width: 16px; height: 16px; margin-top: 4px; color: var(--text-2); }

/* ---------- Footer ---------- */
.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  padding-top: 8px;
  /* --tour-offer-h: set by tour.js while the "First time here?" card sits
     above the bottom bar, so these links can scroll up above it too. */
  padding-bottom: calc(var(--bar-h) + 24px + var(--tour-offer-h, 0px));
  color: var(--text-2);
  font-size: 14px;
}
.footer__text { min-width: 0; }
/* "Help & how-to" and "Organizer"; the negative margin lines their text up
   with the paragraph when they wrap below it. */
.footer__links { display: flex; flex-wrap: wrap; align-items: center; column-gap: 8px; margin-inline: -8px; }
/* Copyright and contact: a row of their own under the links (two lines on
   narrow phones). The address is a 44 px tall link. */
.footer__legal {
  flex: 1 0 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 16px;
  font-size: 13px;
}
.footer__legal p { min-width: 0; }
.footer__mail {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
  margin-inline: -4px;
  color: var(--text-2);
  text-decoration: underline;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}
@media (hover: hover) { .footer__mail:hover { color: var(--text); } }

/* ---------- Bottom bar ---------- */
.bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 10px max(var(--gutter), env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow-bar);
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .bar {
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    -webkit-backdrop-filter: saturate(1.6) blur(14px);
    backdrop-filter: saturate(1.6) blur(14px);
  }
}
.bar__inner {
  max-width: calc(var(--maxw) - 2 * var(--gutter));
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.bar__add { width: 100%; font-size: 16px; padding: 12px 14px; gap: 6px; }
.bar__add span { overflow-wrap: anywhere; }
.bar__mine {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--accent-ink);
  font-size: 15px;
  font-weight: 700;
  touch-action: manipulation;
}
.bar__mine .i { width: 18px; height: 18px; }
.bar__chev { opacity: .8; }
@media (hover: hover) { .bar__mine:hover { background: var(--accent-soft); } }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--bar-h) + 10px);
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 max(var(--gutter), env(safe-area-inset-left));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 520px;
  min-height: 52px;
  padding: 6px 6px 6px 16px;
  border-radius: 14px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  box-shadow: var(--shadow-toast);
  pointer-events: auto;
  animation: toast-in .22s cubic-bezier(.2, .8, .2, 1);
}
.toast.is-leaving { animation: toast-out .18s ease-in forwards; }
.toast__msg { flex: 1; min-width: 0; padding: 8px 0; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.toast__action {
  flex: none;
  min-height: 44px;
  min-width: 64px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--toast-action);
  font-weight: 800;
  font-size: 15px;
}
.toast__action:focus-visible { outline-color: var(--toast-action); outline-offset: -2px; }
@media (hover: hover) { .toast__action:hover { background: rgb(127 127 127 / 18%); } }

/* ---------- Bottom sheet (dialog) ---------- */
.sheet {
  position: fixed;
  inset: auto 0 var(--kb) 0;
  width: 100%;
  max-width: 100%;
  max-height: calc(100vh - 12px);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sheet);
  overflow: hidden;
}
@supports (height: 100dvh) {
  .sheet { max-height: calc(100dvh - 12px); }
}
.has-vv .sheet { max-height: calc(var(--vvh, 100vh) - 12px); }
.sheet[open] { display: flex; flex-direction: column; }
/* Before Safari 17.4 / Chrome 122, ::backdrop does not inherit custom
   properties from :root, so var(--backdrop) alone would be transparent there. */
.sheet::backdrop { background: var(--backdrop, rgb(17 22 20 / 50%)); }
@media (prefers-color-scheme: dark) {
  .sheet::backdrop { background: var(--backdrop, rgb(0 0 0 / 62%)); }
}

.sheet__form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.sheet__head {
  position: relative;
  flex: none;
  padding: 22px 60px 8px 20px;
}
.sheet__grabber {
  position: absolute;
  top: 8px;
  left: 50%;
  width: 40px;
  height: 5px;
  margin-left: -20px;
  border-radius: 3px;
  background: var(--border-strong);
}
.sheet__title { font-size: 20px; line-height: 1.25; font-weight: 800; overflow-wrap: anywhere; }
.sheet__sub { margin-top: 3px; color: var(--text-2); font-size: 15px; overflow-wrap: anywhere; }
.sheet__x { position: absolute; top: 12px; right: 10px; }
.sheet__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2px 20px 18px;
}
.sheet__foot {
  flex: none;
  padding: 10px 20px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.kb-open .sheet__foot { padding-bottom: 10px; }
.sheet__error {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 600;
  font-size: 15px;
  overflow-wrap: anywhere;
}
.sheet__error:empty { display: block; height: 0; margin: 0; padding: 0; overflow: hidden; }
.sheet__actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 10px; }
.sheet__actions .btn { min-height: 52px; font-size: 17px; }
.sheet__form--view .sheet__actions { grid-template-columns: minmax(0, 1fr); }

@media (min-width: 640px) {
  .sheet {
    inset: 0;
    margin: auto;
    width: min(540px, calc(100% - 48px));
    max-height: min(760px, calc(100vh - 64px));
    border-radius: 22px;
  }
  @supports (height: 100dvh) { .sheet { max-height: min(760px, calc(100dvh - 64px)); } }
  .has-vv .sheet { max-height: min(760px, calc(var(--vvh, 100vh) - 64px)); }
  .sheet__grabber { display: none; }
  .sheet__head { padding-top: 22px; }
  .sheet__foot { padding-bottom: 16px; }
}

/* Form fields */
.field { margin-top: 16px; }
.field__head { display: flex; align-items: baseline; gap: 4px; margin-bottom: 6px; }
.field__label { display: block; margin-bottom: 6px; font-size: 15px; font-weight: 700; }
.field__head .field__label { margin-bottom: 0; }
.field__req { color: var(--danger); font-weight: 700; }
.field__opt { margin-left: 4px; color: var(--text-2); font-size: 14px; }
.input, .select, .textarea {
  display: block;
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid var(--field-border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  line-height: 1.35;
  -webkit-appearance: none;
  appearance: none;
}
.textarea { min-height: 110px; resize: vertical; }
.input::-webkit-calendar-picker-indicator { display: none !important; } /* datalist arrow; suggestions still show while typing */
.input::placeholder, .textarea::placeholder { color: var(--text-2); opacity: .85; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--focus);
}
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); border-width: 2px; }
.select-wrap { position: relative; }
.select { padding-right: 44px; }
.select-wrap .i { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text-2); pointer-events: none; }
.field__hint { margin-top: 6px; color: var(--text-2); font-size: 14px; }
.field__error { margin-top: 6px; color: var(--danger); font-size: 14px; font-weight: 700; }
.field__error:empty { display: none; }
/* "New category name" (Add sheet): tucked under the Category menu it belongs to. */
.field--newcat {
  margin-top: 10px;
  padding: 2px 0 2px 12px;
  border-left: 3px solid var(--accent);
}

.context {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 15px;
  overflow-wrap: anywhere;
}
.context strong { color: var(--text); }
.context + .context { margin-top: 8px; }
.context--mine { background: var(--accent-soft); color: var(--text); }

.danger-zone { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.danger-zone__note { margin-top: 8px; color: var(--text-2); font-size: 14px; }
.confirm {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--danger-border);
  background: var(--danger-soft);
}
.confirm__text { font-weight: 700; color: var(--text); overflow-wrap: anywhere; }
.confirm__actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-top: 12px; }
.confirm__actions .btn { min-width: 0; overflow-wrap: anywhere; }

/* Color picker */
.colors { border: 0; padding: 0; margin: 16px 0 0; min-width: 0; }
.colors legend { padding: 0; }
.colors__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.colors__opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
}
.colors__input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.colors__swatch { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--cat); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 15%); }
.colors__opt:has(.colors__input:checked) { border-color: var(--text); border-width: 2px; padding: 7px 11px; background: var(--surface-2); }
.colors__input:checked + .colors__swatch { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--text); }
.colors__opt:has(.colors__input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Checkbox row: the whole row is the tap target (it is the <label>). */
.carry { margin-top: 16px; }
.check {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
}
.check__input {
  /* A 44 px target centred on the drawn box; the rest of the row is the label. */
  position: absolute;
  left: 4px;
  top: 2px;
  z-index: 1;
  width: 44px;
  height: 44px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.check__box {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--field-border);
  border-radius: 7px;
  background: var(--surface);
  color: transparent;
}
.check__box .i { width: 16px; height: 16px; stroke-width: 3; }
.check__input:checked + .check__box { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.check:has(.check__input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.check:has(.check__input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.check__label { flex: 1; min-width: 0; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag {
  max-width: 100%;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.tag--more { border-style: dashed; background: transparent; color: var(--text-2); }
.carry__note { margin-top: 10px; color: var(--text-2); font-size: 14px; overflow-wrap: anywhere; }

.sheet-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 36px 8px;
  color: var(--text-2);
  font-weight: 600;
}
.spinner.is-on { display: inline-block; }

/* Past events */
.past { display: grid; gap: 10px; margin-top: 12px; }
.past__item {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.past__title { font-size: 17px; line-height: 1.3; font-weight: 800; overflow-wrap: anywhere; }
.past__sub { margin-top: 2px; font-size: 15px; font-weight: 500; overflow-wrap: anywhere; }
.past__meta { margin-top: 4px; color: var(--text-2); font-size: 14px; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.past__actions { display: flex; gap: 8px; margin-top: 12px; }
.past__actions .btn { flex: 1 1 auto; min-width: 0; padding: 8px 12px; font-size: 15px; white-space: nowrap; }
.past__actions .btn .i { width: 18px; height: 18px; }
.past__actions .btn__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 419px) { .past__actions .btn:not(.past__del) .i { display: none; } }
@media (max-width: 359px) {
  .past__item { padding: 12px; }
  .past__actions { gap: 6px; }
  .past__actions .btn { padding: 8px 10px; font-size: 14px; }
}
.past__actions .past__del { flex: none; width: 44px; padding: 0; }
.past__confirm { margin-top: 12px; }
.sheet .empty { margin-top: 12px; border-style: dashed; }

/* A past event, read-only */
.snap__summary {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  overflow-wrap: anywhere;
}
.snap__stats { font-weight: 700; font-size: 15px; }
.snap__when { margin-top: 2px; color: var(--text-2); font-size: 14px; }
.snap__cat {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.snap__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding: 10px 12px;
  border-top: 5px solid var(--cat);
  background: var(--cat-soft);
  font-size: 16px;
  line-height: 1.3;
  font-weight: 800;
}
.snap__cat-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.snap__count {
  flex: none;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 700;
}
.snap__item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
  padding: 9px 12px;
  border-top: 1px solid var(--border);
}
.snap__item:first-child { border-top: 0; }
.snap__name { flex: 1 1 0; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.snap__none { flex: none; color: var(--text-2); }
.snap__pledges { flex: 1 1 100%; display: grid; gap: 2px; color: var(--text-2); font-size: 15px; overflow-wrap: anywhere; }
.snap__person { color: var(--text); font-weight: 700; }
.snap__empty { padding: 10px 12px; color: var(--text-2); }

/* ---------- Photos and links on items (v5) ---------- */
/* A line under the item's name (lined up with it): a thumbnail (tap for the
   big photo) and the link, which gets the row's full width. */
.item__media { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 6px 0 0 32px; min-width: 0; }
.item__thumb, .photo-pick__preview, .snap__thumb {
  flex: none;
  display: block;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-3);
}
.item__thumb { width: 64px; height: 64px; cursor: zoom-in; touch-action: manipulation; }
.item__thumb img, .photo-pick__preview img, .photo-pick__canvas, .snap__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
@media (hover: hover) { .item__thumb:hover { border-color: var(--accent); } }
/* A photo that could not be loaded leaves the plain placeholder. */
img.is-broken { visibility: hidden; }

.item__link, .media__link, .snap__link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  min-height: 44px; /* tap target */
  color: var(--accent-ink);
  font-size: 15px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  touch-action: manipulation;
}
.item__link .i, .media__link .i, .snap__link .i { flex: none; width: 16px; height: 16px; }
.item__link { gap: 4px; font-size: 14px; }
.item__link .i { width: 14px; height: 14px; }
.link-host { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* In a sheet: the photo (and link) of the item it is about. */
.media { display: grid; justify-items: start; gap: 6px; margin-top: 4px; }
.media__photo {
  display: grid;
  place-items: center;
  width: 100%;
  margin: 0;
  overflow: hidden;
  border-radius: 14px;
  background: var(--surface-2);
}
.media__photo img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(30vh, 220px);
}
.media__photo--big img { max-height: min(60vh, 560px); }
.media__photo img.is-broken { visibility: visible; min-height: 120px; opacity: 0; }

/* Photo field (Add / Edit sheets). */
.photo-pick__row { display: flex; align-items: center; gap: 12px; }
.photo-pick__preview { width: 88px; height: 88px; }
.photo-pick__actions { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.photo-pick__btn { padding: 8px 12px; font-size: 15px; }
.photo-pick__btn .i { width: 18px; height: 18px; }
.photo-pick__status { margin-top: 6px; color: var(--text-2); font-size: 14px; }
.photo-pick__status:empty { display: none; }

/* "+ Add a photo or link" (guest Add sheet) and what it opens. */
.extras__toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin-top: 10px;
  padding: 0 4px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--accent-ink);
  font-size: 16px;
  font-weight: 700;
  touch-action: manipulation;
}
.extras__toggle .i { width: 18px; height: 18px; }
.extras__toggle .field__opt { font-weight: 400; }
@media (hover: hover) { .extras__toggle:hover { background: var(--accent-soft); } }
.extras { margin-top: 10px; padding: 2px 0 2px 12px; border-left: 3px solid var(--accent); }
.extras > .field:first-child { margin-top: 4px; }

/* Past events. */
.snap__media { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 6px; font-weight: 400; }
.snap__thumb { width: 48px; height: 48px; border-radius: 10px; }

.noscript { padding: 20px; text-align: center; }

/* ---------- Phones: a compact header, so the list starts on the first screen ---------- */
@media (max-width: 639px) {
  .hero { padding-top: max(12px, env(safe-area-inset-top)); }
  .hero__top {
    grid-template-areas: "icon title actions" "icon date actions";
    column-gap: 10px;
    row-gap: 1px;
  }
  .hero__top:has(> .hero__date[hidden]) { grid-template-areas: "icon title actions"; }
  .hero__title { font-size: 20px; line-height: 1.15; letter-spacing: -.01em; }
  .hero__date { gap: 5px; font-size: 14px; }
  .hero__date .i { width: 15px; height: 15px; }

  .notice { margin-top: 10px; padding: 8px 34px 8px 10px; gap: 8px; border-radius: 12px; }
  .notice__icon { width: 18px; height: 18px; }
  .notice__text { font-size: 14px; line-height: 1.4; }
  .notice:not(.is-open) .notice__text {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
  }

  /* "N of M items taken · P people signed up · Updated just now" as one short paragraph. */
  .summary { margin-top: 6px; gap: 4px; }
  .summary__text { line-height: 1.35; }
  .summary__main, .summary__status { display: inline; }
  .summary__status { font-size: 14px; }
  #updated:not(:empty)::before { content: "· "; content: "· " / ""; } /* decorative: not read out */

  .tabs { margin-top: 10px; }

  .toolbar { padding-top: 6px; padding-bottom: 6px; }
  .search__input { height: 44px; }
  .search__clear { top: 0; }
  .chips { margin-top: 6px; }

  .cat__title { font-size: 16px; }
  .cat__toggle, .cat__static { gap: 8px; min-height: 50px; padding: 8px 10px 8px 14px; }
  .cat__label { column-gap: 8px; row-gap: 3px; }
  .cat__head { border-top-width: 5px; }
  .cat__count { padding: 1px 8px; }
  .item { padding-top: 8px; padding-bottom: 8px; }
  .pledges { margin-top: 6px; }

  .bar { padding-top: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .bar__inner { gap: 0; }
  .bar__add { min-height: 48px; padding-top: 10px; padding-bottom: 10px; }
}

/* ---------- Wider screens ---------- */
@media (min-width: 640px) {
  :root { --gutter: 24px; }
  .hero__title { font-size: 34px; }
  .chip { flex: none; padding: 0 16px; }
  .chip.chip--sec { padding: 0 14px; }
  /* One compact sticky row: search + All/Open/Taken/Mine. The section chips
     and Sort follow below it (and scroll away with the page). */
  .toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 12px; }
  .toolbar .search { min-width: 0; }
  .toolbar .chips { margin-top: 0; flex-wrap: nowrap; }
  .bar__inner { flex-direction: row; align-items: center; justify-content: flex-end; gap: 12px; }
  .bar__mine { margin-right: auto; }
  .bar__add { width: auto; }
  .org-panel__actions { display: flex; flex-wrap: wrap; }
  .org-panel__actions .btn { white-space: nowrap; padding: 8px 14px; }
}

/* Phones: Help and Share show only their icons (44 px targets, named by
   aria-label), so the title keeps one line. */
@media (max-width: 479px) {
  .icon-btn--pill { width: 44px; padding: 0; }
  .icon-btn__text { display: none; }
}

/* ---------- Phones: a tighter vertical rhythm ----------
   So the first items still show above the bottom bar with Safari's toolbars
   open (e.g. 390 x 664 on an iPhone 14, 375 x 667 or 320 x 568). */
@media (max-width: 639px) {
  .hero { padding-top: max(8px, env(safe-area-inset-top)); }
  .notice { margin-top: 8px; padding-top: 6px; padding-bottom: 6px; }
  .summary { margin-top: 4px; }
  .tabs { margin-top: 8px; padding: 3px; }
  .toolbar { padding-top: 4px; padding-bottom: 4px; }
  .sections-row { margin-top: 1px; } /* + the toolbar's 4px padding and 1px border = the 6px chip gap */
  .cat:first-child { margin-top: 4px; }
  .cat__toggle, .cat__static { padding-top: 6px; padding-bottom: 6px; }
  .item { padding-top: 6px; padding-bottom: 6px; }
}
@media (max-width: 429px) {
  /* The title gets the icon's room (Help and Share sit beside it), so it fits on one line. */
  .hero__icon { display: none; }
  .hero__top { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title actions" "date actions"; }
  .hero__top:has(> .hero__date[hidden]) { grid-template-areas: "title actions"; }
}

/* ---------- Narrow phones (iPhone SE 1st gen, small Androids) ---------- */
@media (max-width: 359px) {
  :root { --gutter: 12px; }
  /* Room for "Fruit / Vegetables / Nuts" on two lines beside "All sections". */
  .chip.chip--sec { gap: 5px; padding: 0 9px; }
  .sort { padding: 0 12px 0 10px; font-size: 14px; }
  /* One line beside the Help and Share icons. */
  .hero__title { font-size: 16px; }
  .hero__actions { gap: 4px; }
  .hero__date { font-size: 13px; }
  .summary__main { font-size: 14px; }
  .summary__status { font-size: 13px; }
  .chip { padding: 0 8px; font-size: 14px; }
  .bar__add { font-size: 15px; }
  .bar__add .i { display: none; }
  .item { padding-left: 12px; padding-right: 10px; }
  .item__main { gap: 8px; }
  .item__btn { min-width: 92px; padding: 10px; }
  .pledges { margin-left: 30px; }
  .pledge { gap: 8px; }
  .pledge .avatar { width: 28px; height: 28px; font-size: 13px; }
  .sheet__head { padding-left: 16px; }
  .sheet__body, .sheet__foot { padding-left: 16px; padding-right: 16px; }
  .org-panel__actions { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Short landscape screens (a phone held sideways) ----------
   A sticky toolbar would cover most of the few hundred pixels there are, so
   it scrolls away with the page. (The aspect ratio keeps a portrait phone
   whose keyboard shrinks the viewport out of this.) */
@media (max-height: 500px) and (min-aspect-ratio: 3/2) {
  .toolbar { position: static; }
  .toolbar.is-stuck { border-bottom-color: transparent; box-shadow: none; }
  .cat { scroll-margin-top: 8px; }
  .item { scroll-margin-top: 12px; }
}

/* ---------- Motion ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(12px) scale(.97); } }
@keyframes pop-out { to { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

.sheet[open] { animation: sheet-up .3s cubic-bezier(.2, .85, .25, 1); }
.sheet.sheet--fade[open] { animation: fade-in .18s ease-out; }
.sheet[open]::backdrop { animation: fade-in .25s ease-out; }
.sheet[open].is-closing { animation: sheet-down .2s ease-in forwards; }
.sheet[open].is-closing::backdrop { animation: fade-out .2s ease-in forwards; }
@media (min-width: 640px) {
  .sheet[open], .sheet.sheet--fade[open] { animation: pop-in .22s cubic-bezier(.2, .85, .25, 1); }
  .sheet[open].is-closing { animation: pop-out .16s ease-in forwards; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, .sheet[open]::backdrop, .sheet[open].is-closing::backdrop {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .sk { animation: none; }
  .btn:active { transform: none; }
}

@media (forced-colors: active) {
  .chip[aria-pressed="true"], .tab[aria-selected="true"] { outline: 2px solid CanvasText; }
  .item__status { forced-color-adjust: none; }
}
