/*
 * Church CRM design system (shared with church.ug).
 * Deep slate background, warm cream text, a single
 * muted gold accent, DM Serif Display for display headings and Fira Sans for everything else.
 * Reskin by changing the custom properties in :root only. The responsive block is last on purpose.
 */

@font-face { font-family: "DM Serif Display"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/dmserif-regular.woff2") format("woff2"); }
@font-face { font-family: "DM Serif Display"; font-style: italic; font-weight: 400; font-display: swap; src: url("../fonts/dmserif-italic.woff2") format("woff2"); }
@font-face { font-family: "Fira Sans"; font-style: normal; font-weight: 300; font-display: swap; src: url("../fonts/firasans-300.woff2") format("woff2"); }
@font-face { font-family: "Fira Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/firasans-400.woff2") format("woff2"); }
@font-face { font-family: "Fira Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/firasans-500.woff2") format("woff2"); }
@font-face { font-family: "Fira Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/firasans-600.woff2") format("woff2"); }

:root {
    /* Colour - hex fallbacks first; oklch values (from the reference) override where supported. */
    --bg: #15181c;
    --surface: #1b1f24;
    --card: #1e2228;
    --muted: #23272e;
    --accent: #262d37;
    --sidebar: #111418;
    --fg: #ece6da;
    --muted-fg: #aaa397;
    --gold: #c9a45f;
    --gold-strong: #d8b46e;
    --slate-ink: #3f4a5a;
    --on-gold: #15181c;
    --border: rgba(236, 230, 218, .10);
    --border-strong: rgba(236, 230, 218, .18);
    --input: rgba(236, 230, 218, .14);
    --ring: rgba(201, 164, 95, .6);
    --link: #d8b46e;
    --success: #7fb88a;
    --success-bg: rgba(127, 184, 138, .12);
    --warning: #e0b65a;
    --warning-bg: rgba(224, 182, 90, .12);
    --danger: #e07a6a;
    --danger-bg: rgba(224, 122, 106, .12);
    --info: #8fb2d9;
    --info-bg: rgba(143, 178, 217, .12);
    --veil: linear-gradient(90deg, var(--bg) 30%, rgba(21, 24, 28, .6) 60%, transparent);
    --shadow-glow: 0 0 40px -10px rgba(201, 164, 95, .45);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);

    /* Typography */
    --font-display: "DM Serif Display", Georgia, "Times New Roman", serif;
    --font-heading: "DM Serif Display", Georgia, "Times New Roman", serif;
    --font-body: "Fira Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-ui: "Fira Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-label: "Fira Sans", system-ui, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    --text-xs: .75rem;
    --text-sm: .875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    --text-5xl: 3rem;
    --text-7xl: 4.5rem;
    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;
    --leading-reading: 1.75;
    --tracking-tight: -.01em;
    --tracking-eyebrow: .22em;

    /* Space & shape */
    --space-1: .25rem;
    --space-2: .5rem;
    --space-3: .75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;
    --space-24: 6rem;
    --container: 72rem;
    --container-narrow: 48rem;
    --measure: 68ch;
    --gutter: 1.5rem;
    --radius: .5rem;
    --radius-sm: .375rem;
    --header-h: 4.25rem;
    --sidebar-w: 16rem;
    --ease: cubic-bezier(.4, 0, .2, 1);
    --duration: .15s;
}

@supports (color: oklch(0% 0 0)) {
    :root {
        --bg: oklch(20% .009 255);
        --surface: oklch(23.5% .012 255);
        --card: oklch(24.5% .013 255);
        --muted: oklch(27% .014 255);
        --accent: oklch(30% .025 250);
        --sidebar: oklch(17.5% .009 255);
        --fg: oklch(92% .014 85);
        --muted-fg: oklch(72% .018 80);
        --gold: oklch(73% .1 80);
        --gold-strong: oklch(78% .1 80);
        --slate-ink: oklch(40% .035 250);
        --on-gold: oklch(20% .009 255);
        --border: oklch(92% .014 85 / .1);
        --border-strong: oklch(92% .014 85 / .18);
        --input: oklch(92% .014 85 / .14);
        --ring: oklch(73% .1 80 / .6);
        --link: oklch(78% .1 80);
        --veil: linear-gradient(90deg, var(--bg) 30%, color-mix(in oklab, var(--bg) 60%, transparent) 60%, transparent);
        --shadow-glow: 0 0 40px -10px color-mix(in oklab, var(--gold) 45%, transparent);
    }
}

/* Light reading theme (account setting). Contrast checked against WCAG AA. */
:root[data-theme="light"] {
    --bg: #f6f2ea;
    --surface: #efe9de;
    --card: #fbf8f2;
    --muted: #e7e0d3;
    --accent: #e3dccd;
    --sidebar: #ece5d8;
    --fg: #1f2328;
    --muted-fg: #565049;
    --gold: #8a6420;
    --gold-strong: #74531a;
    --slate-ink: #c8cfd8;
    --on-gold: #ffffff;
    --border: rgba(31, 35, 40, .12);
    --border-strong: rgba(31, 35, 40, .22);
    --input: rgba(31, 35, 40, .2);
    --ring: rgba(138, 100, 32, .55);
    --link: #74531a;
    --success: #2f6b3c;
    --success-bg: rgba(47, 107, 60, .1);
    --warning: #7a5410;
    --warning-bg: rgba(160, 110, 20, .12);
    --danger: #a2362a;
    --danger-bg: rgba(162, 54, 42, .1);
    --info: #2d5a8a;
    --info-bg: rgba(45, 90, 138, .1);
    --veil: linear-gradient(90deg, var(--bg) 30%, rgba(246, 242, 234, .7) 60%, transparent);
    --shadow-glow: 0 0 30px -12px rgba(138, 100, 32, .5);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
h1, h2, h3 { font-family: var(--font-heading); font-weight: 400; letter-spacing: var(--tracking-tight); line-height: var(--leading-tight); }
h4, h5, h6 { font-family: var(--font-ui); font-weight: 600; line-height: var(--leading-tight); }
h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-base); }
p + p { margin-top: var(--space-4); }
a { color: var(--link); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { color: var(--gold-strong); }
strong, b { font-weight: 600; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-8) 0; }
ul, ol { padding-left: 1.25rem; }
table { border-collapse: collapse; width: 100%; }
code, pre { font-family: var(--font-mono); font-size: .9em; }
::selection { background: color-mix(in oklab, var(--gold) 40%, transparent); color: var(--fg); }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 2px; }

.icon { width: 1rem; height: 1rem; flex-shrink: 0; }
.icon-lg { width: 1.5rem; height: 1.5rem; }

.skip-link { position: absolute; left: var(--space-4); top: -100px; z-index: 1000; background: var(--gold); color: var(--on-gold); padding: var(--space-2) var(--space-4); border-radius: var(--radius); font-weight: 500; }
.skip-link:focus { top: var(--space-4); color: var(--on-gold); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); }
.container-narrow { max-width: var(--container-narrow); }
.section { padding: var(--space-20) 0; }
.section-tight { padding: var(--space-12) 0; }
.section + .section { border-top: 1px solid var(--border); }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-6); margin-bottom: var(--space-10); }
.section-head h2 { margin-top: var(--space-3); }
.section-head p { color: var(--muted-fg); max-width: 36rem; margin-top: var(--space-3); }
.page-head { padding: var(--space-16) 0 var(--space-10); border-bottom: 1px solid var(--border); }
.page-head h1 { font-size: var(--text-5xl); margin-top: var(--space-3); max-width: 48rem; }
.page-head .lead { margin-top: var(--space-5); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-8); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-8); }
.layout-aside { display: grid; grid-template-columns: minmax(0, 1fr) 18rem; gap: var(--space-12); align-items: start; }
.layout-filter { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: var(--space-10); align-items: start; }
.stack > * + * { margin-top: var(--space-4); }
.stack-lg > * + * { margin-top: var(--space-8); }
.row { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: var(--space-4); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.mt-2 { margin-top: var(--space-2); } .mt-4 { margin-top: var(--space-4); } .mt-6 { margin-top: var(--space-6); } .mt-8 { margin-top: var(--space-8); } .mt-12 { margin-top: var(--space-12); }

/* ---------- Type helpers ---------- */
.eyebrow { font-family: var(--font-label); letter-spacing: var(--tracking-eyebrow); text-transform: uppercase; color: var(--gold); font-size: .7rem; font-weight: 500; }
.lead { font-size: var(--text-lg); color: var(--muted-fg); line-height: var(--leading-relaxed); max-width: 40rem; }
.muted { color: var(--muted-fg); }
mark { background: color-mix(in oklab, var(--gold) 28%, transparent); color: inherit; padding: 0 .1em; border-radius: 2px; }
.small { font-size: var(--text-sm); }
.text-gold { color: var(--gold); }
.display { font-family: var(--font-display); }
.meta { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); font-size: var(--text-sm); color: var(--muted-fg); }
.meta > * { display: inline-flex; align-items: center; gap: var(--space-1); }
.meta-sep::before { content: "·"; margin-right: var(--space-4); color: var(--border-strong); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    height: 2.5rem; padding: 0 var(--space-6);
    border-radius: var(--radius); border: 1px solid transparent;
    background: var(--gold); color: var(--on-gold);
    font: 500 var(--text-sm)/1 var(--font-ui); text-decoration: none; white-space: nowrap; cursor: pointer;
    transition: background-color var(--duration) var(--ease), color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.btn:hover { background: var(--gold-strong); color: var(--on-gold); }
.btn-glow { box-shadow: var(--shadow-glow); }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--accent); color: var(--fg); }
.btn-quiet { background: transparent; color: var(--fg); padding: 0 var(--space-3); }
.btn-quiet:hover { background: var(--accent); color: var(--fg); }
.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in oklab, var(--danger) 45%, transparent); }
.btn-danger:hover { background: var(--danger-bg); color: var(--danger); }
.btn-sm { height: 2rem; padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn-lg { height: 2.75rem; padding: 0 var(--space-8); }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.link-arrow { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); font-weight: 500; text-decoration: none; }
.link-arrow .icon { transition: transform var(--duration) var(--ease); }
.link-arrow:hover .icon { transform: translateX(3px); }
.inline-form { display: inline; }

/* ---------- Site header ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in oklab, var(--bg) 88%, transparent); backdrop-filter: saturate(140%) blur(8px); border-bottom: 1px solid var(--border); }
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: var(--space-6); height: var(--header-h); }
.brand { font-family: var(--font-display); font-size: var(--text-2xl); color: var(--fg); text-decoration: none; line-height: 1; white-space: nowrap; }
.brand:hover { color: var(--fg); }
.brand span { color: var(--gold); }
.primary-nav { display: flex; align-items: center; gap: var(--space-1); }
.primary-nav a { color: var(--fg); text-decoration: none; font-size: var(--text-sm); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); }
.primary-nav a:hover { background: var(--accent); color: var(--fg); }
.primary-nav a[aria-current="page"] { color: var(--gold); }
.header-actions { display: flex; align-items: center; gap: var(--space-2); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; position: relative; width: 2.25rem; height: 2.25rem; border-radius: var(--radius); color: var(--fg); background: transparent; border: 0; cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--accent); color: var(--fg); }
.icon-btn .count { position: absolute; top: 2px; right: 1px; min-width: 1.05rem; height: 1.05rem; padding: 0 .25rem; border-radius: 999px; background: var(--gold); color: var(--on-gold); font-size: .65rem; font-weight: 600; line-height: 1.05rem; text-align: center; }
.nav-toggle { display: none; }
.has-menu { position: relative; }
.menu-panel { position: absolute; right: 0; top: calc(100% + var(--space-2)); min-width: 13rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-2); box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .55); display: none; z-index: 60; }
.menu-panel.open { display: block; }
.menu-panel a, .menu-panel button { display: flex; align-items: center; gap: var(--space-2); width: 100%; padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); color: var(--fg); text-decoration: none; font: 400 var(--text-sm) var(--font-ui); background: none; border: 0; cursor: pointer; text-align: left; }
.menu-panel a:hover, .menu-panel button:hover { background: var(--accent); color: var(--fg); }
.menu-panel .menu-label { padding: var(--space-2) var(--space-3); font-size: var(--text-xs); color: var(--muted-fg); border-bottom: 1px solid var(--border); margin-bottom: var(--space-1); }
.nav-search { display: flex; align-items: center; }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; min-height: calc(92vh - var(--header-h)); display: flex; }
.hero-media { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: right center; }
.hero-veil { position: absolute; inset: 0; background-image: var(--veil); }
.hero-plain { background:
    radial-gradient(ellipse 60% 70% at 85% 30%, color-mix(in oklab, var(--slate-ink) 55%, transparent), transparent 70%),
    radial-gradient(ellipse 40% 40% at 70% 80%, color-mix(in oklab, var(--gold) 9%, transparent), transparent 70%); }
.hero-plain::after { content: ""; position: absolute; inset: 0; background-image: repeating-linear-gradient(0deg, transparent 0 2.4rem, color-mix(in oklab, var(--fg) 4%, transparent) 2.4rem calc(2.4rem + 1px)); mask-image: linear-gradient(90deg, transparent 40%, #000 80%); -webkit-mask-image: linear-gradient(90deg, transparent 40%, #000 80%); pointer-events: none; }
.hero-inner { position: relative; z-index: 2; display: flex; flex-direction: column; justify-content: space-between; width: 100%; padding-top: var(--space-16); padding-bottom: var(--space-10); }
.hero-copy { max-width: 36rem; padding: var(--space-12) 0; }
.hero h1 { font-size: var(--text-5xl); line-height: var(--leading-tight); margin-top: var(--space-4); }
.hero .lead { margin-top: var(--space-6); }
.hero-actions { margin-top: var(--space-8); display: flex; gap: var(--space-3); flex-wrap: wrap; }
.journey { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-6); list-style: none; padding: 0; font-size: var(--text-sm); color: var(--muted-fg); }
.journey li span { color: var(--gold); margin-right: .35em; font-variant-numeric: tabular-nums; }

/* ---------- Editorial lists (preferred over card grids) ---------- */
.entry-list { list-style: none; padding: 0; border-top: 1px solid var(--border); }
.entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2) var(--space-8); padding: var(--space-8) 0; border-bottom: 1px solid var(--border); }
.entry-title { font-family: var(--font-heading); font-size: var(--text-2xl); line-height: var(--leading-tight); }
.entry-title a { color: var(--fg); text-decoration: none; }
.entry-title a:hover { color: var(--gold); }
.entry-summary { color: var(--muted-fg); margin-top: var(--space-2); max-width: 44rem; line-height: var(--leading-relaxed); }
.entry .meta { margin-top: var(--space-3); }
.entry-aside { text-align: right; font-size: var(--text-sm); color: var(--muted-fg); white-space: nowrap; }
.entry-compact { padding: var(--space-5) 0; }
.entry-compact .entry-title { font-size: var(--text-xl); }

.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-6); }
.panel-tight { padding: var(--space-4); }
.panel h2, .panel h3 { margin-bottom: var(--space-3); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }
.panel-head h2, .panel-head h3 { margin: 0; }
.tile { display: block; padding: var(--space-6); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--fg); transition: border-color var(--duration) var(--ease), background-color var(--duration) var(--ease); }
a.tile:hover { border-color: var(--border-strong); background: var(--card); color: var(--fg); }
.tile h3 { font-size: var(--text-xl); }
.tile p { color: var(--muted-fg); font-size: var(--text-sm); margin-top: var(--space-2); line-height: var(--leading-relaxed); }
.tile .meta { margin-top: var(--space-4); }

.subject-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--space-12); border-top: 1px solid var(--border); }
.subject-list li { border-bottom: 1px solid var(--border); }
.subject-list a { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); padding: var(--space-5) 0; color: var(--fg); text-decoration: none; }
.subject-list a:hover { color: var(--gold); }
.subject-list .name { font-family: var(--font-heading); font-size: var(--text-xl); }
.subject-list .count { font-size: var(--text-sm); color: var(--muted-fg); }
.numbered { list-style: none; padding: 0; counter-reset: step; }
.numbered > li { counter-increment: step; position: relative; padding: var(--space-5) 0 var(--space-5) 3.5rem; border-bottom: 1px solid var(--border); }
.numbered > li::before { content: counter(step, decimal-leading-zero); position: absolute; left: 0; top: var(--space-5); color: var(--gold); font-variant-numeric: tabular-nums; font-size: var(--text-sm); }
.numbered h3 { font-size: var(--text-xl); }
.numbered p { color: var(--muted-fg); margin-top: var(--space-1); font-size: var(--text-sm); }
.checklist { list-style: none; padding: 0; }
.checklist li { display: flex; gap: var(--space-3); padding: var(--space-2) 0; }
.checklist .icon { color: var(--gold); margin-top: .2rem; }

/* ---------- Badges / alerts ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; border-radius: var(--radius-sm); font-size: var(--text-xs); font-weight: 500; line-height: 1.4; border: 1px solid var(--border-strong); color: var(--fg); background: var(--muted); white-space: nowrap; }
.badge-success { color: var(--success); background: var(--success-bg); border-color: color-mix(in oklab, var(--success) 35%, transparent); }
.badge-info { color: var(--info); background: var(--info-bg); border-color: color-mix(in oklab, var(--info) 35%, transparent); }
.badge-warning { color: var(--warning); background: var(--warning-bg); border-color: color-mix(in oklab, var(--warning) 35%, transparent); }
.badge-danger { color: var(--danger); background: var(--danger-bg); border-color: color-mix(in oklab, var(--danger) 35%, transparent); }
.badge-gold { color: var(--gold); background: transparent; border-color: color-mix(in oklab, var(--gold) 45%, transparent); }
.tag { display: inline-block; font-size: var(--text-xs); color: var(--muted-fg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .1rem .5rem; text-decoration: none; }
a.tag:hover { color: var(--fg); border-color: var(--border-strong); }
.alert { padding: var(--space-4) var(--space-5); border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--muted); font-size: var(--text-sm); line-height: var(--leading-relaxed); margin-bottom: var(--space-6); }
.alert-success { border-color: color-mix(in oklab, var(--success) 40%, transparent); background: var(--success-bg); }
.alert-error { border-color: color-mix(in oklab, var(--danger) 45%, transparent); background: var(--danger-bg); }
.alert-warning { border-color: color-mix(in oklab, var(--warning) 40%, transparent); background: var(--warning-bg); }
.alert-info { border-color: color-mix(in oklab, var(--info) 40%, transparent); background: var(--info-bg); }
.alert strong { font-weight: 600; }
.flash-wrap { padding-top: var(--space-6); }

/* ---------- Forms ---------- */
.form { max-width: 36rem; }
.form-wide { max-width: none; }
.field { margin-bottom: var(--space-5); }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.field-row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
label, .label { display: block; font-size: var(--text-sm); font-weight: 500; margin-bottom: var(--space-2); }
.label-optional { font-weight: 400; color: var(--muted-fg); }
.hint { font-size: var(--text-xs); color: var(--muted-fg); margin-top: var(--space-1); line-height: var(--leading-normal); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="url"], input[type="number"], input[type="date"], input[type="datetime-local"], input[type="tel"], select, textarea {
    width: 100%; min-height: 2.5rem; padding: .55rem .75rem;
    font: 400 var(--text-base)/1.4 var(--font-ui); color: var(--fg);
    background: var(--surface); border: 1px solid var(--input); border-radius: var(--radius);
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
textarea { min-height: 8rem; resize: vertical; line-height: var(--leading-relaxed); }
textarea.code { font-family: var(--font-mono); font-size: var(--text-sm); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted-fg) 50%), linear-gradient(135deg, var(--muted-fg) 50%, transparent 50%); background-position: calc(100% - 1.1rem) 52%, calc(100% - .8rem) 52%; background-size: .3rem .3rem; background-repeat: no-repeat; padding-right: 2rem; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--ring); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
input[type="checkbox"], input[type="radio"] { width: 1.05rem; height: 1.05rem; accent-color: var(--gold); flex-shrink: 0; margin-top: .15rem; }
input[type="file"] { font: inherit; font-size: var(--text-sm); color: var(--muted-fg); }
input[type="file"]::file-selector-button { font: 500 var(--text-sm) var(--font-ui); background: var(--accent); color: var(--fg); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: .4rem .8rem; margin-right: .75rem; cursor: pointer; }
.check { display: flex; gap: var(--space-3); align-items: flex-start; font-weight: 400; margin-bottom: var(--space-3); cursor: pointer; }
.check-group { border: 0; }
.check-group legend { font-size: var(--text-sm); font-weight: 500; margin-bottom: var(--space-3); }
.form-error { min-height: 1.1rem; font-size: var(--text-xs); color: var(--danger); margin-top: var(--space-1); }
.form-error:empty { visibility: hidden; }
.form-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; margin-top: var(--space-6); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-5); margin-bottom: var(--space-6); }
fieldset legend { padding: 0 var(--space-2); font-size: var(--text-sm); font-weight: 600; }
.auth-wrap { min-height: calc(100vh - var(--header-h) - 10rem); display: flex; align-items: center; padding: var(--space-16) 0; }
.auth-card { width: 100%; max-width: 26rem; margin: 0 auto; }
.auth-card h1 { font-size: var(--text-4xl); margin: var(--space-3) 0 var(--space-2); }
.auth-card .lead { font-size: var(--text-base); margin-bottom: var(--space-8); }
.search-bar { display: flex; gap: var(--space-2); }
.search-bar input { flex: 1; }

/* ---------- Filters ---------- */
.filters h2 { font-family: var(--font-ui); font-size: var(--text-xs); font-weight: 500; letter-spacing: var(--tracking-eyebrow); text-transform: uppercase; color: var(--gold); margin-bottom: var(--space-4); }
.filter-group { margin-bottom: var(--space-6); }
.filter-group .label { color: var(--muted-fg); font-weight: 500; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .08em; }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { display: inline-flex; align-items: center; height: 2rem; padding: 0 var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius); color: var(--fg); text-decoration: none; font-size: var(--text-sm); background: transparent; }
.chip:hover { background: var(--accent); color: var(--fg); }
.chip[aria-current="true"] { border-color: var(--gold); color: var(--gold); }
.result-count { font-size: var(--text-sm); color: var(--muted-fg); margin-bottom: var(--space-4); }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table { font-size: var(--text-sm); }
.table th, .table td { padding: var(--space-3) var(--space-4); text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-weight: 500; color: var(--muted-fg); background: var(--surface); white-space: nowrap; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .06em; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in oklab, var(--accent) 45%, transparent); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { white-space: nowrap; text-align: right; }
.table a { text-decoration: none; }
.table a:hover { text-decoration: underline; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-2) var(--space-6); font-size: var(--text-sm); }
.dl dt { color: var(--muted-fg); }

/* ---------- Pagination / breadcrumbs / tabs ---------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: var(--space-4); margin-top: var(--space-10); }
.page-btn { display: inline-flex; align-items: center; gap: var(--space-2); height: 2.25rem; padding: 0 var(--space-4); border: 1px solid var(--border-strong); border-radius: var(--radius); color: var(--fg); text-decoration: none; font-size: var(--text-sm); }
.page-btn:hover { background: var(--accent); color: var(--fg); }
.page-btn.disabled { opacity: .4; }
.page-info { font-size: var(--text-sm); color: var(--muted-fg); }
.breadcrumbs ol { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); font-size: var(--text-sm); color: var(--muted-fg); }
.breadcrumbs li + li::before { content: "/"; margin-right: var(--space-2); color: var(--border-strong); }
.breadcrumbs a { color: var(--muted-fg); text-decoration: none; }
.breadcrumbs a:hover { color: var(--fg); }
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); margin-bottom: var(--space-8); overflow-x: auto; }
.tabs a { padding: var(--space-3) var(--space-4); color: var(--muted-fg); text-decoration: none; font-size: var(--text-sm); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--fg); }
.tabs a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--gold); }

/* ---------- Reading (articles, lessons, pages) ---------- */
.prose { max-width: var(--measure); font-size: var(--text-lg); line-height: var(--leading-reading); }
.prose > * + * { margin-top: 1.1em; }
.prose h2 { font-size: var(--text-3xl); margin-top: 2em; }
.prose h3 { font-size: var(--text-2xl); margin-top: 1.6em; }
.prose h4 { font-size: var(--text-lg); margin-top: 1.4em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: .4em; }
.prose blockquote { border-left: 2px solid var(--gold); padding-left: 1.2em; color: var(--muted-fg); font-style: italic; }
.prose img { border-radius: var(--radius); }
.prose figcaption { font-size: var(--text-sm); color: var(--muted-fg); margin-top: var(--space-2); }
.prose table { font-size: var(--text-base); }
.prose th, .prose td { border-bottom: 1px solid var(--border); padding: .5em .75em; text-align: left; }
.prose section[data-block] { margin-top: 2em; }
.prose section[data-block] > h2:first-child { margin-top: 0; }
.prose [data-block="scripture"], .prose [data-block="reflection"], .prose [data-block="discussion-questions"], .prose [data-block="key-concepts"], .prose [data-block="note"], .prose [data-block="caution"], .prose [data-block="contested"], .prose [data-block="further-reading"] { padding: 1.25em 1.5em; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.prose [data-block] > h2:first-child { font-size: var(--text-xl); font-family: var(--font-ui); font-weight: 600; }
.prose [data-block="scripture"] { border-left: 3px solid var(--gold); }
.prose [data-block="caution"] { border-left: 3px solid var(--warning); }
.prose [data-block="contested"] { border-left: 3px solid var(--info); }
.prose [data-block="contested"] > h2:first-child::before { content: "Where Christians differ — "; color: var(--info); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .1em; display: block; margin-bottom: .3em; }
.prose [data-block="note"] { font-size: var(--text-base); }
.article-head { padding: var(--space-16) 0 var(--space-10); }
.article-head h1 { font-size: var(--text-5xl); margin-top: var(--space-4); max-width: 52rem; }
.article-head .subtitle { font-size: var(--text-xl); color: var(--muted-fg); margin-top: var(--space-4); max-width: 44rem; line-height: var(--leading-relaxed); }
.article-head .meta { margin-top: var(--space-6); }
.article-figure img { width: 100%; max-height: 32rem; object-fit: cover; border-radius: var(--radius); }
.article-figure figcaption { font-size: var(--text-sm); color: var(--muted-fg); margin-top: var(--space-2); }
.references { font-size: var(--text-sm); color: var(--muted-fg); line-height: var(--leading-relaxed); }
.references h2 { font-size: var(--text-xl); color: var(--fg); margin-bottom: var(--space-3); }
.references ol, .references ul { padding-left: 1.2em; }
.references li + li { margin-top: .4em; }
.author-card { display: flex; gap: var(--space-4); align-items: flex-start; padding: var(--space-6) 0; border-top: 1px solid var(--border); }
.avatar { width: 3rem; height: 3rem; border-radius: 50%; object-fit: cover; background: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: var(--text-xl); color: var(--gold); flex-shrink: 0; }
.avatar-lg { width: 5rem; height: 5rem; font-size: var(--text-3xl); }
.toc { font-size: var(--text-sm); position: sticky; top: calc(var(--header-h) + var(--space-6)); }
.toc h2 { font-family: var(--font-ui); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: var(--tracking-eyebrow); color: var(--gold); margin-bottom: var(--space-3); }
.toc ul { list-style: none; padding: 0; }
.toc li { padding: var(--space-1) 0; }
.toc a { color: var(--muted-fg); text-decoration: none; }
.toc a:hover { color: var(--fg); }
.aside-block + .aside-block { margin-top: var(--space-8); padding-top: var(--space-8); border-top: 1px solid var(--border); }
.aside-block h2 { font-family: var(--font-ui); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: var(--tracking-eyebrow); color: var(--gold); margin-bottom: var(--space-3); font-weight: 500; }

/* ---------- Course page / outline ---------- */
.course-hero { padding: var(--space-16) 0 var(--space-12); border-bottom: 1px solid var(--border); }
.course-hero h1 { font-size: var(--text-5xl); margin-top: var(--space-4); max-width: 48rem; }
.course-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-6); margin-top: var(--space-10); padding-top: var(--space-6); border-top: 1px solid var(--border); }
.course-facts dt { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--muted-fg); }
.course-facts dd { margin-top: var(--space-1); font-size: var(--text-base); }
.enrol-box { position: sticky; top: calc(var(--header-h) + var(--space-6)); }
.enrol-box .price { font-family: var(--font-display); font-size: var(--text-4xl); line-height: 1; }
.outline { list-style: none; padding: 0; border-top: 1px solid var(--border); }
.outline > li { border-bottom: 1px solid var(--border); }
.outline details > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: var(--space-4); padding: var(--space-5) 0; }
.outline details > summary::-webkit-details-marker { display: none; }
.outline .mod-no { color: var(--gold); font-size: var(--text-sm); font-variant-numeric: tabular-nums; width: 2rem; flex-shrink: 0; }
.outline .mod-title { font-family: var(--font-heading); font-size: var(--text-xl); flex: 1; }
.outline .mod-meta { font-size: var(--text-sm); color: var(--muted-fg); white-space: nowrap; }
.outline details[open] > summary .icon-chev { transform: rotate(180deg); }
.icon-chev { transition: transform var(--duration) var(--ease); color: var(--muted-fg); }
.lesson-list { list-style: none; padding: 0 0 var(--space-5) 3rem; }
.lesson-list li { display: flex; gap: var(--space-3); align-items: center; padding: var(--space-2) 0; font-size: var(--text-sm); color: var(--muted-fg); }
.lesson-list a { color: var(--fg); text-decoration: none; }
.lesson-list a:hover { color: var(--gold); }
.lesson-list .done { color: var(--success); }
.lesson-list .current a { color: var(--gold); font-weight: 500; }
.objectives li { padding-left: var(--space-2); }
.objectives li + li { margin-top: var(--space-2); }

/* ---------- App shell (dashboard, teach, admin, org) ---------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: calc(100vh - var(--header-h)); }
.app-sidebar { background: var(--sidebar); border-right: 1px solid var(--border); padding: var(--space-6) var(--space-4); position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); overflow-y: auto; }
.app-sidebar .side-label { font-size: .68rem; letter-spacing: var(--tracking-eyebrow); text-transform: uppercase; color: var(--gold); padding: 0 var(--space-3); margin: var(--space-6) 0 var(--space-2); }
.app-sidebar .side-label:first-child { margin-top: 0; }
.side-nav { list-style: none; padding: 0; }
.side-nav a { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); color: var(--muted-fg); text-decoration: none; font-size: var(--text-sm); }
.side-nav a:hover { background: var(--accent); color: var(--fg); }
.side-nav a[aria-current="page"] { background: var(--accent); color: var(--fg); }
.side-nav a[aria-current="page"] .icon { color: var(--gold); }
.side-nav .count { margin-left: auto; font-size: var(--text-xs); color: var(--gold); }
.app-main { padding: var(--space-10) var(--space-10) var(--space-16); min-width: 0; }
.app-main > .app-title { margin-bottom: var(--space-8); }
.app-title h1 { font-size: var(--text-4xl); margin-top: var(--space-2); }
.app-title p { color: var(--muted-fg); margin-top: var(--space-2); }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: var(--space-4); margin-bottom: var(--space-8); }
.stat { padding: var(--space-5); background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.stat .stat-label { font-size: var(--text-xs); color: var(--muted-fg); text-transform: uppercase; letter-spacing: .06em; }
.stat .stat-value { font-family: var(--font-display); font-size: var(--text-3xl); line-height: 1.1; margin-top: var(--space-2); font-variant-numeric: tabular-nums; }
.stat .stat-note { font-size: var(--text-xs); color: var(--muted-fg); margin-top: var(--space-1); }
.stat a { color: inherit; text-decoration: none; }

/* ---------- Progress ---------- */
.progress { height: .375rem; background: var(--muted); border-radius: 999px; overflow: hidden; }
.progress-bar { display: block; height: 100%; background: var(--gold); border-radius: 999px; }
.progress-text { display: block; font-size: var(--text-xs); color: var(--muted-fg); margin-top: var(--space-1); }
.course-row { display: grid; grid-template-columns: minmax(0, 1fr) 12rem auto; gap: var(--space-6); align-items: center; padding: var(--space-5) 0; border-bottom: 1px solid var(--border); }
.course-row:first-child { border-top: 1px solid var(--border); }
.course-row h3 { font-size: var(--text-xl); }
.course-row h3 a { color: var(--fg); text-decoration: none; }
.course-row h3 a:hover { color: var(--gold); }

/* ---------- Learn (lesson player) ---------- */
.learn-shell { display: grid; grid-template-columns: 20rem minmax(0, 1fr); min-height: calc(100vh - var(--header-h)); }
.learn-outline { background: var(--sidebar); border-right: 1px solid var(--border); padding: var(--space-6) var(--space-5); position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); overflow-y: auto; }
.learn-outline h2 { font-size: var(--text-xl); }
.learn-outline .mod { margin-top: var(--space-6); }
.learn-outline .mod-name { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--muted-fg); margin-bottom: var(--space-2); }
.learn-outline ul { list-style: none; padding: 0; }
.learn-outline li a { display: flex; gap: var(--space-2); align-items: flex-start; padding: var(--space-2); border-radius: var(--radius-sm); color: var(--muted-fg); text-decoration: none; font-size: var(--text-sm); line-height: 1.35; }
.learn-outline li a:hover { background: var(--accent); color: var(--fg); }
.learn-outline li a[aria-current="page"] { background: var(--accent); color: var(--fg); }
.learn-outline li a .icon { margin-top: .1rem; }
.learn-outline .is-done .icon { color: var(--success); }
.learn-main { padding: var(--space-10) var(--space-12) var(--space-16); min-width: 0; }
.lesson-head h1 { font-size: var(--text-4xl); margin-top: var(--space-3); max-width: 44rem; }
.lesson-head .meta { margin-top: var(--space-4); }
.lesson-nav { display: flex; justify-content: space-between; gap: var(--space-4); margin-top: var(--space-12); padding-top: var(--space-6); border-top: 1px solid var(--border); flex-wrap: wrap; }
.complete-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-5); margin-top: var(--space-10); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); flex-wrap: wrap; }
.video-frame { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.materials { list-style: none; padding: 0; }
.materials li { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) 0; border-bottom: 1px solid var(--border); font-size: var(--text-sm); }

/* ---------- Quiz ---------- */
.question { padding: var(--space-6) 0; border-bottom: 1px solid var(--border); }
.question:first-of-type { border-top: 1px solid var(--border); }
.question legend, .question .q-prompt { font-size: var(--text-lg); font-weight: 500; line-height: var(--leading-relaxed); margin-bottom: var(--space-4); padding: 0; }
.question fieldset { border: 0; padding: 0; margin: 0; }
.q-no { color: var(--gold); font-size: var(--text-sm); display: block; margin-bottom: var(--space-1); font-weight: 400; }
.q-points { color: var(--muted-fg); font-size: var(--text-xs); font-weight: 400; }
.q-stimulus { padding: var(--space-4); background: var(--surface); border-left: 3px solid var(--gold); border-radius: var(--radius-sm); margin-bottom: var(--space-4); white-space: pre-line; }
.option { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: var(--space-2); cursor: pointer; font-weight: 400; }
.option:hover { border-color: var(--border-strong); background: var(--surface); }
.option-correct { border-color: color-mix(in oklab, var(--success) 50%, transparent); background: var(--success-bg); }
.option-wrong { border-color: color-mix(in oklab, var(--danger) 50%, transparent); background: var(--danger-bg); }
.result-label { font-size: var(--text-xs); font-weight: 600; margin-left: auto; white-space: nowrap; }
.explanation { margin-top: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--surface); font-size: var(--text-sm); color: var(--muted-fg); }
.timer { position: sticky; top: calc(var(--header-h) + var(--space-3)); z-index: 5; display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-4); background: var(--card); border: 1px solid var(--border-strong); border-radius: var(--radius); font-variant-numeric: tabular-nums; font-size: var(--text-sm); }
.score-big { font-family: var(--font-display); font-size: var(--text-7xl); line-height: 1; }
.rubric { width: 100%; font-size: var(--text-sm); }
.rubric th, .rubric td { border: 1px solid var(--border); padding: var(--space-3); vertical-align: top; text-align: left; }
.rubric th { background: var(--surface); font-weight: 500; }
.rubric .lvl-score { color: var(--gold); font-weight: 600; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: var(--space-16) var(--space-6); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty-state .empty-icon { display: inline-flex; width: 3rem; height: 3rem; align-items: center; justify-content: center; border-radius: 50%; background: var(--accent); color: var(--gold); margin-bottom: var(--space-4); }
.empty-state .empty-icon .icon { width: 1.4rem; height: 1.4rem; }
.empty-state h3 { font-size: var(--text-2xl); }
.empty-state p { color: var(--muted-fg); max-width: 28rem; margin: var(--space-3) auto 0; }
.empty-state .btn { margin-top: var(--space-6); }

/* ---------- Editor ---------- */
.editor { border: 1px solid var(--input); border-radius: var(--radius); background: var(--surface); }
.editor:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px var(--ring); }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: var(--space-2); border-bottom: 1px solid var(--border); background: var(--card); border-radius: var(--radius) var(--radius) 0 0; position: sticky; top: var(--header-h); z-index: 4; }
.editor-toolbar button, .editor-toolbar select { height: 2rem; min-width: 2rem; padding: 0 var(--space-2); border: 1px solid transparent; background: transparent; color: var(--fg); border-radius: var(--radius-sm); font: 500 var(--text-xs) var(--font-ui); cursor: pointer; }
.editor-toolbar select { width: auto; min-height: 2rem; padding-right: 1.6rem; border-color: var(--border); }
.editor-toolbar button:hover { background: var(--accent); }
.editor-toolbar .sep { width: 1px; background: var(--border); margin: 0 var(--space-1); }
.editor-area { min-height: 20rem; padding: var(--space-5); outline: none; }
.editor-area.prose { max-width: none; font-size: var(--text-base); }
.editor-source { display: none; border: 0; border-radius: 0 0 var(--radius) var(--radius); min-height: 20rem; }
.editor.show-source .editor-area { display: none; }
.editor.show-source .editor-source { display: block; }
.no-js .editor-toolbar { display: none; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: var(--space-4); }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); }
.modal-dialog { position: relative; width: 100%; max-width: 32rem; max-height: 90vh; overflow-y: auto; background: var(--card); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: var(--space-6); }
.modal-dialog h2 { font-size: var(--text-2xl); margin-bottom: var(--space-4); padding-right: var(--space-8); }
.modal-close { position: absolute; top: var(--space-3); right: var(--space-3); }

/* ---------- Loading overlay ---------- */
.loading-overlay { position: fixed; inset: 0; z-index: 200; display: none; align-items: center; justify-content: center; background: color-mix(in oklab, var(--bg) 70%, transparent); }
.loading-overlay.show { display: flex; }
.spinner { width: 2.25rem; height: 2.25rem; border: 2px solid var(--border-strong); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--sidebar); padding: var(--space-16) 0 var(--space-10); margin-top: var(--space-20); }
.app-shell + .site-footer, .learn-shell + .site-footer { margin-top: 0; }
.footer-grid { display: grid; grid-template-columns: 1.5fr repeat(3, 1fr); gap: var(--space-10); }
.footer-grid h2 { font-family: var(--font-ui); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: var(--tracking-eyebrow); color: var(--gold); font-weight: 500; margin-bottom: var(--space-4); }
.footer-grid ul { list-style: none; padding: 0; }
.footer-grid li + li { margin-top: var(--space-2); }
.footer-grid a { color: var(--muted-fg); text-decoration: none; font-size: var(--text-sm); }
.footer-grid a:hover { color: var(--fg); }
.footer-brand p { color: var(--muted-fg); font-size: var(--text-sm); margin-top: var(--space-4); max-width: 22rem; line-height: var(--leading-relaxed); }
.footer-bottom { margin-top: var(--space-12); padding-top: var(--space-6); border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; font-size: var(--text-xs); color: var(--muted-fg); }
.footer-bottom a { color: var(--muted-fg); }

/* ---------- Certificate ---------- */
.certificate { max-width: 52rem; margin: var(--space-10) auto; padding: var(--space-16) var(--space-12); background: #fbf8f2; color: #1f2328; border: 1px solid #d9cfbb; outline: 1px solid #d9cfbb; outline-offset: -14px; text-align: center; }
.certificate .eyebrow { color: #8a6420; }
.certificate h1 { font-size: 2.75rem; color: #1f2328; margin-top: var(--space-4); }
.certificate .cert-name { font-family: var(--font-display); font-size: 2.5rem; margin: var(--space-6) 0 var(--space-2); color: #1f2328; }
.certificate .cert-course { font-family: var(--font-display); font-size: 1.75rem; font-style: italic; color: #1f2328; margin-top: var(--space-2); }
.certificate p { color: #565049; }
.certificate .cert-foot { display: flex; justify-content: space-between; gap: var(--space-6); margin-top: var(--space-12); font-size: var(--text-sm); text-align: left; color: #565049; flex-wrap: wrap; }
.certificate .cert-note { margin-top: var(--space-8); font-size: var(--text-xs); color: #6b645b; }

/* ---------- Church CRM workspace components ---------- */
.container-full { max-width: none; padding-left: var(--space-6); padding-right: var(--space-6); }
.header-start { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.header-church { font-size: var(--text-sm); color: var(--muted-fg); max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.truncate { display: inline-block; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.menu-panel form { margin: 0; }
.menu-panel button[aria-current="true"] { color: var(--gold); }
.nav-only-mobile { display: none; }
.announcement { border-bottom: 1px solid var(--border); background: var(--info-bg); font-size: var(--text-sm); padding: var(--space-2) 0; }
.announcement-warning, .announcement-maintenance { background: var(--warning-bg); }
.sidebar-close { display: none; }
.sidebar-church { font-family: var(--font-display); font-size: var(--text-lg); padding: 0 var(--space-3); margin-bottom: var(--space-5); line-height: var(--leading-tight); }
.app-title { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.app-title h1 { font-size: var(--text-3xl); }
.title-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.site-footer-app { margin-top: 0; padding: var(--space-5) 0; }
.site-footer-app .footer-bottom { border-top: 0; padding-top: 0; margin-top: 0; }
.footer-links { list-style: none; padding: 0; }
.footer-links li + li { margin-top: var(--space-2); }
.footer-links a { color: var(--muted-fg); text-decoration: none; font-size: var(--text-sm); }
.footer-links a:hover { color: var(--gold); }
.badge-neutral { background: var(--muted); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-6); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: var(--space-4); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-5); }
.card h3 { font-size: var(--text-xl); }
.card .meta { margin-top: var(--space-2); }
.card-link { color: inherit; text-decoration: none; display: block; }
.card-link:hover { border-color: var(--border-strong); }
.section-gap { margin-top: var(--space-8); }

/* Filter bar above lists: search + a few selects on one wrapping row. */
.filter-bar { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-end; margin-bottom: var(--space-5); }
.filter-bar .field { margin: 0; min-width: 10rem; flex: 1 1 10rem; }
.filter-bar .field-search { flex: 2 1 16rem; }
.filter-bar label { font-size: var(--text-xs); color: var(--muted-fg); }
.filter-bar .btn { flex: 0 0 auto; }
.list-summary { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-3); font-size: var(--text-sm); color: var(--muted-fg); }
.bulk-bar { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; padding: var(--space-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: var(--space-3); }
.bulk-bar select { width: auto; min-width: 12rem; }
.table td.check-col, .table th.check-col { width: 2.5rem; }
.table .sub { display: block; font-size: var(--text-xs); color: var(--muted-fg); margin-top: 2px; }
.table tr.is-muted td { color: var(--muted-fg); }
.table tfoot td { font-weight: 600; background: var(--surface); }
.neg { color: var(--danger); }
.pos { color: var(--success); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-2) var(--space-5); font-size: var(--text-sm); }
.kv dt { color: var(--muted-fg); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.profile-head { display: flex; gap: var(--space-5); align-items: center; }
.profile-photo { width: 4.5rem; height: 4.5rem; border-radius: 50%; object-fit: cover; background: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: var(--text-2xl); color: var(--gold); flex-shrink: 0; }
.timeline { list-style: none; padding: 0; border-left: 1px solid var(--border-strong); margin-left: var(--space-2); }
.timeline li { position: relative; padding: 0 0 var(--space-5) var(--space-5); font-size: var(--text-sm); }
.timeline li::before { content: ""; position: absolute; left: -5px; top: .4rem; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); }
.timeline .when { color: var(--muted-fg); font-size: var(--text-xs); }
.restricted { border-left: 3px solid var(--warning); padding-left: var(--space-4); }
.restricted-label { display: inline-flex; gap: var(--space-1); align-items: center; font-size: var(--text-xs); color: var(--warning); text-transform: uppercase; letter-spacing: .06em; }

/* Onboarding wizard steps. */
.steps { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-8); counter-reset: step; }
.steps li { counter-increment: step; display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--muted-fg); padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); }
.steps li::before { content: counter(step); display: inline-flex; width: 1.5rem; height: 1.5rem; border-radius: 50%; align-items: center; justify-content: center; background: var(--accent); font-size: var(--text-xs); }
.steps li.done::before { content: "✓"; background: var(--success-bg); color: var(--success); }
.steps li[aria-current="step"] { color: var(--fg); border-color: var(--gold); }
.steps li[aria-current="step"]::before { background: var(--gold); color: var(--on-gold); }
.steps a { color: inherit; text-decoration: none; }

/* Fast attendance marking: large touch targets, one row per person. */
.mark-list { list-style: none; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); }
.mark-list li + li { border-top: 1px solid var(--border); }
.mark-row { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-3) var(--space-4); min-height: 3.25rem; cursor: pointer; }
.mark-row input { width: 1.4rem; height: 1.4rem; margin: 0; }
.mark-row .who { flex: 1; min-width: 0; }
.mark-row .who small { display: block; color: var(--muted-fg); font-size: var(--text-xs); }
.mark-row.is-present { background: var(--success-bg); }
.mark-search { position: sticky; top: var(--header-h); z-index: 5; background: var(--bg); padding: var(--space-3) 0; }
.count-pill { display: inline-flex; align-items: center; gap: var(--space-2); padding: .2rem .7rem; border-radius: 999px; background: var(--accent); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }

/* Simple bar charts drawn from real figures (no chart library). */
.bars { display: grid; gap: var(--space-2); }
.bar-row { display: grid; grid-template-columns: minmax(7rem, 12rem) minmax(0, 1fr) minmax(4rem, auto); gap: var(--space-3); align-items: center; font-size: var(--text-sm); }
.bar-track { height: .6rem; background: var(--muted); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--gold); border-radius: 999px; }
.bar-fill.alt { background: var(--info); }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted-fg); }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trend { display: flex; align-items: flex-end; gap: 3px; height: 8rem; padding-top: var(--space-2); border-bottom: 1px solid var(--border); }
.trend span { flex: 1; background: var(--gold); border-radius: 2px 2px 0 0; min-height: 1px; position: relative; }
.trend span.zero { background: var(--border-strong); }
.trend-labels { display: flex; justify-content: space-between; font-size: var(--text-xs); color: var(--muted-fg); margin-top: var(--space-1); }
.metric-note { font-size: var(--text-xs); color: var(--muted-fg); margin-top: var(--space-2); }

/* SMS composer meter. */
.sms-meter { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); font-size: var(--text-sm); color: var(--muted-fg); margin-top: var(--space-2); }
.sms-meter strong { color: var(--fg); font-variant-numeric: tabular-nums; }
.sms-preview { white-space: pre-wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4); font-size: var(--text-sm); }
.cost-box { border: 1px solid var(--gold); border-radius: var(--radius); padding: var(--space-5); }
.cost-box .stat-value { font-family: var(--font-display); font-size: var(--text-3xl); }

/* Receipts print on white. */
.receipt { background: #fff; color: #1f2328; border-radius: var(--radius); padding: var(--space-10); max-width: 36rem; margin: 0 auto; }
.receipt h1, .receipt h2 { color: #1f2328; }
.receipt .kv dt { color: #565049; }
.receipt-total { font-family: var(--font-display); font-size: var(--text-4xl); margin: var(--space-6) 0; }

/* Toasts (main.js toast()). */
.toast-region { position: fixed; right: var(--space-4); bottom: var(--space-4); z-index: 300; display: grid; gap: var(--space-2); max-width: min(24rem, calc(100vw - 2rem)); }
.toast { background: var(--card); border: 1px solid var(--border-strong); border-left: 3px solid var(--gold); border-radius: var(--radius); padding: var(--space-3) var(--space-4); font-size: var(--text-sm); box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .55); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-success { border-left-color: var(--success); }

/* Public marketing additions. */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--space-6); }
.feature { padding: var(--space-6); border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.feature .icon { width: 1.5rem; height: 1.5rem; color: var(--gold); }
.feature h3 { font-size: var(--text-xl); margin-top: var(--space-3); }
.feature p { color: var(--muted-fg); margin-top: var(--space-2); font-size: var(--text-sm); line-height: var(--leading-relaxed); }
.preview-frame { border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); overflow: hidden; box-shadow: var(--shadow-glow); }
.preview-frame .preview-bar { display: flex; gap: 6px; padding: var(--space-3); border-bottom: 1px solid var(--border); }
.preview-frame .preview-bar span { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); }
.preview-body { display: grid; grid-template-columns: 9rem minmax(0, 1fr); min-height: 18rem; font-size: var(--text-xs); }
.preview-side { background: var(--sidebar); padding: var(--space-4) var(--space-3); color: var(--muted-fg); display: grid; align-content: start; gap: var(--space-2); }
.preview-side b { color: var(--fg); font-weight: 500; }
.preview-main { padding: var(--space-5); display: grid; gap: var(--space-4); align-content: start; }
.preview-main .stat { padding: var(--space-3); }
.preview-main .stat .stat-value { font-size: var(--text-xl); }
.faq dt { font-family: var(--font-heading); font-size: var(--text-xl); margin-top: var(--space-8); }
.faq dd { margin: var(--space-2) 0 0; color: var(--muted-fg); line-height: var(--leading-relaxed); max-width: 48rem; }
.numbered-steps { list-style: none; padding: 0; counter-reset: n; display: grid; gap: var(--space-5); }
.numbered-steps li { counter-increment: n; display: grid; grid-template-columns: 2.5rem minmax(0, 1fr); gap: var(--space-3); align-items: baseline; }
.numbered-steps li::before { content: counter(n); font-family: var(--font-display); font-size: var(--text-3xl); color: var(--gold); }
.public-form { max-width: 34rem; margin: 0 auto; }

.lookup-results { display: grid; gap: 2px; margin-top: var(--space-1); }
.lookup-item { text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); color: var(--fg); font: 400 var(--text-sm) var(--font-ui); cursor: pointer; }
.lookup-item:hover, .lookup-item:focus { border-color: var(--gold); }
[data-notification].is-read { opacity: .65; }

/* QR codes and printable QR cards (always black on white so phones scan them reliably). */
.qr { display: block; max-width: 100%; height: auto; }
.qr-box { background: #fff; padding: var(--space-3); border-radius: var(--radius); display: inline-block; line-height: 0; }
.qr-inline { display: flex; gap: var(--space-6); align-items: center; flex-wrap: wrap; }
.qr-inline .qr-box { width: 11rem; }
.qr-card { background: #fff; color: #1f2328; border-radius: var(--radius); padding: var(--space-10) var(--space-8); max-width: 30rem; margin: 0 auto; text-align: center; }
.qr-card h1 { color: #1f2328; font-size: var(--text-4xl); margin-top: var(--space-2); }
.qr-card .qr-box { width: 17rem; margin-top: var(--space-6); border: 1px solid #ddd; }
.qr-card-eyebrow { font-size: var(--text-sm); letter-spacing: .14em; text-transform: uppercase; color: #8a6420; }
.qr-card-text { margin-top: var(--space-3); color: #3d4248; font-size: var(--text-lg); }
.qr-card-hint { margin-top: var(--space-4); font-weight: 600; }
.qr-card-link { margin-top: var(--space-1); font-size: var(--text-sm); color: #565049; overflow-wrap: anywhere; }
.qr-card-footer { margin-top: var(--space-6); font-size: var(--text-xs); color: #6b645b; }
.receipt-verify { display: flex; gap: var(--space-4); align-items: center; margin-top: var(--space-6); padding-top: var(--space-4); border-top: 1px solid #ddd; text-align: left; }
.receipt-verify .qr-box { width: 6.5rem; padding: 0; }
.receipt-verify p { font-size: var(--text-xs); color: #565049; }

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Print ---------- */
@media print {
    .site-header, .site-footer, .app-sidebar, .learn-outline, .no-print, .skip-link { display: none !important; }
    body { background: #fff; color: #000; }
    .app-shell, .learn-shell { display: block; }
    .certificate { margin: 0 auto; border: 1px solid #999; }
}

/* ---------- Responsive (keep last) ---------- */
@media (min-width: 768px) {
    .hero h1 { font-size: var(--text-7xl); line-height: 1.08; }
}

@media (max-width: 1100px) {
    .app-main { padding: var(--space-8) var(--space-6) var(--space-12); }
    .learn-main { padding: var(--space-8) var(--space-6) var(--space-12); }
    .layout-aside { grid-template-columns: minmax(0, 1fr); }
    .layout-aside > aside { order: 2; }
    .toc, .enrol-box { position: static; }
}

@media (max-width: 991px) {
    .nav-toggle { display: inline-flex; }
    .primary-nav { position: fixed; top: var(--header-h); left: 0; bottom: 0; width: min(20rem, 85vw); flex-direction: column; align-items: stretch; gap: 0; padding: var(--space-4); background: var(--sidebar); border-right: 1px solid var(--border); transform: translateX(-100%); transition: transform .2s var(--ease); z-index: 70; overflow-y: auto; visibility: hidden; }
    .primary-nav a { padding: var(--space-3); font-size: var(--text-base); }
    body.nav-open .primary-nav { transform: translateX(0); visibility: visible; }
    .nav-overlay { position: fixed; inset: var(--header-h) 0 0 0; background: rgba(0, 0, 0, .5); z-index: 65; display: none; }
    body.nav-open .nav-overlay { display: block; }
    .app-shell, .learn-shell { grid-template-columns: minmax(0, 1fr); }
    .app-sidebar, .learn-outline { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
    .app-sidebar .side-nav { display: flex; flex-wrap: wrap; gap: var(--space-1); }
    .app-sidebar .side-label { margin-top: var(--space-3); }
    .learn-outline { max-height: none; }
    .learn-outline-body { display: none; }
    .learn-outline.open .learn-outline-body { display: block; }
    .layout-filter { grid-template-columns: minmax(0, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .course-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 992px) {
    .learn-outline-toggle { display: none; }
}

@media (max-width: 640px) {
    :root { --gutter: 1rem; }
    h1 { font-size: var(--text-3xl); }
    h2 { font-size: var(--text-2xl); }
    .hero h1, .page-head h1, .article-head h1, .course-hero h1 { font-size: 2.35rem; }
    .section { padding: var(--space-12) 0; }
    .section-head { flex-direction: column; align-items: flex-start; }
    .grid-2, .grid-3, .subject-list, .field-row, .field-row-3 { grid-template-columns: minmax(0, 1fr); }
    .entry { grid-template-columns: minmax(0, 1fr); }
    .entry-aside { text-align: left; }
    .course-row { grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
    .footer-grid { grid-template-columns: minmax(0, 1fr); }
    .prose { font-size: var(--text-base); }
    .header-actions .hide-sm { display: none; }
    .brand { font-size: var(--text-xl); }
    .certificate { padding: var(--space-10) var(--space-6); }
    .score-big { font-size: var(--text-5xl); }
    .dl { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .dl dd { margin-bottom: var(--space-3); }
}

/* Church CRM responsive overrides (after the shared blocks so they win on equal specificity). */
@media print {
    .title-actions, .filter-bar, .bulk-bar, .pagination, .toast-region, .announcement, .sidebar-close { display: none !important; }
    .app-main { padding: 0; }
    .table-wrap { border: 0; overflow: visible; }
    .receipt { padding: 0; }
    .qr-card { padding: 0; max-width: none; }
    .qr-card .qr-box { width: 9cm; }
}

@media (max-width: 991px) {
    .container-full { padding-left: var(--space-4); padding-right: var(--space-4); }
    .app-sidebar { position: fixed; top: var(--header-h); left: 0; bottom: 0; width: min(18rem, 85vw); height: auto; z-index: 70; border-right: 1px solid var(--border); border-bottom: 0; transform: translateX(-100%); visibility: hidden; transition: transform .2s var(--ease); overflow-y: auto; }
    body.nav-open .app-sidebar { transform: translateX(0); visibility: visible; }
    .app-sidebar .side-nav { display: block; }
    .app-sidebar .side-label { margin-top: var(--space-5); }
    .sidebar-close { display: inline-flex; position: absolute; top: var(--space-2); right: var(--space-2); }
    .nav-only-mobile { display: block; }
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .app-main { padding: var(--space-6) var(--space-4) var(--space-10); }
    .app-title h1 { font-size: var(--text-2xl); }
    .grid-4 { grid-template-columns: minmax(0, 1fr); }
    .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
    .stat { padding: var(--space-4); }
    .stat .stat-value { font-size: var(--text-2xl); }
    .header-church { display: none; }
    .kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .kv dd { margin-bottom: var(--space-3); }
    .bar-row { grid-template-columns: minmax(0, 1fr) auto; }
    .bar-row .bar-track { grid-column: 1 / -1; grid-row: 2; }
    .preview-body { grid-template-columns: minmax(0, 1fr); }
    .preview-side { display: none; }
    .filter-bar .field { flex-basis: 100%; }
    /* Data tables become stacked cards; each cell shows its column name from data-label. */
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
    .table-cards tr { border-bottom: 1px solid var(--border); padding: var(--space-3) 0; }
    .table-cards td { border: 0; padding: var(--space-1) var(--space-4); text-align: left !important; }
    .table-cards td[data-label]::before { content: attr(data-label); display: block; font-size: var(--text-xs); color: var(--muted-fg); text-transform: uppercase; letter-spacing: .06em; }
    .table-cards td.actions { padding-top: var(--space-2); }
    .table-cards tfoot { display: block; }
}
