/* Layout: a lectionary-style index — title block, filter bar, then one ruled table (cards on phones) */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --fg: #1c2230;
  --muted: #5d6677;
  --rule: #dde1e8;
  --accent: #1f3f7a;        /* Marian blue */
  --accent-soft: #e6ecf7;
  --gold: #9a7420;
  --c-sac: #8c1d2a;  --c-church: #1f3f7a; --c-mary: #2f6fb0; --c-saints: #6b4a9b;
  --c-doc: #2d6a4f;  --c-prayer: #9a7420; --c-moral: #6b5a3a; --c-last: #4a4f5c;
  --display: "EB Garamond", Garamond, "Times New Roman", serif;
  --body: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #12151c; --surface: #1a1e27; --fg: #e6e9ef; --muted: #9aa3b4; --rule: #2c323e;
  --accent: #9fb9ec; --accent-soft: #233150; --gold: #d8b25e;
  --c-sac: #e8818c; --c-church: #9fb9ec; --c-mary: #8cc0f0; --c-saints: #c2a6ec;
  --c-doc: #7fcca7; --c-prayer: #d8b25e; --c-moral: #cdb88f; --c-last: #b4bac6;
  color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #12151c; --surface: #1a1e27; --fg: #e6e9ef; --muted: #9aa3b4; --rule: #2c323e;
  --accent: #9fb9ec; --accent-soft: #233150; --gold: #d8b25e;
  --c-sac: #e8818c; --c-church: #9fb9ec; --c-mary: #8cc0f0; --c-saints: #c2a6ec;
  --c-doc: #7fcca7; --c-prayer: #d8b25e; --c-moral: #cdb88f; --c-last: #b4bac6;
  color-scheme: dark; }

body { background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 15px; line-height: 1.5; }
.wrap { max-width: 1180px; margin: 0 auto; padding-block: 40px 64px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid; gap: 24px; }
header { display: grid; gap: 8px; }
.eyebrow { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
h1 { font-family: var(--display); font-weight: 600; font-size: clamp(32px, 5vw, 48px); line-height: 1.05; margin: 0; text-wrap: balance; }
.lede { color: var(--muted); max-width: 68ch; margin: 0; }
.lede a { color: var(--accent); }

.controls { display: grid; gap: 12px; }
.search { width: 100%; max-width: 420px; font: inherit; padding: 10px 14px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); color: var(--fg); }
.search:focus-visible, .chip:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--rule); background: var(--surface); color: var(--fg); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.tablebox { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--rule); background: var(--surface); position: sticky; top: 0; }
td { padding: 14px 16px; border-bottom: 1px solid var(--rule); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.topic { width: 26%; border-left: 3px solid var(--c); }
.tname { font-family: var(--display); font-size: 19px; font-weight: 600; line-height: 1.2; }
.cat { font-size: 12px; color: var(--c); font-weight: 600; letter-spacing: .04em; margin-top: 2px; }
.teach { color: var(--muted); font-size: 14px; max-width: 46ch; }
.refs { display: flex; flex-wrap: wrap; gap: 6px; }
.refs a { font-size: 13px; text-decoration: none; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.refs a:hover { text-decoration: underline; }
.refs a.type { background: transparent; border: 1px dashed var(--accent); }
td.ccc { white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 14px; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.legend { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.legend span.s { display: inline-block; padding: 1px 8px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); }
.legend span.t { display: inline-block; padding: 0 7px; border-radius: 4px; border: 1px dashed var(--accent); color: var(--accent); }
footer { font-size: 13px; color: var(--muted); max-width: 80ch; }

@media (max-width: 680px) {
  .tablebox { overflow: visible; background: transparent; border: 0; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tr { background: var(--surface); border: 1px solid var(--rule); border-left: 3px solid var(--c); border-radius: 8px; margin-bottom: 12px; padding: 4px 0; }
  td { border: 0; padding: 8px 14px; }
  td.topic { width: auto; border-left: 0; }
  td.ccc::before { content: "Catechism "; color: var(--muted); }
}
