:root {
  --bg: #ffffff;
  --ink: #1f2933;
  --muted: #667085;
  --line: #d7dde5;
  --panel: #f8fafc;
  --panel-strong: #eef2f6;
  --accent: #1b6f5d;
  --heart: #2f9fb3;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.12);
}

.lineage-1 {
  --lineage-color: #15756a;
  --lineage-tint: #e5f4f1;
}

.lineage-2 {
  --lineage-color: #276fad;
  --lineage-tint: #e7f1fa;
}

.lineage-3 {
  --lineage-color: #ad681f;
  --lineage-tint: #fbefdf;
}

.lineage-4 {
  --lineage-color: #7654a4;
  --lineage-tint: #f0eaf7;
}

.lineage-5 {
  --lineage-color: #af4964;
  --lineage-tint: #f9e8ed;
}

.lineage-6 {
  --lineage-color: #4f7734;
  --lineage-tint: #edf4e7;
}

.lineage-7 {
  --lineage-color: #4e5ca7;
  --lineage-tint: #eaecf8;
}

.lineage-8 {
  --lineage-color: #a84f35;
  --lineage-tint: #faebe6;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  min-height: 100dvh;
  overscroll-behavior: none;
}

body {
  margin: 0;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.site-header {
  position: fixed;
  z-index: 10;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 84px;
  padding: 18px clamp(18px, 4vw, 44px);
  border-bottom: 1px solid #edf0f4;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 13px;
}

h1 {
  margin: 0;
  color: #111827;
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1;
}

.tree-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.icon-button,
.text-button,
.close-button {
  display: grid;
  place-items: center;
  min-width: 42px;
  height: 42px;
  border: 1px solid #d9dee7;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.icon-button:hover,
.text-button:hover,
.close-button:hover {
  border-color: #b9c2cf;
  background: var(--panel);
}

.text-button {
  width: auto;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 650;
}

.tree-shell {
  position: relative;
  height: 100vh;
  height: 100dvh;
  padding-top: 84px;
}

.mobile-tree-view {
  display: none;
}

.mobile-lineage-key {
  display: none;
}

.tree-viewport {
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.tree-viewport.is-dragging {
  cursor: grabbing;
}

.tree-canvas {
  position: relative;
  width: 1300px;
  height: 840px;
  transform-origin: 0 0;
  will-change: transform;
}

.tree-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.tree-lines path {
  fill: none;
  stroke: #c2c9d3;
  stroke-width: 2;
  stroke-linecap: square;
  stroke-linejoin: round;
}

.tree-lines path.has-lineage {
  stroke: var(--lineage-color);
  stroke-width: 2.6;
  opacity: 0.72;
}

.tree-nodes {
  position: absolute;
  inset: 0;
}

.person-card {
  position: absolute;
  display: grid;
  justify-items: center;
  width: 170px;
  transform: translate(-50%, -50%);
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.branch-toggle {
  position: absolute;
  top: 76px;
  right: 18px;
  z-index: 2;
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 26px;
  padding: 0 7px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #344054;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
}

.person-card.has-partner .branch-toggle {
  right: 86px;
}

.branch-toggle.is-collapsed {
  background: var(--heart);
}

.person-card.has-partner {
  width: 300px;
}

.person-card.has-lineage .portrait {
  border-color: var(--lineage-color);
}

.person-card.has-lineage .couple-link::before,
.person-card.has-lineage .couple-link::after {
  background: var(--lineage-color);
  opacity: 0.72;
}

.person-card.has-lineage .order-badge,
.person-card.has-lineage .branch-toggle {
  background: var(--lineage-color);
}

.person-card:focus-visible .portrait {
  outline: 3px solid rgba(27, 111, 93, 0.28);
  outline-offset: 5px;
}

.couple-unit {
  position: relative;
  display: grid;
  grid-template-columns: 96px 56px 96px;
  align-items: start;
  justify-content: center;
  width: 260px;
}

.couple-person {
  display: grid;
  justify-items: center;
  min-width: 0;
}

.couple-link {
  position: relative;
  display: grid;
  place-items: center;
  height: 88px;
}

.couple-link::before,
.couple-link::after {
  position: absolute;
  top: 43px;
  width: 20px;
  height: 2px;
  background: #c2c9d3;
  content: "";
}

.couple-link::before {
  left: 0;
}

.couple-link::after {
  right: 0;
}

.couple-heart {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #fff;
  color: var(--heart);
  font-size: 16px;
  line-height: 1;
}

.couple-label {
  max-width: 110px;
  margin-top: 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.18;
  text-align: center;
}

.portrait {
  position: relative;
  width: 88px;
  height: 88px;
  overflow: hidden;
  border: 4px solid #71827e;
  border-radius: 999px;
  background: linear-gradient(135deg, #ecfdf5, #f1f5f9 52%, #fff7ed);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.11);
}

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

.portrait-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #1f5f52;
  font-size: 28px;
  font-weight: 700;
}

.order-badge {
  position: absolute;
  top: -8px;
  right: 26px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 750;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
}

.person-card.has-partner .order-badge {
  right: 84px;
}

.person-name {
  max-width: 170px;
  margin-top: 10px;
  color: #17202a;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
}

.person-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
}

.person-lineage {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
  color: var(--lineage-color);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.2;
}

.person-lineage > span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

.desktop-lineage-key {
  position: absolute;
  z-index: 6;
  bottom: 18px;
  left: 18px;
  width: min(340px, calc(100vw - 36px));
  padding: 14px;
  border: 1px solid #dfe5e2;
  border-radius: 16px;
  background: rgba(255, 255, 252, 0.94);
  box-shadow: 0 12px 34px rgba(23, 56, 52, 0.11);
  backdrop-filter: blur(12px);
}

.desktop-lineage-key[hidden],
.mobile-lineage-key[hidden] {
  display: none;
}

.lineage-key-heading {
  display: grid;
  gap: 2px;
}

.lineage-key-heading strong {
  color: #23423e;
  font-size: 13px;
}

.lineage-key-heading > span {
  color: #6b7774;
  font-size: 11px;
  line-height: 1.35;
}

.lineage-key-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px 8px;
  margin: 11px 0 0;
  padding: 0;
  list-style: none;
}

.lineage-key-item {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: #40514d;
  font-size: 11px;
  font-weight: 700;
}

.lineage-key-item > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lineage-key-swatch {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--lineage-color);
  box-shadow: 0 0 0 3px var(--lineage-tint);
}

.is-compact .tree-lines path {
  stroke-width: 1.7;
}

.is-compact .person-card {
  width: 142px;
}

.is-compact .person-card.has-partner {
  width: 248px;
}

.is-compact .couple-unit {
  grid-template-columns: 78px 42px 78px;
  width: 198px;
}

.is-compact .couple-link {
  height: 70px;
}

.is-compact .couple-link::before,
.is-compact .couple-link::after {
  top: 34px;
  width: 14px;
}

.is-compact .couple-heart {
  width: 22px;
  height: 22px;
  font-size: 14px;
}

.is-compact .couple-label {
  max-width: 86px;
  margin-top: 6px;
  font-size: 10px;
}

.is-compact .portrait {
  width: 70px;
  height: 70px;
  border-width: 3px;
}

.is-compact .portrait-placeholder {
  font-size: 22px;
}

.is-compact .order-badge {
  top: -7px;
  right: 24px;
  width: 24px;
  height: 24px;
  font-size: 12px;
}

.is-compact .person-card.has-partner .order-badge {
  right: 76px;
}

.is-compact .branch-toggle {
  top: 59px;
  right: 18px;
  min-width: 28px;
  height: 24px;
  font-size: 12px;
}

.is-compact .person-card.has-partner .branch-toggle {
  right: 74px;
}

.is-compact .person-name {
  max-width: 136px;
  margin-top: 8px;
  font-size: 13px;
}

.is-compact .person-card.has-partner .person-name {
  max-width: 190px;
}

.is-compact .person-meta {
  font-size: 11px;
}

.profile-dialog,
.reference-dialog {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid #d9dee7;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.profile-dialog::backdrop,
.reference-dialog::backdrop {
  background: rgba(17, 24, 39, 0.34);
}

.close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
}

.profile-content {
  display: grid;
  grid-template-columns: minmax(240px, 330px) 1fr;
  gap: 30px;
  padding: 34px;
  background: #fff;
}

.profile-photo {
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(135deg, #ecfdf5, #f8fafc 52%, #fff7ed);
}

.profile-photo:has(.profile-photo-grid) {
  aspect-ratio: auto;
  background: #fff;
}

.profile-photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  height: 100%;
}

.profile-photo-grid figure {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  min-width: 0;
  margin: 0;
}

.profile-photo-grid img,
.profile-photo-grid .portrait-placeholder {
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(135deg, #ecfdf5, #f8fafc 52%, #fff7ed);
}

.profile-photo-grid figcaption {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-align: center;
}

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

.profile-photo .portrait-placeholder {
  font-size: 76px;
}

.profile-details {
  align-self: center;
  padding-right: 28px;
}

.profile-kicker {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.profile-details h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.08;
}

.profile-years,
.profile-facts,
.profile-note {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.profile-years {
  margin: 12px 0 0;
}

.profile-facts {
  display: grid;
  gap: 8px;
  margin: 18px 0 0;
}

.profile-facts div {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
}

.profile-facts dt {
  color: #344054;
  font-weight: 700;
}

.profile-facts dd {
  margin: 0;
}

.profile-note {
  margin: 18px 0 0;
}

.reference-dialog {
  width: min(1040px, calc(100vw - 28px));
}

.reference-dialog figure {
  margin: 0;
  padding: 18px;
  background: #fff;
}

.reference-dialog img {
  display: block;
  width: 100%;
  max-height: 76vh;
  border-radius: 6px;
  object-fit: contain;
}

.reference-dialog figcaption {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}


/* Touch-first tree that keeps growing branches readable without clipping cards. */
@media (max-width: 720px) {
  html {
    scroll-padding-top: 128px;
  }

  html,
  body {
    width: 100%;
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    background: #f5f6f2;
    color: #17211f;
    -webkit-user-select: text;
    user-select: text;
  }

  .site-header {
    position: sticky;
    top: 0;
    min-height: 72px;
    gap: 10px;
    padding: 10px 12px;
    border-bottom-color: rgba(34, 75, 71, 0.12);
    background: rgba(255, 255, 252, 0.94);
  }

  .site-header > div:first-child {
    min-width: 0;
  }

  .site-header h1 {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 27px;
    font-weight: 700;
    letter-spacing: -0.02em;
  }

  .eyebrow {
    overflow: hidden;
    color: #65736f;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
  }

  .tree-shell {
    height: auto;
    min-height: calc(100dvh - 72px);
    padding-top: 0;
  }

  .tree-viewport {
    display: none;
  }

  .tree-controls {
    flex: 0 0 auto;
    max-width: none;
    overflow: visible;
    gap: 6px;
    padding: 0;
  }

  .tree-controls .icon-button,
  .tree-controls .text-button {
    min-width: 42px;
    height: 42px;
    padding: 0 10px;
    border-color: #d9dfdb;
    border-radius: 999px;
    color: #294642;
    font-size: 12px;
    font-weight: 750;
  }

  [data-action="toggle-compact"],
  [data-action="zoom-out"],
  [data-action="reset"],
  [data-action="zoom-in"] {
    display: none;
  }

  .mobile-tree-view {
    display: grid;
    gap: 0;
    width: 100%;
    min-height: calc(100dvh - 72px);
    background:
      radial-gradient(circle at 100% 0, rgba(68, 148, 137, 0.11), transparent 28rem),
      #f5f6f2;
  }

  .mobile-tree-intro {
    display: grid;
    gap: 14px;
    padding: 24px 16px 18px;
    border-bottom: 1px solid rgba(34, 75, 71, 0.1);
    background: #fffef9;
  }

  .mobile-tree-kicker {
    margin: 0 0 5px;
    color: #217268;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }

  .mobile-tree-intro h2 {
    margin: 0;
    color: #173b37;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(25px, 8vw, 34px);
    line-height: 1.04;
  }

  .mobile-tree-intro p:not(.mobile-tree-kicker) {
    max-width: 34rem;
    margin: 7px 0 0;
    color: #687571;
    font-size: 13px;
    line-height: 1.5;
  }

  .mobile-tree-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .mobile-tree-stats span {
    padding: 7px 10px;
    border: 1px solid #dce4df;
    border-radius: 999px;
    background: #f7faf8;
    color: #5b6864;
    font-size: 11px;
  }

  .mobile-tree-stats strong {
    color: #1f5f56;
    font-size: 13px;
  }

  .mobile-tree-toolbar {
    position: sticky;
    z-index: 5;
    top: 72px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    padding: 9px 12px;
    border-bottom-color: rgba(34, 75, 71, 0.12);
    background: rgba(245, 246, 242, 0.94);
  }

  .desktop-lineage-key {
    display: none;
  }

  .mobile-lineage-key {
    display: grid;
    gap: 9px;
    padding: 12px;
    border-bottom: 1px solid rgba(34, 75, 71, 0.1);
    background: #fffef9;
  }

  .mobile-lineage-key .lineage-key-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
  }

  .mobile-lineage-key .lineage-key-heading strong {
    flex: 0 0 auto;
    font-size: 13px;
  }

  .mobile-lineage-key .lineage-key-heading > span {
    font-size: 12px;
    text-align: right;
  }

  .mobile-lineage-key .lineage-key-list {
    display: flex;
    gap: 8px;
    margin: 0;
    padding: 2px 2px 5px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-lineage-key .lineage-key-list::-webkit-scrollbar {
    display: none;
  }

  .mobile-lineage-key .lineage-key-item {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid color-mix(in srgb, var(--lineage-color) 25%, white);
    border-radius: 999px;
    background: var(--lineage-tint);
    color: #344b47;
    font-size: 12px;
  }

  .mobile-mode-label {
    color: #49605c;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
  }

  .generation-filter {
    display: flex;
    align-items: center;
    justify-self: end;
    min-width: 0;
    width: auto;
    height: 38px;
    padding: 3px;
    border: 1px solid #d6ded9;
    border-radius: 999px;
    background: rgba(255, 255, 252, 0.94);
    box-shadow: 0 5px 18px rgba(24, 59, 55, 0.08);
    white-space: nowrap;
  }

  .generation-filter > span {
    margin: 0 3px 0 7px;
    color: #697772;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
  }

  .generation-filter button {
    display: grid;
    place-items: center;
    width: auto;
    min-width: 31px;
    height: 30px;
    padding: 0 8px;
    border: 0;
    border-radius: 999px;
    color: #50625d;
    font-size: 11px;
    font-weight: 800;
  }

  .generation-filter button.is-active {
    background: #226f65;
    color: #fff;
    box-shadow: 0 3px 9px rgba(34, 111, 101, 0.24);
  }

  .mobile-tree-list {
    display: grid;
    gap: 0;
    padding: 16px 12px 64px;
  }

  .mobile-branch {
    --branch-color: #2e8277;
    --branch-tint: #eaf5f2;
    position: relative;
    display: grid;
    gap: 0;
    min-width: 0;
    margin-left: 14px;
  }

  .mobile-branch.generation-1,
  .mobile-branch.generation-2,
  .mobile-branch.generation-3,
  .mobile-branch.generation-4,
  .mobile-branch.generation-5 {
    --branch-color: #65716e;
    --branch-tint: #eef1f0;
  }

  .mobile-branch.has-lineage {
    --branch-color: var(--lineage-color);
    --branch-tint: var(--lineage-tint);
  }

  .mobile-branch::before {
    position: absolute;
    top: -13px;
    bottom: -13px;
    left: -8px;
    width: 2px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--branch-color) 46%, white);
    content: "";
  }

  .mobile-branch::after {
    position: absolute;
    top: 46px;
    left: -8px;
    width: 8px;
    height: 2px;
    background: color-mix(in srgb, var(--branch-color) 46%, white);
    content: "";
  }

  .mobile-branch[data-level="0"] {
    margin-left: 0;
  }

  .mobile-branch[data-level="0"]::before,
  .mobile-branch[data-level="0"]::after {
    display: none;
  }

  .mobile-children > .mobile-branch:last-child::before {
    bottom: calc(100% - 46px);
  }

  .mobile-node-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 46px;
    align-items: center;
    min-width: 0;
    min-height: 92px;
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid #e0e5e1;
    border-left: 4px solid var(--branch-color);
    border-radius: 18px;
    background: rgba(255, 255, 252, 0.98);
    box-shadow: 0 8px 24px rgba(29, 59, 55, 0.08);
  }

  .mobile-person-button {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 11px;
    width: 100%;
    min-height: 90px;
    padding: 10px 8px 10px 10px;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
  }

  .mobile-person-button:focus-visible,
  .mobile-branch-button:focus-visible,
  .generation-filter button:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--branch-color, #226f65) 32%, transparent);
    outline-offset: -3px;
  }

  .mobile-single-portrait,
  .mobile-couple-portrait > .mobile-couple-person {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border: 3px solid var(--branch-color);
    background: var(--branch-tint);
    overflow: hidden;
    border-radius: 999px;
    box-shadow: 0 3px 10px rgba(24, 48, 45, 0.13);
  }

  .mobile-single-portrait .portrait-placeholder,
  .mobile-couple-portrait > .mobile-couple-person .portrait-placeholder {
    color: var(--branch-color);
    font-size: 17px;
  }

  .mobile-single-portrait img,
  .mobile-couple-portrait img,
  .mobile-single-portrait .portrait-placeholder,
  .mobile-couple-portrait .portrait-placeholder {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .mobile-couple-portrait {
    position: relative;
    display: flex;
    align-items: center;
    width: 79px;
    min-width: 79px;
    height: 60px;
  }

  .mobile-couple-portrait > .mobile-couple-person {
    display: grid;
    place-items: center;
    width: 50px;
    height: 50px;
    overflow: hidden;
    border-radius: 999px;
  }

  .mobile-couple-portrait > .mobile-couple-person + .mobile-couple-person {
    margin-left: -20px;
  }

  .mobile-heart {
    position: absolute;
    right: 1px;
    bottom: 0;
    width: 23px;
    height: 23px;
    border: 2px solid #fff;
    border-radius: 999px;
    background: #fff;
    color: #c43f68;
    font-size: 12px;
    box-shadow: 0 2px 7px rgba(24, 48, 45, 0.15);
  }

  .mobile-person-text {
    display: grid;
    min-width: 0;
    gap: 2px;
    align-content: center;
  }

  .mobile-generation-label {
    color: var(--branch-color);
    font-size: 11px;
    font-weight: 850;
    letter-spacing: 0.07em;
    line-height: 1.2;
    text-transform: uppercase;
  }

  .mobile-person-name {
    display: -webkit-box;
    overflow: hidden;
    color: #1c2926;
    font-size: 14px;
    font-weight: 780;
    line-height: 1.22;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .mobile-person-meta {
    margin-top: 1px;
    color: #75807c;
    font-size: 11px;
  }

  .mobile-lineage-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    width: fit-content;
    margin-top: 3px;
    padding: 3px 7px;
    border-radius: 999px;
    background: var(--branch-tint);
    color: var(--branch-color);
    font-size: 11px;
    font-weight: 800;
    line-height: 1.2;
  }

  .mobile-lineage-label > span {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: currentColor;
  }

  .mobile-branch-button {
    display: grid;
    align-self: stretch;
    align-content: center;
    justify-items: center;
    min-width: 46px;
    height: auto;
    margin: 0;
    padding: 8px 4px;
    border: 0;
    border-left: 1px solid #e5e9e6;
    border-radius: 0;
    background: var(--branch-tint);
    color: var(--branch-color);
    font-size: 11px;
    font-weight: 850;
    cursor: pointer;
  }

  .mobile-branch-chevron {
    margin-top: 3px;
    font-size: 14px;
    line-height: 1;
  }

  .mobile-children {
    display: grid;
    gap: 0;
  }

  .profile-dialog,
  .reference-dialog {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
    overflow: auto;
    border: 0;
    border-radius: 22px;
  }

  .close-button {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
  }

  .profile-content {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 18px;
  }

  .profile-details {
    padding-right: 0;
  }

  .profile-photo {
    max-height: 48dvh;
    border-radius: 15px;
  }

  .profile-photo-grid {
    min-height: 260px;
  }

  .profile-details h2 {
    font-size: 28px;
  }
}

@media (max-width: 360px) {
  .site-header {
    padding-inline: 9px;
  }

  .site-header h1 {
    font-size: 24px;
  }

  .tree-controls .icon-button,
  .tree-controls .text-button {
    padding-inline: 8px;
    font-size: 11px;
  }

  .mobile-tree-toolbar {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .generation-filter {
    justify-self: stretch;
    justify-content: space-between;
  }

  .mobile-tree-list {
    padding-inline: 8px;
  }

  .mobile-branch {
    margin-left: 10px;
  }

  .mobile-node-card {
    grid-template-columns: minmax(0, 1fr) 42px;
  }

  .mobile-person-button {
    gap: 8px;
    padding-left: 7px;
  }

  .mobile-single-portrait {
    width: 50px;
    height: 50px;
  }

  .mobile-couple-portrait {
    width: 69px;
    min-width: 69px;
  }

  .mobile-couple-portrait > .mobile-couple-person {
    width: 45px;
    height: 45px;
  }

  .mobile-person-name {
    font-size: 13px;
  }
}
