/* PhotoPool — Material-3-flavoured, dark-mode safe, big tappable rows */
:root {
  --bg: #faf8ff; --surface: #ffffff; --surface2: #f1ecfa;
  --text: #1c1b21; --muted: #5f5b6b; --line: #e3ddf0;
  --primary: #5a41c8; --on-primary: #ffffff; --primary-soft: #e9e2ff;
  --ok-bg: #e3f6e8; --ok-text: #14631f; --err: #b3261e;
  --radius: 20px; --radius-s: 12px;
  --qr-tile: #ffffff; --qr-ink: #14121c; --qr-frame: #ffffff;
  /* Overwritten per event category by applyCategoryTheme() */
  --accent: #5a41c8;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141218; --surface: #1d1a24; --surface2: #262130;
    --text: #e8e4f2; --muted: #a49dbb; --line: #383246;
    --primary: #c3b3ff; --on-primary: #241a55; --primary-soft: #322a52;
    --ok-bg: #143d1e; --ok-text: #9fe3ab; --err: #ffb4ab;
    /* Tinted lavender tile + deep indigo modules: reads as part of the dark theme,
       still ~13:1 contrast so every scanner reads it. */
    --qr-tile: #ede9fb; --qr-ink: #211a3d; --qr-frame: #ede9fb;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 520px; margin: 0 auto; padding: 20px 16px 48px; }
.wrap.wide { max-width: 1024px; }
h1 { font-size: 1.9rem; line-height: 1.2; margin: 12px 0 8px; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; margin: 4px 0 12px; }
.center { text-align: center; }
.brand { font-weight: 700; font-size: 1.05rem; }
.brand .by { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.back { text-decoration: none; color: var(--text); font-weight: 700; display: inline-block; margin-bottom: 8px; }
.hero { text-align: center; padding: 20px 0 8px; }
.sub, .meta { color: var(--muted); margin: 6px 0 16px; }
.opt { color: var(--muted); font-weight: 400; font-size: 0.9em; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin: 16px 0;
  box-shadow: 0 2px 12px rgb(0 0 0 / 0.05);
}
label { display: block; font-weight: 600; font-size: 0.9rem; margin: 14px 0 6px; }
input[type="text"], input[type="date"], select {
  width: 100%; padding: 14px; font-size: 1rem; color: var(--text);
  background: var(--surface2); border: 1px solid var(--line); border-radius: var(--radius-s);
}
.btn {
  display: inline-block; padding: 14px 22px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--surface2); color: var(--text);
  font-size: 1rem; font-weight: 600; text-align: center; text-decoration: none;
  cursor: pointer; min-height: 48px;
}
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.block { display: block; width: 100%; margin-top: 14px; }
.btn.small { padding: 8px 16px; min-height: 0; }
.btn[disabled] { opacity: 0.6; pointer-events: none; }
#create-btn { width: 100%; margin-top: 20px; }
.price { text-align: center; color: var(--muted); font-size: 0.85rem; margin: 10px 0 0; }
.error { color: var(--err); font-weight: 600; }
.banner { border-radius: var(--radius-s); padding: 12px 16px; margin: 12px 0; font-weight: 600; }
.banner.ok { background: var(--ok-bg); color: var(--ok-text); }
.steps .step { display: flex; gap: 14px; align-items: flex-start; padding: 12px 4px; }
.steps .n {
  flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft);
  color: var(--primary); font-weight: 800; display: grid; place-items: center;
}
.foot { text-align: center; color: var(--muted); font-size: 0.8rem; margin-top: 28px; }

/* ---------- Category picker (illustrated event types) ---------- */
.label-as-legend { display: block; font-weight: 600; font-size: 0.9rem; margin: 18px 0 10px; }
.cat-picker { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.cat-card {
  --cat-accent: var(--primary);
  display: flex; flex-direction: column; align-items: stretch; gap: 0;
  padding: 0; overflow: hidden; cursor: pointer; text-align: center;
  background: var(--surface); color: var(--text);
  border: 2px solid var(--line); border-radius: var(--radius);
  transition: border-color .12s ease, transform .12s ease, box-shadow .12s ease;
}
.cat-card:hover { transform: translateY(-2px); }
.cat-card:focus-visible { outline: 3px solid var(--cat-accent); outline-offset: 2px; }
.cat-card[aria-checked="true"] {
  border-color: var(--cat-accent);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--cat-accent) 28%, transparent);
}
.cat-tile { display: block; position: relative; }
.cat-art { display: block; width: 100%; height: auto; aspect-ratio: 120 / 150; }
/* Selected card gets a tick badge — the border alone is too quiet on a small screen. */
.cat-card[aria-checked="true"] .cat-tile::after {
  content: "✓"; position: absolute; top: 8px; right: 8px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--cat-accent); color: #fff;
  font-size: 15px; font-weight: 800; line-height: 26px;
  box-shadow: 0 2px 6px rgb(0 0 0 / .25);
}
.cat-name {
  display: block; padding: 10px 8px 2px; font-weight: 800; font-size: 1rem;
  letter-spacing: .01em; color: var(--cat-accent);
}
.cat-blurb { display: block; padding: 0 10px 12px; font-size: .76rem; line-height: 1.35; color: var(--muted); }
@media (prefers-color-scheme: dark) {
  /* The artwork is painted in light pastels — lift its own accent so the label
     stays legible on a dark card without repainting every illustration. */
  .cat-name { color: color-mix(in srgb, var(--cat-accent) 55%, white); }
}
@media (min-width: 560px) { .cat-picker { grid-template-columns: repeat(3, 1fr); } }

/* Category identity on the event pages */
.cat-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 14px 5px 5px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
  font-size: .8rem; font-weight: 700; color: var(--accent);
  margin-bottom: 10px;
}
@media (prefers-color-scheme: dark) {
  .cat-chip { color: color-mix(in srgb, var(--accent) 55%, white); }
}
.cat-chip .cat-art { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; aspect-ratio: 1; }
.event-head h1 { color: var(--text); }
/* Accent-driven primary action on themed event pages */
:root[data-category] .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-category] .drop { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
:root[data-category] .steps .n { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); color: var(--accent); }
/* host */
/* Event identity header — centred on the event pages (host + guest upload). */
.event-head { text-align: center; }
.event-head h1 { margin-bottom: 6px; }
.event-head .meta { margin-bottom: 4px; }

.qr-box { text-align: center; padding: 12px 0; }
#qr {
  display: inline-block;
  padding: 10px;
  border-radius: var(--radius-s);
  background: var(--qr-frame);
  border: 1px solid var(--line);
}
#qr svg { display: block; width: min(272px, 68vw); height: auto; }
/* Themed but always scannable: dark modules on a light tile in BOTH themes.
   Inverting the code in dark mode breaks scanners that don't handle inversion. */
.qr-tile { fill: var(--qr-tile); }
.qr-ink { fill: var(--qr-ink); }
.qr-hint { color: var(--muted); font-size: 0.85rem; }

/* iPad / tablet: the host card is often propped on a table as a kiosk — the code
   has to be scannable from arm's length across the table, so it gets much bigger. */
@media (min-width: 700px) {
  #qr svg { width: min(400px, 46vmin); }
  #qr { padding: 16px; }
  .qr-hint { font-size: 1rem; }
}
@media (min-width: 1024px) {
  #qr svg { width: min(460px, 44vmin); }
}
.linkrow { display: flex; gap: 8px; }
.linkrow input { flex: 1; font-size: 0.85rem; }
.explain details { border-top: 1px solid var(--line); }
.explain details:first-of-type { border-top: 0; }
.explain summary {
  padding: 16px 4px; font-weight: 700; cursor: pointer; list-style: none; min-height: 48px;
}
.explain summary::-webkit-details-marker { display: none; }
.d-body { padding: 0 4px 16px; color: var(--muted); }
.d-body ol { margin: 6px 0; padding-left: 22px; }
.status-live { color: var(--ok-text); font-weight: 600; }
/* upload */
.drop {
  border: 2px dashed var(--primary); border-radius: var(--radius); text-align: center;
  padding: 32px 16px; margin: 16px 0; cursor: pointer; background: var(--primary-soft);
}
.drop.over { background: var(--surface2); }
.drop-icon { font-size: 2rem; }
.queue { list-style: none; padding: 0; margin: 16px 0 0; }
.queue li {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-top: 1px solid var(--line); font-size: 0.9rem;
}
.queue img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; flex: none; }
.queue .qname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue progress { width: 80px; }
.qdone { color: var(--ok-text); font-weight: 700; }
.qfail { color: var(--err); font-weight: 700; }
/* gallery */
.masonry { columns: 3 220px; column-gap: 10px; margin-top: 16px; }
.masonry figure { margin: 0 0 10px; break-inside: avoid; position: relative; }
.masonry img {
  width: 100%; display: block; border-radius: var(--radius-s); cursor: pointer;
  background: var(--surface2); min-height: 60px;
}
.masonry figcaption {
  position: absolute; left: 8px; bottom: 8px; font-size: 0.7rem; color: #fff;
  background: rgb(0 0 0 / 0.45); padding: 2px 8px; border-radius: 999px;
}
.empty { text-align: center; padding: 48px 0; color: var(--muted); }
.lightbox[hidden] { display: none; }
.lightbox {
  position: fixed; inset: 0; background: rgb(0 0 0 / 0.92); z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px;
}
.lightbox img { max-width: 100%; max-height: 78vh; border-radius: var(--radius-s); }
.lb-close {
  position: absolute; top: 14px; right: 14px; background: rgb(255 255 255 / 0.15);
  color: #fff; border: 0; font-size: 1.2rem; width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
}
.lb-bar { display: flex; align-items: center; gap: 16px; color: #ddd; font-size: 0.9rem; }
/* components: toast / spinner / badge */
.toast-wrap { position: fixed; left: 0; right: 0; bottom: 24px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 90; pointer-events: none; }
.toast {
  background: var(--text); color: var(--bg); padding: 12px 22px; border-radius: 999px;
  font-weight: 600; font-size: 0.9rem; box-shadow: 0 6px 24px rgb(0 0 0 / 0.25);
  animation: toast-in 0.25s ease-out;
}
.toast.ok { background: var(--ok-text); color: var(--ok-bg); }
.toast.err { background: var(--err); color: #fff; }
@keyframes toast-in { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.spinner {
  display: inline-block; width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--primary-soft); border-top-color: var(--primary);
  animation: spin 0.8s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.badge {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: 999px; background: var(--primary); color: var(--on-primary);
  font-size: 0.75rem; font-weight: 800; margin-left: 8px; vertical-align: middle;
}
progress { accent-color: var(--primary); height: 8px; border-radius: 4px; }
