/* =====================================================================
 * BCC Connect — Design System (dark theme)
 *
 * Mirrors CLAUDE.md §5 and the canonical mockup at
 * docs/bcc_main_page_mockup.html. The two brand canonicals
 * (primary, accent) are injected at runtime as inline style on
 * <html> from settings.branding.*; everything else is derived here
 * statically. To change the palette, edit Settings → Branding —
 * not this file.
 * ===================================================================*/

:root {
    /* Brand canonicals (overridable via inline style from layout). */
    --color-primary: #1E40AF;
    --color-accent:  #355E3B;

    /* Surfaces */
    --bg-page:      #0D1117;
    --bg-card:      #161B22;
    --bg-raised:    #1C2128;
    --border-subtle: #30363D;
    --border-strong: #444C56;

    /* Text */
    --text-primary: #E6EDF3;
    --text-muted:   #9DA5AE;
    --text-subtle:  #6E7681;

    /* Derived display tokens for legibility on dark */
    --primary-on-dark:   #7AA8F5;
    --primary-soft:      rgba(122, 168, 245, 0.12);
    --accent-on-dark:    #6FE39B;
    --accent-soft:       rgba(111, 227, 155, 0.11);

    /* Status */
    --status-warning: #F59E0B;
    --status-error:   #F87171;
    --status-success: #6FE39B;

    /* Typography */
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Radii */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
}

/* ---------- Reset / base ------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary-on-dark);
    text-decoration: none;
    transition: color 120ms ease;
}
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 500;
    letter-spacing: -0.015em;
    margin: 0 0 0.5em;
    color: var(--text-primary);
}
h1 { font-size: 36px; line-height: 1.1; letter-spacing: -0.02em; }
h2 { font-size: 24px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; font-weight: 600; }

p { margin: 0 0 1em; }

small, .meta { color: var(--text-muted); font-size: 13px; }
.subtle { color: var(--text-subtle); font-size: 12px; }

hr {
    border: 0;
    border-top: 1px solid var(--border-subtle);
    margin: 1.5rem 0;
}

/* ---------- Layout ------------------------------------------------- */

/*
 * Authenticated pages opt in to the editorial treatment by carrying
 * .app-body on <body>. Aurora is a fixed body background composed
 * from the two brand canonicals — quieter than the auth aurora so
 * dense data screens stay readable.
 */
body.app-body {
    background:
        radial-gradient(900px 600px at 6% -8%,
            color-mix(in oklab, var(--color-primary) 38%, transparent) 0%,
            transparent 62%),
        radial-gradient(720px 540px at 98% 6%,
            color-mix(in oklab, var(--color-accent) 32%, transparent) 0%,
            transparent 64%),
        radial-gradient(1000px 720px at 50% 112%,
            color-mix(in oklab, var(--color-primary) 24%, transparent) 0%,
            transparent 70%),
        var(--bg-page);
    background-attachment: fixed;
}

.shell { min-height: 100%; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    position: sticky;
    top: 0;
    z-index: 50;
    /* Section accent — injected at runtime from settings.branding.section_color */
    background: var(--color-section, #1C234B);
    border-bottom: 1px solid rgba(230, 237, 243, 0.10);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
}
.topbar .brand {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 18px;
    letter-spacing: -0.01em;
}
.topbar .brand .mark {
    display: inline-block;
    width: 22px; height: 22px;
    background: var(--color-primary);
    border-radius: var(--radius-sm);
    vertical-align: middle;
    margin-right: 8px;
}
.topbar .nav { display: flex; gap: 11px; align-items: center; }
.topbar .nav a {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: var(--radius-md);
}
.topbar .nav a.active,
.topbar .nav a:hover {
    color: var(--primary-on-dark);
    background: rgba(122, 168, 245, 0.18);
    text-decoration: none;
}
.topbar .logout-button:hover {
    color: var(--primary-on-dark);
    background: rgba(122, 168, 245, 0.18);
    border-radius: var(--radius-md);
}
.topbar .user-chip {
    color: var(--text-muted);
    font-size: 13px;
}
.topbar .user-chip strong { color: var(--text-primary); }
.topbar .logout-form { display: inline; margin: 0; }
.topbar .logout-button {
    background: transparent;
    border: 0;
    color: var(--text-muted);
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    padding: 6px 10px;
    border-radius: var(--radius-md);
}

main.container {
    flex: 1;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px;
}

.page-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 24px;
}
.page-header .page-title { margin: 0; }
.page-header .page-actions { display: flex; gap: 10px; }

/* ---------- Cards -------------------------------------------------- */

.card {
    background: rgba(22, 27, 34, 0.65);
    border: 1px solid rgba(230, 237, 243, 0.08);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.04) inset,
        0 16px 40px -24px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(18px) saturate(120%);
    -webkit-backdrop-filter: blur(18px) saturate(120%);
}
.card + .card { margin-top: 16px; }
.card .card-title {
    font-family: var(--font-display);
    font-size: 17px;
    margin: 0 0 16px;
}
.card .card-meta { color: var(--text-muted); font-size: 13px; margin-bottom: 12px; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 880px) {
    .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
}

/* ---------- Forms -------------------------------------------------- */

.field { margin-bottom: 14px; }
.field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.field .hint { color: var(--text-subtle); font-size: 12px; margin-top: 4px; }
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="tel"],
.field input[type="date"],
.field input[type="number"],
.field input[type="url"],
.field select,
.field textarea {
    width: 100%;
    background: var(--bg-raised);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 8px 10px;
    font: inherit;
    font-size: 14px;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--primary-on-dark);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.field textarea { min-height: 100px; resize: vertical; }

.checkbox {
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
}
.checkbox input { accent-color: var(--accent-on-dark); }

/* Content-sized fields. Inputs stay width:100% of their .field, so the
   width class on the .field is what caps each control to its average value. */
.form-row { display: flex; flex-wrap: wrap; gap: 14px 16px; align-items: flex-end; }
.form-row .field { margin-bottom: 0; }
.w-2xs { width: 72px; }
.w-xs  { width: 112px; }
.w-sm  { width: 150px; }
.w-md  { width: 190px; }
.w-lg  { width: 260px; }
.w-xl  { width: 340px; }
@media (max-width: 560px) {
    .w-2xs, .w-xs, .w-sm, .w-md, .w-lg, .w-xl { width: 100%; }
}

/* Two mutually exclusive checkboxes standing in for a single-value pick
   (Male/Female). A hidden field carries the canonical M/F/U to the server. */
.choice-row { display: flex; gap: 18px; align-items: center; min-height: 38px; }
.choice { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; color: var(--text-primary); cursor: pointer; }
.choice input { accent-color: var(--accent-on-dark); }

/* Merged Photo (25%) + Name (75%) card. */
.np-row { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.np-photo { flex: 0 0 25%; max-width: 25%; min-width: 170px; }
.np-fields { flex: 1 1 0; min-width: 0; }
.np-photo .photo-tile,
.np-photo .photo-tile img,
.np-photo .photo-tile > div { width: 100%; max-width: 200px; height: auto; aspect-ratio: 1; }
@media (max-width: 720px) {
    .np-photo { flex-basis: 100%; max-width: 100%; }
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}

/* ---------- Buttons ----------------------------------------------- */

.button, button.button, a.button {
    display: inline-block;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0;
    padding: 7px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.button:hover { text-decoration: none; }

.button-primary {
    background: var(--color-primary);
    color: #FFFFFF;
    border-color: var(--color-primary);
}
.button-primary:hover { filter: brightness(1.08); }

.button-accent {
    background: var(--color-accent);
    color: #FFFFFF;
    border-color: var(--color-accent);
}
.button-accent:hover { filter: brightness(1.10); }

.button-secondary {
    background: var(--bg-card);
    color: var(--primary-on-dark);
    border-color: var(--border-strong);
}
.button-secondary:hover { background: var(--bg-raised); }

.button-link {
    background: transparent;
    color: var(--primary-on-dark);
    padding-left: 4px;
    padding-right: 4px;
    border-color: transparent;
}
.button-danger {
    background: transparent;
    color: var(--status-error);
    border-color: var(--status-error);
}
.button-danger:hover { background: rgba(248, 113, 113, 0.08); }

/* ---------- Tables ------------------------------------------------- */

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.table th, .table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 14px;
}
.table th {
    background: var(--bg-raised);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--bg-raised); }
.table .right { text-align: right; }
.table .center { text-align: center; }

/* ---------- Tags / dots / pills ----------------------------------- */

.tag {
    display: inline-block;
    background: var(--accent-soft);
    color: var(--accent-on-dark);
    font-size: 12px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 999px;
    line-height: 1.5;
}
.tag-muted { background: var(--bg-raised); color: var(--text-muted); }
.tag-warning { background: rgba(245, 158, 11, 0.12); color: var(--status-warning); }
.tag-error { background: rgba(248, 113, 113, 0.12); color: var(--status-error); }

.dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 999px;
    background: var(--accent-on-dark);
    vertical-align: middle;
    margin-right: 6px;
}
.dot-muted { background: var(--text-subtle); }
.dot-warning { background: var(--status-warning); }
.dot-error { background: var(--status-error); }

/* Fill bar (4px) */
.fill {
    width: 100%;
    height: 4px;
    background: var(--border-subtle);
    border-radius: 999px;
    overflow: hidden;
}
.fill > span {
    display: block;
    height: 100%;
    background: var(--accent-on-dark);
}

/* ---------- Flash messages ---------------------------------------- */

.flash {
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 14px;
    margin-bottom: 16px;
}
.flash-success {
    background: var(--accent-soft);
    color: var(--accent-on-dark);
    border: 1px solid var(--accent-on-dark);
}
.flash-error {
    background: rgba(248, 113, 113, 0.10);
    color: var(--status-error);
    border: 1px solid var(--status-error);
}
.flash-info {
    background: var(--primary-soft);
    color: var(--primary-on-dark);
    border: 1px solid var(--primary-on-dark);
}

/* ---------- Auth pages -------------------------------------------- */

/*
 * Editorial split shell shared by /login, /password/forgot,
 * /password/reset, /password/force-reset. Brand panel left,
 * frosted-glass form card right. Stacks on narrow viewports.
 * Background is a static aurora composed from the two brand
 * canonicals (var(--color-primary), var(--color-accent)) so it
 * always tracks Settings → Branding without further work.
 */

.auth-body {
    /* Block accidental scroll-chaining if the form section is short. */
    overflow-x: hidden;
}

.auth-shell {
    position: relative;
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    isolation: isolate;
}

/* Aurora — fixed so it doesn't reflow with content; very low opacity
 * so it reads as atmosphere, not decoration. */
.auth-aurora {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(900px 700px at 18% 22%,
            color-mix(in oklab, var(--color-primary) 55%, transparent) 0%,
            transparent 60%),
        radial-gradient(820px 640px at 82% 78%,
            color-mix(in oklab, var(--color-accent) 50%, transparent) 0%,
            transparent 62%),
        radial-gradient(620px 480px at 50% 100%,
            color-mix(in oklab, var(--color-primary) 35%, transparent) 0%,
            transparent 70%),
        var(--bg-page);
    /* The radial layers above are already low-coverage; this filter
     * keeps the effect subtle on bright displays. */
    opacity: 0.55;
}
/* Hairline seam between panels — barely visible, but adds structure. */
.auth-shell::before {
    content: "";
    position: absolute;
    top: 12%;
    bottom: 12%;
    left: calc(1.05 / 2.05 * 100%);
    width: 1px;
    background: linear-gradient(to bottom,
        transparent 0%,
        rgba(230, 237, 243, 0.10) 50%,
        transparent 100%);
    pointer-events: none;
}

/* ----- Brand panel (left) ----- */

.auth-brand-panel {
    display: flex;
    align-items: center;
    padding: clamp(32px, 6vw, 80px);
}
.auth-brand-inner {
    max-width: 520px;
    width: 100%;
}

.auth-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 28px;
}
.auth-eyebrow .mark {
    width: 18px;
    height: 18px;
    background: var(--color-primary);
    border-radius: var(--radius-sm);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
}

.auth-display {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(40px, 5.4vw, 64px);
    line-height: 1.02;
    letter-spacing: -0.025em;
    color: var(--text-primary);
    margin: 0 0 18px;
}

.auth-lede {
    font-size: 17px;
    color: var(--text-muted);
    margin: 0 0 36px;
    max-width: 36ch;
}

.auth-verse {
    margin: 0 0 40px;
    padding-left: 18px;
    border-left: 1px solid color-mix(in oklab, var(--color-accent) 55%, transparent);
    max-width: 44ch;
}
.auth-verse blockquote {
    margin: 0 0 8px;
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 400;
    font-size: 18px;
    line-height: 1.45;
    color: var(--text-primary);
}
.auth-verse figcaption {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--text-subtle);
}

.auth-visit {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 140ms ease, gap 140ms ease;
}
.auth-visit:hover {
    color: var(--primary-on-dark);
    text-decoration: none;
    gap: 12px;
}

/* ----- Form panel (right) ----- */

.auth-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(32px, 5vw, 72px);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 32px;
    border-radius: 14px;
    background: rgba(22, 27, 34, 0.72);
    border: 1px solid rgba(230, 237, 243, 0.08);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.04) inset,
        0 24px 60px -28px rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(22px) saturate(120%);
    -webkit-backdrop-filter: blur(22px) saturate(120%);
}
.auth-card h1 {
    font-size: 22px;
    margin: 0 0 6px;
    letter-spacing: -0.01em;
}
.auth-card h1 + p,
.auth-card h1 + .muted {
    margin-top: 0;
    margin-bottom: 22px;
}
.auth-card form { margin-top: 18px; }
.auth-card .submit-row {
    margin-top: 22px;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}
.auth-card .footer-link {
    text-align: center;
    margin-top: 18px;
    font-size: 13px;
}

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

@media (max-width: 880px) {
    .auth-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        min-height: 100vh;
    }
    .auth-shell::before { display: none; }
    .auth-brand-panel {
        padding: 40px 28px 16px;
    }
    .auth-display { font-size: clamp(36px, 9vw, 48px); }
    .auth-lede   { margin-bottom: 24px; }
    .auth-verse  { margin-bottom: 28px; }
    .auth-form-panel {
        padding: 16px 24px 48px;
        align-items: flex-start;
    }
}

@media (prefers-reduced-transparency: reduce) {
    .auth-card,
    .card {
        background: var(--bg-card);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

/* ---------- Hero band --------------------------------------------- */

.hero-band {
    height: 200px;
    background-size: cover;
    background-position: center center;
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    box-shadow: inset 0 -60px 120px -60px rgba(0,0,0,0.6);
}
@media (max-width: 880px) {
    .hero-band { height: 140px; }
}

/* ---------- Right-click context menu ------------------------------ */

.ctx-menu {
    position: fixed;
    z-index: 9999;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    padding: 4px 0;
    font-size: 13px;
    user-select: none;
}
.ctx-menu-item {
    display: block;
    padding: 7px 14px;
    color: var(--text-primary);
    text-decoration: none;
    background: transparent;
    border: 0;
    font: inherit;
    width: 100%;
    text-align: left;
    cursor: pointer;
}
.ctx-menu-item:hover {
    background: var(--primary-soft);
    color: var(--primary-on-dark);
    text-decoration: none;
}
.ctx-menu-item.danger {
    color: var(--status-error);
}
.ctx-menu-item.danger:hover {
    background: rgba(248, 113, 113, 0.10);
    color: var(--status-error);
}
.ctx-menu-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 0;
}

/* Cursor hint on rows that have a context menu — subtle right-click affordance */
[data-context] { cursor: default; }
[data-context]:hover { background: var(--bg-raised); }

/* ---------- Utility ----------------------------------------------- */

.row { display: flex; gap: 12px; align-items: center; }
.row.spread { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }
.muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.hide { display: none; }
.no-margin { margin: 0; }

/* ---------- Crop-upload modal (Cropper.js) ------------------------ */

.crop-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.crop-modal {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    width: min(720px, 100%);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.crop-modal-header {
    padding: 18px 20px 8px;
}
.crop-modal-title {
    font-family: var(--font-display);
    font-size: 22px;
    margin: 0 0 4px;
}
.crop-modal-hint {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
}
.crop-modal-stage {
    padding: 12px 20px;
    flex: 1;
    min-height: 0;
}
.crop-modal-stage img {
    display: block;
    max-width: 100%;
    max-height: 60vh;
}
.crop-modal-error {
    margin: 0 20px 8px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    background: rgba(248, 113, 113, 0.10);
    color: var(--status-error);
    border: 1px solid var(--status-error);
    font-size: 13px;
}
.crop-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 20px 18px;
    border-top: 1px solid var(--border-subtle);
}

/* ---------- Branded modal (BCC.confirm / BCC.alert) --------------- */

/*
 * Drives the dialogs built by /assets/js/modal.js. Frosted-glass card
 * over a dimmed brand-tinted backdrop so confirm/alert dialogs match
 * the rest of the design system rather than the browser's native UI.
 */
.bcc-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(900px 700px at 50% 50%,
            color-mix(in oklab, var(--color-primary) 18%, transparent) 0%,
            transparent 70%),
        rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(6px) saturate(110%);
    -webkit-backdrop-filter: blur(6px) saturate(110%);
    animation: bcc-modal-overlay-in 140ms ease-out both;
}
.bcc-modal-overlay[hidden] { display: none; }

.bcc-modal {
    width: min(440px, 100%);
    background: rgba(22, 27, 34, 0.82);
    border: 1px solid rgba(230, 237, 243, 0.10);
    border-radius: 14px;
    padding: 24px 24px 20px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.05) inset,
        0 28px 70px -22px rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(24px) saturate(120%);
    -webkit-backdrop-filter: blur(24px) saturate(120%);
    animation: bcc-modal-in 160ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.bcc-modal-title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 20px;
    letter-spacing: -0.01em;
    margin: 0 0 8px;
    color: var(--text-primary);
}
.bcc-modal-message {
    margin: 0 0 20px;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-line;
}
.bcc-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.bcc-modal-actions .button { min-width: 88px; }

@keyframes bcc-modal-overlay-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes bcc-modal-in {
    from { opacity: 0; transform: translateY(6px) scale(0.985); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .bcc-modal-overlay,
    .bcc-modal { animation: none; }
}
@media (prefers-reduced-transparency: reduce) {
    .bcc-modal-overlay {
        background: rgba(0, 0, 0, 0.78);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    .bcc-modal {
        background: var(--bg-card);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

/* =====================================================================
 * Mockup-derived component primitives (added 2026-06)
 *
 * Extends the existing design system with patterns established in
 * docs/bcc_main_page_mockup.html plus the directory / person-profile /
 * calendar / event-detail mockups. Additive only — does not touch any
 * existing class above this line. New tokens are added under :root so
 * existing variables are untouched.
 * ===================================================================*/

:root {
    /* Tabular numeric / code-like text. Used for phone numbers, dates,
     * audit timestamps, ICS URLs — anywhere column alignment matters. */
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;

    /* Ministry color tokens. Each ministry gets a hue used by calendar
     * event chips and ministry pills. Kept separate from the two brand
     * canonicals so a Settings → Branding change does not ripple into
     * ministry tagging. Hues chosen for legibility on dark surfaces. */
    --m-worship:       #7AA8F5;
    --m-worship-soft:  rgba(122, 168, 245, 0.15);
    --m-sound:         #8CCFE6;
    --m-sound-soft:    rgba(140, 207, 230, 0.15);
    --m-children:      #FF9F66;
    --m-children-soft: rgba(255, 159, 102, 0.16);
    --m-nursery:       #FFC5A1;
    --m-nursery-soft:  rgba(255, 197, 161, 0.16);
    --m-seniors:       #F5B541;
    --m-seniors-soft:  rgba(245, 181, 65, 0.16);
    --m-rcys:          #6FE39B;
    --m-rcys-soft:     rgba(111, 227, 155, 0.15);
    --m-outreach:      #C4A1F4;
    --m-outreach-soft: rgba(196, 161, 244, 0.16);
    --m-elders:        #B0BAC4;
    --m-elders-soft:   rgba(176, 186, 196, 0.15);
    --m-study:         #D9B3F5;
    --m-study-soft:    rgba(217, 179, 245, 0.16);
    --m-men:           #F4A4C7;
    --m-men-soft:      rgba(244, 164, 199, 0.15);
}

.mono { font-family: var(--font-mono); }

/* ---------- Brand mark (text-in-square) and brand name ------------ */

a.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}
a.brand:hover { text-decoration: none; }

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: var(--color-primary);
    border-radius: var(--radius-md);
    font-family: var(--font-display);
    font-weight: 600;
    color: #FFFFFF;
    font-size: 12px;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}
.brand-mark::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 4px;
    background: var(--color-accent);
}
.brand-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

/* ---------- User menu (info + avatar + hover-reveal sign-out) ----- */

.user-menu {
    position: relative; /* anchor for the sign-out dropdown */
    display: flex;
    align-items: center;
}
/* The name + avatar are a single link to the user's own profile. */
.user-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 4px 6px;
    border-radius: 999px;
    text-decoration: none;
}
.user-link:hover { background: rgba(122, 168, 245, 0.10); text-decoration: none; }

/* Sign-out lives in a small dropdown that reveals when the user-menu
 * is hovered or any element inside it is keyboard-focused. Positioned
 * absolutely so it doesn't take space in the header when hidden.
 *
 * Sits at top:100% with no margin gap so the mouse can move from the
 * user-link to the dropdown without crossing dead space (which would
 * collapse :hover and re-hide the panel). pointer-events toggles so
 * the hidden panel doesn't block clicks behind it. */
.user-menu .logout-form {
    position: absolute;
    top: 100%;
    right: 0;
    margin: 0;
    padding: 4px;
    min-width: 140px;
    background: #1C234B;
    border: 1px solid rgba(230, 237, 243, 0.10);
    border-radius: var(--radius-md);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-2px);
    transition: opacity 120ms ease, transform 120ms ease;
    z-index: 100;
}
.user-menu:hover .logout-form,
.user-menu:focus-within .logout-form,
.user-menu .logout-form:hover {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
/* Override the topbar's base logout-button styles inside the dropdown
 * so the button reads as a menu item (full-width, left-aligned). */
.user-menu .logout-form .logout-button {
    display: block;
    width: 100%;
    padding: 8px 12px;
    text-align: left;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 13px;
    white-space: nowrap;
}
.user-menu .logout-form .logout-button:hover {
    background: rgba(122, 168, 245, 0.18);
    color: var(--primary-on-dark);
}
.user-link.active .user-name { color: var(--primary-on-dark); }
.user-info {
    line-height: 1.2;
    text-align: right;
}
.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.user-role {
    font-size: 11px;
    color: var(--text-subtle);
}
.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg,
        color-mix(in oklab, var(--color-primary) 75%, white 25%),
        var(--color-primary));
    color: #FFFFFF;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
    font-family: var(--font-body);
}

/* ---------- Stat card (icon + value + label) ---------------------- */

.stat-card {
    background: rgba(22, 27, 34, 0.65);
    border: 1px solid rgba(230, 237, 243, 0.08);
    border-radius: var(--radius-lg);
    padding: 18px 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.04) inset,
        0 16px 40px -24px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(18px) saturate(120%);
    -webkit-backdrop-filter: blur(18px) saturate(120%);
}
.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.primary { background: var(--primary-soft); color: var(--primary-on-dark); }
.stat-icon.accent  { background: var(--accent-soft);  color: var(--accent-on-dark); }
.stat-icon.muted   { background: var(--bg-raised);    color: var(--text-muted); }
.stat-icon.warning { background: rgba(245, 158, 11, 0.12); color: var(--status-warning); }
.stat-value {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1;
}
.stat-value .stat-unit {
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-subtle);
    margin-left: 4px;
}
.stat-label {
    font-size: 13px;
    color: var(--text-subtle);
    margin-top: 4px;
}

/* ---------- Event hero card (glass wash) -------------------------- */
/* Subtle diagonal brand-blue wash so the top-of-page event card reads
   as the heading. Same language as .hh-detail-card (members) but in
   the brand blue instead of indigo so each page's "this is the focus"
   card has its own identifying color. */
.event-hero {
    background:
        linear-gradient(135deg,
            color-mix(in oklab, var(--primary-on-dark) 22%, transparent) 0%,
            color-mix(in oklab, var(--primary-on-dark) 10%, transparent) 50%,
            color-mix(in oklab, var(--primary-on-dark)  3%, transparent) 100%),
        var(--bg-card);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    border-color: color-mix(in oklab, var(--primary-on-dark) 26%, transparent);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 12px 32px -18px color-mix(in oklab, var(--primary-on-dark) 45%, transparent);
}

/* ---------- Statbar: compact stats + action ribbon in one row ----- */
/* Used on index pages (Ministries, Communications, etc.) to collapse
   the old two-row pattern (3-stat strip + action ribbon) into a single
   compact bar. Mobile stacks; desktop ≥1100px puts stats on the left
   and actions on the right. */
.statbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 16px;
    align-items: stretch;
}
.statbar-tiles {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
/* 4-tile variant for dashboards that surface an extra pastoral stat. */
.statbar-tiles.statbar-tiles-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
    .statbar-tiles.statbar-tiles-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 540px) {
    .statbar-tiles.statbar-tiles-4 { grid-template-columns: 1fr; }
}
/* Warm subtle highlight on the visitors tile when there's a count > 0 —
   nudges the eye without screaming. */
.stat-card.is-warm {
    border-color: color-mix(in oklab, var(--status-warning) 35%, var(--border-subtle));
    background:
        linear-gradient(135deg,
            color-mix(in oklab, var(--status-warning) 6%, transparent) 0%,
            transparent 60%),
        rgba(22, 27, 34, 0.65);
}
.statbar-tiles .stat-card {
    padding: 10px 14px;
    gap: 12px;
    border-radius: var(--radius-md);
}
.statbar-tiles .stat-icon { width: 32px; height: 32px; }
.statbar-tiles .stat-icon svg { width: 16px; height: 16px; }
.statbar-tiles .stat-value { font-size: 20px; line-height: 1.1; }
.statbar-tiles .stat-value .stat-unit { font-size: 12px; }
.statbar-tiles .stat-label { font-size: 11px; margin-top: 2px; letter-spacing: 0.02em; }

/* Plain .card tiles (label + big number, no icon) — used on
   communications/show and finance/batch_show. Same compact look as
   .stat-card so the visual rhythm matches across pages. */
.statbar-tiles > .card {
    padding: 10px 14px;
    border-radius: var(--radius-md);
}
.statbar-tiles > .card .card-meta { font-size: 10px; margin-bottom: 4px; letter-spacing: 0.08em; text-transform: uppercase; }
.statbar-tiles > .card .statbar-num {
    font-family: var(--font-display);
    font-size: 20px;
    line-height: 1.1;
    color: var(--text-primary);
}
.statbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.statbar-actions .statbar-spacer { flex: 1; }
.statbar-actions .subtle { font-size: 12px; }
@media (min-width: 1100px) {
    .statbar { grid-template-columns: minmax(0, 1fr) auto; }
    .statbar-actions { padding-left: 6px; }
}
@media (max-width: 640px) {
    .statbar-tiles { grid-template-columns: 1fr; }
}

/* ---------- Event-date inset pill (month + big day) -------------- */

.event-date {
    text-align: center;
    padding: 6px 0;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-page);
    width: 60px;
    flex-shrink: 0;
}
.event-date-month {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--primary-on-dark);
    text-transform: uppercase;
}
.event-date-day {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.05;
}

/* ---------- Detailed list row (date pill + info + action) -------- */

.list-row-detailed {
    display: grid;
    grid-template-columns: 64px 1fr auto;
    gap: 18px;
    padding: 14px 0;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
}
.list-row-detailed:last-child { border-bottom: none; }
.list-row-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.list-row-meta {
    font-size: 12px;
    color: var(--text-subtle);
    margin-top: 2px;
}

/* ---------- Ministry tag color variants -------------------------- */
/* These layer on top of the existing .tag class for color-coded
 * ministry tagging. Use `<span class="tag tag-worship">Worship</span>`. */

.tag-ministry { font-weight: 600; }
.tag-worship  { background: var(--m-worship-soft);  color: var(--m-worship); }
.tag-sound    { background: var(--m-sound-soft);    color: var(--m-sound); }
.tag-children { background: var(--m-children-soft); color: var(--m-children); }
.tag-nursery  { background: var(--m-nursery-soft);  color: var(--m-nursery); }
.tag-seniors  { background: var(--m-seniors-soft);  color: var(--m-seniors); }
.tag-rcys     { background: var(--m-rcys-soft);     color: var(--m-rcys); }
.tag-outreach { background: var(--m-outreach-soft); color: var(--m-outreach); }
.tag-elders   { background: var(--m-elders-soft);   color: var(--m-elders); }
.tag-study    { background: var(--m-study-soft);    color: var(--m-study); }
.tag-men      { background: var(--m-men-soft);      color: var(--m-men); }

/* ---------- Visibility badge ------------------------------------- */
/* Small pill that names *who can see or edit this card or field*, so
 * the §3 permission matrix is legible inline rather than only in
 * Settings → Security. Variants for sensitive scopes. */

.vis-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: var(--text-subtle);
    font-weight: 500;
    padding: 2px 7px;
    background: var(--bg-raised);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    line-height: 1.5;
}
.vis-badge svg { width: 11px; height: 11px; }
.vis-badge.elders,
.vis-badge.leaders {
    color: var(--status-warning);
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.25);
}
.vis-badge.admin {
    color: var(--status-error);
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.25);
}
.vis-badge.children {
    color: var(--m-children);
    background: var(--m-children-soft);
    border-color: color-mix(in oklab, var(--m-children) 35%, transparent);
}

/* ---------- Audit row -------------------------------------------- */
/* Tiny entries for activity / change history panels. The audit-tag
 * is the action class (self / vol / edit / note / rsvp / recur). */

.audit-row {
    padding: 10px 0;
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: 10px;
}
.audit-row + .audit-row { border-top: 1px solid var(--border-subtle); }
.audit-date {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-subtle);
    padding-top: 2px;
    letter-spacing: 0.02em;
}
.audit-text {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}
.audit-tag {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 9px;
    padding: 1px 5px;
    background: var(--primary-soft);
    color: var(--primary-on-dark);
    border-radius: 3px;
    font-weight: 600;
    margin-right: 5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.audit-tag.vol   { background: var(--accent-soft); color: var(--accent-on-dark); }
.audit-tag.edit  { background: rgba(245, 158, 11, 0.12); color: var(--status-warning); }
.audit-tag.note  { background: var(--bg-raised); color: var(--text-muted); }
.audit-tag.rsvp  { background: var(--accent-soft); color: var(--accent-on-dark); }
.audit-tag.recur { background: var(--bg-raised); color: var(--text-muted); }

/* ---------- Toggle switch (on/off slider) ------------------------ */
/* Used for SMS opt-in, public-directory opt-in, etc. on profile and
 * settings pages. State driven by .on class on the same element. */

.toggle {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--border-strong);
    border-radius: 999px;
    cursor: pointer;
    transition: background 120ms ease;
    border: 0;
    padding: 0;
    flex-shrink: 0;
}
.toggle::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: #FFFFFF;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: left 120ms ease;
}
.toggle.on { background: var(--color-accent); }
.toggle.on::after { left: 19px; }

/* ---------- Field grid (key/value display) ----------------------- */
/* Two-column key/value display for read-only profile/event detail
 * fields. Stacks to one column on narrow viewports. */

.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 24px;
}
@media (max-width: 880px) { .field-grid { grid-template-columns: 1fr; } }
.field-grid .field-label,
.field-label-sm {
    font-size: 10px;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-bottom: 3px;
}
.field-grid .field-value,
.field-value-sm {
    font-size: 14px;
    color: var(--text-primary);
}
.field-value-sub {
    display: block;
    font-size: 11px;
    color: var(--text-subtle);
    margin-top: 2px;
}

/* ---------- Identity-card header --------------------------------- */
/* Photo + name + pills + quick stats. Combine with .card for the
 * standard glass-card chrome, or use standalone for a different
 * shell. The ::before gradient stripe ties the brand canonicals
 * into the header. */

.identity-card {
    position: relative;
    overflow: hidden;
    padding: 24px 28px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 28px;
    align-items: center;
}
.identity-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
}
.identity-photo {
    width: 110px; height: 110px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bg-raised), var(--bg-card));
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 42px;
    font-weight: 500;
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
    flex-shrink: 0;
    object-fit: cover;
}
.identity-photo img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}
.identity-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.identity-name {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 500;
    color: var(--primary-on-dark);
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin: 0;
}
.identity-sub {
    font-size: 14px;
    color: var(--text-muted);
}
.identity-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 4px;
}
.identity-quick {
    display: flex;
    gap: 22px;
    align-items: center;
    padding-left: 24px;
    border-left: 1px solid var(--border-subtle);
}
.identity-quick .stat-value { font-size: 22px; }
.identity-quick .stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-top: 4px;
    text-align: center;
    max-width: 86px;
    line-height: 1.3;
}
@media (max-width: 980px) {
    .identity-card {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 16px;
    }
    .identity-photo { margin: 0 auto; }
    .identity-quick {
        padding-left: 0;
        border-left: none;
        padding-top: 16px;
        border-top: 1px solid var(--border-subtle);
        justify-content: center;
    }
}

/* =====================================================================
 * Calendar (month view) — added 2026-06
 *
 * Drives /events/calendar. Toolbar at top (today/prev/month/next, view
 * switcher, add), 7-column month grid below. Event chips are colored
 * by ministry with a small visibility dot to the left of the time.
 * ===================================================================*/

.cal-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.cal-toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(22, 27, 34, 0.65);
    border: 1px solid rgba(230, 237, 243, 0.08);
    border-radius: var(--radius-md);
    padding: 4px;
    backdrop-filter: blur(18px) saturate(120%);
    -webkit-backdrop-filter: blur(18px) saturate(120%);
}
.cal-tool-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: all 120ms ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}
.cal-tool-btn svg { width: 14px; height: 14px; }
.cal-tool-btn:hover {
    color: var(--primary-on-dark);
    background: var(--primary-soft);
    text-decoration: none;
}
.cal-tool-btn.active {
    background: var(--primary-soft);
    color: var(--primary-on-dark);
    font-weight: 600;
}
.cal-tool-divider { width: 1px; height: 18px; background: var(--border-subtle); }
.cal-month-label {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    padding: 0 14px;
    letter-spacing: -0.01em;
    min-width: 180px;
    text-align: center;
}

.cal-legend {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    align-items: center;
    font-size: 11px;
    color: var(--text-subtle);
    margin-bottom: 14px;
}
.cal-legend-item { display: inline-flex; align-items: center; gap: 6px; }

.vis-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.vis-dot.public  { background: var(--accent-on-dark); }
.vis-dot.members { background: var(--primary-on-dark); }
.vis-dot.leaders { background: var(--status-warning); }

/* The month grid surface itself — a card with the weekday header
 * row strapped to the top and 5-6 day rows under it. */
.cal-wrap {
    background: rgba(22, 27, 34, 0.65);
    border: 1px solid rgba(230, 237, 243, 0.08);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 16px 40px -24px rgba(0, 0, 0, 0.55);
    overflow: hidden;
    backdrop-filter: blur(18px) saturate(120%);
    -webkit-backdrop-filter: blur(18px) saturate(120%);
}
.cal-weekday-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-raised);
}
.cal-weekday {
    padding: 9px 12px;
    font-size: 11px;
    color: var(--text-subtle);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-align: left;
    border-right: 1px solid var(--border-subtle);
}
.cal-weekday:last-child { border-right: none; }
.cal-weekday.weekend { color: var(--text-muted); }

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: 130px;
}
.cal-day {
    border-right: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
    padding: 6px 6px 4px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow: hidden;
    position: relative;
    transition: background 120ms ease;
}
.cal-day:hover { background: var(--bg-raised); }
.cal-day:nth-child(7n) { border-right: none; }
.cal-grid > .cal-day:nth-last-child(-n+7) { border-bottom: none; }

.cal-day.outside { background: var(--bg-page); }
.cal-day.outside .cal-day-num { color: var(--text-subtle); opacity: 0.45; }
.cal-day.past .cal-day-num,
.cal-day.past .cal-event { opacity: 0.6; }
.cal-day.weekend { background: rgba(28, 33, 40, 0.35); }
.cal-day.weekend.outside { background: var(--bg-page); }

.cal-day-num-wrap {
    align-self: flex-start;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 1px 2px;
}
.cal-day.today .cal-day-num-wrap {
    background: var(--color-primary);
    color: #FFFFFF;
    border-radius: 999px;
    padding: 1px 8px;
    font-weight: 700;
}

/* Event chip: 3px left bar carries the ministry color, soft fill
 * gives the chip body. Visibility dot to the left of the time. */
.cal-event {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
    cursor: pointer;
    transition: filter 100ms ease, transform 100ms ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: var(--m-elders-soft);
    border-left: 3px solid var(--m-elders);
    text-decoration: none;
}
.cal-event:hover { filter: brightness(1.15); transform: translateX(1px); text-decoration: none; }
.cal-event .ev-time {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.cal-event .ev-title {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ministry-color variants (mirror the .tag-* set in the primitives). */
.ev-worship  { background: var(--m-worship-soft);  border-left-color: var(--m-worship); }
.ev-sound    { background: var(--m-sound-soft);    border-left-color: var(--m-sound); }
.ev-children { background: var(--m-children-soft); border-left-color: var(--m-children); }
.ev-nursery  { background: var(--m-nursery-soft);  border-left-color: var(--m-nursery); }
.ev-seniors  { background: var(--m-seniors-soft);  border-left-color: var(--m-seniors); }
.ev-rcys     { background: var(--m-rcys-soft);     border-left-color: var(--m-rcys); }
.ev-outreach { background: var(--m-outreach-soft); border-left-color: var(--m-outreach); }
.ev-elders   { background: var(--m-elders-soft);   border-left-color: var(--m-elders); }
.ev-study    { background: var(--m-study-soft);    border-left-color: var(--m-study); }
.ev-men      { background: var(--m-men-soft);      border-left-color: var(--m-men); }

/* Multi-day event bar variants. Negative side margins let the bar
 * span the cell edges; rounded corners only on the start/end. */
.cal-event.multi {
    border-radius: 0;
    border-left: none;
    border-top: 1px solid;
    border-bottom: 1px solid;
    padding: 2px 8px;
    margin-left: -7px;
    margin-right: -7px;
}
.cal-event.multi.start {
    border-top-left-radius: 3px;
    border-bottom-left-radius: 3px;
    border-left: 3px solid;
    margin-left: 0;
}
.cal-event.multi.end {
    border-top-right-radius: 3px;
    border-bottom-right-radius: 3px;
    margin-right: 0;
}

.cal-more {
    font-size: 10.5px;
    color: var(--text-subtle);
    font-weight: 600;
    padding: 1px 6px;
}

.cal-empty {
    padding: 32px;
    text-align: center;
    color: var(--text-subtle);
    font-size: 13px;
}

@media (max-width: 900px) {
    .cal-grid { grid-auto-rows: 100px; }
    .cal-month-label { min-width: 140px; font-size: 16px; }
}

/* =====================================================================
 * Calendar sidebar primitives — added 2026-06
 *
 * Sidebar shown alongside the month grid. Contains a mini-calendar
 * (current month at a glance, event-day dots), a filters card, and
 * an "upcoming this week" list. Mirrors docs/bcc_calendar.html.
 * ===================================================================*/

.cal-main-grid {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 16px;
    align-items: start;
}
.cal-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.cal-sidebar .card { padding: 0; }
.cal-sidebar .card + .card { margin-top: 0; }
.cal-sidebar-head {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-raised);
}
.cal-sidebar-title {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-on-dark);
    letter-spacing: -0.01em;
}
.cal-sidebar-body { padding: 14px 16px; }
.cal-sidebar-body-tight { padding: 8px 12px; }

/* Mini calendar table */
.mini-cal { width: 100%; border-collapse: collapse; }
.mini-cal th {
    font-size: 10px;
    color: var(--text-subtle);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-align: center;
    padding: 4px 0 6px;
}
.mini-cal td {
    text-align: center;
    padding: 0;
    font-size: 12px;
    color: var(--text-muted);
    height: 26px;
    vertical-align: middle;
    border-radius: var(--radius-sm);
    cursor: default;
}
.mini-cal td.outside { color: var(--text-subtle); opacity: 0.45; }
.mini-cal td.today {
    background: var(--color-primary);
    color: #FFFFFF;
    font-weight: 700;
}
.mini-cal td.has-event::after {
    content: '';
    display: block;
    width: 3px; height: 3px;
    background: var(--accent-on-dark);
    border-radius: 50%;
    margin: 1px auto 0;
}

/* Filters card */
.filter-section + .filter-section {
    border-top: 1px solid var(--border-subtle);
    margin-top: 10px;
    padding-top: 10px;
}
.filter-section-title {
    font-size: 10px;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-bottom: 8px;
}
.filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 12.5px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 120ms ease;
    text-decoration: none;
}
.filter-item:hover { color: var(--text-primary); text-decoration: none; }
.filter-item.checked { color: var(--text-primary); }
.filter-item.disabled { cursor: not-allowed; opacity: 0.5; }
.filter-check {
    width: 14px; height: 14px;
    border: 1.5px solid var(--border-strong);
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 120ms ease;
}
.filter-item.checked .filter-check {
    background: var(--primary-on-dark);
    border-color: var(--primary-on-dark);
}
.filter-item.checked .filter-check::after {
    content: '✓';
    color: var(--bg-page);
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
}
.filter-color {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.filter-count {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-subtle);
    font-variant-numeric: tabular-nums;
}

/* Upcoming list (compact date pill + info) */
.up-row {
    padding: 10px 0;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    border-top: 1px solid var(--border-subtle);
    text-decoration: none;
    color: inherit;
}
.up-row:first-child { border-top: none; padding-top: 4px; }
.up-row:last-child { padding-bottom: 4px; }
.up-row:hover { background: var(--bg-raised); }
.up-row:hover .up-title { color: var(--primary-on-dark); }
.up-date {
    flex-shrink: 0;
    width: 38px;
    text-align: center;
    padding: 3px 0;
    background: var(--bg-page);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
}
.up-date-mo {
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--primary-on-dark);
    text-transform: uppercase;
}
.up-date-day {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.05;
}
.up-info { min-width: 0; }
.up-title {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    transition: color 120ms ease;
}
.up-meta {
    font-size: 11px;
    color: var(--text-subtle);
    margin-top: 2px;
}

/* Tool-btn disabled variant */
.cal-tool-btn.disabled,
.cal-tool-btn[aria-disabled="true"] {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

@media (max-width: 1100px) {
    .cal-main-grid { grid-template-columns: 1fr; }
    .cal-sidebar { order: 2; }
}

/* =====================================================================
 * Calendar Week / Day / Agenda views — added 2026-06
 * ===================================================================*/

/* ---------- Week view ---------- */
.cal-week-wrap {
    background: rgba(22, 27, 34, 0.65);
    border: 1px solid rgba(230, 237, 243, 0.08);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 16px 40px -24px rgba(0, 0, 0, 0.55);
    overflow: hidden;
    backdrop-filter: blur(18px) saturate(120%);
    -webkit-backdrop-filter: blur(18px) saturate(120%);
}
.cal-week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    min-height: 540px;
}
.cal-week-day {
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.cal-week-day:last-child { border-right: none; }
.cal-week-day.past { opacity: 0.7; background: rgba(13, 17, 23, 0.4); }
.cal-week-day.today { background: rgba(122, 168, 245, 0.06); }
.cal-week-day-head {
    padding: 12px 12px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-raised);
    text-align: center;
    text-decoration: none;
    display: block;
    transition: background 120ms ease;
}
.cal-week-day.today .cal-week-day-head { background: rgba(122, 168, 245, 0.18); }
.cal-week-day-head:hover { background: var(--primary-soft); text-decoration: none; }
.cal-week-day-wd {
    display: block;
    font-size: 11px;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}
.cal-week-day-num {
    display: block;
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.1;
    margin-top: 4px;
}
.cal-week-day.today .cal-week-day-num { color: var(--primary-on-dark); }
.cal-week-day-events {
    padding: 8px 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}
.cal-week-add {
    display: block;
    text-align: center;
    font-size: 11px;
    color: var(--text-subtle);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 4px;
    text-decoration: none;
    margin-top: 4px;
}
.cal-week-add:hover {
    color: var(--primary-on-dark);
    border-color: var(--primary-on-dark);
    background: var(--primary-soft);
    text-decoration: none;
}

/* ---------- Day view ---------- */
.cal-day-wrap {
    background: rgba(22, 27, 34, 0.65);
    border: 1px solid rgba(230, 237, 243, 0.08);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 16px 40px -24px rgba(0, 0, 0, 0.55);
    overflow: hidden;
    backdrop-filter: blur(18px) saturate(120%);
    -webkit-backdrop-filter: blur(18px) saturate(120%);
}
.cal-day-head {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-raised);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}
.cal-day-head.today { background: rgba(122, 168, 245, 0.10); }
.cal-day-head.past { opacity: 0.7; }
.cal-day-head-wd {
    font-size: 11px;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}
.cal-day-head-big {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    line-height: 1.1;
    margin-top: 4px;
}
.cal-day-head.today .cal-day-head-big { color: var(--primary-on-dark); }
.cal-day-events { padding: 0; }
.cal-day-event {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 16px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-subtle);
    text-decoration: none;
    color: inherit;
    border-left: 3px solid transparent;
    transition: background 120ms ease;
}
.cal-day-event:last-child { border-bottom: none; }
.cal-day-event:hover { background: var(--bg-raised); text-decoration: none; }
.cal-day-event.ev-worship  { border-left-color: var(--m-worship); }
.cal-day-event.ev-sound    { border-left-color: var(--m-sound); }
.cal-day-event.ev-children { border-left-color: var(--m-children); }
.cal-day-event.ev-nursery  { border-left-color: var(--m-nursery); }
.cal-day-event.ev-seniors  { border-left-color: var(--m-seniors); }
.cal-day-event.ev-rcys     { border-left-color: var(--m-rcys); }
.cal-day-event.ev-outreach { border-left-color: var(--m-outreach); }
.cal-day-event.ev-elders   { border-left-color: var(--m-elders); }
.cal-day-event.ev-study    { border-left-color: var(--m-study); }
.cal-day-event.ev-men      { border-left-color: var(--m-men); }
.cal-day-event-time {
    text-align: right;
    color: var(--text-primary);
}
.cal-day-event-time .time-big {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1;
}
.cal-day-event-time .time-ampm {
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--text-subtle);
    margin-left: 2px;
}
.cal-day-event-time .time-end {
    font-size: 11px;
    color: var(--text-subtle);
    margin-top: 2px;
}
.cal-day-event-body { min-width: 0; }
.cal-day-event-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}
.cal-day-event-meta {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 4px;
}
.cal-day-event-desc {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 8px;
    line-height: 1.5;
}
.cal-day-empty {
    padding: 60px 24px;
    text-align: center;
    color: var(--text-subtle);
    font-size: 14px;
    line-height: 1.7;
}

/* ---------- Agenda view ---------- */
.cal-agenda-wrap {
    background: rgba(22, 27, 34, 0.65);
    border: 1px solid rgba(230, 237, 243, 0.08);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 16px 40px -24px rgba(0, 0, 0, 0.55);
    overflow: hidden;
    backdrop-filter: blur(18px) saturate(120%);
    -webkit-backdrop-filter: blur(18px) saturate(120%);
}
.cal-agenda-day {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 0;
    border-bottom: 1px solid var(--border-subtle);
}
.cal-agenda-day:last-child { border-bottom: none; }
.cal-agenda-day.past { opacity: 0.6; }
.cal-agenda-date-link {
    text-decoration: none;
    color: inherit;
    display: block;
    border-right: 1px solid var(--border-subtle);
    background: var(--bg-raised);
    transition: background 120ms ease;
}
.cal-agenda-date-link:hover {
    background: var(--primary-soft);
    text-decoration: none;
}
.cal-agenda-date {
    padding: 18px 16px;
    text-align: center;
}
.cal-agenda-date-wd {
    font-size: 11px;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}
.cal-agenda-date-num {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1;
    margin-top: 4px;
}
.cal-agenda-date-mo {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-top: 4px;
}
.cal-agenda-date-today {
    display: inline-block;
    margin-top: 6px;
    padding: 1px 7px;
    background: var(--color-primary);
    color: #FFFFFF;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 999px;
}
.cal-agenda-events { display: flex; flex-direction: column; }
.cal-agenda-event {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 14px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
    text-decoration: none;
    color: inherit;
    border-left: 3px solid transparent;
    transition: background 120ms ease;
}
.cal-agenda-event:last-child { border-bottom: none; }
.cal-agenda-event:hover { background: var(--bg-raised); text-decoration: none; }
.cal-agenda-event.ev-worship  { border-left-color: var(--m-worship); }
.cal-agenda-event.ev-sound    { border-left-color: var(--m-sound); }
.cal-agenda-event.ev-children { border-left-color: var(--m-children); }
.cal-agenda-event.ev-nursery  { border-left-color: var(--m-nursery); }
.cal-agenda-event.ev-seniors  { border-left-color: var(--m-seniors); }
.cal-agenda-event.ev-rcys     { border-left-color: var(--m-rcys); }
.cal-agenda-event.ev-outreach { border-left-color: var(--m-outreach); }
.cal-agenda-event.ev-elders   { border-left-color: var(--m-elders); }
.cal-agenda-event.ev-study    { border-left-color: var(--m-study); }
.cal-agenda-event.ev-men      { border-left-color: var(--m-men); }
.cal-agenda-event-time {
    font-size: 13px;
    color: var(--text-muted);
    padding-top: 1px;
    white-space: nowrap;
}
.cal-agenda-event-body { min-width: 0; }
.cal-agenda-event-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}
.cal-agenda-event-meta {
    font-size: 12px;
    color: var(--text-subtle);
    margin-top: 4px;
}

@media (max-width: 900px) {
    .cal-week-grid { grid-template-columns: 1fr; min-height: 0; }
    .cal-week-day { border-right: none; border-bottom: 1px solid var(--border-subtle); }
    .cal-day-event { grid-template-columns: 70px 1fr; }
    .cal-agenda-day { grid-template-columns: 80px 1fr; }
}

/* =====================================================================
 * Calendar — collapsible filter sections + larger upcoming card
 * added 2026-06
 * ===================================================================*/

/* Collapsible filter section using <details>. The summary acts as the
 * section header; default disclosure marker is hidden and replaced
 * with a custom chevron that rotates when open. */
details.filter-section { padding: 0; }
details.filter-section + details.filter-section {
    border-top: 1px solid var(--border-subtle);
    margin-top: 8px;
    padding-top: 8px;
}
details.filter-section > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 10px;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    transition: color 120ms ease;
}
details.filter-section > summary::-webkit-details-marker { display: none; }
details.filter-section > summary::after {
    content: '';
    width: 8px; height: 8px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 160ms ease;
    margin-right: 4px;
}
details.filter-section[open] > summary::after {
    transform: rotate(45deg);
}
details.filter-section > summary:hover {
    color: var(--primary-on-dark);
}
details.filter-section > .filter-section-body {
    padding-top: 4px;
    padding-bottom: 4px;
}

/* Inline count badge next to the section summary (e.g. ministry has 12). */
details.filter-section > summary .filter-summary-count {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-subtle);
    font-weight: 600;
    margin-left: 8px;
    padding: 1px 6px;
    background: var(--bg-raised);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    text-transform: none;
    letter-spacing: 0;
}

/* Larger Upcoming-This-Week section that lives below the calendar. */
.cal-upcoming-wide {
    margin-top: 18px;
    max-width: 100%;
}
.cal-upcoming-wide .cal-upcoming-head {
    text-align: center;
    margin-bottom: 14px;
}
.cal-upcoming-wide .cal-upcoming-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 600;
    color: var(--primary-on-dark);
    letter-spacing: -0.01em;
    margin: 0;
}
.cal-upcoming-wide .cal-upcoming-sub {
    color: var(--text-subtle);
    font-size: 13px;
    margin-top: 4px;
}
.cal-upcoming-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}
.cal-upcoming-empty {
    text-align: center;
    padding: 28px;
    color: var(--text-subtle);
    font-size: 13px;
}
.cal-upcoming-card {
    background: rgba(22, 27, 34, 0.65);
    border: 1px solid rgba(230, 237, 243, 0.08);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 14px;
    align-items: center;
    text-decoration: none;
    color: inherit;
    border-left: 3px solid transparent;
    transition: filter 100ms ease, transform 100ms ease;
    backdrop-filter: blur(18px) saturate(120%);
    -webkit-backdrop-filter: blur(18px) saturate(120%);
}
.cal-upcoming-card:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    text-decoration: none;
}
.cal-upcoming-card.ev-worship  { border-left-color: var(--m-worship); }
.cal-upcoming-card.ev-sound    { border-left-color: var(--m-sound); }
.cal-upcoming-card.ev-children { border-left-color: var(--m-children); }
.cal-upcoming-card.ev-nursery  { border-left-color: var(--m-nursery); }
.cal-upcoming-card.ev-seniors  { border-left-color: var(--m-seniors); }
.cal-upcoming-card.ev-rcys     { border-left-color: var(--m-rcys); }
.cal-upcoming-card.ev-outreach { border-left-color: var(--m-outreach); }
.cal-upcoming-card.ev-elders   { border-left-color: var(--m-elders); }
.cal-upcoming-card.ev-study    { border-left-color: var(--m-study); }
.cal-upcoming-card.ev-men      { border-left-color: var(--m-men); }
.cal-upcoming-card-date {
    text-align: center;
    padding: 6px 0;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-page);
}
.cal-upcoming-card-date-mo {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--primary-on-dark);
    text-transform: uppercase;
}
.cal-upcoming-card-date-day {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1;
    margin-top: 2px;
}
.cal-upcoming-card-body { min-width: 0; }
.cal-upcoming-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cal-upcoming-card-meta {
    font-size: 11.5px;
    color: var(--text-subtle);
    margin-top: 4px;
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.cal-upcoming-card-meta .mono {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}

/* =====================================================================
 * Calendar right-column wrapper — keeps Upcoming aligned with calendar
 * and lets the Upcoming section sit in its own dark band.
 * added 2026-06
 * ===================================================================*/
.cal-main-grid > .cal-right-col {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

/* Section-band version of Upcoming This Week: dark background, full
 * column width, event cards retain their lighter glass for contrast. */
.cal-upcoming-wide {
    background: var(--color-section, #1C234B);
    border: 1px solid rgba(230, 237, 243, 0.08);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.05) inset,
        0 16px 40px -24px rgba(0, 0, 0, 0.55);
    margin-top: 0;
}
.cal-upcoming-wide .cal-upcoming-head {
    text-align: center;
    margin-bottom: 16px;
}
.cal-upcoming-wide .cal-upcoming-title {
    color: var(--text-primary);
}
.cal-upcoming-wide .cal-upcoming-sub {
    color: rgba(230, 237, 243, 0.6);
}
.cal-upcoming-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
}
.cal-upcoming-empty {
    color: rgba(230, 237, 243, 0.5);
    padding: 22px;
}
/* Cards inside the dark band: brighten slightly for separation. */
.cal-upcoming-wide .cal-upcoming-card {
    background: rgba(22, 27, 34, 0.55);
    border-color: rgba(230, 237, 243, 0.10);
}

/* =====================================================================
   PREACHING
   Service-type accent system + "next service" spotlight, timeline rows,
   and the share toast. Service types map onto the existing ministry hue
   tokens so the palette stays coherent with the calendar:
     morning   -> primary blue   (the main weekly gathering)
     evening   -> study purple    (teaching / study feel)
     wednesday -> accent green     (midweek)
     special   -> warning amber    (stands out: revivals, holidays)
     other     -> neutral
   ===================================================================== */

:root {
    --svc-morning:        var(--primary-on-dark);
    --svc-morning-soft:   var(--primary-soft);
    --svc-evening:        var(--m-study);
    --svc-evening-soft:   var(--m-study-soft);
    --svc-wednesday:      var(--accent-on-dark);
    --svc-wednesday-soft: var(--accent-soft);
    --svc-special:        var(--status-warning);
    --svc-special-soft:   rgba(245, 158, 11, 0.14);
    --svc-other:          var(--text-muted);
    --svc-other-soft:     var(--bg-raised);

    /* Month palette for the preaching timeline. 12 hues, evenly
       distributed around the wheel and tuned for legibility against
       a dark page bg when passed through color-mix(..., transparent).
       Order roughly follows the season: winter blues, spring greens,
       summer golds, autumn reds, winter violets. */
    --month-1:  hsl(218, 70%, 58%); /* Jan – winter blue */
    --month-2:  hsl(248, 60%, 64%); /* Feb – indigo */
    --month-3:  hsl(150, 55%, 50%); /* Mar – spring green */
    --month-4:  hsl(180, 55%, 50%); /* Apr – teal */
    --month-5:  hsl( 95, 55%, 50%); /* May – fresh lime */
    --month-6:  hsl( 42, 75%, 56%); /* Jun – gold */
    --month-7:  hsl( 28, 80%, 56%); /* Jul – amber */
    --month-8:  hsl( 12, 75%, 56%); /* Aug – sun orange */
    --month-9:  hsl(340, 65%, 62%); /* Sep – rose */
    --month-10: hsl(  0, 70%, 56%); /* Oct – red */
    --month-11: hsl( 22, 50%, 50%); /* Nov – warm brown */
    --month-12: hsl(280, 60%, 62%); /* Dec – violet */
}

/* Service-type pill (small, color-coded) ------------------------------ */
.svc-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: 999px;
    line-height: 1.4;
    white-space: nowrap;
}
.svc-pill::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.svc-morning   { background: var(--svc-morning-soft);   color: var(--svc-morning); }
.svc-evening   { background: var(--svc-evening-soft);   color: var(--svc-evening); }
.svc-wednesday { background: var(--svc-wednesday-soft); color: var(--svc-wednesday); }
.svc-special   { background: var(--svc-special-soft);   color: var(--svc-special); }
.svc-other     { background: var(--svc-other-soft);     color: var(--svc-other); }

/* Deviation pill — flags a service whose preacher is not the regular
   preacher (set via the preaching.regular_preacher_name setting). The
   amber star reads as "noteworthy" without screaming. */
.deviation-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--svc-special-soft);
    color: var(--status-warning);
    border: 1px solid color-mix(in oklab, var(--status-warning) 35%, transparent);
}

/* Rows whose preacher isn't the regular get a stronger amber ring and
   a subtle accent halo so they stand out among a sea of monthly tints. */
.preach-row.is-deviation {
    border-color: color-mix(in oklab, var(--status-warning) 40%, transparent);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 0 0 1px color-mix(in oklab, var(--status-warning) 18%, transparent),
        0 6px 18px -10px color-mix(in oklab, var(--status-warning) 35%, transparent);
}
.preach-row.is-deviation:hover {
    border-color: color-mix(in oklab, var(--status-warning) 60%, transparent);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 0 0 1px color-mix(in oklab, var(--status-warning) 30%, transparent),
        0 8px 22px -10px color-mix(in oklab, var(--status-warning) 50%, transparent);
}
.preach-spotlight.is-deviation::before {
    /* Brighter, glowing accent bar on the spotlight when the next
       service deviates from the regular preacher. */
    background: var(--status-warning);
    box-shadow: 0 0 18px 2px color-mix(in oklab, var(--status-warning) 35%, transparent);
}

/* ---------- "Next service" spotlight -------------------------------- */
.preach-spotlight {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    background:
        radial-gradient(120% 140% at 100% 0%, rgba(122, 168, 245, 0.10), transparent 55%),
        linear-gradient(180deg, rgba(28, 33, 40, 0.55), rgba(22, 27, 34, 0.85));
    padding: 10px 18px;
    box-shadow: 0 24px 60px -36px rgba(0, 0, 0, 0.7);
}
/* Left accent bar carries the service-type color. */
.preach-spotlight::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--spot-accent, var(--primary-on-dark));
}
.preach-spotlight-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 14px;
    align-items: center;
}
.preach-eyebrow {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.preach-eyebrow-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-subtle);
}
.preach-countdown {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--spot-accent, var(--primary-on-dark));
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    padding: 2px 10px;
    border-radius: 999px;
}
/* Big date block (left column of the spotlight). */
.preach-bigdate {
    text-align: center;
    width: 92px;
    padding: 7px 6px;
    border-radius: var(--radius-md);
    background: var(--bg-page);
    border: 1px solid var(--border-strong);
}
.preach-bigdate-wd {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--spot-accent, var(--primary-on-dark));
}
.preach-bigdate-day {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 600;
    line-height: 1;
    color: var(--text-primary);
    margin: 1px 0;
}
.preach-bigdate-mo {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.preach-bigdate-time {
    margin-top: 3px;
    padding-top: 3px;
    border-top: 1px solid var(--border-subtle);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}
.preach-spot-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--text-primary);
    margin: 1px 0 0;
}
.preach-spot-title .untitled { color: var(--text-subtle); font-style: italic; }
/* The scripture line — the heart of "what we're preaching". */
.preach-scripture {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 500;
    color: var(--spot-accent, var(--primary-on-dark));
}
.preach-scripture svg { width: 13px; height: 13px; opacity: 0.85; }
.preach-spot-meta {
    display: flex;
    align-items: center;
    gap: 6px 12px;
    flex-wrap: wrap;
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-muted);
}
.preach-spot-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.preach-spot-actions .button { padding: 4px 12px; font-size: 12px; }
@media (max-width: 760px) {
    .preach-spotlight-grid { grid-template-columns: 1fr; gap: 18px; }
    .preach-bigdate { width: 100%; display: flex; align-items: baseline; justify-content: center; gap: 12px; }
    .preach-bigdate-time { border-top: none; padding-top: 0; margin-top: 0; }
    .preach-spot-title { font-size: 24px; }
}

/* Desktop density: pair the next-service spotlight with the stat grid
   so the four stat tiles stop consuming a full row of vertical space.
   Below 1100px the hero collapses to a single column (spotlight then
   stats), matching mobile/tablet behavior. */
.preach-hero { display: grid; gap: 16px; }
@media (min-width: 1100px) {
    .preach-hero {
        grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr);
        align-items: stretch;
    }
    .preach-hero .preach-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-content: start;
    }
}

/* Preacher chip (avatar initials + name) ----------------------------- */
.preacher-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.preacher-avatar {
    width: 39px;
    height: 39px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-on-dark);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid color-mix(in oklab, currentColor 35%, transparent);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 2px 6px rgba(0, 0, 0, 0.25);
}
/* Per-preacher color tokens. Tony (the regular) wears the brand blue;
   Les and Kenny get their own hues so they're instantly identifiable
   at a glance. Guest gets the warning amber so it pops as "outside". */
.preacher-avatar.is-tony  { background: color-mix(in oklab, var(--primary-on-dark) 28%, var(--bg-page)); color: var(--primary-on-dark); }
.preacher-avatar.is-les   { background: color-mix(in oklab, var(--accent-on-dark)  28%, var(--bg-page)); color: var(--accent-on-dark); }
.preacher-avatar.is-kenny { background: color-mix(in oklab, #a18d69 32%, var(--bg-page));               color: #d8c39a; }
.preacher-avatar.guest    { background: var(--svc-special-soft); color: var(--status-warning); }
.preacher-chip .preacher-name { color: var(--text-primary); font-weight: 500; font-size: 20px; }

/* ---------- Timeline rows (upcoming / series) ----------------------- */
.preach-timeline { display: flex; flex-direction: column; }
/* Desktop: pack the timelines into two columns so we use the full
   width of the card instead of leaving the right half empty. */
@media (min-width: 1100px) {
    .preach-timeline {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 14px;
        row-gap: 16px;
    }
    .preach-timeline > .preach-row + .preach-row { margin-top: 0; }
    /* Month dividers always span the full width so the boundary is
       unambiguous in 2-column layout. */
    .preach-timeline > .preach-month-divider { grid-column: 1 / -1; }
}
.preach-row {
    display: grid;
    grid-template-columns: 58px 1fr;
    gap: 16px;
    align-items: center;
    padding: 14px 16px 14px 18px;
    border-radius: var(--radius-md);
    position: relative;
    /* Glass-morphism surface tinted by service-type accent. The
       horizontal gradient washes the accent color from the left
       (where the date sits) out to neutral on the right. backdrop
       blur+saturate gives the frosted-glass feel against the page. */
    background:
        linear-gradient(90deg,
            color-mix(in oklab, var(--row-accent, var(--border-strong)) 22%, transparent) 0%,
            color-mix(in oklab, var(--row-accent, var(--border-strong))  8%, transparent) 55%,
            color-mix(in oklab, var(--row-accent, var(--border-strong))  2%, transparent) 100%),
        rgba(255, 255, 255, 0.025);
    backdrop-filter: blur(10px) saturate(140%);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
    border: 1px solid color-mix(in oklab, var(--row-accent, var(--border-strong)) 22%, transparent);
    border-left: 4px solid var(--row-accent, var(--border-strong));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.045),
        0 1px 2px rgba(0, 0, 0, 0.18);
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}
.preach-row + .preach-row { margin-top: 16px; }
/* Alternating brightness keeps adjacent same-service-type rows
   distinguishable (Sunday-after-Sunday sequences would otherwise
   blur together). */
.preach-row:nth-child(even) {
    background:
        linear-gradient(90deg,
            color-mix(in oklab, var(--row-accent, var(--border-strong)) 14%, transparent) 0%,
            color-mix(in oklab, var(--row-accent, var(--border-strong))  6%, transparent) 50%,
            color-mix(in oklab, var(--row-accent, var(--border-strong))  1%, transparent) 100%),
        rgba(255, 255, 255, 0.04);
}
.preach-row:hover {
    background:
        linear-gradient(90deg,
            color-mix(in oklab, var(--row-accent, var(--border-strong)) 32%, transparent) 0%,
            color-mix(in oklab, var(--row-accent, var(--border-strong)) 12%, transparent) 55%,
            color-mix(in oklab, var(--row-accent, var(--border-strong))  3%, transparent) 100%),
        rgba(255, 255, 255, 0.06);
    border-color: color-mix(in oklab, var(--row-accent, var(--border-strong)) 38%, transparent);
    transform: translateY(-1px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.07),
        0 6px 18px -8px color-mix(in oklab, var(--row-accent, var(--border-strong)) 55%, transparent),
        0 2px 4px rgba(0, 0, 0, 0.25);
}
.preach-date {
    text-align: center;
    line-height: 1.05;
    padding: 6px 4px;
    border-radius: 8px;
    background: color-mix(in oklab, var(--row-accent, var(--border-strong)) 14%, rgba(0, 0, 0, 0.18));
    border: 1px solid color-mix(in oklab, var(--row-accent, var(--border-strong)) 25%, transparent);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.preach-date-mo {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--row-accent, var(--primary-on-dark));
}
.preach-date-day {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}
.preach-date-wd {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-subtle);
}
/* Row body: 2-col grid so preacher/title sit at the left and the
   series tag (top-right) + scripture (bottom-right) anchor cleanly
   to the right edge — much more scannable than a single flex-wrap
   meta line. */
.preach-body {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto;
    column-gap: 14px;
    row-gap: 4px;
    align-items: center;
}
.preach-row-preacher  { grid-column: 1; grid-row: 1; display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.preach-row-title     { grid-column: 1; grid-row: 2; align-self: start; }
.preach-row-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.preach-row-title a { color: inherit; }
.preach-row-title a:hover { color: var(--primary-on-dark); }
.preach-deviation-line { grid-column: 1; grid-row: 3; align-self: start; }
.preach-row-series    { grid-column: 2; grid-row: 1; justify-self: end; align-self: start; }
.preach-row-scripture {
    grid-column: 2;
    grid-row: 3;
    justify-self: end;
    align-self: end;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.preach-row-scripture .scripture { color: var(--text-primary); font-weight: 500; }
/* If the row has no title and no deviation, scripture and series
   end up in rows 1 and 3 respectively, leaving an empty row 2.
   Collapse that empty row so the two stack flush together. */
.preach-row:not(:has(.preach-row-title)):not(:has(.preach-deviation-line)) .preach-body {
    grid-template-rows: auto;
}
.preach-row:not(:has(.preach-row-title)):not(:has(.preach-deviation-line)) .preach-row-scripture {
    grid-row: 2;
}
.preach-row-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.12s ease;
}
.preach-row:hover .preach-row-actions,
.preach-row:focus-within .preach-row-actions { opacity: 1; }
@media (hover: none) { .preach-row-actions { opacity: 1; } }
@media (max-width: 640px) {
    .preach-row { grid-template-columns: 48px 1fr; }
}

/* "Special speaker" callout below the preacher name. Bright yellow
   so it cuts through the colored row tint without competing with the
   service-type pill or the title. */
.preach-deviation-line {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #fde047; /* tailwind yellow-300 — bright against dark theme */
    text-shadow: 0 0 8px rgba(253, 224, 71, 0.35);
}
.preach-deviation-spot {
    font-size: 13px;
    margin-top: 12px;
}

/* Month divider — sits between rows whenever the month changes.
   Tinted with the new month's accent so the boundary is visually
   color-coordinated with the rows below it. */
.preach-month-divider {
    margin: 14px 0 10px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    gap: 14px;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: color-mix(in oklab, var(--row-accent, var(--text-muted)) 70%, var(--text-primary));
}
.preach-month-divider::before,
.preach-month-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg,
        transparent,
        color-mix(in oklab, var(--row-accent, var(--border-strong)) 55%, transparent) 50%,
        transparent);
}
.preach-month-label {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid color-mix(in oklab, var(--row-accent, var(--border-strong)) 35%, transparent);
    background: color-mix(in oklab, var(--row-accent, var(--border-strong)) 12%, transparent);
}
/* First divider in a timeline shouldn't carry the big top gap (the
   card already provides padding). */
.preach-timeline > .preach-month-divider:first-child { margin-top: 4px; }
.evt-timeline      > .preach-month-divider:first-child { margin-top: 4px; }

/* ---------- Event timeline rows (mirrors preaching glass rows) ------ */
/* Same visual language as .preach-row: glass-morphism surface tinted
   by --row-accent (set per-row from the event's month), alternating
   brightness, lift on hover. Two columns on desktop ≥1100px. */
.evt-timeline { display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 1100px) {
    .evt-timeline {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 14px;
        row-gap: 16px;
    }
    .evt-timeline > .preach-month-divider { grid-column: 1 / -1; }
}
.evt-row {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 14px;
    align-items: center;
    padding: 12px 16px 12px 18px;
    border-radius: var(--radius-md);
    position: relative;
    background:
        linear-gradient(90deg,
            color-mix(in oklab, var(--row-accent, var(--border-strong)) 22%, transparent) 0%,
            color-mix(in oklab, var(--row-accent, var(--border-strong))  8%, transparent) 55%,
            color-mix(in oklab, var(--row-accent, var(--border-strong))  2%, transparent) 100%),
        rgba(255, 255, 255, 0.025);
    backdrop-filter: blur(10px) saturate(140%);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
    border: 1px solid color-mix(in oklab, var(--row-accent, var(--border-strong)) 22%, transparent);
    border-left: 4px solid var(--row-accent, var(--border-strong));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.045),
        0 1px 2px rgba(0, 0, 0, 0.18);
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}
.evt-row:nth-child(even) {
    background:
        linear-gradient(90deg,
            color-mix(in oklab, var(--row-accent, var(--border-strong)) 14%, transparent) 0%,
            color-mix(in oklab, var(--row-accent, var(--border-strong))  6%, transparent) 50%,
            color-mix(in oklab, var(--row-accent, var(--border-strong))  1%, transparent) 100%),
        rgba(255, 255, 255, 0.04);
}
.evt-row:hover {
    background:
        linear-gradient(90deg,
            color-mix(in oklab, var(--row-accent, var(--border-strong)) 32%, transparent) 0%,
            color-mix(in oklab, var(--row-accent, var(--border-strong)) 12%, transparent) 55%,
            color-mix(in oklab, var(--row-accent, var(--border-strong))  3%, transparent) 100%),
        rgba(255, 255, 255, 0.06);
    border-color: color-mix(in oklab, var(--row-accent, var(--border-strong)) 38%, transparent);
    transform: translateY(-1px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.07),
        0 6px 18px -8px color-mix(in oklab, var(--row-accent, var(--border-strong)) 55%, transparent),
        0 2px 4px rgba(0, 0, 0, 0.25);
}
.evt-date {
    text-align: center;
    line-height: 1.05;
    padding: 6px 4px;
    border-radius: 8px;
    background: color-mix(in oklab, var(--row-accent, var(--border-strong)) 14%, rgba(0, 0, 0, 0.18));
    border: 1px solid color-mix(in oklab, var(--row-accent, var(--border-strong)) 25%, transparent);
}
.evt-date-wd {
    font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--row-accent, var(--primary-on-dark));
}
.evt-date-day {
    font-family: var(--font-display); font-size: 22px; font-weight: 600;
    line-height: 1; color: var(--text-primary);
}
.evt-date-mo {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-subtle);
}
.evt-date-time {
    font-family: var(--font-mono); font-size: 10px; color: var(--text-muted);
    margin-top: 3px; padding-top: 3px;
    border-top: 1px solid color-mix(in oklab, var(--row-accent, var(--border-strong)) 25%, transparent);
}
.evt-body { min-width: 0; }
.evt-row-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.evt-row-title a { color: inherit; text-decoration: none; }
.evt-row-title a:hover { color: var(--primary-on-dark); }
.evt-row-location {
    font-size: 12.5px; color: var(--text-muted); margin-top: 2px;
}
.evt-row-tags {
    display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap;
    margin-top: 6px;
}

/* Icon button (share / copy / link) ---------------------------------- */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.icon-btn:hover {
    background: var(--bg-raised);
    color: var(--text-primary);
    border-color: var(--border-subtle);
    text-decoration: none;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.wide { width: auto; padding: 0 12px; font-size: 12.5px; font-weight: 600; }

/* Media link button (Listen / Watch) --------------------------------- */
.media-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--accent-on-dark);
    background: var(--accent-soft);
    border-radius: 999px;
    padding: 3px 11px;
}
.media-link:hover { filter: brightness(1.1); text-decoration: none; }
.media-link svg { width: 13px; height: 13px; }

/* ---------- Share toast --------------------------------------------- */
.share-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%) translateY(12px);
    background: var(--bg-raised);
    border: 1px solid var(--border-strong);
    color: var(--text-primary);
    font-size: 13.5px;
    font-weight: 500;
    padding: 10px 18px;
    border-radius: 999px;
    box-shadow: 0 16px 40px -18px rgba(0, 0, 0, 0.7);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 1200;
}
.share-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.share-toast svg { width: 15px; height: 15px; color: var(--accent-on-dark); }
@media (prefers-reduced-motion: reduce) {
    .share-toast { transition: opacity 0.18s ease; transform: translateX(-50%); }
    .preach-row { transition: none; }
}

/* =====================================================================
   NAV: utility dropdown + gear icon
   ===================================================================== */

/* Utility dropdown, built on native <details> (no JS, keyboard-friendly). */
.nav-dd { position: relative; }
.nav-dd > summary {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    user-select: none;
}
.nav-dd > summary::-webkit-details-marker { display: none; }
.nav-dd > summary::marker { content: ""; }
.nav-dd > summary:hover,
.nav-dd[open] > summary,
.nav-dd > summary.active {
    color: var(--primary-on-dark);
    background: rgba(122, 168, 245, 0.18);
}
.nav-dd-caret { font-size: 10px; line-height: 1; opacity: 0.8; }
.nav-dd[open] .nav-dd-caret { transform: rotate(180deg); }
.nav-dd-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    min-width: 168px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 18px 44px -20px rgba(0, 0, 0, 0.7);
    z-index: 60;
}
.nav-dd-menu a {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
}
.nav-dd-menu a.active,
.nav-dd-menu a:hover {
    color: var(--primary-on-dark);
    background: var(--bg-raised);
    text-decoration: none;
}

/* Gear icon link for Settings. */
.topbar .nav a.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px;
}
.topbar .nav a.nav-icon svg { width: 18px; height: 18px; display: block; }

/* =====================================================================
   STAFF DIRECTORY
   ===================================================================== */
.staff-section + .staff-section { margin-top: 16px; }
.staff-section-title {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px;
}
.staff-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
    margin-top: 12px;
}
.staff-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background:
        linear-gradient(135deg,
            color-mix(in oklab, var(--primary-on-dark) 12%, transparent) 0%,
            color-mix(in oklab, var(--primary-on-dark)  4%, transparent) 60%,
            transparent 100%),
        var(--bg-raised);
    backdrop-filter: blur(8px) saturate(130%);
    -webkit-backdrop-filter: blur(8px) saturate(130%);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.04),
        0 2px 6px rgba(0, 0, 0, 0.18);
    transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.15s ease;
}
.staff-card:hover {
    transform: translateY(-1px);
    border-color: color-mix(in oklab, var(--primary-on-dark) 30%, transparent);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 6px 16px -8px color-mix(in oklab, var(--primary-on-dark) 35%, transparent),
        0 2px 4px rgba(0, 0, 0, 0.25);
}
.staff-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-soft);
    color: var(--primary-on-dark);
    font-size: 17px;
    font-weight: 700;
    font-family: var(--font-display);
}
.staff-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.staff-body { min-width: 0; }
.staff-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.staff-roles {
    margin-top: 3px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.staff-role {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--primary-on-dark);
    line-height: 1.3;
}
.staff-contact {
    margin-top: 5px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.staff-contact a {
    font-size: 12.5px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}
.staff-contact a:hover { color: var(--primary-on-dark); }

/* The leader sits in the lineup like everyone else, but highlighted: a
   tan fill and bold text. Text darkened for legibility on the lighter
   background. */
.staff-card.is-leader {
    background: #a18d69;
    border-color: #8a774f;
}
.staff-card.is-leader .staff-name { color: #1b1205; font-weight: 700; }
.staff-card.is-leader .staff-role { color: #4a3a17; font-weight: 700; }
.staff-card.is-leader .staff-contact a { color: #3f3318; font-weight: 600; }
.staff-card.is-leader .staff-contact a:hover { color: #1b1205; }
.staff-card.is-leader .staff-avatar {
    background: rgba(27, 18, 5, 0.18);
    color: #1b1205;
}
/* Non-leader lineup members: cool midnight-blue (the header/section color)
   to complement the warm tan leader. Dark enough that the default light
   card text stays legible. */
.ministry-lineup .staff-card:not(.is-leader) {
    background: var(--color-section, #1C234B);
    border-color: rgba(230, 237, 243, 0.14);
}

/* ---------- Ministry lineup editor ---------------------------------- */
.lineup-filter {
    width: 100%;
    max-width: 320px;
    margin-bottom: 12px;
    padding: 8px 11px;
    background: var(--bg-page);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
}
.lineup-filter:focus { outline: none; border-color: var(--primary-on-dark); }
.lineup-list {
    max-height: 360px;
    overflow-y: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 4px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1px;
}
.lineup-opt {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
}
.lineup-opt:hover { background: var(--bg-raised); }
.lineup-opt input { accent-color: var(--accent-on-dark); flex-shrink: 0; }

/* Section heading with a count chip ---------------------------------- */
.preach-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}
.preach-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-subtle);
    background: var(--bg-raised);
    border-radius: 999px;
    padding: 2px 9px;
}

/* =====================================================================
 * Calendar notes — informational annotations rendered alongside events
 * added 2026-06
 *
 * Notes use the same .cal-event-style chip geometry but with a dashed
 * left border, italic title, and a slight muted/warm tint so they read
 * as "info" rather than "scheduled event."
 * ===================================================================*/

.cal-note {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11.5px;
    color: var(--text-primary);
    line-height: 1.3;
    cursor: pointer;
    transition: filter 100ms ease, transform 100ms ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: rgba(245, 158, 11, 0.10);          /* warm, neutral fallback */
    border-left: 3px dashed var(--status-warning);
    text-decoration: none;
    font-style: italic;
}
.cal-note:hover { filter: brightness(1.15); transform: translateX(1px); text-decoration: none; }
.cal-note .note-icon {
    width: 11px; height: 11px;
    color: var(--text-subtle);
    flex-shrink: 0;
}
.cal-note .note-title { overflow: hidden; text-overflow: ellipsis; }
.cal-note .note-who   {
    font-family: var(--font-mono);
    font-style: normal;
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Multi-day notes: same bar treatment as events.multi but with the
 * dashed border feel preserved on the start cap. */
.cal-note.multi {
    border-radius: 0;
    border-left: none;
    border-top: 1px dashed var(--status-warning);
    border-bottom: 1px dashed var(--status-warning);
    padding: 2px 8px;
    margin-left: -7px;
    margin-right: -7px;
}
.cal-note.multi.start {
    border-top-left-radius: 3px;
    border-bottom-left-radius: 3px;
    border-left: 3px dashed var(--status-warning);
    margin-left: 0;
}
.cal-note.multi.end {
    border-top-right-radius: 3px;
    border-bottom-right-radius: 3px;
    margin-right: 0;
}

/* Day-view: bigger note row, mirrors .cal-day-event but lighter. */
.cal-day-note {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 16px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-subtle);
    text-decoration: none;
    color: inherit;
    border-left: 3px dashed var(--status-warning);
    background: rgba(245, 158, 11, 0.04);
    transition: background 120ms ease;
}
.cal-day-note:hover { background: rgba(245, 158, 11, 0.10); text-decoration: none; }
.cal-day-note-time {
    text-align: right;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    padding-top: 4px;
}
.cal-day-note-body { min-width: 0; }
.cal-day-note-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
    font-style: italic;
}
.cal-day-note-meta {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 4px;
}
.cal-day-note-desc {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 8px;
    line-height: 1.5;
    font-style: normal;
}

/* Agenda-view: compact note row. */
.cal-agenda-note {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 14px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
    text-decoration: none;
    color: inherit;
    border-left: 3px dashed var(--status-warning);
    background: rgba(245, 158, 11, 0.04);
    transition: background 120ms ease;
}
.cal-agenda-note:hover { background: rgba(245, 158, 11, 0.10); text-decoration: none; }
.cal-agenda-note-time {
    font-size: 13px;
    color: var(--text-muted);
    padding-top: 1px;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    font-size: 11px;
}
.cal-agenda-note-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
    font-style: italic;
}
.cal-agenda-note-meta {
    font-size: 12px;
    color: var(--text-subtle);
    margin-top: 4px;
}

/* =====================================================================
 * Calendar help page — TOC sidebar + long-form content sections
 * added 2026-06
 * ===================================================================*/

.help-grid {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 28px;
    align-items: start;
}
.help-toc {
    position: sticky;
    top: 88px;
    align-self: start;
    background: rgba(22, 27, 34, 0.65);
    border: 1px solid rgba(230, 237, 243, 0.08);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    backdrop-filter: blur(18px) saturate(120%);
    -webkit-backdrop-filter: blur(18px) saturate(120%);
    max-height: calc(100vh - 110px);
    overflow-y: auto;
}
.help-toc-title {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}
.help-toc a {
    display: block;
    padding: 6px 8px;
    color: var(--text-muted);
    font-size: 13px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    line-height: 1.4;
    transition: all 120ms ease;
}
.help-toc a:hover,
.help-toc a:focus {
    background: var(--primary-soft);
    color: var(--primary-on-dark);
    text-decoration: none;
}
.help-toc a.sub {
    padding-left: 22px;
    font-size: 12px;
    color: var(--text-subtle);
}

.help-section { scroll-margin-top: 88px; }
.help-section h2 {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 500;
    color: var(--primary-on-dark);
    letter-spacing: -0.015em;
    margin: 0 0 4px;
}
.help-section .help-sub {
    color: var(--text-subtle);
    font-size: 13px;
    margin-bottom: 16px;
}
.help-section h3 {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 24px 0 10px;
}
.help-section p { line-height: 1.65; margin: 0 0 12px; }
.help-section ul { margin: 0 0 12px; padding-left: 22px; line-height: 1.65; }
.help-section ul li + li { margin-top: 4px; }
.help-section code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--bg-raised);
    padding: 1px 6px;
    border-radius: 3px;
    color: var(--primary-on-dark);
}

/* Callout box for important / pro tip / heads-up content. */
.help-callout {
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin: 14px 0;
    border-left: 3px solid;
    display: grid;
    grid-template-columns: 22px 1fr;
    gap: 12px;
    align-items: start;
}
.help-callout.info {
    background: var(--primary-soft);
    border-left-color: var(--primary-on-dark);
    color: var(--text-primary);
}
.help-callout.tip {
    background: var(--accent-soft);
    border-left-color: var(--accent-on-dark);
}
.help-callout.warn {
    background: rgba(245, 158, 11, 0.12);
    border-left-color: var(--status-warning);
}
.help-callout svg { width: 22px; height: 22px; }
.help-callout strong { display: block; margin-bottom: 4px; }
.help-callout p { margin: 0; font-size: 13px; line-height: 1.55; }

/* Mini-screenshot frame — wraps real .cal-* example chips to look like
 * an inline screenshot. */
.help-shot {
    background: var(--bg-page);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px;
    margin: 10px 0 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.help-shot .help-shot-caption {
    font-size: 11px;
    color: var(--text-subtle);
    margin-top: 6px;
    font-style: italic;
    text-align: center;
}

/* Keyboard / right-click hint chips. */
.kbd {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 2px 7px;
    background: var(--bg-raised);
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 4px;
    color: var(--text-primary);
    line-height: 1.4;
}

/* Ministry color swatch table. */
.help-color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
    margin: 10px 0 14px;
}
.help-color-swatch {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 12px;
}
.help-color-swatch .dot {
    width: 14px; height: 14px;
    border-radius: 4px;
    flex-shrink: 0;
    margin-right: 0;
}

/* Right-click menu reference table. */
.help-menu-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin: 10px 0 16px;
}
.help-menu-list .help-menu-row {
    display: grid;
    grid-template-columns: 200px 1fr auto;
    gap: 14px;
    padding: 10px 14px;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-card);
}
.help-menu-list .help-menu-row:last-child { border-bottom: none; }
.help-menu-list .help-menu-row.head {
    background: var(--bg-raised);
    font-size: 11px;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.help-menu-list .help-menu-label {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 600;
}
.help-menu-list .help-menu-desc {
    font-size: 12.5px;
    color: var(--text-muted);
}
.help-menu-list .help-menu-perm {
    font-size: 10px;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    white-space: nowrap;
}

@media (max-width: 980px) {
    .help-grid { grid-template-columns: 1fr; }
    .help-toc { position: static; max-height: none; }
    .help-menu-list .help-menu-row { grid-template-columns: 1fr; gap: 4px; }
}

/* =====================================================================
 * Lineup picker — pills + autocomplete-add  (used by Ministries lineup
 * editor; generic enough to reuse elsewhere)
 * added 2026-06
 * ===================================================================*/
.lineup-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
    min-height: 38px;
    padding: 8px;
    border: 1px dashed var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-raised);
}
.lineup-pills:empty::before,
.lineup-pills.is-empty::before {
    content: 'No one on lineup yet — add the first person below.';
    color: var(--text-subtle);
    font-size: 12px;
    font-style: italic;
    padding: 6px 4px;
}
.lineup-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 3px 4px 3px 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    font-size: 13px;
}
.lineup-pill .lineup-pill-avatar {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2952C8, #1E40AF);
    color: #FFFFFF;
    font-size: 10px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.lineup-pill .lineup-pill-name {
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
}
.lineup-pill .lineup-pill-remove {
    background: transparent;
    border: 0;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    width: 22px; height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 100ms ease;
}
.lineup-pill .lineup-pill-remove:hover {
    background: rgba(248, 113, 113, 0.20);
    color: var(--status-error);
}
.lineup-add-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
    margin-bottom: 14px;
}
.lineup-add-row input[type="text"] {
    flex: 1;
    background: var(--bg-raised);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 8px 10px;
    font: inherit;
    font-size: 14px;
}
.lineup-add-row input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-on-dark);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.lineup-add-row .button { white-space: nowrap; }
.lineup-add-row .lineup-add-hint {
    align-self: center;
    font-size: 12px;
    color: var(--status-warning);
    margin-left: 4px;
}

/* ---------- Attendance grid --------------------------------------- */
.att-scroll {
    overflow-x: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    -webkit-overflow-scrolling: touch;
}
/* Fluid name-column width: narrower on an 8" tablet, wider on a 10".
   The present column pins to this same var so its offset always matches. */
.att-grid { border-collapse: collapse; width: 100%; font-size: 14px; --att-name-w: clamp(148px, 26vw, 210px); }
.att-grid th, .att-grid td { border-bottom: 1px solid var(--border-subtle); }

/* Name + present column are both pinned left so identity and the tap
   target stay together while the history columns scroll. */
.att-name-col {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--bg-card);
    text-align: left;
    width: var(--att-name-w);
    min-width: var(--att-name-w);
    max-width: var(--att-name-w);
    padding: 0;
}
.att-grid thead .att-name-col {
    z-index: 3;
    padding: 10px 12px;
    color: var(--text-muted);
    font-weight: 600;
}
.att-date-col {
    min-width: 52px;
    padding: 10px 6px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.att-date-col.att-current {
    position: sticky;
    left: var(--att-name-w);
    z-index: 3;
    color: var(--primary-on-dark);
    /* Layered so the tint stays opaque over scrolling history columns. */
    background: linear-gradient(0deg, var(--primary-soft), var(--primary-soft)), var(--bg-card);
    font-weight: 700;
    box-shadow: 1px 0 0 var(--border-strong);
}

/* Household separator rows. */
.att-group td {
    position: sticky;
    left: 0;
    background: var(--color-section, #1C234B);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 7px 12px;
}

/* Name button — large touch target, reveals photo (wired next chunk). */
.att-name {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 48px;
    padding: 6px 12px;
    background: none;
    border: 0;
    color: var(--text-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.att-name:hover { background: var(--bg-raised); }
.att-name-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-age { color: var(--text-subtle); font-size: 12px; }

.att-badge {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 700;
}
.att-badge-H { background: var(--primary-soft); color: var(--primary-on-dark); }
.att-badge-S { background: rgba(245, 158, 11, 0.14); color: var(--status-warning); }
.att-badge-P { background: var(--bg-raised); color: var(--text-muted); }
.att-badge-C { background: var(--accent-soft); color: var(--accent-on-dark); }

/* Cells. Current column is the wide tappable target; context columns
   are compact read-only dots. */
.att-cell {
    text-align: center;
    vertical-align: middle;
    height: 48px;
}
.att-cell.att-current {
    position: sticky;
    left: var(--att-name-w);
    z-index: 1;
    min-width: 72px;
    /* Opaque (layered tint) so history scrolls cleanly underneath; the
       shadow separates the pinned pair from the scrolling history. */
    background: linear-gradient(0deg, rgba(122, 168, 245, 0.06), rgba(122, 168, 245, 0.06)), var(--bg-card);
    box-shadow: 1px 0 0 var(--border-strong);
}
.att-context.is-present::after {
    content: "";
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent-on-dark);
    opacity: 0.55;
}
/* Current column renders as a real checkbox: an empty box when not yet
   marked (so unmarked rows are obvious), a filled green check when present.
   This is the completion aid for the person walking the roster. */
.att-cell.att-current::after {
    content: "";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-strong);
    border-radius: 6px;
    box-sizing: border-box;
    color: var(--bg-page);
    font-size: 15px;
    font-weight: 800;
}
.att-cell.att-current.is-present::after {
    content: "\2713"; /* check */
    background: var(--accent-on-dark);
    border-color: var(--accent-on-dark);
}

/* ---------- Attendance: interactive states ----------------------- */
.att-takeable .att-cell.att-current { cursor: pointer; }
.att-takeable .att-cell.att-current:hover {
    background: linear-gradient(0deg, rgba(122, 168, 245, 0.14), rgba(122, 168, 245, 0.14)), var(--bg-card);
}
.att-takeable .att-cell.att-current:active {
    background: linear-gradient(0deg, rgba(122, 168, 245, 0.22), rgba(122, 168, 245, 0.22)), var(--bg-card);
}

/* Pending = optimistic change not yet confirmed by the server. Opaque so
   it reads correctly over the scrolling history underneath. */
.att-cell.att-pending {
    background: linear-gradient(0deg, rgba(245, 158, 11, 0.20), rgba(245, 158, 11, 0.20)), var(--bg-card) !important;
    box-shadow: inset 0 0 0 2px var(--status-warning);
}

/* Non-blocking photo preview pinned to the grid's top-right, below the
   frozen header. The grid scrolls/marks underneath; only the small area
   it covers (history columns) is obscured, never the left checkboxes. */
.att-gridwrap { position: relative; }
.att-photo-panel {
    position: absolute;
    right: 12px;
    z-index: 30;
    width: clamp(150px, 22vw, 200px);
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 8px;
    box-shadow: 0 18px 44px -18px rgba(0, 0, 0, 0.7);
}
.att-photo-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius-md);
    display: block;
    background: var(--bg-raised);
}
.att-photo-name {
    margin-top: 6px;
    font-family: var(--font-display);
    font-size: 15px;
    color: var(--text-primary);
    text-align: center;
}
.att-photo-close {
    position: absolute;
    top: 4px;
    right: 6px;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 50%;
    background: rgba(13, 17, 23, 0.6);
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}
.att-photo-close:hover { background: rgba(13, 17, 23, 0.85); }

/* Highlight the roster name whose photo is being previewed. */
.att-name.att-name-active {
    background: var(--primary-soft);
    box-shadow: inset 3px 0 0 var(--primary-on-dark);
}

/* Toast. */
.att-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%) translateY(8px);
    z-index: 1001;
    background: var(--bg-raised);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.att-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* The brand indigo (--color-section, as on the members page) marks each
   family's header line — see .att-group above. Person rows stay neutral. */

/* ---------- Attendance: sticky header, search, all-present ------- */
/* Make the grid a two-axis scroll region so the date header can freeze
   on vertical scroll (name + present already freeze on horizontal). */
/* Fallback height; attendance.js refines it to fill the exact space left
   below the controls on whatever device/orientation is in use. */
.att-scroll { overflow: auto; max-height: 70dvh; }
.att-grid thead th { position: sticky; top: 0; z-index: 5; background: var(--bg-card); }
.att-grid thead .att-name-col { z-index: 6; }                 /* frozen corner */
.att-grid thead .att-date-col.att-current { z-index: 6; }     /* frozen corner */

.att-searchbar { margin-bottom: 12px; display: flex; align-items: center; }
.att-searchbar input {
    width: 100%;
    max-width: 360px;
    background: var(--bg-raised);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 9px 12px;
    font: inherit;
    font-size: 14px;
}
.att-searchbar input:focus {
    outline: none;
    border-color: var(--primary-on-dark);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.att-searchbar #att-search-empty { margin-left: 10px; font-size: 13px; }
.att-searchbar .att-search-hint { margin-left: 14px; font-size: 13px; font-style: italic; }

.att-group-row { display: flex; align-items: center; gap: 12px; }
.att-allpresent {
    border: 1px solid rgba(230, 237, 243, 0.25);
    background: rgba(230, 237, 243, 0.08);
    color: var(--text-primary);
    border-radius: 5px;
    padding: 2px 9px;
    font-size: 11px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    white-space: nowrap;
    cursor: pointer;
}
.att-allpresent:hover { background: rgba(230, 237, 243, 0.18); }

/* ---------- Installed PWA / touch: larger, readable defaults -------
   Most sizing is in fixed px, so bump it explicitly when running as an
   installed app (display-mode: standalone) or on a touch device. Desktop
   mouse browsers are unaffected. Tuned for the attendance tablet. */
@media (display-mode: standalone), (pointer: coarse) {
    body.app-body { font-size: 16px; }

    /* General form controls a bit larger for fingertips. */
    .field label { font-size: 15px; }
    .field input, .field select, .field textarea { font-size: 16px; padding: 11px 12px; }

    /* Attendance grid: bigger text + roomier touch targets. */
    .att-grid { font-size: 17px; --att-name-w: clamp(176px, 30vw, 248px); }
    .att-name { min-height: 60px; }
    .att-name-text { font-size: 17px; }
    .att-age { font-size: 14px; }
    .att-badge { width: 26px; height: 26px; font-size: 13px; }

    .att-date-col { font-size: 16px; min-width: 66px; padding: 14px 8px; }
    .att-cell { height: 62px; }
    .att-cell.att-current { min-width: 96px; }
    .att-cell.att-current::after { width: 30px; height: 30px; font-size: 19px; }
    .att-context.is-present::after { width: 13px; height: 13px; }

    .att-group td { font-size: 14px; padding: 10px 14px; }
    .att-allpresent { font-size: 13px; padding: 5px 12px; }

    .att-searchbar input { max-width: 460px; font-size: 17px; padding: 12px 14px; }

    /* Photo preview scaled up to match. */
    .att-photo-panel { width: clamp(180px, 26vw, 240px); }
    .att-photo-name { font-size: 17px; }
}

/* ---------- Installed PWA: lock to the attendance screen ----------
   Only the installed app (display-mode: standalone) — browser tabs keep
   the full nav. Hides the nav bar, drops the width cap, and runs the
   content edge-to-edge so the attendance table fills the tablet. */
@media (display-mode: standalone) {
    .topbar .nav { display: none; }
    .topbar { padding: 8px 14px; }
    .user-menu .user-link { display: none; }   /* keep only Sign out */
    .att-reports-link { display: none; }        /* stay locked to the grid */

    main.container { max-width: none; margin: 0; padding: 6px; }
    .page-header { margin-bottom: 8px; }
}

/* ---------- Children's-room kiosk -------------------------------- */
.kiosk-body { padding: 0; }
.kiosk-top {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 20px;
    background: var(--color-section, #1C234B);
    border-bottom: 1px solid var(--border-strong);
}
.kiosk-room { font-family: var(--font-display); font-size: 26px; font-weight: 600; color: var(--text-primary); }
.kiosk-date { font-size: 14px; color: var(--text-muted); }
.kiosk-count { font-size: 16px; color: var(--text-muted); }
.kiosk-count strong { color: var(--accent-on-dark); font-size: 22px; }

.kiosk-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
    padding: 16px;
}
.kiosk-cell {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 92px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.kiosk-cell:active { transform: scale(0.99); }
.kiosk-check {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border: 2px solid var(--border-strong);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 800;
    color: var(--bg-page);
}
.kiosk-cell.is-present {
    border-color: var(--accent-on-dark);
    background: linear-gradient(0deg, var(--accent-soft), var(--accent-soft)), var(--bg-card);
}
.kiosk-cell.is-present .kiosk-check {
    background: var(--accent-on-dark);
    border-color: var(--accent-on-dark);
}
.kiosk-cell.is-present .kiosk-check::after { content: "\2713"; }
.kiosk-name { font-size: 19px; font-weight: 600; flex: 1; }
.kiosk-age { color: var(--text-subtle); font-size: 15px; }
.kiosk-cell.kiosk-pending { box-shadow: inset 0 0 0 2px var(--status-warning); }
