:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #0f766e;
  --primary-dark: #134e4a;
  --on-primary: #ffffff;
  --danger: #b91c1c;
  --ok-bg: #dcfce7;
  --ok-text: #166534;
  --error-bg: #fee2e2;
  --error-text: #991b1b;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111a2e;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --border: #1f2a44;
    --primary: #2dd4bf;
    --primary-dark: #99f6e4;
    --on-primary: #042f2e;
    --danger: #f87171;
    --ok-bg: #052e16;
    --ok-text: #86efac;
    --error-bg: #450a0a;
    --error-text: #fca5a5;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: 0 0 0.75rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 0.4rem; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.brand-mark { background: var(--primary); color: var(--on-primary); border-radius: 8px; padding: 0.1rem 0.4rem; font-size: 0.85rem; }
.nav { display: flex; align-items: center; gap: 0.5rem; }

.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; font-size: 1.4rem; padding: 0.2rem 0.5rem; user-select: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute;
  right: 0;
  top: 2.6rem;
  min-width: 13rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.15);
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
}
.menu-panel a, .menu-panel .link { padding: 0.7rem 0.8rem; border-radius: 10px; color: var(--text); text-decoration: none; text-align: left; font: inherit; }
.menu-panel a:hover, .menu-panel .link:hover { background: var(--bg); }
.menu-panel form { margin: 0; display: flex; }
.menu-panel .link { flex: 1; }

.container { max-width: 960px; margin: 0 auto; padding: 1rem; }
.footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 2rem 1rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1rem; }
.narrow { max-width: 440px; margin: 1.5rem auto; }
.stack { display: flex; flex-direction: column; gap: 0.9rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; font-size: 0.9rem; }
input, select, textarea {
  font: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
  font-weight: 400;
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
input[type="checkbox"] { width: auto; }
input[type="file"] { padding: 0.5rem; }
.code-input { font-family: ui-monospace, Menlo, monospace; letter-spacing: 0.15em; text-transform: uppercase; font-size: 1.25rem; text-align: center; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 0.8rem; }
legend { font-weight: 600; font-size: 0.9rem; padding: 0 0.3rem; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.75rem 1.1rem;
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: var(--on-primary);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  min-height: 44px;
}
.button:hover { filter: brightness(1.08); }
.button-small { padding: 0.4rem 0.8rem; min-height: 36px; font-size: 0.9rem; }
.button-secondary { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.button-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.link { background: none; border: 0; cursor: pointer; }

.alert { padding: 0.75rem 1rem; border-radius: 10px; margin: 0 0 1rem; }
.alert-ok { background: var(--ok-bg); color: var(--ok-text); }
.alert-error { background: var(--error-bg); color: var(--error-text); }

.filters { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; margin-bottom: 1rem; }
.alert-info { background: #dbeafe; color: #1e3a8a; }
@media (prefers-color-scheme: dark) { .alert-info { background: #172554; color: #bfdbfe; } }
.danger { color: var(--danger); }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 0.85em; background: var(--bg); padding: 0.1rem 0.3rem; border-radius: 6px; overflow-wrap: anywhere; }
/* Checkbox aligned with the first line, so longer labels wrap next to it */
.check { flex-direction: row; align-items: flex-start; gap: 0.6rem; font-weight: 400; font-size: 1rem; }
.check input { flex: none; width: 1.2rem; height: 1.2rem; margin: 0.15rem 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.child { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.6rem 0; }
.child + .child { border-top: 1px solid var(--border); }
fieldset { display: flex; flex-direction: column; gap: 0.7rem; margin: 0; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.6rem 0; border-top: 1px solid var(--border); }
.list li > div { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }

.row3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 0.6rem; }
@media (max-width: 480px) { .row3 { grid-template-columns: 1fr 1fr; } .row3 > :first-child { grid-column: 1 / -1; } }
.child-head { display: flex; justify-content: space-between; align-items: center; }
.child-head .link { font: inherit; font-size: 0.9rem; padding: 0.3rem 0; }
.danger-zone { margin-top: 2rem; }
.badge-ok { background: #16a34a; }
.badge-warn { background: #d97706; }
.badge-off { background: #6b7280; }
.row-actions { white-space: nowrap; }
.pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
h1 { overflow-wrap: anywhere; }
.row-actions form { display: inline; margin: 0 0.6rem 0 0; }
.row-actions .link { color: var(--primary); font: inherit; padding: 0; }
.nav .button { white-space: nowrap; }
.prose { max-width: 760px; margin: 0 auto; }
.prose h2 { margin-top: 1.6rem; }
.prose h3 { font-size: 1rem; margin: 1rem 0 0.4rem; }
.prose ul { padding-left: 1.2rem; }
.prose li { margin: 0.25rem 0; }

/* Public home page */
.hero { display: flex; flex-direction: column; gap: 0.8rem; padding: 1rem 0 1.5rem; }
.hero h1 { font-size: clamp(1.6rem, 5vw, 2.3rem); line-height: 1.15; margin: 0; }
.hero .lead { font-size: 1.1rem; margin: 0; max-width: 40rem; }
.hero p { margin: 0; }
.preview { padding: 0; overflow: hidden; margin: 0 0 1rem; }
.preview img { display: block; width: 100%; height: auto; }
.preview figcaption { padding: 0.8rem 1.1rem 1rem; gap: 0.5rem; }
.stats { text-align: center; margin: 0 0 1.2rem; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 1rem; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 2rem 1fr; gap: 0.1rem 0.8rem; }
.steps li::before { content: counter(step); grid-row: span 2; width: 2rem; height: 2rem; border-radius: 50%; background: var(--primary); color: var(--on-primary); font-weight: 700; display: flex; align-items: center; justify-content: center; }
.steps span { color: var(--muted); }
.checks { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.checks li { padding-left: 1.6rem; position: relative; }
.checks li::before { content: "✓"; position: absolute; left: 0; color: #16a34a; font-weight: 700; }

/* Services */
[hidden] { display: none !important; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.tag { border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600; line-height: 1.6; }
.tag-offer { background: #16a34a; color: #fff; }
.tag-request { background: #2563eb; color: #fff; }
.tag-category { background: #e0e7ff; color: #1e3a8a; }
.tag-plain { background: #f3f4f6; color: #374151; font-weight: 500; }
.services { list-style: none; margin: 0; padding: 0; }
.service-item { padding: 0.8rem 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.service-item:first-child { border-top: 0; padding-top: 0; }
.service-item.paused { opacity: 0.6; }
.service-title { font-weight: 700; font-size: 1.05rem; text-decoration: none; }
.service-title:hover { text-decoration: underline; }
.service-desc { margin: 0.3rem 0 0; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.service-item .row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.9rem; margin-top: 0.5rem; white-space: normal; }
.service-item .row-actions form { margin: 0; }
.result-meta { margin-top: 0.3rem; }
.result-meta .link { color: var(--primary); font: inherit; padding: 0; text-decoration: underline; }
.badge { color: #fff; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600; }
.checks-inline { display: flex; flex-wrap: wrap; gap: 0.5rem 1.2rem; }
.segmented { flex-direction: row; flex-wrap: wrap; gap: 0.5rem 1.5rem; }
.segmented legend { width: 100%; }


/* Bottom tab bar on every page after login */
body.has-tabs { padding-bottom: 4.5rem; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; padding: 0.5rem 0.2rem; font-size: 0.78rem; color: var(--muted); text-decoration: none; }
.tabbar a span { font-size: 1.25rem; line-height: 1; }
.tabbar a.active { color: var(--primary); font-weight: 700; }
@media (min-width: 760px) {
  body.has-tabs { padding-bottom: 0; padding-top: 0; }
  .tabbar { position: sticky; top: 57px; bottom: auto; max-width: 960px; margin: 0 auto; border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); grid-template-columns: repeat(4, auto); justify-content: start; gap: 0.5rem; padding: 0 0.5rem; }
  .tabbar a { flex-direction: row; gap: 0.4rem; font-size: 0.95rem; padding: 0.6rem 0.8rem; }
  .tabbar a span { font-size: 1rem; }
  body.has-tabs .tabbar { order: -1; }
  body.has-tabs { display: flex; flex-direction: column; }
  body.has-tabs .topbar { order: -2; }
}

.page-head { margin: 0.5rem 0 1rem; }
.page-head p { margin: 0; }
.empty { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.8rem; }
.empty p { margin: 0; }

/* Filters */
.filters-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 1rem; }
.filters-bar .segmented-links { grid-column: 1 / -1; }
.filters-bar select { padding: 0.5rem 0.7rem; }
@media (min-width: 760px) { .filters-bar { grid-template-columns: auto 12rem 14rem; justify-content: start; } .filters-bar .segmented-links { grid-column: auto; } }
.segmented-links { display: flex; gap: 0.3rem; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 0.2rem; width: fit-content; }
.segmented-links label { flex-direction: row; font-weight: 500; padding: 0.35rem 0.9rem; border-radius: 999px; cursor: pointer; font-size: 0.9rem; }
.segmented-links input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-links label.active, .segmented-links label:has(input:checked) { background: var(--primary); color: var(--on-primary); }
.segmented-links label:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Activity lists */
.day { margin-bottom: 1.2rem; }
.day-label { font-size: 0.95rem; color: var(--muted); text-transform: none; margin: 0 0 0.4rem; }
.activities { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.activities.card { padding: 0; }
.activity + .activity { border-top: 1px solid var(--border); }
.activity-link { display: grid; grid-template-columns: 3.6rem 1fr auto; gap: 0.8rem; align-items: center; padding: 0.8rem 1rem; color: var(--text); text-decoration: none; }
.activity-link:hover { background: var(--bg); }
.activity.mine .activity-link { box-shadow: inset 4px 0 0 var(--primary); }
.activity-time { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.activity-time .small { color: var(--muted); font-size: 0.75rem; }
.activity-body { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; overflow-wrap: anywhere; }
.activity-title { font-weight: 700; font-size: 1.02rem; color: var(--text); text-decoration: none; }
a.activity-title:hover { text-decoration: underline; }
.activity-count { display: flex; flex-direction: column; align-items: center; line-height: 1.1; min-width: 3rem; }
.activity-count strong { font-size: 1.3rem; color: var(--primary); }
.tag-topic { background: #ccfbf1; color: #134e4a; }
.tag-kids { background: #fef3c7; color: #92400e; }
.tag-adults { background: #ede9fe; color: #5b21b6; }
.tag-example { background: #fee2e2; color: #991b1b; }
.tag-new { background: #dcfce7; color: #166534; }
.tag-member { background: var(--primary); color: var(--on-primary); }
@media (prefers-color-scheme: dark) {
  .tag-topic { background: #134e4a; color: #ccfbf1; }
  .tag-kids { background: #451a03; color: #fde68a; }
  .tag-adults { background: #2e1065; color: #ddd6fe; }
  .tag-example { background: #450a0a; color: #fecaca; }
  .tag-new { background: #052e16; color: #bbf7d0; }
  .tag-plain { background: #1f2937; color: #e5e7eb; }
}

/* Detail page */
.rsvp-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.rsvp-buttons .button { flex: 1 1 8rem; }
.button-quiet { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.button:disabled { opacity: 0.5; cursor: not-allowed; }
.button-whatsapp { background: #25d366; color: #052e16; }
.member-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.8rem; border-radius: 10px; background: var(--bg); }
.member-box .link { color: var(--primary); font: inherit; padding: 0; text-decoration: underline; }
.people { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.people li { background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 0.2rem 0.75rem; }
.share { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.comments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.8rem; }
.comment-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem; }
.comment-head form { margin: 0 0 0 auto; }
.comment-head .link { color: var(--muted); padding: 0; }
.comments .pre { margin-top: 0.15rem; }
.page-actions { justify-content: space-between; align-items: center; margin-bottom: 1rem; }

/* Forms */
.chip-group { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip-check { flex-direction: row; font-weight: 500; font-size: 0.9rem; cursor: pointer; }
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check span { display: inline-block; padding: 0.35rem 0.8rem; border-radius: 999px; border: 1px solid var(--border); background: var(--bg); }
.chip-check input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.chip-check input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.hint { font-weight: 400; }
.more summary { cursor: pointer; font-weight: 600; color: var(--primary); padding: 0.3rem 0; }
.more[open] summary { margin-bottom: 0.8rem; }
@media (max-width: 480px) { .row { grid-template-columns: 1fr; } }

/* Ideas */
.ideas { list-style: none; margin: 0 0 1rem; padding: 0; }
.ideas.card { padding: 0 1rem; }
.idea { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; padding: 0.8rem 0; }
.idea + .idea { border-top: 1px solid var(--border); }
.idea-body { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; overflow-wrap: anywhere; }
.idea form { margin: 0; flex: none; }
.progress { display: inline-flex; gap: 3px; vertical-align: middle; }
.progress .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border); }
.progress .dot.on { background: var(--primary); }
.invite-code { font-size: 1.1rem; }
.brand { white-space: nowrap; }
@media (max-width: 400px) {
  .topbar { padding: 0.6rem 0.75rem; gap: 0.4rem; }
  .brand { font-size: 0.98rem; }
  .nav { gap: 0.2rem; }
  .nav .button-small { padding: 0.4rem 0.6rem; }
}
