:root {
  color-scheme: light;

  /* Semantic colors shared by web and native. */
  --color-primary: #0c5b6d;
  --color-primary-strong: #074b59;
  --color-primary-soft: #d8ecef;
  --color-accent: #d18b20;
  --color-accent-soft: #fff5df;
  --color-background: #ffffff;
  --color-surface: #ffffff;
  --color-border: #c9e0e5;
  --color-text-primary: #092f3a;
  --color-text-muted: #54707a;
  --color-success: #247a55;
  --color-success-soft: #e5f5ed;
  --color-warning: #9a620d;
  --color-warning-soft: #fff5df;
  --color-danger: #b9473d;
  --color-danger-soft: #fff0ee;

  /* One spacing scale. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  /* One radius scale. */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* Only two elevation levels. */
  --shadow-subtle: 0 3px 12px rgba(9, 47, 58, 0.06);
  --shadow-elevated: 0 12px 28px rgba(9, 47, 58, 0.14);
  --touch-target-min: 48px;

  /* Shared type scale. */
  --type-display-size: 32px;
  --type-page-title-size: 26px;
  --type-section-title-size: 20px;
  --type-card-title-size: 16px;
  --type-body-size: 15px;
  --type-supporting-size: 13px;
  --type-caption-size: 12px;

  /* Backward-compatible aliases while older screens are migrated. */
  --green: var(--color-primary);
  --green2: var(--color-primary-strong);
  --mint: var(--color-primary-soft);
  --gold: var(--color-accent);
  --cream: var(--color-background);
  --white: var(--color-surface);
  --line: var(--color-border);
  --ink: var(--color-text-primary);
  --muted: var(--color-text-muted);
  --shadow: var(--shadow-subtle);
}

/* Foundation applied first to the approved login and account-entry patterns. */
.login-screen {
  background: var(--color-background);
  color: var(--color-text-primary);
}
.login-panel .brand { gap: var(--space-2); }
.login-copy { margin-bottom: var(--space-6); }
.login-copy > p:last-child,
.signup-heading p,
.signup-choice small,
.login-support { color: var(--color-text-muted); }
.login-panel .input-wrap input {
  min-height: 56px;
  border-color: var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-primary);
}
.login-panel .input-wrap input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(12, 91, 109, 0.12);
}
.login-submit {
  min-height: 56px;
  border-radius: var(--radius-pill);
  background: var(--color-primary);
  box-shadow: var(--shadow-elevated);
}
.signup-choice {
  min-height: 96px;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-color: var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-subtle);
}
.signup-choice-icon {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}
.login-meta a,
.login-support a,
.choice-arrow { color: var(--color-primary); }

button,
[role="button"],
input,
select,
textarea { min-height: var(--touch-target-min); }

body,
.app-shell,
.role-screen,
.chat-body { background: var(--color-background); }
body { color: var(--color-text-primary); font-size: var(--type-body-size); line-height: 1.47; }
h1 { color: var(--color-text-primary); font: 700 var(--type-page-title-size)/1.23 'DM Sans', sans-serif; }
h2 { color: var(--color-text-primary); font: 700 var(--type-section-title-size)/1.3 'DM Sans', sans-serif; }
.card h2,
.card-title,
.section-title h2 { font-size: var(--type-card-title-size); line-height: 1.375; font-weight: 700; }
.muted,
small { color: var(--color-text-muted); font-size: var(--type-supporting-size); line-height: 1.38; }
button,
.primary,
.soft { font: 700 var(--type-body-size)/1.33 'DM Sans', sans-serif; }
input,
select,
textarea { font: 400 16px/1.375 'DM Sans', sans-serif; }
label { color: var(--color-text-primary); font-size: var(--type-supporting-size); line-height: 1.38; font-weight: 700; }

/* Account creation and public recovery flows. */
.registration-screen[data-role="super-admin"] {
  background: var(--color-background);
  padding: var(--space-5) var(--space-4) var(--space-6);
}
.registration-screen[data-role="super-admin"] .registration-wrap {
  border-color: var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-elevated);
}
.registration-screen[data-role="super-admin"] #registration-title,
.registration-section-heading h2,
.church-registration-success h2 { color: var(--color-text-primary); }
.registration-screen[data-role="super-admin"] #registration-description,
.registration-section-heading p,
.church-registration-success p { color: var(--color-text-muted); }
.registration-fields { gap: var(--space-4); }
.registration-fields input,
.registration-fields select {
  min-height: 56px;
  border-color: var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-primary);
}
.registration-fields input:focus,
.registration-fields select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(12, 91, 109, 0.12);
}
.registration-section-icon,
.church-registration-success > span {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}
.church-registration-track { background: var(--color-border); }
.church-registration-track span,
.registration-step-actions .primary { background: var(--color-primary); }
.church-review-note {
  gap: var(--space-3);
  padding: var(--space-4);
  border-color: var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-success-soft);
  color: var(--color-text-muted);
}
.registration-step-actions { gap: var(--space-3); margin-top: var(--space-5); }
.registration-step-actions .primary,
.registration-step-actions .soft { min-height: var(--touch-target-min); border-radius: var(--radius-pill); }

/* Web experience aligned with the mobile information architecture. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.login-screen {
  background: var(--color-background);
}
.login-panel h1 { font-size: var(--type-display-size); line-height: 1.18; }
.login-copy .eyebrow { color: var(--color-accent); }
.login-recovery-link,
.church-account-link {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--color-primary);
  font: 700 var(--type-caption-size)/1.35 'DM Sans', sans-serif;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.church-account-link { justify-self: center; }
.signup-choice { grid-template-columns: 52px 1fr 40px; }
.signup-choice .choice-arrow {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-surface);
  font-size: 18px;
}
.home-quick-access {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
  margin: 0 0 var(--space-5);
}
.home-quick-access button {
  display: grid;
  grid-template-columns: 44px 1fr;
  grid-template-rows: auto auto;
  column-gap: var(--space-3);
  align-items: center;
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text-primary);
  text-align: left;
  box-shadow: var(--shadow-subtle);
  cursor: pointer;
}
.home-quick-access button:hover { border-color: var(--color-primary); transform: translateY(-1px); }
.home-quick-access button > span { grid-row: 1 / 3; display: grid; width: 44px; height: 44px; place-items: center; border-radius: var(--radius-md); background: var(--color-primary-soft); color: var(--color-primary); font-size: 20px; }
.home-quick-access strong { align-self: end; font-size: var(--type-card-title-size); }
.home-quick-access small { align-self: start; font-size: var(--type-caption-size); }
.recovery-modal {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background: rgba(6,59,74,.50);
}
.recovery-card {
  position: relative;
  width: min(500px, 100%);
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-elevated);
}
.recovery-card > .close-recovery { position: absolute; top: var(--space-3); right: var(--space-3); width: 44px; border: 0; background: transparent; color: var(--color-text-muted); font-size: 25px; cursor: pointer; }
.recovery-card h2 { font-size: var(--type-page-title-size); margin-bottom: var(--space-2); }
.recovery-options { display: grid; gap: var(--space-3); margin-top: var(--space-5); }
.recovery-options > button { display: grid; grid-template-columns: 42px 1fr 20px; align-items: center; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); color: var(--color-text-primary); text-align: left; cursor: pointer; }
.recovery-options > button:hover { border-color: var(--color-primary); background: var(--color-primary-soft); }
.recovery-options > button > span:first-child { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 50%; background: var(--color-primary-soft); color: var(--color-primary); font-size: 20px; }
.recovery-options strong,.recovery-options small { display: block; }
.recovery-form { display: grid; gap: var(--space-4); margin-top: var(--space-5); }
.recovery-back { justify-self: start; border: 0; background: transparent; color: var(--color-primary); font-weight: 700; cursor: pointer; }
.recovery-form label { display: grid; gap: var(--space-2); }
.recovery-form input { width: 100%; padding: 0 var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.recovery-success { text-align: center; padding-top: var(--space-5); }
.recovery-success > span { display: grid; width: 58px; height: 58px; margin: 0 auto var(--space-4); place-items: center; border-radius: 50%; background: var(--color-success-soft); color: var(--color-success); font-size: 25px; font-weight: 700; }
.recovery-success p { color: var(--color-text-muted); }
@media (max-width: 760px) {
  .home-quick-access { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0 var(--space-4); }
  .recovery-modal { align-items: end; padding: 0; }
  .recovery-card { border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: var(--space-5) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom)); }
}

/* My Church mirrors the mobile workspace hierarchy and tab flow. */
.church-workspace-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: var(--space-5); }
.church-workspace-heading h1 { margin-bottom: var(--space-1); }
.church-hero h2 { margin: 0; font: 700 clamp(22px, 3vw, 32px)/1.15 'Playfair Display', serif; color: #fff; }
.church-workspace-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); margin: calc(-1 * var(--space-3)) 0 var(--space-5); }
.church-workspace-stats > div { min-height: 94px; padding: var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); box-shadow: var(--shadow-subtle); }
.church-workspace-stats b,.church-workspace-stats span { display: block; }
.church-workspace-stats b { color: var(--color-primary); font: 700 28px/1 'Playfair Display', serif; }
.church-workspace-stats span { margin-top: var(--space-2); color: var(--color-text-muted); font-size: var(--type-caption-size); font-weight: 700; }
.church-tabs { scrollbar-width: none; }
.church-tabs::-webkit-scrollbar { display: none; }
.church-tabs button { min-height: 48px; white-space: nowrap; }
.church-admin-group-list { display: grid; gap: var(--space-2); margin-top: var(--space-4); }
.church-admin-group { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); }
.church-admin-group strong,.church-admin-group small { display: block; }
.church-admin-group small { margin-top: var(--space-1); color: var(--color-text-muted); }
.church-workflow-row { grid-template-columns: minmax(220px, 1fr) auto auto auto; }
.empty-workflow { padding: var(--space-5); text-align: center; }

@media (max-width: 760px) {
  .church-workspace-heading { padding: 0 var(--space-4); margin-bottom: var(--space-3); }
  .church-workspace-heading .muted { display: none; }
  .church-workspace-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); margin: var(--space-2) var(--space-3); }
  .church-workspace-stats > div { min-height: 82px; padding: var(--space-3); }
  .church-workspace-stats b { font-size: 24px; }
  .church-tabs { gap: var(--space-4); padding: 0 var(--space-4); overflow-x: auto; }
  .church-panel.member-management { margin-top: var(--space-2); }
  .church-admin-group { grid-template-columns: 38px minmax(0, 1fr); }
  .church-admin-group .soft { grid-column: 1 / -1; min-height: 42px; }
  .church-workflow-row { grid-template-columns: 1fr auto; }
}

/* Platform Owner church member drill-down. */
.platform-church-account-row { cursor: pointer; transition: border-color .16s ease, box-shadow .16s ease; }
.platform-church-account-row:hover,
.platform-church-account-row:focus-visible { border-color: var(--color-primary); box-shadow: var(--shadow-elevated); outline: none; }
.platform-view-members { margin-top: var(--space-2) !important; color: var(--color-primary) !important; font-weight: 700; }
.platform-church-members-card { width: min(680px, 100%); max-height: min(760px, 88dvh); overflow: auto; }
.platform-church-member-search { width: 100%; margin: var(--space-4) 0 var(--space-3); }
.platform-church-member-search input { width: 100%; }
.platform-church-member-summary { margin-bottom: var(--space-2); color: var(--color-text-muted); font-size: var(--type-supporting-size); font-weight: 700; }
.platform-church-member-row { padding: var(--space-3) 0; border-top: 1px solid var(--color-border); }
.platform-church-member-row strong,
.platform-church-member-row small { display: block; }
.platform-church-member-row small { margin-top: var(--space-1); color: var(--color-text-muted); }

@media (max-width: 600px) {
  .platform-church-members-modal { align-items: end; padding: 0; }
  .platform-church-members-card { max-height: 90dvh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom)); }
}
