:root {
  --bg: #ece6f7;
  --bg-soft: #f4f0fb;
  --bg-deep: #ddd3ef;
  --paper: #faf7fe;
  --ink: #0a0a0d;
  --ink-soft: #2a2535;
  --muted: #5b556b;
  --line: #c9bfe3;
  --primary: #6b5dd8;
  --primary-deep: #4d3fb2;
  --primary-darker: #382c8a;
  --gold: #b8924a;
  --shadow: 0 30px 60px -30px rgba(56, 44, 138, 0.35);
  --shadow-soft: 0 10px 30px -16px rgba(56, 44, 138, 0.25);

  --font-display: "Cinzel", "Cormorant Garamond", Georgia, serif;
  --font-serif: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  --font-body: "EB Garamond", Georgia, serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

/* Sticky header is ~64px tall; offset anchor targets so they don't slide
   behind it when scrollIntoView/scroll-to-hash fires. */
main [id],
main section[id] { scroll-margin-top: 96px; }

/* <main> is invisible by default and JS adds .is-ready to fade it in once
   server-side overrides have been applied (or a 250ms safety timeout
   fires). The transition is declared ONLY on the .is-ready rule so the
   hide step at the start of each render is instant — without this the
   user sees the default text paint, fade away, then fade back in. */
main { opacity: 0; }
main.is-ready { opacity: 1; transition: opacity .15s ease; }

body {
  font-family: var(--font-body);
  font-size: 19px;
  line-height: 1.65;
  color: var(--ink-soft);
  background: var(--bg);
  background-image:
    radial-gradient(1100px 700px at 110% -10%, rgba(107, 93, 216, 0.18), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(184, 146, 74, 0.10), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }

a {
  color: var(--primary-deep);
  text-decoration: none;
  text-underline-offset: 4px;
  transition: color .2s ease;
}
a:hover { color: var(--primary-darker); text-decoration: underline; }

.container {
  width: min(1180px, 92%);
  margin: 0 auto;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: -9999px; top: 0; background: var(--ink); color: #fff;
  padding: .6rem 1rem; z-index: 1000;
}
.skip:focus { left: 1rem; top: 1rem; }

/* ───────────── Header ───────────── */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(236, 230, 247, 0.85);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid rgba(107, 93, 216, 0.18);
}

.header-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 2rem; padding: 1.1rem 0;
}

.brand {
  display: inline-flex; align-items: center; gap: .85rem;
  color: var(--ink); text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-logo {
  display: block; width: auto; max-width: 100%;
  height: 60px; /* larger at the top of the page */
  transition: height .25s ease;
}
.site-header.is-scrolled .brand-logo { height: 46px; } /* shrinks once scrolled */
.brand-wordmark { transition: opacity .25s ease; }
.site-header.is-scrolled .brand-wordmark { opacity: 0; } /* fade out the text when scrolled */
@media (max-width: 560px) {
  .brand-logo { height: 48px; }
  .site-header.is-scrolled .brand-logo { height: 38px; }
}
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-line {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: .08em;
  font-size: 1.05rem;
  text-transform: uppercase;
  color: var(--ink);
}
.brand-line--accent { color: var(--primary-deep); margin-top: .25rem; }

.primary-nav ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; gap: 1.6rem; align-items: center;
}
.primary-nav a {
  font-family: var(--font-serif);
  color: var(--ink);
  font-size: 1.02rem;
  letter-spacing: .04em;
  padding: .4rem 0;
  border-bottom: 1.5px solid transparent;
  transition: border-color .2s ease, color .2s ease;
}
.primary-nav a:hover { color: var(--primary-deep); text-decoration: none; border-bottom-color: var(--primary-deep); }
.primary-nav a.is-active {
  color: var(--primary-deep);
  border-bottom-color: var(--primary-deep);
}

.nav-toggle {
  display: none; background: none; border: 0; padding: .5rem; cursor: pointer;
}
.nav-toggle-bar {
  display: block; width: 24px; height: 2px; background: var(--ink); margin: 5px 0;
  transition: transform .2s ease, opacity .2s ease;
}

@media (max-width: 980px) {
  .nav-toggle { display: block; }
  .primary-nav {
    position: absolute; left: 0; right: 0; top: 100%;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--line);
    max-height: 0; overflow: hidden;
    transition: max-height .25s ease;
  }
  .primary-nav.is-open { max-height: 600px; }
  .primary-nav ul {
    flex-direction: column; align-items: stretch; gap: 0;
    padding: 1rem 0;
  }
  .primary-nav li { padding: 0 5%; }
  .primary-nav a {
    display: block; padding: .8rem 0;
    border-bottom: 1px solid var(--line);
  }
  .primary-nav a.is-active { border-bottom-color: var(--primary-deep); }
}

/* ───────────── Typography ───────────── */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  color: var(--ink);
  letter-spacing: -.005em;
  margin: .5em 0;
  line-height: 1.15;
}
h1 { font-size: clamp(2.6rem, 6vw, 4.6rem); font-weight: 600; }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.4rem); font-weight: 500; line-height: 1.25; }
h3 { font-size: 1.5rem; font-weight: 600; }
h4 { font-size: 1.15rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--primary-deep); }

p { margin: 0 0 1.1em; }

.eyebrow {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: .28em;
  font-size: .82rem;
  color: var(--primary-deep);
  margin-bottom: 1.2rem;
  display: inline-block;
}

.lead { font-size: 1.22rem; color: var(--ink-soft); }

.rule {
  display: block;
  width: 88px; height: 1px;
  background: var(--primary-deep);
  margin: 1.4rem 0 1.8rem;
}
.rule--center { margin-left: auto; margin-right: auto; }

.flourish {
  display: flex; align-items: center; justify-content: center;
  gap: .9rem; color: var(--primary-deep);
  margin: 2.4rem 0;
}
.flourish::before, .flourish::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(to right, transparent, var(--primary-deep), transparent);
  max-width: 160px;
}
.flourish svg { width: 22px; height: 22px; }

blockquote.verse {
  border-left: 3px solid var(--primary-deep);
  padding: .4rem 0 .4rem 1.4rem;
  margin: 1.6rem 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.18rem;
  color: var(--ink);
}
blockquote.verse cite {
  display: block;
  font-style: normal;
  font-size: .95rem;
  color: var(--muted);
  margin-top: .4rem;
  letter-spacing: .08em;
  font-family: var(--font-display);
}

.dropcap::first-letter {
  font-family: var(--font-display);
  font-size: 3.6em;
  float: left;
  line-height: .9;
  padding: .12em .12em 0 0;
  color: var(--primary-deep);
  font-weight: 700;
}

/* ───────────── Buttons ───────────── */
.btn {
  display: inline-flex; align-items: center; gap: .6rem;
  padding: .85rem 1.5rem;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-size: .82rem;
  border-radius: 2px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .15s ease, background .2s ease, color .2s ease, border-color .2s ease;
}
.btn--primary { background: var(--primary-deep); color: #fff; }
.btn--primary:hover { background: var(--primary-darker); color: #fff; text-decoration: none; transform: translateY(-1px); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn--ghost:hover { background: var(--ink); color: #fff; text-decoration: none; }
.btn--on-dark { background: transparent; color: #fff; border-color: #fff; }
.btn--on-dark:hover { background: #fff; color: var(--ink); text-decoration: none; }

/* ───────────── Page sections ───────────── */
.page { padding: 4rem 0 5rem; }
.page-head { padding: 4.5rem 0 2.5rem; text-align: center; }
.page-head .eyebrow { display: block; }

section + section { margin-top: 3.5rem; }

/* ───────────── Home: Hero ───────────── */
.hero {
  position: relative;
  padding: 5rem 0 3rem;
  text-align: center;
}
.hero h1 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(3rem, 8vw, 6.4rem);
  letter-spacing: -.015em;
}
.hero h1 .word--accent { color: var(--primary-deep); font-style: italic; }
.hero h2 {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.25rem, 2.4vw, 1.85rem);
  color: var(--ink-soft);
  margin: 1.2rem auto 0;
  line-height: 1.45;
}
.hero-cta {
  display: flex; flex-wrap: wrap; gap: .8rem; justify-content: center;
  margin-top: 2.3rem;
}

.hero-mark {
  display: block;
  height: 84px; width: auto; /* taller-than-wide icon — let width follow ratio */
  margin: 0 auto 1.6rem;
}

/* ───────────── Section heads ───────────── */
.section-head {
  margin: 4rem 0 1.6rem;
}
.section-head .kicker {
  font-family: var(--font-display);
  font-size: .82rem;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--primary-deep);
  margin-bottom: .6rem;
}
.section-head h2 {
  font-size: clamp(2rem, 4vw, 3rem);
  margin: 0;
}
.section-head .rule { margin: 1.2rem 0 0; }
.section-head--center { text-align: center; }
.section-head--center .rule { margin-left: auto; margin-right: auto; }

/* ───────────── Editorial info list (hanging label, hairline rules) ───────────── */
.info-list {
  margin: 1.5rem 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.info-item {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 3rem;
  padding: 2.4rem 0;
  border-bottom: 1px solid var(--line);
}
.info-item dt, .info-item .info-label {
  font-family: var(--font-display);
  font-size: .8rem;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--primary-deep);
  padding-top: .35rem;
  margin: 0;
}
.info-item dd, .info-item .info-body {
  margin: 0;
}
.info-headline {
  font-family: var(--font-serif);
  font-size: 1.65rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 .9rem;
  line-height: 1.2;
}
.info-sub {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--primary-deep);
  font-size: 1.15rem;
  margin: -.5rem 0 .8rem;
}
.info-note {
  font-style: italic;
  color: var(--muted);
  font-size: 1rem;
}
.info-body ul { margin: 0 0 1rem; padding-left: 1.15rem; }
.info-body ul li { margin-bottom: .2rem; }
.info-body p:last-child { margin-bottom: 0; }

@media (max-width: 820px) {
  .info-item {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 2rem 0;
  }
  .info-item dt, .info-item .info-label { padding-top: 0; }
}

/* ───────────── Home: Lord's Day passage ───────────── */
.lords-day-body {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
}
.lords-day-body p { font-size: 1.12rem; }
.lords-day-body .btn { margin-top: 1.4rem; }

/* ───────────── Welcome ornament ───────────── */
.welcome {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3.5rem;
  align-items: center;
  margin-top: 5rem;
}
.welcome-text { max-width: 560px; }
.welcome-text .btn { margin-top: 1.4rem; }
.welcome-ornament {
  display: flex; align-items: center; justify-content: center;
  color: var(--primary-deep);
}
.welcome-ornament svg { width: 70%; max-width: 360px; opacity: .85; }
.welcome-ornament-img { width: 70%; max-width: 300px; height: auto; display: block; }
@media (max-width: 820px) {
  .welcome { grid-template-columns: 1fr; }
  .welcome-ornament svg { max-width: 240px; }
  .welcome-ornament-img { max-width: 220px; }
}

/* ───────────── Numbered marks grid (no boxes, hairline columns) ───────────── */
.home-content .marks-grid {
  grid-template-columns: repeat(3, 1fr);
}

.home-content .marks-grid > .mark:nth-child(2n) { border-right: 1px solid var(--line); }
.home-content .marks-grid--two > .mark:nth-child(2n) { border-right: 1px solid var(--line); }

.marks {
  margin-top: 5rem;
}
.marks-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin-top: 2.4rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.marks-grid--two { grid-template-columns: repeat(2, 1fr); }
.mark {
  padding: 2.4rem 2rem;
  border-right: 1px solid var(--line);
}
.mark:last-child { border-right: none; }
.marks-grid > .mark:nth-child(2n) { border-right: none; }
.marks-grid--two > .mark:nth-child(2n) { border-right: none; }

.mark-num {
  display: block;
  font-family: var(--font-display);
  font-size: .8rem;
  letter-spacing: .26em;
  color: var(--primary-deep);
  margin-bottom: 1.1rem;
}
.mark-title {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 600;
  margin: 0 0 .6rem;
  color: var(--ink);
}
.mark p { margin-bottom: 0; }

@media (max-width: 820px) {
  .home-content .marks-grid,
  .home-content .marks-grid--two,
  .marks-grid,
  .marks-grid--two { grid-template-columns: 1fr; }
  
  .home-content .mark,
  .home-content .marks-grid > .mark:nth-child(2n),
  .mark {
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 2rem 0;
  }
  .marks-grid > .mark:last-child { border-bottom: none; }
}

/* ───────────── About ───────────── */
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3.5rem;
  align-items: start;
}
@media (max-width: 820px) { .split { grid-template-columns: 1fr; } }

/* Editorial roster — no cards, just typography and rules */
.roster {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 2rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.roster-item {
  text-align: center;
  padding: 2.4rem 1.5rem;
  border-right: 1px solid var(--line);
}
.roster-item:last-child { border-right: none; }
.roster-mark {
  font-family: var(--font-display);
  color: var(--primary-deep);
  font-size: 1.1rem;
  letter-spacing: .3em;
  margin-bottom: 1.1rem;
}
.roster-name {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 .35rem;
  letter-spacing: 0;
  text-transform: none;
}
.roster-role {
  font-family: var(--font-display);
  font-size: .74rem;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--primary-deep);
}
@media (max-width: 820px) {
  .roster { grid-template-columns: 1fr; }
  .roster-item {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .roster-item:last-child { border-bottom: none; }
}

/* ───────────── Aside info (Visit, Get-in-Touch) ───────────── */
.aside-stack > * + * {
  margin-top: 2.2rem;
  padding-top: 2.2rem;
  border-top: 1px solid var(--line);
}
.aside-block .info-label {
  font-family: var(--font-display);
  font-size: .78rem;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--primary-deep);
  margin-bottom: .6rem;
  display: block;
}
.aside-block h3 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 .6rem;
}
.aside-block p:last-child { margin-bottom: 0; }

/* ───────────── Doctrine ───────────── */
.doctrine-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 3rem;
  align-items: start;
}
@media (max-width: 980px) { .doctrine-layout { grid-template-columns: 1fr; } }

.doctrine-toc {
  position: sticky; top: 100px;
  border-left: 1px solid var(--line);
  padding-left: 1.4rem;
  font-size: .98rem;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
.doctrine-toc h4 { margin-bottom: 1rem; }
.doctrine-toc ol {
  list-style: none; padding: 0; margin: 0;
  counter-reset: chapter;
}
.doctrine-toc li {
  counter-increment: chapter;
  margin-bottom: .55rem;
}
.doctrine-toc li::before {
  content: counter(chapter, upper-roman) ". ";
  color: var(--primary-deep);
  font-family: var(--font-display);
  font-size: .82rem;
  margin-right: .3rem;
}
.doctrine-toc a {
  color: var(--ink-soft);
  text-decoration: none;
  transition: color .15s ease;
}
.doctrine-toc a:hover { color: var(--primary-deep); }
.doctrine-toc a.is-active {
  color: var(--primary-deep);
  font-weight: 600;
}
.doctrine-toc li.is-active::before { font-weight: 700; }

@media (max-width: 980px) {
  .doctrine-toc { position: static; max-height: none; }
}

.doctrine-article {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: clamp(1.8rem, 4vw, 3.2rem);
  box-shadow: var(--shadow-soft);
}
.doctrine-article > section { scroll-margin-top: 110px; }
.doctrine-article h2 {
  font-family: var(--font-display);
  font-size: 1.7rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--primary-darker);
  margin-top: 3rem;
  padding-bottom: .8rem;
  border-bottom: 1px solid var(--line);
}
.doctrine-article h2:first-child { margin-top: 0; }
.doctrine-article .chapter-num {
  display: block;
  font-family: var(--font-display);
  font-size: .82rem;
  letter-spacing: .28em;
  color: var(--primary-deep);
  margin-bottom: .3rem;
  text-transform: uppercase;
}
.doctrine-article h3 {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  margin: 2rem 0 .4rem;
  color: var(--ink);
}
.doctrine-article .refs {
  font-style: italic;
  color: var(--muted);
  font-size: 1rem;
}
.doctrine-article .attr-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2rem 0 1.4rem;
  font-size: 1rem;
}
.doctrine-article .attr-table th,
.doctrine-article .attr-table td {
  text-align: left;
  padding: .6rem .8rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.doctrine-article .attr-table th {
  font-family: var(--font-display);
  font-size: .8rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--primary-deep);
  background: var(--bg-soft);
}
.doctrine-article .attr-table tr:last-child td { border-bottom: 0; }
.doctrine-article .lorem { color: var(--muted); font-style: italic; }

/* ───────────── Forms ───────────── */
.form {
  display: grid;
  gap: 1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2rem;
}
.form .row { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 600px) { .form .row { grid-template-columns: 1fr; } }
.form label {
  font-family: var(--font-display);
  font-size: .78rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--primary-deep);
  margin-bottom: .3rem;
  display: block;
}
.char-counter {
  margin-top: .3rem;
  text-align: right;
  font-size: .78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.char-counter.is-over { color: #a33; font-weight: 600; }

.form input, .form textarea, .form select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  padding: .7rem .85rem;
  font: inherit;
  color: var(--ink);
  border-radius: 2px;
}
.form input:focus, .form textarea:focus, .form select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.form .field { display: grid; }
.form-success {
  background: var(--bg-deep);
  border: 1px solid var(--primary-deep);
  padding: 1rem 1.2rem;
  border-radius: 4px;
  font-style: italic;
}

/* ───────────── Footer ───────────── */
.site-footer {
  margin-top: 5rem;
  background: var(--ink);
  color: #d4cce5;
  padding: 3.5rem 0 1.5rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: 2.5rem;
}
@media (max-width: 820px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 540px) { .footer-grid { grid-template-columns: 1fr; } }

.footer-brand { display: flex; flex-direction: column; line-height: 1; gap: .3rem; margin-bottom: 1.2rem; }
.footer-brand .brand-line { color: #fff; font-size: 1.1rem; }
.footer-brand .brand-line--accent { color: #b6a6f5; }

.footer-verse {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1rem;
  color: #c8bee0;
  max-width: 420px;
}
.footer-verse cite {
  display: block;
  margin-top: .5rem;
  font-style: normal;
  letter-spacing: .18em;
  font-size: .75rem;
  text-transform: uppercase;
  font-family: var(--font-display);
  color: #b6a6f5;
}
.footer-col h4 { color: #fff; }
.footer-col p { color: #c8bee0; }
.footer-links { list-style: none; margin: 0; padding: 0; }
.footer-links li { margin-bottom: .35rem; }
.footer-links a { color: #d4cce5; }
.footer-links a:hover { color: #fff; }
.solas { font-family: var(--font-serif); font-size: 1.05rem; }
.solas em { color: #b6a6f5; }
.footer-bar { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid rgba(255,255,255,0.1); text-align: center; }
.footer-bar small { color: #8e85a8; letter-spacing: .04em; }

/* ───────────── Misc ───────────── */
.tagline {
  text-align: center;
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--muted);
  font-size: 1.1rem;
  margin: 2rem 0;
}

/* ───────────── Footer sign-in (inconspicuous) ───────────── */
.footer-signin {
  display: inline-block;
  margin-left: 1.2rem;
  color: rgba(255, 255, 255, 0.18);
  font-family: var(--font-display);
  font-size: .68rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  text-decoration: none;
  transition: color .2s ease;
}
.footer-signin:hover { color: rgba(255, 255, 255, 0.7); text-decoration: none; }

/* ───────────── Admin chrome (logged-in state) ───────────── */
body.admin-active { padding: 10px; }
body.admin-active .site-header { top: 10px; }

#admin-chrome { position: relative; }

.admin-border {
  position: fixed;
  inset: 0;
  border: 10px solid #39ff14;
  box-shadow:
    inset 0 0 30px rgba(57, 255, 20, 0.55),
    0 0 28px rgba(57, 255, 20, 0.45);
  pointer-events: none;
  z-index: 9998;
}

.admin-badge {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
}

.admin-badge-btn {
  display: block;
  height: 45px;
  padding: 0 1.8rem;
  background: #39ff14;
  color: #001a00;
  border: 0;
  border-radius: 0 0 8px 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .82rem;
  letter-spacing: .32em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 0 24px rgba(57, 255, 20, 0.65),
    0 4px 18px rgba(0, 0, 0, 0.25);
}
.admin-badge-btn:hover { background: #5dff44; }
.admin-badge-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.admin-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 4px;
  min-width: 240px;
  background: #001a00;
  border: 2px solid #39ff14;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.45),
    0 0 24px rgba(57, 255, 20, 0.45);
}
.admin-menu[hidden] { display: none; }
.admin-menu > * {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: #b4ff9b;
  padding: .85rem 1.4rem;
  font-family: var(--font-display);
  font-size: .78rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px solid rgba(57, 255, 20, 0.18);
}
.admin-menu > *:last-child { border-bottom: 0; }
.admin-menu > *:hover,
.admin-menu > *:focus-visible {
  background: rgba(57, 255, 20, 0.15);
  color: #d6ffc4;
  outline: none;
}

/* ───────────── Admin pages ───────────── */
.admin-login {
  max-width: 480px;
  margin: 0 auto;
  padding: 4rem 0 6rem;
}

.admin-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-top: 2rem;
}
.admin-tile {
  display: block;
  padding: 2.2rem 1.8rem;
  text-decoration: none;
  color: var(--ink);
  border-right: 1px solid var(--line);
}
.admin-tile:last-child { border-right: 0; }
.admin-tile:hover { background: var(--bg-soft); text-decoration: none; }
.admin-tile .info-label {
  font-family: var(--font-display);
  font-size: .78rem;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--primary-deep);
  margin-bottom: .8rem;
  display: block;
}
.admin-tile h3 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  margin: 0 0 .5rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.5rem;
  font-size: 1rem;
}
.admin-table th,
.admin-table td {
  text-align: left;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.admin-table th {
  font-family: var(--font-display);
  font-size: .76rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--primary-deep);
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table .you { color: var(--primary-deep); font-style: italic; margin-left: .4rem; font-size: .85rem; }
.admin-table .row-actions-cell { width: 1%; white-space: nowrap; text-align: right; }

/* Forms list — whole row clickable */
#forms-table .form-row { cursor: pointer; }
#forms-table .form-row:hover { background: var(--bg-soft); }

/* Per-form submissions table */
.submissions-table-wrap { overflow-x: auto; }

/* Sort + filter share each header cell — flex layout puts the sort button
   on the left (label + arrow) and the filter icon (if any) on the right. */
/* Only zero out header padding when the cell wraps a flex .th-inner — plain
   header cells (e.g., the Forms list) keep their default cell padding. */
.admin-table thead th:has(.th-inner) { padding: 0; }
.admin-table .th-inner {
  display: flex;
  align-items: center;
  gap: .25rem;
  padding-right: .35rem;
}
.admin-table .sort-header {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  padding: .85rem 1rem;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--primary-deep);
  font-family: var(--font-display);
  font-size: .76rem;
  letter-spacing: .2em;
  text-transform: uppercase;
}
.admin-table .sort-header:hover { background: var(--bg-deep); }
.admin-table .sort-arrow {
  font-size: .8rem;
  letter-spacing: normal;
  opacity: .85;
}
.admin-table .sort-arrow--inactive { opacity: .25; }

.admin-table .column-filter-wrap {
  display: inline-flex;
  position: relative;
  flex-shrink: 0;
}
.admin-table .filter-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.admin-table .filter-icon-btn:hover {
  background: var(--bg-deep);
  color: var(--ink);
}
.admin-table .filter-icon-btn.is-active {
  color: var(--primary-deep);
  background: var(--bg-deep);
}
.admin-table .filter-icon-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.admin-table .filter-icon {
  width: 13px;
  height: 13px;
  fill: currentColor;
}
.admin-table .filter-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  background: var(--primary-deep);
  color: #fff;
  border-radius: 7px;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0;
}
.admin-table .filter-badge--dot {
  min-width: 8px;
  height: 8px;
  padding: 0;
  border-radius: 50%;
  top: 4px;
  right: 4px;
}

/* Filter popover — fixed-positioned so it escapes any overflow:auto */
.filter-popover {
  min-width: 220px;
  max-width: 320px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.22);
  padding: .5rem;
  font-family: var(--font-body);
}
.filter-popover[hidden] { display: none; }
.filter-popover-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .8rem;
  padding: .25rem .35rem .55rem;
  margin-bottom: .35rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: .72rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--primary-deep);
}
.filter-clear {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: .7rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  cursor: pointer;
  padding: .15rem .3rem;
  border-radius: 2px;
}
.filter-clear:hover {
  color: var(--primary-deep);
  background: var(--bg-soft);
}

.filter-checks { display: flex; flex-direction: column; }
.filter-check {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .4rem .35rem;
  cursor: pointer;
  font-size: .98rem;
  color: var(--ink);
  border-radius: 2px;
  user-select: none;
}
.filter-check:hover { background: var(--bg-soft); }
.filter-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary-deep);
  cursor: pointer;
  flex-shrink: 0;
}

.filter-date-grid { display: grid; gap: .5rem; padding: .25rem; }
.filter-date-grid label {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  font-family: var(--font-display);
  font-size: .7rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--primary-deep);
}
.filter-date {
  font: inherit;
  font-size: .95rem;
  color: var(--ink);
  padding: .4rem .55rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
}
.filter-date:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}


.submission-cell {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}
.submission-cell--wrap {
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 460px;
}
.submission-delete {
  background: transparent;
  border: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.submission-delete:hover { background: #fbe9e9; color: #6f1f1f; }

.row-menu { position: relative; display: inline-block; }
.row-menu-btn {
  background: transparent;
  border: 0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  color: var(--muted);
  transition: background .15s ease, color .15s ease;
}
.row-menu-btn:hover,
.row-menu.is-open .row-menu-btn {
  background: var(--bg-soft);
  color: var(--ink);
}
.row-menu-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.row-menu-icon { width: 16px; height: 16px; display: block; fill: currentColor; }

.row-menu-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 160px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  z-index: 100;
  padding: .35rem 0;
}
.row-menu-dropdown[hidden] { display: none; }
.row-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: .55rem 1rem;
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--ink);
  cursor: pointer;
}
.row-menu-item:hover:not([disabled]),
.row-menu-item:focus-visible:not([disabled]) {
  background: var(--bg-soft);
  outline: none;
}
.row-menu-item--danger { color: #a33; }
.row-menu-item--danger:hover:not([disabled]) { background: #fbe9e9; color: #6f1f1f; }
.row-menu-item[disabled] {
  color: var(--muted);
  cursor: not-allowed;
}

.field-hint {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  margin-left: .35rem;
}

/* Table-level controls: search + page-size + (optional) primary action */
.table-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 1.4rem 0 1rem;
}
.table-search {
  flex: 1 1 240px;
  max-width: 360px;
  font: inherit;
  font-size: .95rem;
  color: var(--ink);
  padding: .55rem .8rem;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 2px;
}
.table-search:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.table-search::-webkit-search-cancel-button { cursor: pointer; }
.table-page-size {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--font-display);
  font-size: .7rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}
.table-page-size select {
  font-family: var(--font-body);
  font-size: .95rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  padding: .35rem .55rem;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 2px;
}
.table-controls-actions { margin-left: auto; display: flex; gap: .75rem; }
.table-controls-actions .btn { letter-spacing: .18em; }

/* Footer: status text on the left, pagination on the right */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
  font-family: var(--font-body);
  font-size: .92rem;
  color: var(--muted);
  min-height: 32px;
}
.table-footer .muted { color: var(--muted); opacity: .85; }
.table-status { line-height: 1.4; }

.pagination {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  margin-left: auto;
}
.page-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  font-size: .92rem;
  padding: .35rem .6rem;
  min-width: 34px;
  border-radius: 2px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.page-btn:hover:not([disabled]) { background: var(--bg-soft); border-color: var(--primary-deep); }
.page-btn.is-active {
  background: var(--primary-deep);
  color: #fff;
  border-color: var(--primary-deep);
}
.page-btn[disabled] {
  opacity: .35;
  cursor: not-allowed;
}
.page-ellipsis {
  padding: 0 .35rem;
  color: var(--muted);
}

/* ───────────── Inline editor (Admin only) ───────────── */
/* Runs of consecutive <p> are grouped into this wrapper so the whole block
   edits as one unit; it has no layout impact of its own. */
.text-block { display: block; }
.text-block > p:last-child { margin-bottom: 0; }

body.editor-on .editable {
  cursor: text;
  outline: 1px dashed transparent;
  outline-offset: 4px;
  border-radius: 2px;
  transition: outline-color .15s ease, background .15s ease;
}
body.editor-on .editable:hover {
  outline-color: var(--primary-deep);
}
/* Don't outline an inner <p> when the wrapping .text-block is already
   shown as the editable target. */
body.editor-on .text-block p { outline: none; }
/* Suppress the browser's default focus outline on editable elements when
   they are NOT actively being edited (the .is-editing rule below wins on
   specificity while editing). */
.editable:focus,
.editable:focus-visible { outline: none; }

.editable.is-editing,
.editable.is-editing:hover,
.editable.is-editing:focus,
.editable.is-editing:focus-visible {
  outline: 2px solid #39ff14;
  outline-offset: 4px;
  background: rgba(57, 255, 20, 0.06);
  caret-color: #2bb010;
}

.edit-toolbar {
  position: fixed;
  z-index: 11500;
  display: flex;
  align-items: stretch;
  background: #0a0a0d;
  color: #fff;
  border: 1px solid #39ff14;
  border-radius: 4px;
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.4),
    0 0 14px rgba(57, 255, 20, 0.45);
  overflow: hidden;
  font-family: var(--font-display);
}
.edit-toolbar[hidden] { display: none; }
.edit-toolbar button {
  background: transparent;
  color: #fff;
  border: 0;
  height: 36px;
  padding: 0 .9rem;
  font-family: inherit;
  font-size: .82rem;
  letter-spacing: .08em;
  cursor: pointer;
}
.edit-toolbar button:hover { background: rgba(57, 255, 20, 0.18); }
.edit-toolbar button strong { font-weight: 800; }
.edit-toolbar button em { font-style: italic; }
.edit-toolbar-divider {
  width: 1px;
  background: rgba(255, 255, 255, 0.15);
  margin: 6px 0;
}
.edit-toolbar-primary {
  background: #39ff14 !important;
  color: #001a00 !important;
  font-weight: 700;
  letter-spacing: .16em;
}
.edit-toolbar-primary:hover { background: #5dff44 !important; }

/* ───────────── Settings modal (per-page meta + site settings) ───────────── */
/* The Settings entry in the admin menu is only meaningful on public pages. */
body.admin-route .admin-menu-settings { display: none; }

/* Wider modal dialog used for the multi-tab Settings panel */
.modal-dialog.modal-dialog--wide { max-width: 760px; }

/* Tabs */
.settings-tabs {
  display: flex;
  gap: 1.6rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.2rem;
}
.settings-tab {
  background: transparent;
  border: 0;
  padding: .7rem 0;
  margin-bottom: -1px;
  font-family: var(--font-display);
  font-size: .76rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.settings-tab:hover { color: var(--ink); }
.settings-tab.is-active {
  color: var(--primary-deep);
  border-bottom-color: var(--primary-deep);
}
.settings-panel[hidden] { display: none; }

/* Nav editor */
.nav-editor { margin-top: .6rem; }
.nav-editor-empty,
.nav-editor-loading {
  text-align: center;
  color: var(--muted);
  font-style: italic;
  padding: 1.2rem 0;
}
.nav-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .35rem;
  border-bottom: 1px solid var(--line);
}
.nav-row:last-child { border-bottom: 0; }
.nav-row--child { padding-left: 1.6rem; background: var(--bg-soft); }
.nav-row-handles {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}
.nav-row-handles button {
  width: 24px;
  height: 18px;
  font-size: .75rem;
  line-height: 1;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  border-radius: 2px;
}
.nav-row-handles button:hover { background: var(--bg-soft); color: var(--ink); }
.nav-row-label,
.nav-row-path {
  flex: 1;
  min-width: 0;
  padding: .4rem .55rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  font: inherit;
  font-size: .92rem;
  background: #fff;
}
.nav-row-label { flex: 1.4; }
.nav-row-label:focus,
.nav-row-path:focus,
.nav-row-parent:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.nav-row-parent {
  padding: .4rem .55rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  font: inherit;
  font-size: .9rem;
  background: #fff;
  max-width: 160px;
}
.nav-row-parent[disabled] {
  color: var(--muted);
  background: var(--bg-soft);
  cursor: not-allowed;
}
.nav-row-delete {
  background: transparent;
  border: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.nav-row-delete:hover { color: #6f1f1f; background: #fbe9e9; }
.nav-add-btn { margin-top: .8rem; letter-spacing: .14em; }

/* ───────────── Public sub-nav (dropdown under top nav) ───────────── */
.nav-item--has-children { position: relative; }
.nav-item--has-children > a { padding-right: .4rem; }
.nav-subnav-toggle {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  font-size: .7rem;
  padding: 0 .2rem;
  line-height: 1;
  /* hidden on desktop; visible on mobile */
  display: none;
}
/* Bumped specificity (`.primary-nav .nav-subnav`) so this wins over
   `.primary-nav ul { display: flex; gap: 1.6rem; }` which would otherwise
   lay the dropdown items out horizontally. */
.primary-nav .nav-subnav {
  display: block;
  gap: 0;
  align-items: stretch;
  list-style: none;
  margin: 0;
  padding: .35rem 0;
  position: absolute;
  top: calc(100% + .25rem);
  left: -.5rem;
  min-width: 200px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
  border-radius: 2px;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity .15s ease, transform .15s ease;
  white-space: nowrap;
}
.primary-nav .nav-subnav li { display: block; padding: 0; }
.nav-item--has-children:hover > .nav-subnav,
.nav-item--has-children:focus-within > .nav-subnav,
.nav-item--has-children.is-open > .nav-subnav {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.nav-subnav li { padding: 0; border: 0; }
.nav-subnav a {
  display: block;
  padding: .55rem 1rem;
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 0;
  letter-spacing: 0;
}
.nav-subnav a:hover {
  background: var(--bg-soft);
  color: var(--primary-deep);
  text-decoration: none;
}

@media (max-width: 980px) {
  /* Parent <li> becomes a flex container so the link takes the row and
     the toggle (▾) sits to its right; the dropdown wraps to the next row
     beneath them via flex-basis: 100%. */
  .primary-nav .nav-item--has-children {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
  }
  .primary-nav .nav-item--has-children > a {
    flex: 1;
    min-width: 0;
    padding-right: .5rem;
  }
  .primary-nav .nav-subnav-toggle {
    display: block;
    float: none;
    margin: 0;
    padding: .8rem .5rem;
    font-size: 1rem;
    color: var(--ink);
    flex-shrink: 0;
  }

  /* Mobile dropdown — stacked, inline (no absolute positioning), full
     width. Selector is `.primary-nav .nav-subnav` so it outranks the
     desktop `.primary-nav .nav-subnav` rule on specificity ties (later
     in the stylesheet wins). */
  .primary-nav .nav-subnav {
    flex-basis: 100%;
    display: none;
    position: static;
    top: auto;
    left: auto;
    border: 0;
    box-shadow: none;
    background: transparent;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    transition: none;
    padding: 0 0 0 1rem;
    margin: 0;
    min-width: 0;
    max-width: none;
    z-index: auto;
    white-space: normal;
  }
  /* Open only when the user has tapped the toggle — never on hover/focus
     (those are desktop-only behaviors). */
  .primary-nav .nav-item--has-children:hover > .nav-subnav,
  .primary-nav .nav-item--has-children:focus-within > .nav-subnav { display: none; }
  .primary-nav .nav-item--has-children.is-open > .nav-subnav { display: block; }

  .primary-nav .nav-subnav a {
    padding: .7rem 0;
    border-bottom: 1px solid var(--line);
  }
  .primary-nav .nav-subnav li:last-child a { border-bottom: 0; }
}

.settings-path {
  font-family: var(--font-display);
  font-size: .76rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--primary-deep);
  margin: .35rem 0 0;
}
.settings-section + .settings-section {
  margin-top: 1.8rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
}
.settings-section-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0 0 .35rem;
  color: var(--ink);
}
.settings-section-hint {
  color: var(--muted);
  font-size: .95rem;
  margin-bottom: 1rem;
}
.settings-reset {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: .72rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  cursor: pointer;
  padding: .35rem .5rem;
  border-radius: 2px;
}
.settings-reset:hover { color: #a33; background: #fbe9e9; }

/* ───────────── Modal ───────────── */
body.modal-open { overflow: hidden; }

.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 11000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 14, 50, 0.5);
  backdrop-filter: blur(2px);
  cursor: pointer;
}
.modal-dialog {
  position: relative;
  background: var(--paper);
  width: 100%;
  max-width: 580px;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  padding: 2.6rem 2.2rem 2rem;
  box-shadow: 0 32px 80px -10px rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line);
  border-radius: 4px;
  animation: modal-rise .18s ease-out;
}
@keyframes modal-rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-close {
  position: absolute;
  top: .6rem;
  right: .8rem;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  padding: .2rem .55rem;
  border-radius: 2px;
}
.modal-close:hover { color: var(--ink); background: var(--bg-soft); }
.modal-head { margin-bottom: 1.4rem; }
.modal-head .kicker {
  font-family: var(--font-display);
  font-size: .78rem;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--primary-deep);
  margin-bottom: .45rem;
}
.modal-head h2 {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  margin: 0;
}
.modal-dialog .form {
  padding: 0;
  background: transparent;
  border: 0;
}
.modal-actions {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  margin-top: 1.4rem;
}

.form-error,
.form-message {
  margin-top: .9rem;
  padding: .8rem 1rem;
  font-style: italic;
  border-left: 3px solid var(--primary-deep);
  background: var(--bg-deep);
  border-radius: 2px;
}
.form-error {
  border-left-color: #b54040;
  background: #fbe9e9;
  color: #6f1f1f;
  font-style: normal;
}
.form-message--success {
  border-left-color: #2c8a4a;
  background: #e8f5ec;
  color: #1f5230;
  font-style: normal;
}

/* ───────────── Teachings: public list ───────────── */
.teaching-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 3rem;
  align-items: start;
}
@media (max-width: 880px) { .teaching-layout { grid-template-columns: 1fr; } }

.teaching-filters { position: sticky; top: 100px; }
@media (max-width: 880px) { .teaching-filters { position: static; } }
.teaching-filters .table-search { width: 100%; margin-bottom: 1.4rem; }
.teaching-tags-title {
  margin: 0 0 .8rem;
  font-size: .9rem;
  width: 100%;
}
.teaching-tags { display: flex; flex-wrap: wrap; gap: .5rem; }
.teaching-tag {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .35rem .7rem;
  font-family: var(--font-body);
  font-size: .9rem;
  color: var(--ink-soft);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.teaching-tag:hover { border-color: var(--primary-deep); color: var(--primary-deep); }
.teaching-tag.is-active {
  background: var(--primary-deep);
  border-color: var(--primary-deep);
  color: #fff;
}
.teaching-tag-count { font-size: .78rem; opacity: .7; }

/* Public Series filter — chips like the tag filter, but single-select. */
.teaching-series-filter { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.6rem; }
.teaching-series-filter:empty { display: none; }
.teaching-series-chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .35rem .7rem;
  font-family: var(--font-body);
  font-size: .9rem;
  color: var(--ink-soft);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.teaching-series-chip:hover { border-color: var(--primary-deep); color: var(--primary-deep); }
.teaching-series-chip.is-active {
  background: var(--primary-deep);
  border-color: var(--primary-deep);
  color: #fff;
}

/* Series label on a card and on the detail header. */
.teaching-card-series {
  display: inline-block;
  font-family: var(--font-display);
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--primary-deep);
  margin: 0 0 .3rem;
}
.teaching-detail-series {
  display: inline-block;
  background: none; border: 0; padding: 0;
  font-family: var(--font-display);
  font-size: .82rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--primary-deep);
  cursor: pointer;
  margin: 0 0 .5rem;
}
.teaching-detail-series:hover { text-decoration: underline; }

/* "Manage Series" modal. */
.series-add-row { display: flex; gap: .6rem; align-items: stretch; }
.series-add-row input { flex: 1; }
.series-add-row .btn { white-space: nowrap; }
.series-manager { margin-top: 1.4rem; display: flex; flex-direction: column; gap: .55rem; }
.series-manager-empty { color: var(--muted); font-style: italic; margin: 0; }
.series-row { display: flex; align-items: center; gap: .6rem; }
.series-row-name {
  flex: 1; min-width: 0;
  border: 1px solid var(--line);
  background: #fff;
  padding: .55rem .75rem;
  font: inherit;
  color: var(--ink);
  border-radius: 2px;
}
.series-row-name:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.series-row-count { font-size: .82rem; color: var(--muted); white-space: nowrap; }

/* "Order Series" reorder modal. */
.series-order-list { list-style: none; margin: 1.2rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.series-order-item {
  display: flex; align-items: center; gap: .8rem;
  padding: .55rem .7rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-soft);
}
.series-order-pos {
  flex: 0 0 auto;
  width: 1.7rem; height: 1.7rem;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: .85rem;
  color: #fff; background: var(--primary-deep);
  border-radius: 50%;
}
.series-order-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.series-order-name { font-weight: 600; line-height: 1.25; }
.series-order-date { font-size: .8rem; color: var(--muted); }
.series-order-moves { flex: 0 0 auto; display: flex; gap: .3rem; }
.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  width: 2rem; height: 2rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem; line-height: 1;
  transition: border-color .15s ease, color .15s ease;
}
.icon-btn:hover:not(:disabled) { border-color: var(--primary-deep); color: var(--primary-deep); }
.icon-btn:disabled { opacity: .35; cursor: default; }

.teaching-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.8rem;
}
@media (max-width: 1080px) { .teaching-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .teaching-grid { grid-template-columns: 1fr; } }

.teaching-card {
  display: flex; flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease;
}
.teaching-card:hover {
  text-decoration: none;
  transform: translateY(-3px);
  box-shadow: var(--shadow-soft);
  border-color: var(--primary-deep);
}
.teaching-card-thumb {
  aspect-ratio: 16 / 9;
  background: var(--bg-deep);
  overflow: hidden;
}
.teaching-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.teaching-card-body { padding: 1.1rem 1.2rem 1.3rem; }
.teaching-card-title {
  font-size: 1.3rem;
  margin: 0 0 .35rem;
  line-height: 1.2;
}
.teaching-card-meta {
  font-size: .85rem;
  color: var(--primary-deep);
  font-family: var(--font-display);
  letter-spacing: .04em;
  margin: 0 0 .55rem;
}
.teaching-card-desc { font-size: .98rem; color: var(--muted); margin: 0; }
.teaching-empty { color: var(--muted); font-style: italic; grid-column: 1 / -1; }

/* ───────────── Teachings: detail ───────────── */
.teaching-back {
  display: inline-block;
  margin-bottom: 1.2rem;
  font-family: var(--font-display);
  font-size: .82rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-decoration: none;
}
.teaching-detail-actions {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 1rem; margin-top: 1.4rem;
}
.teaching-next { margin-left: auto; } /* push the link to the right of the row */
.teaching-next-link {
  display: inline-block;
  font-family: var(--font-display);
  font-size: .82rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-decoration: none;
}
.teaching-next-link:hover { text-decoration: underline; }

.teaching-detail-head h1 { margin: 0 0 .4rem; }
.teaching-detail-meta {
  color: var(--primary-deep);
  font-family: var(--font-display);
  letter-spacing: .05em;
  margin: 0 0 1.6rem;
}
.teaching-detail-body {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 2.4rem;
  align-items: start;
}
@media (max-width: 980px) { .teaching-detail-body { grid-template-columns: 1fr; } }

.teaching-video {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 4px;
  overflow: hidden;
}
.teaching-video iframe,
.teaching-video > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.teaching-detail-tags { display: flex; flex-wrap: wrap; gap: .5rem; }
.teaching-description {
  margin-top: 1.6rem;
  color: var(--ink-soft);
  line-height: 1.7;
}
.teaching-description > :first-child { margin-top: 0; }
.teaching-description > :last-child { margin-bottom: 0; }
.teaching-description p { margin: 0 0 1rem; }
.teaching-description h2,
.teaching-description h3 {
  color: var(--ink);
  line-height: 1.3;
  margin: 1.8rem 0 .6rem;
}
.teaching-description h2 { font-size: 1.5rem; }
.teaching-description h3 { font-size: 1.2rem; }
.teaching-description ul,
.teaching-description ol { margin: 0 0 1rem; padding-left: 1.4rem; }
.teaching-description li { margin: .25rem 0; }
.teaching-description a { color: var(--accent, #6b4fa0); text-decoration: underline; }
.teaching-description blockquote {
  margin: 1.2rem 0;
  padding: .4rem 0 .4rem 1.1rem;
  border-left: 3px solid var(--line);
  color: var(--muted);
  font-style: italic;
}

/* Rich-text editor (Quill) inside the teaching modal. */
.rte-editor {
  background: #fff;
  border-radius: 4px;
}
.rte-editor .ql-toolbar.ql-snow,
.rte-editor .ql-container.ql-snow { border-color: var(--line); }
.rte-editor .ql-toolbar.ql-snow { border-radius: 4px 4px 0 0; }
.rte-editor .ql-container.ql-snow { border-radius: 0 0 4px 4px; }
.rte-editor .ql-editor {
  min-height: 9rem;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.7;
}
.rte-editor .ql-editor.ql-blank::before { font-style: normal; color: var(--muted); }
.rte-fallback {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
}

.teaching-transcript {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-soft);
  position: sticky; top: 100px;
  display: flex; flex-direction: column;
  /* Cap the height so it stays compact on tall screens, but never taller than
     the viewport allows on shorter ones. */
  max-height: min(32rem, calc(100vh - 130px));
}
@media (max-width: 980px) { .teaching-transcript { position: static; max-height: 480px; } }
.teaching-transcript-head {
  margin: 0;
  padding: 1rem 1.2rem;
  font-size: 1rem;
  border-bottom: 1px solid var(--line);
}
.transcript-scroll { overflow-y: auto; padding: .5rem; }
.transcript-line {
  display: flex; gap: .7rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 3px;
  padding: .45rem .6rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.transcript-line:hover { background: var(--bg-deep); }
.transcript-line.is-active {
  background: var(--primary-deep);
  color: #fff;
}
.transcript-line.is-active .transcript-time { color: #fff; }
.transcript-time {
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-size: .78rem;
  color: var(--primary-deep);
  padding-top: .15rem;
  min-width: 3.2rem;
}
.transcript-text { flex: 1; }

/* ───────────── Teachings: admin ───────────── */
.link-btn {
  background: none; border: 0; padding: 0;
  color: var(--primary-deep);
  font-family: var(--font-body);
  font-size: .95rem;
  cursor: pointer;
  text-decoration: underline;
}
.link-btn + .link-btn { margin-left: .9rem; }
.link-btn--danger { color: #a33; }
.link-btn:hover { color: var(--primary-darker); }
.link-btn--danger:hover { color: #7d2424; }

.pill {
  display: inline-block;
  padding: .1rem .55rem;
  margin: .1rem 0;
  font-size: .8rem;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
}

.btn--small { padding: .5rem .9rem; font-size: .72rem; }

/* Tag chip input (teaching modal) */
.tag-input { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .5rem; }
.tag-input:empty { display: none; }
.tag-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .25rem .3rem .25rem .65rem;
  background: var(--primary-deep);
  color: #fff;
  border-radius: 999px;
  font-size: .88rem;
}
.tag-chip-x {
  background: rgba(255,255,255,.25);
  border: 0; color: #fff;
  width: 1.1rem; height: 1.1rem;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.tag-chip-x:hover { background: rgba(255,255,255,.45); }

.teaching-thumb-preview { margin-top: .6rem; }
.teaching-thumb-preview img {
  max-width: 220px; width: 100%;
  border: 1px solid var(--line);
  border-radius: 3px;
  display: block;
}

.transcript-editor-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.transcript-editor {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .9rem;
  line-height: 1.5;
  white-space: pre;
}
.transcript-status {
  display: block;
  margin: .4rem 0;
  font-size: .9rem;
  color: var(--primary-deep);
}
.transcript-status.is-error { color: #a33; }
