/*
  The admin's one stylesheet (docs/ADMIN-DESIGN.md). Design tokens first: scripts/check-contrast.ts reads every "--name: #hex;" line in
  this file and checks the text pairs, and checks that the accent tokens below equal what core's adminAccent() computes for the neutral
  navy. Then components, then one section per screen. Every color a screen uses is a token here, so the contrast check covers it.

  The accent (--accent and its relatives) is the church's own color. The shell overrides these seven lines inline for a church, from
  core's adminAccent(), which guarantees 4.5:1 for the text on a button and 4.5:1 for the focus ring whatever color the church chose.
  Platform screens (/ops, sign-in) keep the neutral navy written here.
*/
:root {
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* One type scale */
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 24px;
  --fs-3xl: 30px;

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

  /* Radii */
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --r-pill: 999px;

  /* Neutral cool gray */
  --ground: #f6f7f9;
  --surface: #ffffff;
  --surface-sunken: #f8fafc;
  --surface-hover: #eef1f5;
  --line: #e3e7ee;
  --line-strong: #c4ccd8;
  /* The edge of a text field, a menu or a color box: 3:1 on every ground, so a person can see where to type (WCAG 1.4.11). Not for decoration; see D181. */
  --field-edge: #6b7686;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #526072;

  /* Status colors */
  --ok-bg: #dcfce7;
  --ok-ink: #166534;
  --warn-bg: #fef3c7;
  --warn-ink: #92400e;
  --danger-bg: #fee2e2;
  --danger-ink: #991b1b;
  --info-bg: #e0e7ff;
  --info-ink: #3730a3;
  --danger: #b91c1c;
  --danger-soft: #fecaca;

  /* The church's accent: the neutral navy here; the shell writes the church's own, guarded, inline. */
  --accent: #1f3a56;
  --accent-ink: #ffffff;
  --accent-hover: #1b324a;
  --accent-edge: #192e45;
  --accent-text: #1f3a56;
  --accent-tint: #e4e7eb;
  --accent-tint-ink: #1f3a56;
  --accent-ring: #1f3a56;
  --accent-select: #c0c8d0;
  --accent-select-ink: #0f172a;

  /* The editor's selection blue: inside the page being edited (public/blocks-frame.css repeats the hex), not the church's color */
  --ed-blue: #1d4ed8;
  --ed-blue-ink: #ffffff;

  --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-2: 0 10px 30px rgba(15, 23, 42, 0.16);
  --nav-w: 248px;
  --nav-w-collapsed: 68px;
  --tap: 44px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: var(--fs-md) / 1.5 var(--font-ui); color: var(--ink); background: var(--ground); }
a { color: var(--accent-text); }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { line-height: 1.25; color: var(--ink); }
h1 { font-size: var(--fs-2xl); margin: 0 0 var(--sp-3); }
h2 { font-size: var(--fs-lg); margin: var(--sp-6) 0 var(--sp-3); }
h3 { font-size: var(--fs-md); margin: var(--sp-4) 0 var(--sp-2); }
p { margin: 0 0 var(--sp-3); }
code { font-family: var(--font-mono); font-size: 0.92em; }
::selection { background: var(--accent-select); color: var(--accent-select-ink); }
:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 2px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.right { text-align: right; }
[hidden] { display: none !important; }

/* Icons: outline, drawn in the color of the text around them. */
.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.skip { position: absolute; left: -999px; top: 8px; z-index: 100; }
.skip:focus { left: 8px; background: var(--surface); color: var(--ink); padding: 10px 14px; border-radius: var(--r); box-shadow: var(--shadow-2); }

/* ---- The shell: the menu at the left, the screen at the right -------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: 100vh; }
.sidenav { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: var(--sp-1); padding: var(--sp-4) var(--sp-3); background: var(--surface); border-right: 1px solid var(--line); }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-1) var(--sp-2) var(--sp-3); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: var(--fs-lg); color: var(--ink); text-decoration: none; }
.brand .i { width: 30px; height: 30px; padding: 5px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); }
.btn.side-close { display: none; }

.switcher { margin: 0 var(--sp-1) var(--sp-3); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); position: relative; }
.switcher > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 9px 10px; min-height: 48px; cursor: pointer; border-radius: var(--r); }
.switcher > summary::-webkit-details-marker { display: none; }
.switcher > summary:hover { background: var(--surface-hover); }
.sw-text { display: grid; min-width: 0; line-height: 1.25; }
.sw-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-text small { color: var(--muted); font-size: var(--fs-xs); }
.sw-caret { margin-left: auto; width: 18px; height: 18px; color: var(--muted); }
.sw-menu { display: grid; padding: var(--sp-1); border-top: 1px solid var(--line); }
.sw-menu a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; min-height: 40px; border-radius: 8px; color: var(--ink-2); text-decoration: none; }
.sw-menu a:hover { background: var(--surface-hover); }

.avatar { display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: var(--r-pill); background: var(--accent-tint); color: var(--accent-tint-ink); font-weight: 700; font-size: var(--fs-xs); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sq { background: var(--surface); border: 1px solid var(--line); }
.avatar.sq img { object-fit: contain; padding: 2px; }
.avatar.sq { border-radius: 8px; width: 32px; height: 32px; }
.avatar.sq.sm { width: 26px; height: 26px; }

.nav { display: grid; gap: var(--sp-1); }
.nav-group { display: grid; gap: 2px; }
.nav-title { margin: var(--sp-4) var(--sp-3) var(--sp-1); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.nav-group:first-child .nav-title { margin-top: 0; }
.nav-link { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 12px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.nav-link:hover { background: var(--surface-hover); color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--accent-tint); color: var(--accent-tint-ink); font-weight: 600; }
.nav-link .count, .count { margin-left: auto; font-size: 11px; font-weight: 600; background: var(--surface-hover); color: var(--muted); border-radius: var(--r-pill); padding: 1px 8px; }
.nav-link[aria-current="page"] .count { background: var(--surface); }
.side-foot { margin-top: auto; display: grid; gap: var(--sp-2); padding-top: var(--sp-4); }
.view-site { justify-content: flex-start; color: var(--accent-text); }
.side-collapse { justify-content: flex-start; color: var(--muted); }

/* Collapsed on a desktop: icons only. The words stay in the page for screen readers, and each link keeps its tooltip. */
body.nav-collapsed .app { grid-template-columns: var(--nav-w-collapsed) minmax(0, 1fr); }
body.nav-collapsed .sidenav { padding-left: var(--sp-2); padding-right: var(--sp-2); align-items: center; }
body.nav-collapsed .nav-label, body.nav-collapsed .count, body.nav-collapsed .sw-text, body.nav-collapsed .sw-caret, body.nav-collapsed .brand span, body.nav-collapsed .nav-title, body.nav-collapsed .sw-menu { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; padding: 0; border: 0; }
body.nav-collapsed .side-head { justify-content: center; padding-left: 0; padding-right: 0; }
body.nav-collapsed .switcher { margin-left: 0; margin-right: 0; border-color: transparent; }
body.nav-collapsed .switcher > summary { padding: 6px; justify-content: center; }
body.nav-collapsed .nav, body.nav-collapsed .nav-group, body.nav-collapsed .side-foot { width: 100%; }
body.nav-collapsed .nav-link, body.nav-collapsed .view-site, body.nav-collapsed .side-collapse { justify-content: center; padding-left: 0; padding-right: 0; }
body.nav-collapsed .side-collapse .i { transform: rotate(180deg); }

.app-main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-5); min-height: 56px; }
.tb-brand { display: none; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); text-decoration: none; min-width: 0; }
.tb-brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signout { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; }
.tb-user { color: var(--muted); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 24ch; }
main { width: 100%; max-width: 1180px; margin: 0 auto; padding: var(--sp-2) var(--sp-5) var(--sp-7); flex: 1; }
main.narrow { max-width: 700px; }
main.wide { max-width: none; }
.tabbar, .scrim { display: none; }

/* Sign-in and the other screens with no church: a centered card under the brand. */
.plain-layout { min-height: 100vh; display: flex; flex-direction: column; }
.plain-brand { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-4) var(--sp-5); }
.plain-layout main { padding-top: var(--sp-5); }
.card.auth { padding: var(--sp-6); box-shadow: var(--shadow-2); }
.card.auth h1 { margin-bottom: var(--sp-2); }

/* ---- Page header: one pattern for every screen ------------------------------------------------------------------ */
.ph { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--sp-3) var(--sp-4); margin: var(--sp-2) 0 var(--sp-5); }
.ph-text { min-width: 0; flex: 1 1 22rem; }
.ph-title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); }
.ph-title h1 { margin: 0; font-size: var(--fs-2xl); overflow-wrap: anywhere; }
.ph-desc { margin: var(--sp-1) 0 0; color: var(--muted); max-width: 64ch; }
.ph-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.ph-back { display: inline-flex; align-items: center; gap: 2px; margin-bottom: var(--sp-1); font-size: var(--fs-sm); color: var(--muted); text-decoration: none; }
.ph-back:hover { color: var(--ink); text-decoration: underline; }
.ph-back .i { width: 16px; height: 16px; }

/* ---- Buttons: one filled primary, outlined secondary, text or icon tertiary --------------------------------------- */
.btn.wrap { white-space: normal; text-align: center; } /* a button whose words are a look's name: it may wrap, so a phone at 320 px does not scroll sideways */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); font: inherit; font-weight: 600; line-height: 1.2; min-height: 38px; padding: 7px 14px; border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-hover); text-decoration: none; }
.btn .i { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent-edge); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-hover); color: var(--ink); }
.btn.icon { padding: 0; width: 38px; min-width: 38px; }
.btn.danger { color: var(--danger-ink); border-color: transparent; background: transparent; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.small { min-height: 32px; padding: 3px 10px; font-size: var(--fs-sm); }
.btn.block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn[aria-pressed="true"] { background: var(--accent-tint); border-color: var(--accent-ring); color: var(--accent-tint-ink); }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-text); text-decoration: underline; cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); align-items: center; }
.inline-btns { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1); margin: 0; }
/* A read-only value with a Copy button beside it (the Team screen's invitation link). The field takes the room; on a phone the button wraps below. */
.copy-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin: var(--sp-2) 0; }
.copy-row input { flex: 1 1 18rem; min-width: 0; font-family: var(--font-mono, monospace); }
.inline { display: inline-block; margin: var(--sp-3) var(--sp-2) 0 0; }
.danger-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-4); }
.danger-row form { margin: 0; }

/* ---- Cards, chips, notices, empty states ---------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-5); box-shadow: var(--shadow-1); }
.card h2:first-child { margin-top: 0; }
main > .card + .card, main > .card + h2 { margin-top: var(--sp-4); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; line-height: 1.5; background: var(--surface-sunken); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.ok { background: var(--ok-bg); color: var(--ok-ink); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.badge.danger { background: var(--danger-bg); color: var(--danger-ink); border-color: transparent; }
.badge.info { background: var(--info-bg); color: var(--info-ink); border-color: transparent; }
.chip { display: inline-block; font-size: var(--fs-xs); font-weight: 600; background: var(--info-bg); color: var(--info-ink); border-radius: var(--r-pill); padding: 1px 9px; }
.notice { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r); background: var(--info-bg); color: var(--info-ink); margin: 0 0 var(--sp-4); }
.notice > .i { margin-top: 2px; }
.notice > span { min-width: 0; flex: 1; }
.notice.ok { background: var(--ok-bg); color: var(--ok-ink); }
.notice.warn { background: var(--warn-bg); color: var(--warn-ink); }
.notice a, .notice button.link { color: inherit; }
.notice ul { margin: var(--sp-2) 0 0; padding-left: 18px; }
.empty { display: grid; justify-items: center; gap: var(--sp-2); text-align: center; padding: var(--sp-7) var(--sp-5); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r-lg); }
.empty-i { width: 36px; height: 36px; color: var(--muted); }
.empty-title { margin: 0; font-weight: 600; font-size: var(--fs-lg); }
.empty-body { margin: 0; color: var(--muted); max-width: 44ch; }
.empty-act { margin-top: var(--sp-2); }

/* ---- Tables ------------------------------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; max-width: 100%; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.table th { text-align: left; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; padding: 10px var(--sp-4); background: var(--surface-sunken); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px var(--sp-4); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-sunken); }
.table th.right, .table td.right { text-align: right; }
.table td a { font-weight: 600; }
.person { display: inline-flex; align-items: center; gap: var(--sp-3); text-decoration: none; color: var(--ink); min-width: 0; }
.person > span:last-child { display: grid; min-width: 0; }
.person small { font-weight: 400; }
.person:hover > span:last-child { text-decoration: underline; }
.thumb { display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 8px; background: var(--surface-hover); color: var(--muted); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.row-title { color: var(--ink); text-decoration: none; }
.row-title:hover { text-decoration: underline; }
.addr { display: block; color: var(--muted); font-size: var(--fs-xs); font-weight: 400; margin-top: 2px; }
.pages-table .actions-col { width: 1%; white-space: nowrap; text-align: right; }
.row-actions { display: inline-flex; gap: 2px; opacity: 0; transition: opacity 0.12s; }
tr:hover .row-actions, tr:focus-within .row-actions { opacity: 1; }
.inmenu.yes { color: var(--accent-text); display: inline-flex; }
.inmenu.no { color: var(--muted); }
.shape { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--ink-2); }
.shape-i { display: inline-flex; }
.member-actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); justify-content: flex-end; align-items: center; }
.member-actions select { width: auto; min-height: 32px; padding: 3px 8px; }
.toolbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-3); }
.search { position: relative; flex: 1 1 14rem; max-width: 26rem; display: block; }
.search .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 38px; }
.filters { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.fchip { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: var(--fs-sm); font-weight: 600; min-height: 34px; padding: 4px 12px; border-radius: var(--r-pill); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.fchip:hover { background: var(--surface-hover); }
.fchip[aria-pressed="true"] { background: var(--accent-tint); border-color: var(--accent-ring); color: var(--accent-tint-ink); }
.fchip .count { margin: 0; background: var(--surface-hover); }

/* ---- Dashboard ---------------------------------------------------------------------------------------------- */
.stats { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: var(--sp-4); }
.stat { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4); color: var(--ink); text-decoration: none; }
a.stat:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); }
.stat-ic { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 11px; background: var(--accent-tint); color: var(--accent-tint-ink); }
.stat-text { display: grid; line-height: 1.25; }
.stat-text strong { font-size: var(--fs-xl); }
.stat-text span { color: var(--ink-2); font-size: var(--fs-sm); }
.stat-text small { color: var(--muted); font-size: var(--fs-xs); }
.two-col { display: grid; gap: var(--sp-4); grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); margin-bottom: var(--sp-4); align-items: start; }
.rows { list-style: none; margin: 0; padding: 0; }
.row-item { display: flex; align-items: center; gap: var(--sp-3); padding: 12px 0; border-top: 1px solid var(--line); }
.row-item:first-child { border-top: 0; }
.row-ic { color: var(--muted); }
.row-main { display: grid; min-width: 0; flex: 1; line-height: 1.35; }
.row-main a { font-weight: 600; }
.quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.quick a { display: flex; align-items: center; gap: var(--sp-3); min-height: 48px; padding: var(--sp-3); border: 1px solid var(--line); border-radius: var(--r); color: var(--ink); font-weight: 600; text-decoration: none; }
.quick a .i { color: var(--accent-text); }
.quick a:hover { background: var(--surface-hover); border-color: var(--line-strong); }
.church-grid { list-style: none; margin: 0 0 var(--sp-4); padding: 0; display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.church-card { padding: 0; }
.church-card a { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4); color: var(--ink); text-decoration: none; min-height: 64px; border-radius: var(--r-lg); }
.church-card a:hover { background: var(--surface-hover); }
.cc-text { display: grid; gap: 2px; justify-items: start; flex: 1; min-width: 0; }
.cc-go { color: var(--muted); }

/* A control reached with Tab is scrolled clear of the sticky tool bars above and the sticky save bar below (and, on a phone, of the top bar and the tab bar), so it is never hidden behind one (WCAG 2.4.11). */
html { scroll-padding-top: 72px; scroll-padding-bottom: 88px; }

/* ---- Forms ------------------------------------------------------------------------------------------------- */
.stack { display: grid; gap: var(--sp-4); }
.row { display: grid; gap: var(--sp-4); grid-template-columns: 1fr 1fr; align-items: start; }
.field { display: grid; gap: 6px; font-weight: 600; }
.field .hint, .hint { font-weight: 400; color: var(--muted); font-size: var(--fs-sm); }
.check { display: flex; gap: var(--sp-2); align-items: center; min-height: 28px; }
input:where(:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file])), textarea, select { font: inherit; padding: 9px 12px; min-height: 40px; border: 1px solid var(--field-edge); border-radius: 8px; background: var(--surface); color: var(--ink); width: 100%; }
input[type=file] { font: inherit; width: 100%; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: 0; border-color: var(--accent-ring); }
textarea { resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: var(--r); margin: 0; padding: var(--sp-3) var(--sp-4) var(--sp-4); display: grid; gap: var(--sp-3); min-width: 0; }
legend { font-weight: 700; padding: 0 var(--sp-2); }
.error { color: var(--danger-ink); font-weight: 600; font-size: var(--fs-sm); }
.savebar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); position: sticky; bottom: 0; z-index: 6; margin: var(--sp-2) calc(var(--sp-5) * -1) calc(var(--sp-5) * -1); padding: var(--sp-3) var(--sp-5); background: var(--surface); border-top: 1px solid var(--line); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.repeat-row { display: grid; gap: var(--sp-3); grid-template-columns: 1.1fr 0.8fr 1.4fr; }
.repeat-row.two { grid-template-columns: 1fr 2fr; }
.colorpair { display: flex; gap: var(--sp-2); align-items: center; }
.colorpair input[type=color] { width: 44px; min-width: 44px; height: 40px; padding: 2px; border: 1px solid var(--field-edge); border-radius: 8px; background: var(--surface); }
.choice { display: flex; gap: var(--sp-3); align-items: flex-start; font-weight: 400; min-height: 28px; }
.choice .hint { display: block; }
.current-logo { display: flex; gap: var(--sp-3); align-items: center; }
.current-logo img { max-width: 120px; height: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-sunken); }
.danger-zone { border-color: var(--danger); }
.danger-zone h2 { margin-top: 0; }
.narrow-form { max-width: 440px; }
.roles { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--sp-4); margin: 0; }
.roles dt { font-weight: 700; }
.roles dd { margin: 0; color: var(--ink-2); }
.plain { padding-left: 18px; }
.cards { list-style: none; padding: 0; display: grid; gap: var(--sp-3); }
.editor-grid { display: grid; gap: var(--sp-5); grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.preview { position: sticky; top: var(--sp-3); }
.preview iframe { width: 100%; height: 78vh; border: 1px solid var(--line-strong); border-radius: var(--r); background: #fff; }
/* ---- Rich text (public/rich-editor.js, SPEC D297): one row of icon buttons and a More menu over a ProseMirror editing box ---- */
.rt { display: grid; gap: var(--sp-1); min-width: 0; }
.rt-bar { display: flex; flex-wrap: nowrap; align-items: center; gap: 2px; min-width: 0; }
.rt-btn { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 36px; height: 36px; padding: 0; border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; color: var(--ink); cursor: pointer; }
.rt-btn:hover { background: var(--surface-hover); }
/* Pressed is a tint and an edge, never the color alone. */
.rt-btn[aria-pressed="true"], .rt-btn[aria-expanded="true"] { background: var(--accent-tint); color: var(--accent-tint-ink); border-color: var(--accent-edge); }
.rt-more { position: relative; flex: none; }
.rt-menu { position: absolute; z-index: 70; top: calc(100% + 4px); right: 0; display: grid; min-width: 230px; padding: var(--sp-1); background: var(--surface); border: 1px solid var(--field-edge); border-radius: var(--r); box-shadow: var(--shadow-2); }
.rt-bar.rt-float .rt-menu { right: auto; left: 0; }
.rt-item { display: flex; align-items: center; gap: var(--sp-2); min-height: 40px; padding: 6px 10px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink); font: inherit; font-weight: 400; text-align: left; cursor: pointer; white-space: nowrap; }
.rt-item:hover { background: var(--surface-hover); }
.rt-item[aria-checked="true"] { background: var(--accent-tint); color: var(--accent-tint-ink); font-weight: 600; }
.rt-item[aria-checked="true"]::after { content: "\2713"; margin-left: auto; padding-left: var(--sp-3); }
.rt-keys { margin-left: auto; padding-left: var(--sp-3); color: var(--muted); font-size: var(--fs-xs); }
.rt-sep { height: 1px; margin: 4px 2px; background: var(--line); }
.rt-area { min-height: 280px; border: 1px solid var(--field-edge); border-radius: 8px; padding: 10px 12px; background: var(--surface); font-weight: 400; color: var(--ink); }
.rt-area a { color: var(--accent-text); }
.rt-area blockquote { margin: 0 0 var(--sp-3); padding-left: var(--sp-3); border-left: 3px solid var(--line-strong); color: var(--ink-2); }
.rt-area hr { border: 0; border-top: 1px solid var(--line-strong); margin: var(--sp-3) 0; }
.rt-area li > p, .rt-area blockquote > p:last-child { margin: 0; }
.rt-area ul, .rt-area ol { margin: 0 0 var(--sp-3); padding-left: 1.6em; }
.rt-area h2, .rt-area h3 { margin: var(--sp-3) 0 var(--sp-2); }
.rt-area > :first-child { margin-top: 0; }
.rt-label { display: block; }
/* The markup fallback under a rich field (D11): its disclosure is a target like any other. */
.rt-field > details > summary { display: flex; align-items: center; min-height: 32px; font-weight: 600; cursor: pointer; }
/* The link popover: a small box under the words, not a browser prompt. */
.rt-pop { position: fixed; z-index: 80; width: min(380px, calc(100vw - 16px)); padding: var(--sp-3); background: var(--surface); color: var(--ink); border: 1px solid var(--field-edge); border-radius: var(--r); box-shadow: var(--shadow-2); }
.rt-pop-form { display: grid; gap: var(--sp-2); }
.rt-pop-form .field { display: block; }
.rt-pop .hint { margin: 0; }
.rt-pop-err { margin: 0; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); background: var(--danger-bg); color: var(--danger-ink); font-weight: 600; }
.rt-pop-btns { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
/* What ProseMirror's own stylesheet asks of the editing box (prosemirror-view and prosemirror-gapcursor, MIT). */
.ProseMirror { position: relative; word-wrap: break-word; white-space: pre-wrap; white-space: break-spaces; font-variant-ligatures: none; font-feature-settings: "liga" 0; }
.ProseMirror li { position: relative; }
.ProseMirror-hideselection *::selection { background: transparent; }
.ProseMirror-hideselection { caret-color: transparent; }
.ProseMirror-selectednode { outline: 2px solid var(--accent-ring); }
img.ProseMirror-separator { display: inline !important; border: none !important; margin: 0 !important; }
.ProseMirror-gapcursor { display: none; pointer-events: none; position: absolute; }
.ProseMirror-gapcursor::after { content: ""; display: block; position: absolute; top: -2px; width: 20px; border-top: 1px solid var(--ink); animation: pm-blink 1.1s steps(2, start) infinite; }
.ProseMirror-focused .ProseMirror-gapcursor { display: block; }
@keyframes pm-blink { to { visibility: hidden; } }

/* ---- Phones: the menu becomes a bottom bar and a sheet, targets are 44px ----------------------------------------- */
@media (max-width: 900px) { .editor-grid, .two-col { grid-template-columns: 1fr; } .preview { position: static; } .row { grid-template-columns: 1fr; } }
@media (max-width: 800px) {
  html { scroll-padding-top: 72px; scroll-padding-bottom: calc(144px + env(safe-area-inset-bottom)); }
  .app { display: block; }
  .tb-brand { display: inline-flex; }
  .topbar { padding: var(--sp-2) var(--sp-4); position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--line); }
  .tb-user { display: none; }
  .signout .btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  main { padding: var(--sp-3) var(--sp-4) 96px; }
  .sidenav { position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: auto; max-height: 86vh; z-index: 60; border-right: 0; border-radius: 18px 18px 0 0; box-shadow: var(--shadow-2); transform: translateY(105%); visibility: hidden; transition: transform 0.2s, visibility 0.2s; padding-bottom: calc(var(--sp-5) + env(safe-area-inset-bottom)); }
  body.nav-open .sidenav { transform: none; visibility: visible; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(15, 23, 42, 0.5); }
  .btn.side-close { display: inline-flex; }
  .side-collapse { display: none; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .tab { flex: 1; min-height: 56px; min-width: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font: inherit; font-size: 11px; font-weight: 600; color: var(--muted); background: none; border: 0; text-decoration: none; cursor: pointer; }
  .tab[aria-current="page"] { color: var(--accent-tint-ink); }
  .tab[aria-current="page"] .i { background: var(--accent-tint); width: 44px; padding: 3px 12px; border-radius: var(--r-pill); height: 26px; }
  .nav-link { min-height: 44px; }
  .btn { min-height: 44px; }
  .btn.small { min-height: 44px; }
  .btn.icon { width: 44px; min-width: 44px; }
  .fchip { min-height: 44px; }
  input:where(:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file])), textarea, select { min-height: 44px; font-size: 16px; }
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; }
  .check, .choice { min-height: 44px; align-items: center; }
  .ph { margin-bottom: var(--sp-4); }
  .ph-actions { width: 100%; }
  .ph-actions .btn.primary { flex: 1; }
  .quick { grid-template-columns: 1fr; }
  .repeat-row, .repeat-row.two { grid-template-columns: 1fr; }
  .savebar { bottom: calc(56px + env(safe-area-inset-bottom)); margin-left: calc(var(--sp-4) * -1); margin-right: calc(var(--sp-4) * -1); padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .row-actions { opacity: 1; }
  .card { padding: var(--sp-4); }
}
@media (hover: none) { .row-actions { opacity: 1; } }
@media (max-width: 700px) {
  .table:has(td[data-label]) thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table:has(td[data-label]), .table:has(td[data-label]) tbody, .table:has(td[data-label]) tr, .table:has(td[data-label]) td { display: block; width: 100%; }
  .table:has(td[data-label]) tr { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line); }
  .table:has(td[data-label]) tr:last-child { border-bottom: 0; }
  .table:has(td[data-label]) td { border: 0; padding: 4px 0; text-align: left; display: flex; align-items: center; gap: var(--sp-3); }
  .table:has(td[data-label]) td::before { content: attr(data-label); flex: 0 0 5.5rem; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
  .table:has(td[data-label]) td.actions-col { display: block; text-align: left; width: auto; }
  .table:has(td[data-label]) td.actions-col::before, .table:has(td[data-label]) td:first-child::before { display: none; }
  .table:has(td[data-label]) td.right { justify-content: flex-start; }
  .member-actions { justify-content: flex-start; }
}

/* ---- Starting points on the New page form: picture cards (a radio each) with a small outline of the page starter's blocks ---- */
.pick-form { max-width: 60rem; }
.pick-field { border: 0; padding: 0; margin: 0; min-width: 0; }
.pick-field legend { font-weight: 700; padding: 0; margin-bottom: var(--sp-1); }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: var(--sp-3); margin-top: var(--sp-2); }
.pick-card { position: relative; display: flex; flex-direction: column; gap: 6px; min-height: var(--tap); padding: var(--sp-3); background: var(--surface); border: 2px solid var(--line); border-radius: var(--r); cursor: pointer; }
.pick-card:hover { background: var(--surface-sunken); border-color: var(--line-strong); }
.pick-card input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.pick-card:has(input:checked) { border-color: var(--accent-ring); box-shadow: 0 0 0 2px var(--accent-ring); background: var(--accent-tint); }
.pick-card:has(input:focus-visible) { outline: 3px solid var(--accent-ring); outline-offset: 2px; }
.pick-name { font-weight: 700; color: var(--ink); }
.pick-desc { font-size: var(--fs-sm); color: var(--ink-2); }
.pick-card:has(input:checked) .pick-desc { color: var(--accent-tint-ink); }
.pick-sub { margin: var(--sp-4) 0 0; }
.pick-pic { display: flex; flex-direction: column; gap: 3px; padding: 6px; height: 7rem; overflow: hidden; background: var(--surface-sunken); border: 1px solid var(--line); border-radius: 6px; }
.pick-pic i { display: block; flex: none; border-radius: 2px; background: var(--line-strong); height: 8px; }
.pick-pic .shape-hero { height: 22px; background: var(--accent); }
.pick-pic .shape-imgtext { height: 16px; background: linear-gradient(90deg, var(--ink-2) 0 30%, var(--line-strong) 30% 100%); }
.pick-pic .shape-text { height: 8px; }
.pick-pic .shape-cols { height: 14px; background: linear-gradient(90deg, var(--line-strong) 0 48%, transparent 48% 52%, var(--line-strong) 52% 100%); }
.pick-pic .shape-grid { display: block; height: 14px; background: linear-gradient(90deg, var(--ink-2) 0 22%, transparent 22% 26%, var(--ink-2) 26% 48%, transparent 48% 52%, var(--ink-2) 52% 74%, transparent 74% 78%, var(--ink-2) 78% 100%); }
.pick-pic .shape-list { height: 14px; background: repeating-linear-gradient(180deg, var(--line-strong) 0 4px, transparent 4px 7px); }
.pick-pic .shape-btn { width: 40%; height: 10px; background: var(--accent); }
.pick-pic .shape-form { height: 14px; background: transparent; border: 2px solid var(--line-strong); }
.pick-pic .shape-none { height: 100%; background: transparent; border: 2px dashed var(--line-strong); }
/* The layout pictograms (the New page form and the editor's Page tab): a little page, drawn in tokens. */
.lay-pic { position: relative; display: block; height: 5.5rem; padding: 6px; background: var(--surface-sunken); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.lay-pic i { position: absolute; display: block; border-radius: 2px; background: var(--line-strong); }
.lay-pic .lp-head { top: 6px; left: 6px; right: 6px; height: 8px; background: var(--accent); }
.lay-pic .lp-main { top: 20px; bottom: 6px; left: 6px; right: 6px; background: repeating-linear-gradient(180deg, var(--line-strong) 0 5px, transparent 5px 9px); }
.lay-pic.lay-narrow .lp-main { left: 30%; right: 30%; }
.lay-pic.lay-sidebar_right .lp-main { right: 38%; }
.lay-pic.lay-sidebar_right .lp-side { top: 20px; bottom: 6px; right: 6px; width: 28%; background: var(--ink-2); opacity: 0.55; }
.lay-pic.lay-sidebar_left .lp-main { left: 38%; }
.lay-pic.lay-sidebar_left .lp-side { top: 20px; bottom: 6px; left: 6px; width: 28%; background: var(--ink-2); opacity: 0.55; }


/* ===== One section per screen ===== */
/* ---- The page editor (blocks-editor.js): a slim top bar, a rail of tools, the canvas, the inspector. Everything is .ed- ; the page being edited sees none of this. ---- */
main.bare { max-width: none; padding: 0; margin: 0; }
.ed { display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: var(--ground); }
.ed-id, .ed-tools { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.ed-id { flex: 1; }
.ed-tools { flex: none; }
.ed-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: 6px var(--sp-4); min-height: 56px; flex: none; background: var(--surface); border-bottom: 1px solid var(--line); position: relative; z-index: 30; }
.ed-brand { color: var(--accent-text); }
.ed-crumb { display: flex; gap: 6px; color: var(--muted); font-size: var(--fs-sm); }
.ed-crumb a { color: var(--muted); text-decoration: none; }
.ed-crumb a:hover { color: var(--ink); text-decoration: underline; }
.ed-title { flex: 0 1 340px; min-width: 120px; font-weight: 700; font-size: var(--fs-lg); border-color: transparent transparent var(--field-edge); background: transparent; padding-left: 8px; }
.ed-title:hover { border-color: var(--field-edge); }
.ed-heading { font-size: var(--fs-lg); margin: 0; }
.ed-savestatus { color: var(--muted); font-size: var(--fs-xs); min-width: 9ch; }
.ed-savestatus.bad { color: var(--danger-ink); font-weight: 700; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.seg button { width: 40px; min-height: 36px; border: 0; background: none; display: grid; place-items: center; color: var(--muted); cursor: pointer; }
.seg button:hover { background: var(--surface-hover); color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--accent-tint); color: var(--accent-tint-ink); }
.seg button:focus-visible { outline-offset: -3px; }
.seg-text { display: flex; width: 100%; }
.seg-opt { flex: 1; position: relative; display: grid; place-items: center; text-align: center; min-height: 40px; padding: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg-opt + .seg-opt { border-left: 1px solid var(--line-strong); }
.seg-opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg-opt:has(input:checked) { background: var(--accent-tint); color: var(--accent-tint-ink); }
.seg-opt:has(input:focus-visible) { outline: 3px solid var(--accent-ring); outline-offset: -3px; }
.ed-banner { margin: var(--sp-2) var(--sp-4) 0; }
.ed > .notice { margin: var(--sp-2) var(--sp-4) 0; }
.ed-body { flex: 1; min-height: 0; display: flex; }
.ed-rail { flex: none; width: 66px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: var(--sp-2) 0; background: var(--surface); border-right: 1px solid var(--line); }
.ed-rbtn { width: 54px; min-height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 4px 0; border: 0; border-radius: 10px; background: none; font: inherit; font-size: 11px; font-weight: 500; color: var(--muted); cursor: pointer; }
.ed-rbtn:hover { background: var(--surface-hover); color: var(--ink); }
.ed-rbtn[aria-pressed="true"] { background: var(--accent-tint); color: var(--accent-tint-ink); font-weight: 600; }
.ed-drawer { flex: none; width: 310px; background: var(--surface); border-right: 1px solid var(--line); overflow: hidden; }
.ed[data-tool=""] .ed-drawer { display: none; }
.ed-view { height: 100%; overflow-y: auto; padding: 0 var(--sp-4) var(--sp-5); }
.ed-view[hidden] { display: none; }
.ed-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); position: sticky; top: 0; z-index: 3; background: var(--surface); padding: var(--sp-3) 0 var(--sp-1); }
.ed-sheet-head h2 { margin: 0; font-size: var(--fs-lg); }
.ed-view .search { max-width: none; margin-bottom: var(--sp-2); }
.ed-group h3 { margin: var(--sp-4) 2px var(--sp-2); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.ed-tilegrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); }
.ed-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 78px; padding: 10px 4px 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); font: inherit; font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); cursor: grab; touch-action: manipulation; }
.ed-tile .i { width: 24px; height: 24px; color: var(--accent-text); }
.ed-tile-label { text-align: center; line-height: 1.2; overflow-wrap: anywhere; }
.ed-tile:hover { border-color: var(--accent-ring); box-shadow: var(--shadow-1); background: var(--surface-sunken); }
.ed-ghost { position: fixed; z-index: 300; pointer-events: none; display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--surface); color: var(--ink); border: 2px solid var(--accent-ring); border-radius: var(--r); font-weight: 600; box-shadow: var(--shadow-2); }
body.ed-dragging-tile { cursor: grabbing; user-select: none; }
.ed-stage { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; }
.ed-canvas { flex: 1; min-height: 0; padding: var(--sp-4); display: flex; justify-content: center; align-items: flex-start; overflow: hidden; background: #e6e9ef; }
.ed-wrap { flex: none; position: relative; overflow: hidden; background: #fff; border-radius: 6px; box-shadow: 0 0 0 1px var(--line-strong), 0 6px 20px rgba(15, 23, 42, 0.12); }
.ed[data-size="phone"] .ed-wrap { border-radius: 22px; box-shadow: 0 0 0 7px var(--ink-2), 0 12px 30px rgba(15, 23, 42, 0.25); }
.ed[data-size="tablet"] .ed-wrap { border-radius: 14px; box-shadow: 0 0 0 6px var(--ink-2), 0 12px 30px rgba(15, 23, 42, 0.25); }
.ed-wrap iframe { display: block; border: 0; background: #fff; transform-origin: 0 0; }
.ed-versionframe { width: 100%; height: 40vh; border: 1px solid var(--line-strong); border-radius: var(--r); background: #fff; }
.ed-toast { position: absolute; top: var(--sp-3); left: 50%; transform: translateX(-50%); z-index: 55; display: flex; align-items: center; gap: var(--sp-3); max-width: min(90%, 40rem); padding: 8px 14px; background: var(--ink); color: #ffffff; border-radius: var(--r); box-shadow: var(--shadow-2); }
.ed-toast a { color: #ffffff; font-weight: 600; }
.ed-toast .btn { min-height: 30px; }
.ed-selbar { position: fixed; z-index: 50; display: flex; align-items: center; gap: 2px; padding: 4px; background: var(--ink); border-radius: var(--r); box-shadow: var(--shadow-2); }
.ed-selbar[hidden] { display: none; }
.ed-tb { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 7px; background: transparent; color: #ffffff; cursor: pointer; }
.ed-tb:hover:not(:disabled) { background: rgba(255, 255, 255, 0.16); }
.ed-tb:disabled { opacity: 0.4; cursor: not-allowed; }
.ed-tb[data-danger] { color: var(--danger-soft); }
.ed-tb:focus-visible, .ed-colpick select:focus-visible { outline: 2px solid #ffffff; outline-offset: 1px; }
.ed-tb-sep { width: 1px; height: 22px; background: rgba(255, 255, 255, 0.25); margin: 0 2px; }
.ed-colpick select { width: auto; min-height: 34px; padding: 2px 6px; font-size: var(--fs-sm); }
.ed-panel { flex: none; width: 306px; overflow-y: auto; padding: 0 var(--sp-4) var(--sp-5); background: var(--surface); border-left: 1px solid var(--line); }
.ed-panel h2 { font-size: var(--fs-lg); margin: var(--sp-3) 0 var(--sp-1); }
.ed-bh { display: flex; align-items: center; gap: var(--sp-2); }
.ed-bh .i { color: var(--accent-text); }
.ed-panel .ed-sheet-head { padding-bottom: 0; }
.ed-tabs { display: flex; gap: 2px; flex: 1; border-bottom: 1px solid var(--line); margin-right: var(--sp-2); }
.ed-tab { font: inherit; font-weight: 600; min-height: 44px; padding: 6px 10px; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; background: none; color: var(--muted); cursor: pointer; }
.ed-tab:hover { color: var(--ink); }
.ed-tab[aria-selected="true"] { border-bottom-color: var(--accent-ring); color: var(--ink); }
.ed-tab .chip:empty { display: none; }
.ed-empty { color: var(--muted); margin-top: var(--sp-4); }
.ed-fieldwrap { margin: var(--sp-3) 0; }
.ed-fieldwrap[hidden], .ed-banner[hidden], .ed-toast[hidden] { display: none; }
.ed-radios { border: 0; padding: 0; margin: 0; }
.ed-radios legend { padding: 0; font-weight: 600; margin-bottom: 4px; }
.ed-row { display: grid; gap: var(--sp-2); padding: var(--sp-3); border: 1px solid var(--line); border-radius: var(--r); }
.ed-sec { border: 1px solid var(--line); border-radius: var(--r); margin-top: var(--sp-3); }
.ed-sec > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 0 var(--sp-3); font-weight: 600; cursor: pointer; border-radius: var(--r); }
.ed-sec > summary::-webkit-details-marker { display: none; }
.ed-sec > summary:hover { background: var(--surface-hover); }
.ed-sec[open] .ed-sec-caret { transform: rotate(180deg); }
.ed-sec-body { padding: 0 var(--sp-3) var(--sp-3); }
.ed-layout { border: 0; padding: 0; margin: var(--sp-4) 0 0; display: grid; gap: var(--sp-2); }
.ed-layout legend { font-weight: 600; padding: 0; margin-bottom: 6px; }
.ed-laygrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.ed-laygrid .pick-card { padding: 6px; gap: 4px; border-width: 1px; align-items: stretch; min-height: 0; }
.ed-laygrid .pick-card:has(input:checked) { box-shadow: 0 0 0 1px var(--accent-ring); }
.ed-laygrid .lay-pic { height: 3.4rem; padding: 4px; }
.ed-laygrid .pick-name { font-size: 11px; text-align: center; font-weight: 600; }
.ed-intro { margin: var(--sp-3) 0 0; }
.ed-page-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-5); padding-top: var(--sp-3); border-top: 1px solid var(--line); }
.ed-page-actions form { margin: 0; }
.ed-issues { list-style: none; margin: 0 0 var(--sp-3); padding: 0; display: grid; gap: var(--sp-2); }
.ed-issue { display: grid; gap: var(--sp-2); padding: var(--sp-3); border-radius: var(--r); }
.ed-issue.block { background: var(--danger-bg); color: var(--danger-ink); }
.ed-issue.warn { background: var(--warn-bg); color: var(--warn-ink); }
.ed-issue a { color: inherit; }
.ed-issue .btn { justify-self: start; }
/* Text typed on the canvas: its toolbar floats over the page, above the words (blocks-editor.js positionFloat). */
.rt-bar.rt-float { position: fixed; z-index: 60; padding: 3px; background: var(--surface); border: 1px solid var(--field-edge); border-radius: var(--r); box-shadow: var(--shadow-2); }
.ed .rt-area { min-height: 160px; }
.ed .btn.ed-btn, .ed .ed-btn { min-height: 38px; }
.ed input[type=radio], .ed input[type=checkbox] { flex: none; }
.ed .choice { align-items: center; }
.ed-starter h2 { margin-top: var(--sp-3); }
.ed-starter select { min-height: 40px; }
.ed-starter-btns { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
/* The Layers panel: a tidy tree, one row per block, columns indented under their block. */
.ed-outline { list-style: none; margin: 0 0 var(--sp-3); padding: 0; display: grid; gap: 2px; }
.ed-ocol { margin: 2px 0 2px 16px; padding-left: 8px; border-left: 2px solid var(--line); }
.ed-ocoltitle { margin: 6px 0 0 16px; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.ed-oitem { margin: 0; }
.ed-orow { display: flex; align-items: center; gap: 2px; min-width: 0; padding: 2px 4px; border-radius: 8px; }
.ed-orow:hover { background: var(--surface-hover); }
.ed-oitem.sel > .ed-orow { background: var(--accent-tint); }
.ed-ohandle { cursor: grab; width: 24px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); user-select: none; touch-action: none; }
.ed-oname { flex: 1 1 6rem; min-width: 0; min-height: 40px; display: flex; align-items: center; gap: var(--sp-2); text-align: left; font: inherit; color: var(--ink); background: none; border: 0; border-radius: 6px; padding: 2px 4px; cursor: pointer; }
.ed-otype { color: var(--muted); }
.ed-oitem.sel .ed-otype { color: var(--accent-tint-ink); }
.ed-otext { display: grid; min-width: 0; line-height: 1.25; }
.ed-otext strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-otext .hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: var(--fs-xs); }
.ed-oitem.sel .ed-otext .hint { color: var(--accent-tint-ink); }
.ed-omove.btn { width: 30px; min-width: 30px; min-height: 30px; height: 30px; }
.sortable-ghost.ed-oitem { opacity: 0.5; }
#ed-history table { font-size: var(--fs-sm); }
.table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
.table.stack tr { padding: var(--sp-3); border-bottom: 1px solid var(--line); }
.table.stack tr:last-child { border-bottom: 0; }
.table.stack td { border: 0; padding: 2px 0; text-align: left; }
.table.stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: var(--fs-xs); }
.table.stack td.actions-col { padding-top: var(--sp-2); }
.table.stack tbody tr:hover td { background: transparent; }

/* The editor on a phone: the rail becomes a bar along the bottom, the panels become sheets, the block toolbar docks above the bar. */
@media (max-width: 800px) {
  .ed-top { flex-direction: column; align-items: stretch; gap: 4px; padding: 6px var(--sp-3); }
  .ed-crumb, .ed-sizes, .ed-brand { display: none; }
  .ed-id { flex: none; }
  .ed-title { flex: 1 1 0; min-width: 0; }
  .ed-tools { justify-content: flex-end; gap: 4px; }
  .ed-savestatus { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ed-body { flex-direction: column; }
  .ed-stage { order: 1; flex: 1 1 auto; }
  .ed-rail { order: 3; width: 100%; flex-direction: row; justify-content: space-around; border-right: 0; border-top: 1px solid var(--line); padding: 0 0 env(safe-area-inset-bottom); gap: 0; position: relative; z-index: 45; }
  .ed-rbtn { flex: 1; width: auto; border-radius: 0; min-height: 56px; }
  .ed-canvas { padding: 0; background: #fff; }
  .ed-wrap { border-radius: 0 !important; box-shadow: none !important; }
  .ed-drawer, .ed-panel { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 76vh; z-index: 60; border: 0; border-radius: 18px 18px 0 0; box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.3); visibility: hidden; transform: translateY(105%); transition: transform 0.2s, visibility 0.2s; overflow-y: auto; padding-bottom: calc(var(--sp-5) + env(safe-area-inset-bottom)); }
  .ed-drawer { padding: 0; }
  .ed-view { max-height: 76vh; }
  .ed[data-tool=""] .ed-drawer { display: block; }
  body.ed-open-palette .ed-drawer, body.ed-open-panel .ed-panel { visibility: visible; transform: none; }
  .ed-selbar, .ed-selbar.docked { left: 8px !important; right: 8px; top: auto !important; bottom: calc(64px + env(safe-area-inset-bottom)); justify-content: space-around; padding: 4px; z-index: 50; }
  .ed-tb { width: 44px; height: 44px; }
  .ed-colpick select { min-height: 44px; }
  .ed-toast { top: auto; bottom: calc(132px + env(safe-area-inset-bottom)); }
  .ed-tilegrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ed-tile { min-height: 84px; }
  .ed-omove.btn { width: 44px; min-width: 44px; height: 44px; min-height: 44px; }
  .ed-ohandle { width: 36px; min-height: 44px; }
  .ed-oname { min-height: 44px; }
  .ed-seg button, .seg button { min-height: 44px; }
  .ed-tab { min-height: 48px; }
  .ed .btn.ed-btn, .ed .ed-btn { min-height: 44px; }
  .ed-sec > summary { min-height: 48px; }
}
/* The Shared blocks library */
.gb { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 16px; align-items: start; margin: 12px 0; }
#gb-preview { display: block; width: 100%; height: 420px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: #fff; }
.gb-rename { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; max-width: 40rem; }
.gb-rename .field { flex: 1 1 14rem; margin: 0; }
.gb-rename .btn { min-height: 44px; }
.gb-actions { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 4px 0 12px; }
.gb-col { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 12px; padding: 8px 10px; }
.gb-col legend { font-weight: 700; padding: 0 4px; }
.gb-child { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 8px; padding: 6px 10px; }
.gb-child summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.gb-childbar, .gb-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.gb-add select { width: auto; min-height: 44px; }
.gb .btn.small, .gb-actions .btn { min-height: 44px; }
@media (max-width: 800px) { .gb { display: block; } #gb-preview { height: 320px; } }
.gb input[type=radio], .gb input[type=checkbox] { width: auto; flex: none; }
.gb .choice { align-items: center; }
@media (max-width: 800px) { .table .btn.small { min-height: 44px; } }

/* ---- A list row: a visible name link and a "more" menu (Staff and Missionaries; SPEC D141) ---------------------------- */
/* The menu is the menu builder's (.mb-more, .mb-menu, .mb-mi). It drops below its row, so the table must not clip it. */
.more-rows, .more-rows .table { overflow: visible; }
.more-rows .table thead th:first-child { border-top-left-radius: var(--r-lg); }
.more-rows .table thead th:last-child { border-top-right-radius: var(--r-lg); }
.more-rows .table tbody tr:last-child td:first-child { border-bottom-left-radius: var(--r-lg); }
.more-rows .table tbody tr:last-child td:last-child { border-bottom-right-radius: var(--r-lg); }
.more-rows td.right { white-space: nowrap; }
.row-link > span:last-child { color: var(--accent-text); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.row-more-form { margin: 0; }
a.mb-mi { text-decoration: none; }
a.mb-mi:hover { text-decoration: none; }
@media (max-width: 800px) { .mb-mi { min-height: 44px; } .more-rows .mb-menu { position: static; box-shadow: none; margin-top: var(--sp-1); } .more-rows .mb-more { display: block; } }


/* Pictures (B5, D126): the library as a grid with each picture's name and size, the picture control in the block panel, and the chooser dialog. */
.media-up { display: grid; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.media-up h2 { margin: 0; }
.media-grid { list-style: none; padding: 0; margin: var(--sp-4) 0; display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); }
.media-card { display: grid; gap: 4px; align-content: start; padding: 0; overflow: hidden; }
.media-card .lb-open, .media-card .lb-fb { border-radius: 0; }
.media-card .lb-open img, .media-card .lb-fb img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 0; background: var(--surface-hover); border-bottom: 1px solid var(--line); }
/* The preview is the public lightbox (core blocks/lightbox.ts, written into this screen's head), drawn with the admin's own tokens. */
.lb, .lb-ctl { --tm-surface: var(--surface); --tm-ink: var(--ink); --tm-radius: var(--r); --tm-body: var(--font-ui); }
.media-card .media-name, .media-card .muted, .media-card form { padding: 0 var(--sp-3); }
.media-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: var(--sp-2); }
.media-card form { margin: 0; padding-bottom: var(--sp-2); }
.ed-media { border: 0; padding: 0; margin: 0 0 var(--sp-3); display: grid; gap: var(--sp-2); min-width: 0; }
.ed-media legend { font-weight: 600; padding: 0; }
.ed-mthumb { display: grid; gap: 4px; justify-items: start; }
.ed-mthumb img { max-width: 100%; max-height: 9rem; border-radius: 8px; border: 1px solid var(--line); object-fit: contain; background: var(--surface-sunken); }
.ed-mbtns { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.ed-mbtns [hidden], .ed-media [hidden] { display: none; }
dialog.mp { width: min(44rem, calc(100vw - 16px)); max-height: calc(100vh - 16px); padding: var(--sp-4); border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--surface); color: var(--ink); overflow: auto; box-shadow: var(--shadow-2); }
dialog.mp::backdrop { background: rgba(15, 23, 42, 0.5); }
.mp-head { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); }
.mp-head h2 { margin: 0; font-size: var(--fs-lg); }
.mp-grid { list-style: none; padding: 0; margin: var(--sp-3) 0 0; display: grid; gap: var(--sp-2); grid-template-columns: repeat(2, 1fr); }
@media (min-width: 600px) { .mp-grid { grid-template-columns: repeat(4, 1fr); } }
.mp-item { width: 100%; min-height: 44px; display: grid; gap: 4px; padding: 6px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; text-align: left; }
.mp-item:hover { background: var(--accent-tint); }
.mp-item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; background: var(--surface-sunken); }
.mp-name { font-size: var(--fs-sm); overflow-wrap: anywhere; }

.ed-heading { font-size: 18px; margin: 0; }
.ed-intro { margin: 0 0 8px; }
.ed-gridwrap { border: 0; padding: 0; margin: 0 0 12px; min-width: 0; }
.ed-gridwrap legend { font-weight: 600; padding: 0; margin-bottom: 4px; }
.ed-gridscroll { overflow-x: auto; max-width: 100%; margin-bottom: 8px; }
.ed-grid { border-collapse: collapse; }
.ed-grid td { padding: 2px; }
.ed-grid input { min-width: 7rem; min-height: 44px; }
.ed-grid .btn { min-height: 44px; }

/* ---- The menu builder (SPEC D72, D125): a compact tree, one row per item, with the preview kept in view at the right. Tokens only. ---- */
.mb-top { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); align-items: center; position: sticky; top: 0; z-index: 20; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-4); box-shadow: var(--shadow-1); }
.mb-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-left: auto; }
.mb-status { color: var(--muted); font-size: var(--fs-sm); }
.mb-status.bad { color: var(--danger-ink); font-weight: 700; }
.mb-toast { display: flex; align-items: center; gap: var(--sp-3); background: var(--ink); color: #ffffff; border-radius: var(--r); padding: 8px 14px; margin: 0 0 var(--sp-3); }
.mb-cols { display: grid; gap: var(--sp-4); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 62rem) { .mb-cols { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } .mb-right { position: sticky; top: 76px; } }
.mb-card { margin-bottom: var(--sp-4); }
.mb-card h2, .mb-right h2 { margin-top: 0; font-size: var(--fs-lg); }
.mb-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.mb-kids { margin: 2px 0 2px 22px; padding-left: 10px; border-left: 2px solid var(--line); }
.mb-item { margin: 0; }
.mb-row { display: flex; align-items: center; gap: 2px; min-width: 0; padding: 2px 4px; border: 1px solid transparent; border-radius: var(--r); }
.mb-row:hover { background: var(--surface-sunken); border-color: var(--line); }
.mb-item.sel > .mb-row { background: var(--accent-tint); border-color: transparent; }
.mb-item.hidden > .mb-row .mb-text strong { text-decoration: line-through; color: var(--muted); }
.mb-handle { cursor: grab; width: 24px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); user-select: none; touch-action: none; }
.mb-name { flex: 1 1 8rem; min-width: 0; min-height: 40px; display: flex; align-items: center; gap: var(--sp-2); text-align: left; font: inherit; color: var(--ink); background: none; border: 0; border-radius: 6px; padding: 2px 6px; cursor: pointer; }
.mb-kind { color: var(--muted); }
.mb-item.sel > .mb-row .mb-kind { color: var(--accent-tint-ink); }
.mb-text { display: grid; min-width: 0; line-height: 1.25; }
.mb-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mb-text .hint { font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mb-item.sel > .mb-row .mb-text .hint { color: var(--accent-tint-ink); }
.mb-btn.btn { width: 34px; min-width: 34px; min-height: 34px; height: 34px; }
.mb-more { position: relative; }
.mb-more > summary { list-style: none; width: 34px; min-width: 34px; min-height: 34px; height: 34px; padding: 0; }
.mb-more > summary::-webkit-details-marker { display: none; }
.mb-menu { position: absolute; right: 0; top: 100%; z-index: 30; display: grid; gap: 2px; min-width: 13rem; padding: var(--sp-1); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); box-shadow: var(--shadow-2); }
.mb-mi { display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: 40px; padding: 6px 10px; border: 0; border-radius: 8px; background: none; color: var(--ink); font: inherit; font-weight: 500; text-align: left; cursor: pointer; }
.mb-mi:hover:not(:disabled) { background: var(--surface-hover); }
.mb-mi:disabled { opacity: 0.5; cursor: not-allowed; }
.mb-mi.danger { color: var(--danger-ink); }
.mb-mi.danger:hover { background: var(--danger-bg); }
.mb-under { width: 100%; min-height: 40px; }
.mb-flag { margin: 2px 8px 4px 34px; font-size: var(--fs-sm); border-radius: 6px; padding: 4px 8px; }
.mb-flag.warn { background: var(--warn-bg); color: var(--warn-ink); }
.mb-flag.info { color: var(--muted); padding-left: 0; }
.mb-empty { margin: 4px 8px 0 34px; }
.mb-edit { display: grid; gap: var(--sp-3); margin: 4px 6px 8px 34px; padding: var(--sp-3); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-sunken); }
.mb-field { display: grid; gap: 4px; font-weight: 600; }
.mb-field input, .mb-field select { min-height: 40px; font: inherit; }
.mb-check { display: flex; align-items: center; gap: var(--sp-2); min-height: 40px; }
.mb-addrow { display: flex; flex-wrap: wrap; align-items: end; gap: var(--sp-2); margin: 0 0 var(--sp-3); }
.mb-form { margin: 0 0 var(--sp-3); padding: 0 var(--sp-3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.mb-form > summary { list-style: none; min-height: 44px; display: flex; align-items: center; gap: var(--sp-2); cursor: pointer; font-weight: 600; }
.mb-form > summary::-webkit-details-marker { display: none; }
.mb-form > summary::after { content: ""; flex: none; width: 8px; height: 8px; margin: 0 4px 3px auto; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform 0.15s; }
.mb-form[open] > summary::after { transform: rotate(-135deg); margin-bottom: 0; }
.mb-form:hover { border-color: var(--line-strong); }
.mb-form[open] { display: grid; gap: var(--sp-2); padding-bottom: var(--sp-3); }
.mb-marked { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.mb-marked li { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.mb-frame { width: 100%; height: 30rem; border: 1px solid var(--line-strong); border-radius: var(--r); background: #fff; }
.mb-right .mb-field { margin-bottom: var(--sp-3); }
@media (max-width: 800px) {
  .mb-actions { margin-left: 0; }
  .mb-btn.btn, .mb-more > summary { width: 44px; min-width: 44px; height: 44px; min-height: 44px; }
  .mb-handle { width: 32px; min-height: 44px; }
  .mb-name { min-height: 44px; }
  .mb-mi { min-height: 44px; }
  .mb-frame { height: 22rem; }
  .mb-top { position: static; }
}

/* ---- Custom CSS and Embeds (B8). Admin tokens only. ---- */
.cs-top { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); align-items: center; position: sticky; top: 0; z-index: 20; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-4); box-shadow: var(--shadow-1); }
.cs-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-left: auto; }
.cs-status { color: var(--muted); font-size: var(--fs-sm); }
.cs-status.bad { color: var(--danger-ink); font-weight: 700; }
.cs-cols { display: grid; gap: var(--sp-5); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 70rem) { .cs-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .cs-right { position: sticky; top: 76px; } }
.cs-label { display: flex; flex-wrap: wrap; gap: 4px var(--sp-3); align-items: baseline; margin-bottom: 4px; }
.cs-over { color: var(--danger-ink); font-weight: 700; }
.cs-text { font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.5; tab-size: 2; min-height: 22rem; white-space: pre; overflow: auto; background: var(--surface); }
.cs-errors, .cs-warnings { margin-top: var(--sp-2); }
.cs-notes { margin: 6px 0 0; padding-left: 18px; }
.cs-notes li { margin: 4px 0; overflow-wrap: anywhere; }
.cs-notes button.link { min-height: 32px; font-weight: 700; }
.cs-help { margin-top: var(--sp-3); }
.cs-help > summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.cs-help code, .cs-intro code, .ph-desc code { background: var(--surface-hover); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: var(--fs-sm); }
.cs-field { display: grid; gap: 4px; font-weight: 600; margin-bottom: var(--sp-2); }
.cs-frame { width: 100%; height: 30rem; border: 1px solid var(--line-strong); border-radius: var(--r); background: #fff; }
.cs-safe { margin-top: var(--sp-5); }
@media (max-width: 800px) { .cs-actions { margin-left: 0; } .cs-frame { height: 24rem; } .cs-top { position: static; } }
.cs-scroll { overflow-x: auto; max-width: 100%; }

/* ---- Templates (the gallery, one template's page, the /ops screen). Everything is .tpl- or .ops-. ---- */
.tpl-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); }
.tpl-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.tpl-card:hover { box-shadow: var(--shadow-2); }
.tpl-pic { display: block; width: 100%; height: auto; aspect-ratio: 1200 / 750; object-fit: cover; background: var(--surface-sunken); border-bottom: 1px solid var(--line); }
.tpl-nopic { min-height: 8rem; }
.tpl-body { padding: var(--sp-3) var(--sp-4) var(--sp-4); display: grid; gap: 6px; align-content: start; flex: 1; }
.tpl-body h3 { margin: 0; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.tpl-body p { margin: 0; }
.tpl-body .actions { margin-top: auto; padding-top: var(--sp-2); }
.tpl-update { display: grid; gap: 6px; }
.tpl-changes { margin: 4px 0; padding-left: 18px; }
.tpl-history { list-style: none; padding: 0; margin: 0; }
.tpl-history li { padding: var(--sp-3) 0; border-bottom: 1px solid var(--line); }
.tpl-history li:last-child { border-bottom: 0; }
.tpl-history ul { margin: 4px 0 0; padding-left: 18px; }
.row-choices { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-5); }
.tpl-view .choice { min-height: 40px; align-items: center; }
.inline-form { display: grid; gap: var(--sp-2); justify-items: start; }
/* The preview frame is the viewport, so the template's own media queries answer for a phone when it is 390 pixels wide. */
.tpl-preview .preview iframe { display: block; margin: 0 auto; }
.tpl-now { margin-bottom: var(--sp-4); }
@media (min-width: 901px) { .editor-grid:has(input[name="width"][value="phone"]:checked) .tpl-preview .preview iframe { width: 390px; max-width: 100%; } }
@media (max-width: 900px) { .editor-grid:has(input[name="width"][value="phone"]:checked) .tpl-preview .preview iframe { width: 390px; max-width: 100%; } .tpl-preview .preview iframe { height: 28rem; } }
.ops-template .head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sp-2); align-items: baseline; }
.ops-template .table { display: block; overflow-x: auto; }
.ops-report ul { margin: 4px 0 12px; padding-left: 18px; }
.ops-report li { overflow-wrap: anywhere; }
#apply input[type=radio], #apply input[type=checkbox] { flex: none; margin-top: 3px; }
.tpl-view .row-choices .choice { flex: 0 0 auto; }
.choices { border-color: var(--line); }


/* ---- Collapsible form sections (Look and feel, Church settings): a native details, the chevron drawn like the menu builder's add forms ---- */
.fsec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.fsec:hover { border-color: var(--line-strong); }
.fsec > summary { list-style: none; min-height: 48px; padding: var(--sp-2) var(--sp-4); display: flex; flex-wrap: wrap; align-items: baseline; column-gap: var(--sp-3); cursor: pointer; font-weight: 700; border-radius: var(--r); position: relative; padding-right: calc(var(--sp-4) + 24px); align-content: center; }
.fsec > summary::-webkit-details-marker { display: none; }
.fsec > summary::after { content: ""; position: absolute; right: var(--sp-4); top: 50%; width: 8px; height: 8px; margin-top: -6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform 0.15s; color: var(--muted); }
.fsec[open] > summary::after { transform: rotate(-135deg); margin-top: -2px; }
.fsec > summary:hover { background: var(--surface-hover); }
.fsec[open] > summary { border-bottom: 1px solid var(--line); border-radius: var(--r) var(--r) 0 0; }
.fsec-h { font-weight: 400; font-size: var(--fs-sm); color: var(--muted); }
.fsec-body { display: grid; gap: var(--sp-4); padding: var(--sp-4); }
.fsec-body fieldset.repeat { border: 0; padding: 0; }
.fsec-body fieldset.choices { background: var(--surface); }
.empty-act .btn { text-decoration: none; }
.table-wrap > .empty, [data-filter-empty] > .empty { margin-top: var(--sp-3); }

/* ---- The phone pass (390 wide): every target 44px, no screen wider than the screen, tables stacked or scrolling inside their box ---- */
@media (max-width: 800px) {
  .tb-brand, .ph-back { min-height: 44px; }
  .ph-back { padding-right: var(--sp-3); }
  .row-title, .table td a.person, .person.row-link, .row-main a { display: inline-flex; align-items: center; min-height: 44px; }
  .person.row-link { min-height: 44px; }
  .more-rows .person { min-height: 44px; }
  .btn.small { min-width: 44px; }
  .rt-btn { width: 44px; height: 44px; }
  .rt-item, .rt-pop .btn, .rt-field > details > summary { min-height: 44px; }
  .gb-childbar .btn { min-height: 44px; }
  .mb-under, .mb-field input, .mb-field select { min-height: 44px; }
  .colorpair input[type=color] { height: 44px; }
  input[type=file] { min-height: 44px; padding: 9px 0; }
  .member-actions select { min-height: 44px; }
  .fsec > summary { min-height: 52px; }
  .fsec-body { padding: var(--sp-3); }
  .empty { padding: var(--sp-6) var(--sp-4); }
  .ops-template .table { overflow-x: visible; }
  .savebar .btn { flex: 1 1 auto; }
}
@media (max-width: 800px) {
  .table td > a:not(.btn) { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; }
  .plain-brand .brand { min-height: 44px; }
}
@media (max-width: 800px) {
  .seg-opt, .ed-starter select { min-height: 44px; }
}
.ed-sec + .btn { margin-top: var(--sp-3); }
@media (max-width: 700px) {
  .table:has(td[data-label]) td { flex-wrap: wrap; }
  .table:has(td[data-label]) td > .hint, .table:has(td[data-label]) td > br { flex: 1 1 100%; }
  .table:has(td[data-label]) td > br { display: none; }
}

/* ---- Modules (the church's Modules screen). Everything is .mod-. ---- */
.mod-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); }
.mod { display: grid; gap: var(--sp-2); align-content: start; }
.mod p { margin: 0; }
.mod-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.mod-head h2 { margin: 0; font-size: var(--fs-lg); }
.mod-act { padding-top: var(--sp-2); }
.mod-confirm > summary { list-style: none; cursor: pointer; display: inline-flex; }
.mod-confirm > summary::-webkit-details-marker { display: none; }
.mod-confirm-body { margin-top: var(--sp-3); padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface-sunken); display: grid; gap: var(--sp-2); }
.mod-confirm-body p, .mod-confirm-body ul { margin: 0; }
.mod-confirm-body .plain { padding-left: 18px; display: grid; gap: 4px; }

/* Hosted video (the video module): the Pictures and Videos tabs, the upload progress, the video list and the chooser's rows. */
.subtabs { display: flex; gap: var(--sp-2); margin: 0 0 var(--sp-4); border-bottom: 1px solid var(--line); }
.subtabs a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--sp-4); text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 600; }
.subtabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.vu-progress progress { width: 100%; height: 1.25rem; }
.video-list { list-style: none; padding: 0; margin: var(--sp-4) 0; display: grid; gap: var(--sp-4); }
.video-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); }
.video-preview video { display: block; width: 100%; max-width: 32rem; height: auto; margin-top: var(--sp-2); background: var(--surface-sunken); border-radius: 8px; }
.video-caps h3 { font-size: var(--fs-md, 1rem); margin: var(--sp-3) 0 var(--sp-2); }
.video-tracks { list-style: none; padding: 0; margin: 0 0 var(--sp-3); display: grid; gap: var(--sp-2); }
.video-tracks li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.video-capfields { display: grid; gap: var(--sp-3); grid-template-columns: 1fr; }
@media (min-width: 40rem) { .video-capfields { grid-template-columns: 1fr 2fr; } }
.vp-list { display: grid; grid-template-columns: 1fr; gap: var(--sp-2); }
.vp-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; min-height: 44px; text-align: left; }
.vp-icon { font-size: 1.25rem; }
.how summary, .video-preview > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; }
.mod-open { display: inline-flex; align-items: center; min-height: 32px; margin-right: var(--sp-3); }

/* Self-serve signup, the Welcome screen and the Setup checklist (SPEC D241). Tokens only. */
.slug-row { display: flex; align-items: stretch; gap: 0; }
.slug-row input { flex: 1 1 6rem; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.slug-suffix { flex: 0 0 auto; white-space: nowrap; display: inline-flex; align-items: center; padding: 0 var(--sp-3); border: 1px solid var(--field-edge); border-left: 0; border-radius: 0 var(--r) var(--r) 0; background: var(--surface-sunken); color: var(--ink-2); font-weight: 400; overflow-wrap: anywhere; }
.slug-status { min-height: 1.4em; font-size: var(--fs-sm); }
.ok-text { color: var(--ok-ink); font-weight: 600; font-size: var(--fs-sm); }
.two-field { display: grid; gap: var(--sp-4); grid-template-columns: 1fr; }
@media (min-width: 40rem) { .two-field { grid-template-columns: 1fr 1fr; } }
fieldset.field { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.field legend { font-weight: 600; padding: 0; margin-bottom: 6px; }
.look-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr)); }
.look-pick { display: grid; gap: var(--sp-2); align-content: start; height: 100%; padding: var(--sp-2); border: 1px solid var(--field-edge); border-radius: var(--r); background: var(--surface); cursor: pointer; font-weight: 400; }
.look-pick:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-ring); }
.look-pick:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--accent-ring); }
.look-pick input { justify-self: start; }
.look-pic { display: block; width: 100%; height: auto; aspect-ratio: 1200 / 750; object-fit: cover; border-radius: var(--r-sm, 6px); background: var(--surface-sunken); }
.look-text, .look-none { display: grid; gap: 2px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-2) var(--sp-4); margin: var(--sp-4) 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.invite-code { font-size: var(--fs-xl); margin: var(--sp-2) 0; }
.invite-code code { padding: var(--sp-2) var(--sp-3); background: var(--surface-sunken); border: 1px solid var(--line-strong); border-radius: var(--r); letter-spacing: 0.08em; user-select: all; }
.setup-head { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); align-items: baseline; justify-content: space-between; }
.setup-head h2 { margin: 0; }
.setup-bar { width: 100%; height: 10px; margin: var(--sp-3) 0; accent-color: var(--accent); }
.setup-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-1); }
.setup-list li { display: flex; align-items: center; gap: var(--sp-3); min-height: 44px; padding: var(--sp-2) 0; border-top: 1px solid var(--line); }
.setup-list li:first-child { border-top: 0; }
.setup-mark { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 24px; height: 24px; border: 2px solid var(--field-edge); border-radius: 50%; }
.setup-list li.done .setup-mark { background: var(--ok-bg); border-color: var(--ok-ink); color: var(--ok-ink); }
.setup-mark svg { width: 14px; height: 14px; }
.setup-text { display: grid; gap: 2px; flex: 1 1 auto; min-width: 0; }
.setup-list li.done .setup-text a { color: var(--ink-2); }
.setup-dismiss { margin-top: var(--sp-3); }
.setup-act { margin-top: 4px; }
.welcome-step-head { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.welcome-step-head h2 { margin: 0; flex: 1 1 auto; }
.welcome-n { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-tint); color: var(--accent-tint-ink); font-weight: 700; }
.time-row { display: grid; gap: var(--sp-3); grid-template-columns: 1fr; margin-bottom: var(--sp-2); }
@media (min-width: 40rem) { .time-row { grid-template-columns: 1.2fr 1fr 1.4fr; } }
.welcome-foot { display: flex; flex-wrap: wrap; gap: var(--sp-3); justify-content: space-between; margin: var(--sp-4) 0; }

/* A person who asks for less motion gets none: every transition and animation is cut to an instant (WCAG 2.3.3, SPEC D181). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* Help (SPEC D249): the icon button beside a screen's title, and the short "Learn more" link under a confusing control. The target is 44 pixels
   on every screen (a help button is easy to miss and hard to hit otherwise). The title stays the width of its words and wraps inside its own box,
   so on a phone the button sits at the end of the title instead of dropping to a line of its own. */
.ph-h { display: flex; align-items: center; gap: var(--sp-1); min-width: 0; max-width: 100%; }
.ph-h h1 { min-width: 0; }
.btn.help-btn { flex: none; width: 44px; min-width: 44px; height: 44px; color: var(--muted); }
.btn.help-btn:hover { color: var(--ink); }
.learn-more { font-size: var(--fs-sm); white-space: nowrap; }
.ed-head-btns { display: inline-flex; align-items: center; gap: 2px; }
.ed-help-line { margin: var(--sp-2) 0; }
.pb-tools { display: inline-flex; align-items: center; gap: var(--sp-2); }
.setup-head { align-items: center; }
.setup-head .muted { margin-left: auto; }
.setup-head .help-btn { margin-block: -8px; }
/* ---- Recurring events (SPEC D247): the Repeats part of the event form, the dates panel and the repeat mark in the Events list ---- */
/* ---- Recurring events (SPEC D251): the Repeats part of the event form, the dates panel and the repeat mark in the Events list ---- */
.ev-repeat { gap: var(--sp-3); }
[data-repeat-for][hidden] { display: none !important; }
.ev-every-box { display: inline-flex; align-items: center; gap: var(--sp-2); }
.ev-every-box input { width: 5.5rem; }
.ev-days { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); }
.ev-end { gap: var(--sp-2); }
.ev-end .check { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); min-height: var(--tap); }
.ev-end input[type="number"] { width: 6rem; }
.ev-summary { margin: 0; padding: var(--sp-3) var(--sp-4); background: var(--surface-sunken); border: 1px solid var(--line); border-radius: var(--r); }
.ev-summary-err { color: var(--danger-ink); font-weight: 600; }
.ev-next ol { margin: 0; padding-left: 20px; }
.ev-next[hidden] { display: none; }
.ev-repeat-line { display: flex; align-items: center; gap: var(--sp-1); margin-top: 2px; }
.ev-repeat-i { width: 14px; height: 14px; flex: none; }
.ev-dates h2 { margin: 0; font-size: var(--fs-lg); }
.ev-dates h3 { margin: var(--sp-3) 0 0; font-size: var(--fs-md); }
.ev-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.ev-actions form { margin: 0; }

.ev-changes { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.ev-changes li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--sp-2) var(--sp-4); padding: var(--sp-2) 0; border-bottom: 1px solid var(--line); }
.ev-changes li:last-child { border-bottom: 0; }
.ev-changes form { margin: 0; }
.ev-date-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.ev-date-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--sp-2) var(--sp-4); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line); }
.ev-date-row:last-child { border-bottom: 0; }
.ev-date-info { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-2); min-width: 0; }
.ev-date-info small { flex-basis: 100%; }

/* ---- Search and sharing (SPEC D257) ------------------------------------------------------------------------ */
.seo-count.over { color: var(--danger-ink); font-weight: 600; }
.seo-warn { margin: 0; }
.seo-box { display: grid; gap: var(--sp-3); }

/* Download my site (SPEC D261): the choices, the progress bar and the list. */
.xp-opts { border: 0; padding: 0; margin: 0; display: grid; gap: var(--sp-3); }
.xp-opts legend { padding: 0; margin-bottom: var(--sp-2); }
.xp-opt { align-items: flex-start; min-height: 0; }
.xp-opt input { margin-top: 4px; flex: none; }
.xp-hint { display: block; }
.xp-bar { display: block; width: 100%; height: 12px; border: 0; border-radius: var(--r-pill); background: var(--line); overflow: hidden; appearance: none; accent-color: var(--accent); }
.xp-bar::-webkit-progress-bar { background: var(--line); border-radius: var(--r-pill); }
.xp-bar::-webkit-progress-value { background: var(--accent); border-radius: var(--r-pill); }
.xp-bar::-moz-progress-bar { background: var(--accent); border-radius: var(--r-pill); }
.xp-progress .actions { margin-top: var(--sp-3); }
.xp-h { margin-top: var(--sp-5); }

/* The Members screen (SPEC D313). */
.cg-tabs { margin: 0 0 var(--sp-4); }
.cg-tabs a.fchip { text-decoration: none; }
.cg-requests { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-4); }
.cg-request { border-top: 1px solid var(--line); padding-top: var(--sp-3); }
.cg-request:first-child { border-top: 0; padding-top: 0; }
.cg-note { margin: var(--sp-2) 0; padding: var(--sp-2) var(--sp-3); border-left: 3px solid var(--line); color: var(--ink-2); white-space: pre-line; }
.cg-groups, .cg-vis fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: var(--sp-2) var(--sp-3); margin: 0; }
.cg-indent { margin-left: var(--sp-5); }
.cg-search { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-end; margin: 0 0 var(--sp-4); }
.cg-photo { max-width: 100%; height: auto; border-radius: var(--r); }
