:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1a2233;
  --muted: #6b7488;
  --line: #e2e6ef;
  --brand: #3b5bdb;
  --brand-dark: #2f49b0;
  --ok: #2f9e44;
  --alt: #e8940c;
  --danger: #e03131;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 18px; text-decoration: none; color: var(--ink); }
nav a, nav button { margin-left: 14px; }
main { max-width: 820px; margin: 0 auto; padding: 24px 20px 64px; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px;
}
h1 { font-size: 26px; margin: 4px 0 8px; }
h2 { font-size: 20px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 0 0 6px; }
.muted { color: var(--muted); }
.desc { white-space: pre-wrap; color: var(--ink); }

label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; }
input, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 72px; resize: vertical; }
input[type="number"] { width: 90px; }

button {
  cursor: pointer; border: none; border-radius: 8px; padding: 10px 16px;
  font: inherit; font-weight: 600; background: var(--brand); color: #fff;
}
button:hover { background: var(--brand-dark); }
button.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
button.ghost:hover { background: #eef1fb; }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
button.danger:hover { background: #fdecec; }
button.small { padding: 6px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.slot {
  border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px;
}
.slot-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.pill { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.pill.open { background: #e6f4ea; color: var(--ok); }
.pill.full { background: #fdecec; color: var(--danger); }
.people { margin: 10px 0 0; padding: 0; list-style: none; }
.people li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--ok); }
.dot.alt { background: var(--alt); }
.tag { font-size: 11px; font-weight: 700; color: var(--alt); }
.err { color: var(--danger); font-size: 14px; margin: 8px 0; }
.ok-msg { color: var(--ok); font-size: 14px; margin: 8px 0; }
.live {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted);
}
.live .dot { background: var(--muted); }
.live.on .dot { background: var(--ok); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
.slot-edit { display: grid; grid-template-columns: 1fr 90px auto; gap: 8px; align-items: end; margin-bottom: 8px; }
.share { font-size: 13px; word-break: break-all; }
table { width: 100%; border-collapse: collapse; }

/* ---------- org public carousel ---------- */
.carousel {
  position: relative;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}
.carousel-head { text-align: center; margin: 8px 0 12px; }
.carousel-head h1 { margin: 0; font-size: 28px; }
.carousel-track {
  display: flex;
  overflow-x: auto;
  overflow-y: visible;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  gap: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  align-items: flex-start;
}
.carousel-track::-webkit-scrollbar { display: none; }
.slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px;
}
.slide a.slide-link { display: block; width: 100%; text-decoration: none; color: inherit; }
.slide-img {
  width: 100%;
  aspect-ratio: 4 / 5;
  max-height: 62vh;
  object-fit: cover;
  border-radius: 14px;
  background: var(--line);
  display: block;
}
.slide-noimg {
  width: 100%;
  aspect-ratio: 4 / 5;
  max-height: 62vh;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 24px; font-size: 26px; font-weight: 700;
}
.slide-cap {
  width: 100%; margin-top: 12px; text-align: center;
}
.slide-cap h2 { margin: 0 0 6px; font-size: 22px; }
.slide-cap .cta { display: inline-block; margin-top: 6px; }
.slide-badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  background: var(--alt); color: #fff; padding: 3px 10px; border-radius: 999px; margin-bottom: 8px;
}
.carousel-arrow {
  position: absolute; top: 38%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,.92); color: var(--ink);
  border: 1px solid var(--line); font-size: 22px; line-height: 1;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.12); z-index: 2;
}
.carousel-arrow.prev { left: 4px; }
.carousel-arrow.next { right: 4px; }
.carousel-arrow:hover { background: #fff; }
.carousel-dots { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }
.carousel-dots .cdot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--line); cursor: pointer; border: none; padding: 0;
}
.carousel-dots .cdot.active { background: var(--brand); }
.reorder-btns { display: inline-flex; gap: 4px; }
.reorder-btns button { padding: 4px 8px; font-size: 13px; }

/* QR card */
.qr-card { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.qr-holder { flex: none; width: 140px; height: 140px; }
.qr-holder svg { width: 100%; height: 100%; display: block; border: 1px solid var(--line); border-radius: 8px; }
.qr-meta { flex: 1; min-width: 220px; }

/* inline sign-up slots beneath a carousel slide */
.slide-slots { width: 100%; margin-top: 14px; }
.slots-hd { text-align: center; margin: 6px 0 10px; font-size: 15px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.slide-slot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px;
  background: var(--card);
}
.slide-slot-info { display: flex; flex-direction: column; min-width: 0; }
.slide-slot-desc { font-weight: 600; }
.slide-slot-count { font-size: 12px; }
.slide-slot button { flex: none; }

/* modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,28,44,.55);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100;
}
.modal {
  position: relative; background: var(--card); border-radius: 16px; padding: 22px;
  width: 100%; max-width: 400px; box-shadow: 0 12px 40px rgba(0,0,0,.25);
  max-height: 90vh; overflow-y: auto;
}
.modal-close {
  position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; padding: 0;
  border-radius: 50%; background: transparent; color: var(--muted); font-size: 16px; border: none;
}
.modal-close:hover { background: var(--line); color: var(--ink); }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  main { padding: 14px 12px 80px; }
  .topbar { padding: 10px 12px; flex-wrap: wrap; gap: 6px; }
  nav { display: flex; flex-wrap: wrap; gap: 8px; }
  nav a, nav button { margin-left: 0; }
  h1 { font-size: 22px; }
  .card { padding: 16px; }
  /* comfortable tap targets */
  button { padding: 12px 16px; min-height: 44px; }
  button.small { padding: 8px 12px; min-height: 36px; }
  input, textarea, select { font-size: 16px; padding: 12px; } /* 16px avoids iOS zoom-on-focus */
  .slot-edit { grid-template-columns: 1fr auto; }
  .slot-edit > div:nth-child(2) { grid-column: 1; }
  /* near-full-bleed carousel on phones */
  .carousel { max-width: 100%; }
  .slide { padding: 0 2px; }
  .slide-img, .slide-noimg { aspect-ratio: 3 / 4; max-height: 82vh; }
  .carousel-arrow { width: 40px; height: 40px; top: 34%; }
  /* stack the reorder column and keep rows readable */
  .row { gap: 8px; }
  .share { font-size: 12px; }
}
/* honor iOS safe-area on notched devices */
@supports (padding: max(0px)) {
  .topbar { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  main { padding-bottom: max(80px, env(safe-area-inset-bottom)); }
}
