:root {
  --fc-bg: #f7f4ef;
  --fc-surface: #ffffff;
  --fc-ink: #2c2416;
  --fc-muted: #6b6256;
  --fc-accent: #8b5e3c;
  --fc-accent-dark: #6f4a2f;
  --fc-border: #e6dfd4;
  --fc-success: #2f6b4f;
  --fc-danger: #9b3b3b;
  --fc-radius: 0.85rem;
  --fc-shadow: 0 10px 30px rgba(44, 36, 22, 0.08);
}

html, body {
  min-height: 100%;
}

body.app-body {
  background:
    radial-gradient(circle at top left, rgba(139, 94, 60, 0.08), transparent 28%),
    linear-gradient(180deg, #fbf8f3 0%, var(--fc-bg) 100%);
  color: var(--fc-ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* Room for logo that slightly overlaps below the compact navbar */
body.app-body > main.container {
  padding-top: 1.75rem;
}

body.guest-body {
  background:
    radial-gradient(circle at 20% 20%, rgba(139, 94, 60, 0.12), transparent 35%),
    linear-gradient(160deg, #fbf8f3, #efe7db);
  color: var(--fc-ink);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

.navbar-family {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--fc-border);
  /* Keep the bar itself compact; logo can sit larger without stretching the bar */
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
  min-height: 3.5rem;
  overflow: visible;
  z-index: 1030;
}

.navbar-bar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-height: 3.25rem;
  width: 100%;
  gap: 0.5rem 1rem;
  position: relative;
}

/* Push title + user block to the far right of the bar */
.navbar-end-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  margin-left: auto;
  flex-shrink: 0;
  order: 4;
  z-index: 2;
}

.navbar-family .navbar-brand {
  order: 1;
  z-index: 2;
}

.navbar-family .navbar-toggler {
  order: 3;
  margin-left: 0;
  z-index: 2;
}

.navbar-family .navbar-collapse {
  order: 5;
  flex-basis: 100%;
}

/* Primary app sections — centered in the top bar (Photos / Genealogy / …) */
.navbar-section-tabs {
  order: 2;
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.2rem;
  border-radius: 999px;
  background: #f1e9df;
  border: 1px solid var(--fc-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
  z-index: 2;
}

.section-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.38rem 1.15rem;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fc-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.section-tab:hover,
.section-tab:focus {
  color: var(--fc-accent-dark);
  text-decoration: none;
}

.section-tab.is-active {
  background: #fff;
  color: var(--fc-accent-dark);
  box-shadow: 0 2px 8px rgba(44, 36, 22, 0.1);
}

@media (min-width: 992px) {
  /* True optical center between logo and site title */
  .navbar-section-tabs {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    order: unset;
  }

  .navbar-family .navbar-collapse {
    display: none !important;
  }

  .navbar-family .navbar-toggler {
    display: none;
  }

  .navbar-end-block {
    order: 3;
  }
}

.navbar-brand {
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--fc-accent-dark) !important;
}

.navbar-brand-logo {
  padding-top: 0;
  padding-bottom: 0;
  margin-right: 1rem;
  line-height: 0;
  /* Let the tall logo hang outside the thin bar without forcing bar height */
  position: relative;
  z-index: 1031;
  align-self: center;
}

/* Keep large logo; negative margins cancel most of its layout height */
.navbar-logo {
  display: block;
  height: 120px;
  width: auto;
  max-width: 280px;
  object-fit: contain;
  margin-top: -2.4rem;
  margin-bottom: -2.4rem;
}

.navbar-site-title {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--fc-accent-dark);
  white-space: nowrap;
  font-size: 1.15rem;
  line-height: 1.2;
  display: block;
}

@media (max-width: 991.98px) {
  .navbar-logo {
    height: 72px;
    max-width: 170px;
    margin-top: -1.1rem;
    margin-bottom: -1.1rem;
  }

  .navbar-end-block {
    /* Keep title visible on the right; user/logout live in the menu */
    max-width: 42%;
  }

  .navbar-site-title {
    font-size: 0.95rem;
    white-space: normal;
    text-align: right;
  }

  .navbar-section-tabs {
    /* Sit between logo and toggler on one row when space allows */
    margin-left: auto;
    margin-right: 0.25rem;
  }

  .section-tab {
    padding: 0.32rem 0.75rem;
    font-size: 0.82rem;
  }
}

@media (max-width: 575.98px) {
  .navbar-logo {
    height: 56px;
    max-width: 130px;
    margin-top: -0.75rem;
    margin-bottom: -0.75rem;
  }

  .navbar-section-tabs {
    order: 5;
    flex-basis: 100%;
    justify-content: center;
    margin: 0.15rem 0 0;
  }

  .navbar-end-block {
    max-width: 50%;
  }
}

.nav-link.active {
  color: var(--fc-accent-dark) !important;
  font-weight: 600;
}

.card-soft {
  background: var(--fc-surface);
  border: 1px solid var(--fc-border);
  border-radius: var(--fc-radius);
  box-shadow: var(--fc-shadow);
}

.action-card {
  border-radius: var(--fc-radius);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.action-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(44, 36, 22, 0.12);
}

/* Primary CTA — matches filled "Help tag photos" button on gallery */
.action-card-primary {
  background: linear-gradient(145deg, var(--fc-accent) 0%, var(--fc-accent-dark) 100%);
  border: 1px solid var(--fc-accent-dark);
  box-shadow: 0 12px 28px rgba(111, 74, 47, 0.28);
  color: #fff;
}

.action-card-primary:hover {
  color: #fff;
  box-shadow: 0 16px 32px rgba(111, 74, 47, 0.35);
}

.action-card-primary .action-card-title {
  color: #fff;
  font-size: 1.1rem;
}

.action-card-primary .action-card-desc {
  color: rgba(255, 255, 255, 0.88);
}

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

.btn-family:hover,
.btn-family:focus {
  background: var(--fc-accent-dark);
  border-color: var(--fc-accent-dark);
  color: #fff;
}

/* Add person idle: white, not usable until "Add new" is chosen */
.btn-add-person-idle,
.btn-add-person-idle:disabled {
  background: #fff !important;
  border: 1px solid var(--fc-border) !important;
  color: #a89f92 !important;
  box-shadow: none !important;
  font-weight: 600;
  opacity: 1 !important;
  cursor: not-allowed !important;
  pointer-events: none;
}

/* After "Add new" is chosen — flash the birth year field */
.birth-year-ready {
  border-color: #2f6b4f !important;
  border-width: 2px !important;
  background: #f3faf6 !important;
  box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.25);
}

.birth-year-ready-pulse {
  animation: birth-year-blink 0.4s ease-in-out 5;
}

@keyframes birth-year-blink {
  0%, 100% {
    background: #e8f5ee !important;
    border-color: #2f6b4f !important;
    box-shadow: 0 0 0 4px rgba(47, 107, 79, 0.4);
    transform: scale(1.02);
  }
  50% {
    background: #f0d9b5 !important;
    border-color: #c4a574 !important;
    box-shadow: 0 0 0 10px rgba(240, 217, 181, 0.55);
    transform: scale(1.05);
  }
}

.btn-outline-family {
  color: var(--fc-accent-dark);
  border-color: var(--fc-accent);
}

.btn-outline-family:hover {
  background: var(--fc-accent);
  border-color: var(--fc-accent);
  color: #fff;
}

.navbar-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  color: inherit;
}

.navbar-user-chip:hover .navbar-user-link,
.navbar-user-chip:focus .navbar-user-link {
  color: var(--fc-accent);
  text-decoration: underline;
}

.navbar-user-chip:hover .navbar-user-avatar,
.navbar-user-chip:focus .navbar-user-avatar {
  filter: brightness(1.06);
}

.navbar-user-avatar.pedigree-avatar {
  flex: 0 0 1.85rem;
  width: 1.85rem;
  height: 1.85rem;
  min-height: 1.85rem;
  max-height: 1.85rem;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 0 1px rgba(139, 94, 60, 0.18);
}

.navbar-user-avatar .pedigree-avatar-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.navbar-user-avatar svg {
  width: 0.9rem;
  height: 0.9rem;
  display: block;
}

.navbar-user-link {
  color: var(--fc-accent-dark);
  text-decoration: none;
}

.navbar-user-link:hover,
.navbar-user-link:focus {
  color: var(--fc-accent);
  text-decoration: underline;
}

.text-muted-family {
  color: var(--fc-muted) !important;
}

.stat-pill {
  border-radius: 999px;
  background: #f1e9df;
  color: var(--fc-accent-dark);
  padding: 0.35rem 0.8rem;
  font-size: 0.9rem;
  font-weight: 600;
  display: inline-block;
}

a.stat-pill:hover {
  background: #e6d9c8;
  color: var(--fc-accent-dark);
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.85rem;
}

/* Home page strips: prefer a single row of ~7 thumbs */
.photo-grid-strip {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

@media (max-width: 991.98px) {
  .photo-grid-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 575.98px) {
  .photo-grid-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.photo-tile {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 0.75rem;
  border: 1px solid var(--fc-border);
  background: #efe8de;
}

.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.photo-tile:hover img {
  transform: scale(1.04);
}

.photo-tile .badge-tag,
.photo-tile .badge-year {
  position: absolute;
  bottom: 0.4rem;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border-radius: 999px;
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  line-height: 1.2;
}

.photo-tile .badge-tag {
  left: 0.4rem;
}

.photo-tile .badge-year {
  right: 0.4rem;
}

/* Person photo timeline (vertical line) */
.photo-timeline {
  position: relative;
  margin: 0;
  padding: 0 0 1rem 0;
}

.photo-timeline-year {
  position: relative;
  margin: 0.35rem 0 0.65rem;
  padding-left: 2.15rem;
}

.photo-timeline-year-label {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fc-accent-dark);
  background: #f3ebe2;
  border: 1px solid var(--fc-border);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
}

.photo-timeline-item {
  position: relative;
  display: flex;
  gap: 0.85rem;
  padding: 0 0 1.35rem 0;
}

.photo-timeline-item:last-child {
  padding-bottom: 0.25rem;
}

.photo-timeline-rail {
  position: relative;
  flex: 0 0 1.5rem;
  width: 1.5rem;
}

/* Continuous vertical string */
.photo-timeline-rail::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: -1.35rem;
  width: 2px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, var(--fc-accent) 0%, #c4a484 100%);
  opacity: 0.55;
}

.photo-timeline-item:last-child .photo-timeline-rail::before {
  bottom: 50%;
}

.photo-timeline-dot {
  position: absolute;
  left: 50%;
  top: 1.35rem;
  width: 0.72rem;
  height: 0.72rem;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--fc-accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(139, 94, 60, 0.35);
  z-index: 1;
}

.photo-timeline-card {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 0.9rem;
  align-items: stretch;
  text-decoration: none;
  color: inherit;
  background: var(--fc-surface);
  border: 1px solid var(--fc-border);
  border-radius: var(--fc-radius);
  box-shadow: var(--fc-shadow);
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.photo-timeline-card:hover {
  transform: translateY(-1px);
  border-color: #d4c4b0;
  box-shadow: 0 14px 28px rgba(44, 36, 22, 0.1);
  color: inherit;
}

.photo-timeline-thumb {
  flex: 0 0 7.5rem;
  width: 7.5rem;
  background: #efe8de;
  align-self: stretch;
}

.photo-timeline-thumb img {
  width: 100%;
  height: 100%;
  min-height: 5.5rem;
  max-height: 7.5rem;
  object-fit: cover;
  display: block;
}

.photo-timeline-meta {
  flex: 1;
  min-width: 0;
  padding: 0.75rem 0.95rem 0.75rem 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.2rem;
}

.photo-timeline-date {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--fc-accent-dark);
  letter-spacing: 0.01em;
}

.photo-timeline-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--fc-ink);
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.photo-timeline-location {
  font-size: 0.9rem;
  color: var(--fc-muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.photo-timeline-empty {
  font-style: italic;
}

@media (max-width: 575.98px) {
  .photo-timeline-thumb {
    flex-basis: 5.5rem;
    width: 5.5rem;
  }

  .photo-timeline-thumb img {
    max-height: 5.5rem;
    min-height: 5rem;
  }

  .photo-timeline-meta {
    padding-right: 0.65rem;
  }
}

.photo-title-toolbar {
  width: 100%;
}

.photo-title-block {
  min-width: 0;
  max-width: 100%;
}

.photo-title-text {
  color: var(--fc-ink);
  font-weight: 600;
  max-width: 100%;
}

.photo-title-display .text-muted-family {
  font-style: italic;
}

.photo-title-edit-form .form-control {
  min-width: 10rem;
  max-width: 22rem;
}

.photo-stage-wrap {
  width: 100%;
}

.photo-comment-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: 22rem;
  overflow-y: auto;
}

.photo-comment {
  padding: 0.65rem 0.75rem;
  background: #fbf8f3;
  border: 1px solid var(--fc-border);
  border-radius: 0.65rem;
}

.photo-comment-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.35rem;
}

.photo-comment-author {
  color: var(--fc-accent-dark);
  font-size: 0.95rem;
}

.photo-comment-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
  line-height: 1.45;
}

.photo-fs-root {
  position: relative;
  width: 100%;
}

.photo-stage {
  position: relative;
  display: block;
  max-width: 100%;
  line-height: 0;
  border-radius: var(--fc-radius);
  overflow: visible; /* keep name labels above boxes visible */
  background: #1d1812;
  user-select: none;
  touch-action: none;
  cursor: crosshair;
  width: 100%;
}

.photo-hero {
  max-height: min(72vh, 820px);
  width: 100%;
  height: auto;
  object-fit: contain;
  background: #1d1812;
  border-radius: var(--fc-radius);
  display: block;
  pointer-events: none;
}

/* Full-screen photo: no tags, max size */
.photo-fs-exit {
  display: none;
}

.photo-fs-root:fullscreen,
.photo-fs-root:-webkit-full-screen {
  background: #0a0908;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  cursor: zoom-out;
}

.photo-fs-root:fullscreen .photo-stage,
.photo-fs-root:-webkit-full-screen .photo-stage {
  width: 100%;
  height: 100%;
  max-width: none;
  border-radius: 0;
  overflow: hidden;
  cursor: zoom-out;
  background: #0a0908;
}

.photo-fs-root:fullscreen .photo-hero,
.photo-fs-root:-webkit-full-screen .photo-hero {
  max-height: 100vh;
  max-width: 100vw;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
  background: #0a0908;
}

.photo-fs-root:fullscreen .tag-overlay,
.photo-fs-root:fullscreen .tag-box,
.photo-fs-root:fullscreen .tag-box-draft,
.photo-fs-root:-webkit-full-screen .tag-overlay,
.photo-fs-root:-webkit-full-screen .tag-box,
.photo-fs-root:-webkit-full-screen .tag-box-draft {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

.photo-fs-root:fullscreen .photo-fs-exit,
.photo-fs-root:-webkit-full-screen .photo-fs-exit {
  display: block;
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.tag-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.tag-box {
  position: absolute;
  border: 2px solid rgba(255, 236, 200, 0.95);
  border-radius: 0.35rem;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(0, 0, 0, 0.25);
  background: rgba(139, 94, 60, 0.12);
  pointer-events: none;
  box-sizing: border-box;
}

.tag-box-draft {
  border-style: dashed;
  border-color: #f0d9b5;
  background: rgba(240, 217, 181, 0.18);
  z-index: 5;
}

.tag-box-saved {
  z-index: 3;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

/* Show tags only while the pointer is over the photo, or when a chip highlights one */
.photo-stage:hover .tag-box-saved,
.photo-stage:focus-within .tag-box-saved,
.photo-stage.is-touch-reveal .tag-box-saved,
.tag-box-saved.is-active {
  opacity: 1;
  visibility: visible;
}

/* While drawing or holding a new face box, hide saved tags so they don't get in the way */
.photo-stage.is-placing-tag .tag-box-saved,
.photo-stage.is-placing-tag:hover .tag-box-saved,
.photo-stage.is-placing-tag:focus-within .tag-box-saved,
.photo-stage.is-placing-tag.is-touch-reveal .tag-box-saved,
.photo-stage.is-placing-tag .tag-box-saved.is-active {
  opacity: 0 !important;
  visibility: hidden !important;
}

.tag-box-saved.is-active {
  border-color: #fff;
  background: rgba(139, 94, 60, 0.28);
  z-index: 4;
}

.tag-box-label {
  position: absolute;
  left: 0;
  bottom: 100%;
  margin-bottom: 3px;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(44, 36, 22, 0.88);
  color: #fff;
  font-size: 0.72rem;
  line-height: 1.2;
  padding: 0.15rem 0.4rem;
  border-radius: 0.3rem;
  pointer-events: none;
}

.tag-loc-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--fc-accent);
  display: inline-block;
}

.tag-chip-located {
  cursor: default;
}

.tag-chip.is-active {
  outline: 2px solid var(--fc-accent);
  background: #e8d9c8;
}

#tag-location-status.has-box {
  color: var(--fc-success);
  font-weight: 600;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #f1e9df;
  border: 1px solid var(--fc-border);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  margin: 0.15rem;
  font-size: 0.9rem;
}

.tag-search-wrap {
  position: relative;
  z-index: 30;
}

.suggest-list {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  background: #fff;
  border: 2px solid var(--fc-accent);
  border-radius: 0.5rem;
  box-shadow: 0 8px 24px rgba(44, 36, 22, 0.18), 0 0 0 1px rgba(139, 94, 60, 0.12);
  max-height: 240px;
  overflow: auto;
}

.suggest-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0.55rem 0.75rem;
}

.suggest-item:hover,
.suggest-item:focus {
  background: #f7f1ea;
}

.suggest-year {
  display: inline-block;
  font-weight: 700;
  color: var(--fc-accent-dark);
  background: #f1e9df;
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  font-size: 0.8rem;
  margin-left: 0.15rem;
}

.suggest-item-create {
  border-top: 1px solid var(--fc-border);
  color: var(--fc-accent-dark);
  background: #fbf6f0;
}

.suggest-item-create:hover,
.suggest-item-create:focus {
  background: #f3e8db;
}

.login-card {
  width: min(420px, 100%);
}

.dropzone {
  border: 2px dashed #cbb9a4;
  border-radius: var(--fc-radius);
  background: #fbf8f3;
  padding: 2rem 1rem;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
  cursor: pointer;
}

.dropzone.dragover {
  border-color: var(--fc-accent);
  background: #f3ebe2;
}

.dropzone.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.upload-progress-track {
  height: 0.65rem;
  border-radius: 999px;
  background: #efe8de;
  border: 1px solid var(--fc-border);
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--fc-accent) 0%, var(--fc-accent-dark) 100%);
  transition: width 0.15s ease;
}

#upload-submit.is-uploading {
  opacity: 0.85;
  cursor: wait;
}

.queue-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #fff8ef;
  border-bottom: 1px solid var(--fc-border);
  padding: 0.65rem 0;
}

.family-table td {
  vertical-align: middle;
}

/* Square chip on family list — override pedigree-avatar height:100% / min-height */
.family-list-avatar.pedigree-avatar {
  flex: 0 0 2.4rem;
  width: 2.4rem;
  height: 2.4rem;
  min-height: 2.4rem;
  max-height: 2.4rem;
  border-radius: 0.45rem;
  overflow: hidden;
  text-decoration: none;
  align-self: center;
}

.family-list-avatar .pedigree-avatar-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.family-list-avatar svg {
  width: 1.15rem;
  height: 1.15rem;
}

.family-list-avatar:hover,
.family-list-avatar:focus {
  filter: brightness(1.06);
  text-decoration: none;
  color: #fff;
}

/* Genealogy icon buttons on family list (between photos & edit) */
.family-list-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0.2rem;
  vertical-align: middle;
  line-height: 1;
}

.family-list-icon {
  width: 1.15rem;
  height: 1.15rem;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

/* Genealogy subnav + pedigree */
.genealogy-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.genealogy-subnav-item {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--fc-border);
  background: #fff;
  color: var(--fc-muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.genealogy-subnav-item:hover,
.genealogy-subnav-item:focus {
  color: var(--fc-accent-dark);
  border-color: #d4c4b0;
  text-decoration: none;
}

.genealogy-subnav-item.is-active {
  background: var(--fc-accent);
  border-color: var(--fc-accent-dark);
  color: #fff;
}

.pedigree-shell {
  min-height: 28rem;
}

.pedigree-controls {
  background: #fbf8f3;
}

.pedigree-viewport {
  position: relative;
  height: min(78vh, 720px);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background:
    radial-gradient(circle at 20% 20%, rgba(139, 94, 60, 0.05), transparent 40%),
    linear-gradient(180deg, #fdfbf8 0%, #f7f4ef 100%);
  user-select: none;
}

.pedigree-viewport.is-panning {
  cursor: grabbing;
}

.pedigree-world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.pedigree-lines {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  pointer-events: none;
}

.pedigree-cards {
  position: absolute;
  left: 0;
  top: 0;
}

.pedigree-card {
  position: absolute;
  display: flex;
  align-items: stretch;
  width: 11.5rem;
  height: 3.65rem;
  background: #fff;
  border: 1px solid var(--fc-border);
  border-radius: 0.55rem;
  box-shadow: 0 4px 14px rgba(44, 36, 22, 0.08);
  overflow: hidden;
  color: inherit;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.pedigree-card:hover {
  border-color: #d4c4b0;
  box-shadow: 0 8px 20px rgba(44, 36, 22, 0.12);
  transform: translateY(-1px);
}

.pedigree-card.is-focus {
  border-color: var(--fc-accent);
  box-shadow: 0 0 0 2px rgba(139, 94, 60, 0.25), 0 8px 20px rgba(44, 36, 22, 0.1);
}

.pedigree-card.is-spouse {
  border-color: #a89070;
  box-shadow: 0 0 0 1px rgba(168, 144, 112, 0.35), 0 4px 14px rgba(44, 36, 22, 0.08);
}

.pedigree-card.is-child {
  border-style: solid;
}

.pedigree-line-spouse {
  stroke: #b5a48f;
  stroke-dasharray: 4 3;
}

.pedigree-avatar {
  flex: 0 0 2.65rem;
  width: 2.65rem;
  height: 100%;
  min-height: 3.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-decoration: none;
  transition: filter 0.15s ease;
  overflow: hidden;
}

/* Square profile preview on person edit (matches tree avatar width) */
.profile-avatar-preview {
  flex: 0 0 2.65rem;
  width: 2.65rem;
  height: 2.65rem;
  min-height: 2.65rem;
  border-radius: 0.45rem;
  overflow: hidden;
}

.profile-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pedigree-avatar-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pedigree-avatar:hover,
.pedigree-avatar:focus {
  color: #fff;
  filter: brightness(1.08);
  text-decoration: none;
}

.pedigree-avatar-male {
  background: linear-gradient(160deg, #5b8fc7 0%, #3d6fa3 100%);
}

.pedigree-avatar-female {
  background: linear-gradient(160deg, #a57bb8 0%, #7a4f96 100%);
}

.pedigree-avatar-other {
  background: linear-gradient(160deg, #9a9084 0%, #6f675c 100%);
}

.pedigree-avatar svg {
  width: 1.35rem;
  height: 1.35rem;
  display: block;
}

.pedigree-meta {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.55rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.1rem;
}

.pedigree-name {
  display: block;
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.2;
  color: var(--fc-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
}

.pedigree-name:hover,
.pedigree-name:focus {
  color: var(--fc-accent-dark);
  text-decoration: underline;
}

.pedigree-years {
  font-size: 0.72rem;
  color: var(--fc-muted);
  letter-spacing: 0.01em;
}

.pedigree-line {
  fill: none;
  stroke: #c4b5a3;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Relationship viewer */
.relationship-badge {
  display: inline-flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.55rem 1rem;
  background: #f3ebe2;
  border: 1px solid var(--fc-border);
  border-radius: var(--fc-radius);
}

.relationship-badge.is-missing {
  background: #f7f4ef;
}

.relationship-label {
  font-size: 1.15rem;
  color: var(--fc-accent-dark);
}

.relationship-shell {
  padding: 0;
  overflow: visible;
  background:
    radial-gradient(circle at 50% 0%, rgba(139, 94, 60, 0.05), transparent 50%),
    linear-gradient(180deg, #fdfbf8 0%, #f7f4ef 100%);
}

.relationship-path-header {
  padding: 0.75rem 1.15rem;
  border-bottom: 1px solid var(--fc-border);
  background: #fbf8f3;
  font-size: 0.875rem;
  color: var(--fc-muted);
}

.relationship-path-header strong {
  color: var(--fc-accent-dark);
  font-weight: 650;
}

/* Single-column path (direct ancestors / descendants) */
.relationship-path-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.75rem 1.25rem 2rem;
  gap: 0;
  overflow: visible;
}

.relationship-connector {
  width: 2px;
  height: 1.75rem;
  background: #c4b5a3;
  border-radius: 1px;
  flex: 0 0 auto;
}

/* Peak layout: CA on top, two branches down (cousin / uncle / etc.) */
.relationship-peak {
  padding: 1.75rem 1rem 2rem;
  overflow-x: auto;
}

.relationship-peak-ca {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
}

/* Two shared parents (or other co-CA couple) on one horizontal line */
.relationship-ca-couple {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  gap: 0;
  flex: 0 0 auto;
}

.relationship-ca-couple .relationship-card {
  width: 16rem;
  min-width: 16rem;
  max-width: 16rem;
  align-self: center;
}

/* T-junction: horizontal between co-CAs, vertical down into the fork stem */
.relationship-ca-couple-join {
  position: relative;
  flex: 0 0 1.75rem;
  width: 1.75rem;
  align-self: stretch;
  min-height: 3.65rem;
}

.relationship-ca-couple-h {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  background: #c4b5a3;
  border-radius: 1px;
  transform: translateY(-50%);
}

.relationship-ca-couple-v {
  position: absolute;
  left: 50%;
  top: 50%;
  bottom: 0;
  width: 2px;
  background: #c4b5a3;
  border-radius: 1px;
  transform: translateX(-50%);
}

.relationship-peak-fork {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(100%, 28rem);
  margin-top: 0;
}

/* Stem continues from couple T-junction, then splits to both branches */
.relationship-peak-fork-couple {
  width: min(100%, 34rem);
}

.relationship-peak-fork-couple .relationship-peak-stem {
  /* seamless continuation of couple-v (no gap under the cards) */
  margin-top: 0;
}

.relationship-peak-stem {
  width: 2px;
  height: 1.1rem;
  background: #c4b5a3;
  border-radius: 1px;
}

.relationship-peak-bar {
  width: 100%;
  max-width: 22rem;
  height: 2px;
  background: #c4b5a3;
  border-radius: 1px;
}

.relationship-peak-fork-couple .relationship-peak-bar {
  max-width: 34rem;
}

.relationship-peak-branches {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
  width: min(100%, 40rem);
  margin: 0 auto;
  align-items: start;
}

.relationship-peak-branch {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.relationship-branch-leg {
  width: 2px;
  height: 1.1rem;
  background: #c4b5a3;
  border-radius: 1px;
  flex: 0 0 auto;
}

/* Fixed card size everywhere in the relationship chart (including via-child / spouse).
   Note: stacks are flex-direction:column — do not use flex-basis for width. */
.relationship-card {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  box-sizing: border-box;
  width: 16rem;
  min-width: 16rem;
  max-width: 16rem;
  height: 3.65rem;
  min-height: 3.65rem;
  max-height: 3.65rem;
  background: #fff;
  border: 1px solid var(--fc-border);
  border-radius: 0.55rem;
  box-shadow: 0 4px 14px rgba(44, 36, 22, 0.08);
  overflow: visible;
  flex: 0 0 auto; /* height from height: above, not flex-basis */
}

.relationship-card .pedigree-avatar {
  border-radius: 0.55rem 0 0 0.55rem;
  overflow: hidden;
  min-height: 3.65rem;
  height: 3.65rem;
  flex: 0 0 2.65rem;
}

.relationship-card.is-start,
.relationship-card.is-relative {
  border-color: var(--fc-accent);
  box-shadow: 0 0 0 2px rgba(139, 94, 60, 0.22), 0 8px 18px rgba(44, 36, 22, 0.1);
}

.relationship-card.is-common {
  border-color: #8a734f;
  box-shadow: 0 0 0 2px rgba(138, 115, 79, 0.2), 0 8px 18px rgba(44, 36, 22, 0.08);
}

.relationship-card.is-spouse {
  border-color: #a89070;
  box-shadow: 0 0 0 1px rgba(168, 144, 112, 0.35), 0 4px 14px rgba(44, 36, 22, 0.08);
}

/*
 * Spouse-via-child layout:
 * - Co-parent stays on the main stem (peak fork aims at Danielle)
 * - Spouse floats to the right at the same generation (no bar between co-parents)
 * - Elbow from proxy child: right, then up to spouse
 */
.relationship-peak {
  overflow-x: auto;
  overflow-y: visible;
}

.relationship-peak-branch-relative {
  overflow: visible;
  /* Keep main stem centered under the fork; spouse hangs outside */
  position: relative;
}

.relationship-coparent-slot,
.relationship-proxy-child-slot {
  position: relative;
  flex: 0 0 auto;
  width: 16rem;
  min-width: 16rem;
  max-width: 16rem;
  /* Main card only — spouse/elbow are out of flow so fork centering is unchanged */
}

.relationship-spouse-float {
  position: absolute;
  left: calc(100% + 2.75rem);
  top: 0;
  z-index: 2;
  width: 16rem;
}

/* From child mid-right: horizontal out, then vertical up to spouse mid */
.relationship-spouse-elbow {
  position: absolute;
  left: 100%;
  top: 50%;
  /* half child + connector + half co-parent card */
  width: 2.75rem;
  height: calc(3.65rem * 0.5 + 1.75rem + 3.65rem * 0.5);
  border-right: 2px solid #b5a48f;
  border-bottom: 2px solid #b5a48f;
  border-radius: 0 0 2px 0;
  box-sizing: border-box;
  transform: translateY(-100%);
  pointer-events: none;
  z-index: 1;
}

/* Short stub into the left edge of the spouse card */
.relationship-spouse-float::before {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  width: 0.35rem;
  height: 2px;
  background: #b5a48f;
  transform: translateY(-50%);
  pointer-events: none;
}

.relationship-role {
  position: absolute;
  left: 50%;
  top: -0.95rem;
  transform: translateX(-50%);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--fc-muted);
  white-space: nowrap;
  background: #fdfbf8;
  padding: 0 0.35rem;
  z-index: 2;
  line-height: 1.2;
}

@media (max-width: 640px) {
  .relationship-peak-branches {
    grid-template-columns: 1fr;
    width: min(100%, 18rem);
  }

  .relationship-peak-bar {
    display: none;
  }

  .relationship-peak-branch + .relationship-peak-branch {
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px dashed #d4c4b0;
  }

  /* On narrow screens, stack spouse under co-parent instead of floating */
  .relationship-spouse-float {
    position: static;
    left: auto;
    top: auto;
    margin-top: 0.65rem;
    display: flex;
    justify-content: center;
  }

  .relationship-spouse-float::before {
    display: none;
  }

  .relationship-spouse-elbow {
    display: none;
  }

  .relationship-coparent-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
}

.flash-wrap {
  max-width: 960px;
}
