:root,
html[data-theme="dark"] {
  --brand: #0b6e4f;
  --gold: #c4a35a;
  --bg0: #071a14;
  --bg1: #0d2f24;
  --bg2: #102820;
  --ink: #e8f2ec;
  --muted: rgba(232, 242, 236, 0.65);
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(232, 242, 236, 0.12);
  --input-bg: rgba(0, 0, 0, 0.25);
  --input-border: rgba(255, 255, 255, 0.15);
  --nav: rgba(255, 255, 255, 0.8);
  --brand-text: #ffffff;
  --ghost-border: rgba(255, 255, 255, 0.2);
  --ghost-text: #ffffff;
  --footer: rgba(255, 255, 255, 0.5);
  --shadow: none;
  --glow: rgba(11, 110, 79, 0.45);
  color-scheme: dark;
}

html[data-theme="light"] {
  --brand: #0b6e4f;
  --gold: #9a7b32;
  --bg0: #f3f7f4;
  --bg1: #e7f0ea;
  --bg2: #dfeae3;
  --ink: #132019;
  --muted: rgba(19, 32, 25, 0.62);
  --card: rgba(255, 255, 255, 0.82);
  --card-border: rgba(19, 32, 25, 0.1);
  --input-bg: #ffffff;
  --input-border: rgba(19, 32, 25, 0.16);
  --nav: rgba(19, 32, 25, 0.75);
  --brand-text: #0b3d2c;
  --ghost-border: rgba(19, 32, 25, 0.18);
  --ghost-text: #132019;
  --footer: rgba(19, 32, 25, 0.5);
  --shadow: 0 10px 30px rgba(19, 32, 25, 0.06);
  --glow: rgba(11, 110, 79, 0.18);
  color-scheme: light;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "DM Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 90% 0%, var(--glow), transparent 55%),
    linear-gradient(165deg, var(--bg0), var(--bg1) 45%, var(--bg2));
  min-height: 100vh;
  transition: background 0.25s ease, color 0.25s ease;
}
a { color: var(--gold); text-decoration: none; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0.85rem 1.1rem 3rem; }

/* Header: brand + theme top row, nav second row */
.site-header {
  margin-bottom: 1.35rem;
}
.site-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 48px;
}
.brand {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: clamp(1.35rem, 3vw, 1.7rem);
  color: var(--brand-text);
  display: inline-block;
  line-height: 1.1;
}
.brand:hover { color: var(--gold); }

/* Top-right modern theme control */
.theme-fab {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--ghost-border);
  background: var(--card);
  color: var(--ink);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.theme-fab:hover {
  transform: translateY(-1px);
  border-color: var(--gold);
}
.theme-fab:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}
.theme-fab svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* Clean nav — pills, not crowded */
nav.site-nav {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.85rem;
  padding: 0.35rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
html[data-theme="light"] nav.site-nav {
  background: rgba(255, 255, 255, 0.72);
}
nav.site-nav a {
  flex: 0 0 auto;
  color: var(--nav);
  font-size: 0.86rem;
  font-weight: 600;
  padding: 0.48rem 0.78rem;
  border-radius: 10px;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
nav.site-nav a:hover {
  color: var(--brand-text);
  background: rgba(196, 163, 90, 0.16);
}
nav.site-nav a.is-active {
  color: #132019;
  background: linear-gradient(135deg, var(--gold), #e0c37a);
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(196, 163, 90, 0.28);
}
html[data-theme="light"] nav.site-nav a.is-active {
  color: #132019;
}

/* Legacy aliases kept for admin layout */
.site-top {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.35rem;
}
.site-top-left { min-width: 0; }
.site-top-right {
  position: absolute;
  right: 1.1rem;
  top: 0.9rem;
}
.site-header .site-top-right { position: static; }

header.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
header.admin-header nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.7rem;
}
header.admin-header nav a { color: var(--nav); }
header.admin-header nav a.is-active {
  color: var(--gold);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.hero, .card {
  background: linear-gradient(180deg, var(--card), transparent);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.4rem;
  box-shadow: var(--shadow);
}
.hero h1, .card h1, .post-title {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  margin: 0.2rem 0;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 8px;
  padding: 0.85rem 1.1rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}
.btn-primary { background: linear-gradient(135deg, var(--gold), #e0c37a); color: #132019; }
.btn-ghost { background: transparent; border: 1px solid var(--ghost-border); color: var(--ghost-text); }
.btn-danger { background: #8b2e2e; color: #fff; }
.row { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1rem; }
input, select, textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--ink);
}
.tabs button { margin-right: 0.4rem; }
.muted { color: var(--muted); }
.footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--card-border);
  color: var(--footer);
  font-size: 0.85rem;
}
.grid3, .grid-posts, .grid-testimonials {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 1rem;
}
.stat, .post-card, .testimony-card {
  padding: 1rem;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
}
.post-card h2, .testimony-card h3 {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 1.35rem;
  margin: 0.5rem 0;
}
.post-body {
  line-height: 1.7;
  white-space: pre-wrap;
  margin-top: 1rem;
}
.post-body img, .post-body video {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  display: block;
  margin: 1rem 0;
}

/* Media aspect frames */
.media-frame {
  width: 100%;
  overflow: hidden;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--card-border);
  margin: 0.8rem 0 1rem;
}
.media-frame img,
.media-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}
.ratio-16x9 { aspect-ratio: 16 / 9; }
.ratio-9x16 { aspect-ratio: 9 / 16; max-width: 420px; margin-left: auto; margin-right: auto; }
.ratio-1x1 { aspect-ratio: 1 / 1; max-width: 520px; }
.ratio-auto { aspect-ratio: auto; }
.ratio-auto img,
.ratio-auto video {
  height: auto;
  object-fit: contain;
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold);
}
.stars { color: var(--gold); letter-spacing: 0.08em; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.admin-table th, .admin-table td {
  padding: 0.55rem 0.35rem;
  border-top: 1px solid var(--card-border);
  vertical-align: top;
}
.form-grid label { display: block; margin-top: 0.7rem; }
.preview-box { margin-top: 0.8rem; max-width: 480px; }

@media (max-width: 640px) {
  .btn { width: 100%; }
  .tabs.row {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.5rem;
    margin-top: 1rem;
  }
  .tabs.row .btn {
    width: auto;
    flex: 1 1 0;
    min-width: 0;
  }
  .row:not(.tabs) > .btn { width: 100%; }
  nav.site-nav {
    margin-left: -0.25rem;
    margin-right: -0.25rem;
  }
}

.tabs.row {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  align-items: stretch;
}
.tabs.row .btn {
  flex: 1 1 0;
  width: auto;
}
