:root {
  color-scheme: light;
  --paper: #f8f4ec;
  --paper-2: #fffdf8;
  --ink: #24211d;
  --muted: #686157;
  --line: #ded4c4;
  --sage: #6e7f68;
  --sage-dark: #3f5142;
  --blue: #4f6474;
  --gold: #c59b55;
  --rose: #a46f67;
  --shadow: 0 24px 70px rgba(59, 47, 32, 0.14);
  --radius: 8px;
  --max: 1180px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(115deg, rgba(110, 127, 104, 0.12), transparent 30%),
    linear-gradient(245deg, rgba(79, 100, 116, 0.10), transparent 34%),
    var(--paper);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(36, 33, 29, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(36, 33, 29, 0.026) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.65), transparent 75%);
}

a {
  color: inherit;
}

button,
input,
textarea,
select {
  font: inherit;
}

.skip-link {
  position: absolute;
  top: -60px;
  left: 16px;
  z-index: 20;
  background: var(--ink);
  color: white;
  padding: 10px 14px;
  border-radius: var(--radius);
}

.skip-link:focus {
  top: 16px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: min(var(--max), calc(100% - 32px));
  margin: 18px auto 0;
  padding: 12px 14px;
  border: 1px solid rgba(222, 212, 196, 0.84);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.86);
  backdrop-filter: blur(18px);
  box-shadow: 0 10px 32px rgba(49, 39, 27, 0.08);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  min-width: 190px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: white;
  background: linear-gradient(135deg, var(--sage-dark), var(--blue));
  font-family: Georgia, serif;
  font-size: 22px;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.08;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topnav a {
  text-decoration: none;
  color: var(--muted);
  padding: 9px 10px;
  border-radius: var(--radius);
  font-size: 14px;
}

.topnav a:hover,
.topnav a:focus-visible {
  color: var(--ink);
  background: #efe7da;
  outline: none;
}

.hero {
  width: min(var(--max), calc(100% - 32px));
  margin: 34px auto 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 34px;
  align-items: stretch;
  min-height: 640px;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(30px, 6vw, 76px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 253, 248, 0.93), rgba(248, 244, 236, 0.72)),
    radial-gradient(circle at 18% 12%, rgba(197, 155, 85, 0.18), transparent 36%);
  box-shadow: var(--shadow);
}

.eyebrow,
.section-kicker,
.card-label {
  margin: 0 0 12px;
  color: var(--sage-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 780px;
  margin-bottom: 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(46px, 8vw, 96px);
  line-height: 0.96;
  font-weight: 500;
}

h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1.04;
  font-weight: 500;
}

.years {
  color: var(--gold);
  font-weight: 800;
  margin-bottom: 18px;
}

.hero-subtitle {
  max-width: 660px;
  color: var(--muted);
  font-size: clamp(18px, 2vw, 23px);
  line-height: 1.55;
}

.hero-actions,
.form-actions,
.closing-actions,
.filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.button,
.filter-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  background: var(--paper-2);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.button:hover,
.filter-chip:hover,
.button:focus-visible,
.filter-chip:focus-visible {
  transform: translateY(-1px);
  border-color: var(--sage);
  outline: none;
}

.button.primary {
  color: #fffdf8;
  border-color: var(--sage-dark);
  background: var(--sage-dark);
}

.button.ghost {
  background: rgba(255, 253, 248, 0.72);
}

.portrait-panel {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 16px;
}

.portrait-frame {
  position: relative;
  min-height: 460px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background:
    linear-gradient(160deg, rgba(63, 81, 66, 0.78), rgba(79, 100, 116, 0.74)),
    linear-gradient(45deg, rgba(197, 155, 85, 0.28), transparent);
}

.portrait-frame::before {
  content: attr(data-initials);
  position: absolute;
  inset: 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 253, 248, 0.42);
  color: rgba(255, 253, 248, 0.88);
  font-family: Georgia, serif;
  font-size: clamp(82px, 12vw, 148px);
}

.portrait-frame.has-photo::before {
  content: "";
}

.portrait-frame img,
.photo-thumb img,
#lightboxImage img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.service-card {
  display: grid;
  gap: 8px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.92);
}

.service-card strong {
  font-size: 22px;
}

.service-card small {
  color: var(--muted);
  line-height: 1.4;
}

.support-band,
.section,
.closing {
  width: min(var(--max), calc(100% - 32px));
  margin: 26px auto 0;
}

.support-band {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(320px, 1fr);
  gap: 24px;
  align-items: start;
  padding: 28px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--sage-dark);
  color: #fffdf8;
  box-shadow: var(--shadow);
}

.support-band .section-kicker {
  color: #efe0bd;
}

.support-band h2 {
  margin-bottom: 0;
}

.support-band ul {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.support-band li {
  padding: 12px 14px;
  border: 1px solid rgba(255, 253, 248, 0.22);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
}

.section {
  padding-top: 58px;
}

.section-heading {
  max-width: 720px;
  margin-bottom: 24px;
}

.story-grid,
.memory-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(340px, 1.1fr);
  gap: 22px;
  align-items: start;
}

.story-card,
.memory-form,
.memory-wall,
.closing {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.88);
  box-shadow: 0 16px 50px rgba(59, 47, 32, 0.08);
}

.story-card {
  padding: 28px;
  color: var(--muted);
  line-height: 1.75;
  font-size: 18px;
}

.timeline {
  display: grid;
  gap: 14px;
}

.timeline-item {
  position: relative;
  padding: 20px 20px 20px 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.9);
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 22px;
  bottom: 22px;
  width: 3px;
  border-radius: 4px;
  background: linear-gradient(var(--gold), var(--rose));
}

.timeline-year {
  color: var(--sage-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.timeline-item h3 {
  margin: 5px 0 8px;
  font-size: 20px;
}

.timeline-item p {
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 0;
}

.filter-row {
  margin-bottom: 18px;
}

.filter-row.compact {
  margin-bottom: 14px;
}

.filter-chip {
  min-height: 36px;
  color: var(--muted);
  background: rgba(255, 253, 248, 0.8);
}

.filter-chip.active {
  color: white;
  border-color: var(--blue);
  background: var(--blue);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.photo-card {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-2);
  cursor: pointer;
  text-align: left;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.photo-card:hover,
.photo-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  outline: none;
}

.photo-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  color: rgba(255, 253, 248, 0.9);
  background:
    linear-gradient(135deg, rgba(63, 81, 66, 0.9), rgba(164, 111, 103, 0.72)),
    radial-gradient(circle at 70% 20%, rgba(197, 155, 85, 0.55), transparent 35%);
  font-family: Georgia, serif;
  font-size: 40px;
}

.photo-body {
  padding: 15px;
}

.photo-body strong {
  display: block;
  margin-bottom: 6px;
}

.photo-body span {
  color: var(--muted);
  line-height: 1.45;
  font-size: 14px;
}

.memory-form,
.memory-wall {
  padding: 20px;
}

.memory-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--sage-dark);
  font-size: 13px;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf8;
  color: var(--ink);
  padding: 11px 12px;
}

textarea {
  resize: vertical;
  min-height: 140px;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(79, 100, 116, 0.28);
  border-color: var(--blue);
}

.form-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

#memoryList {
  display: grid;
  gap: 12px;
}

.memory-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(248, 244, 236, 0.72);
}

.memory-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 10px;
}

.memory-card strong,
.memory-card small {
  display: block;
}

.memory-card small,
.memory-date {
  color: var(--muted);
  font-size: 12px;
}

.memory-tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--sage-dark);
  background: #e8dfcf;
  font-size: 12px;
  font-weight: 800;
}

.memory-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.58;
}

.family-tree {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.family-group {
  position: relative;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.9);
}

.family-group::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  border-radius: var(--radius) 0 0 var(--radius);
  background: linear-gradient(var(--sage), var(--gold));
}

.family-group h3 {
  margin: 0 0 12px;
  font-size: 17px;
}

.family-group ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.family-group li {
  padding: 8px 10px;
  border-radius: var(--radius);
  background: #f0e8da;
  color: var(--muted);
}

.closing {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 28px;
  margin-bottom: 42px;
}

.closing h2 {
  max-width: 720px;
  margin-bottom: 10px;
}

.closing p {
  color: var(--muted);
  margin-bottom: 0;
}

.lightbox {
  width: min(980px, calc(100% - 28px));
  border: none;
  border-radius: var(--radius);
  padding: 0;
  color: var(--paper-2);
  background: #171613;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.45);
}

.lightbox::backdrop {
  background: rgba(16, 14, 11, 0.72);
  backdrop-filter: blur(6px);
}

.lightbox figure {
  margin: 0;
}

#lightboxImage {
  width: 100%;
  min-height: 360px;
  max-height: 72vh;
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(63, 81, 66, 0.86), rgba(79, 100, 116, 0.82)),
    radial-gradient(circle at 50% 40%, rgba(197, 155, 85, 0.38), transparent 38%);
  font-family: Georgia, serif;
  font-size: 74px;
}

.lightbox figcaption {
  display: grid;
  gap: 6px;
  padding: 18px 22px 22px;
}

.lightbox figcaption span {
  color: #d8d0c4;
}

.icon-button {
  position: absolute;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 253, 248, 0.32);
  border-radius: 50%;
  background: rgba(23, 22, 19, 0.66);
  color: #fffdf8;
  cursor: pointer;
  z-index: 2;
}

.lightbox-close {
  top: 12px;
  right: 12px;
}

.lightbox-prev,
.lightbox-next {
  top: 44%;
}

.lightbox-prev {
  left: 12px;
}

.lightbox-next {
  right: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 30;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: white;
  background: var(--sage-dark);
  box-shadow: var(--shadow);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

[data-reveal] {
  opacity: 1;
  transform: none;
}

[data-reveal].is-visible {
  opacity: 1;
  transform: none;
}

@media (max-width: 980px) {
  .hero,
  .support-band,
  .story-grid,
  .memory-layout {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .portrait-frame {
    min-height: 360px;
  }

  .gallery-grid,
  .family-tree {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .closing {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 700px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .topnav {
    justify-content: flex-start;
  }

  .hero-copy {
    padding: 28px;
  }

  .gallery-grid,
  .family-tree {
    grid-template-columns: 1fr;
  }

  .memory-card header {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }

  [data-reveal] {
    opacity: 1;
    transform: none;
  }
}

@media print {
  .site-header,
  .hero-actions,
  .memory-form,
  .filter-row,
  .closing-actions,
  .lightbox,
  .toast {
    display: none !important;
  }

  body {
    background: white;
  }

  .hero,
  .support-band,
  .section,
  .closing {
    width: 100%;
    margin: 0 0 18px;
  }
}

/* =========================================================================
   Sturgis Family app additions (auth, tree, profile media, comments, admin)
   Built on the design tokens above. Kept in the same visual language.
   ========================================================================= */

/* Top navigation auth states */
.topnav .nav-user {
  color: var(--sage-dark);
  font-weight: 700;
  padding: 9px 10px;
}

.topnav .button {
  min-height: 38px;
  padding: 8px 14px;
}

/* Generic page wrapper for non-hero pages */
.page {
  width: min(var(--max), calc(100% - 32px));
  margin: 34px auto 0;
}

.page-head {
  margin-bottom: 22px;
}

.page-head h1 {
  font-size: clamp(38px, 6vw, 64px);
  margin-bottom: 8px;
}

.page-lead {
  max-width: 720px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.6;
}

/* Auth card (login / register / pending) */
.auth-shell {
  width: min(560px, calc(100% - 32px));
  margin: 6vh auto 40px;
}

.auth-card {
  padding: clamp(26px, 4vw, 40px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 253, 248, 0.96), rgba(248, 244, 236, 0.8)),
    radial-gradient(circle at 16% 10%, rgba(197, 155, 85, 0.16), transparent 40%);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  font-size: clamp(34px, 5vw, 46px);
  margin-bottom: 6px;
}

.auth-card form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.auth-note {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(110, 127, 104, 0.08);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.auth-switch {
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
}

.auth-switch a {
  color: var(--sage-dark);
  font-weight: 700;
}

.field-hint {
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
}

/* Inline status banners */
.banner {
  padding: 13px 15px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.5;
  border: 1px solid var(--line);
}

.banner.error {
  border-color: #d8b1a9;
  background: #f6e4e0;
  color: #7d3a30;
}

.banner.success {
  border-color: #b6c6ac;
  background: #e7efdd;
  color: #3f5142;
}

.banner.info {
  border-color: #c3cdd6;
  background: #e7eef3;
  color: #3c4b57;
}

.banner.hidden,
.hidden {
  display: none !important;
}

.banner ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

/* Service banner strip on the tree page */
.service-strip {
  width: min(var(--max), calc(100% - 32px));
  margin: 22px auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--sage-dark);
  color: #fffdf8;
  box-shadow: var(--shadow);
}

.service-strip .strip-kicker {
  color: #efe0bd;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}

.service-strip strong {
  font-size: 18px;
}

.service-strip .button {
  border-color: rgba(255, 253, 248, 0.5);
  background: rgba(255, 255, 255, 0.1);
  color: #fffdf8;
}

/* Tree: generation rows of clickable person cards */
.tree-generations {
  display: grid;
  gap: 18px;
}

.generation-row {
  position: relative;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.9);
}

.generation-row::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  border-radius: var(--radius) 0 0 var(--radius);
  background: linear-gradient(var(--sage), var(--gold));
}

.generation-row h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.generation-row .gen-sub {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.person-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.person-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
  text-decoration: none;
  color: var(--ink);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.person-card:hover,
.person-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--sage);
  box-shadow: var(--shadow);
  outline: none;
}

.person-avatar {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #fffdf8;
  font-family: Georgia, serif;
  font-size: 18px;
  background: linear-gradient(135deg, var(--sage-dark), var(--blue));
}

.person-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.person-meta strong {
  display: block;
  font-size: 15px;
  line-height: 1.2;
}

.person-meta span {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  padding: 40px 24px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.7);
  color: var(--muted);
}

/* Tree: lineage board adapted from the design prototype */
.lineage-board {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 253, 248, 0.95), rgba(248, 244, 236, 0.78)),
    radial-gradient(circle at 16% 12%, rgba(197, 155, 85, 0.13), transparent 34%);
  box-shadow: 0 16px 50px rgba(59, 47, 32, 0.08);
  overflow: hidden;
}

.tree-topline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding: clamp(18px, 3vw, 28px);
}

.tree-topline h2 {
  margin-bottom: 6px;
}

.tree-board-note {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
}

.tree-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 245px;
}

.tree-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 253, 248, 0.82);
  font-size: 13px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--sage-dark);
}

.dot.child {
  background: var(--blue);
}

.dot.portrait {
  background: var(--gold);
}

.tree-canvas {
  overflow: auto;
  overscroll-behavior-x: contain;
  min-height: 430px;
  padding: 24px 16px 42px;
  border-top: 1px solid var(--line);
  background:
    linear-gradient(rgba(110, 127, 104, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(110, 127, 104, 0.08) 1px, transparent 1px),
    rgba(248, 244, 236, 0.58);
  background-size: 34px 34px;
}

.lineage-tree,
.lineage-tree ul {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 22px;
  min-width: max-content;
  margin: 0;
  padding: 38px 0 0;
  list-style: none;
}

.lineage-tree {
  padding-top: 0;
}

.lineage-tree ul::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 1px;
  height: 38px;
  background: var(--line);
}

.lineage-tree li {
  position: relative;
  display: grid;
  justify-items: center;
  padding: 38px 8px 0;
}

.lineage-tree > li {
  padding-top: 0;
}

.lineage-tree li::before,
.lineage-tree li::after {
  content: "";
  position: absolute;
  top: 0;
  width: 50%;
  height: 38px;
  border-top: 1px solid var(--line);
}

.lineage-tree li::before {
  right: 50%;
}

.lineage-tree li::after {
  left: 50%;
}

.lineage-tree > li::before,
.lineage-tree > li::after,
.lineage-tree li:only-child::before,
.lineage-tree li:only-child::after {
  display: none;
}

.lineage-tree li:first-child::before {
  border-top: 0;
}

.lineage-tree li:last-child::after {
  border-top: 0;
}

.lineage-person-card {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  width: 166px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  background: rgba(255, 253, 248, 0.95);
  box-shadow: 0 14px 34px rgba(59, 47, 32, 0.12);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.lineage-person-card:hover,
.lineage-person-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--sage);
  box-shadow: 0 20px 42px rgba(59, 47, 32, 0.16);
  outline: none;
}

.lineage-person-card.is-root {
  width: 194px;
  border-color: rgba(63, 81, 66, 0.45);
  box-shadow: 0 20px 48px rgba(63, 81, 66, 0.18);
}

.lineage-photo {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  margin-bottom: 9px;
  border: 1px dashed rgba(63, 81, 66, 0.42);
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--sage-dark);
  background:
    linear-gradient(135deg, rgba(110, 127, 104, 0.18), rgba(197, 155, 85, 0.08)),
    rgba(248, 244, 236, 0.8);
}

.lineage-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lineage-initials {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 42px;
  line-height: 1;
}

.lineage-name {
  width: 100%;
  min-height: 30px;
  padding: 5px 2px 6px;
  border-bottom: 1px solid var(--line);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  line-height: 1.15;
}

.lineage-relation {
  min-height: 28px;
  padding: 6px 2px 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

@media (max-width: 700px) {
  .tree-topline {
    flex-direction: column;
    align-items: stretch;
    padding: 18px;
  }

  .tree-legend {
    justify-content: flex-start;
    min-width: 0;
  }

  .tree-board-note {
    max-width: none;
  }

  .tree-canvas {
    min-height: 360px;
    padding: 20px 12px 34px;
  }

  .lineage-tree,
  .lineage-tree ul {
    gap: 14px;
  }

  .lineage-person-card {
    width: 152px;
  }

  .lineage-person-card.is-root {
    width: 172px;
  }
}

/* Collapsible admin panels */
.admin-panel {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.92);
  overflow: hidden;
}

.admin-panel > summary {
  cursor: pointer;
  list-style: none;
  padding: 16px 20px;
  font-weight: 800;
  color: var(--sage-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.admin-panel > summary::-webkit-details-marker {
  display: none;
}

.admin-panel > summary::after {
  content: "+";
  font-size: 20px;
  color: var(--muted);
}

.admin-panel[open] > summary::after {
  content: "–";
}

.admin-panel .panel-body {
  padding: 0 20px 20px;
  display: grid;
  gap: 14px;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #e8dfcf;
  color: var(--sage-dark);
  margin-left: 8px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 640px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Profile page: media gallery for photo + video + audio */
.media-item .media-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: rgba(255, 253, 248, 0.92);
  background:
    linear-gradient(135deg, rgba(63, 81, 66, 0.9), rgba(164, 111, 103, 0.72)),
    radial-gradient(circle at 70% 20%, rgba(197, 155, 85, 0.5), transparent 36%);
}

.media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-kind-pill {
  position: absolute;
  top: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  background: rgba(23, 22, 19, 0.66);
  color: #fffdf8;
}

.media-glyph {
  font-family: Georgia, serif;
  font-size: 40px;
}

.av-block {
  display: grid;
  gap: 10px;
}

.av-block audio,
.av-block video {
  width: 100%;
  display: block;
  border-radius: var(--radius);
  background: #100f0d;
}

.av-block video {
  aspect-ratio: 16 / 9;
}

/* Comments / guestbook on profile */
.comment-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(248, 244, 236, 0.72);
}

.comment-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 8px;
}

.comment-card strong {
  color: var(--ink);
}

.comment-card time {
  color: var(--muted);
  font-size: 12px;
}

.comment-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* Upload control */
.upload-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.upload-progress {
  height: 6px;
  border-radius: 999px;
  background: #e8dfcf;
  overflow: hidden;
}

.upload-progress > span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--sage-dark);
  transition: width 140ms ease;
}

.muted-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--rose);
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
}

.detail-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.detail-list div {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.9);
}

.detail-list dt {
  color: var(--sage-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-list dd {
  margin: 0;
  color: var(--ink);
}
