:root {
  --ink: #172322;
  --muted: #61706b;
  --paper: #fbf8ef;
  --cream: #f3ead8;
  --forest: #16483d;
  --teal: #1d6a73;
  --coral: #c45745;
  --gold: #c69b4c;
  --blue: #425f8c;
  --line: #ded5c4;
  --white: #ffffff;
  --shadow: 0 20px 60px rgba(23, 35, 34, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(18px, 4vw, 56px);
  color: var(--white);
  background: rgba(15, 30, 30, 0.9);
  backdrop-filter: blur(16px);
}

.is-locked {
  overflow: hidden;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark,
.avatar,
.profile-initials {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: var(--white);
  background: linear-gradient(135deg, var(--forest), var(--coral));
  font-weight: 800;
}

.brand-mark {
  width: 42px;
  height: 42px;
  font-size: 0.82rem;
}

.brand small {
  display: block;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.74rem;
}

nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

nav a {
  padding: 8px 10px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.92rem;
}

nav a:hover,
nav a:focus-visible {
  color: var(--white);
}

.user-session {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.88rem;
  font-weight: 800;
}

.header-button {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--white);
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  font-weight: 800;
}

.header-button.light {
  color: var(--forest);
  border-color: rgba(22, 72, 61, 0.22);
  background: rgba(22, 72, 61, 0.08);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(22, 72, 61, 0.22);
  border-radius: 8px;
  color: var(--forest);
  background: rgba(22, 72, 61, 0.08);
  cursor: pointer;
  font-weight: 900;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 28px;
  overflow-y: auto;
  color: var(--white);
  background:
    linear-gradient(90deg, rgba(10, 20, 19, 0.92), rgba(10, 20, 19, 0.72)),
    url("assets/genealogy-hero.png") center / cover;
}

.auth-gate[hidden] {
  display: none;
}

.auth-panel {
  width: min(1040px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  padding: clamp(22px, 4vw, 42px);
  background: rgba(16, 24, 23, 0.82);
  box-shadow: var(--shadow);
}

.auth-panel h1 {
  max-width: 860px;
  font-size: clamp(2.5rem, 6vw, 5.4rem);
}

.auth-panel > p {
  max-width: 720px;
  color: rgba(255, 255, 255, 0.78);
}

.auth-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 18px;
  margin-top: 26px;
}

.auth-grid form {
  display: grid;
  gap: 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.09);
}

.auth-grid h2,
.edit-form h3 {
  margin-bottom: 4px;
  font-family: Georgia, "Times New Roman", serif;
}

.auth-grid label {
  display: grid;
  gap: 8px;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 800;
}

.auth-grid input {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--white);
  background: rgba(255, 255, 255, 0.1);
}

.auth-message {
  min-height: 22px;
  margin: 16px 0 0;
  color: #f3c17c;
  font-weight: 800;
}

.hero {
  position: relative;
  min-height: 86vh;
  display: grid;
  align-items: end;
  padding: 108px clamp(18px, 5vw, 72px) 76px;
  overflow: hidden;
  color: var(--white);
}

.hero-image,
.hero-overlay {
  position: absolute;
  inset: 0;
}

.hero-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-overlay {
  background:
    linear-gradient(90deg, rgba(10, 20, 19, 0.84), rgba(10, 20, 19, 0.48) 48%, rgba(10, 20, 19, 0.12)),
    linear-gradient(0deg, rgba(10, 20, 19, 0.72), rgba(10, 20, 19, 0.04) 44%);
}

.hero-content {
  position: relative;
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--coral);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero .eyebrow {
  color: #f3c17c;
}

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

h1 {
  max-width: 780px;
  margin-bottom: 18px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3rem, 7vw, 6.7rem);
  line-height: 0.94;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.08rem;
  line-height: 1.2;
}

.hero-copy {
  max-width: 630px;
  color: rgba(255, 255, 255, 0.86);
  font-size: clamp(1rem, 1.5vw, 1.22rem);
}

.hero-actions,
.tool-row,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.button.primary {
  color: var(--white);
  background: var(--coral);
}

.button.secondary {
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.12);
}

.button.secondary.dark {
  color: var(--white);
  background: rgba(255, 255, 255, 0.08);
}

.button.compact {
  min-height: 38px;
  padding: 8px 12px;
  color: var(--forest);
  border-color: rgba(22, 72, 61, 0.24);
  background: rgba(22, 72, 61, 0.08);
}

.button.danger-soft {
  color: #8b2f26;
  border-color: rgba(196, 87, 69, 0.28);
  background: rgba(196, 87, 69, 0.1);
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-block: 1px solid var(--line);
}

.summary-band div {
  padding: 24px clamp(18px, 4vw, 42px);
  background: var(--white);
}

.summary-band strong {
  display: block;
  color: var(--forest);
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
}

.summary-band span {
  color: var(--muted);
  font-weight: 700;
}

.section-shell,
.timeline-section {
  padding: 78px clamp(18px, 4vw, 56px);
}

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

.section-heading p:not(.eyebrow) {
  color: var(--muted);
  font-size: 1.04rem;
}

.tool-row {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.search-field {
  flex: 1 1 300px;
}

.search-field input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--ink);
  background: var(--white);
  outline: none;
}

.search-field input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(29, 106, 115, 0.14);
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--white);
}

.segment {
  min-height: 44px;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.segment:last-child {
  border-right: 0;
}

.segment.is-active {
  color: var(--white);
  background: var(--forest);
}

.generation-heading {
  margin-top: 54px;
}

.tree-layout.generation-browser {
  display: block;
  height: min(82vh, 880px);
}

.tree-board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 188px;
  align-items: start;
  gap: 12px;
  height: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  overflow-x: auto;
  overflow-y: auto;
  padding: 12px;
  overscroll-behavior: contain;
}

.generation-column {
  min-width: 188px;
  max-width: 188px;
  display: grid;
  grid-template-rows: auto auto;
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  box-shadow: 0 12px 34px rgba(23, 35, 34, 0.08);
}

.generation-column header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.generation-column header strong {
  color: var(--coral);
  font-size: 1.15rem;
}

.person-stack {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow: visible;
  padding: 10px;
}

.person-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 9px;
  width: 100%;
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  text-align: left;
  background: var(--white);
  cursor: pointer;
}

.person-card:hover,
.person-card:focus-visible,
.person-card.is-selected {
  border-color: var(--teal);
  box-shadow: 0 10px 24px rgba(29, 106, 115, 0.14);
}

.person-card[draggable="true"] {
  cursor: grab;
}

.person-card.is-dragging {
  cursor: grabbing;
  opacity: 0.62;
}

.person-card.is-drop-target {
  border-color: var(--coral);
  background: rgba(196, 87, 69, 0.08);
  box-shadow: 0 0 0 4px rgba(196, 87, 69, 0.14);
}

.avatar {
  width: 38px;
  height: 38px;
  font-size: 0.7rem;
}

.photo-avatar,
.profile-photo {
  object-fit: cover;
}

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

.person-card small,
.person-card em {
  color: var(--muted);
  font-size: 0.76rem;
  font-style: normal;
}

.empty-generation {
  min-height: 86px;
  display: grid;
  place-items: center;
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.profile-panel {
  min-height: 0;
  height: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.profile-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(15, 30, 30, 0.22);
  opacity: 0;
  transition: opacity 180ms ease;
}

.profile-backdrop.is-open {
  opacity: 1;
}

.profile-panel.profile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 21;
  width: min(430px, calc(100vw - 28px));
  height: 100dvh;
  max-height: none;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  border-radius: 8px 0 0 8px;
  padding: 58px 22px 22px;
  transform: translateX(105%);
  transition: transform 200ms ease;
}

.profile-panel.profile-drawer.is-open {
  transform: translateX(0);
}

.profile-close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(22, 72, 61, 0.18);
  border-radius: 8px;
  color: var(--forest);
  background: rgba(22, 72, 61, 0.08);
  cursor: pointer;
  font-size: 1.45rem;
  line-height: 1;
  font-weight: 700;
}

.profile-close-button:hover,
.profile-close-button:focus-visible {
  border-color: rgba(22, 72, 61, 0.36);
  background: rgba(22, 72, 61, 0.14);
}

.lineage-view {
  margin-top: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(18px, 3vw, 26px);
  background: #fffdf8;
  box-shadow: 0 12px 34px rgba(23, 35, 34, 0.08);
}

.lineage-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.lineage-heading h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.9rem, 3vw, 2.8rem);
}

.lineage-heading span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.tree-zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.tree-zoom-controls output {
  min-width: 54px;
  color: var(--forest);
  font-size: 0.88rem;
  font-weight: 900;
  text-align: center;
}

.lineage-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  width: 250px;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  text-align: left;
  color: var(--ink);
  background: #fffdf8;
}

.lineage-card:not(.is-missing) {
  cursor: pointer;
}

.lineage-card:hover:not(.is-missing),
.lineage-card:focus-visible:not(.is-missing),
.lineage-card.is-focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(29, 106, 115, 0.12);
}

.lineage-card.is-focus {
  background: rgba(29, 106, 115, 0.08);
}

.lineage-card.is-spouse {
  background: rgba(66, 95, 140, 0.07);
}

.lineage-card.is-missing {
  display: grid;
  width: 250px;
  color: var(--muted);
  border-style: dashed;
  background: var(--paper);
}

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

.lineage-card small,
.lineage-card em {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
}

.branch-tree-scroll {
  height: min(74vh, 780px);
  min-height: 460px;
  overflow: auto;
  overscroll-behavior: contain;
  cursor: grab;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background:
    linear-gradient(90deg, rgba(251, 248, 239, 0.96), rgba(251, 248, 239, 0)) left / 28px 100% no-repeat,
    linear-gradient(270deg, rgba(251, 248, 239, 0.96), rgba(251, 248, 239, 0)) right / 28px 100% no-repeat,
    var(--paper);
}

.branch-tree-scroll.is-panning {
  cursor: grabbing;
  user-select: none;
}

.branch-tree-scroll .lineage-card,
.branch-tree-scroll button {
  cursor: pointer;
}

.branch-zoom-canvas {
  position: relative;
  min-width: 100%;
  min-height: 100%;
}

.branch-forest {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: start;
  justify-content: center;
  min-width: max-content;
  width: max-content;
  padding: 8px 24px 42px;
  transform-origin: top left;
}

.family-tree-list {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.family-root-list {
  gap: 36px;
}

.family-node {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 18px 0;
}

.family-root-list > .family-node {
  padding-top: 0;
}

.family-children {
  margin-top: 22px;
  padding-top: 34px;
}

.family-children::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  height: 34px;
  border-left: 2px solid rgba(22, 72, 61, 0.45);
}

.family-children > .family-node::before,
.family-children > .family-node::after {
  content: "";
  position: absolute;
  top: 0;
  width: 50%;
  height: 30px;
  border-top: 2px solid rgba(22, 72, 61, 0.45);
}

.family-children > .family-node::before {
  right: 50%;
}

.family-children > .family-node::after {
  left: 50%;
  border-left: 2px solid rgba(22, 72, 61, 0.45);
}

.family-children > .family-node:first-child::before,
.family-children > .family-node:last-child::after {
  border-top-color: transparent;
}

.family-children > .family-node:only-child::before {
  display: none;
}

.family-children > .family-node:only-child::after {
  left: 50%;
  width: 0;
  border-top: 0;
  border-left: 2px solid rgba(22, 72, 61, 0.45);
}

.family-marriage-stack {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 24px;
}

.family-marriage-stack.has-multiple-unions {
  border-top: 2px solid rgba(66, 95, 140, 0.22);
  padding-top: 18px;
}

.family-marriage-branch {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.family-marriage-stack.has-multiple-unions > .family-marriage-branch::before {
  content: "";
  position: absolute;
  top: -18px;
  left: 50%;
  height: 18px;
  border-left: 2px solid rgba(66, 95, 140, 0.22);
}

.family-unit {
  position: relative;
  z-index: 2;
  display: grid;
  justify-items: center;
}

.family-marriage-branch.has-children > .family-unit::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -22px;
  height: 22px;
  border-left: 2px solid rgba(22, 72, 61, 0.45);
}

.family-couple-row {
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid rgba(22, 72, 61, 0.08);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.86);
  box-shadow: 0 10px 22px rgba(23, 35, 34, 0.05);
}

.family-node.is-active-node .family-couple-row {
  background: rgba(29, 106, 115, 0.06);
}

.family-member-main,
.spouse-card-wrap {
  display: grid;
  gap: 6px;
  justify-items: center;
}

.spouse-card-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 540px;
}

.spouse-label {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--blue);
  background: rgba(66, 95, 140, 0.12);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.surname-focus-button {
  min-height: 30px;
  border: 1px solid rgba(66, 95, 140, 0.22);
  border-radius: 8px;
  padding: 4px 8px;
  color: var(--blue);
  background: rgba(66, 95, 140, 0.08);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 900;
}

.surname-focus-button:hover,
.surname-focus-button:focus-visible {
  border-color: rgba(66, 95, 140, 0.44);
  background: rgba(66, 95, 140, 0.14);
}


.profile-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}

.upload-button {
  position: relative;
  overflow: hidden;
}

.upload-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.photo-grid figure {
  margin: 0;
}

.photo-grid img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  object-fit: cover;
}

.photo-grid figcaption,
.last-updated span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
}

.last-updated {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.edit-form {
  display: grid;
  gap: 12px;
}

.edit-form label,
.relationship-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.edit-form input,
.edit-form textarea,
.edit-form select,
.relationship-form input,
.relationship-form select,
.profile-mini-form textarea,
.relative-dialog-form input,
.relative-dialog-form select,
.relative-dialog-form textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--white);
}

.edit-form textarea {
  min-height: 96px;
  resize: vertical;
}

.profile-mini-form {
  display: grid;
  gap: 10px;
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fffdf8;
}

.profile-mini-form h4 {
  margin: 0;
}

.profile-mini-form label,
.relative-dialog-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.profile-mini-form textarea,
.relative-dialog-form textarea {
  min-height: 112px;
  resize: vertical;
}

.relative-dialog-form {
  display: grid;
  gap: 12px;
  padding: clamp(18px, 4vw, 30px);
}

.relative-dialog-form h2 {
  font-size: clamp(1.8rem, 4vw, 2.7rem);
}

.admin-tool-copy {
  color: var(--muted);
}

.two-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.empty-profile {
  text-align: center;
}

.profile-header {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.profile-initials {
  width: 72px;
  height: 72px;
}

.profile-header p,
.profile-header span {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.profile-header h3 {
  margin: 2px 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.7rem;
}

.fact-list,
.record-card dl {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
}

.fact-list div,
.record-card dl div {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
}

dt {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 0;
}

.story-note {
  padding: 16px;
  border-left: 4px solid var(--gold);
  background: var(--paper);
}

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

.tag-row span,
.record-type {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--forest);
  background: rgba(22, 72, 61, 0.1);
  font-size: 0.78rem;
  font-weight: 800;
}

.relationship-groups {
  display: grid;
  gap: 14px;
}

.relationship-groups h4,
.source-list h4 {
  margin: 0 0 6px;
}

.relationship-groups p {
  margin: 0;
  color: var(--muted);
}

.relationship-form {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fffdf8;
}

.relationship-form h4 {
  margin: 0;
}

.relationship-form select[size] {
  min-height: 154px;
  padding: 6px;
}

.relationship-form button {
  justify-self: start;
}

.typed-relation {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.relationship-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.typed-relation span {
  min-width: 92px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.link-button {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  margin: 0 8px 8px 0;
  border: 1px solid rgba(29, 106, 115, 0.24);
  border-radius: 8px;
  padding: 5px 9px;
  color: var(--teal);
  background: rgba(29, 106, 115, 0.08);
  cursor: pointer;
  font-weight: 800;
}

.remove-relationship-button {
  min-height: 30px;
  border: 1px solid rgba(196, 87, 69, 0.24);
  border-radius: 8px;
  padding: 4px 8px;
  color: #8b2f26;
  background: rgba(196, 87, 69, 0.08);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
}

.remove-relationship-button:hover,
.remove-relationship-button:focus-visible {
  border-color: rgba(196, 87, 69, 0.48);
  background: rgba(196, 87, 69, 0.14);
}

.source-list {
  margin-top: 18px;
}

.source-list ul {
  margin: 0;
  padding-left: 20px;
}

.relationship-dialog {
  width: min(720px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: var(--white);
  box-shadow: var(--shadow);
}

.relationship-dialog::backdrop {
  background: rgba(10, 20, 19, 0.58);
  backdrop-filter: blur(3px);
}

.relationship-dialog form {
  padding: clamp(18px, 4vw, 30px);
}

.camera-dialog-content {
  display: grid;
  gap: 12px;
  padding: clamp(18px, 4vw, 30px);
}

.relationship-dialog h2 {
  font-size: clamp(1.8rem, 4vw, 2.7rem);
}

.dialog-copy {
  color: var(--muted);
}

.camera-device-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.camera-device-label select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--white);
}

.camera-preview {
  width: 100%;
  max-height: min(56vh, 520px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101817;
  object-fit: contain;
}

.camera-message {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.relationship-option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.relationship-option {
  display: grid;
  gap: 4px;
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  text-align: left;
  color: var(--ink);
  background: #fffdf8;
  cursor: pointer;
}

.relationship-option:hover,
.relationship-option:focus-visible {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(29, 106, 115, 0.12);
}

.relationship-option span {
  color: var(--muted);
  font-size: 0.86rem;
}

.timeline-section {
  background: #e7eef0;
}

.timeline-list {
  display: grid;
  max-width: 1000px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline-list li {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 22px;
  position: relative;
  padding: 0 0 30px;
}

.timeline-list li::before {
  content: "";
  position: absolute;
  left: 96px;
  top: 8px;
  bottom: 0;
  width: 2px;
  background: rgba(23, 35, 34, 0.18);
}

.timeline-list time {
  position: relative;
  z-index: 1;
  display: inline-grid;
  place-items: center;
  width: 86px;
  height: 44px;
  border-radius: 8px;
  color: var(--white);
  background: var(--blue);
  font-weight: 900;
}

.timeline-list div {
  border: 1px solid rgba(23, 35, 34, 0.1);
  border-radius: 8px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.72);
}

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

.admin-section[hidden] {
  display: none;
}

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

.admin-column {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--white);
  box-shadow: 0 12px 30px rgba(23, 35, 34, 0.08);
}

.admin-column h3 {
  margin-bottom: 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
}

.account-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fffdf8;
}

.account-card + .account-card {
  margin-top: 10px;
}

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

.account-card span,
.account-card small,
.self-note {
  color: var(--muted);
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.self-note {
  font-size: 0.78rem;
  font-weight: 800;
}

.audit-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.audit-card {
  border: 1px solid rgba(23, 35, 34, 0.1);
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.72);
}

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

.audit-card span,
.audit-card small {
  color: var(--muted);
}

.audit-card p {
  margin: 10px 0;
}

.record-card {
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: var(--white);
  box-shadow: 0 12px 30px rgba(23, 35, 34, 0.08);
}

.record-card h3 {
  margin-top: 18px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
}

.record-card p {
  color: var(--muted);
}

.help-section {
  background: #f7f1e5;
}

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

.help-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: var(--white);
  box-shadow: 0 12px 30px rgba(23, 35, 34, 0.08);
}

.help-card h3 {
  margin-bottom: 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
}

.instruction-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
}

.instruction-list li::marker {
  color: var(--coral);
  font-weight: 900;
}

.tip-box {
  max-width: 980px;
  margin-top: 18px;
  border-left: 4px solid var(--gold);
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.74);
}

.tip-box strong {
  display: block;
  margin-bottom: 4px;
}

.tip-box p {
  margin: 0;
  color: var(--muted);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 24px clamp(18px, 4vw, 56px);
  color: rgba(255, 255, 255, 0.72);
  background: #101817;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--white);
  font-weight: 800;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 1040px) {
  .auth-grid {
    grid-template-columns: 1fr;
  }

  .tree-layout.generation-browser {
    grid-template-columns: 1fr;
    height: auto;
  }

  .tree-board {
    height: min(68vh, 680px);
  }

  .profile-panel {
    height: auto;
    max-height: none;
  }

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

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .audit-list {
    grid-template-columns: 1fr;
  }

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

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

  nav {
    justify-content: flex-start;
  }

  .hero {
    min-height: 82vh;
    padding-top: 82px;
  }

  .hero-overlay {
    background:
      linear-gradient(90deg, rgba(10, 20, 19, 0.9), rgba(10, 20, 19, 0.45)),
      linear-gradient(0deg, rgba(10, 20, 19, 0.72), rgba(10, 20, 19, 0.1) 50%);
  }

  .summary-band {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .segmented-control {
    width: 100%;
  }

  .segment {
    flex: 1 1 130px;
    border-bottom: 1px solid var(--line);
  }

  .segment:last-child {
    border-bottom: 0;
  }

  .timeline-list li {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .timeline-list li::before {
    display: none;
  }

  .record-grid {
    grid-template-columns: 1fr;
  }

  .help-grid {
    grid-template-columns: 1fr;
  }

  .two-field-grid,
  .photo-grid,
  .relationship-option-grid {
    grid-template-columns: 1fr;
  }

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

  .tree-zoom-controls {
    flex-wrap: wrap;
  }

  .branch-tree-scroll {
    height: 68vh;
    min-height: 420px;
  }

  .lineage-card {
    width: 220px;
  }

  .spouse-card-stack {
    max-width: 240px;
  }

  .branch-forest {
    justify-content: flex-start;
  }

  .site-footer {
    flex-direction: column;
  }
}
