:root {
  --gold: #8a6a1e;
  --gold-soft: #c9b47a;
  --gold-faint: #f3ecd9;
  --ink: #222;
  --muted: #6b6457;
  --paper: #fffdf8;
  --bg: #f4efe4;
  --danger: #9b2f2f;
  --ok: #2f6b3a;
  --serif: "EB Garamond", Garamond, "Times New Roman", Times, serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* keep the hidden attribute authoritative over display rules */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--serif); font-size: 18px; line-height: 1.45; color: var(--ink); background: var(--bg); }
a { color: var(--gold); }
a:hover { color: #6f5314; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: 8px; }
.skip:focus { left: 8px; z-index: 10; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--gold); font: inherit; cursor: pointer; text-decoration: underline; }

/* Header / nav */
.site-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 10px 16px; background: var(--paper); border-bottom: 1px solid var(--gold-soft); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: 1.15em; }
.brand .chapel { width: 28px; height: 28px; border-radius: 6px; }
.site-nav { display: flex; flex-wrap: wrap; gap: 0 12px; font-size: .92em; }
.site-nav a { text-decoration: none; color: var(--muted); padding: 10px 2px; min-height: 44px; display: inline-flex; align-items: center; border-bottom: 2px solid transparent; }
.site-nav a.active, .site-nav a:hover { color: var(--gold); border-bottom-color: var(--gold); }
.site-nav .edit-link { color: var(--ok); font-weight: 600; }

.page { max-width: 880px; margin: 0 auto; padding: 24px 16px 40px; }
.flash { padding: 10px 14px; border-radius: 6px; margin: 0 0 16px; border: 1px solid; }
.flash-ok { background: #eef6ee; border-color: #b9d6bd; color: var(--ok); }
.flash-err { background: #fbeeee; border-color: #e3bcbc; color: var(--danger); }

/* Program card (page 1) */
.program-card { background: var(--paper); border: 1px solid var(--gold-soft); padding: 8px; box-shadow: 0 4px 24px rgba(80, 60, 10, .08); }
.program-inner { border: 1px solid var(--gold-soft); padding: 28px 24px 24px; text-align: center; }
.ornament-chapel { width: 96px; height: 96px; border-radius: 16px; }
.program-inner h1 { margin: 6px 0 0; font-size: 2.2em; font-weight: 700; letter-spacing: .01em; }
.program-inner .tagline { margin: 2px 0; font-style: italic; color: var(--gold); font-size: 1.25em; }
.program-inner .date { margin: 2px 0 14px; font-size: 1.05em; }
.presiding { margin: 0; }
.visiting { margin: 0; font-style: italic; font-size: .92em; }
.welcome { margin: 0; font-style: italic; color: var(--gold); font-size: .92em; }
.rule { display: flex; align-items: center; gap: 12px; color: var(--gold); margin: 18px 0 12px; }
.rule::before, .rule::after { content: ""; flex: 1; border-top: 1px solid var(--gold-soft); }
.rule span { font-size: .8em; }
.agenda { margin: 0; text-align: left; }
.agenda .row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; margin: 0 0 8px; }
.agenda dt { font-weight: 700; color: var(--gold); }
.agenda dd { margin: 0; text-align: right; }
.agenda dd.note { grid-column: 1 / -1; font-style: italic; color: var(--gold); font-size: .88em; }
.agenda dd.note.center { text-align: center; }
.agenda-heading { text-align: center; color: var(--gold); font-size: 1em; letter-spacing: .28em; text-transform: uppercase; margin: 14px 0 10px; font-weight: 700; }
.actions { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.btn { display: inline-block; background: var(--gold); color: #fff; border: 1px solid var(--gold); padding: 9px 18px; border-radius: 4px; text-decoration: none; font: inherit; font-size: .95em; cursor: pointer; }
.btn:hover { background: #6f5314; color: #fff; }
.btn-ghost { background: transparent; color: var(--gold); }
.btn-ghost:hover { background: var(--gold-faint); color: var(--gold); }
.btn-sm { padding: 4px 10px; font-size: .85em; }
.btn-danger { background: transparent; color: var(--danger); border-color: #d8b2b2; }
.btn-danger:hover { background: #fbeeee; color: var(--danger); }

/* Groups */
.groups { margin-top: 36px; }
.groups h2 { text-align: center; font-weight: 600; color: var(--gold); letter-spacing: .04em; }
.announce-preview { list-style: none; padding: 0; margin: 0 0 20px; text-align: center; }
.announce-preview li { margin: 4px 0; }
.announce-preview a { text-decoration: none; color: var(--ink); }
.announce-preview a:hover { color: var(--gold); }
.group-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.group-card { display: block; background: var(--paper); border: 1px solid var(--gold-soft); padding: 16px 18px; text-decoration: none; color: var(--ink); border-radius: 4px; transition: box-shadow .15s; }
.group-card:hover { box-shadow: 0 4px 18px rgba(80, 60, 10, .12); color: var(--ink); }
.group-name { display: block; font-weight: 700; font-size: 1.15em; color: var(--gold); }
.group-sub { display: block; color: var(--muted); font-size: .9em; }

/* Sheet pages (announcements / orgs) */
.sheet { background: var(--paper); border: 1px solid var(--gold-soft); padding: 28px 28px 24px; box-shadow: 0 4px 24px rgba(80, 60, 10, .08); }
.sheet.narrow { max-width: 460px; margin: 0 auto; }
.sheet-head { text-align: center; }
.sheet-head h1 { margin: 0; font-size: 2em; }
.sheet-head .tagline { margin: 2px 0 0; font-style: italic; color: var(--gold); }
.sheet-head .muted { margin: 0; }
.intro { font-style: italic; }
.announce-list { list-style: none; padding: 0; margin: 0; }
.announce-list li { margin: 0 0 14px; }
.announce-list h2, .announce-list h3 { margin: 0; font-size: 1.1em; color: var(--gold); font-weight: 700; }
.announce-list p { margin: 2px 0 0 18px; }
.announce-list .when { color: var(--muted); font-size: .9em; font-style: italic; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 32px; margin-top: 8px; }
.two-col h3 { color: var(--gold); margin: 14px 0 6px; font-size: 1.05em; }
.two-col p { margin: 0 0 8px; }
.lessons, .leaders { border-collapse: collapse; width: 100%; }
.lessons th, .leaders th { text-align: left; font-weight: 700; padding: 3px 12px 3px 0; vertical-align: top; white-space: nowrap; }
.lessons td, .leaders td { padding: 3px 0; vertical-align: top; }
.lessons em { color: var(--gold); font-size: .9em; }
.plain { list-style: none; padding: 0; margin: 0; }

/* Footer */
.site-footer { max-width: 880px; margin: 0 auto; padding: 8px 16px 40px; text-align: center; color: var(--muted); font-size: .85em; }
.site-footer .scripture { font-style: italic; color: var(--gold); font-size: 1.05em; }
.site-footer .contact span { display: inline-block; margin: 0 8px; }
.site-footer .disclaimer { max-width: 680px; margin: 10px auto; }

/* PWA */
.sheet-center { text-align: center; }
.offline-mark { border-radius: 12px; }
.site-footer .links a, .site-footer .links .linkbtn { display: inline-block; padding: 12px 4px; min-height: 44px; }
.site-footer .updated { color: var(--muted); font-size: .9em; }
.offline-banner { background: #fff3cd; color: #6b5200; text-align: center; padding: 8px 12px; font-size: .9em; border-bottom: 1px solid #e6d28a; }
.install-box { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 20; display: flex; align-items: center; gap: 12px; background: var(--paper); border: 1px solid var(--gold-soft); border-radius: 10px; padding: 10px 12px; box-shadow: 0 6px 24px rgba(60, 40, 0, .18); max-width: 520px; margin: 0 auto; }
.install-box img { border-radius: 8px; flex: none; }
.install-text { display: flex; flex-direction: column; gap: 4px; font-size: .92em; flex: 1; }
.install-close { background: none; border: 0; font-size: 1.1em; color: var(--muted); cursor: pointer; padding: 10px; flex: none; }
.install-close:hover { color: var(--danger); }

/* Block pages */
.org-card .intro { font-style: italic; text-align: center; margin: 12px 0 0; }
.org-card .intro.small { font-size: .95em; color: var(--muted); }
.block { position: relative; text-align: left; margin: 0 0 12px; }
.block-heading { margin-top: 4px; }
.block .b-title { margin: 0; font-size: 1.1em; color: var(--gold); font-weight: 700; }
.block .when { margin: 0 0 0 18px; color: var(--muted); font-size: .9em; font-style: italic; }
.block .b-body { margin: 2px 0 0 18px; white-space: pre-line; }
.block .b-section-title { margin: 6px 0 2px; font-size: 1.05em; color: var(--gold); }
.block .lesson-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.block .lesson-row dt { font-weight: 700; color: var(--gold); }
.block .lesson-row dd { margin: 0; text-align: right; }
.block .lesson-row dd.note { grid-column: 1 / -1; font-style: italic; color: var(--gold); font-size: .88em; }
.b-scripture { margin: 10px 24px; text-align: center; font-style: italic; color: var(--gold); }
.b-scripture cite { font-style: normal; font-size: .9em; }
.b-photo { margin: 14px auto; max-width: 560px; text-align: center; }
.photo-frame { border: 1px solid var(--gold-soft); padding: 6px; background: var(--paper); }
.photo-frame img { display: block; width: 100%; height: auto; border: 1px solid var(--gold-soft); }
.photo-frame.small-frame { max-width: 320px; }
.b-photo figcaption { margin-top: 6px; font-style: italic; color: var(--gold); font-size: .92em; }
.b-attachment { margin: 6px 0 0; }
.b-attachment a { text-decoration: none; font-weight: 600; }
.block-expired { opacity: .5; }
.back-link { text-align: center; margin: 18px 0 0; }
.draft-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; background: #fff3cd; border: 1px solid #e6d28a; color: #6b5200; padding: 8px 12px; margin-bottom: 14px; border-radius: 6px; }
.ribbon { font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: .8em; }
.draft-actions { display: flex; align-items: center; gap: 8px; }
.review-form { display: flex; gap: 6px; align-items: center; }
.review-form input { font: inherit; padding: 5px 8px; border: 1px solid #cfc6b1; border-radius: 4px; }
.block-tools { display: flex; justify-content: flex-end; gap: 6px; align-items: center; margin: 0 0 4px; padding: 2px 8px; font-size: .8em; border-bottom: 1px dashed var(--gold-soft); }
.block-tools button, .block-tools a { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; font-size: 1em; padding: 2px 4px; text-decoration: none; }
.block-tools button:hover, .block-tools a:hover { color: var(--gold); }
.block-tools .del:hover { color: var(--danger); }
.block-tools .kind-tag { color: var(--gold); letter-spacing: .08em; text-transform: uppercase; font-size: .85em; }
body.previewing .block { outline: 1px dashed transparent; padding: 4px 6px 6px; }
body.previewing .block:hover { outline-color: var(--gold-soft); }
.status-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.pill-draft { background: #fff3cd; color: #6b5200; }
.block-list { list-style: none; padding: 0; margin: 0 0 16px; counter-reset: b; }
.block-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--gold-soft); background: var(--paper); border-radius: 4px; margin-bottom: 6px; }
.block-list li.expired { opacity: .6; }
.block-list .kind-tag { min-width: 96px; font-size: .78em; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); }
.block-list .block-summary { flex: 1; min-width: 160px; text-decoration: none; color: var(--ink); }
.block-list .block-actions { display: flex; gap: 4px; align-items: center; }
.add-title { margin: 6px 0 8px; font-size: 1em; color: var(--muted); }
.add-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.add-card { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--gold-soft); border-radius: 4px; background: var(--paper); text-decoration: none; color: var(--ink); font-size: .9em; }
.add-card:hover { background: var(--gold-faint); color: var(--ink); }
.add-card strong { color: var(--gold); }
.add-card span { color: var(--muted); font-size: .9em; }
.actions.left { justify-content: flex-start; margin-top: 8px; }
.archive-files { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.form label .hint { display: block; font-weight: 400; margin-top: 2px; }
.copy-field { width: 100%; max-width: 520px; font: inherit; font-size: .9em; padding: 6px 8px; border: 1px solid #cfc6b1; border-radius: 4px; background: #fff; }
@media (max-width: 720px) {
  .block .lesson-row { grid-template-columns: 1fr; }
  .block .lesson-row dd, .block .lesson-row dd.note { text-align: left; }
}

/* Drag and drop */
.handle { cursor: grab; color: var(--muted); user-select: none; touch-action: none; padding: 4px 6px; font-size: 1em; line-height: 1; }
.handle:active { cursor: grabbing; }
.block-list li .handle { margin-right: 2px; }
.block-tools .handle { margin-right: auto; }
.dragging { position: fixed !important; z-index: 50; box-shadow: 0 10px 30px rgba(60, 40, 0, .25); opacity: .95; pointer-events: none; background: var(--paper); }
.drag-placeholder { border: 2px dashed var(--gold-soft); border-radius: 4px; background: var(--gold-faint); margin-bottom: 6px; }
body.is-dragging { user-select: none; cursor: grabbing; }
.dropped { animation: dropped .6s ease-out; }
@keyframes dropped { from { background: var(--gold-faint); } to { background: transparent; } }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 8px 16px; border-radius: 20px; font-size: .9em; opacity: 0; transition: opacity .25s, transform .25s; z-index: 60; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-err { background: var(--danger); }

/* Forms */
.form label { display: block; margin: 0 0 12px; font-weight: 600; }
.form input:not([type=checkbox]), .form select, .form textarea, .rows input, .rows select, .rows textarea { display: block; width: 100%; font: inherit; font-size: .95em; padding: 7px 9px; border: 1px solid #cfc6b1; border-radius: 4px; background: #fff; margin-top: 3px; font-weight: 400; }
.form textarea { resize: vertical; }
.form .check { font-weight: 400; }
.form .check input { margin-right: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; }
.narrow-form { max-width: 620px; }
.hint { color: var(--muted); }
details.hint summary { cursor: pointer; }

/* Admin shell */
body.admin { font-size: 17px; }
.admin-shell { display: grid; grid-template-columns: 220px 1fr; gap: 24px; }
.admin-nav { background: var(--paper); border: 1px solid var(--gold-soft); padding: 12px; align-self: start; position: sticky; top: 12px; }
.admin-nav a { display: block; padding: 6px 8px; text-decoration: none; color: var(--ink); border-radius: 4px; }
.admin-nav a.sub { padding-left: 18px; font-size: .95em; }
.admin-nav a.active, .admin-nav a:hover { background: var(--gold-faint); color: var(--gold); }
.admin-nav-group { display: block; margin: 12px 8px 2px; font-size: .78em; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.admin-user { margin: 0 8px 10px; font-size: .9em; }
.admin-main h1 { margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 20px; }
.card { display: block; background: var(--paper); border: 1px solid var(--gold-soft); padding: 14px 16px; text-decoration: none; color: var(--ink); border-radius: 4px; }
.card h2 { margin: 0 0 6px; font-size: 1.1em; color: var(--gold); }
.card p { margin: 0 0 4px; }
.panel { background: var(--paper); border: 1px solid var(--gold-soft); padding: 14px 18px; margin-bottom: 20px; border-radius: 4px; }
.panel h2 { margin-top: 0; font-size: 1.1em; color: var(--gold); }
.checklist li { margin-bottom: 6px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tabs a { padding: 6px 12px; border: 1px solid var(--gold-soft); border-radius: 20px; text-decoration: none; color: var(--muted); background: var(--paper); font-size: .9em; }
.tabs a.active { background: var(--gold); border-color: var(--gold); color: #fff; }
.table { width: 100%; border-collapse: collapse; background: var(--paper); border: 1px solid var(--gold-soft); }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #eee4cc; vertical-align: top; }
.table th { background: var(--gold-faint); font-size: .85em; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.table tr.expired td { opacity: .55; }
.accounts tr.account-tools td { padding-top: 0; }
.accounts details summary { cursor: pointer; color: var(--muted); font-size: .85em; }
.account-actions { padding: 8px 0 4px; }
.account-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 8px 0; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-family: ui-monospace, monospace; font-size: .85em; }
.pill { display: inline-block; background: var(--gold-faint); color: var(--gold); border-radius: 10px; padding: 0 8px; font-size: .75em; vertical-align: middle; }
.pill-muted { background: #eee; color: #777; }

/* Repeatable rows */
.rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.rows .r { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: start; background: var(--paper); border: 1px solid var(--gold-soft); padding: 8px; border-radius: 4px; }
.rows .handle { text-align: center; padding-top: 10px; }
.rows .fields { display: grid; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.rows .fields.f-heading, .rows .fields.f-divider { grid-template-columns: 1fr; }
.rows .fields label { font-size: .8em; color: var(--muted); font-weight: 600; margin: 0; }
.rows .fields .full { grid-column: 1 / -1; }
.rows .tools { display: flex; gap: 4px; padding-top: 16px; }
.rows .tools button { background: none; border: 1px solid #d9d0b8; border-radius: 4px; cursor: pointer; font: inherit; font-size: .85em; padding: 2px 7px; color: var(--muted); }
.rows .tools button:hover { color: var(--gold); border-color: var(--gold); }
.rows .tools .del:hover { color: var(--danger); border-color: var(--danger); }
.rows .kind-tag { font-size: .8em; color: var(--gold); letter-spacing: .1em; text-transform: uppercase; padding-top: 8px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

@media (max-width: 720px) {
  body { font-size: 16px; }
  /* Phone header: centered brand, then the groups as evenly spaced pills */
  .site-header { flex-direction: column; align-items: stretch; gap: 6px; padding: 8px 6px; }
  .brand { justify-content: center; font-size: 1.05em; }
  .brand .chapel { width: 24px; height: 24px; }
  /* Plain text links (as on desktop), centered, sized to fit two rows on 360–390px phones */
  .site-nav { justify-content: center; gap: 0 14px; font-size: .86em; }
  .site-nav a { min-height: 34px; padding: 4px 0; }
  .page { padding: 16px 12px 32px; }
  .program-inner { padding: 20px 14px; }
  .program-inner h1 { font-size: 1.8em; }
  .agenda .row { grid-template-columns: 1fr; }
  .agenda dd { text-align: left; }
  .agenda dd.note { text-align: left; }
  .two-col, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .sheet { padding: 20px 16px; }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-nav { position: static; }
  .rows .r { grid-template-columns: 22px 1fr; }
  .rows .tools { grid-column: 2; padding-top: 0; }
}
@media print {
  .site-header, .site-footer, .actions, .groups, .flash { display: none !important; }
  body { background: #fff; font-size: 13pt; }
  .page { padding: 0; max-width: none; }
  .program-card { box-shadow: none; }
}
