:root {
  --bg: #fbfaf7;
  --fg: #171714;
  --muted: #6b6a62;
  --card: #ffffff;
  --border: #e3e0d8;
  --border-strong: #c9c5ba;
  --accent: #1f7a55;
  --accent-soft: #e6f2ec;
  --accent-ink: #ffffff;
  --danger: #a3261d;
  --shadow: 0 18px 40px rgba(23, 23, 20, 0.08);
  --radius: 16px;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

[data-theme="dark"] {
  --bg: #121310;
  --fg: #f2f0e9;
  --muted: #a3a096;
  --card: #1b1c18;
  --border: #2f312a;
  --border-strong: #464941;
  --accent-soft: #1e2f27;
  --danger: #ff8f85;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121310;
    --fg: #f2f0e9;
    --muted: #a3a096;
    --card: #1b1c18;
    --border: #2f312a;
    --border-strong: #464941;
    --accent-soft: #1e2f27;
    --danger: #ff8f85;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

a { color: inherit; }

button, input, textarea, select { font: inherit; color: inherit; }

.theme-row {
  display: flex;
  justify-content: flex-end;
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 24px 0;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  background: var(--card);
}

.theme-option {
  display: inline-flex;
  width: 30px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border: 0;
  background: none;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
}

.theme-option svg { width: 16px; height: 16px; }

.theme-option:hover { color: var(--fg); }

.theme-option.active { background: var(--fg); color: var(--bg); }

/* Hub --------------------------------------------------------------- */

.hub {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

.hub-head { max-width: 780px; }

.eyebrow {
  margin: 0 0 12px;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 650;
}

.hub-head h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5.2vw, 3.9rem);
  line-height: 1.04;
  letter-spacing: -0.035em;
  font-weight: 680;
  text-wrap: balance;
}

.lede {
  margin: 20px 0 0;
  font-size: clamp(1.05rem, 1.6vw, 1.24rem);
  color: var(--muted);
  max-width: 62ch;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin: 44px 0 0;
}

.group-card {
  --accent: #1f7a55;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px 26px 26px;
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 180ms ease, border-color 180ms ease;
}

.group-card:hover { transform: translateY(-3px); border-color: var(--border-strong); border-top-color: var(--accent); }

.group-mark {
  display: inline-flex;
  width: 46px;
  height: 46px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  color: var(--accent);
}

.group-mark svg { width: 28px; height: 28px; }

.group-copy { display: flex; flex-direction: column; gap: 8px; }

.group-name {
  font-size: 1.55rem;
  font-weight: 660;
  letter-spacing: -0.02em;
}

.group-tagline { font-weight: 560; }

.group-blurb { color: var(--muted); font-size: 0.98rem; }

.group-action {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 6px;
}

.group-minutes {
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.group-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
}

.group-card:hover .group-button { filter: brightness(1.06); }

.hub-foot {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 68ch;
}

/* Questionnaire shell ------------------------------------------------ */

.tf-body { display: flex; flex-direction: column; min-height: 100dvh; }

.tf-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 12px;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
}

.tf-brand {
  font-weight: 660;
  letter-spacing: -0.01em;
  text-decoration: none;
  font-size: 0.95rem;
}

.tf-progress {
  height: 3px;
  background: var(--border);
  width: 100%;
  position: sticky;
  top: 0;
  z-index: 5;
}

#tf-progress-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 260ms ease;
}

.tf-stage {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(28px, 7vh, 84px) 24px 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.q-screen { animation: rise 220ms ease-out both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .q-screen { animation: none; }
  #tf-progress-fill { transition: none; }
  .group-card { transition: none; }
}

.q-count {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.86rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.q-prompt {
  margin: 0;
  font-size: clamp(1.65rem, 4vw, 2.5rem);
  line-height: 1.14;
  letter-spacing: -0.028em;
  font-weight: 640;
  text-wrap: balance;
}

.q-prompt:focus { outline: none; }

.q-help {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1rem;
  max-width: 58ch;
}

.q-body { margin: 32px 0 0; }

.tf-input {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 2px solid var(--border-strong);
  border-radius: 0;
  padding: 10px 2px;
  font-size: clamp(1.15rem, 2.4vw, 1.45rem);
  outline: none;
  transition: border-color 160ms ease;
}

.tf-input:focus { border-bottom-color: var(--accent); }

.tf-input::placeholder { color: var(--muted); opacity: 0.65; }

.tf-textarea {
  width: 100%;
  min-height: 170px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  font-size: 1.08rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}

.tf-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.char-count { margin-top: 8px; color: var(--muted); font-size: 0.8rem; text-align: right; }

.choice-list { display: grid; gap: 10px; }

.choice {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 16px;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.choice:hover { border-color: var(--border-strong); transform: translateY(-1px); }

.choice.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice-key {
  flex: 0 0 auto;
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 0.8rem;
  font-weight: 620;
  color: var(--muted);
}

.choice.selected .choice-key {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.choice-label { font-size: 1.02rem; }

.choice.selected .choice-label { font-weight: 560; }

.scale-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }

.scale-choice {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 0;
  font-size: 1.2rem;
  font-weight: 620;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

.scale-choice:hover { border-color: var(--border-strong); }

.scale-choice.selected { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.scale-labels {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

.tf-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 36px;
}

.tf-forward {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
}

.tf-actions.start-only { justify-content: flex-start; }

.tf-back {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 0;
  font-size: 0.95rem;
}

.tf-back:hover { color: var(--fg); }

.tf-next {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 999px;
  padding: 13px 22px;
  font-size: 1rem;
  font-weight: 620;
  cursor: pointer;
  text-decoration: none;
  transition: filter 140ms ease, transform 140ms ease;
}

.tf-next:hover { filter: brightness(1.07); transform: translateY(-1px); }

.tf-next:disabled { opacity: 0.55; cursor: progress; transform: none; }

.tf-hint { color: var(--muted); font-size: 0.82rem; line-height: 1.2; }

.choice:focus-visible,
.scale-choice:focus-visible,
.tf-next:focus-visible,
.tf-back:focus-visible,
.theme-option:focus-visible,
.review-edit:focus-visible,
.admin-tabs a:focus-visible,
.admin-status a:focus-visible,
.status-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.form-error { color: var(--danger); margin: 14px 0 0; font-size: 0.95rem; }

.banner {
  margin: 0 0 24px;
  padding: 12px 16px;
  border: 1px solid var(--danger);
  border-radius: 10px;
  color: var(--danger);
  font-size: 0.94rem;
}

/* Intro and review --------------------------------------------------- */

.intro-mark {
  display: inline-flex;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  margin-bottom: 22px;
}

.intro-mark svg { width: 32px; height: 32px; }

.intro-title {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.1rem);
  line-height: 1.06;
  letter-spacing: -0.03em;
  font-weight: 660;
  text-wrap: balance;
}

.intro-copy { margin: 20px 0 0; color: var(--muted); font-size: 1.06rem; max-width: 60ch; }

.intro-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 26px 0 0;
}

.meta-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 13px;
  color: var(--muted);
  font-size: 0.85rem;
}

.review-list { display: grid; gap: 0; margin: 28px 0 0; }

.review-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}

.review-row:first-child { border-top: 1px solid var(--border); }

.review-q { color: var(--muted); font-size: 0.88rem; margin: 0 0 6px; }

.review-a { margin: 0; font-size: 1.02rem; white-space: pre-wrap; }

.review-edit {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.88rem;
  padding: 2px 0;
  align-self: start;
}

/* Thanks ------------------------------------------------------------- */

.thanks {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(48px, 12vh, 140px) 24px 80px;
}

.thanks h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.06;
  letter-spacing: -0.03em;
}

.reference { margin: 28px 0; color: var(--muted); }

.reference strong { color: var(--fg); letter-spacing: 0.04em; }

/* Local-membership gate ---------------------------------------------- */

.gate-screen {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(48px, 12vh, 120px) 24px 80px;
}

.gate-message {
  margin: 22px 0 0;
  font-size: clamp(1.12rem, 2.4vw, 1.4rem);
  line-height: 1.5;
  max-width: 54ch;
}

.gate-reconsider { margin: 18px 0 0; }

/* No-JavaScript note ------------------------------------------------- */

.noscript-note {
  max-width: 680px;
  margin: 0 auto;
  padding: 40px 24px;
}

.noscript-note h2 { margin: 0 0 10px; }

.noscript-note p { color: var(--muted); }

.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Admin -------------------------------------------------------------- */

.admin-shell { max-width: 1080px; margin: 0 auto; padding: 32px 24px 80px; }

.admin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.admin-head h1 { margin: 0; font-size: clamp(1.7rem, 3.6vw, 2.4rem); letter-spacing: -0.025em; }

.admin-actions { display: flex; align-items: center; gap: 16px; }

.admin-logout { color: var(--muted); font-size: 0.9rem; }

.meta { color: var(--muted); margin: 8px 0 0; font-size: 0.95rem; }

.admin-tabs, .admin-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 26px 0 0;
}

.admin-status { margin-top: 10px; }

.admin-tabs a, .admin-status a {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  text-decoration: none;
  font-size: 0.88rem;
  color: var(--muted);
}

.admin-tabs a.active, .admin-status a.active {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
}

.table-wrap { margin-top: 24px; overflow-x: auto; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }

.admin-table th {
  text-align: left;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.admin-table td { padding: 13px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }

.admin-table tr:hover td { background: var(--accent-soft); }

.row-open { font-size: 0.86rem; color: var(--accent); }

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
}

.pill-new { border-color: var(--accent); color: var(--accent); }
.pill-reviewed { border-color: var(--border-strong); color: var(--muted); }
.pill-contacted { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.empty { margin-top: 32px; color: var(--muted); }

.status-form { display: flex; align-items: center; gap: 10px; margin: 26px 0 0; flex-wrap: wrap; }

.status-label { color: var(--muted); font-size: 0.86rem; }

.status-button {
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 0.88rem;
}

.status-button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.qa-list { margin: 34px 0 0; display: grid; gap: 0; }

.qa { padding: 20px 0; border-bottom: 1px solid var(--border); }

.qa:first-child { border-top: 1px solid var(--border); }

.qa dt { color: var(--muted); font-size: 0.86rem; margin-bottom: 6px; }

.qa dd { margin: 0; font-size: 1.04rem; }

.muted { color: var(--muted); }

.admin-login { max-width: 520px; margin: 0 auto; padding: clamp(48px, 12vh, 120px) 24px 80px; }

.admin-login h1 { margin: 0 0 12px; font-size: clamp(1.9rem, 4vw, 2.6rem); letter-spacing: -0.03em; }

.admin-form { display: grid; gap: 10px; margin-top: 28px; }

.admin-form label { font-size: 0.9rem; color: var(--muted); }

.admin-form input {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.admin-form .tf-next { justify-self: start; margin-top: 8px; }

/* Responsive --------------------------------------------------------- */

@media (max-width: 900px) {
  .group-grid { grid-template-columns: 1fr; }
  .group-card { flex-direction: row; flex-wrap: wrap; align-items: flex-start; }
  .group-copy { flex: 1 1 260px; }
  .group-action { flex: 1 1 100%; }
}

@media (max-width: 560px) {
  .hub { padding: 24px 18px 56px; }
  .tf-stage { padding: 32px 20px 48px; }
  .tf-actions { flex-direction: column-reverse; align-items: stretch; gap: 10px; }
  .tf-forward { align-items: stretch; }
  .tf-hint { text-align: center; }
  .tf-next { justify-content: center; }
  .tf-back { align-self: flex-start; }
  .scale-row { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .scale-choice { padding: 14px 0; }
}

/* Question editor ---------------------------------------------------- */

.q-blocks { display: grid; gap: 18px; margin-top: 26px; }

.q-block {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
}

.q-block-head { display: flex; align-items: center; gap: 12px; }

.q-order {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--fg);
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 650;
}

.q-id { color: var(--muted); font-size: 0.76rem; letter-spacing: 0.04em; }

.q-block-tools { margin-left: auto; display: flex; gap: 6px; }

.q-tool {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
}

.q-tool:hover { color: var(--fg); border-color: var(--border-strong); }

.q-delete { color: var(--danger); }

.q-field { display: grid; gap: 6px; }

.q-field span {
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.q-field input,
.q-field textarea,
.q-field select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.q-field textarea { resize: vertical; }

.q-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; }

.q-field-small { flex: 1 1 140px; }

.q-check { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; padding-bottom: 10px; }

.q-scale-fields { display: none; }

.q-block[data-scale="1"] .q-scale-fields { display: flex; }

.editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 26px;
}

.reset-form { margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--border); }

.save-note { margin: 18px 0 0; color: var(--accent); font-weight: 560; }
