:root {
  --ground: #F7F6F2;
  --card: #FFFFFF;
  --ink: #1C1B19;
  --muted: #5F5C55;
  --line: #E6E2DA;
  --soft: #EFECE6;
  --teal: #1F6F6B;
  --teal-dark: #174F4C;
  --teal-soft: #DCEBE9;
  --orange: #A84B16;
  --orange-soft: #FDEEE3;
  --plum: #6E4A86;
  --plum-soft: #F1EAF5;
  --red: #A33A2E;
  --yellow: #FCE9A8;
  --radius: 16px;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--ground);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); min-height: 100vh; }
a { color: var(--teal); font-weight: 700; }
a:hover { color: var(--teal-dark); }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
p { margin: 0; line-height: 1.55; }
button, input, select, textarea { font: inherit; color: inherit; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; background: #fff; padding: 8px 12px; border-radius: 8px; z-index: 10; }
:focus-visible { outline: 3px solid #2F7FD8; outline-offset: 2px; }

.loading { padding: 80px 24px; text-align: center; color: var(--muted); }

.shell { max-width: 720px; margin: 0 auto; padding: 0 16px 120px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 0 8px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--teal); display: grid; place-items: center; }
.brand-name { font-weight: 800; font-size: 17px; }
.brand-name span { color: var(--teal); }

.page-head { padding: 12px 0 16px; display: flex; flex-direction: column; gap: 6px; }
.page-head h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.sub { color: var(--muted); font-size: 14px; }
.eyebrow { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.section { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 2px rgba(28,27,25,0.06); }
.card + .card { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }

.btn { min-height: 44px; padding: 0 18px; border-radius: 22px; border: 1.5px solid var(--line); background: #fff; font-weight: 700; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: #CFCBC2; color: var(--ink); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); color: #fff; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.danger { color: var(--red); border-color: transparent; background: transparent; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.on-going { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.on-not { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.on-wait { background: var(--orange-soft); border-color: var(--orange); color: #8A3D12; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--teal); font-weight: 700; cursor: pointer; font-size: 13px; min-height: 32px; }
.linkbtn.muted { color: var(--muted); font-weight: 600; text-decoration: underline; }

.pill { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 12px; background: var(--teal-soft); color: var(--teal-dark); white-space: nowrap; }
.pill.orange { background: var(--orange-soft); color: #8A3D12; }
.pill.plum { background: var(--plum-soft); color: var(--plum); }
.pill.grey { background: var(--soft); color: var(--muted); }
.pill.red { background: #FBEBEB; color: var(--red); }
.pill.dark { background: var(--ink); color: #fff; }

.type-school { --g: var(--teal); }
.type-club { --g: var(--orange); }
.type-family { --g: var(--plum); }
.type-community { --g: #3F4FA8; }
.bar { width: 6px; align-self: stretch; border-radius: 3px; background: var(--g, var(--teal)); flex-shrink: 0; }
.dot { width: 8px; height: 8px; border-radius: 4px; background: var(--g, var(--teal)); display: inline-block; }
.gname { font-size: 12px; font-weight: 800; color: var(--g, var(--teal)); }

.event-card { display: flex; gap: 14px; align-items: stretch; text-decoration: none; color: var(--ink); }
.event-card:hover { color: var(--ink); }
.date-box { width: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; }
.date-box .dow { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; }
.date-box .day { font-size: 22px; font-weight: 800; line-height: 1.1; }
.title { font-size: 16px; font-weight: 800; }
.meta { font-size: 13px; color: var(--muted); }
.cancelled .title { text-decoration: line-through; color: var(--muted); }

.rsvp-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rsvp-row .who { flex: 1; min-width: 90px; font-weight: 700; font-size: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 12px; font-weight: 800; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 12px; background: #FBFAF8; font-size: 15px; min-height: 46px;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--teal); margin: 0; flex-shrink: 0; }
.check span { display: flex; flex-direction: column; gap: 2px; font-size: 14px; font-weight: 700; }
.check small { font-weight: 500; color: var(--muted); font-size: 12px; }
.error { background: #FBEBEB; color: var(--red); border-radius: 10px; padding: 10px 12px; font-size: 14px; font-weight: 600; }
.notice { background: var(--teal-soft); color: var(--teal-dark); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.warn { background: var(--yellow); color: #4A4535; border-radius: 12px; padding: 12px 14px; font-size: 14px; }

.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--soft); }
.list-row:first-child { border-top: 0; }
.avatar { width: 36px; height: 36px; border-radius: 18px; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; font-weight: 800; font-size: 13px; flex-shrink: 0; }

.capbar { height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.capbar div { height: 8px; background: var(--teal); border-radius: 4px; }

.q { border-top: 1px solid var(--soft); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.q:first-child { border-top: 0; padding-top: 0; }
.answer { background: #F2F7F6; border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }

.code { font-size: 28px; font-weight: 800; letter-spacing: 0.1em; }
.invite { background: var(--ink); color: #fff; }
.invite .meta { color: #CFCBC2; }

/* Calendar */
.cal { background: #fff; border-radius: var(--radius); padding: 12px 8px 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 800; color: var(--muted); padding-bottom: 6px; }
.cal-day { height: 52px; border: 0; border-radius: 12px; background: transparent; font-weight: 700; font-size: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; padding: 0; }
.cal-day.muted { color: #A8A49B; }
.cal-day.today { background: var(--teal-soft); font-weight: 800; }
.cal-day.sel { background: var(--teal); color: #fff; }
.cal-day.sel .dot { background: #fff; }
.cal-dots { display: flex; gap: 3px; height: 8px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip { flex-shrink: 0; min-height: 36px; padding: 0 14px; border-radius: 18px; font-weight: 700; font-size: 13px; background: #fff; border: 1.5px solid var(--line); cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Bottom nav */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.nav-inner { max-width: 720px; margin: 0 auto; display: flex; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 0 8px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; position: relative; min-height: 56px; }
.nav a[aria-current=page] { color: var(--teal); font-weight: 800; }
.badge { position: absolute; top: 6px; left: 50%; margin-left: 6px; background: var(--orange); color: #fff; font-size: 10px; font-weight: 800; border-radius: 8px; padding: 1px 5px; }

/* Auth / landing */
.auth { max-width: 440px; margin: 0 auto; padding: 32px 16px 64px; display: flex; flex-direction: column; gap: 18px; }
.hero h1 { font-size: 32px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.hero p { color: var(--muted); font-size: 16px; margin-top: 8px; }
.tabs { display: flex; background: var(--soft); border-radius: 12px; padding: 3px; }
.tabs button { flex: 1; min-height: 40px; border: 0; border-radius: 10px; background: transparent; font-weight: 700; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected=true] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.12); }
.points { display: grid; gap: 8px; }
.points div { display: flex; gap: 10px; font-size: 14px; color: var(--muted); }
.points b { color: var(--ink); }

details.faq { border-top: 1px solid var(--soft); }
details.faq:first-of-type { border-top: 0; }
details.faq summary { cursor: pointer; padding: 14px 0; font-weight: 700; font-size: 15px; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
details.faq summary::after { content: '+'; color: var(--muted); font-size: 18px; }
details.faq[open] summary::after { content: '−'; }
details.faq p { padding: 0 0 14px; color: #3A3833; font-size: 14px; }

#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 22px; font-weight: 700; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 20; max-width: calc(100% - 32px); text-align: center; }
#toast.show { opacity: 1; }

.footer { margin-top: 40px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.6; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; font-size: 14px; }
