/* Tandem design tokens and base styles.
   Contrast for every text pairing is checked by scripts/contrast.mjs. */

@font-face { font-family: "Lora"; src: url("/fonts/lora-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Lora"; src: url("/fonts/lora-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Lora"; src: url("/fonts/lora-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Lora"; src: url("/fonts/lora-latin-600-italic.woff2") format("woff2"); font-weight: 600; font-style: italic; font-display: swap; }
@font-face { font-family: "Poppins"; src: url("/fonts/poppins-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Poppins"; src: url("/fonts/poppins-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Poppins"; src: url("/fonts/poppins-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Poppins"; src: url("/fonts/poppins-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }

:root {
  /* Brand palette */
  --navy: #1F2444;
  --navy-deep: #11142A; /* dark theme background */
  --coral: #E0735A;
  --cream: #F8F8F7;
  --grey-blue: #6B6F80;
  --lavender: #B7BAD1;
  --coral-tint: #E8916F;
  --coral-deep: #B4513A; /* light theme only: accent text on cream */
  --white: #FFFFFF;

  --font-serif: "Lora", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-sans: "Poppins", "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;

  --measure: 64ch;
  --page: 72rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --radius: 6px;

  /* Light theme (cream surface) */
  color-scheme: light;
  --bg: var(--cream);
  --surface: var(--white);
  --text: var(--navy);
  --muted: var(--grey-blue);
  --accent: var(--coral-deep);
  --rule: #D9DAE3;
  --field-border: var(--grey-blue);
  --focus: var(--navy);
  --logo-stem: var(--navy);
  --btn-bg: var(--coral);
  --btn-bg-hover: var(--coral-tint);
  --btn-text: var(--navy);
  --stars: none;
  --error: #A3321F;
  --success: #2F6B4F;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: var(--navy-deep);
    --surface: var(--navy);
    --text: var(--cream);
    --muted: var(--lavender);
    --accent: var(--coral-tint);
    --rule: #2E3461;
    --field-border: var(--lavender);
    --focus: var(--coral-tint);
    --logo-stem: var(--white);
    --stars: block;
    --error: #F2A08E;
    --success: #8FD1AE;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: var(--navy-deep);
  --surface: var(--navy);
  --text: var(--cream);
  --muted: var(--lavender);
  --accent: var(--coral-tint);
  --rule: #2E3461;
  --field-border: var(--lavender);
  --focus: var(--coral-tint);
  --logo-stem: var(--white);
  --stars: block;
  --error: #F2A08E;
  --success: #8FD1AE;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  font-weight: 400;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
h1, h2, h3 { font-family: var(--font-serif); font-weight: 400; line-height: 1.2; margin: 0 0 0.75rem; text-wrap: balance; }
h2 { font-size: clamp(1.5rem, 2.5vw, 1.875rem); }
h3 { font-size: 1.125rem; }
p { margin: 0 0 1rem; max-width: var(--measure); }
ul { padding-left: 1.25rem; max-width: var(--measure); }
li { margin-bottom: 0.4rem; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 2px; }

.skip-link {
  position: absolute; left: var(--gutter); top: -100px; z-index: 10;
  background: var(--surface); color: var(--text); padding: 0.75rem 1rem; border-radius: var(--radius);
  font-family: var(--font-sans); font-weight: 600; font-size: 1rem;
}
.skip-link:focus { top: 0.75rem; }

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

.wrap { max-width: var(--page); margin-inline: auto; padding-inline: var(--gutter); }

/* Small labels: Poppins tracked caps */
.eyebrow {
  font-family: var(--font-sans); font-weight: 600; font-size: 0.8125rem;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
  margin: 0 0 1.25rem;
}

/* Header */
.site-header .wrap {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.75rem 1.5rem; padding-block: 1.25rem;
}
.brand { font-family: var(--font-serif); display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; font-weight: 600; font-size: 1.25rem; }
.logo { width: 2.25rem; height: auto; color: var(--text); }
.logo .stem { fill: var(--logo-stem); }
.logo .stem-coral { fill: var(--coral); }
.site-nav ul { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 2rem; list-style: none; margin: 0; padding: 0; }
.site-nav li { margin: 0; }
.site-header .wrap.is-stacked { justify-content: center; }
.site-header .wrap.is-stacked .site-nav ul { justify-content: center; }

.site-nav a {
  display: inline-flex; align-items: center; min-height: 44px;
  font-family: var(--font-sans); font-weight: 500; font-size: 0.875rem; text-decoration: none;
}
.site-nav a:hover { text-decoration: underline; }

.theme-toggle {
  display: inline-grid; place-items: center; width: 44px; height: 44px;
  background: transparent; color: var(--text); border: 1px solid var(--rule); border-radius: 50%; cursor: pointer;
}
.theme-toggle[hidden] { display: none; }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle[data-current="dark"] .icon-sun { display: block; }
.theme-toggle[data-current="dark"] .icon-moon { display: none; }

/* Hero */
.hero { position: relative; overflow: hidden; padding-block: clamp(2rem, 9vh, 6rem) clamp(2.5rem, 9vh, 6rem); }
/* Static star texture, dark theme only, kept to the right so it never sits behind text. */
.hero::after {
  content: ""; display: var(--stars); position: absolute; inset: 0 0 0 55%; pointer-events: none;
  background-image:
    radial-gradient(1.2px 1.2px at 12% 18%, rgba(248,248,247,0.55) 50%, transparent 51%),
    radial-gradient(1px 1px at 34% 62%, rgba(248,248,247,0.4) 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 58% 28%, rgba(183,186,209,0.6) 50%, transparent 51%),
    radial-gradient(1px 1px at 76% 74%, rgba(248,248,247,0.35) 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 88% 12%, rgba(232,145,111,0.55) 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 88%, rgba(183,186,209,0.45) 50%, transparent 51%),
    radial-gradient(1px 1px at 66% 48%, rgba(248,248,247,0.3) 50%, transparent 51%);
  background-size: 260px 220px;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 35%);
  mask-image: linear-gradient(to right, transparent, #000 35%);
}
.hero .wrap { position: relative; z-index: 1; }
.hero h1 {
  font-size: clamp(2rem, 4.5vw, 2.75rem); line-height: 1.15; letter-spacing: -0.01em;
  max-width: 20ch; margin-bottom: 1.25rem;
}
.hero h1 em { display: block; font-style: italic; font-weight: 400; color: var(--accent); }
.hero .lede { font-size: clamp(1.0625rem, 1.5vw, 1.1875rem); max-width: 42ch; margin-bottom: 2rem; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.75rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px;
  padding: 0.75rem 1.6rem; border: 0; border-radius: var(--radius);
  background: var(--btn-bg); color: var(--btn-text);
  font-family: var(--font-sans); font-weight: 600; font-size: 0.9375rem; text-decoration: none; cursor: pointer;
  transition: background-color 150ms ease;
}
.btn:hover { background: var(--btn-bg-hover); text-decoration: none; }
.text-link { font-family: var(--font-sans); font-weight: 500; font-size: 0.9375rem; min-height: 44px; display: inline-flex; align-items: center; }

/* Sections */
.section { padding-block: clamp(2.5rem, 5vw, 4rem); border-top: 1px solid var(--rule); }
.section-head { margin-bottom: 2rem; }
.section-head .eyebrow { margin-bottom: 0.75rem; }
.section-label { margin-bottom: 0.6rem; }

.benefits { display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); list-style: none; padding: 0; margin: 0; max-width: none; }
.benefits > li { margin: 0; padding-top: 1.25rem; border-top: 2px solid var(--accent); }
.benefits h3 { margin-bottom: 0.5rem; }
.benefits p { margin: 0 0 0.5rem; }
.benefits .layers { margin: 0; padding-left: 1.25rem; }
.benefits .layers li { margin-bottom: 0.35rem; }

/* FAQ */
.faq { max-width: 48rem; }
.faq details { border-bottom: 1px solid var(--rule); }
.faq details:first-of-type { border-top: 1px solid var(--rule); }
.faq summary {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  min-height: 52px; padding-block: 0.75rem; cursor: pointer; list-style: none;
  font-family: var(--font-serif); font-weight: 400; font-size: 1.0625rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; flex: none; font-family: var(--font-sans); font-weight: 500; font-size: 1.5rem; line-height: 1;
  color: var(--accent);
}
.faq details[open] summary::after { content: "\2212"; }
.faq details > p { margin-bottom: 1.25rem; }

/* Footer */
.site-footer { border-top: 1px solid var(--rule); padding-block: 2rem 2.5rem; font-size: 0.9375rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 1rem 2.5rem; justify-content: space-between; align-items: flex-start; }
.site-footer p { margin: 0 0 0.35rem; }
.site-footer .muted { color: var(--muted); }

/* Inner pages */
.page { padding-block: clamp(2rem, 6vw, 3.5rem) clamp(2.5rem, 7vw, 4rem); }
.narrow { max-width: 38rem; }
.wrap.narrow { max-width: calc(38rem + 2 * var(--gutter)); }
.page h1 { font-size: clamp(1.75rem, 4vw, 2.25rem); margin-bottom: 0.75rem; }
.lede-small { font-size: 1.0625rem; }
.aside { margin-top: 2.5rem; color: var(--muted); }
.link-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.5rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-head h1 { margin: 0; }

/* Forms */
form { margin-top: 1.5rem; }
.field { margin: 0 0 1.75rem; padding: 0; border: 0; min-width: 0; }
.field > label, .field > legend, .field-group > legend { display: block; font-weight: 600; margin-bottom: 0.35rem; padding: 0; }
.field-group { border: 0; padding: 0; margin: 0 0 1.75rem; }
.field-group > legend { font-size: 1.125rem; margin-bottom: 1rem; }
.hint { color: var(--muted); margin: 0 0 0.5rem; font-size: 0.875rem; }
.input {
  display: block; width: 100%; max-width: 32rem; min-height: 48px;
  padding: 0.6rem 0.75rem; font: inherit; font-size: 1rem; color: var(--text);
  background: var(--surface); border: 2px solid var(--field-border); border-radius: var(--radius);
}
textarea.input { min-height: 8rem; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.9375rem; }
select.input { appearance: auto; }
.input-short { max-width: 14rem; }
.input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.field-error .input, .field-error input[type="file"] { border-color: var(--error); }
.field-error { border-left: 4px solid var(--error); padding-left: 1rem; }
.error-message { color: var(--error); font-weight: 600; margin: 0 0 0.5rem; font-size: 0.9375rem; }
.count { color: var(--muted); font-size: 0.875rem; margin: 0.4rem 0 0; }
.count-over { color: var(--error); font-weight: 600; }
.guidance { border-left: 4px solid var(--accent); padding: 0.25rem 0 0.25rem 1rem; margin: 0 0 1.5rem; }
.reveal-wrap { display: flex; gap: 0.5rem; align-items: stretch; max-width: 32rem; }
.reveal-wrap .input { flex: 1; }
.reveal { min-width: 4.5rem; padding-inline: 0.75rem; font-family: var(--font-sans); font-weight: 500; font-size: 0.9375rem; color: var(--text); background: transparent; border: 2px solid var(--field-border); border-radius: var(--radius); cursor: pointer; }
.reveal[hidden] { display: none; }
.choices { display: grid; gap: 0.6rem; }
.choice { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-bottom: 0; }
.field.choice { margin-bottom: 1.75rem; }
.choice input { width: 24px; height: 24px; margin: 0; accent-color: var(--accent); flex: none; }
.choice label { font-weight: 400; margin: 0; cursor: pointer; }
.choice-hint { flex-basis: 100%; padding-left: calc(24px + 0.6rem); margin: 0; }
input[type="file"] { font: inherit; font-size: 1rem; max-width: 100%; }
input[type="file"]::file-selector-button { font-family: var(--font-sans); font-weight: 500; min-height: 44px; margin-right: 0.75rem; padding: 0 1rem; border: 2px solid var(--field-border); border-radius: var(--radius); background: var(--surface); color: var(--text); cursor: pointer; }
.photo-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.5rem; margin-top: 2rem; }
.form-section { font-size: 1.375rem; margin-top: 2.5rem; }
.preview { margin: 0 0 1.75rem; padding: 1rem 1.25rem; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); }
.preview-label { font-family: var(--font-sans); font-weight: 600; font-size: 0.8125rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 0 0 0.25rem; }
.byline { margin: 0; font-weight: 600; }

.btn-secondary { background: transparent; color: var(--text); border: 2px solid var(--text); }
.btn-secondary:hover { background: var(--surface); }
.btn-danger { background: transparent; color: var(--error); border: 2px solid var(--error); }
.btn-danger:hover { background: var(--surface); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.link-button { font: inherit; font-family: var(--font-sans); font-weight: 500; font-size: 0.9375rem; color: inherit; background: none; border: 0; padding: 0; min-height: 44px; text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer; }
.site-nav .link-button { text-decoration: none; }
.site-nav .link-button:hover { text-decoration: underline; }
.inline-form { margin: 0; display: inline; }

.error-summary { border: 3px solid var(--error); border-radius: var(--radius); padding: 1rem 1.25rem; margin: 1rem 0 1.5rem; background: var(--surface); }
.error-summary h2 { font-size: 1.125rem; margin-bottom: 0.5rem; }
.error-summary ul { margin: 0; padding-left: 1.1rem; }
.error-summary a { color: var(--error); font-weight: 600; }
.notice { border-left: 5px solid var(--accent); background: var(--surface); padding: 0.9rem 1.1rem; margin: 1rem 0 1.5rem; border-radius: 0 var(--radius) var(--radius) 0; }
.notice-success { border-left-color: var(--success); }
.notice-problem { border-left-color: var(--error); }
.divider { display: flex; align-items: center; gap: 1rem; color: var(--muted); margin: 2rem 0 1.25rem; max-width: 32rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }
.passkey-block[hidden], [data-passkey-register][hidden], [data-passkey-signin][hidden] { display: none; }

/* Avatars: navy initial on coral, 4.9:1 */
.avatar { border-radius: 50%; object-fit: cover; flex: none; }
.avatar-initials { display: inline-grid; place-items: center; background: var(--coral); color: var(--navy); font-family: var(--font-sans); font-weight: 600; }
.avatar-40 { width: 40px; height: 40px; font-size: 1rem; }
.avatar-64 { width: 64px; height: 64px; font-size: 1.5rem; }
.avatar-72 { width: 72px; height: 72px; font-size: 1.75rem; }

/* Admin */
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); max-width: none; }
.card { margin: 0; padding: 1.25rem; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
.card-title { font-size: 1.125rem; margin-bottom: 0.75rem; }
.card-title a { text-decoration-thickness: 1px; }
.facts { margin: 0; display: grid; gap: 0.35rem; font-size: 0.9375rem; }
.facts div { display: grid; grid-template-columns: 7.5rem 1fr; gap: 0.75rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts-stacked { margin-bottom: 2rem; padding: 1.25rem; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
.status { display: inline-flex; align-items: center; gap: 0.45rem; }
.status .dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--muted); flex: none; }
.status-active .dot { background: var(--success); }
.status-invited .dot, .status-ending .dot { background: var(--accent); }
.status-expired .dot, .status-removed .dot { background: var(--error); }
.action-block { border-top: 1px solid var(--rule); padding-top: 1.5rem; margin-top: 1.5rem; }
.action-block h2 { font-size: 1.125rem; }
.action-block form { margin-top: 0.75rem; }
.todo { padding-left: 1.25rem; }
.todo li { margin-bottom: 0.6rem; }
.audit { list-style: none; padding: 0; max-width: none; }
.audit li { display: grid; grid-template-columns: minmax(9rem, 12rem) 1fr; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--rule); font-size: 0.9375rem; }
.audit time { color: var(--muted); }
.steps { padding-left: 1.25rem; }
.steps > li { margin-bottom: 1.5rem; }
.setup-key code, .codes code { font-size: 1.0625rem; letter-spacing: 0.05em; overflow-wrap: anywhere; }
.codes { columns: 2; list-style: none; padding: 0; }
@media (max-width: 30rem) { .audit li { grid-template-columns: 1fr; gap: 0.15rem; } }
.footer-name { font-family: var(--font-serif); font-weight: 600; }

.muted { color: var(--muted); }

/* Smaller screens: tighter menu, slightly smaller type.
   Form fields stay at 16px so phones don't zoom in when they're focused. */
@media (max-width: 48rem) {
  body { font-size: 0.9375rem; }
  .site-header .wrap { padding-block: 1rem; }
  .brand { font-size: 1.125rem; gap: 0.5rem; }
  .logo { width: 2rem; }
  .site-nav ul { gap: 0.25rem 1.25rem; }
  .site-nav a, .site-nav .link-button { font-size: 0.8125rem; }
  .theme-toggle { width: 40px; height: 40px; }
  .eyebrow { font-size: 0.75rem; }
  .hero .lede, .lede-small { font-size: 1rem; }
  .btn, .text-link { font-size: 0.875rem; }
  .faq summary { font-size: 1rem; }
  .hint, .count { font-size: 0.8125rem; }
  .site-footer { font-size: 0.875rem; }
}
@media (max-width: 30rem) {
  .site-nav ul { gap: 0.25rem 0.875rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- Milestone 2: feed, reading pages, library ---------- */
.small { font-size: 0.9375rem; }
.empty { padding: 2rem 1.5rem; border: 1px dashed var(--rule); border-radius: var(--radius); }
.empty-title { font-family: var(--font-serif); font-weight: 600; font-size: 1.25rem; margin-bottom: 0.25rem; }
.clamp-2, .clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }
.clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }

.feed { max-width: 44rem; }
.posts { display: grid; gap: 1.25rem; margin-top: 2rem; }
.post { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.25rem 1.5rem; }
.post-pinned { border-left: 4px solid var(--accent); }
.pin-label { font-family: var(--font-sans); font-weight: 600; font-size: 0.875rem; color: var(--accent); margin: 0 0 0.25rem; }
.post-kind { margin-bottom: 0.5rem; }
.post-title { font-size: 1.375rem; margin-bottom: 0.5rem; }
.post-title a { text-decoration-thickness: 1px; }
.post-body { margin-bottom: 0.75rem; overflow-wrap: anywhere; }
.post-body a { color: inherit; }
.byline-meta { margin: 0; color: var(--muted); font-size: 0.9375rem; }
.byline-meta .byline { color: var(--text); font-weight: 600; }

.digest-list { list-style: none; padding: 0; max-width: 44rem; }
.digest-list li { padding: 1.5rem 0; border-bottom: 1px solid var(--rule); margin: 0; }
.digest-list .eyebrow { margin-bottom: 0.35rem; }
.digest-list h2 { font-size: 1.5rem; margin-bottom: 0.4rem; }

/* Long-form reading: digests and the handbook */
.prose { max-width: 42rem; }
.prose h1 { font-size: clamp(2rem, 5vw, 2.75rem); }
/* Sections (h2) are clearly a level above sub-headings (h3): a divider, a coral marker,
   a section number and more space. Sub-headings use the sans face at a smaller size. */
.digest-body, .handbook-body { counter-reset: section; }
.prose h2 { font-size: 1.875rem; margin-top: 3.5rem; scroll-margin-top: 1rem; }
.prose h2.section-heading {
  position: relative; flex-wrap: wrap; counter-increment: section;
  padding-top: 1.5rem; border-top: 1px solid var(--rule);
}
.prose h2.section-heading::before {
  content: ""; position: absolute; top: -2px; left: 0; width: 3rem; height: 3px; background: var(--accent);
}
.prose h2.section-heading::after {
  content: counter(section, decimal-leading-zero) / "";
  order: -1; flex-basis: 100%; margin-bottom: 0.35rem;
  font-family: var(--font-sans); font-weight: 600; font-size: 0.875rem; letter-spacing: 0.14em; color: var(--accent);
}
.prose h3 { font-family: var(--font-sans); font-weight: 600; font-size: 1.0625rem; line-height: 1.4; margin-top: 2rem; margin-bottom: 0.4rem; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin-bottom: 0.5rem; }
.prose strong { font-weight: 600; }
.prose blockquote { margin: 1.5rem 0; padding-left: 1rem; border-left: 4px solid var(--accent); }
.prose img { height: auto; border-radius: var(--radius); margin: 1.5rem 0; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }
.prose :target { scroll-margin-top: 1rem; }
.section-heading { display: flex; align-items: baseline; gap: 0.5rem; }
.anchor-link {
  font-family: var(--font-sans); font-weight: 500; font-size: 1rem; color: var(--muted); text-decoration: none;
  min-width: 24px; min-height: 24px; display: inline-grid; place-items: center; opacity: 0.75;
}
/* The section link stays beside every section, including once saving and highlighting arrive (19 Oct). */
.section-heading:hover .anchor-link, .anchor-link:focus-visible, .anchor-link:hover { opacity: 1; color: var(--accent); }
.anchor-link[data-copied]::after { content: "Link copied"; margin-left: 0.4rem; font-size: 0.875rem; }
.toc { margin: 1.5rem 0 2rem; padding: 1rem 1.25rem; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
.toc-title { font-family: var(--font-sans); font-weight: 600; font-size: 0.875rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 0 0 0.5rem; }
.prose .toc-title { margin-top: 0; font-size: 0.875rem; }
.toc ol { margin: 0; padding-left: 1.25rem; }
.toc li { margin-bottom: 0.3rem; }
.handbook-time { margin-top: -0.5rem; }
.back { margin-top: 3rem; }

/* Library */
.filters { margin: 1.5rem 0 2.5rem; }
.search-row { display: flex; gap: 0.5rem; max-width: 36rem; }
.search-row .input { flex: 1; }
.filter-row { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; align-items: flex-end; }
.filter-row .field { margin-bottom: 0; min-width: 12rem; }
.filter-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; min-height: 48px; }
.section-label { font-size: 1.25rem; margin-bottom: 1rem; }
.theme-grid { list-style: none; padding: 0; margin: 0 0 1.5rem; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); max-width: none; }
.theme-grid li { margin: 0; }
.theme-card { display: grid; gap: 0.25rem; padding: 1.25rem; min-height: 6rem; background: var(--surface); border: 1px solid var(--rule); border-top: 3px solid var(--accent); border-radius: var(--radius); text-decoration: none; }
.theme-card:hover { border-color: var(--accent); }
.theme-name { font-family: var(--font-serif); font-weight: 600; font-size: 1.25rem; }
.resource-meta { font-family: var(--font-sans); font-weight: 500; color: var(--muted); font-size: 0.9375rem; margin-bottom: 0.5rem; }
.resource-themes { font-size: 1rem; }

/* Admin lists and editors */
.admin-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.75rem; max-width: 48rem; }
.admin-list > li { margin: 0; }
.admin-list.compact > li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem 1rem; padding: 0.5rem 0; border-bottom: 1px solid var(--rule); }
.admin-list .card-title { font-size: 1.125rem; margin-bottom: 0.25rem; }
.file-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem 1rem; }
.file-row p { margin: 0; }
textarea.input.textarea { min-height: 7rem; font-family: var(--font-sans); font-size: 1.0625rem; line-height: 1.6; resize: vertical; max-width: 44rem; }
textarea.input.textarea-mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.9375rem; }
.preview-pane { margin-top: 2.5rem; padding-top: 1rem; border-top: 2px dashed var(--rule); }
.preview-pane > h2.notice { font-family: var(--font-sans); font-size: 1rem; font-weight: 400; }
.rename-row { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: center; width: 100%; margin: 0; }
.rename-row .input { flex: 1; min-width: 12rem; }
.add-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; margin-top: 1rem; }
.add-row .field { margin: 0; flex: 1; min-width: 14rem; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.9em; }
.checks { margin: 1.5rem 0 2rem; padding: 1.25rem; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
.checks h2 { font-size: 1.25rem; }
.check-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.check-list li { display: flex; gap: 0.6rem; align-items: baseline; margin-bottom: 0.5rem; }
.check-list .dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; flex: none; transform: translateY(-0.1rem); }
.check-ok .dot { background: var(--success); }
.check-warn .dot { background: var(--error); }
.admin-sections { margin: -1rem 0 2rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--rule); }
.admin-sections ul { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; list-style: none; padding: 0; margin: 0; max-width: none; }
.admin-sections li { margin: 0; }
.admin-sections a { display: inline-flex; align-items: center; min-height: 44px; font-family: var(--font-sans); font-weight: 500; font-size: 0.9375rem; text-decoration: none; }
.admin-sections a:hover, .admin-sections a[aria-current="page"] { text-decoration: underline; text-underline-offset: 0.35em; text-decoration-thickness: 2px; }
.luma-frame { margin: 2rem 0 1rem; max-width: 48rem; border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; background: #fff; }
.luma-frame iframe { display: block; width: 100%; height: 640px; border: 0; }
@media (max-width: 30rem) { .luma-frame iframe { height: 560px; } }

/* Members' header: icon link and Profile menu */
.icon { width: 22px; height: 22px; }
.icon-link { justify-content: center; min-width: 44px; }
.with-icon { display: inline-flex; align-items: center; gap: 0.5rem; }
.with-icon .icon { width: 18px; height: 18px; }
.menu { position: relative; }
.menu > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 0.35rem; min-height: 44px;
  font-family: var(--font-sans); font-weight: 500; font-size: 0.9375rem;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: ""; width: 0.45rem; height: 0.45rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-0.15rem) rotate(45deg); }
.menu[open] > summary::after { transform: translateY(0.1rem) rotate(-135deg); }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 0.25rem); z-index: 20; min-width: 12rem; list-style: none; margin: 0; padding: 0.4rem;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(17, 20, 42, 0.18);
}
.site-nav .menu-list { display: block; }
.menu-list li { margin: 0; }
.menu-list a, .menu-list .link-button { display: flex; width: 100%; min-height: 44px; padding: 0 0.75rem; align-items: center; border-radius: 4px; text-decoration: none; }
.menu-list a:hover, .menu-list .link-button:hover { background: var(--bg); text-decoration: none; }
.menu-list .inline-form { display: block; }
.library-digests { margin-bottom: 2.5rem; }
.digest-cards .card-title { font-size: 1.25rem; }
.aside-first { margin-top: 1.25rem; }

.external-mark { font-family: var(--font-sans); }

.menu > summary.icon-link { justify-content: center; min-width: 44px; }
.menu > summary.icon-link::after { display: none; }
.saved-section { margin: 1rem 0 2.5rem; scroll-margin-top: 1rem; }
.saved-section h2 { gap: 0.5rem; }
.saved-section h2 .icon { width: 22px; height: 22px; }

.menu-left .menu-list { left: 0; right: auto; }
.admin-sections .menu > summary { font-family: var(--font-sans); font-weight: 500; font-size: 0.9375rem; }
.admin-sections .menu-list { display: block; min-width: 11rem; }
.admin-sections .menu-list li { display: block; }
.admin-sections .menu-list a { display: flex; width: 100%; padding: 0 0.75rem; }

/* Admin only: Members' space | Admin switch. Coral in admin so it's clear which area you're in. */
.area-switch { font-family: var(--font-sans); font-size: 0.875rem; border-bottom: 1px solid var(--rule); background: var(--surface); }
.area-switch .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.25rem 1rem; padding-block: 0.25rem; }
.area-label { margin: 0; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; font-size: 0.75rem; }
.area-switch ul { display: flex; gap: 0.25rem; list-style: none; margin: 0; padding: 0.2rem; border: 1px solid var(--rule); border-radius: 999px; }
.area-switch li { margin: 0; }
.area-switch a { display: inline-flex; align-items: center; min-height: 32px; padding: 0 0.9rem; border-radius: 999px; text-decoration: none; font-weight: 500; color: inherit; }
.area-switch a:hover { text-decoration: underline; }
.area-switch a[aria-current="page"] { background: var(--text); color: var(--bg); text-decoration: none; }
.area-switch-admin { background: var(--coral); color: var(--navy); border-bottom-color: var(--coral); }
.area-switch-admin ul { border-color: rgba(31, 36, 68, 0.35); }
.area-switch-admin a[aria-current="page"] { background: var(--navy); color: var(--cream); }
.area-switch-admin a:focus-visible { outline-color: var(--navy); }

/* Profile tabs (links, one page each) */
.tabs { margin: 0 0 1.75rem; border-bottom: 1px solid var(--rule); }
.tabs ul { display: flex; flex-wrap: wrap; gap: 0 1.5rem; list-style: none; margin: 0; padding: 0; max-width: none; }
.tabs li { margin: 0; }
.tabs a { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 44px; font-family: var(--font-sans); font-weight: 500; font-size: 0.9375rem; text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a .icon { width: 18px; height: 18px; }
.tabs a:hover { border-bottom-color: var(--rule); }
.tabs a[aria-current="page"] { border-bottom-color: var(--accent); font-weight: 600; }
.tab-title { font-size: 1.375rem; margin-bottom: 0.25rem; }
