:root {
  /* Brand: Caminho Santo logo blues */
  --brand: #245aa8;
  --brand-deep: #114c8f;
  --accent: var(--brand);
  --masthead-bg:
    radial-gradient(120% 220% at 100% 0%, rgba(60, 118, 200, .5) 0%, transparent 60%),
    linear-gradient(115deg, #041733 0%, #0a2f60 50%, #1a4a8c 100%);

  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #e9eef5;
  --ink: #14213d;
  --ink-2: #47536b;
  --ink-3: #8590a4;
  --line: #dde3ec;
  --line-strong: #c4cedd;
  --holiday: #f8ecd4;
  --holiday-ink: #8a6424;
  --today: var(--brand);
  --shadow: 0 1px 2px rgba(20, 33, 61, .05), 0 8px 24px -12px rgba(20, 33, 61, .18);

  --m-eventos: #3f4f8f;
  --m-evangelismo: #b4583b;
  --m-kids: #c48b17;
  --m-casais: #b04a6c;
  --m-mov: #2d7f7a;
  --m-rd: #6b7a32;
  --m-edb: #77508f;
  --m-geral: #5e6472;

  --st-sugestao: #8a8b90;
  --st-a_confirmar: #c07a12;
  --st-revisar: #b23b3b;
  --st-sem_data: #77508f;
  --st-confirmado: #2e7d4f;

  --radius: 14px;
  --radius-sm: 8px;
  --font-display: "Outfit", "Inter", system-ui, sans-serif;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #86aef0;
    --brand-deep: #6f9be6;
    --masthead-bg:
    radial-gradient(120% 220% at 100% 0%, rgba(60, 118, 200, .26) 0%, transparent 60%),
    linear-gradient(115deg, #030e22 0%, #071d3b 50%, #0f2f5c 100%);
    --bg: #0f141d;
    --surface: #161c27;
    --surface-2: #1e2633;
    --ink: #e8ecf3;
    --ink-2: #b2bccb;
    --ink-3: #7a869a;
    --line: #263043;
    --line-strong: #33405a;
    --holiday: #2e281d;
    --holiday-ink: #e2bf83;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
    --m-eventos: #8796d8;
    --m-evangelismo: #e08a6c;
    --m-kids: #e3b450;
    --m-casais: #df7fa0;
    --m-mov: #5fbab3;
    --m-rd: #a8b765;
    --m-edb: #b28ccb;
    --m-geral: #9aa0ae;
    --st-sugestao: #9a9a9f;
    --st-a_confirmar: #e3a34a;
    --st-revisar: #e07272;
    --st-sem_data: #b28ccb;
    --st-confirmado: #6cc08f;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --brand: #86aef0;
  --brand-deep: #6f9be6;
  --masthead-bg:
    radial-gradient(120% 220% at 100% 0%, rgba(60, 118, 200, .26) 0%, transparent 60%),
    linear-gradient(115deg, #030e22 0%, #071d3b 50%, #0f2f5c 100%);
  --bg: #0f141d;
  --surface: #161c27;
  --surface-2: #1e2633;
  --ink: #e8ecf3;
  --ink-2: #b2bccb;
  --ink-3: #7a869a;
  --line: #263043;
  --line-strong: #33405a;
  --holiday: #2e281d;
  --holiday-ink: #e2bf83;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
  --m-eventos: #8796d8;
  --m-evangelismo: #e08a6c;
  --m-kids: #e3b450;
  --m-casais: #df7fa0;
  --m-mov: #5fbab3;
  --m-rd: #a8b765;
  --m-edb: #b28ccb;
  --m-geral: #9aa0ae;
  --st-sugestao: #9a9a9f;
  --st-a_confirmar: #e3a34a;
  --st-revisar: #e07272;
  --st-sem_data: #b28ccb;
  --st-confirmado: #6cc08f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Masthead ─────────────────────────────────────────── */
/* Brand band: white logo on Caminho Santo blue (same in both themes, just deeper in dark). */
/* One compact row: logo · section tabs · counters. */
.masthead {
  display: flex;
  align-items: center;
  gap: 36px;
  padding: 0 40px;
  min-height: 64px;
  background: var(--masthead-bg);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand-mark { width: 30px; height: 40px; flex: none; fill: #fff; stroke: none; }
h1 { margin: 0; line-height: 0; }
/* Wordmark PNG is white-on-transparent, used as a mask so it can be painted any color. */
.wordmark {
  display: block;
  width: 108px; /* 1200×463 source */
  height: 42px;
  background: #fff;
  -webkit-mask: url("assets/wordmark-caminho-santo.png") center / contain no-repeat;
  mask: url("assets/wordmark-caminho-santo.png") center / contain no-repeat;
}
.section-tabs { display: flex; align-self: stretch; gap: 4px; }
.section-tabs button {
  position: relative;
  border: 0;
  background: none;
  padding: 0 14px;
  color: rgba(255, 255, 255, .72);
  font: 500 15px var(--font-display);
  transition: color .15s;
}
.section-tabs button:hover { color: #fff; }
.section-tabs button[aria-selected="true"] { color: #fff; }
.section-tabs button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: #fff;
}
.section-tabs button:focus-visible { outline-color: #fff; outline-offset: -4px; }
.stats { display: flex; gap: 22px; margin: 0 0 0 auto; }
.stats div { display: flex; align-items: baseline; gap: 6px; }
.stats dt { font-size: 11px; color: rgba(255, 255, 255, .7); text-transform: uppercase; letter-spacing: .06em; }
.stats dd { margin: 0; font: 600 17px var(--font-display); font-variant-numeric: tabular-nums; }
.stats div { flex-direction: row-reverse; }
@media (max-width: 960px) { .stats { display: none; } }

/* ── Toolbar ──────────────────────────────────────────── */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 40px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-2);
  border-radius: 999px;
  gap: 2px;
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 7px 16px;
  border-radius: 999px;
  color: var(--ink-2);
  font-weight: 500;
  transition: background .15s, color .15s;
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}
.period-nav { display: flex; align-items: center; gap: 8px; }
.period-nav h2 {
  margin: 0;
  min-width: 220px;
  text-align: center;
  font: 500 20px var(--font-display);
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  transition: border-color .15s, color .15s;
}
.icon-btn:hover:not(:disabled) { border-color: var(--line-strong); color: var(--ink); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn svg { width: 18px; height: 18px; }
.filters-toggle {
  display: none;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 500;
}
.filters-toggle svg { width: 16px; height: 16px; }
.badge-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--ink);
  color: var(--bg);
  font-size: 11px;
  display: inline-grid;
  place-items: center;
}
.badge-count[hidden] { display: none; }

/* ── Layout ───────────────────────────────────────────── */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 32px;
  padding: 28px 40px 48px;
  align-items: start;
}
.filters {
  position: sticky;
  top: 86px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  padding-right: 4px;
}
.filters-head { display: flex; justify-content: space-between; align-items: baseline; }
.filters h3 { margin: 0; font: 500 18px var(--font-display); }
.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  font-weight: 500;
  font-size: 13px;
}
.link-btn:hover { text-decoration: underline; }
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  transition: border-color .15s;
}
.search:focus-within { border-color: var(--accent); }
.search svg { width: 16px; height: 16px; color: var(--ink-3); flex: none; }
.search input {
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  padding: 10px 0;
  width: 100%;
}
fieldset { border: 0; margin: 0; padding: 0; }
legend {
  padding: 0;
  margin-bottom: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--ink-2);
  transition: all .15s;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.checks { display: flex; flex-direction: column; gap: 2px; }
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  margin: 0 -8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
}
.check:hover { background: var(--surface-2); }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  border: 1.5px solid var(--line-strong);
  display: grid;
  place-items: center;
  flex: none;
  transition: all .15s;
}
.check .box svg { width: 11px; height: 11px; stroke: #fff; stroke-width: 3; opacity: 0; }
.check input:checked + .box { background: var(--c, var(--ink)); border-color: var(--c, var(--ink)); }
.check input:checked + .box svg { opacity: 1; }
.check input:focus-visible + .box { outline: 2px solid var(--accent); outline-offset: 2px; }
.check .label { flex: 1; }
.check .count { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ── Shared atoms ─────────────────────────────────────── */
.stage { min-width: 0; outline: none; }
.loading, .empty {
  padding: 80px 20px;
  text-align: center;
  color: var(--ink-3);
  font: 400 17px var(--font-display);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-2);
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.badge.status { border-color: color-mix(in srgb, var(--c) 40%, transparent); color: var(--c); background: color-mix(in srgb, var(--c) 8%, transparent); }
.badge.holiday { background: var(--holiday); border-color: transparent; color: var(--holiday-ink); }

/* Event pill used inside calendar cells */
.ev {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-left: 3px solid var(--c);
  background: color-mix(in srgb, var(--c) 11%, var(--surface));
  color: var(--ink);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .12s;
}
.ev:hover { background: color-mix(in srgb, var(--c) 20%, var(--surface)); }
.ev.is-sugestao, .ev.is-a_confirmar, .ev.is-revisar {
  background: transparent;
  border: 1px dashed color-mix(in srgb, var(--c) 60%, transparent);
  border-left: 3px solid var(--c);
}
.ev.is-a_confirmar { border-style: dotted; border-left-style: solid; }
.ev.is-revisar::after { content: " ⚑"; color: var(--st-revisar); }
.ev.is-feriado {
  background: var(--holiday);
  border-left-color: var(--holiday-ink);
  color: var(--holiday-ink);
  font-weight: 500;
}

/* ── Month grid (mes / trimestre) ─────────────────────── */
.month-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.month-card > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 18px 10px;
}
.month-card h3 { margin: 0; font: 500 19px var(--font-display); }
.month-card h3 button { border: 0; background: none; padding: 0; font: inherit; }
.month-card h3 button:hover { color: var(--accent); }
.month-card .count { font-size: 12px; color: var(--ink-3); }
.dow, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.dow { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.dow span {
  padding: 6px 8px;
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
.day {
  position: relative;
  min-height: 118px;
  padding: 6px 6px 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.grid .day:nth-child(7n) { border-right: 0; }
.day[data-day] { cursor: pointer; }
.day.out { background: repeating-linear-gradient(-45deg, transparent 0 6px, color-mix(in srgb, var(--line) 35%, transparent) 6px 7px); }
.day.out .num { visibility: hidden; }
.day.weekend .num { color: var(--ink-3); }
.day.has-holiday { background: color-mix(in srgb, var(--holiday) 55%, transparent); }
.day .num {
  font: 500 13px var(--font-display);
  font-variant-numeric: tabular-nums;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  margin-bottom: 2px;
}
.day.today .num { background: var(--today); color: var(--bg); }
.more {
  border: 0;
  background: none;
  padding: 0 4px;
  text-align: left;
  font-size: 11.5px;
  color: var(--ink-3);
  font-weight: 500;
}
.more:hover { color: var(--accent); }

/* ── Mini months (trimestre / semestre / ano) ─────────── */
.view-trimestre, .view-semestre, .view-ano { display: grid; gap: 18px; align-items: stretch; }
.view-trimestre { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.view-trimestre .mini-day { font-size: 13px; }
.view-trimestre .mini .grid { padding: 0 14px 14px; }
.view-trimestre .mini .dow { padding: 0 14px; }
.view-semestre { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.view-ano { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mini .dow { border-top: 0; background: transparent; border-bottom: 0; padding: 0 10px; }
.mini .dow span { text-align: center; padding: 2px 0; font-size: 10px; letter-spacing: 0; }
.mini .grid { padding: 0 10px 12px; row-gap: 2px; }
.mini-day {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  padding: 0;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  border-radius: 50%;
}
.mini-day.out { visibility: hidden; }
.mini-day.has-events { color: var(--ink); font-weight: 600; }
.mini-day.has-events:hover { background: var(--surface-2); }
.mini-day.has-holiday { background: var(--holiday); color: var(--holiday-ink); }
.mini-day.today { outline: 1.5px solid var(--today); outline-offset: -2px; }
.mini-day .dots {
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
}
.mini-day .dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--c); }
.mini-list {
  list-style: none;
  margin: 0;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mini-list li button {
  display: flex;
  gap: 8px;
  align-items: baseline;
  width: 100%;
  border: 0;
  background: none;
  padding: 3px 4px;
  margin: 0 -4px;
  border-radius: 6px;
  text-align: left;
  font-size: 12.5px;
  line-height: 1.35;
}
.mini-list li button:hover { background: var(--surface-2); }
.mini-list li .pub-item { display: flex; gap: 8px; align-items: baseline; width: 100%; padding: 3px 4px; margin: 0 -4px; font-size: 12.5px; line-height: 1.35; }
.mini-list .d { flex: none; width: 20px; color: var(--ink-3); font-variant-numeric: tabular-nums; font-weight: 600; }
.mini-list .bar { flex: none; width: 3px; align-self: stretch; border-radius: 2px; background: var(--c); }
.mini-list .t { min-width: 0; }
.mini-list .is-tentative .t { color: var(--ink-2); font-style: italic; }
.mini-list .empty-li { color: var(--ink-3); font-style: italic; font-size: 12.5px; }
.mini-list.detailed { gap: 2px; padding: 12px 16px 16px; }
.mini-list.detailed li button, .mini-list.detailed li .pub-item { padding: 6px 6px; margin: 0 -6px; gap: 10px; font-size: 13.5px; }
.mini-list.detailed .d { width: 28px; display: flex; flex-direction: column; align-items: center; font: 500 17px/1 var(--font-display); color: var(--ink); }
.mini-list.detailed .d em { font: 600 9.5px var(--font-ui); font-style: normal; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin-top: 3px; }
.mini-list .t small { display: block; font-size: 11.5px; color: var(--ink-3); font-style: normal; margin-top: 1px; }

/* ── List view ────────────────────────────────────────── */
.list-month { margin-bottom: 34px; }
.list-month > h3 {
  position: sticky;
  top: 63px;
  z-index: 5;
  margin: 0 0 10px;
  padding: 10px 0 8px;
  background: var(--bg);
  display: flex;
  align-items: baseline;
  gap: 12px;
  font: 500 22px var(--font-display);
  border-bottom: 1px solid var(--line-strong);
}
.list-month > h3 small { font: 500 12px var(--font-ui); color: var(--ink-3); }
.list-items { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid;
  grid-template-columns: 64px 4px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 12px 14px;
  margin: 0 -14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 0;
  background: none;
  width: calc(100% + 28px);
  text-align: left;
}
.row + .row { box-shadow: inset 0 1px var(--line); }
.row:hover, .row:hover + .row { box-shadow: none; }
.row:hover { background: var(--surface); box-shadow: var(--shadow); }
.row .date { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.row .date b { font: 500 28px var(--font-display); font-variant-numeric: tabular-nums; }
.row .date span { margin-top: 4px; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.row .bar { align-self: stretch; border-radius: 2px; background: var(--c); }
.row .body { min-width: 0; }
.row .title { font-size: 15px; font-weight: 500; color: var(--ink); }
.row.is-feriado .title { color: var(--holiday-ink); }
.row .note { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.row .tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.row.pending .date b { font-size: 18px; color: var(--ink-3); }
.pending-section > h3 { color: var(--st-sem_data); }

/* ── Legend ───────────────────────────────────────────── */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 22px;
  font-size: 12px;
  color: var(--ink-3);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 22px; height: 12px; border-radius: 3px; }
.legend .sw.solid { background: color-mix(in srgb, var(--ink-2) 15%, var(--surface)); border-left: 3px solid var(--ink-2); }
.legend .sw.dashed { border: 1px dashed var(--ink-3); border-left: 3px solid var(--ink-3); }
.legend .sw.hol { background: var(--holiday); border-left: 3px solid var(--holiday-ink); }

/* ── Dialog ───────────────────────────────────────────── */
.event-dialog {
  border: 0;
  padding: 0;
  width: min(460px, calc(100vw - 32px));
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .45);
}
.event-dialog::backdrop { background: rgba(20, 22, 29, .45); backdrop-filter: blur(3px); }
.event-dialog .close { position: absolute; top: 14px; right: 14px; }
.dlg { padding: 28px 28px 26px; }
.dlg .stripe { height: 4px; width: 48px; border-radius: 2px; background: var(--c); margin-bottom: 18px; }
.dlg .when { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); font-weight: 600; margin: 0 0 6px; }
.dlg h3 { margin: 0 40px 14px 0; font: 500 26px/1.15 var(--font-display); }
.dlg .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.dlg dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 13px; }
.dlg dt { color: var(--ink-3); }
.dlg dd { margin: 0; }
.dlg .day-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.dlg .day-list .ev { white-space: normal; font-size: 13.5px; padding: 8px 10px; }

.colophon {
  padding: 22px 40px 30px;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  text-align: center;
  font: 400 13px var(--font-display);
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 1180px) {
  .view-trimestre { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
  .view-ano { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .view-semestre { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .masthead { padding: 0 16px; gap: 16px; min-height: 56px; }
  .brand-mark { width: 26px; height: 34px; }
  .wordmark { width: 80px; height: 32px; }
  .section-tabs button { padding: 0 10px; font-size: 14px; }
  .section-tabs button[aria-selected="true"]::after { left: 10px; right: 10px; }
  .toolbar { padding: 10px 16px; flex-wrap: wrap; }
  .segmented { order: 3; width: 100%; overflow-x: auto; }
  .segmented button { flex: 1; padding: 7px 10px; }
  .period-nav h2 { min-width: 0; font-size: 17px; }
  .filters-toggle { display: inline-flex; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 18px 16px 40px; gap: 0; }
  .filters {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 40;
    width: min(320px, 88vw);
    max-height: none;
    background: var(--bg);
    padding: 20px 18px;
    box-shadow: -20px 0 60px rgba(0, 0, 0, .25);
    transform: translateX(105%);
    transition: transform .25s ease;
  }
  .filters.open { transform: none; }
  .list-month > h3 { top: 104px; }
  .colophon { padding: 18px 16px 24px; }
}

@media (max-width: 640px) {
  .view-ano, .view-semestre { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .mini .grid { padding: 0 6px 10px; }
  .mini .dow { padding: 0 6px; }
  .mini-day { font-size: 11px; }
  .view-semestre .mini-list { display: none; }
  .day { min-height: 74px; padding: 3px 2px; }
  .dow span { padding: 5px 3px; font-size: 9.5px; letter-spacing: 0; }
  .day .ev { pointer-events: none; } /* taps go to the cell → day agenda */
  .day .ev { font-size: 0; height: 6px; padding: 0; border: 0; background: var(--c); border-radius: 3px; }
  .day .ev.is-feriado { background: var(--holiday-ink); }
  .day .ev.is-revisar::after { content: none; }
  .row { grid-template-columns: 46px 3px minmax(0, 1fr); gap: 12px; }
  .row .tags { grid-column: 3; justify-content: flex-start; }
  .row .date b { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ═════════════ Editing, Pregações, Login ═════════════ */
[hidden] { display: none !important; }
#appShell { flex: 1; display: flex; flex-direction: column; }
.section { flex: 1; }
.muted { color: var(--ink-3); margin: 0 0 16px; font-size: 13.5px; }
.muted.small { font-size: 12.5px; }
.danger-text { color: var(--st-revisar) !important; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 500;
  font-size: 13.5px;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--brand) 86%, #000); }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn.ghost:hover:not(:disabled) { border-color: var(--line-strong); }
.btn.danger { background: var(--st-revisar); color: #fff; }
.btn.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--st-revisar) 86%, #000); }
.btn.danger-ghost { background: none; color: var(--st-revisar); border-color: color-mix(in srgb, var(--st-revisar) 35%, transparent); }
.btn.danger-ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--st-revisar) 8%, transparent); }
.btn.sm { padding: 5px 11px; font-size: 12.5px; }
.btn.block { width: 100%; padding: 11px 16px; font-size: 14.5px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn.primary { color: #0f141d; }
}
:root[data-theme="dark"] .btn.primary { color: #0f141d; }

.toolbar-actions { display: flex; align-items: center; gap: 8px; }
.select {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
}
.toolbar-search { flex: 1; max-width: 420px; border-radius: 999px; }
.toolbar-search input { padding: 8px 0; }

/* Empty day → add */
.day[data-new] { cursor: pointer; }
.day[data-new]::after {
  content: "+";
  position: absolute;
  top: 6px;
  right: 8px;
  font: 400 18px/1 var(--font-display);
  color: var(--accent);
  opacity: 0;
  transition: opacity .15s;
}
.day[data-new]:hover::after { opacity: 1; }
.day[data-new]:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }

/* Dialog actions + forms */
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; flex-wrap: wrap; }
.dlg-actions .btn.danger-ghost { margin-right: auto; }
.event-form h3 { margin-bottom: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  padding: 9px 12px;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.field input:disabled, .field select:disabled { opacity: .5; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.check.no-date { margin: 26px 0 0; }
.field-error { color: var(--st-revisar); font-size: 12px; min-height: 0; }
.field-error:empty { display: none; }
.form-error { color: var(--st-revisar); font-size: 13px; margin: 4px 0 0; }
.form-error:empty { display: none; }
.event-dialog { max-height: calc(100vh - 32px); overflow-y: auto; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  transform: translate(-50%, 16px);
  opacity: 0;
  background: var(--ink);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 500;
  font-size: 13.5px;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .4);
  transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Avatar (pregadores, usuários) */
.avatar {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  color: var(--accent);
  font: 600 11px var(--font-ui);
  letter-spacing: .02em;
  flex: none;
}

/* Pregações */
.side-panel {
  position: sticky;
  top: 86px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
}
.side-panel h3 { margin: 0; font: 500 18px var(--font-display); }
.preacher-list { display: flex; flex-direction: column; gap: 2px; }
.preacher-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: none;
  padding: 7px 8px;
  margin: 0 -8px;
  border-radius: var(--radius-sm);
  text-align: left;
}
.preacher-item:hover { background: var(--surface-2); }
.preacher-item[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.preacher-item[aria-pressed="true"] .label { font-weight: 600; }
.preacher-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preacher-item .count { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.preacher {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
}
.sermon-row .note.passage { font-style: italic; }
.sermon-row.is-past .title { color: var(--ink-2); font-weight: 400; }
.sermon-row.is-past .date b { color: var(--ink-3); }
.empty-cta { padding: 70px 20px; text-align: center; color: var(--ink-3); font: 400 17px var(--font-display); }
.empty-cta p { margin: 0 0 18px; }

/* User menu */
.user-menu-wrap { position: relative; flex: none; }
.stats + .user-menu-wrap { margin-left: 4px; }
.user-btn { border: 0; background: none; padding: 2px; border-radius: 50%; }
.user-btn .avatar { width: 34px; height: 34px; font-size: 12.5px; background: rgba(255, 255, 255, .18); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35); }
.user-btn:hover .avatar { background: rgba(255, 255, 255, .28); }
.user-btn:focus-visible { outline-color: #fff; }
.user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 50;
  min-width: 230px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 40px -12px rgba(0, 0, 0, .35);
  padding: 6px;
}
.user-menu-head { padding: 10px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; display: flex; flex-direction: column; }
.user-menu-head small { color: var(--ink-3); font-size: 12px; }
.user-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: none;
  padding: 9px 10px;
  border-radius: 8px;
  text-align: left;
}
.user-menu button:hover { background: var(--surface-2); }
.user-menu button svg { width: 17px; height: 17px; color: var(--ink-3); }
.user-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.user-list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.user-list .avatar { width: 34px; height: 34px; font-size: 12px; }
.user-list .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.user-list .who b { font-weight: 500; }
.user-list .who em { font-style: normal; color: var(--ink-3); font-weight: 400; }
.user-list .who small { color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-actions { display: flex; gap: 6px; flex: none; }
.user-actions .btn.danger-ghost { margin: 0; padding: 5px 8px; }

/* Login */
.login-screen { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }
.login-brand {
  background: var(--masthead-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 40px;
}
.login-mark { width: 92px; height: 121px; fill: #fff; stroke: none; }
.login-wordmark { width: 240px; height: 93px; }
.login-brand p { margin: 0; font: 400 16px var(--font-display); color: rgba(255, 255, 255, .78); letter-spacing: .02em; }
.login-panel { display: grid; place-items: center; padding: 40px 24px; }
.login-form { width: min(360px, 100%); }
.login-title { margin: 0 0 6px; font: 600 28px var(--font-display); line-height: 1.2; }
.login-form .form-error { margin: 0 0 12px; }
.login-public { margin: 28px 0 0; text-align: center; font-size: 13.5px; }
.login-public a { color: var(--accent); text-decoration: none; }
.login-public a:hover { text-decoration: underline; }

@media (max-width: 900px) {
  .side-panel { position: static; max-height: none; margin-bottom: 18px; }
  .preacher-list { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .preacher-item { margin: 0; flex: none; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px 4px 4px; background: var(--surface); }
  .toolbar-actions { margin-left: auto; }
  .toolbar-search { max-width: none; }
  .login-screen { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-brand { padding: 32px 24px; gap: 12px; flex-direction: row; }
  .login-mark { width: 40px; height: 53px; }
  .login-wordmark { width: 100px; height: 40px; }
  .login-brand p { display: none; }
}
.login-form .form-error.info { color: var(--ink-2); }
@media (max-width: 640px) {
  .masthead { gap: 8px; padding: 0 12px; }
  .section-tabs { gap: 0; }
  .section-tabs button { padding: 0 8px; font-size: 13.5px; }
  .section-tabs button[aria-selected="true"]::after { left: 8px; right: 8px; }
  .user-menu-wrap { margin-left: auto; }
  .toolbar-search { order: 3; flex-basis: 100%; }
  .btn-label { display: none; }
  .toolbar-actions .btn.primary { padding: 8px 10px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .check.no-date { margin: -4px 0 14px; }
  .user-list .btn.ghost.sm { padding: 5px 8px; font-size: 0; gap: 0; }
}

/* Sermon pills in the calendar grids: title + preacher on two lines */
.sermon-ev { padding: 4px 6px; }
.sermon-ev .t, .sermon-ev small { display: block; overflow: hidden; text-overflow: ellipsis; }
.sermon-ev small { font-size: 10.5px; color: var(--ink-3); margin-top: 1px; }
.sermon-ev.is-next { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 55%, transparent); }
.side-panel .filters-head h3 small { font: 400 12px var(--font-ui); color: var(--ink-3); margin-left: 4px; }
.dlg .day-list .sermon-ev small { font-size: 12px; }
@media (max-width: 640px) {
  .day .sermon-ev small, .day .sermon-ev .t { display: none; }
}

/* ── Theme toggle ─────────────────────────────────────── */
.theme-toggle { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .12); color: #fff; padding: 0; }
.theme-toggle:hover { background: rgba(255, 255, 255, .24); }
.theme-toggle:focus-visible { outline-color: #fff; }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: block; }
.stats + .theme-toggle { margin-left: 4px; }

/* ── Public page ──────────────────────────────────────── */
.public-spacer { flex: 1; }
.public-main { flex: 1; padding: 28px 40px 48px; }
.public-title { margin: 0 0 20px; font: 500 24px var(--font-display); }
@media (max-width: 720px) {
  .masthead.public-masthead { padding: 0 16px; }
  .public-main { padding: 18px 16px 40px; }
}

/* Login: white button with a navy label */
.btn.login-submit, :root .btn.login-submit { background: #fff; color: #0a1f4d; border-color: var(--line-strong); font-weight: 600; }
.btn.login-submit:hover:not(:disabled) { background: #f1f5fb; border-color: var(--brand); }
