:root {
  --bg: #ffffff;
  --page: #fdfdfc;
  --panel: #ffffff;
  --panel2: #f5f5f4;
  --line: #e4e4e2;
  --line2: #c8c8c5;
  --text: #262626;
  --label: #3a3a3a;
  --muted: #6b6b6b;
  --accent: #ff5e1f; --green: #15784f; --green-bg: #e8f5ee; --green-line: #b5dfc8;
  --ink: #c2410c;
  --btn: #cc4410;
  --btn2: #b93c0a;
  --danger: #c62828;
  --ok: #15784f;
  --warn: #9a6200;
  --r: 4px;
  --shadow: 0 4px 60px rgba(255, 80, 10, .06), 0 2px 12px rgba(0, 0, 0, .03);
  --ease: cubic-bezier(0.19, 1, 0.22, 1);
  --font: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --hover: #ececea;
  --tint: #fff7f3;
  --tint2: #fff1ea;
  --tint-line: #ffd2bf;
  --ok-bg: #e8f5ee; --ok-line: #b5dfc8;
  --warn-bg: #fff4e0; --warn-ink: #7a4d00; --warn-line: #f2d49b;
  --danger-bg: #fdecec; --danger-line: #f1b5b5;
  --group: #fbfbfa;
  --glass: rgba(255, 255, 255, .85);
  --grid-dot: rgba(0, 0, 0, .07);
  --checker: #dddddd;
  --inv: #262626; --inv-text: #ffffff;
  color-scheme: light;
}
/* Dark mode: follows the device unless the ◐ switch picks Light or Dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141414;
    --page: #0f0f0f;
    --panel: #1a1a1a;
    --panel2: #222222;
    --line: #2f2f2f;
    --line2: #474747;
    --text: #f2f2f0;
    --label: #d6d6d3;
    --muted: #a3a3a0;
    --accent: #ff6a2e; --green: #4fd197; --green-bg: #10291d; --green-line: #24573b;
    --ink: #ff8a5c;
    --btn: #cc4410;
    --btn2: #e0500f;
    --danger: #ff8080;
    --ok: #4fd197;
    --warn: #f5b942;
    --shadow: 0 4px 60px rgba(255, 80, 10, .05), 0 2px 12px rgba(0, 0, 0, .4);
    --hover: #2a2a2a;
    --tint: #26170f;
    --tint2: #33190c;
    --tint-line: #5c2c14;
    --ok-bg: #12291d; --ok-line: #24573b;
    --warn-bg: #2b2210; --warn-ink: #f5c86a; --warn-line: #5a4517;
    --danger-bg: #2e1414; --danger-line: #6b2b2b;
    --group: #1d1d1d;
    --glass: rgba(20, 20, 20, .85);
    --grid-dot: rgba(255, 255, 255, .06);
    --checker: #444444;
    --inv: #f2f2f0; --inv-text: #141414;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141414;
  --page: #0f0f0f;
  --panel: #1a1a1a;
  --panel2: #222222;
  --line: #2f2f2f;
  --line2: #474747;
  --text: #f2f2f0;
  --label: #d6d6d3;
  --muted: #a3a3a0;
  --accent: #ff6a2e; --green: #4fd197; --green-bg: #10291d; --green-line: #24573b;
  --ink: #ff8a5c;
  --btn: #cc4410;
  --btn2: #e0500f;
  --danger: #ff8080;
  --ok: #4fd197;
  --warn: #f5b942;
  --shadow: 0 4px 60px rgba(255, 80, 10, .05), 0 2px 12px rgba(0, 0, 0, .4);
  --hover: #2a2a2a;
  --tint: #26170f;
  --tint2: #33190c;
  --tint-line: #5c2c14;
  --ok-bg: #12291d; --ok-line: #24573b;
  --warn-bg: #2b2210; --warn-ink: #f5c86a; --warn-line: #5a4517;
  --danger-bg: #2e1414; --danger-line: #6b2b2b;
  --group: #1d1d1d;
  --glass: rgba(20, 20, 20, .85);
  --grid-dot: rgba(255, 255, 255, .06);
  --checker: #444444;
  --inv: #f2f2f0; --inv-text: #141414;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); color: var(--text); font: 14px/1.45 var(--font); letter-spacing: -.14px; min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: var(--ink); }
button, .btn { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
input, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 9px 12px; width: 100%; min-width: 0; }
input:hover, select:hover { border-color: var(--line2); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
select.sm { width: auto; padding: 6px 10px; font-size: 12.5px; }
h1 { font-size: 32px; font-weight: 500; line-height: 1; margin: 0; letter-spacing: -.8px; }
h2 { font-size: 19px; font-weight: 500; line-height: 1.2; margin: 0; letter-spacing: -.48px; }
b, strong { font-weight: 600; }
button, a, input, select { transition: background-color .1s, border-color .1s, color .1s; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.grow { flex: 1; }
.mono { font-family: var(--mono); font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 8px; }

.primary { background: var(--btn); border: 1px solid var(--btn); color: #fff; border-radius: 4px; padding: 8px 16px; min-height: 36px; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.primary:hover { background: var(--btn2); border-color: var(--btn2); }
.ghost { background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 8px 14px; min-height: 36px; font-weight: 500; color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.ghost:hover { background: var(--hover); border-color: var(--line2); }
.sm { padding: 5px 12px; min-height: 30px; font-size: 12.5px; }
.danger { color: var(--danger); }
.wide { width: 100%; padding: 11px; }

.top { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 800; font-size: 16px; display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.brand.big { font-size: 20px; justify-content: center; margin-bottom: 18px; }
.dot { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle, var(--green) 30%, var(--accent) 34%); border-radius: 50%; }
.churchsel { width: auto; max-width: 50vw; }

.main { max-width: 1680px; margin: 0 auto; padding: 36px 24px 72px; }
.head { display: flex; align-items: center; gap: 12px; margin: 0 0 20px; flex-wrap: wrap; }
.head:has(h2) { margin-top: 48px; padding-top: 32px; border-top: 1px solid var(--line); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); }
.card.center { padding: 40px 20px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.tile { display: flex; flex-direction: column; gap: 4px; color: var(--text); text-decoration: none; }
.tile:hover { border-color: var(--accent); }
.page { display: flex; flex-direction: column; gap: 14px; }
.page:hover { border-color: var(--line2); }
.page > .row.wrap { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.pagehead { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.pagehead b { font-size: 16px; }
.pill { font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--panel2); color: var(--label); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.pill.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }

.more { position: relative; }
.more summary { list-style: none; padding: 8px 12px; }
.more summary::-webkit-details-marker { display: none; }
.more .menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel2); border: 1px solid var(--line2); border-radius: 4px; padding: 6px; min-width: 190px; z-index: 4; display: flex; flex-direction: column; box-shadow: 0 8px 24px rgba(0, 0, 0, .12); }
.more .menu button { background: none; border: 0; text-align: left; padding: 9px 12px; border-radius: 3px; }
.more .menu button:hover { background: var(--line); }

.list { padding: 4px 20px; }
.person { display: flex; align-items: center; gap: 10px; padding: 16px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.person:last-child { border-bottom: 0; }
.person .who { flex: 1; min-width: 180px; display: flex; flex-direction: column; }
.dangerzone { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); text-align: right; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line2); border-radius: 4px; padding: 0; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(38, 38, 38, .45); }
.dlgform { display: flex; flex-direction: column; gap: 16px; padding: 24px; }
.dlgform p { margin: 0; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; color: var(--label); }
label .small { font-weight: 400; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--inv); color: var(--inv-text); padding: 10px 16px; border-radius: 4px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* sign-in page */
.loginpage { display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 400px; padding: 32px 28px; }
.login form { display: flex; flex-direction: column; gap: 16px; }
.login h1 { font-size: 19px; text-align: center; }
.google { display: flex; align-items: center; justify-content: center; gap: 10px; background: #fff; color: #1f1f1f; border-radius: 4px; padding: 10px; font-weight: 600; text-decoration: none; }
.google:hover { background: #f1f3f4; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.msg { margin: 14px 0 0; color: var(--danger); text-align: center; }
.msg.good { color: var(--ok); }
[hidden] { display: none !important; }

/* tap stats */
.stats { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 12px 14px; }
.stats:hover { border-color: var(--accent); }
.statnums { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.statnums .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bars { width: 96px; height: 32px; flex-shrink: 0; }
.bars rect { fill: var(--accent); }
.bars rect.zero { fill: var(--line2); }
.bars.tall { width: 100%; height: 120px; display: block; }
dialog:has(.statsdlg) { width: min(1280px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
.statcols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.statcol { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.statsdlg .taplist { max-height: 46vh; }
.statsdlg .log { max-height: calc(100vh - 480px); min-height: 240px; }
@media (max-width: 900px) { .statcols { grid-template-columns: minmax(0, 1fr); } .statsdlg .log { max-height: 60vh; } }
.statsdlg h3 { font-size: 14px; margin: 6px 0 0; }
.statbig { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.statbig > div { background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 14px; display: flex; flex-direction: column; }
.statbig b { font-size: 22px; }
.chart { background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 14px 14px 8px; }
.taplist { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.tapRow { display: grid; grid-template-columns: minmax(0, 1.2fr) 1fr 3.5em; gap: 10px; align-items: center; }
.tapLabel { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tapBar { height: 8px; background: var(--panel2); border-radius: 3px; overflow: hidden; }
.tapBar i { display: block; height: 100%; background: var(--green); border-radius: 3px; }
.tapRow b { text-align: right; }

/* connect card answers */
.answers { width: 100%; text-align: left; background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 12px 14px; display: flex; align-items: center; gap: 8px; }
.answers:hover { border-color: var(--accent); }
.answers .pill { margin-left: auto; }
dialog:has(.answersdlg) { width: min(1280px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
.answerlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; align-items: start; max-height: calc(100vh - 230px); overflow-y: auto; }
.answer { background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 14px 16px; }
.answer.new { border-color: var(--ok); }
.answer dl { margin: 8px 0 0; display: grid; grid-template-columns: minmax(90px, 35%) 1fr; gap: 4px 12px; }
.answer dt { color: var(--muted); font-size: 12px; padding-top: 1px; }
.answer dd { margin: 0; white-space: pre-wrap; word-break: break-word; }

/* template picker: page previews side by side */
.tplgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; padding: 20px; }
.tplcard { font: inherit; color: inherit; text-align: left; background: transparent; border: 0; padding: 0; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.tplprev { position: relative; width: 100%; aspect-ratio: 195 / 300; border-radius: 4px; overflow: hidden; border: 2px solid var(--line); background: #000; margin-bottom: 6px; transition: border-color .15s, transform .15s; }
.tplprev iframe { position: absolute; top: 0; left: 0; width: 200%; height: 200%; border: 0; transform: scale(.5); transform-origin: 0 0; pointer-events: none; }
.tplprev.blank { display: flex; align-items: center; justify-content: center; background: transparent; border-style: dashed; font-size: 44px; color: var(--muted); }
.tplcard:hover .tplprev, .tplcard:focus-visible .tplprev { border-color: var(--accent); transform: translateY(-2px); }
.tplcard small { color: var(--muted); font-size: 12px; line-height: 1.35; }
dialog:has(.newpage) { width: min(1080px, calc(100vw - 24px)); }
.newpage .tplgrid { padding: 4px 0 0; max-height: 62vh; overflow-y: auto; }

/* admin templates panel */
.tplpanel { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tplitem { display: flex; flex-direction: column; gap: 10px; }
.tplitem .tplprev { margin-bottom: 2px; }
.tplitem.off .tplprev { opacity: .45; }
#tplBtn.on { border-color: var(--accent); }

/* activity log */
.activity { display: flex; flex-direction: column; gap: 10px; }
.activity h3 { margin: 6px 0 0; }
.activity input[type=date] { width: auto; padding: 4px 8px; font-size: 12px; }
.log { display: flex; flex-direction: column; max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: 4px; }
.logrow { display: flex; gap: 14px; padding: 10px 14px; align-items: flex-start; }
.logrow + .logrow { border-top: 1px solid var(--line); }
.logtime { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; min-width: 64px; padding-top: 2px; }
.logwhat { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.logtaps { display: flex; flex-wrap: wrap; gap: 4px; }
.logtap { background: var(--panel2); border-radius: 99px; padding: 2px 9px; font-size: 12px; display: inline-flex; gap: 6px; align-items: baseline; }
.logtap small { color: var(--muted); font-size: 11px; }

/* phones: tighter outer gutters, keep the top bar on one line */
.top .ghost { white-space: nowrap; }
@media (max-width: 600px) {
  .top { padding: 10px 16px; gap: 8px; }
  .main { padding: 24px 16px 56px; }
  .churchsel { flex: 1; max-width: none; min-width: 0; }
  .top .grow { display: none; }
  #tplBtn .lbl { display: none; }
  .card { padding: 16px; }
}

/* stats link page and the Share stats dialog */
.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 500; cursor: pointer; }
.check input { width: auto; margin: 3px 0 0; accent-color: var(--btn); }
.check > span { display: flex; flex-direction: column; gap: 2px; }
.topname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topname:not(:empty)::before { content: '·'; margin-right: 10px; }
.head .sub { margin: 4px 0 0; }
.overview { display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 1000px) { .wideov { display: grid; grid-template-columns: minmax(420px, 1fr) 2fr; align-items: stretch; } .wideov .statbig > div { justify-content: center; } }
.page .taplist { max-height: none; }
.foot { margin-top: 32px; text-align: center; }
