/* Hausbuch tree: a light, quiet canvas with the person panel docked on the right.
   Text sizes use rem so the header's text-size switch and native zoom scale them.
   Node geometry (portrait size, anchors, toggle offsets) stays in px because the
   layout engine positions nodes around the 76px portrait centre. */

/* One continuous daylit surface from the header down; no bands or rules. */
.atlas-page {
  background:
    radial-gradient(
      ellipse 70% 65% at 42% 45%,
      #fff 0%,
      rgba(255, 255, 255, 0) 72%
    ),
    var(--hb-ground);
  background-attachment: fixed;
  color: var(--hb-ink);
  color-scheme: light;
}
.official-constellation {
  --tree-line: #b3bab2;
  --tree-lit: #1b1f1c;
  --tree-uncertain: #a9843f;
  --tree-mono: #ecede8;
  --tree-mono-ink: #69706a;
  --tree-panel-w: 26rem;
  position: relative;
  height: calc(100dvh - var(--hb-header-h));
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  background: transparent;
  color: var(--hb-ink);
}
.official-constellation button {
  font-family: var(--fz-font);
  cursor: pointer;
}
.official-constellation .portrait {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}
.official-constellation .portrait > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.expanded-constellation .life-dialog-photo .portrait {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

/* The person panel is a permanent column; heading and tree share the rest. */
.official-constellation {
  grid-template-columns: minmax(0, 1fr) var(--tree-panel-w);
}
/* The view switch floats over the top of the tree rather than taking a row. */
.explorer-heading {
  grid-column: 1;
  grid-row: 1;
  align-self: start;
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 1rem;
  padding: 0.6rem clamp(1rem, 3vw, 2.6rem) 0;
  pointer-events: none;
}
.explorer-heading > .explorer-view-switch {
  grid-column: 2;
}
.explorer-heading > * {
  pointer-events: auto;
}
.explorer-heading > * {
  min-width: 0;
}
/* Line the view switch up with the header navigation, which is centred on the
   page rather than on the tree column. */
@media (min-width: 1181px) {
  .explorer-heading .explorer-view-switch {
    transform: translateX(calc(var(--tree-panel-w) / 2));
  }
}
.explorer-controls .explorer-undo:disabled {
  opacity: 0.35;
  cursor: default;
  background: none;
}
.explorer-controls .explorer-undo svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Small segmented switches: a hairline track, the active choice lifted in white. */
.explorer-view-switch,
.explorer-presets {
  display: flex;
  gap: 0.1rem;
  padding: 0.2rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  box-shadow:
    inset 0 0 0 1px rgba(27, 31, 28, 0.06),
    0 0.8rem 1.6rem -1.3rem rgba(22, 32, 26, 0.35);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.explorer-view-switch button,
.explorer-presets button {
  padding: 0.38rem 0.95rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--hb-muted);
  white-space: nowrap;
  transition:
    color 0.2s,
    background 0.2s,
    box-shadow 0.2s;
}
.explorer-view-switch button:hover,
.explorer-presets button:hover {
  color: var(--hb-ink);
}
.explorer-view-switch button[aria-pressed="true"],
.explorer-presets button[aria-pressed="true"] {
  color: var(--hb-ink);
  background: var(--hb-surface);
  box-shadow:
    0 0.25rem 0.7rem -0.4rem rgba(22, 32, 26, 0.45),
    0 0 0 1px rgba(27, 31, 28, 0.06);
}

/* Stage: soft daylight, canvas, overlays. */
.explorer-stage {
  grid-column: 1;
  grid-row: 1;
  position: relative;
  container-type: inline-size;
  min-height: 0;
  overflow: hidden;
}
.explorer-canvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  cursor: grab;
}
.explorer-canvas:focus-visible {
  outline: 2px solid rgba(27, 31, 28, 0.15);
  outline-offset: -8px;
  border-radius: 1.2rem;
}
.explorer-canvas.dragging {
  cursor: grabbing;
}
.explorer-world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: auto;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
.explorer-node,
.explorer-connections {
  will-change: auto;
}
.reordering .explorer-node {
  will-change: left, top;
}

/* Connections */
.explorer-connections {
  position: absolute;
  inset: 0;
  overflow: visible;
  fill: none;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.explorer-partner {
  stroke: var(--tree-line);
  stroke-dasharray: 3 5;
}
.explorer-trunk,
.explorer-child {
  stroke: var(--tree-line);
}
.explorer-end {
  stroke: none;
  fill: var(--tree-line);
}
.explorer-union circle {
  fill: var(--hb-ground);
  stroke: var(--tree-line);
  stroke-width: 1.2;
}
.explorer-union path {
  stroke: #8f978f;
  stroke-width: 1;
  fill: none;
}
[data-selection="person"] .explorer-connections .lit {
  stroke: var(--tree-lit);
  stroke-width: 1.9;
}
[data-selection="person"] .explorer-end.lit {
  stroke: none;
  fill: var(--tree-lit);
}
[data-selection="person"] .explorer-union.lit circle {
  stroke: var(--tree-lit);
  fill: #fff;
}
[data-selection="person"] .explorer-union.lit path {
  stroke: var(--tree-lit);
}
.explorer-connections .uncertain-edge {
  stroke: var(--tree-uncertain);
  stroke-dasharray: 6 6;
}

/* People */
.explorer-node {
  position: absolute;
  width: 180px;
  transform: translate(-50%, -38px);
  text-align: center;
}
.explorer-person {
  display: flex;
  align-items: center;
  flex-direction: column;
  width: 100%;
  padding: 0;
  color: var(--hb-ink);
}
.explorer-person .portrait {
  width: 76px;
  height: 76px;
  overflow: hidden;
  background: var(--tree-mono);
  color: var(--tree-mono-ink);
  font: italic 400 27px/1 var(--hb-display);
  box-shadow:
    0 0 0 5px var(--hb-ground),
    0 0 0 6px #d3d7d1,
    0 18px 26px -18px rgba(22, 32, 26, 0.6);
  transition:
    transform 0.3s cubic-bezier(0.2, 0.7, 0.2, 1),
    box-shadow 0.3s;
}
.explorer-person .photo {
  filter: none;
}
.explorer-person:hover .portrait {
  transform: translateY(-2px);
  box-shadow:
    0 0 0 5px var(--hb-ground),
    0 0 0 6px #9fa79f,
    0 22px 30px -18px rgba(22, 32, 26, 0.6);
}
[data-selection="person"] .explorer-node.chosen .portrait {
  box-shadow:
    0 0 0 5px #fff,
    0 0 0 7px var(--tree-lit),
    0 24px 34px -18px rgba(22, 32, 26, 0.65);
}
.explorer-node.central-person .explorer-person-name {
  font-weight: 500;
}
.explorer-name-row {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 14px;
}
.explorer-name-button {
  padding: 0;
  color: inherit;
  min-width: 0;
  text-align: center;
}
.explorer-person-name {
  display: block;
  font: 500 1.2rem/1.15 var(--hb-text);
  color: var(--hb-ink);
  text-wrap: balance;
}
.explorer-name-row .explorer-person-name {
  margin-top: 0;
}
.official-constellation .explorer-person-name {
  white-space: normal;
  max-width: 215px;
}
.explorer-person-name em {
  font-style: normal;
  color: inherit;
}
.explorer-person-years,
.explorer-node > .explorer-person-years {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.875rem;
  letter-spacing: 0.02em;
  color: var(--hb-muted);
  font-variant-numeric: tabular-nums;
}
.official-constellation .explorer-person-years {
  max-width: 210px;
  margin-inline: auto;
}
.estimated-year {
  color: var(--tree-uncertain);
}
.explorer-story-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border-radius: 50%;
  color: var(--hb-ink);
  background: var(--hb-surface);
  border: 1px solid var(--hb-hair);
  transition: background 0.15s;
}
.explorer-story-icon .icon {
  width: 0.85rem;
  height: 0.85rem;
  display: block;
}
.explorer-story-icon:hover {
  background: var(--hb-ink);
  color: #fff;
}
.explorer-person:focus-visible {
  outline: 2px solid var(--hb-ink);
  outline-offset: 7px;
  border-radius: 8px;
}
.explorer-story-icon:focus-visible,
.explorer-name-button:focus-visible {
  outline: 2px solid var(--hb-ink);
  outline-offset: 4px;
  border-radius: 4px;
}

/* Branch toggles and collapsed family previews */
.branch-toggle {
  position: absolute;
  padding: 0.2rem 0.6rem;
  min-width: 25px;
  border-radius: 999px;
  border: 1px solid #cfd4cd;
  background: var(--hb-surface);
  color: var(--hb-muted);
  font-size: 0.8125rem;
  line-height: 1.4;
  white-space: nowrap;
  box-shadow: 0 4px 10px -8px rgba(22, 32, 26, 0.5);
}
.branch-toggle:hover {
  color: var(--hb-ink);
  border-color: #8f978f;
}
.branch-toggle.branch-open {
  color: var(--hb-faint);
  background: rgba(255, 255, 255, 0.7);
}
.branch-toggle.branch-open:hover {
  color: var(--hb-ink);
}
.ancestor-toggle {
  top: -25px;
  left: 97px;
}
.children-toggle {
  top: 140px;
  left: 50%;
  transform: translateX(-50%);
}
.family-preview {
  position: absolute;
  z-index: 1;
  transform: translateX(-50%);
  width: 166px;
  padding: 0;
  text-align: center;
  color: var(--hb-muted);
  font-size: 0.875rem;
}
.preview-stem {
  position: absolute;
  left: 50%;
  top: -83px;
  height: 78px;
  width: 1px;
  background: linear-gradient(#b3bab2, rgba(179, 186, 178, 0.1));
  pointer-events: none;
}
.single-parent-preview .preview-stem {
  top: -21px;
  height: 18px;
}
.preview-ghosts {
  display: flex;
  justify-content: center;
  gap: 8px;
  height: 37px;
  opacity: 0.6;
  mask-image: linear-gradient(#000 15%, #0009 75%, transparent);
  pointer-events: none;
}
.preview-ghosts > span {
  display: flex;
  width: 35px;
  height: 35px;
  align-items: center;
  justify-content: center;
  border: 1px solid #cfd4cd;
  background: var(--tree-mono);
  border-radius: 50%;
  font: italic 14px var(--hb-display);
  color: var(--tree-mono-ink);
}
.preview-count {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  align-items: center;
  margin-top: 3px;
}
.preview-count > b {
  width: 1.3rem;
  height: 1.3rem;
  line-height: 1.2rem;
  border: 1px solid #b3bab2;
  border-radius: 50%;
  color: var(--hb-ink);
  font-weight: 500;
}
.family-preview:hover .preview-ghosts {
  opacity: 0.9;
}
.family-preview:hover .preview-count {
  color: var(--hb-ink);
}
.family-preview.preview-open {
  top: auto;
  transform: translate(-50%, 12px);
  width: 150px;
  opacity: 0.7;
}
.family-preview.preview-open:hover {
  opacity: 1;
}
.preview-collapse {
  padding: 0.3rem 0.7rem;
  border: 1px solid #cfd4cd;
  border-radius: 999px;
  background: var(--hb-surface);
  white-space: nowrap;
}

/* Year guides (birth-year view) */
.explorer-year-guide {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  border-top: 1px solid rgba(27, 31, 28, 0.08);
  pointer-events: none;
}
.explorer-year-guide > span {
  position: absolute;
  left: 8px;
  top: -1.1rem;
  padding: 0.3rem 0.6rem;
  font: italic 400 1.35rem/1 var(--hb-display);
  color: #6f7670;
  background: var(--hb-ground);
}
.explorer-year-guide.unknown-years {
  border-top: 1px dashed rgba(169, 132, 63, 0.5);
}
.explorer-year-guide.unknown-years > span {
  color: var(--tree-uncertain);
}

/* Bottom bar: count, zoom and family scope float over the tree. */
.explorer-bottom {
  position: absolute;
  z-index: 3;
  left: clamp(1rem, 3vw, 2.6rem);
  right: clamp(1rem, 3vw, 2.6rem);
  bottom: 1.1rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1.2rem;
}
.explorer-bottom > .explorer-count {
  grid-column: 1;
  justify-self: start;
}
.explorer-bottom > .explorer-controls {
  grid-column: 2;
}
.explorer-bottom > .explorer-presets {
  grid-column: 3;
  justify-self: end;
}
/* When the tree column is too narrow for zoom centred and scope at the side,
   the scope sits centred just above the zoom bar. */
@container (max-width: 70rem) {
  .explorer-bottom {
    grid-template-rows: auto auto;
    row-gap: 0.5rem;
  }
  .explorer-bottom > .explorer-presets {
    grid-column: 1 / -1;
    grid-row: 1;
    justify-self: center;
  }
  .explorer-bottom > :is(.explorer-count, .explorer-controls) {
    grid-row: 2;
  }
  .explorer-count > small {
    display: none;
  }
}
@container (max-width: 44rem) {
  .explorer-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .explorer-bottom > .explorer-presets {
    order: -1;
  }
  .explorer-bottom > .explorer-count {
    order: 2;
  }
}
.explorer-count {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  box-shadow:
    inset 0 0 0 1px rgba(27, 31, 28, 0.06),
    0 0.8rem 1.6rem -1.3rem rgba(22, 32, 26, 0.35);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  font-size: 0.9375rem;
  color: var(--hb-muted);
  white-space: nowrap;
}
.explorer-count:hover {
  color: var(--hb-ink);
}
.explorer-count > small {
  font-size: inherit;
}
.explorer-count .icon {
  width: 1.1rem;
  height: 1.1rem;
}
.explorer-controls {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: var(--hb-glass);
  border: 1px solid var(--hb-glass-edge);
  box-shadow:
    var(--hb-glass-shadow),
    inset 0 1px 0 #fff;
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
}
.explorer-controls button {
  display: grid;
  place-items: center;
  min-width: 2.6rem;
  height: 2.6rem;
  border-radius: 999px;
  font-size: 1.3rem;
  color: var(--hb-ink);
}
.explorer-controls button:hover {
  background: var(--tree-mono);
}
.explorer-controls output {
  min-width: 3.3rem;
  text-align: center;
  font-size: 0.9375rem;
  color: var(--hb-muted);
  font-variant-numeric: tabular-nums;
}
.explorer-controls .icon {
  width: 1.05rem;
  height: 1.05rem;
}
.explorer-controls i {
  width: 1px;
  height: 1.2rem;
  margin: 0 0.2rem;
  background: var(--hb-hair);
}

/* Person panel, docked to the right edge. The canvas and bottom bar make room. */
/* A detached card in its own column: the tree never runs underneath it. Change
   --tree-card-radius to 0 for square corners. */
.explorer-inspector {
  --tree-card-radius: 1.2rem;
  grid-column: 2;
  grid-row: 1;
  position: relative;
  z-index: 6;
  min-height: 0;
  margin: 0.6rem clamp(1rem, 1.6vw, 1.5rem) 1.5rem 0;
  overflow: auto;
  scrollbar-width: none;
  padding: 1.3rem 1.9rem 2rem;
  background: var(--hb-surface);
  border: 1px solid rgba(27, 31, 28, 0.06);
  border-radius: var(--tree-card-radius);
  box-shadow: 0 2.5rem 5rem -2.8rem rgba(22, 32, 26, 0.45);
  color: var(--hb-ink);
}
.explorer-inspector::-webkit-scrollbar {
  display: none;
}
.explorer-inspector[hidden] {
  display: none;
}
.explorer-empty {
  padding-top: 0.6rem;
}
.explorer-empty h2 {
  margin: 0;
  font: 400 2.2rem/1.05 var(--hb-display);
  letter-spacing: -0.01em;
}
.explorer-empty > p {
  margin-top: 0.6rem;
  font: 400 1.15rem/1.5 var(--hb-text);
  color: var(--hb-muted);
}
.explorer-empty h3 {
  margin: 2rem 0 0.4rem;
  font: 500 0.875rem var(--fz-font);
  color: var(--hb-faint);
}
.explorer-empty ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.1rem;
}
.explorer-empty li button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: calc(100% + 0.8rem);
  margin-left: -0.4rem;
  padding: 0.3rem 0.4rem;
  border-radius: 0.5rem;
  text-align: left;
  color: var(--hb-ink);
  transition: background 0.2s;
}
.explorer-empty li button:hover {
  background: var(--hb-ground);
}
.explorer-empty .portrait {
  width: 2.4rem;
  height: 2.4rem;
  background: var(--tree-mono);
  color: var(--tree-mono-ink);
  font: italic 400 0.95rem/1 var(--hb-display);
  overflow: hidden;
}
/* Only the mobile sheet can be closed; the wide-screen column is static. */
.explorer-inspector-close {
  position: absolute;
  z-index: 1;
  top: 2.3rem;
  right: 2.6rem;
  display: none;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: var(--hb-ink);
  font-size: 1.5rem;
  line-height: 1;
  box-shadow: 0 0.4rem 1rem -0.6rem rgba(22, 32, 26, 0.5);
}
.explorer-inspector-close:hover {
  background: #fff;
}
/* As in the draft: the photo spans the card, name and dates sit left-aligned below. */
.explorer-identity {
  display: block;
  text-align: left;
}
.explorer-identity > .portrait {
  display: block;
  width: calc(100% + 1.2rem);
  height: auto;
  margin: 0 -0.6rem 1.2rem;
  border-radius: 0.9rem;
  background: var(--tree-mono);
  box-shadow: none;
  overflow: hidden;
}
/* The photo at its own proportions across the card; only unusually tall
   pictures are trimmed, from the bottom, so faces stay in view. */
.explorer-identity > .portrait > img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 26rem;
  object-fit: cover;
  object-position: 50% 20%;
  border-radius: 0;
}
.explorer-identity > .portrait:not(:has(img)) {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 5 / 4;
  color: var(--tree-mono-ink);
  font: italic 400 5rem/1 var(--hb-display);
}
.explorer-identity h2 {
  margin: 0;
  font: 400 2.6rem/1.02 var(--hb-display);
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.explorer-identity h2 br {
  display: none;
}
.explorer-identity h2 em {
  font-style: normal;
  color: inherit;
}
.explorer-identity h2 em::before {
  content: " ";
}
.explorer-identity p {
  margin-top: 0.5rem;
  font: 400 1.15rem/1.4 var(--hb-text);
  color: var(--hb-muted);
}
.explorer-relations {
  margin-top: 1.5rem;
  display: grid;
  gap: 1rem;
}
.expanded-relation > span {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--hb-faint);
}
.expanded-relation > div {
  display: grid;
  gap: 0.1rem;
}
.expanded-relation button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: calc(100% + 0.8rem);
  margin-left: -0.4rem;
  padding: 0.3rem 0.4rem;
  border-radius: 0.5rem;
  text-align: left;
  color: var(--hb-ink);
  transition: background 0.2s;
}
.expanded-relation button:hover {
  background: var(--hb-ground);
}
.expanded-relation button .portrait {
  width: 2.4rem;
  height: 2.4rem;
  background: var(--tree-mono);
  color: var(--tree-mono-ink);
  font: italic 400 0.95rem/1 var(--hb-display);
  overflow: hidden;
}
.expanded-relation-name > small {
  display: block;
  margin-top: 0.1rem;
  font: 400 0.8125rem/1.35 var(--fz-font);
  color: var(--hb-faint);
}
.expanded-relation-name {
  font: 500 1.12rem/1.2 var(--hb-text);
}
.expanded-relation button small {
  margin-left: auto;
  color: var(--hb-faint);
}
.explorer-estimate-note {
  margin-top: 1.2rem;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: #7f6630;
}
.explorer-facts:empty {
  display: none;
}
.explorer-facts {
  margin-top: 1.4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--hb-hair);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--hb-muted);
}
.explorer-facts p {
  font-size: 0.9375rem;
  margin: 0.5rem 0;
  color: var(--hb-muted);
}
.explorer-facts a,
.explorer-facts button {
  color: var(--hb-ink);
  text-decoration: underline;
  text-decoration-color: #c3c9c1;
  text-underline-offset: 0.2em;
}
.explorer-uncertainty {
  color: #7f6630;
}
/* All actions sit together at the end of the column. */
.explorer-actions {
  display: grid;
  gap: 0.55rem;
  margin-top: 1.6rem;
}
.expanded-story-button,
.expanded-life-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  width: 100%;
  padding: 0.95rem 1.3rem;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 500;
  transition: background 0.2s;
}
.expanded-story-button {
  background: var(--hb-ink);
  color: #fff;
}
.expanded-story-button:hover {
  background: #343a36;
}
.expanded-story-button .icon:first-child {
  display: none;
}
.expanded-life-button {
  border: 1px solid #c9cec7;
  color: var(--hb-ink);
  text-decoration: none;
}
.expanded-life-button:hover {
  background: var(--hb-ground);
}
.expanded-story-button .icon,
.expanded-life-button .icon {
  width: 1.05rem;
  height: 1.05rem;
}
.expanded-center-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.45rem auto 0;
  padding: 0.3rem 0;
  font-size: 0.9375rem;
  color: var(--hb-muted);
}
.expanded-center-button:hover {
  color: var(--hb-ink);
}
.expanded-center-button .icon {
  width: 1rem;
  height: 1rem;
}

/* Family directory dialog */
.atlas-page dialog {
  color-scheme: light;
  color: var(--hb-ink);
}
.expanded-directory {
  padding: 2.2rem;
  max-width: 640px;
}
.expanded-directory h2 {
  margin: 0.9rem 0;
  font: 400 2.2rem/1.1 var(--hb-display);
}
.expanded-directory .dialog-subtitle {
  font-size: 0.9375rem;
  line-height: 1.7;
}
.expanded-directory .family-directory {
  display: grid;
  max-height: 50dvh;
  overflow: auto;
}
.expanded-directory .family-directory button {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 0.85rem 0.6rem 0.85rem 0;
  text-align: left;
  border-bottom: 1px solid var(--hb-hair);
}
.expanded-directory .portrait {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ecede8;
  color: #69706a;
  font: italic 18px var(--hb-display);
}
.expanded-directory .family-directory button > span:nth-child(2) {
  flex: 1;
}
.expanded-directory .family-directory strong {
  display: block;
  font: 500 1.15rem/1.25 var(--hb-text);
}
.expanded-directory .family-directory small {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.875rem;
  color: var(--hb-muted);
}
.expanded-directory .family-directory .icon {
  width: 16px;
  height: 16px;
}
.expanded-result-count {
  margin: 0.8rem 0;
  font-size: 0.875rem !important;
  color: var(--hb-muted) !important;
}

/* Source dialog */
.archive-source-dialog {
  max-width: 1000px;
  padding: 32px;
}
.archive-source-dialog .dialog-heading h2 {
  font: 400 2rem/1.2 var(--hb-display);
}
.archive-source-dialog .dialog-heading p {
  font-size: 0.9375rem;
  line-height: 1.7;
}
.archive-source-preview {
  display: block;
  margin: 20px 0;
  padding: 10px;
  border-radius: 5px;
  background: #eee;
}
.archive-source-preview img {
  display: block;
  width: 100%;
  max-height: 65dvh;
  object-fit: contain;
}
.archive-source-actions {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  margin: 20px 0;
}
.archive-source-dialog pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 65dvh;
  overflow: auto;
  padding: 20px 0;
  font: 0.9375rem/1.8 var(--fz-font);
}
.source-text-cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  height: 100%;
  min-height: 230px;
  background: #ecede8;
  color: #5b625d;
  font: 1.5rem var(--hb-display);
}
.source-text-cover .icon {
  width: 44px;
  height: 44px;
}

/* Story reader */
.story-dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: 90dvh;
  padding: 0;
  background: #fbfbf9;
}
.family-story {
  padding: 55px 64px;
  color: var(--hb-ink);
}
.family-story header {
  position: relative;
  margin-bottom: 30px;
}
.family-story header > .close-dialog {
  top: -35px;
  right: -42px;
}
.family-story h2 {
  margin: 18px 0;
  font: 400 3rem/1.05 var(--hb-display);
  letter-spacing: -0.01em;
}
.family-story .story-subtitle {
  font: 0.9375rem/1.6 var(--fz-font);
  color: var(--hb-muted);
}
.family-story .story-lead {
  margin-bottom: 40px;
  font: 400 1.45rem/1.6 var(--hb-text);
  color: #343936;
}
.family-story section {
  margin: 35px 0;
}
.family-story h3 {
  margin: 0 0 16px;
  font: 400 1.8rem/1.2 var(--hb-display);
}
.family-story section p {
  margin: 17px 0;
  font: 400 1.25rem/1.7 var(--hb-text);
  color: #343936;
}
.story-sources {
  margin-top: 44px;
  padding-top: 27px;
  border-top: 1px solid var(--hb-hair);
}
.story-sources h3 {
  font-size: 1.5rem;
}
.story-sources button {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 12px 0;
  text-align: left;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--hb-ink);
  border-bottom: 1px solid var(--hb-hair);
}
.story-sources button > span {
  flex: 1;
}
.story-sources .icon {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  margin-top: 3px;
}
.story-sources > p {
  margin-top: 22px;
  font: 0.875rem/1.8 var(--fz-font);
  color: var(--hb-muted);
}
.story-back-link {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 15px 0;
  font-size: 0.9375rem;
  color: var(--hb-muted);
}
.story-back-link .icon {
  width: 15px;
  height: 15px;
}

/* Lifelines: calendar axis with ribbons below each birth. */
[data-view="lifelines"] .explorer-node {
  width: 170px;
  height: 0;
  transform: translate(-50%, 0);
}
[data-view="lifelines"] .explorer-person {
  position: absolute;
  top: -122px;
  left: 0;
}
[data-view="lifelines"] .explorer-person .portrait {
  width: 42px;
  height: 42px;
  font-size: 17px;
  box-shadow:
    0 0 0 3px var(--hb-ground),
    0 0 0 4px #d3d7d1;
}
[data-view="lifelines"] .explorer-name-row {
  position: absolute;
  top: -72px;
  left: 0;
  width: 100%;
  margin: 0;
}
[data-view="lifelines"] .explorer-person-name {
  font-size: 1.1rem;
  line-height: 1.15;
}
[data-view="lifelines"] .explorer-person-years {
  position: absolute;
  top: -24px;
  left: 0;
  width: 100%;
  margin: 0;
  font-size: 0.8125rem;
}
[data-view="lifelines"] .ancestor-toggle {
  top: -153px;
  left: 50%;
  transform: translateX(-50%);
}
[data-view="lifelines"] .explorer-year-guide > span {
  display: none;
}
[data-view="lifelines"] .explorer-connections {
  z-index: 2;
  pointer-events: none;
}
[data-view="lifelines"] .explorer-child {
  stroke: #9aa39b;
  stroke-width: 1.6;
  opacity: 0.85;
}
[data-view="lifelines"] .explorer-partner {
  stroke: #b3a47c;
  stroke-width: 1.5;
  opacity: 0.8;
}
[data-view="lifelines"][data-selection="person"] .explorer-child.lit,
[data-view="lifelines"][data-selection="person"] .explorer-partner.lit {
  stroke: var(--tree-lit);
  stroke-width: 2.2;
  opacity: 1;
}
.lifespan-bar {
  position: absolute;
  top: 0;
  left: 49px;
  width: 72px;
  min-height: 2px;
  padding: 0;
  border-radius: 7px;
  background: linear-gradient(90deg, #e2e7df, #d9e0d6);
  border: 1px solid #c1c9bf;
  border-top: 3px solid #8e9a8c;
  border-bottom: 3px solid #8e9a8c;
  color: var(--hb-ink);
}
.lifespan-bar:hover,
[data-selection="person"] .chosen .lifespan-bar {
  background: linear-gradient(90deg, #cfd8cc, #c4cfc0);
  border-color: var(--tree-lit);
}
.lifespan-bar.open-end {
  background: linear-gradient(#dde3da, transparent);
  border-bottom: 0;
  border-left-style: dashed;
  border-right-style: dashed;
}
.lifespan-bar.estimated-start {
  border-top-style: dashed;
}
.lifespan-bar.uncertain-end {
  border-bottom-style: dashed;
}
.lifespan-bar.projected-end {
  border-left-style: dashed;
  border-right-style: dashed;
}
.lifespan-bar:focus-visible {
  outline: 2px solid var(--hb-ink);
  outline-offset: 5px;
}
.lifespan-end {
  position: absolute;
  top: calc(100% + 9px);
  left: -49px;
  width: 170px;
  white-space: normal;
  font: 0.8125rem/1.5 var(--fz-font);
  color: var(--hb-muted);
}
.lifespan-continuation {
  position: absolute;
  left: 24px;
  max-height: 220px;
  overflow: hidden;
  writing-mode: vertical-rl;
  white-space: nowrap;
  text-overflow: ellipsis;
  font: 1rem var(--hb-text);
  letter-spacing: 0.02em;
  color: var(--hb-muted);
  pointer-events: none;
}
.lifespan-continuation[hidden] {
  display: none;
}
.lifeline-axis {
  position: absolute;
  inset: 0;
  z-index: 4;
  overflow: hidden;
  pointer-events: none;
}
.lifeline-axis > span {
  position: absolute;
  left: 10px;
  max-width: 120px;
  transform: translateY(-50%);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--hb-hair);
  font: 0.875rem var(--fz-font);
  color: var(--hb-muted);
}
.lifeline-union-label {
  fill: var(--hb-ink);
  font: 12px var(--fz-font);
  paint-order: stroke;
  stroke: var(--hb-ground);
  stroke-width: 5px;
  stroke-linejoin: round;
}
.lifeline-parent-port {
  fill: var(--hb-ground);
  stroke: #8e9a8c;
  stroke-width: 1.5;
}
.lifeline-child-port {
  fill: #8e9a8c;
  stroke: var(--hb-ground);
  stroke-width: 1.5;
}
[data-selection="person"] .selected-link .lifeline-parent-port,
[data-selection="person"] .selected-link .lifeline-child-port {
  stroke: var(--tree-lit);
  fill: var(--tree-lit);
}
.lifeline-union-dot {
  fill: var(--hb-ground);
  stroke: #b3a47c;
  stroke-width: 1.3;
}

/* Responsive */
@media (max-width: 1180px) {
  .official-constellation {
    --tree-panel-w: 22rem;
  }
}
@media (max-width: 800px) {
  .explorer-heading {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem 0;
  }
  .explorer-heading > .explorer-view-switch {
    grid-column: 1;
    grid-row: 1;
  }
  .explorer-view-switch {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .explorer-bottom > .explorer-presets {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .explorer-canvas {
    inset: 0;
  }
  .explorer-count {
    padding: 0.35rem 0.8rem;
    font-size: 0.875rem;
  }
  /* On narrow screens the panel is a bottom sheet over the canvas. */
  .official-constellation {
    grid-template-columns: minmax(0, 1fr);
  }
  .explorer-inspector[data-empty] {
    display: none;
  }
  .explorer-inspector {
    /* Out of the grid, so the sheet spans the section rather than a column. */
    grid-column: auto;
    grid-row: auto;
    position: absolute;
    right: 0;
    bottom: 0;
    top: auto;
    left: 0;
    width: auto;
    max-height: 62%;
    margin: 0;
    border: 0;
    border-top: 1px solid var(--hb-hair);
    border-radius: 1rem 1rem 0 0;
    box-shadow: 0 -1.5rem 3rem -2.5rem rgba(22, 32, 26, 0.6);
  }
  .explorer-identity {
    display: block;
    text-align: left;
    position: relative;
    min-height: 5rem;
    padding-left: 6rem;
    padding-right: 2.5rem;
  }
  .explorer-identity > .portrait,
  .explorer-identity > .portrait:not(:has(img)) {
    position: absolute;
    left: 0;
    top: 0;
    margin: 0;
    aspect-ratio: auto;
    width: 4.8rem;
    height: 4.8rem;
    overflow: hidden;
    border-radius: 50%;
    background: var(--tree-mono);
    font-size: 1.8rem;
  }
  .explorer-identity > .portrait > img {
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: cover;
    border-radius: 50%;
  }
  .explorer-identity h2 {
    font-size: 1.9rem;
  }
  .explorer-inspector-close {
    display: grid;
    top: 1rem;
    right: 1rem;
  }
}
@media (max-width: 600px) {
  .family-story {
    padding: 38px 25px;
  }
  .family-story h2 {
    font-size: 2.3rem;
  }
  .family-story header > .close-dialog {
    top: -24px;
    right: -14px;
  }
  .family-story .story-lead {
    font-size: 1.25rem;
  }
  .family-story section p {
    font-size: 1.15rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  .explorer-world {
    will-change: auto;
  }
  .explorer-person .portrait {
    transition: none;
  }
}
