/* 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);
}

#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-btn.active .material-symbols-outlined {
  transform: scale(1.1);
}

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

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

body.tree-evidence-visible .tree-person-evidence-badge,
body.tree-evidence-visible .tree-link-evidence-badge {
  display: block;
}

.tree-person-evidence-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;
}

.tree-person-evidence-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;
}

.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-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;
}

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;
  }
}

/* Mode Background Themes for Seamless Viewports */
#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-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%);
}

.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 .material-symbols-outlined {
  font-size: 20px;
}

.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-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-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 {
  display: none;
}

.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;
}

.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;
}

.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;
  }
}

@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;
  }

  .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));
  }
}
