/* D3 Node Styling */
.node rect {
  transition: all 0.2s ease;
}

.node text {
  font-family: 'Inter', sans-serif;
}

.link {
  fill: none;
  stroke: #94a3b8;
  stroke-width: 1.5px;
}

/* Custom Card in SVG */
.person-card {
  cursor: pointer;
}

.person-card .card-bg {
  transition:
    opacity 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    filter 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.person-card:hover .card-bg {
  opacity: 0.9;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

.card-box {
  rx: 8;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.05));
}

.card-name {
  font-weight: 600;
  font-size: 14px;
  fill: var(--text-primary);
}

.card-dates {
  font-size: 11px;
  fill: var(--text-secondary);
  font-weight: 400;
}

.glow-focus-div {
  border: 2px solid rgba(255, 202, 40, 0.8) !important; /* Delicate Gold */
  animation: pulse-gold-delicate 2s infinite ease-in-out;
  box-shadow: 0 0 12px rgba(255, 202, 40, 0.4) !important;
  transform: scale(1.02);
  pointer-events: none; /* Let clicks pass through to the card beneath */
}

/* Glow Focus Effect - Pulsing Gold Border for the specific person card */
.person-card.glow-active .card-bg {
  stroke: rgba(255, 202, 40, 0.8) !important;
  stroke-width: 2px !important;
  filter: drop-shadow(0 0 8px rgba(255, 202, 40, 0.4)) !important;
}

/* Animation and Pulse for the glow fallback circle */
.glow-fallback-circle {
  fill: rgba(255, 202, 40, 0.4) !important;
  filter: blur(15px);
  pointer-events: none;
  transform-origin: center;
  transform-box: fill-box;
  animation: pulse-gold-fill 2s infinite ease-in-out;
}

/* Animations moved to animations.css */

/* View Mode Selector (Diagramma / Cronologia / Posizione) */
.view-mode-selector {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.view-mode-menu {
  position: relative;
  display: inline-flex;
}

.view-mode-menu::after {
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  height: 10px;
  content: '';
}

.view-mode-chevron {
  margin-right: -5px;
  font-size: 15px !important;
}

.view-mode-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 110;
  min-width: 174px;
  padding: 6px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 13px;
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 16px 38px rgba(2, 6, 23, 0.38);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-5px) scale(0.98);
  transform-origin: top left;
  pointer-events: none;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition:
    opacity 0.16s ease,
    visibility 0.16s ease,
    transform 0.16s ease;
}

.view-mode-menu:hover .view-mode-dropdown,
.view-mode-menu:focus-within .view-mode-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.view-mode-dropdown-item {
  display: grid;
  width: 100%;
  grid-template-columns: 22px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #cbd5e1;
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.view-mode-dropdown-item:hover,
.view-mode-dropdown-item:focus-visible {
  outline: none;
  background: rgba(56, 189, 248, 0.12);
  color: #f8fafc;
}

.view-mode-dropdown-item .material-symbols-outlined {
  font-size: 18px;
}

.view-mode-check {
  opacity: 0;
  color: #7dd3fc;
}

.view-mode-dropdown-item.active .view-mode-check {
  opacity: 1;
}

#tree-container > svg {
  display: block;
  width: 100%;
  height: 100%;
}

.view-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: transparent;
  border: none;
  border-radius: 999px;
  color: #94a3b8;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.view-mode-btn .material-symbols-outlined {
  font-size: 18px;
  transition: transform 0.2s ease;
}

.view-mode-btn:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.08);
}

.view-mode-btn.active {
  color: #ffffff;
  background: linear-gradient(135deg, #0284c7 0%, #3b82f6 100%);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
  font-weight: 600;
}

.view-mode-menu.has-active-mode > .view-mode-btn {
  color: #ffffff;
  background: linear-gradient(135deg, #0284c7 0%, #3b82f6 100%);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
  font-weight: 600;
}

.view-mode-btn.active .material-symbols-outlined {
  transform: scale(1.1);
}

.view-mode-evidence-btn {
  padding-inline: 8px;
}

.tree-person-evidence-badge,
.tree-person-completeness-badge,
.tree-person-integrity-badge,
.tree-link-evidence-badge {
  display: none;
  pointer-events: none;
}

body.tree-evidence-visible .tree-person-evidence-badge,
body.tree-evidence-visible .tree-person-completeness-badge,
body.tree-evidence-visible .tree-person-integrity-badge,
body.tree-evidence-visible .tree-link-evidence-badge {
  display: block;
  pointer-events: auto;
  cursor: help;
}

.tree-person-evidence-badge rect,
.tree-person-completeness-badge rect,
.tree-person-integrity-badge rect,
.tree-link-evidence-badge circle {
  fill: #f8fafc;
  stroke: #64748b;
  fill-opacity: 0.68;
  stroke-opacity: 0.76;
  stroke-width: 1;
  shape-rendering: geometricPrecision;
  transition:
    fill-opacity 0.15s ease,
    stroke-width 0.15s ease,
    filter 0.15s ease;
}

.tree-person-evidence-badge text,
.tree-person-completeness-badge text,
.tree-person-integrity-badge text,
.tree-link-evidence-badge text {
  fill: #334155;
  font-family: 'Inter', sans-serif;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: -0.15px;
  opacity: 0.82;
  user-select: none;
}

/* Hover highlights on badges */
body.tree-evidence-visible .tree-person-evidence-badge:hover rect,
body.tree-evidence-visible .tree-person-completeness-badge:hover rect,
body.tree-evidence-visible .tree-person-integrity-badge:hover rect {
  fill-opacity: 0.95;
  stroke-width: 1.4;
  filter: drop-shadow(0 2px 4px rgba(15, 23, 42, 0.18));
}

body.tree-evidence-visible .tree-person-evidence-badge:hover text,
body.tree-evidence-visible .tree-person-completeness-badge:hover text,
body.tree-evidence-visible .tree-person-integrity-badge:hover text {
  opacity: 1;
}

.tree-person-evidence-badge.status-asserted rect {
  fill: #f8fafc;
  fill-opacity: 0.42;
  stroke-opacity: 0.54;
}

.tree-person-evidence-badge.status-asserted text {
  opacity: 0.68;
}

.tree-link-evidence-badge.status-verified circle {
  fill: #dcfce7;
  stroke: #16a34a;
}

.tree-link-evidence-badge.status-verified text {
  fill: #166534;
}

.tree-person-evidence-badge.status-near_certain rect,
.tree-link-evidence-badge.status-attested circle {
  fill: #ecfdf5;
  stroke: #10b981;
  fill-opacity: 0.7;
}

.tree-person-evidence-badge.status-near_certain text,
.tree-link-evidence-badge.status-attested text {
  fill: #047857;
}

.tree-person-evidence-badge.status-probable rect,
.tree-link-evidence-badge.status-candidate circle {
  fill: #fffbeb;
  stroke: #f59e0b;
  fill-opacity: 0.7;
}

.tree-person-evidence-badge.status-probable text,
.tree-link-evidence-badge.status-candidate text {
  fill: #92400e;
}

.tree-person-evidence-badge.status-possible rect {
  fill: #fff7ed;
  stroke: #f97316;
  fill-opacity: 0.7;
}

.tree-person-evidence-badge.status-possible text {
  fill: #9a3412;
}

.tree-link-evidence-badge.status-contested circle {
  fill: #fef2f2;
  stroke: #ef4444;
  fill-opacity: 0.7;
}

.tree-link-evidence-badge.status-contested text {
  fill: #b91c1c;
}

/* Completeness Badge Color Styles */
.tree-person-completeness-badge.status-emerald rect {
  fill: #ecfdf5;
  stroke: #10b981;
  fill-opacity: 0.82;
  stroke-opacity: 0.9;
}

.tree-person-completeness-badge.status-emerald text {
  fill: #047857;
  opacity: 0.95;
}

.tree-person-completeness-badge.status-blue rect {
  fill: #eff6ff;
  stroke: #3b82f6;
  fill-opacity: 0.82;
  stroke-opacity: 0.9;
}

.tree-person-completeness-badge.status-blue text {
  fill: #1d4ed8;
  opacity: 0.95;
}

.tree-person-completeness-badge.status-amber rect {
  fill: #fffbeb;
  stroke: #f59e0b;
  fill-opacity: 0.82;
  stroke-opacity: 0.9;
}

.tree-person-completeness-badge.status-amber text {
  fill: #b45309;
  opacity: 0.95;
}

/* Integrity Alert Badge Color Styles */
.tree-person-integrity-badge.status-error rect {
  fill: #fef2f2;
  stroke: #ef4444;
  fill-opacity: 0.92;
  stroke-opacity: 0.95;
  stroke-width: 1.2;
}

.tree-person-integrity-badge.status-error text {
  fill: #b91c1c;
  font-size: 9px;
  font-weight: 800;
  opacity: 1;
}

.tree-person-integrity-badge.status-warning rect {
  fill: #fffbeb;
  stroke: #f59e0b;
  fill-opacity: 0.92;
  stroke-opacity: 0.95;
  stroke-width: 1.2;
}

.tree-person-integrity-badge.status-warning text {
  fill: #b45309;
  font-size: 9px;
  font-weight: 800;
  opacity: 1;
}

.tree-link-evidence-hit {
  display: none;
  fill: none;
  stroke: transparent;
  stroke-width: 14px;
  vector-effect: non-scaling-stroke;
}

body.tree-evidence-visible .tree-link-evidence-hit {
  display: block;
  pointer-events: stroke;
  cursor: help;
}

body.tree-evidence-visible path.link.evidence-verified {
  stroke: #16a34a !important;
}

body.tree-evidence-visible path.link.evidence-attested {
  stroke: #10b981 !important;
}

body.tree-evidence-visible path.link.evidence-candidate {
  stroke: #f59e0b !important;
}

body.tree-evidence-visible path.link.evidence-contested {
  stroke: #ef4444 !important;
}

.view-mode-btn:focus-visible,
.alternative-view-action:focus-visible,
.alternative-view-search input:focus-visible,
.map-person-button:focus-visible {
  outline: 2px solid #7dd3fc;
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .view-mode-selector {
    top: 8px;
    padding: 3px;
  }
  .view-mode-btn {
    padding: 5px 10px;
    font-size: 12px;
  }
  .view-mode-label {
    display: none;
  }
  .view-mode-chevron {
    display: inline-block;
    margin-right: -4px;
  }
  .view-mode-dropdown {
    min-width: 158px;
  }
}

/* Mode Background Themes for Seamless Viewports */
#tree-section.mode-fan,
#tree-section.mode-timeline,
#tree-section.mode-map,
#tree-section.mode-surnames {
  background: #0b1120 !important;
  background-color: #0b1120 !important;
  background-image: none !important;
  transition: background 0.4s ease;
}

#tree-section.mode-fan::before,
#tree-section.mode-timeline::before,
#tree-section.mode-map::before,
#tree-section.mode-surnames::before {
  background-image: radial-gradient(
    rgba(255, 255, 255, 0.08) 0.8px,
    transparent 0.8px
  ) !important;
  opacity: 0.8 !important;
}

/* Shared premium chrome for timeline and map */
.alternative-view-chrome {
  box-sizing: border-box;
  color: #e2e8f0;
  font-family: 'Inter', sans-serif;
}

.alternative-view-toolbar {
  position: absolute;
  top: 68px;
  left: 16px;
  right: 16px;
  z-index: 90;
  display: flex;
  min-height: 58px;
  align-items: center;
  gap: 12px;
  padding: 9px 10px 9px 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.88);
  box-shadow: 0 18px 48px rgba(2, 6, 23, 0.28);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.alternative-view-toolbar.is-timeline {
  top: 108px;
}

.alternative-view-toolbar.is-map {
  right: auto;
  left: 50%;
  width: max-content;
  max-width: calc(100% - 32px);
  transform: translateX(-50%);
}

.fan-surname-strip {
  position: absolute;
  top: 68px;
  right: auto;
  left: 50%;
  z-index: 89;
  display: flex;
  width: max-content;
  max-width: calc(100% - 32px);
  min-height: 46px;
  align-items: center;
  gap: 14px;
  padding: 8px 10px 8px 13px;
  border: 1px solid rgba(148, 163, 184, 0.17);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.84);
  box-shadow: 0 12px 32px rgba(2, 6, 23, 0.24);
  transform: translateX(-50%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.fan-view-heading,
.fan-surname-heading {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 2px;
}

.fan-view-heading {
  min-width: 172px;
}

.fan-generation-control {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 2px;
  padding-left: 14px;
  border-left: 1px solid rgba(148, 163, 184, 0.16);
  color: #64748b;
  font-size: 9px;
}

.fan-generation-control select {
  min-width: 118px;
  height: 28px;
  padding: 0 28px 0 10px;
  border: 1px solid rgba(125, 211, 252, 0.22);
  border-radius: 999px;
  outline: none;
  background: rgba(14, 165, 233, 0.1);
  color: #e2e8f0;
  font: inherit;
  font-size: 10px;
  font-weight: 650;
  cursor: pointer;
}

.fan-generation-control select:focus-visible {
  border-color: rgba(56, 189, 248, 0.72);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.16);
}

.fan-generation-control option {
  background: #0f172a;
  color: #e2e8f0;
}

.fan-view-heading strong,
.fan-surname-heading strong {
  color: #f8fafc;
  font-size: 12px;
}

.fan-view-heading span,
.fan-surname-heading span {
  color: #64748b;
  font-size: 9px;
  white-space: nowrap;
}

.fan-surname-heading {
  min-width: 128px;
}

.fan-facet-block {
  position: relative;
  display: flex;
  min-width: 0;
  flex: 1 1 0;
  align-items: flex-start;
  gap: 10px;
  padding-left: 14px;
  border-left: 1px solid rgba(148, 163, 184, 0.16);
}

.fan-facet-picker {
  position: relative;
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
}

.fan-facet-value {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 30px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 5px 4px 10px;
  border: 1px solid rgba(125, 211, 252, 0.16);
  border-radius: 10px;
  background: rgba(14, 165, 233, 0.09);
  color: #cbd5e1;
  font: inherit;
  font-size: 10px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}

.fan-facet-value > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fan-facet-value > strong {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0 4px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.18);
  color: #7dd3fc;
  font-size: 9px;
}

.fan-facet-primary {
  width: min(190px, 20vw);
  min-height: 34px;
  border-color: rgba(56, 189, 248, 0.3);
  background: rgba(14, 165, 233, 0.14);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 750;
}

.fan-facet-value:hover,
.fan-facet-value:focus-visible,
.fan-facet-value.is-active {
  border-color: rgba(125, 211, 252, 0.72);
  outline: none;
  background: rgba(14, 165, 233, 0.24);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}

.fan-facet-origin .fan-facet-value {
  border-color: rgba(251, 191, 36, 0.22);
  background: rgba(245, 158, 11, 0.1);
}

.fan-facet-origin .fan-facet-value > strong {
  background: rgba(245, 158, 11, 0.2);
  color: #fde68a;
}

.fan-facet-origin .fan-facet-value:hover,
.fan-facet-origin .fan-facet-value:focus-visible,
.fan-facet-origin .fan-facet-value.is-active {
  border-color: rgba(251, 191, 36, 0.74);
  background: rgba(245, 158, 11, 0.22);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12);
}

.fan-facet-menu {
  position: relative;
  flex: 0 0 auto;
}

.fan-facet-menu > summary {
  display: flex;
  min-width: 48px;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0 7px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 10px;
  background: rgba(30, 41, 59, 0.76);
  color: #94a3b8;
  font-size: 10px;
  font-weight: 750;
  list-style: none;
  cursor: pointer;
}

.fan-facet-menu > summary::-webkit-details-marker {
  display: none;
}

.fan-facet-menu > summary .material-symbols-outlined {
  font-size: 17px;
  transition: transform 0.16s ease;
}

.fan-facet-menu[open] > summary .material-symbols-outlined {
  transform: rotate(180deg);
}

.fan-facet-menu > summary:hover,
.fan-facet-menu > summary:focus-visible,
.fan-facet-menu.has-active-item > summary {
  border-color: rgba(125, 211, 252, 0.5);
  outline: none;
  color: #e2e8f0;
}

.fan-surname-list {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  z-index: 6;
  display: flex;
  width: min(250px, 68vw);
  max-height: min(360px, 52vh);
  flex-direction: column;
  gap: 5px;
  overflow-x: hidden;
  overflow-y: auto;
  margin: 0;
  padding: 7px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.98);
  box-shadow: 0 16px 38px rgba(2, 6, 23, 0.46);
  list-style: none;
  scrollbar-color: rgba(100, 116, 139, 0.5) transparent;
  scrollbar-width: thin;
}

.fan-surname-list::-webkit-scrollbar {
  width: 6px;
}

.fan-fit-action {
  flex: 0 0 38px;
}

.fan-controls-toggle {
  display: none;
  flex: 0 0 38px;
}

.fan-controls-toggle-icon {
  display: block;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  transform: translateY(-1px);
}

.fan-surname-list li {
  display: block;
}

.fan-surname-list li .fan-facet-value {
  width: 100%;
}

.fan-surname-empty {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 5px 9px;
  border-color: rgba(148, 163, 184, 0.12);
  border-radius: 10px;
  background: rgba(100, 116, 139, 0.08);
  color: #64748b;
  font-size: 9px;
}

.fan-view-container {
  font-family: 'Inter', sans-serif;
}

.fan-person-segment {
  outline: none;
  cursor: pointer;
  transition: opacity 0.18s ease;
}

.fan-placeholder-segment .fan-segment-shape {
  fill: rgba(30, 41, 59, 0.28);
  stroke: rgba(148, 163, 184, 0.18);
  stroke-width: 1;
}

.fan-segment-shape {
  fill: #12314f;
  stroke: rgba(186, 230, 253, 0.34);
  stroke-width: 1.2;
  transition:
    fill 0.16s ease,
    filter 0.16s ease,
    stroke 0.16s ease;
}

.fan-person-segment.generation-0 .fan-segment-shape {
  fill: #075985;
}

.fan-person-segment.generation-1 .fan-segment-shape {
  fill: #0c4a6e;
}

.fan-person-segment.generation-2 .fan-segment-shape {
  fill: #164e63;
}

.fan-person-segment.generation-3 .fan-segment-shape {
  fill: #134e4a;
}

.fan-person-segment.generation-4 .fan-segment-shape {
  fill: #1e3a5f;
}

.fan-person-segment.generation-5 .fan-segment-shape,
.fan-person-segment.generation-6 .fan-segment-shape {
  fill: #243b53;
}

.fan-person-segment:hover .fan-segment-shape,
.fan-person-segment:focus-visible .fan-segment-shape,
.fan-person-segment.glow-active .fan-segment-shape {
  fill: #0369a1;
  stroke: #bae6fd;
  stroke-width: 2;
  filter: drop-shadow(0 5px 10px rgba(14, 165, 233, 0.32));
}

.fan-view-container.has-line-highlight .fan-person-segment.is-line-muted {
  opacity: 0.2;
}

.fan-view-container.has-line-highlight .fan-placeholder-segment {
  opacity: 0.12;
}

.fan-view-container.has-line-highlight
  .fan-person-segment.is-line-highlighted
  .fan-segment-shape {
  fill: #0284c7;
  stroke: #e0f2fe;
  stroke-width: 2.4;
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.58));
}

.fan-view-container.has-line-highlight
  .fan-person-segment.is-line-match
  .fan-segment-shape {
  fill: #0ea5e9;
  stroke: #fff;
  stroke-width: 3.2;
}

.fan-view-container.has-line-highlight.is-origin-line-highlight
  .fan-person-segment.is-line-highlighted
  .fan-segment-shape {
  fill: #b45309;
  stroke: #fde68a;
  filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.58));
}

.fan-view-container.has-line-highlight.is-origin-line-highlight
  .fan-person-segment.is-line-match
  .fan-segment-shape {
  fill: #d97706;
  stroke: #fff7ed;
}

.fan-person-label {
  fill: #f8fafc;
  font-size: 11px;
  font-weight: 720;
  pointer-events: none;
}

.fan-person-years {
  fill: #94a3b8;
  font-size: 9px;
  font-weight: 550;
}

.fan-person-avatar {
  pointer-events: none;
}

.fan-person-avatar text {
  fill: #fff;
  font-size: 10px;
  font-weight: 800;
}

@media (min-width: 641px) {
  .fan-surname-strip {
    width: min(1460px, calc(100% - 32px));
    align-items: center;
  }

  .fan-fit-action {
    align-self: center;
  }
}

@media (max-width: 640px) {
  .fan-surname-strip {
    top: 58px;
    right: auto;
    left: 50%;
    width: max-content;
    max-width: calc(100% - 20px);
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    transform: translateX(-50%);
  }
  .fan-controls-toggle {
    position: absolute;
    top: 8px;
    right: 54px;
    display: inline-grid;
  }
  .fan-view-heading {
    min-height: 38px;
    justify-content: center;
    padding-right: 88px;
  }
  .fan-view-heading,
  .fan-generation-control,
  .fan-surname-heading,
  .fan-facet-block {
    min-width: 0;
  }
  .fan-generation-control {
    padding-top: 6px;
    padding-left: 0;
    border-top: 1px solid rgba(148, 163, 184, 0.16);
    border-left: 0;
  }
  .fan-generation-control select {
    width: 100%;
  }
  .fan-facet-block {
    flex-direction: column;
    gap: 5px;
    padding-top: 6px;
    padding-left: 0;
    border-top: 1px solid rgba(148, 163, 184, 0.16);
    border-left: 0;
  }
  .fan-facet-picker,
  .fan-facet-primary {
    width: 100%;
  }
  .fan-facet-menu[open] {
    position: static;
  }
  .fan-facet-menu[open] .fan-surname-list {
    position: static;
    width: 100%;
    margin-top: 6px;
  }
  .fan-fit-action {
    position: absolute;
    top: 8px;
    right: 8px;
  }
  .fan-surname-strip.is-collapsed {
    width: auto;
    min-height: 46px;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 5px;
  }
  .fan-surname-strip.is-collapsed
    > :not(.fan-controls-toggle):not(.fan-fit-action) {
    display: none;
  }
  .fan-surname-strip.is-collapsed .fan-controls-toggle,
  .fan-surname-strip.is-collapsed .fan-fit-action {
    position: static;
  }
  .fan-person-label {
    font-size: 9px;
  }
}

.alternative-view-toolbar.is-map .alternative-view-search {
  width: 300px;
  flex: 0 1 300px;
}

.alternative-view-toolbar-copy {
  display: flex;
  min-width: 180px;
  flex-direction: column;
  gap: 2px;
}

.alternative-view-toolbar-copy strong,
.alternative-view-panel header strong {
  color: #f8fafc;
  font-size: 14px;
  font-weight: 700;
}

.alternative-view-summary,
.alternative-view-panel header span {
  color: #94a3b8;
  font-size: 11px;
  line-height: 1.35;
}

.alternative-view-search {
  display: flex;
  min-width: 180px;
  max-width: 340px;
  height: 38px;
  flex: 1;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 11px;
  background: rgba(2, 6, 23, 0.48);
}

.alternative-view-search .material-symbols-outlined {
  color: #64748b;
  font-size: 18px;
}

.alternative-view-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #f8fafc;
  font: inherit;
  font-size: 12px;
}

.alternative-view-search input::placeholder {
  color: #64748b;
}

.alternative-view-action {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border: 1px solid rgba(125, 211, 252, 0.24);
  border-radius: 11px;
  background: rgba(14, 165, 233, 0.12);
  color: #7dd3fc;
  cursor: pointer;
}

.alternative-view-action:hover {
  background: rgba(14, 165, 233, 0.22);
}

.alternative-view-action.active {
  background: rgba(14, 165, 233, 0.35);
  border-color: #38bdf8;
  color: #fff;
  box-shadow: 0 0 12px rgba(14, 165, 233, 0.4);
}

.alternative-view-action .material-symbols-outlined {
  font-size: 20px;
  width: 20px;
  overflow: hidden;
  pointer-events: none;
}

.alternative-view-legend {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  padding: 3px 1px;
  color: #94a3b8;
  font-size: 10px;
  scrollbar-width: none;
  white-space: nowrap;
}

.alternative-view-legend::-webkit-scrollbar {
  display: none;
}

.alternative-view-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.alternative-view-legend span::before {
  width: 13px;
  height: 7px;
  border-radius: 999px;
  background: #0ea5e9;
  content: '';
}

.alternative-view-legend .legend-female::before {
  background: #ec4899;
}

.alternative-view-legend .legend-unknown-sex::before {
  background: #8b5cf6;
}

.alternative-view-legend .legend-uncertain::before {
  box-sizing: border-box;
  border: 1px dashed #fbbf24;
  background: rgba(251, 191, 36, 0.08);
}

.alternative-view-legend .legend-missing::before {
  box-sizing: border-box;
  border: 1px dashed #94a3b8;
  background: rgba(100, 116, 139, 0.22);
}

.alternative-view-legend .legend-conflict::before {
  background: #dc2626;
}

/* Timeline */
.timeline-view-container {
  font-family: 'Inter', sans-serif;
}

.timeline-view-container.is-vertically-scrollable {
  cursor: grab;
}

.timeline-view-container.is-vertically-scrollable:active {
  cursor: grabbing;
}

.timeline-fixed-axis {
  position: absolute;
  top: 62px;
  right: 0;
  left: 0;
  z-index: 94;
  height: 40px;
  overflow: hidden;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(11, 17, 32, 0.96) 0%,
    rgba(11, 17, 32, 0.82) 72%,
    rgba(11, 17, 32, 0) 100%
  );
}

.timeline-fixed-axis line {
  stroke: rgba(148, 163, 184, 0.52);
  stroke-width: 1;
}

.timeline-fixed-axis line.is-current {
  stroke: #4ade80;
  stroke-width: 1.5;
}

.timeline-fixed-axis text {
  fill: #94a3b8;
  font-size: 10px;
  font-weight: 650;
}

.timeline-fixed-axis text.is-current {
  fill: #86efac;
  font-weight: 800;
}

.timeline-fixed-axis .timeline-fixed-axis-baseline {
  stroke: rgba(148, 163, 184, 0.28);
}

.timeline-axis-ticks line {
  stroke: rgba(148, 163, 184, 0.16);
  stroke-width: 1;
}

.timeline-axis-ticks line.is-current {
  stroke: rgba(34, 197, 94, 0.5);
}

.timeline-axis-labels text {
  fill: #64748b;
  font-size: 10px;
  font-weight: 600;
}

.timeline-axis-labels text.is-current {
  fill: #86efac;
}

.timeline-axis-baseline,
.timeline-row-separator {
  stroke: rgba(148, 163, 184, 0.14);
}

.timeline-row {
  cursor: pointer;
  outline: none;
}

.timeline-row:hover .timeline-life-bar,
.timeline-row:focus-visible .timeline-life-bar,
.timeline-row.glow-active .timeline-life-bar {
  filter: brightness(1.18) drop-shadow(0 5px 10px rgba(14, 165, 233, 0.25));
  stroke: rgba(255, 255, 255, 0.75);
  stroke-width: 1.2;
}

.timeline-life-bar {
  fill: #0ea5e9;
  stroke: rgba(255, 255, 255, 0.18);
  transition:
    filter 0.16s ease,
    stroke 0.16s ease;
}

.timeline-life-bar.sex-f {
  fill: #ec4899;
}

.timeline-life-bar.sex-u {
  fill: #8b5cf6;
}

.timeline-life-bar.is-uncertain {
  stroke: #fbbf24;
  stroke-width: 2;
  stroke-dasharray: 4 3;
}

.timeline-row.has-conflict .timeline-life-bar {
  fill: #dc2626;
}

.timeline-unknown-bar {
  fill: rgba(100, 116, 139, 0.22);
  stroke: rgba(148, 163, 184, 0.35);
  stroke-dasharray: 4 4;
}

.timeline-avatar circle {
  fill: #334155;
}

.timeline-avatar circle.sex-f {
  fill: #be185d;
}

.timeline-avatar circle.sex-m {
  fill: #0369a1;
}

.timeline-avatar text {
  fill: #fff;
  font-size: 9px;
  font-weight: 800;
  pointer-events: none;
}

.timeline-person-name {
  fill: #f8fafc;
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
}

.timeline-date-label {
  fill: #94a3b8;
  font-size: 10px;
  pointer-events: none;
}

.timeline-empty-message {
  fill: #94a3b8;
  font-size: 12px;
}

/* Map */
.map-ocean {
  fill: #081326;
}

.map-street-tiles,
.map-street-wash {
  pointer-events: none;
}

.map-street-tiles {
  opacity: 0;
  transition: none;
}

.map-street-tile {
  opacity: 0;
  filter: none;
  image-rendering: auto;
  transition: opacity 0.16s ease-out;
}

.map-street-tile.is-loaded {
  opacity: 0.82;
}

.map-street-wash {
  fill: #07111f;
  opacity: 0;
  transition: opacity 0.28s ease;
}

.map-landmasses,
.map-graticule {
  transition: opacity 0.28s ease;
}

.map-street-toggle.active {
  border-color: rgba(125, 211, 252, 0.68);
  background: linear-gradient(
    145deg,
    rgba(14, 165, 233, 0.34),
    rgba(34, 211, 238, 0.18)
  );
  color: #e0f2fe;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 7px 20px rgba(14, 165, 233, 0.22);
}

.map-attribution {
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: 92;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 7px 5px 6px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 999px;
  background: rgba(7, 17, 31, 0.78);
  box-shadow: 0 8px 28px rgba(2, 6, 23, 0.28);
  color: #94a3b8;
  font-size: 8px;
  line-height: 1;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease,
    transform 0.2s ease;
}

.map-attribution.is-street-hidden {
  transform: translateY(5px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.map-attribution a {
  color: #cbd5e1;
  text-decoration: none;
}

.map-attribution a:hover {
  color: #f8fafc;
  text-decoration: underline;
}

.map-detail-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.13);
  color: #7dd3fc;
  font-weight: 750;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.map-detail-chip .material-symbols-outlined {
  font-size: 11px;
}

.map-graticule {
  fill: none;
  stroke: rgba(148, 163, 184, 0.09);
  stroke-width: 0.6;
}

.map-landmasses path {
  fill: #17243a;
  stroke: #334155;
  stroke-width: 0.55;
  vector-effect: non-scaling-stroke;
}

.map-view-container.is-high-zoom .map-landmasses,
.map-view-container.is-high-zoom .map-graticule {
  display: none !important;
}

.map-landmass-fallback {
  fill: #17243a;
  opacity: 0;
  transition: opacity 0.28s ease;
  pointer-events: none;
}

.map-view-container.is-high-zoom .map-landmass-fallback {
  opacity: 0.2;
}

.map-view-container.is-city-detail .map-localities {
  display: none !important;
}

.map-locality {
  pointer-events: none;
}

.map-locality circle {
  fill: #64748b;
  stroke: rgba(15, 23, 42, 0.9);
  stroke-width: 1;
}

.map-locality text {
  fill: #94a3b8;
  font-size: 10px;
  font-weight: 650;
  paint-order: stroke;
  stroke: rgba(11, 17, 32, 0.96);
  stroke-linejoin: round;
  stroke-width: 3px;
}

.map-locality.is-relevant circle {
  fill: #38bdf8;
}

.map-locality.is-relevant text {
  fill: #e2e8f0;
  font-weight: 800;
}

.map-pin {
  cursor: pointer;
}

.map-movement-path {
  fill: none;
  stroke: rgba(56, 189, 248, 0.72);
  stroke-width: 2;
  stroke-dasharray: 7 6;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.map-view-container.is-map-zooming .map-movement-path {
  stroke-dasharray: none;
  stroke-linecap: butt;
  shape-rendering: optimizeSpeed;
}

.map-view-container.is-map-zooming .map-movement-path.glow-active {
  filter: none;
}

.map-movement-path.glow-active {
  stroke: #facc15;
  stroke-width: 3;
  filter: drop-shadow(0 0 7px rgba(250, 204, 21, 0.65));
}

.map-pin-aura {
  fill: rgba(14, 165, 233, 0.2);
  stroke: rgba(56, 189, 248, 0.32);
}

.map-person-avatar {
  pointer-events: none;
}

.map-avatar-fallback {
  stroke: rgba(255, 255, 255, 0.82);
  stroke-width: 1.5;
}

.map-avatar-initial {
  fill: #fff;
  font-size: 12px;
  font-weight: 850;
}

.map-event-badge {
  fill: #fff;
  font-size: 6px;
  font-weight: 900;
  paint-order: stroke;
  stroke: #0f172a;
  stroke-width: 3px;
  pointer-events: none;
}

.map-location-stack-badge {
  fill: rgba(15, 23, 42, 0.92);
  stroke: rgba(186, 230, 253, 0.9);
  stroke-width: 1.2;
  pointer-events: none;
}

.map-location-stack-count {
  fill: #f8fafc;
  font-size: 8px;
  font-weight: 900;
  pointer-events: none;
}

.map-person-marker:not(.is-location-stack) .map-location-stack-badge,
.map-person-marker:not(.is-location-stack) .map-location-stack-count {
  display: none;
}

.map-person-marker.is-location-stack .map-event-badge,
.map-person-marker.is-location-stack .map-age-badge {
  display: none;
}

.map-age-badge {
  pointer-events: none;
}

.map-age-badge-bg {
  fill: rgba(15, 23, 42, 0.95);
  stroke: rgba(56, 189, 248, 0.95);
  stroke-width: 1.2;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.map-age-badge-text {
  fill: #f8fafc;
  font-size: 8px;
  font-weight: 850;
  font-family:
    Inter,
    system-ui,
    -apple-system,
    sans-serif;
  letter-spacing: -0.2px;
}

.map-person-marker.is-location-stack .map-family-unit-badge {
  display: none;
}

.map-family-unit-badge {
  pointer-events: none;
}

.map-family-unit-badge-bg {
  fill: rgba(15, 23, 42, 0.96);
  stroke: rgba(245, 158, 11, 0.95);
  stroke-width: 1.2;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.map-family-unit-badge-text {
  fill: #fef3c7;
  font-size: 7.5px;
  font-weight: 850;
  font-family:
    Inter,
    system-ui,
    -apple-system,
    sans-serif;
  letter-spacing: -0.2px;
}

.map-pin-core {
  fill: #0284c7;
  stroke: #bae6fd;
  stroke-width: 1.5;
}

.map-pin.is-approximate .map-pin-aura {
  fill: rgba(245, 158, 11, 0.18);
  stroke: rgba(251, 191, 36, 0.4);
}

.map-pin.is-approximate .map-pin-core {
  fill: #b45309;
  stroke: #fde68a;
}

.map-person-marker {
  outline: none;
}

/* Luogo ambiguo: mostrato sul comune più probabile, da verificare. */
.map-person-marker.is-ambiguous .map-pin-aura {
  fill: rgba(239, 68, 68, 0.16);
  stroke: rgba(248, 113, 113, 0.75);
  stroke-dasharray: 3 2;
  stroke-width: 1.5;
}

.map-legend {
  position: absolute;
  left: 16px;
  bottom: 24px;
  z-index: 94;
  display: none;
  width: min(320px, calc(100vw - 32px));
  max-height: min(60vh, 420px);
  overflow: auto;
  padding: 12px 14px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.94);
  color: #e2e8f0;
  font-size: 12px;
  box-sizing: border-box;
}

.map-legend.is-open {
  display: block;
}

.map-legend h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

.map-legend dl {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 6px 10px;
  margin: 0;
}

.map-legend dt {
  font-weight: 700;
  text-align: center;
  color: #fbbf24;
}

.map-legend dt.material-symbols-outlined {
  font-size: 16px;
  color: #2dd4bf;
}

.map-legend dd {
  margin: 0;
}

/* Posizione nell'anno: dedotta (figli, matrimonio, coniuge) o approssimata
   (solo nascita o morte). La residenza documentata resta piena. */
.map-person-marker.is-position-inferred .map-pin-aura {
  stroke-dasharray: 4 3;
  stroke-width: 1.5;
}

.map-person-marker.is-position-approximate .map-pin-aura {
  stroke-dasharray: 2 4;
  stroke-width: 1.5;
}

.map-person-marker.is-position-approximate .map-person-avatar {
  opacity: 0.78;
}

.map-pin:hover .map-pin-aura,
.map-pin:focus-visible .map-pin-aura,
.map-pin.is-selected .map-pin-aura,
.map-pin.glow-active .map-pin-aura {
  stroke: #fff;
  stroke-width: 2;
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.65));
}

.map-pin-count {
  fill: #fff;
  font-size: 9px;
  font-weight: 800;
  pointer-events: none;
}

.map-pin-label rect {
  fill: rgba(15, 23, 42, 0.9);
  stroke: rgba(148, 163, 184, 0.25);
}

.map-pin-label {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.16s ease,
    visibility 0.16s ease;
}

.map-person-marker:hover .map-pin-label,
.map-person-marker:focus-visible .map-pin-label,
.map-person-marker.is-selected .map-pin-label,
.map-person-marker.glow-active .map-pin-label {
  visibility: visible;
  opacity: 1;
}

.map-pin-label text {
  fill: #e2e8f0;
  font-size: 10px;
  font-weight: 650;
  pointer-events: none;
}

.map-pin-label .map-pin-person-name {
  fill: #f8fafc;
  font-weight: 800;
}

.map-pin-label .map-pin-event-copy {
  fill: #94a3b8;
  font-size: 9px;
}

.map-inline-error {
  fill: #fbbf24;
  font-size: 10px;
}

/* Map Spatio-Temporal Controller */
.map-time-controller {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 92;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: min(520px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.92);
  box-shadow: 0 20px 50px rgba(2, 6, 23, 0.45);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease,
    visibility 0.25s;
}

.map-time-controller.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-50%) translateY(14px);
}

.map-time-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.map-time-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(2, 6, 23, 0.5);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.14);
}

.map-time-pill {
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.map-time-pill:hover {
  color: #f1f5f9;
}

.map-time-pill.is-active {
  background: rgba(14, 165, 233, 0.25);
  color: #38bdf8;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.map-time-pill-divider {
  width: 1px;
  height: 14px;
  background: rgba(148, 163, 184, 0.25);
  margin: 0 2px;
}

.map-family-group-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.map-family-group-pill .material-symbols-outlined {
  font-size: 13px;
}

.map-family-group-pill.is-active {
  background: rgba(245, 158, 11, 0.22);
  color: #fbbf24;
  box-shadow: 0 1px 4px rgba(245, 158, 11, 0.25);
}

.alternative-view-action.map-family-toggle.active {
  background: rgba(245, 158, 11, 0.22);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.45);
}

.map-time-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-time-count-badge {
  font-size: 11px;
  font-weight: 600;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.07);
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.map-time-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}

.map-time-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.map-time-btn .material-symbols-outlined {
  font-size: 18px;
}

.map-time-btn.map-time-play-btn {
  width: 36px;
  height: 36px;
  background: rgba(14, 165, 233, 0.2);
  border-color: rgba(56, 189, 248, 0.35);
  color: #38bdf8;
}

.map-time-btn.map-time-play-btn:hover {
  background: rgba(14, 165, 233, 0.32);
}

.map-time-btn.map-time-play-btn.is-playing {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(248, 113, 113, 0.35);
  color: #f87171;
}

.map-time-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.map-time-slider-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.map-time-range-label {
  font-size: 13px;
  font-weight: 700;
  color: #f8fafc;
  text-align: center;
  letter-spacing: 0.02em;
}

.map-time-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(148, 163, 184, 0.28);
  outline: none;
  cursor: pointer;
}

.map-time-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.map-time-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.map-time-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
  cursor: pointer;
}

.map-time-slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  font-weight: 500;
  color: #64748b;
  padding: 0 2px;
}

.map-time-window-select {
  background: rgba(2, 6, 23, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 11px;
  padding: 4px 6px;
  outline: none;
  cursor: pointer;
}

.map-time-window-select option {
  background: #0f172a;
  color: #cbd5e1;
}

/* Map Family Unit Popover */
.map-family-unit-popover.map-documented-household-popover {
  left: 16px;
  top: 80px;
  max-height: min(65vh, 600px);
  overflow: auto;
  padding: 16px;
  gap: 10px;
  color: #e2e8f0;
  box-sizing: border-box;
}
.map-household-marker {
  cursor: pointer;
}

.map-household-marker .map-household-icon {
  font-size: 15px;
}

.map-household-marker .map-household-count {
  font-size: 9px;
  font-weight: 700;
}

.map-family-list-button .map-person-initial {
  font-size: 18px;
}
.map-family-unit-popover {
  position: absolute;
  top: 68px;
  left: 16px;
  z-index: 95;
  display: flex;
  flex-direction: column;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100% - 150px);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.94);
  box-shadow:
    0 24px 60px rgba(2, 6, 23, 0.65),
    0 0 0 1px rgba(245, 158, 11, 0.15);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow: hidden;
  animation: mapFamilyPopoverEnter 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes mapFamilyPopoverEnter {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.map-family-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(2, 6, 23, 0.4);
}

.map-family-popover-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.map-family-popover-title-row .material-symbols-outlined {
  color: #fbbf24;
  font-size: 20px;
  flex-shrink: 0;
}

.map-family-popover-title {
  font-size: 13.5px;
  font-weight: 750;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.map-family-popover-header-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.map-family-popover-year-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
  letter-spacing: 0.02em;
}

.map-family-popover-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s ease;
}

.map-family-popover-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(148, 163, 184, 0.2);
}

.map-family-popover-close .material-symbols-outlined {
  font-size: 18px;
}

.map-family-popover-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  font-size: 11px;
  color: #94a3b8;
  background: rgba(2, 6, 23, 0.25);
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.map-family-popover-meta-strong {
  color: #cbd5e1;
  font-weight: 600;
}

.map-family-popover-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 14px;
  overflow-y: auto;
  min-height: 0;
}

.map-family-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.map-family-section-label {
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.map-family-section-empty {
  font-size: 11.5px;
  font-style: italic;
  color: #64748b;
  padding: 4px 6px;
}

.map-family-member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  width: 100%;
}

.map-family-member-row:hover {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.35);
  transform: translateX(2px);
}

.map-family-member-row.is-capo {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.35);
}

.map-family-member-row.is-capo:hover {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.55);
}

.map-family-member-row.is-married-out {
  opacity: 0.85;
  background: rgba(255, 255, 255, 0.015);
  border-style: dashed;
}

.map-family-member-avatar {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 1.5px solid rgba(148, 163, 184, 0.4);
  background: #1e293b;
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-family-member-avatar.sex-m {
  border-color: rgba(56, 189, 248, 0.65);
}

.map-family-member-avatar.sex-f {
  border-color: rgba(244, 114, 182, 0.65);
}

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

.map-family-member-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5px;
}

.map-family-member-name {
  font-size: 12px;
  font-weight: 650;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-family-member-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-family-role-tag {
  font-size: 9px;
  font-weight: 750;
  padding: 1px 5px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.map-family-role-tag.capo {
  background: rgba(245, 158, 11, 0.22);
  color: #fbbf24;
}

.map-family-role-tag.spouse {
  background: rgba(244, 114, 182, 0.2);
  color: #f472b6;
}

.map-family-role-tag.child {
  background: rgba(56, 189, 248, 0.16);
  color: #38bdf8;
}

.map-family-role-tag.documented {
  background: rgba(20, 184, 166, 0.18);
  color: #2dd4bf;
}

.map-family-role-tag.married-out {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
}

.map-family-member-age-pill {
  font-size: 10.5px;
  font-weight: 750;
  padding: 2px 7px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  white-space: nowrap;
  flex-shrink: 0;
}

.map-family-married-out-hint {
  font-size: 10.5px;
  color: #64748b;
  margin-top: -2px;
  padding-left: 2px;
}

.alternative-view-panel {
  position: absolute;
  top: 68px;
  right: 16px;
  bottom: 16px;
  z-index: 88;
  display: flex;
  width: 320px;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.92);
  box-shadow: 0 18px 48px rgba(2, 6, 23, 0.38);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition:
    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.alternative-view-panel.is-collapsed {
  transform: translateX(120%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.alternative-view-panel > header {
  padding: 15px 16px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.13);
}

.alternative-view-panel > header > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.alternative-view-panel-body {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  scrollbar-color: rgba(100, 116, 139, 0.5) transparent;
  scrollbar-width: thin;
}

.map-location-list section + section {
  margin-top: 12px;
}

.map-location-list h4 {
  margin: 8px 8px 6px;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.map-person-button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #e2e8f0;
  text-align: left;
  cursor: pointer;
}

.map-person-button:hover {
  background: rgba(148, 163, 184, 0.1);
}

.map-person-button > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.map-person-button strong,
.map-person-button small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-person-button strong {
  font-size: 12px;
}

.map-person-button small {
  color: #94a3b8;
  font-size: 10px;
}

.map-person-initial {
  display: inline-grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  border-radius: 50%;
  background: #0369a1;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.map-person-initial.sex-f {
  background: #be185d;
}

.map-person-initial.sex-u {
  background: #6d28d9;
}

.map-panel-empty {
  margin: 12px 8px;
  color: #86efac;
  font-size: 11px;
  line-height: 1.5;
}

.map-panel-empty.is-neutral {
  color: #94a3b8;
}

.map-cluster-details {
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.13);
}

/* Surnames */
.surname-view-container {
  position: absolute;
  top: 138px;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 86;
  display: grid;
  min-height: 0;
  grid-template-columns: minmax(245px, 310px) minmax(0, 1fr);
  gap: 12px;
  cursor: default;
}

.surname-index-panel,
.surname-detail-panel {
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.9);
  box-shadow: 0 18px 48px rgba(2, 6, 23, 0.3);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.surname-index-panel {
  display: flex;
  flex-direction: column;
}

.surname-index-panel > header,
.surname-detail-panel > header {
  position: static;
  z-index: auto;
  width: auto;
  height: auto;
  min-height: 0;
  box-sizing: border-box;
  background: transparent;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.surname-index-panel > header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 15px 14px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.13);
}

.surname-index-panel > header > strong {
  color: #f8fafc;
  font-size: 14px;
}

.surname-list-controls {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.surname-list-controls label {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.35);
  color: #64748b;
}

.surname-list-controls label .material-symbols-outlined {
  font-size: 17px;
}

.surname-list-controls select {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: #e2e8f0;
  font: inherit;
  font-size: 11px;
}

.surname-list-controls select {
  height: 34px;
}

.surname-list-controls option {
  background: #0f172a;
  color: #e2e8f0;
}

.surname-multiple-filter {
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 10px;
  background: transparent;
  color: #94a3b8;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.surname-multiple-filter .material-symbols-outlined {
  font-size: 17px;
}

.surname-multiple-filter:hover,
.surname-multiple-filter.active {
  border-color: rgba(56, 189, 248, 0.38);
  background: rgba(14, 165, 233, 0.12);
  color: #7dd3fc;
}

.surname-index-list,
.surname-detail-panel {
  overflow-y: auto;
  scrollbar-color: rgba(100, 116, 139, 0.55) transparent;
  scrollbar-width: thin;
}

.surname-index-list {
  min-height: 0;
  flex: 1;
  padding: 7px;
}

.surname-index-item {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: #e2e8f0;
  text-align: left;
  cursor: pointer;
}

.surname-index-item:hover {
  background: rgba(148, 163, 184, 0.08);
}

.surname-index-item.active {
  border-color: rgba(56, 189, 248, 0.28);
  background: rgba(14, 165, 233, 0.13);
}

.surname-index-item:focus-visible,
.surname-person-row:focus-visible,
.surname-primary-action:focus-visible,
.surname-secondary-action:focus-visible,
.surname-multiple-filter:focus-visible {
  outline: 2px solid #7dd3fc;
  outline-offset: 2px;
}

.surname-index-item > span:first-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.surname-index-item strong,
.surname-index-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.surname-index-item strong {
  color: #f8fafc;
  font-size: 12px;
}

.surname-index-item small {
  color: #64748b;
  font-size: 10px;
}

.surname-index-item-stats {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
}

.surname-index-item-stats > span {
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.18);
  color: #94a3b8;
  font-size: 9px;
  font-weight: 700;
}

.surname-index-item-stats .has-open-lines {
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
}

.surname-detail-panel {
  padding: 20px;
}

.surname-detail-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 0 0 18px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}

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

.surname-detail-header > div:first-child > span {
  color: #38bdf8;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.surname-detail-header h2 {
  margin: 5px 0 0;
  color: #f8fafc;
  font-family: 'Playfair Display', serif;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1;
}

.surname-detail-header p {
  margin: 7px 0 0;
  color: #94a3b8;
  font-size: 11px;
}

.surname-detail-metrics {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.surname-metric {
  display: inline-flex;
  min-width: 72px;
  flex-direction: column;
  gap: 1px;
  padding: 8px 10px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 11px;
  background: rgba(2, 6, 23, 0.34);
  text-align: center;
}

.surname-metric strong {
  color: #f8fafc;
  font-size: 15px;
}

.surname-metric small {
  color: #64748b;
  font-size: 9px;
  text-transform: lowercase;
}

.surname-lineage-intro {
  margin: 15px 1px 11px;
  color: #94a3b8;
  font-size: 11px;
  line-height: 1.5;
}

.surname-lineage-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.surname-lineage-card {
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 14px;
  background: rgba(2, 6, 23, 0.26);
}

.surname-lineage-card[open] {
  border-color: rgba(56, 189, 248, 0.24);
  background: rgba(15, 23, 42, 0.62);
}

.surname-lineage-card > summary {
  display: flex;
  min-height: 72px;
  align-items: center;
  gap: 14px;
  padding: 11px 13px;
  list-style: none;
  cursor: pointer;
}

.surname-lineage-card > summary::-webkit-details-marker {
  display: none;
}

.surname-lineage-founder {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 2px;
}

.surname-lineage-founder small {
  color: #38bdf8;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.surname-lineage-founder strong {
  overflow: hidden;
  color: #f8fafc;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.surname-lineage-founder > span {
  color: #64748b;
  font-size: 10px;
}

.surname-lineage-founder .surname-lineage-form-summary {
  overflow: hidden;
  color: #7dd3fc;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.surname-lineage-founder .surname-current-user-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  padding: 3px 7px;
  border: 1px solid rgba(52, 211, 153, 0.28);
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
  font-size: 9px;
  font-weight: 800;
}

.surname-current-user-badge .material-symbols-outlined {
  font-size: 13px;
}

.surname-lineage-stats {
  display: flex;
  gap: 6px;
}

.surname-lineage-stats .surname-metric {
  min-width: 64px;
  padding: 6px 8px;
}

.surname-lineage-card > summary > .material-symbols-outlined {
  color: #64748b;
  transition: transform 0.18s ease;
}

.surname-lineage-card[open] > summary > .material-symbols-outlined {
  transform: rotate(180deg);
}

.surname-lineage-body {
  padding: 0 13px 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.1);
}

.surname-lineage-forms {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.surname-lineage-forms > strong {
  flex: 0 0 auto;
  color: #94a3b8;
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.surname-lineage-form-list {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 5px;
}

.surname-lineage-form-chip {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border: 1px solid rgba(148, 163, 184, 0.13);
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.1);
  color: #94a3b8;
  font-size: 9px;
  font-weight: 700;
}

.surname-lineage-form-chip.is-primary {
  border-color: rgba(56, 189, 248, 0.24);
  background: rgba(14, 165, 233, 0.13);
  color: #7dd3fc;
}

.surname-lineage-places-empty {
  color: #64748b;
  font-size: 10px;
  font-style: italic;
}

.surname-lineage-place-chip.is-primary {
  border-color: rgba(52, 211, 153, 0.28);
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
}

.surname-lineage-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  padding: 10px 0;
}

.surname-primary-action,
.surname-secondary-action {
  display: inline-flex;
  min-height: 35px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 11px;
  border-radius: 10px;
  font: inherit;
  font-size: 10px;
  font-weight: 750;
  cursor: pointer;
}

.surname-primary-action {
  border: 1px solid #0284c7;
  background: #0284c7;
  color: #fff;
}

.surname-primary-action:hover {
  background: #0369a1;
}

.surname-secondary-action {
  border: 1px solid rgba(125, 211, 252, 0.22);
  background: rgba(14, 165, 233, 0.1);
  color: #7dd3fc;
}

.surname-secondary-action:hover {
  background: rgba(14, 165, 233, 0.2);
}

.surname-primary-action .material-symbols-outlined,
.surname-secondary-action .material-symbols-outlined {
  font-size: 17px;
}

.surname-generation + .surname-generation {
  margin-top: 12px;
}

.surname-generation h4 {
  margin: 0 0 6px;
  color: #64748b;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.surname-generation-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 6px;
}

.surname-person-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(148, 163, 184, 0.045);
  color: #e2e8f0;
  text-align: left;
  cursor: pointer;
}

.surname-person-row:hover {
  border-color: rgba(148, 163, 184, 0.16);
  background: rgba(148, 163, 184, 0.09);
}

.surname-person-row.glow-active {
  border-color: rgba(250, 204, 21, 0.75);
  box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.12);
}

.surname-person-initial {
  display: inline-grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  border-radius: 50%;
  background: #0369a1;
  color: #fff;
  font-size: 11px;
  font-weight: 850;
}

.surname-person-initial.sex-f {
  background: #be185d;
}

.surname-person-initial.sex-u {
  background: #6d28d9;
}

.surname-person-row > span:nth-child(2) {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 2px;
}

.surname-person-row strong,
.surname-person-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.surname-person-row strong {
  color: #f8fafc;
  font-size: 11px;
}

.surname-person-row small {
  color: #64748b;
  font-size: 9px;
}

.surname-match-badge {
  max-width: 90px;
  overflow: hidden;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.13);
  color: #7dd3fc;
  font-size: 8px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.surname-empty-state {
  display: grid;
  min-height: 180px;
  place-content: center;
  justify-items: center;
  gap: 7px;
  padding: 24px;
  color: #64748b;
  text-align: center;
}

.surname-empty-state .material-symbols-outlined {
  font-size: 30px;
}

.surname-empty-state strong {
  color: #cbd5e1;
  font-size: 13px;
}

.surname-empty-state p {
  max-width: 390px;
  margin: 0;
  font-size: 10px;
  line-height: 1.5;
}

.surname-view-container.is-updating {
  pointer-events: none;
  opacity: 0.7;
}

@media (max-width: 980px) {
  .alternative-view-toolbar.is-timeline {
    flex-wrap: wrap;
  }

  .alternative-view-toolbar.is-timeline .alternative-view-legend {
    flex: 1 1 100%;
    order: 5;
  }
}

@media (max-width: 820px) {
  .alternative-view-toolbar,
  .alternative-view-toolbar.is-map {
    top: 54px;
    right: 12px;
    left: 12px;
    min-height: 52px;
  }

  .alternative-view-toolbar.is-map {
    right: auto;
    left: 50%;
    width: max-content;
    max-width: calc(100% - 24px);
    transform: translateX(-50%);
  }

  .alternative-view-toolbar.is-map .alternative-view-search {
    width: 220px;
    flex-basis: 220px;
  }

  .alternative-view-toolbar.is-timeline {
    top: 102px;
  }

  .timeline-fixed-axis {
    top: 55px;
  }

  .alternative-view-toolbar-copy {
    min-width: 0;
  }

  .alternative-view-toolbar-copy strong {
    font-size: 12px;
  }

  .alternative-view-summary {
    display: none;
  }

  .alternative-view-panel {
    top: auto;
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
    max-height: min(38vh, 320px);
    border-radius: 14px;
  }

  .surname-view-container {
    top: 118px;
    right: 12px;
    bottom: 12px;
    left: 12px;
    display: flex;
    overflow-y: auto;
    flex-direction: column;
  }

  .surname-index-panel {
    min-height: 230px;
    max-height: 38%;
    flex: 0 0 38%;
  }

  .surname-detail-panel {
    min-height: 360px;
    flex: 1 0 auto;
    overflow: visible;
  }

  .map-time-controller {
    bottom: 12px;
    left: 12px;
    right: 12px;
    transform: none;
    min-width: 0;
    max-width: none;
    padding: 10px 12px;
    gap: 8px;
  }

  .map-time-controller.is-hidden {
    transform: translateY(14px);
  }

  .map-family-unit-popover {
    top: auto;
    bottom: 125px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 48vh;
  }
}

@media (max-width: 540px) {
  .alternative-view-toolbar {
    gap: 7px;
    padding: 7px;
  }

  .alternative-view-toolbar-copy {
    display: none;
  }

  .alternative-view-toolbar.is-timeline .alternative-view-legend {
    display: flex;
  }

  .alternative-view-search {
    min-width: 0;
    height: 36px;
  }

  .alternative-view-toolbar.is-map .alternative-view-search {
    width: min(160px, 40vw);
    flex-basis: min(160px, 40vw);
  }

  .alternative-view-action {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .map-attribution {
    bottom: 10px;
    left: 10px;
    max-width: calc(100% - 20px);
    gap: 5px;
    padding: 4px 6px 4px 5px;
  }

  .map-detail-chip {
    padding: 3px 5px;
  }

  .map-time-header {
    gap: 6px;
  }

  .map-time-pills {
    width: 100%;
    justify-content: space-between;
  }

  .map-time-pill {
    padding: 3px 6px;
    font-size: 10px;
    flex: 1;
    text-align: center;
  }

  .map-time-controls {
    gap: 8px;
  }

  .map-time-window-select {
    display: none;
  }

  .alternative-view-panel > header {
    padding: 11px 13px 9px;
  }

  .timeline-date-label {
    font-size: 9px;
  }

  .surname-detail-panel {
    padding: 14px;
  }

  .surname-detail-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .surname-detail-metrics {
    width: 100%;
  }

  .surname-detail-metrics .surname-metric {
    flex: 1;
  }

  .surname-lineage-card > summary {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .surname-lineage-stats {
    order: 3;
    width: 100%;
  }

  .surname-lineage-stats .surname-metric {
    flex: 1;
  }

  .surname-lineage-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

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

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

/* Immersive canvas shared by Diagram, Timeline, Map and Surnames. */
.view-mode-expand-btn {
  margin-left: 3px;
  border-left: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 0 999px 999px 0;
}

body.tree-canvas-expanded header,
body.tree-canvas-expanded #site-footer,
body.tree-canvas-expanded #identity-reminder {
  display: none !important;
}

body.tree-canvas-expanded .app-container,
body.tree-canvas-expanded main {
  width: 100%;
  height: var(--app-vh, 100dvh);
  min-height: var(--app-vh, 100dvh);
}

body.tree-canvas-expanded main {
  flex: 1 1 100%;
}

body.tree-canvas-expanded #tree-section {
  position: fixed;
  inset: 0;
  z-index: 1800;
  width: 100vw;
  height: var(--app-vh, 100dvh);
}

body.tree-canvas-expanded .view-mode-selector {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  z-index: 1950;
}

body.tree-canvas-expanded .print-tree-launch,
body.tree-canvas-expanded .site-feedback-launch {
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 1960;
}

@media (max-width: 640px) {
  .view-mode-selector {
    max-width: calc(100vw - 16px);
  }

  .view-mode-expand-btn {
    margin-left: 1px;
  }

  body.tree-canvas-expanded .view-mode-selector {
    top: max(8px, env(safe-area-inset-top));
  }
}
