.branching-tree {
  --tree-graphite: #50524f;
  --tree-graphite-deep: #3f413e;
  --tree-paper: #fbfaf6;
  --tree-ink: #242a27;
  --tree-line: #bcc0b9;
  padding: clamp(20px, 2.4vw, 38px) clamp(14px, 2.2vw, 34px) clamp(54px, 6vw, 88px);
  background: #e8e7e0;
  color: var(--tree-ink);
}

.branching-tree-header {
  width: min(100%, 1900px);
  display: grid;
  grid-template-columns: minmax(300px, .9fr) minmax(430px, 1.15fr) auto;
  align-items: end;
  gap: clamp(24px, 3vw, 54px);
  margin: 0 auto clamp(18px, 2vw, 28px);
}

.branching-tree-title .family-eyebrow {
  margin-bottom: 7px;
  color: #6b746e;
  font-size: 8px;
}

.branching-tree-title h1 {
  margin: 0;
  color: #26312c;
  font-family: var(--title);
  font-size: clamp(44px, 4.4vw, 76px);
  font-weight: 520;
  letter-spacing: -.05em;
  line-height: .92;
}

.branching-tree-title > p:last-child {
  max-width: 530px;
  margin: 15px 0 0;
  color: #5f6963;
  font-family: var(--font-geist-sans), sans-serif;
  font-size: 13px;
  line-height: 1.55;
}

.branching-tree-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  padding: 5px;
  border: 1px solid rgba(37, 47, 42, .18);
  border-radius: 16px;
  background: rgba(255, 255, 255, .48);
}

.branching-tree-tabs button {
  min-height: 62px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: #5b6660;
  font-family: var(--font-geist-sans), sans-serif;
  font-size: 14px;
  font-weight: 720;
  text-align: left;
  cursor: pointer;
}

.branching-tree-tabs button span {
  color: #89918c;
  font-family: var(--utility);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.branching-tree-tabs button.active {
  border-color: rgba(255, 255, 255, .16);
  background: #343936;
  color: #fffdf7;
  box-shadow: 0 3px 9px rgba(43, 50, 46, .14);
}

.branching-tree-tabs button.active span {
  color: #b9c3bd;
}

.branching-tree-tabs button:focus,
.branching-tree-tools button:focus {
  outline: none;
}

.branching-tree-tabs button:focus-visible,
.branching-tree-tools button:focus-visible {
  outline: 2px solid #d2aa5f;
  outline-offset: 2px;
}

.branching-tree-summary {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 13px 28px;
  padding-bottom: 5px;
}

.branching-tree-summary span {
  display: grid;
  gap: 1px;
  color: #7a837d;
  font-family: var(--utility);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.branching-tree-summary strong {
  color: #38433d;
  font-family: var(--title);
  font-size: 22px;
  font-weight: 620;
  letter-spacing: -.02em;
}

.branching-tree-frame {
  position: relative;
  width: min(100%, 1900px);
  overflow: hidden;
  margin: 0 auto;
  border: 1px solid rgba(38, 43, 39, .78);
  border-radius: 22px;
  background: var(--tree-graphite);
  box-shadow: 0 24px 64px rgba(43, 49, 45, .2), 0 2px 6px rgba(43, 49, 45, .12);
}

.branching-tree-tools {
  position: relative;
  z-index: 8;
  min-height: 49px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 9px 11px 9px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  background: var(--tree-graphite-deep);
}

.branching-tree-tools > span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #ced2cc;
  font-family: var(--font-geist-sans), sans-serif;
  font-size: 11px;
}

.branching-tree-tools > div {
  display: flex;
  align-items: center;
  gap: 5px;
}

.branching-tree-tools button,
.branching-tree-tools output {
  min-width: 37px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 10px;
  background: rgba(255, 255, 255, .045);
  color: #eff1ec;
  font-family: var(--font-geist-sans), sans-serif;
  font-size: 10px;
}

.branching-tree-tools button {
  padding: 0 10px;
  cursor: pointer;
}

.branching-tree-tools output {
  min-width: 48px;
  border-color: transparent;
  background: transparent;
  color: #c1c6c0;
}

.branching-tree-tools button:disabled {
  opacity: .38;
  cursor: default;
}

.branching-tree-viewport {
  position: relative;
  height: clamp(680px, calc(100svh - 250px), 1260px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: #7f837d #454744;
  scrollbar-width: thin;
  background: #4c4f4b;
  cursor: grab;
  touch-action: none;
}

.branching-tree-viewport.dragging {
  cursor: grabbing;
  user-select: none;
}

.branching-tree-viewport:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .16);
}

.branching-tree-scaled {
  position: relative;
}

.branching-tree-canvas {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  transform-origin: top left;
  animation: branching-tree-arrive .34s ease-out both;
}

.branching-tree-canvas > svg {
  position: absolute;
  z-index: 1;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

.branching-family-line,
.branching-couple-line {
  fill: none;
  stroke: var(--tree-line);
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .88;
  vector-effect: non-scaling-stroke;
}

.branching-family-line {
  stroke-width: 2.25px;
}

.branching-couple-line {
  stroke-width: 2px;
}

.branching-tree-canvas.has-selection .branching-family-line,
.branching-tree-canvas.has-selection .branching-couple-line {
  opacity: .14;
}

.branching-tree-canvas.has-selection .branching-link--context {
  stroke: #dfe1da;
  opacity: .58;
}

.branching-tree-canvas.has-selection .branching-link--selected {
  stroke: #f0c873;
  stroke-width: 3px;
  opacity: 1;
}

.branching-generation-label {
  position: absolute;
  z-index: 2;
  left: 28px;
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 999px;
  background: rgba(53, 56, 52, .86);
  color: #d7dad4;
  font-family: var(--utility);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: .13em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.branching-person-card {
  position: absolute;
  z-index: 3;
  width: 126px;
  height: 164px;
  overflow: visible;
  padding: 0;
  border: 2px solid #f4f2ec;
  border-radius: 12px;
  background: var(--tree-paper);
  color: var(--tree-ink);
  text-align: left;
  box-shadow: 0 7px 18px rgba(20, 24, 21, .25), 0 1px 2px rgba(20, 24, 21, .18);
  cursor: pointer;
}

.branching-card-photo {
  width: 100%;
  height: 108px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 10px 10px 0 0;
  border-bottom: 1px solid #d8d8d1;
  background: #d9e1e3;
  color: #58717d;
}

.branching-person-card[data-sex="F"] .branching-card-photo {
  background: #e7d7cf;
  color: #9a6857;
}

.branching-person-card[data-sex="U"] .branching-card-photo {
  background: #dcded9;
  color: #707872;
}

.branching-card-photo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center 24%;
}

.branching-card-copy {
  height: 50px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 6px 9px 7px;
}

.branching-card-copy strong {
  display: -webkit-box;
  overflow: hidden;
  font-family: var(--font-geist-sans), sans-serif;
  font-size: 10px;
  font-weight: 760;
  letter-spacing: -.018em;
  line-height: 1.08;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.branching-card-copy small {
  color: #727a75;
  font-family: var(--font-geist-sans), sans-serif;
  font-size: 8px;
  line-height: 1;
}

.branching-direct-marker {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 13px;
  height: 13px;
  border: 3px solid var(--tree-graphite);
  border-radius: 50%;
  background: var(--branch-color);
}

.branching-person-card--root {
  border-bottom-color: var(--branch-color);
}

.branching-person-card[aria-pressed="true"] {
  z-index: 6;
  border-color: #f2c86f;
  box-shadow: 0 0 0 3px rgba(242, 200, 111, .3), 0 12px 26px rgba(20, 24, 21, .32);
}

.branching-tree-canvas.has-selection .branching-person-card {
  opacity: .28;
  filter: saturate(.5);
}

.branching-tree-canvas.has-selection .branching-person-card--context {
  opacity: .86;
  filter: none;
}

.branching-tree-canvas.has-selection .branching-person-card[aria-pressed="true"] {
  opacity: 1;
  filter: none;
}

.branching-tree-viewport.dragging .branching-person-card {
  cursor: grabbing;
  transform: none;
  transition: none;
}

.branching-tree-overview {
  position: absolute;
  z-index: 9;
  right: 18px;
  bottom: 61px;
  width: 210px;
  padding: 9px;
  border: 1px solid rgba(41, 47, 43, .24);
  border-radius: 15px;
  background: rgba(248, 245, 237, .96);
  box-shadow: 0 15px 38px rgba(20, 24, 21, .24);
}

.branching-tree-overview > span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 1px 2px 7px;
  color: #303833;
  font-family: var(--font-geist-sans), sans-serif;
}

.branching-tree-overview strong {
  font-size: 9px;
  font-weight: 760;
}

.branching-tree-overview small {
  color: #7b847e;
  font-family: var(--utility);
  font-size: 6px;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.branching-tree-overview > button {
  width: 100%;
  display: block;
  overflow: hidden;
  padding: 0;
  border: 1px solid rgba(41, 47, 43, .25);
  border-radius: 9px;
  background: #555954;
  cursor: grab;
  touch-action: none;
}

.branching-tree-overview > button:active {
  cursor: grabbing;
}

.branching-tree-overview > button:focus {
  outline: none;
}

.branching-tree-overview > button:focus-visible {
  outline: 2px solid #f0c873;
  outline-offset: 2px;
}

.branching-tree-overview svg {
  width: 100%;
  height: 100%;
  display: block;
}

.branching-overview-link {
  fill: none;
  stroke: rgba(236, 238, 231, .55);
  stroke-width: 5px;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.branching-tree-overview .has-selection .branching-overview-link {
  opacity: .16;
}

.branching-tree-overview .has-selection .branching-link--context {
  stroke: #dfe1da;
  opacity: .6;
}

.branching-tree-overview .has-selection .branching-link--selected {
  stroke: #f0c873;
  opacity: 1;
}

.branching-overview-node {
  fill: color-mix(in srgb, var(--branch-color) 32%, #f4f1e8);
  stroke: rgba(44, 48, 45, .7);
  stroke-width: 4px;
  vector-effect: non-scaling-stroke;
}

.branching-tree-overview .has-selection .branching-overview-node {
  opacity: .22;
}

.branching-tree-overview .has-selection .branching-person-card--context {
  opacity: .82;
}

.branching-tree-overview .has-selection .branching-overview-node.is-selected {
  fill: #f0c873;
  opacity: 1;
}

.branching-overview-window {
  fill: rgba(240, 200, 115, .1);
  stroke: #f0c873;
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
}

.branching-tree-note {
  min-height: 43px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 10px 18px;
  border-top: 1px solid rgba(255, 255, 255, .1);
  background: var(--tree-graphite-deep);
  color: #c4c9c2;
  font-family: var(--font-geist-sans), sans-serif;
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
}

@media (hover: hover) and (pointer: fine) {
  .branching-tree-tabs button,
  .branching-tree-tools button,
  .branching-person-card,
  .branching-family-line,
  .branching-couple-line {
    transition: border-color .17s ease, background .17s ease, color .17s ease, transform .17s ease, box-shadow .17s ease, opacity .17s ease, filter .17s ease, stroke .17s ease;
  }

  .branching-tree-tabs button:not(.active):hover {
    border-color: rgba(37, 47, 42, .16);
    background: rgba(255, 255, 255, .58);
    color: #303a35;
  }

  .branching-tree-tools button:not(:disabled):hover {
    border-color: rgba(255, 255, 255, .35);
    background: rgba(255, 255, 255, .1);
  }

  .branching-person-card:hover {
    z-index: 7;
    transform: translateY(-3px);
    box-shadow: 0 9px 18px rgba(20, 24, 21, .3);
  }
}

@media (max-width: 1250px) {
  .branching-tree-header {
    grid-template-columns: minmax(280px, .85fr) minmax(420px, 1.15fr);
  }

  .branching-tree-summary {
    display: none;
  }
}

@media (max-width: 820px) {
  .branching-tree {
    padding: 14px 9px 56px;
  }

  .branching-tree-header {
    grid-template-columns: 1fr;
    gap: 17px;
    margin-bottom: 16px;
  }

  .branching-tree-title h1 {
    font-size: clamp(43px, 13vw, 62px);
  }

  .branching-tree-title > p:last-child {
    margin-top: 10px;
    font-size: 12px;
  }

  .branching-tree-tabs button {
    min-height: 55px;
    padding: 8px 12px;
    font-size: 12px;
  }

  .branching-tree-tools {
    min-height: 47px;
    justify-content: flex-end;
    padding: 6px;
  }

  .branching-tree-tools > span {
    display: none;
  }

  .branching-tree-tools button span {
    display: none;
  }

  .branching-tree-viewport {
    height: min(67svh, 720px);
    min-height: 560px;
  }

  .branching-tree-note {
    align-items: flex-start;
    justify-content: flex-start;
    padding: 10px 12px;
    text-align: left;
  }

  .branching-tree-overview {
    display: none;
  }
}

@media (max-width: 430px) {
  .branching-tree-tabs {
    gap: 4px;
    padding: 4px;
  }

  .branching-tree-tabs button {
    padding-inline: 9px;
  }

  .branching-tree-tools output {
    min-width: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .branching-tree-canvas {
    animation: none;
  }

  .branching-tree-tabs button,
  .branching-tree-tools button,
  .branching-person-card,
  .branching-family-line,
  .branching-couple-line {
    transition: none;
  }
}

@keyframes branching-tree-arrive {
  from { opacity: .6; }
  to { opacity: 1; }
}
