:root {
  --green: #1b5e20;
  --green-dark: #0e3a14;
  --tan: #f7f4ec;
  --ink: #1a1a1a;
  --muted: #555;
  --max: 760px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--tan);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

.site-header {
  background: var(--green);
  color: #fff;
  padding: 1rem 0;
}
.site-header .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.site-title {
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .6rem;
}
.site-logo {
  width: 28px;
  height: 36px;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.3));
}
.site-nav a {
  color: #fff;
  text-decoration: none;
  margin-left: 1.25rem;
  border-bottom: 2px solid transparent;
  padding-bottom: 2px;
}
.site-nav a:hover { border-bottom-color: #fff; }

.auth-status {
  margin-left: 1.5rem;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: .9rem;
  min-height: 1.5em;  /* reserve space so layout doesn't shift on JS load */
}
.auth-name {
  color: #d6e4d8;
  font-style: italic;
}
.auth-link {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 3px;
  padding: 2px 8px;
  text-decoration: none;
  margin-left: 0;
}
.auth-link:hover {
  background: rgba(255, 255, 255, 0.22);
  border-bottom-color: transparent;
}

/* Members-area nav is a left sidebar now (see the Members section CSS below and
   partials/members-sidebar.html), not a top strip. */

.site-main { padding: 2rem 0 4rem; }

.hero {
  border-bottom: 1px solid #d8d2c0;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
}
.hero h1 {
  margin: 0 0 .25rem;
  color: var(--green-dark);
  font-size: 2rem;
}
.hero .tagline {
  margin: 0;
  color: var(--muted);
  font-style: italic;
}

.hero-neckerchief {
  margin: 0 0 1.25rem;
  text-align: center;
}
.hero-neckerchief img {
  width: 100%;
  max-width: 460px;
  height: auto;
  border-radius: 8px;
}
.hero-neckerchief figcaption {
  margin-top: .4rem;
  font-size: .9rem;
  font-style: italic;
}

article.page h1, article.page h2, article.page h3 {
  color: var(--green-dark);
}
article.page h1 { font-size: 1.75rem; }
article.page a { color: var(--green); }
article.page a:hover { color: var(--green-dark); }

/* History page — photos and primary-source facsimiles */
.hist-figure {
  margin: 1.75rem 0;
  text-align: center;
}
.hist-figure img {
  width: 100%;
  max-width: 620px;
  height: auto;
  border-radius: 6px;
  border: 1px solid #d8d2c0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
}
.hist-figure figcaption,
.hist-gallery figcaption {
  margin: .55rem auto 0;
  max-width: 620px;
  font-size: .9rem;
  color: var(--muted);
  font-style: italic;
  line-height: 1.45;
}
.hist-figure figcaption em { font-style: normal; font-weight: 600; }
/* Document scans read best a little smaller, with a plainer frame */
.hist-figure--doc img { max-width: 460px; }
.hist-hint { font-style: normal; opacity: .8; }

.hist-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin: 1.75rem 0;
  align-items: start;
}
.hist-gallery figure { margin: 0; text-align: center; }
.hist-gallery img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid #d8d2c0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
}

article.page iframe {
  max-width: 100%;
  display: block;
  margin: 1.5rem auto;
}

.page-list { padding-left: 1rem; }

/* Roster + directory tables */
.roster-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 2rem;
  font-size: .95rem;
}
.roster-table th,
.roster-table td {
  border-bottom: 1px solid #d8d2c0;
  padding: .55rem .75rem;
  text-align: left;
  vertical-align: top;
}
.roster-table th {
  background: #eae3cf;
  color: var(--green-dark);
  font-weight: 700;
}
.roster-table tbody tr:hover { background: rgba(27, 94, 32, 0.04); }

.hint, .muted { color: var(--muted); }
.muted { font-size: .88em; }
.hint { font-size: .92em; margin-bottom: 1rem; }
.warn {
  padding: .75rem 1rem;
  background: #fff3cd;
  border-left: 4px solid #c29d0b;
  color: #5a4400;
  border-radius: 3px;
}

.leader-list {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.leader-list li {
  background: #fff;
  border: 1px solid #d8d2c0;
  border-radius: 4px;
  padding: .75rem 1rem;
}

.site-footer {
  background: var(--green-dark);
  color: #d6e4d8;
  padding: 1.25rem 0;
  font-size: .9rem;
}
.site-footer a { color: #fff; }
.site-version {
  margin: .35rem 0 0;
  font-size: .75rem;
  color: #9bb1a0;          /* dimmer than the footer text — deliberately low-key */
  letter-spacing: .02em;
}

/* --- Join Us / recruitment block on the landing page --- */
.join-us {
  margin: 1.5rem 0 2.5rem;
  padding: 1.5rem 1.5rem 1.25rem;
  background: #fff;
  border: 1px solid #d8d2c0;
  border-left: 4px solid var(--green);
  border-radius: 4px;
}
.join-qr {
  margin: 0 auto 1.25rem;
  text-align: center;
}
.join-qr img {
  display: block;
  margin: 0 auto .5rem;
  max-width: 100%;
  height: auto;
  /* Subtle frame so the placeholder reads as an image, not a logo. */
  border: 1px solid #e3ddc7;
  border-radius: 4px;
  background: #fff;
  padding: .5rem;
}
.join-qr figcaption {
  margin: 0;
}
.join-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin: 0 0 1rem;
  justify-content: center;
}
.join-btn {
  display: inline-block;
  padding: .7rem 1.1rem;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 600;
  line-height: 1.2;
  border: 2px solid var(--green);
  transition: background .15s ease, color .15s ease;
}
.join-btn-primary {
  background: var(--green);
  color: #fff !important;
}
.join-btn-primary:hover {
  background: var(--green-dark);
  border-color: var(--green-dark);
  color: #fff !important;
}
.join-btn-secondary {
  background: #fff;
  color: var(--green) !important;
}
.join-btn-secondary:hover {
  background: var(--green);
  color: #fff !important;
}

/* ── Calendar events list (gated /members/calendar/) ─────────────────── */
.calendar-events .dim { color: var(--muted); }
.calendar-events .small { font-size: 0.85em; }
.calendar-event-list {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.calendar-event {
  border-left: 4px solid var(--green);
  padding: 0.6rem 0.9rem;
  background: #fff;
  border-radius: 0 6px 6px 0;
}
.calendar-event-when {
  color: var(--green-dark);
  font-weight: 600;
  font-size: 0.92em;
}
.calendar-event-title {
  font-size: 1.1em;
  margin-top: 2px;
}
.calendar-event-loc {
  color: var(--muted);
  font-size: 0.92em;
  margin-top: 2px;
}
.calendar-event-desc {
  color: var(--muted);
  font-size: 0.92em;
  margin-top: 0.4rem;
  white-space: pre-wrap;
}

/* ── Subscribe link box (gated /members/calendar/) ───────────────────── */
.subscribe-box {
  background: #fff;
  border-left: 4px solid var(--green);
  padding: 0.75rem 1rem;
  border-radius: 0 6px 6px 0;
  margin: 1.25rem 0;
}
.subscribe-url {
  background: var(--tan);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  word-break: break-all;
  font-size: 0.88em;
}
.copy-btn {
  background: var(--green);
  color: #fff;
  border: 0;
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  font: inherit;
  font-size: 0.85em;
  cursor: pointer;
  margin-left: 0.4rem;
}
.copy-btn:hover { background: var(--green-dark); }

/* ── Documents table (gated /members/documents/) ─────────────────────── */
.documents-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.documents-table th,
.documents-table td {
  padding: 0.7rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid #eee;
}
.documents-table th {
  background: var(--green);
  color: #fff;
  font-weight: 600;
  font-size: 0.95em;
}
.documents-table tr:last-child td { border-bottom: 0; }
.documents-table a {
  font-weight: 600;
  color: var(--green-dark);
  text-decoration: none;
}
.documents-table a:hover { text-decoration: underline; }
.doc-desc {
  color: var(--muted);
  font-size: 0.9em;
  margin-top: 0.2rem;
}
.doc-kind {
  color: var(--muted);
  font-size: 0.88em;
  white-space: nowrap;
}

/* ── Leader meetings (Committee / Troop Officers, issue #36) ─────────── */
.meeting-series .dim { color: var(--muted); }
.meeting-series .small { font-size: 0.85em; }
.meet-join-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.75rem 0 1rem;
}
a.meet-join {
  display: inline-block;
  background: var(--green);
  color: #fff !important; /* beat article.page a, which repaints in-article links green */
  padding: 0.45rem 1rem;
  border-radius: 4px;
  font-weight: 600;
  text-decoration: none;
}
a.meet-join:hover { background: var(--green-dark); }
.meetings-table td { white-space: nowrap; }
.meetings-table tr.past td { color: var(--muted); }

/* ── Admin panel ─────────────────────────────────────────────────────────── */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
  margin: 1rem 0;
}
.admin-table th, .admin-table td {
  padding: 0.55rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #e0ddd5;
  vertical-align: top;
}
.admin-table th {
  background: var(--green);
  color: #fff;
  font-weight: 600;
}
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tr:hover td { background: rgba(0,0,0,.03); }

.admin-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: .02em;
}
.admin-badge.active  { background: #d4edda; color: #155724; }
.admin-badge.disabled{ background: #f8d7da; color: #721c24; }
.admin-badge.admin   { background: #cce5ff; color: #004085; }
.admin-badge.warn    { background: #fff3cd; color: #856404; }
.admin-badge.danger  { background: #f5c6cb; color: #721c24; }
.admin-badge.muted   { background: #e2e3e5; color: #495057; }

.admin-actions { white-space: nowrap; }

.admin-btn {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
  font-family: inherit;
}
.admin-btn:hover { background: var(--green-dark); }
.admin-btn.sm { padding: 0.2rem 0.5rem; font-size: 0.82em; }
.admin-btn.danger { background: #c0392b; }
.admin-btn.danger:hover { background: #962d22; }
.admin-btn:disabled { opacity: 0.5; cursor: default; }

.admin-notice {
  padding: 0.5rem 0.75rem;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 4px;
  font-size: 0.9em;
  margin: 0.5rem 0;
}
.admin-error {
  padding: 0.5rem 0.75rem;
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  border-radius: 4px;
  font-size: 0.9em;
}

.admin-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.admin-modal {
  background: var(--tan);
  border-radius: 6px;
  padding: 2rem;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 4px 24px rgba(0,0,0,.25);
}
.admin-modal h3 { margin-top: 0; }
code.password-display {
  display: block;
  font-size: 1.2em;
  padding: 0.6rem 0.9rem;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  letter-spacing: .05em;
  margin: 0.75rem 0;
}

/* Email form */
.admin-field { margin-bottom: 1.2rem; }
.admin-field label { display: block; margin-bottom: 0.35rem; }
.admin-input {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font: inherit;
  background: #fff;
}
.admin-textarea { resize: vertical; }
.admin-checklist { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin-top: 0.3rem; }
.admin-check { display: flex; align-items: center; gap: 0.35rem; cursor: pointer; }
.admin-check-group { flex-basis: 100%; width: 100%; margin: 0.6rem 0 0.1rem; font-weight: 600; color: var(--green-dark); }
.admin-check-note { flex-basis: 100%; width: 100%; margin: 0.1rem 0 0.35rem; color: var(--muted); font-size: 0.85em; }

/* Admin page TOC nav bar */
.admin-toc {
  background: #e8f5e9;
  border: 1px solid #c8e6c9;
  border-radius: 5px;
  padding: 0.6rem 1rem;
  font-size: 0.9em;
  margin: 1rem 0 1.5rem;
  line-height: 1.8;
}
.admin-toc a {
  color: var(--green-dark);
  text-decoration: none;
  font-weight: 500;
}
.admin-toc a:hover { text-decoration: underline; }

/* Admin section: sidebar + content layout (rendered by baseof.html) */
.admin-layout {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
}
.admin-content {
  flex: 1 1 auto;
  min-width: 0;
}

/* Vertical sidebar nav — single source of truth: partials/admin-sidebar.html */
.admin-sidebar {
  flex: 0 0 200px;
  position: sticky;
  top: 1rem;
  background: var(--green);
  border-radius: 5px;
  padding: 0.6rem;
}
.admin-sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.admin-sidebar a {
  display: block;
  color: #fff;
  text-decoration: none;
  font-size: 0.9em;
  font-weight: 500;
  padding: 0.4rem 0.7rem;
  border-radius: 3px;
  white-space: nowrap;
}
.admin-sidebar a:hover { background: rgba(255,255,255,.18); color: #fff; }
.admin-sidebar a.active {
  background: #fff;
  color: var(--green-dark);
  font-weight: 600;
}

/* Narrow viewports: collapse sidebar to a scrollable top bar */
@media (max-width: 700px) {
  .admin-layout {
    flex-direction: column;
    gap: 1rem;
  }
  .admin-sidebar {
    flex: 0 0 auto;
    width: 100%;
    position: static;
    top: auto;
    padding: 0.45rem 0.6rem;
  }
  .admin-sidebar ul {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.3rem;
    -webkit-overflow-scrolling: touch;
  }
  .admin-sidebar a { white-space: nowrap; }
}

.admin-field-hint {
  margin: 0.15rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.85em;
}
.admin-field-hint code {
  background: #f0ede5;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.95em;
}

/* Widen content area on admin sub-pages */
.admin-page .container { max-width: 1100px; }

/* Members section: sidebar + content layout (rendered by baseof.html).
   Mirrors the admin section layout above. Nav source: partials/members-sidebar.html */
.members-layout {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
}
.members-content {
  flex: 1 1 auto;
  min-width: 0;
}
.members-sidebar {
  flex: 0 0 200px;
  position: sticky;
  top: 1rem;
  background: var(--green);
  border-radius: 5px;
  padding: 0.6rem;
}
.members-sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.members-sidebar a {
  display: block;
  color: #fff;
  text-decoration: none;
  font-size: 0.9em;
  font-weight: 500;
  padding: 0.4rem 0.7rem;
  border-radius: 3px;
  white-space: nowrap;
}
.members-sidebar a:hover { background: rgba(255,255,255,.18); color: #fff; }
.members-sidebar a.active {
  background: #fff;
  color: var(--green-dark);
  font-weight: 600;
}
/* "Admin" link sits at the foot, set off by a divider. */
.members-sidebar-foot {
  margin-top: 0.35rem;
  padding-top: 0.4rem;
  border-top: 1px solid rgba(255,255,255,.22);
}
.members-page .container { max-width: 1100px; }

/* Narrow viewports: collapse the members sidebar to a scrollable top strip */
@media (max-width: 700px) {
  .members-layout { flex-direction: column; gap: 1rem; }
  .members-sidebar {
    flex: 0 0 auto;
    width: 100%;
    position: static;
    top: auto;
    padding: 0.45rem 0.6rem;
  }
  .members-sidebar ul {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.3rem;
    -webkit-overflow-scrolling: touch;
  }
  .members-sidebar a { white-space: nowrap; }
  /* Divider turns vertical when the sidebar becomes a horizontal strip. */
  .members-sidebar-foot {
    margin: 0 0 0 0.3rem;
    padding: 0 0 0 0.4rem;
    border-top: 0;
    border-left: 1px solid rgba(255,255,255,.22);
  }
}

/* Test-send section */
.admin-test-send {
  border-top: 1px solid #d0cdc5;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
}
.admin-test-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}
.admin-test-row .admin-input { flex: 1; min-width: 200px; }
.admin-test-row .admin-btn { white-space: nowrap; flex-shrink: 0; }
