:root {
  --ink: #1f1d24;
  --muted: #66616e;
  --paper: #f7f6f3;
  --rule: #e2dfe7;
  --accent: #5b3a8c;
  --accent-soft: #ece6f5;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --measure: 40rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #ebeaee;
    --muted: #a3a0aa;
    --paper: #1e1e21;
    --rule: #36353b;
    --accent: #b89be8;
    --accent-soft: #2b2733;
  }
}

* { box-sizing: border-box; }

html { font-size: 112.5%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }

.wrap { max-width: 64rem; margin: 0 auto; padding: 0 1.5rem; }

/* Header */
.site-header { border-bottom: 1px solid var(--rule); }
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; padding-top: 1.25rem; padding-bottom: 1.25rem;
}
.brand {
  font-size: 1.25rem; letter-spacing: 0.02em; color: var(--ink);
  text-decoration: none; font-weight: 600;
}
.brand { display: inline-flex; align-items: center; gap: 0.6rem; }
.brand img { width: 36px; height: 36px; border-radius: 7px; flex: none; }
.brand span { color: var(--accent); }
.hero-logo { display: block; margin: 2.5rem auto 2rem; max-width: 34rem; }
.hero-logo img { display: block; width: 100%; height: auto; }
nav ul { list-style: none; display: flex; gap: 1.5rem; margin: 0; padding: 0; }
nav a {
  font-family: var(--sans); font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--muted); text-decoration: none;
}
nav a:hover, nav a[aria-current="page"] { color: var(--accent); }

/* Content */
main { padding: 4rem 0 5rem; }
.prose { max-width: var(--measure); }
.eyebrow {
  font-family: var(--sans); font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.16em; color: var(--accent); margin: 0 0 0.75rem;
}
h1, h2, h3 { line-height: 1.2; font-weight: 600; }
h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); margin: 0 0 1.25rem; letter-spacing: -0.01em; }
h2 { font-size: 1.6rem; margin: 3rem 0 0.75rem; }
h3 { font-size: 1.15rem; margin: 2rem 0 0.4rem; }
.lede { font-size: 1.25rem; color: var(--muted); margin: 0 0 2rem; }

/* Home: the two words */
.pair {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--rule); border: 1px solid var(--rule); margin: 3.5rem 0;
}
.pair a {
  display: block; background: var(--paper); padding: 2rem; color: var(--ink);
  text-decoration: none; transition: background 0.15s;
}
.pair a:hover { background: var(--accent-soft); }
.pair .word { font-size: 1.9rem; font-style: italic; color: var(--accent); margin: 0; }
.pair .gloss { font-family: var(--sans); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0.25rem 0 1rem; }
.pair p:last-child { margin: 0; }
@media (max-width: 40rem) { .pair { grid-template-columns: 1fr; } }

blockquote {
  margin: 2rem 0; padding: 0 0 0 1.25rem; border-left: 3px solid var(--accent);
  font-style: italic;
}
blockquote cite {
  display: block; margin-top: 0.5rem; font-style: normal; font-family: var(--sans);
  font-size: 0.8rem; color: var(--muted); letter-spacing: 0.04em;
}

.creed { columns: 1; }
.creed p { margin: 0 0 0.9rem; }

ol.beliefs { padding-left: 1.25rem; }
ol.beliefs li { margin-bottom: 1.25rem; }
ol.beliefs strong { display: block; }

.note {
  font-family: var(--sans); font-size: 0.85rem; color: var(--muted);
  background: var(--accent-soft); padding: 0.9rem 1.1rem; border-radius: 4px; margin: 2rem 0;
}

/* Footer */
.site-footer { border-top: 1px solid var(--rule); }
.site-footer .wrap {
  padding-top: 1.75rem; padding-bottom: 2.5rem; font-family: var(--sans);
  font-size: 0.8rem; color: var(--muted); display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.site-footer .csb { flex-basis: 100%; margin: 0.5rem 0 0; font-size: 0.7rem; line-height: 1.5; }
ol.beliefs .refs { display: block; margin-top: 0.35rem; font: 0.8rem/1.5 var(--sans); color: var(--muted); }
.source-note { font: 0.85rem var(--sans); color: var(--muted); }

/* Header search */
nav { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.site-search input {
  font: 0.85rem var(--sans); color: var(--ink); background: transparent;
  border: 1px solid var(--rule); border-radius: 99px; padding: 0.35rem 0.8rem; width: 9rem;
}
.site-search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; width: 13rem; }
@media (max-width: 40rem) { nav { gap: 0.75rem; } .site-search { width: 100%; } .site-search input, .site-search input:focus { width: 100%; } }

/* Articles */
.article-list { list-style: none; padding: 0; margin: 2rem 0 0; }
.article-list li { padding: 1.5rem 0; border-top: 1px solid var(--rule); }
.article-list h2 { margin: 0.2rem 0 0.4rem; font-size: 1.4rem; }
.article-list h2 a { color: var(--ink); text-decoration: none; }
.article-list h2 a:hover { color: var(--accent); }
.article-list p { margin: 0; color: var(--muted); }
.meta { font: 0.8rem var(--sans); color: var(--muted); letter-spacing: 0.03em; }
.article-body h2 { font-size: 1.4rem; }
.article-body img { max-width: 100%; height: auto; border-radius: 6px; }
.article-body pre { overflow-x: auto; }

/* Search results */
.search-page input[type=search] {
  font: 1.1rem var(--sans); color: var(--ink); background: var(--paper); width: 100%;
  border: 1px solid var(--rule); border-radius: 10px; padding: 0.8rem 1rem; margin: 0.5rem 0 1.5rem;
}
.results { list-style: none; padding: 0; margin: 0; }
.results li { padding: 1rem 0; border-top: 1px solid var(--rule); }
.results a.title { font-size: 1.15rem; font-weight: 600; text-decoration: none; }
.results .kind { font: 600 0.7rem var(--sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-left: 0.5rem; }
.results p { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.95rem; }
.results mark { background: var(--accent-soft); color: inherit; padding: 0 0.1em; border-radius: 2px; }
nav ul { flex-wrap: wrap; row-gap: 0.4rem; }
@media (max-width: 40rem) {
  .site-header .wrap { flex-direction: column; align-items: flex-start; }
  nav { width: 100%; min-width: 0; }
  nav ul { gap: 0.4rem 1.1rem; }
}

/* Article footnotes and bibliography */
.article-body sup a { text-decoration: none; font: 600 0.7em var(--sans); padding: 0 0.1em; }
.article-body .footnotes, .article-body .bibliography { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); }
.article-body .footnotes h2, .article-body .bibliography h2 { font-size: 1.15rem; margin-top: 0; }
.article-body .footnotes ol { padding-left: 1.5rem; }
.article-body .footnotes li, .article-body .bibliography li { font: 0.85rem/1.55 var(--sans); color: var(--muted); margin-bottom: 0.6rem; overflow-wrap: anywhere; }
.article-body .footnotes li:target { background: var(--accent-soft); border-radius: 4px; }
.article-body .footnotes a.back { text-decoration: none; margin-left: 0.25rem; }
.article-body .bibliography ul { list-style: none; padding: 0; }
.article-body .bibliography li { padding-left: 2rem; text-indent: -2rem; }
.article-body blockquote { font-style: normal; }

/* Chiasm and figure layouts in articles */
.article-body .chiasm { margin: 1.5rem 0; padding: 1rem 1.25rem; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 6px 6px 0; }
.article-body .chiasm p { margin: 0.15rem 0; }
.article-body .chiasm .c1 { padding-left: 1.5rem; }
.article-body .chiasm .c2 { padding-left: 3rem; }
.article-body .chiasm .c3 { padding-left: 4.5rem; font-weight: 600; color: var(--accent); }
.article-body .chiasm.figure { font: 0.9rem/1.6 var(--sans); }
.article-body .chiasm .label { font: 600 0.7rem var(--sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-top: 0.6rem; }
@media (max-width: 40rem) { .article-body .chiasm .c1 { padding-left: 0.9rem; } .article-body .chiasm .c2 { padding-left: 1.8rem; } .article-body .chiasm .c3 { padding-left: 2.7rem; } }
.article-body sup.fn a { text-decoration: none; font: 600 0.7em var(--sans); padding: 0 0.1em; }
.site-footer a { color: inherit; }
.site-footer a:hover { color: var(--accent); }
.contact-link { font-size: 1.15rem; font-weight: 600; }

/* Anything marked hidden stays hidden, whatever layout it has */
[hidden] { display: none !important; }

/* Editing pages (site owner only) */
.edit-fab {
  position: fixed; right: 1rem; bottom: calc(env(safe-area-inset-bottom) + 1rem); z-index: 50;
  font: 600 0.9rem var(--sans); background: var(--accent); color: #fff; border: 0; border-radius: 99px;
  padding: 0.75rem 1.1rem; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25); cursor: pointer;
}
@media (prefers-color-scheme: dark) { .edit-fab { color: #1e1e21; } }
body.editing .edit-fab { display: none; }
body.editing [data-edit] { outline: 2px dashed var(--accent); outline-offset: 6px; border-radius: 4px; cursor: text; }
body.editing [data-edit]:focus { outline-style: solid; }
body.editing { padding-bottom: 6rem; }
.edit-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
  padding: 0.7rem 1rem calc(env(safe-area-inset-bottom) + 0.7rem); background: var(--paper); border-top: 1px solid var(--rule);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12); font-family: var(--sans);
}
.edit-bar button {
  font: 600 0.85rem var(--sans); border: 1px solid var(--rule); background: transparent; color: var(--ink);
  border-radius: 8px; padding: 0.5rem 0.8rem; cursor: pointer;
}
.edit-bar button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .edit-bar button.primary { color: #1e1e21; } }
.edit-bar button.link { border: 0; color: var(--accent); }
.edit-tools { display: flex; gap: 0.3rem; }
.edit-tools button { min-width: 2.2rem; }
.edit-spacer { flex: 1; }
.edit-status { font-size: 0.8rem; color: var(--muted); }

/* Article comments */
.comments { margin-top: 3.5rem; padding-top: 1.5rem; border-top: 2px solid var(--accent); }
.comments h2 { margin-top: 0; }
.comment-form { display: grid; gap: 0.6rem; margin: 0 0 1.5rem; }
.comment-form textarea {
  font: 1rem var(--sans); color: var(--ink); background: var(--paper); border: 1px solid var(--rule);
  border-radius: 8px; padding: 0.7rem 0.8rem; width: 100%; resize: vertical;
}
.comment-form textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.comment-form button {
  justify-self: start; font: 600 0.9rem var(--sans); background: var(--accent); color: #fff; border: 0;
  border-radius: 8px; padding: 0.6rem 1rem; cursor: pointer;
}
@media (prefers-color-scheme: dark) { .comment-form button { color: #1e1e21; } }
.comment-form button:disabled { opacity: 0.6; }
.comment-form.reply { margin: 0.5rem 0 0.5rem 1rem; }
.comment-error { margin: 0; color: #b3261e; font: 0.85rem var(--sans); }
.comment-error:empty { display: none; }
@media (prefers-color-scheme: dark) { .comment-error { color: #f2a097; } }
.comment-signin { font-family: var(--sans); background: var(--accent-soft); padding: 0.9rem 1.1rem; border-radius: 8px; }
.comment-list, .comment-replies { list-style: none; padding: 0; margin: 0; }
.comment-list > li { padding: 1rem 0; border-top: 1px solid var(--rule); }
.comment-list > li.empty { color: var(--muted); font: 0.95rem var(--sans); border: 0; }
.comment-replies { margin: 0.75rem 0 0 1rem; padding-left: 1rem; border-left: 2px solid var(--accent-soft); }
.comment-replies li { padding: 0.5rem 0; }
.comment-meta { margin: 0 0 0.25rem; font: 0.85rem var(--sans); color: var(--muted); }
.comment-meta strong { color: var(--ink); }
.author-tag { font: 600 0.65rem var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); padding: 0.1rem 0.4rem; border-radius: 4px; }
.comment-body { margin: 0; overflow-wrap: anywhere; }
.comment-action { font: 600 0.8rem var(--sans); color: var(--accent); background: none; border: 0; padding: 0.3rem 0; cursor: pointer; margin-right: 0.5rem; }

/* Credenda: each conviction is a dropdown */
ol.beliefs { list-style: none; padding: 0; counter-reset: belief; }
ol.beliefs li { margin: 0; border-top: 1px solid var(--rule); counter-increment: belief; }
ol.beliefs li:last-child { border-bottom: 1px solid var(--rule); }
ol.beliefs summary {
  cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 0.75rem;
  padding: 0.9rem 0; font-weight: 600; font-size: 1.1rem;
}
ol.beliefs summary::-webkit-details-marker { display: none; }
ol.beliefs summary::before { content: counter(belief); font: 600 0.8rem var(--sans); color: var(--accent); min-width: 1.2rem; }
ol.beliefs summary::after { content: "+"; margin-left: auto; font: 400 1.4rem/1 var(--sans); color: var(--accent); }
ol.beliefs details[open] summary::after { content: "−"; }
ol.beliefs summary:hover { color: var(--accent); }
ol.beliefs details p { margin: 0 0 0.5rem 1.95rem; }
ol.beliefs details .refs { margin: 0 0 1rem 1.95rem; }

/* Articles: owner buttons, categories, editor */
.owner-btn { display: inline-block; font: 600 0.85rem var(--sans); background: var(--accent); color: #fff !important; text-decoration: none; border-radius: 99px; padding: 0.5rem 1rem; }
@media (prefers-color-scheme: dark) { .owner-btn { color: #1e1e21 !important; } }
.draft-tag { font: 600 0.65rem var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: #8a5a00; background: #fbefd6; padding: 0.1rem 0.4rem; border-radius: 4px; }
.category-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 1.25rem 0 0; font-family: var(--sans); }
.category-chips a { font-size: 0.8rem; font-weight: 600; text-decoration: none; color: var(--muted); border: 1px solid var(--rule); border-radius: 99px; padding: 0.3rem 0.8rem; }
.category-chips a[aria-current="page"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.article-editor { display: grid; gap: 1rem; margin-top: 1.5rem; font-family: var(--sans); }
.article-editor label { display: grid; gap: 0.35rem; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.article-editor label small { font-weight: 400; }
.article-editor input, .article-editor textarea {
  font: 1rem var(--sans); color: var(--ink); background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; padding: 0.65rem 0.75rem; width: 100%;
}
.article-editor #md-body { font: 1rem/1.6 ui-monospace, Menlo, monospace; min-height: 24rem; resize: vertical; }
.article-editor .row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
@media (max-width: 40rem) { .article-editor .row3 { grid-template-columns: 1fr; } }
.editor-tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--rule); }
.editor-tabs button, .md-toolbar button, .editor-actions button {
  font: 600 0.85rem var(--sans); border: 1px solid var(--rule); background: transparent; color: var(--ink); border-radius: 8px; padding: 0.45rem 0.8rem; cursor: pointer;
}
.editor-tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); }
.editor-tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.md-toolbar { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.md-preview { border: 1px dashed var(--rule); border-radius: 8px; padding: 1rem 1.25rem; min-height: 24rem; font-family: var(--serif); }
.md-help { font-size: 0.85rem; color: var(--muted); }
.md-help code { background: var(--accent-soft); padding: 0 0.3rem; border-radius: 4px; }
.article-editor label.check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.95rem; color: var(--ink); }
.article-editor .error { color: #b3261e; margin: 0; }
.article-editor .success { color: #2e6b3a; margin: 0; }
.article-editor .error:empty, .article-editor .success:empty { display: none; }
.editor-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.editor-actions .primary-btn { background: var(--accent); border-color: var(--accent); color: #fff; padding: 0.65rem 1.4rem; }
@media (prefers-color-scheme: dark) { .editor-actions .primary-btn { color: #1e1e21; } }
.editor-actions .spacer { flex: 1; }
.editor-actions .danger-link { border: 0; color: #b3261e; }
.view-link { font-weight: 600; }

/* Owner dashboard */
.dash-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; margin: 1.5rem 0; font-family: var(--sans); }
@media (max-width: 40rem) { .dash-grid { grid-template-columns: repeat(2, 1fr); } }
.dash-grid div { background: var(--accent-soft); border-radius: 10px; padding: 0.8rem 0.9rem; display: grid; }
.dash-grid strong { font: 600 1.7rem var(--serif); color: var(--accent); }
.dash-grid span { font-size: 0.8rem; color: var(--muted); }
.bars { display: grid; grid-template-columns: repeat(14, 1fr); gap: 0.3rem; height: 9rem; align-items: end; font-family: var(--sans); }
.bar-col { display: grid; grid-template-rows: 1fr auto; height: 100%; align-items: end; text-align: center; }
.bar { display: block; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-label { font-size: 0.7rem; color: var(--muted); padding-top: 0.25rem; }
.dash-table { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 0.9rem; }
.dash-table th, .dash-table td { text-align: left; padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--rule); }
.dash-table th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.dash-table td:not(:first-child), .dash-table th:not(:first-child) { text-align: right; width: 6rem; }
.owner-links { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.5rem 0 0; }
.feed-copy { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.5rem 0 1.5rem; }
.feed-copy input { flex: 1 1 16rem; min-width: 0; font: 0.9rem var(--sans); padding: 0.55rem 0.75rem; border: 1px solid var(--rule); border-radius: 8px; background: transparent; color: var(--ink); }
.feed-copy button { border: 0; cursor: pointer; }
