/**
 * MARKHEINZ.COM — Design System v2
 * Desaturated Phosphor Green + Charcoal | Fraunces + Inter + IBM Plex Mono
 * System-aware light/dark mode
 */

/* ── Fonts ───────────────────────────────────────────────────────────── */

@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter-var.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Fraunces';
  src: url('/fonts/fraunces-var.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ── Reset ───────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; line-height: 1.5; scroll-behavior: smooth; }
body { min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; margin-bottom: var(--space-4xl); }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }

/* ── Tokens (Light Default) ──────────────────────────────────────────── */

:root {
  /* Brand palette */
  --mh-sage: #5a8a5a;
  --mh-sage-dark: #487048;
  --mh-sage-light: #7ac47a;
  --mh-charcoal: #1a1a1a;
  --mh-charcoal-light: #2d2d2d;
  --mh-offwhite: #f5f5f0;
  --mh-muted: #6a6a62;
  --mh-muted-light: #9a9a92;
  --mh-border-light: #e0e0d8;
  --mh-border-dark: #3a3a3a;

  /* Semantic tokens — light mode defaults */
  --color-bg: var(--mh-offwhite);
  --color-bg-alt: #ffffff;
  --color-bg-dark: var(--mh-charcoal);
  --color-text: var(--mh-charcoal-light);
  --color-text-muted: var(--mh-muted);
  --color-text-inverse: var(--mh-offwhite);
  --color-accent: var(--mh-sage);
  --color-accent-dark: var(--mh-sage-dark);
  --color-accent-light: var(--mh-sage-light);
  --color-border: var(--mh-border-light);
  --color-success: #38a169;
  --color-error: #c53030;
  --color-warning: #b37700;
  --color-overlay: rgba(0, 0, 0, 0.6);

  /* Typography */
  --font-heading: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  /* Spacing (8-point grid) */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;

  /* Layout */
  --max-width: 1100px;
  --max-width-narrow: 680px;
  --border-radius: 4px;
  --border-radius-sm: 2px;
  --transition: 0.2s ease;

  /* Shadows */
  --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-card-hover: 0 8px 24px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.05);
  --shadow-btn: 0 1px 2px rgba(0,0,0,0.06);

  /* Focus */
  --focus-ring: 2px solid var(--color-accent);
  --focus-offset: 2px;

  /* Color scheme hint for form controls */
  color-scheme: light;
}

/* ── Dark Mode (System) ──────────────────────────────────────────────── */

@media (prefers-color-scheme: dark) {
  :root:not(.light-mode) {
    --color-bg: var(--mh-charcoal);
    --color-bg-alt: var(--mh-charcoal-light);
    --color-bg-dark: #111111;
    --color-text: var(--mh-offwhite);
    --color-text-muted: var(--mh-muted-light);
    --color-text-inverse: var(--mh-charcoal);
    --color-accent: var(--mh-sage-light);
    --color-accent-dark: var(--mh-sage);
    --color-accent-light: #8fd48f;
    --color-border: var(--mh-border-dark);
    --color-error: #fc8181;
    --color-warning: #ecc94b;
    --color-overlay: rgba(0, 0, 0, 0.8);

    --shadow-card: 0 1px 3px rgba(0,0,0,0.2), 0 2px 8px rgba(0,0,0,0.15);
    --shadow-card-hover: 0 8px 24px rgba(0,0,0,0.3), 0 2px 6px rgba(0,0,0,0.15);

    color-scheme: dark;
  }
}

/* ── Manual Dark Override ────────────────────────────────────────────── */

:root.dark-mode {
  --color-bg: var(--mh-charcoal);
  --color-bg-alt: var(--mh-charcoal-light);
  --color-bg-dark: #111111;
  --color-text: var(--mh-offwhite);
  --color-text-muted: var(--mh-muted-light);
  --color-text-inverse: var(--mh-charcoal);
  --color-accent: var(--mh-sage-light);
  --color-accent-dark: var(--mh-sage);
  --color-accent-light: #8fd48f;
  --color-border: var(--mh-border-dark);
  --color-error: #fc8181;
  --color-warning: #ecc94b;
  --color-overlay: rgba(0, 0, 0, 0.8);

  --shadow-card: 0 1px 3px rgba(0,0,0,0.2), 0 2px 8px rgba(0,0,0,0.15);
  --shadow-card-hover: 0 8px 24px rgba(0,0,0,0.3), 0 2px 6px rgba(0,0,0,0.15);

  color-scheme: dark;
}

/* ── Manual Light Override ───────────────────────────────────────────── */

:root.light-mode {
  --color-bg: var(--mh-offwhite);
  --color-bg-alt: #ffffff;
  --color-bg-dark: var(--mh-charcoal);
  --color-text: var(--mh-charcoal-light);
  --color-text-muted: var(--mh-muted);
  --color-text-inverse: var(--mh-offwhite);
  --color-accent: var(--mh-sage);
  --color-accent-dark: var(--mh-sage-dark);
  --color-accent-light: var(--mh-sage-light);
  --color-border: var(--mh-border-light);
  --color-error: #c53030;
  --color-warning: #b37700;
  --color-overlay: rgba(0, 0, 0, 0.6);

  --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-card-hover: 0 8px 24px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.05);

  color-scheme: light;
}

/* Smooth theme transition (added by JS after load to prevent flash) */
body.theme-transition,
body.theme-transition *,
body.theme-transition *::before,
body.theme-transition *::after {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}

/* ── Skip Link ───────────────────────────────────────────────────────── */

.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  background: var(--color-accent);
  color: var(--color-text-inverse);
  padding: 8px 16px;
  border-radius: var(--border-radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 200;
  text-decoration: none;
}
.skip-link:focus { top: 8px; }

/* ── Focus Rings ─────────────────────────────────────────────────────── */

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

/* ── Typography ──────────────────────────────────────────────────────── */

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='discrete' tableValues='0 0 0 0.08 0.08 0.12 0 0 0 0'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' fill='black'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

h1 { font-size: clamp(2rem, 4vw, 3.25rem); margin-bottom: var(--space-lg); }
h2 { font-size: 2rem; margin-bottom: var(--space-md); }
h3 { font-size: 1.35rem; margin-bottom: var(--space-sm); }
h4 { font-size: 1.125rem; margin-bottom: var(--space-sm); }

p { margin-bottom: var(--space-md); }
p:last-child { margin-bottom: 0; }

small, .text-sm { font-size: 0.875rem; }
.text-muted { color: var(--color-text-muted); }
.text-accent { color: var(--color-accent); }

a:not(.btn) {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--transition);
}

a:not(.btn):hover {
  color: var(--color-accent-dark);
}

code, .font-mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* ── Layout ──────────────────────────────────────────────────────────── */

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.container-narrow {
  max-width: var(--max-width-narrow);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.section {
  padding: var(--space-3xl) 0;
}

.section-alt {
  background: var(--color-bg-alt);
}

.section-dark {
  background: var(--color-bg-dark);
  color: var(--color-text-inverse);
}

.section-dark h1,
.section-dark h2,
.section-dark h3,
.section-dark h4 {
  color: var(--color-text-inverse);
}

.section-dark a:not(.btn) {
  color: var(--color-accent-light);
}

/* ── Site Header ─────────────────────────────────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(245, 245, 240, 0.85);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-md) 0;
  transition: box-shadow 0.3s ease;
}

.site-header.scrolled {
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
}

.site-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.site-title:hover {
  color: var(--color-accent);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.site-nav a {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--color-accent);
}

.theme-toggle {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: var(--space-xs);
  font-size: 1.1rem;
  line-height: 1;
  transition: color var(--transition);
}

.theme-toggle:hover {
  color: var(--color-accent);
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  padding: var(--space-xs);
  font-size: 1.5rem;
  line-height: 1;
}

/* ── Site Footer ─────────────────────────────────────────────────────── */

.site-footer {
  background: var(--mh-charcoal);
  color: var(--mh-offwhite);
  padding: var(--space-3xl) 0 var(--space-xl);
  position: relative;
  box-shadow: inset 0 1px 0 0 var(--mh-sage), inset 0 40px 80px -40px rgba(0, 0, 0, 0.3);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: var(--space-2xl);
  margin-bottom: var(--space-2xl);
}

.footer-brand {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: var(--space-sm);
}

.footer-tagline {
  font-size: 0.9rem;
  color: var(--mh-muted-light);
  line-height: 1.5;
}

.footer-heading {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mh-muted-light);
  margin-bottom: var(--space-md);
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.footer-links a {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--mh-offwhite);
  text-decoration: none;
  transition: color var(--transition);
}

.footer-links a:hover {
  color: var(--color-accent-light);
}

.footer-bottom {
  border-top: 1px solid rgba(90, 138, 90, 0.2);
  padding-top: var(--space-lg);
  font-size: 0.85rem;
  color: var(--mh-muted-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-bottom a {
  color: var(--mh-muted-light);
  text-decoration: none;
}

.footer-bottom a:hover {
  color: var(--color-accent-light);
}

/* ── Cards ───────────────────────────────────────────────────────────── */

.card {
  position: relative;
  overflow: hidden;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: var(--space-lg);
  box-shadow: var(--shadow-card);
  transition: transform var(--transition), box-shadow var(--transition);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.card-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}

.card-body {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--color-text);
}

.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.card-link:hover {
  color: inherit;
}

.card-link .card-title {
  transition: color var(--transition);
}

.card-link:hover .card-title {
  color: var(--color-accent);
}

/* Card with accent top bar */
.card-accent {
  border-top: 3px solid var(--color-accent);
}

/* Card grid layouts */
.card-grid {
  display: grid;
  gap: var(--space-lg);
}

.card-grid-2 { grid-template-columns: repeat(2, 1fr); }
.card-grid-3 { grid-template-columns: repeat(3, 1fr); }

/* Card with hero image */
.card-hero {
  overflow: hidden;
}

.card-hero img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  margin: calc(-1 * var(--space-lg));
  margin-bottom: var(--space-md);
  width: calc(100% + 2 * var(--space-lg));
}

/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.6rem 1.5rem;
  border-radius: var(--border-radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  box-shadow: var(--shadow-btn);
  line-height: 1.4;
}

.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

.btn-primary:hover {
  background: var(--color-accent-dark);
  border-color: var(--color-accent-dark);
}

.btn-outline {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-outline:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.btn-outline-light {
  background: transparent;
  color: var(--color-text-inverse);
  border-color: rgba(255,255,255,0.3);
}

.btn-outline-light:hover {
  border-color: var(--color-accent-light);
  color: var(--color-accent-light);
}

.btn-sm {
  font-size: 0.85rem;
  padding: 0.4rem 1rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Prose (Article Content) ─────────────────────────────────────────── */

.prose {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--color-text);
}

.prose h2 { margin-top: var(--space-2xl); }
.prose h3 { margin-top: var(--space-xl); }

.prose a {
  color: var(--color-accent-dark);
  text-decoration: underline;
}

.prose blockquote {
  border-left: 3px solid var(--color-accent);
  padding-left: var(--space-lg);
  margin: var(--space-xl) 0;
  font-style: italic;
  color: var(--color-text-muted);
}

.prose ul, .prose ol {
  padding-left: var(--space-lg);
  margin-bottom: var(--space-md);
}

.prose li { margin-bottom: var(--space-xs); }

.prose img {
  border-radius: var(--border-radius);
  margin: var(--space-xl) 0;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-2xl) 0;
}

.prose code {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  padding: 0.15em 0.4em;
  border-radius: var(--border-radius-sm);
  font-size: 0.88em;
}

.prose pre {
  background: var(--color-bg-dark);
  color: var(--color-text-inverse);
  padding: var(--space-lg);
  border-radius: var(--border-radius);
  overflow-x: auto;
  margin: var(--space-xl) 0;
}

.prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.9rem;
}

.prose .pull-quote {
  border-left: 3px solid var(--color-accent);
  padding-left: var(--space-lg);
  font-style: italic;
  font-size: 1.15rem;
  margin: var(--space-xl) 0;
  color: var(--color-text);
}

.prose .section-break {
  text-align: center;
  margin: var(--space-2xl) 0;
  color: var(--color-text-muted);
  letter-spacing: 0.5em;
}

/* Tooltips */
dfn[data-tooltip] {
  position: relative;
  cursor: help;
  font-style: normal;
  border-bottom: 1px dotted var(--color-text-muted);
}

dfn[data-tooltip]::before {
  content: attr(data-term);
  position: absolute;
  bottom: 100%;
  left: 0;
  background: var(--color-bg-dark);
  color: var(--mh-muted-light);
  padding: 0.25rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  white-space: nowrap;
  border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s;
  z-index: 10;
}

dfn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 1.5rem);
  left: 0;
  background: var(--color-bg-dark);
  color: var(--mh-offwhite);
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  min-width: 200px;
  max-width: min(340px, calc(100vw - 2rem));
  white-space: normal;
  line-height: 1.5;
  border-radius: var(--border-radius-sm);
  border-bottom-left-radius: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s;
  z-index: 10;
}

dfn[data-tooltip]:hover::before,
dfn[data-tooltip]:hover::after,
dfn[data-tooltip]:focus::before,
dfn[data-tooltip]:focus::after {
  opacity: 1;
  visibility: visible;
}

dfn[data-tooltip]:focus {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

/* Mobile: tap to toggle */
dfn[data-tooltip].tooltip-open::before,
dfn[data-tooltip].tooltip-open::after {
  opacity: 1;
  visibility: visible;
}

/* Flipped: near top of viewport */
dfn[data-tooltip].tooltip-below::before {
  bottom: auto;
  top: 100%;
  border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm);
}
dfn[data-tooltip].tooltip-below::after {
  bottom: auto;
  top: calc(100% + 1.5rem);
  border-radius: var(--border-radius-sm);
  border-top-left-radius: 0;
}

/* Right-aligned: near right edge */
dfn[data-tooltip].tooltip-right::before { left: auto; right: 0; }
dfn[data-tooltip].tooltip-right::after { left: auto; right: 0; }

.prose dfn {
  font-style: normal;
  border-bottom: 1px dotted var(--color-text-muted);
  cursor: help;
}

/* ── Hero Section ────────────────────────────────────────────────────── */

.hero {
  padding: var(--space-4xl) 0 var(--space-3xl);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero h1 {
  font-size: clamp(2.5rem, 5vw, 4rem);
  margin-bottom: var(--space-md);
}

.hero-tagline {
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  color: var(--color-text-muted);
  max-width: 600px;
  margin: 0 auto var(--space-xl);
  line-height: 1.5;
}

.hero-rule {
  width: 60px;
  height: 3px;
  background: var(--color-accent);
  border: none;
  margin: 0 auto;
}

/* ── Page Header ─────────────────────────────────────────────────────── */

.page-header {
  padding: var(--space-2xl) 0;
  border-bottom: none;
  margin-bottom: var(--space-2xl);
  position: relative;
}

.page-header h1 {
  margin-bottom: var(--space-xs);
}

.page-header p {
  color: var(--color-text-muted);
  font-size: 1.05rem;
}

/* ── Notes ───────────────────────────────────────────────────────────── */

.note-card {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.note-card:last-child {
  border-bottom: none;
}

.note-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.note-date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}

.note-content {
  font-size: 0.95rem;
  line-height: 1.6;
}

.note-image {
  width: 100%;
  border-radius: var(--border-radius);
  margin: var(--space-md) 0;
}

.note-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-sm);
  margin: var(--space-md) 0;
}

.note-gallery-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: opacity var(--transition);
}

.note-gallery-image:hover {
  opacity: 0.85;
}

/* Load more */
.load-more {
  text-align: center;
  padding: var(--space-xl) 0;
}

/* Share buttons */
.share-buttons {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

/* ── Admin Bar ───────────────────────────────────────────────────────── */

.admin-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  background: var(--color-bg-alt);
  font-size: 0.85rem;
}

.admin-bar-user {
  color: var(--color-text-muted);
}

.admin-bar-user .email {
  color: var(--color-text);
  font-weight: 500;
}

.admin-bar-actions {
  display: flex;
  gap: var(--space-sm);
}

/* Inline admin controls */
.item-admin {
  display: flex;
  gap: var(--space-sm);
  margin-left: auto;
  padding-left: var(--space-md);
  font-size: 0.85rem;
}

.item-admin a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.item-admin a:hover {
  color: var(--color-accent);
}

.item-admin .admin-delete:hover,
.item-admin .admin-delete-seed:hover {
  color: var(--color-error);
}

/* Auth visibility */
.requires-auth { display: none; }
.authenticated .requires-auth { display: block; }
.authenticated .requires-no-auth { display: none; }

/* ── Modal ───────────────────────────────────────────────────────────── */

.note-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-overlay);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.note-modal.open {
  display: flex;
}

.note-modal-content {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: var(--space-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.note-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.note-modal-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

.note-modal-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.note-modal-close:hover {
  color: var(--color-text);
}

/* ── Forms ───────────────────────────────────────────────────────────── */

.form-group {
  margin-bottom: var(--space-lg);
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-sm);
}

.form-group textarea,
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="url"],
.form-group input[type="date"] {
  width: 100%;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.65rem 0.75rem;
  transition: border-color var(--transition);
}

.form-group textarea {
  min-height: 150px;
  resize: vertical;
}

.form-group textarea:focus,
.form-group input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.form-row {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.form-group-sm {
  flex: 0 0 auto;
  margin-bottom: 0;
}

.form-group-sm label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-sm);
}

.form-group-sm select,
.form-group-sm input[type="number"],
.form-group-sm input[type="date"] {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.5rem;
}

.form-group-sm select { min-width: 120px; }
.form-group-sm input[type="number"] { width: 70px; }

.form-group-sm select:focus,
.form-group-sm input[type="number"]:focus,
.form-group-sm input[type="date"]:focus {
  outline: none;
  border-color: var(--color-accent);
}

.form-actions {
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

.status-msg { font-size: 0.9rem; }
.status-msg.success { color: var(--color-success); }
.status-msg.error { color: var(--color-error); }

.char-count {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-align: right;
  margin-top: var(--space-xs);
}
.char-count.warn { color: var(--color-warning); }
.char-count.over { color: var(--color-error); }

.required-mark { color: var(--color-error); }

/* Tags */
.tags-display {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: var(--space-sm);
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--color-bg-alt);
}

.tag-chip-remove {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0 2px;
  line-height: 1;
}
.tag-chip-remove:hover { color: var(--color-error); }

/* Formatting toolbar */
.formatting-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  padding: var(--space-sm) 0;
  border-top: 1px solid var(--color-border);
}

.fmt-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  color: var(--color-text-muted);
  font-size: 0.8rem;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  line-height: 1;
  min-width: 2rem;
  text-align: center;
  transition: all var(--transition);
}

.fmt-btn:hover,
.fmt-btn:focus {
  color: var(--color-accent);
  border-color: var(--color-accent);
  outline: none;
}

.fmt-btn:active { background: rgba(90, 138, 90, 0.1); }
.fmt-btn:disabled { opacity: 0.3; cursor: default; }

/* Markup preview */
.markup-preview {
  min-height: 150px;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 0.95rem;
  line-height: 1.6;
  overflow-y: auto;
  max-height: 400px;
}

.markup-preview p { margin-bottom: 0.75rem; }
.markup-preview p:last-child { margin-bottom: 0; }
.markup-preview hr { text-align: center; margin: 1.5rem 0; border: none; color: var(--color-text-muted); letter-spacing: 0.5em; }
.markup-preview hr::after { content: '\00B7 \00B7 \00B7'; }
.markup-preview .pull-quote { border-left: 3px solid var(--color-accent); padding-left: 1rem; font-style: italic; }
.markup-preview dfn { border-bottom: 1px dotted var(--color-text-muted); cursor: help; }
.markup-preview .article-image img { max-width: 100%; }

/* Gallery admin preview */
.gallery-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--space-sm);
}

.gallery-thumb {
  position: relative;
  width: 200px;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.gallery-thumb img {
  width: 100%;
  height: 80px;
  object-fit: cover;
}

.gallery-meta-input {
  display: block;
  width: 100%;
  font-size: 0.65rem;
  color: var(--color-text);
  background: var(--color-bg-alt);
  border: none;
  border-top: 1px solid var(--color-border);
  padding: 3px 5px;
}

.gallery-meta-input::placeholder { color: var(--color-text-muted); opacity: 0.5; }
.gallery-meta-input:focus { outline: 1px solid var(--color-accent); }

.gallery-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  background: rgba(0, 0, 0, 0.7);
  color: var(--color-error);
  border: 1px solid var(--color-error);
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-remove:hover { background: var(--color-error); color: #fff; }

/* Slug input */
.slug-input-row {
  display: flex;
  align-items: center;
  gap: 0;
}

.slug-prefix {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  padding: 0.65rem 0;
  padding-right: var(--space-xs);
  white-space: nowrap;
}

.slug-auto-badge {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-left: var(--space-sm);
}
.slug-auto-badge.manual { color: var(--color-warning); }

/* Sticky submit for work modal */
.work-form-actions {
  position: sticky;
  bottom: -1.5rem;
  background: var(--color-bg);
  margin: 0 calc(-1 * var(--space-lg));
  padding: var(--space-md) var(--space-lg) var(--space-lg);
  border-top: 1px solid var(--color-border);
  z-index: 2;
}

/* ── Lightbox ────────────────────────────────────────────────────────── */

.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9998;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  cursor: pointer;
}

.lightbox-overlay.open { opacity: 1; }

.lightbox-content {
  position: relative;
  z-index: 2;
  max-width: 85vw;
  cursor: default;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-content img {
  max-width: 85vw;
  max-height: 70vh;
  object-fit: contain;
  border-radius: var(--border-radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  transition: opacity 0.25s ease;
}

.lightbox-close {
  position: fixed;
  top: 20px;
  right: 24px;
  font-size: 1.3rem;
  color: rgba(255,255,255,0.7);
  background: none;
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  z-index: 9999;
  transition: color var(--transition);
}
.lightbox-close:hover { color: #fff; }

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2.5rem;
  color: rgba(255,255,255,0.5);
  background: none;
  border: none;
  padding: 16px;
  cursor: pointer;
  z-index: 9999;
  transition: color var(--transition);
}
.lightbox-nav:hover { color: #fff; }

.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }

.lightbox-caption {
  text-align: center;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.8);
  line-height: 1.6;
  margin-top: var(--space-md);
  max-width: 70vw;
}

.lightbox-counter {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.5);
  margin-top: var(--space-sm);
}

/* ── Contact Form ────────────────────────────────────────────────────── */

.contact-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.contact-overlay.open { display: flex; }

.contact-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
}

.contact-card-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.contact-card-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.contact-card-body {
  padding: var(--space-lg);
}

.contact-bridge {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin: 0 0 var(--space-lg) 0;
  line-height: 1.6;
}

.contact-form .form-group { margin-bottom: var(--space-md); }
.contact-form .form-group label {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
}

.contact-form .form-group input,
.contact-form .form-group textarea {
  width: 100%;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.6rem 0.75rem;
  transition: border-color var(--transition);
}

.contact-form .form-group input:focus,
.contact-form .form-group textarea:focus {
  outline: none;
  border-color: var(--color-accent);
}

.contact-form .form-group textarea { min-height: 140px; resize: vertical; }

.contact-form .form-group .field-error {
  font-size: 0.85rem;
  color: var(--color-error);
  margin-top: var(--space-xs);
}

.contact-char-count {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-align: right;
  margin-top: var(--space-xs);
  opacity: 0.6;
}

.contact-form-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.contact-status { font-size: 0.9rem; min-height: 1.5em; }
.contact-status.success { color: var(--color-success); }
.contact-status.error { color: var(--color-error); }

.contact-honeypot { position: absolute; left: -9999px; top: -9999px; }

.contact-card-footer {
  padding: var(--space-sm) var(--space-lg);
  border-top: 1px solid var(--color-border);
  text-align: right;
}

.contact-close-btn {
  background: none;
  border: none;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  cursor: pointer;
}
.contact-close-btn:hover { color: var(--color-text); }

/* ── Scripture Modal (Seeds) ─────────────────────────────────────────── */

.scripture-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  z-index: 1001;
  align-items: center;
  justify-content: center;
}

.scripture-modal.open { display: flex; }

.scripture-modal-content {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: var(--space-xl);
  max-width: 320px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.scripture-modal-content h3 {
  font-size: 1.1rem;
  margin-bottom: var(--space-lg);
}

.scripture-modal-content .btn {
  display: block;
  width: 100%;
  margin-bottom: var(--space-sm);
  text-align: center;
}

/* ── Utilities ───────────────────────────────────────────────────────── */

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

.initially-hidden { display: none; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-xl { margin-top: var(--space-xl); }
.mb-xl { margin-bottom: var(--space-xl); }

/* ── Visual Refinements ──────────────────────────────────────────────── */

/* Grain texture — baked into body background, never overlaps text */


/* Hero: radial sage glow behind content */
.hero::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 400px;
  background: radial-gradient(ellipse at center, rgba(90, 138, 90, 0.07) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.hero .container-narrow {
  position: relative;
  z-index: 1;
}

/* Hero: animated rule */
.hero-rule {
  transform-origin: center;
  animation: expandRule 1.2s ease-out 0.3s both;
}

@keyframes expandRule {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* Hero: text fade-in */
.hero h1 {
  animation: fadeInUp 0.6s ease-out both;
}

.hero-tagline {
  animation: fadeInUp 0.6s ease-out 0.15s both;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Page header: gradient accent rule */
.page-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent 0%, var(--color-accent) 15%, var(--color-accent) 85%, transparent 100%);
  transform-origin: left;
  animation: expandRule 1.2s ease-out 0.3s both;
}

/* Card: accent bar reveal on hover */
.card-link::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  z-index: 1;
}

.card-link:hover::before {
  transform: scaleX(1);
}

/* Cards with static accent bar don't need the reveal */
.card-accent.card-link::before {
  display: none;
}

/* Section flow: subtle sage divider between sections */
.section + .section::before {
  content: '';
  display: block;
  width: 40px;
  height: 2px;
  background: var(--color-accent);
  margin: 0 auto;
  opacity: 0.4;
  position: relative;
  top: calc(-1 * var(--space-3xl));
}

.section-alt {
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.section-alt + .section::before {
  display: none;
}

/* Scroll reveal */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.card-grid .reveal:nth-child(1) { transition-delay: 0s; }
.card-grid .reveal:nth-child(2) { transition-delay: 0.1s; }
.card-grid .reveal:nth-child(3) { transition-delay: 0.2s; }
.card-grid .reveal:nth-child(4) { transition-delay: 0.3s; }

/* Dark mode refinements */
@media (prefers-color-scheme: dark) {
  :root:not(.light-mode) body { background-image: none; }
  :root:not(.light-mode) .hero::before {
    background: radial-gradient(ellipse at center, rgba(122, 196, 122, 0.09) 0%, transparent 70%);
  }
  :root:not(.light-mode) .site-header {
    background: rgba(26, 26, 26, 0.85);
  }
  :root:not(.light-mode) .site-header.scrolled {
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.2);
  }
  :root:not(.light-mode) .card-link:hover {
    box-shadow: var(--shadow-card-hover), 0 0 20px rgba(122, 196, 122, 0.08);
  }
}

:root.dark-mode body { background-image: none; }
:root.dark-mode .hero::before {
  background: radial-gradient(ellipse at center, rgba(122, 196, 122, 0.09) 0%, transparent 70%);
}
:root.dark-mode .site-header {
  background: rgba(26, 26, 26, 0.85);
}
:root.dark-mode .site-header.scrolled {
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.2);
}
:root.dark-mode .card-link:hover {
  box-shadow: var(--shadow-card-hover), 0 0 20px rgba(122, 196, 122, 0.08);
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .card-grid-2,
  .card-grid-3 {
    grid-template-columns: 1fr;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: var(--space-xl);
  }

  .site-nav {
    display: none;
  }

  .site-nav.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-md) var(--space-lg);
    gap: var(--space-md);
    box-shadow: var(--shadow-card);
  }

  .nav-toggle {
    display: block;
  }

  .hero h1 {
    font-size: clamp(2rem, 6vw, 3rem);
  }

  .admin-bar {
    flex-direction: column;
    gap: var(--space-sm);
    text-align: center;
  }

  .note-modal-content {
    padding: var(--space-md);
  }

  .form-row {
    flex-direction: column;
  }

  .work-form-actions {
    margin: 0 calc(-1 * var(--space-md));
    padding: var(--space-md);
    bottom: calc(-1 * var(--space-md));
  }

  .contact-card {
    max-width: 100%;
  }

  .contact-form .form-group textarea {
    min-height: 120px;
  }
}

@media (max-width: 480px) {
  .section { padding: var(--space-xl) 0; }
  .container, .container-narrow { padding: 0 var(--space-md); }
  .hero { padding: var(--space-2xl) 0; }
}

/* ── Reduced Motion ──────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
}

/* ── Print ───────────────────────────────────────────────────────────── */

@media print {
  .site-header, .site-footer, .admin-bar, .share-buttons, .theme-toggle, .nav-toggle { display: none; }
  body { color: #000; background: #fff; }
  a { text-decoration: underline; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
