:root {
  /* Royal blue palette: the header bar (behind the menu buttons) is royal
     blue, and buttons/accents use lighter blues on top of it. */
  --bg: #f4f7fc;
  --surface: #ffffff;
  --text: #1e2533;
  --muted: #5a6478;
  --royal: #2346b0;         /* header bar */
  --primary: #3d6bd6;       /* main buttons, active chips, bars */
  --primary-dark: #1c3a8f;  /* headings, hover */
  --nav: #5b86e5;           /* menu buttons on the royal bar */
  --nav-active: #bcd3f7;    /* current page's menu button */
  --light: #dce7fa;         /* secondary buttons */
  --light-hover: #c3d5f5;
  --accent: #2f5fc4;        /* badge text */
  --border: #d6e0f0;
  --tint: #e8eff9;
  --green: #3f7a5e;
  --amber: #b5772a;
  --grey: #7a7f8c;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { font-size: 20px; }
body {
  margin: 0;
  font-family: "Segoe UI", Verdana, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header.site-header {
  background: var(--royal);
  color: #fff;
  padding: 1rem;
}
header.site-header .bar {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}
header.site-header h1 { margin: 0; font-size: 1.5rem; }
header.site-header nav a {
  color: #fff;
  text-decoration: none;
  background: var(--nav);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  white-space: nowrap;
}
header.site-header nav a:hover { background: var(--primary); }
header.site-header nav a[aria-current="page"] { background: var(--nav-active); color: var(--primary-dark); font-weight: 600; }

main { max-width: 900px; margin: 0 auto; padding: 1.25rem; }
h2 { color: var(--primary-dark); font-size: 1.4rem; }
h3 { color: var(--primary-dark); font-size: 1.1rem; margin-top: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: 1rem;
}
.note {
  background: var(--tint);
  border: 1px dashed var(--primary);
  border-radius: var(--radius);
  padding: 0.9rem;
  font-size: 0.95rem;
}

.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.6rem 1.1rem;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: var(--light); color: var(--primary-dark); }
.btn.secondary:hover { background: var(--light-hover); }
.btn:disabled { opacity: 0.5; cursor: default; }

label { display: block; margin-top: 0.6rem; font-size: 0.9rem; color: var(--muted); }
input, select, textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  margin-top: 0.2rem;
}

/* Clickable visual cards -- used for Temples, Visits, Plans, People, Photos */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.click-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  display: block;
  transition: box-shadow 0.15s;
}
.click-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.08); }
.click-card .thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--tint);
  display: block;
}
.click-card .body { padding: 0.75rem; }
.click-card .title { font-weight: 600; margin: 0 0 0.2rem; }
.click-card .meta { font-size: 0.85rem; color: var(--muted); margin: 0; }

.empty-state { text-align: center; padding: 2rem 1rem; color: var(--muted); }

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
  text-align: center;
}
.stat-card .num { font-size: 1.6rem; font-weight: 700; color: var(--primary-dark); }
.stat-card .label { font-size: 0.8rem; color: var(--muted); }

/* Nav */
header.site-header nav { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.nav-soon {
  color: rgba(255,255,255,0.55);
  padding: 0.4rem 0.8rem;
  font-size: 0.95rem;
  white-space: nowrap;
}
.header-right { display: flex; align-items: center; gap: 0.6rem; }
.header-right .btn.secondary { padding: 0.35rem 0.7rem; font-size: 0.85rem; }

/* Cards: badges / shorthand */
.click-card .meta.badges { color: var(--accent); font-weight: 600; }
.work-shorthand {
  display: inline-block;
  background: var(--tint);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 0.35rem;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--primary-dark);
}

/* Quick actions */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}
.quick-actions a.btn.disabled, .btn.disabled {
  background: var(--grey);
  opacity: 0.6;
  pointer-events: none;
}

/* Filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1rem;
}
.filter-bar select, .filter-bar input[type="text"] { width: auto; margin-top: 0; }
.filter-bar label.checkbox { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.9rem; margin: 0; }
.filter-bar label.checkbox input { width: auto; margin: 0; }
.view-tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.75rem; }
.view-tabs button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
}
.view-tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Checkbox / multi-select groups (Purpose, Work Performed, Who With) */
.check-group { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.3rem; }
.check-group label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--tint);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
  margin: 0;
  cursor: pointer;
}
.check-group input { width: auto; margin: 0; }
.check-group label:has(input:checked) { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Forms */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.form-actions { margin-top: 1.1rem; display: flex; gap: 0.6rem; flex-wrap: wrap; }
.toggle-more { background: none; border: none; color: var(--primary); text-decoration: underline; cursor: pointer; padding: 0.4rem 0; font-size: 0.95rem; }
.field-error { color: #a33; font-size: 0.9rem; margin-top: 0.3rem; }
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 0.5rem; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
.detail-actions .btn { font-size: 0.9rem; padding: 0.5rem 0.9rem; }
.journal-section { margin-bottom: 1rem; }
.journal-section h3 { margin-bottom: 0.3rem; }
.journal-section p { white-space: pre-wrap; margin: 0; }
.tag-pill {
  display: inline-block;
  background: var(--tint);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.8rem;
  margin: 0 0.3rem 0.3rem 0;
}
.tag-pill.removable { cursor: pointer; }
.tag-pill.removable::after { content: " \00d7"; }

/* Photo upload control */
.photo-upload-label {
  position: relative;
  overflow: hidden;
  display: inline-block;
  cursor: pointer;
}
.photo-upload-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
}
.photo-upload-status { margin-left: 0.5rem; }

/* Photo detail */
.photo-detail-img {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  background: #000;
  border-radius: var(--radius);
  display: block;
  margin-bottom: 1rem;
}
.pick-list { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.3rem; }
.pick-list label {
  display: flex; align-items: center; gap: 0.3rem;
  background: var(--tint); border: 1px solid var(--border); border-radius: 999px;
  padding: 0.25rem 0.6rem; font-size: 0.85rem; margin: 0; cursor: pointer;
}
.pick-list input { width: auto; margin: 0; }

/* Statistics: dependency-free bar list */
.stat-bar-list { display: flex; flex-direction: column; gap: 0.5rem; }
.stat-bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 30%) 1fr auto;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
}
a.stat-bar-row:hover .stat-bar-fill { background: var(--primary-dark); }
.stat-bar-label { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-bar-track { background: var(--tint); border-radius: 999px; height: 0.7rem; overflow: hidden; }
.stat-bar-fill { background: var(--primary); height: 100%; border-radius: 999px; }
.stat-bar-count { font-size: 0.85rem; color: var(--muted); min-width: 1.5rem; text-align: right; }

/* Statistics: sub-section headings inside the same page */
.stats-section { margin-bottom: 1.5rem; }
.stats-section h3 { margin-bottom: 0.5rem; }
.stats-subgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .stats-subgrid { grid-template-columns: 1fr; } }

/* People: profile photo. Faces sit near the top of most portraits, so bias
   the crop upward instead of centering. */
.person-card .thumb { object-position: center 25%; }
.person-photo {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 25%;
  background: var(--tint);
  border: 3px solid var(--light);
  flex-shrink: 0;
}
.person-header { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }

/* Instructions page */
.help-section h3 { margin-bottom: 0.3rem; }
.help-section ul { margin: 0.3rem 0 0; padding-left: 1.2rem; }
.help-section li { margin-bottom: 0.3rem; }
