:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --text: #e7ecf3;
  --muted: #9aa7b8;
  --accent: #6cb6ff;
  --border: #2d3a4d;
  --danger: #f85149;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.site-header nav { display: flex; gap: 1rem; }

.research-login-account {
  margin: 0.5rem 0 1.25rem;
  font-size: 0.95rem;
}

.container { max-width: 1100px; margin: 0 auto; padding: 1.25rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

.hero h1 { margin: 0 0 0.25rem; }
.meta, .footer-note, .empty { color: var(--muted); }
.place-present-day { font-size: 0.92em; margin: 0.15rem 0 0.35rem; }

.overview-stats h2,
.overview-links h2,
.overview-sources h2,
.overview-activity h2 {
  margin: 0 0 0.65rem;
  font-size: 1.1rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.stat {
  background: #111822;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
}

.stat-label {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.25rem;
}

.link-rows {
  margin: 0;
  padding-left: 1.15rem;
}

.link-rows li { margin: 0.35rem 0; }

.activity-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.activity-feed {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 28rem;
  overflow: auto;
}

.activity-item {
  display: grid;
  grid-template-columns: 11.5rem 1fr;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--border);
}

.activity-item:first-child { border-top: none; }

.activity-ts {
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  line-height: 1.25;
}

.activity-date { color: var(--text); }
.activity-time { color: var(--muted); }
.activity-time-utc {
  color: var(--muted);
  font-size: 0.72rem;
  opacity: 0.85;
}

.activity-meta { font-size: 0.78rem; margin-top: 0.15rem; }

.activity-item[data-kind="visit"] .activity-meta::before {
  content: "visit · ";
}
.activity-item[data-kind="discovery"] .activity-meta::before {
  content: "discovery · ";
}
.activity-item[data-kind="update"] .activity-meta::before {
  content: "update · ";
}

.activity-item[data-outcome="blocked"] .activity-body,
.activity-item[data-outcome="captcha"] .activity-body {
  color: var(--text);
}
.activity-item[data-outcome="blocked"] .badge.warn,
.activity-item[data-outcome="captcha"] .badge.warn,
.activity-item[data-outcome="error"] .badge.warn,
.activity-item[data-outcome="failed"] .badge.warn,
.activity-item[data-outcome="paused"] .badge.warn {
  margin-right: 0.35rem;
}

.source-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.source-table th,
.source-table td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}
.source-table th {
  color: var(--muted);
  font-weight: 600;
  border-top: none;
}
.source-actions {
  white-space: nowrap;
}
.source-btn {
  margin-right: 0.35rem;
  font-size: 0.82rem;
}

@media (max-width: 720px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .activity-item { grid-template-columns: 1fr; gap: 0.2rem; }
}

.filter-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 0.75rem;
  align-items: end;
}

.filters label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
}

input, select, button {
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #111822;
  color: var(--text);
}

button {
  cursor: pointer;
  background: #243044;
}

button:hover { border-color: var(--accent); }

.button-link {
  display: inline-block;
  padding: 0.55rem 0.65rem;
  margin-top: 0.35rem;
}

.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.75rem; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #243044;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.78rem;
  color: var(--text);
  text-decoration: none;
}

.chip.active, .chip:hover { border-color: var(--accent); }

.chip.member-surname {
  border-color: var(--accent);
  font-weight: 600;
}

.chip-count {
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

.chip-legend {
  margin: 0.75rem 0 0.15rem;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.55rem 0.45rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 0.85rem; }

.badge {
  display: inline-block;
  background: #243044;
  border-radius: 6px;
  padding: 0.15rem 0.45rem;
  font-size: 0.75rem;
}

.badge.local { border: 1px solid var(--accent); }
.badge.muted { color: var(--muted); }
.badge.divorced {
  margin-left: 0.35rem;
  color: #c9a227;
  border: 1px solid #c9a227;
  font-size: 0.75rem;
}
.badge.warn {
  color: #e6c27a;
  border: 1px solid #a67c3a;
}

.list-hint {
  font-size: 0.78rem;
  margin-top: 0.15rem;
  line-height: 1.3;
}

.research-links, .research-candidates {
  list-style: none;
  margin: 0.35rem 0 0.85rem;
  padding: 0;
}

.census-gap-years {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  list-style: none;
  margin: 0.5rem 0 0.35rem;
  padding: 0;
}

.census-gap-years a,
.census-gap-years span {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

.census-year-missing a {
  border-color: var(--danger);
}

.census-year-covered span {
  opacity: 0.85;
}

.census-year-destroyed span {
  opacity: 0.55;
  text-decoration: line-through;
}

.research-links li {
  margin: 0.35rem 0;
}

.research-links + h3,
.card > h3 {
  margin-top: 0.85rem;
}

.research-candidates {
  margin: 0.35rem 0 0;
  padding-left: 1.2rem;
}

.research-candidates li { margin-bottom: 0.75rem; }

.research-candidate {
  list-style: none;
  margin-left: -1.2rem;
  padding: 0.75rem 1rem;
  border-left: 4px solid #8a9099;
  background: rgba(0, 0, 0, 0.03);
  margin-bottom: 1rem;
}
.research-candidate.verdict-reject { border-left-color: #a33; }
.research-candidate.verdict-apply { border-left-color: #2a7; }
.research-candidate.verdict-review { border-left-color: #c90; }
.verdict-badge {
  display: inline-block;
  margin-left: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
}
.verdict-badge.verdict-reject { color: #a33; }
.verdict-badge.verdict-apply { color: #1a6b45; }
.verdict-badge.verdict-review { color: #8a6200; }
.reject-reasons { margin: 0.4rem 0; color: #8a3030; }
.adds-summary { margin: 0.5rem 0 0.25rem; }
.candidate-adds { margin: 0.25rem 0 0.75rem 1.2rem; }
.accept-candidate { margin: 0.5rem 0 0.75rem; }
.accept-candidate button { font-weight: 600; }
.research-not-matches .not-match-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}
.research-not-matches .not-match-item {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-left: 4px solid #a33;
  background: rgba(160, 50, 50, 0.06);
}
.research-not-matches .not-match-item .facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin: 0.35rem 0;
  font-size: 0.92rem;
}
.research-fields {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin-top: 0.5rem;
}
.research-fields th,
.research-fields td {
  text-align: left;
  padding: 0.25rem 0.4rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  vertical-align: top;
}
.research-fields tr.field-reject td { opacity: 0.75; }
.research-fields tr.field-apply td { background: color-mix(in srgb, #2a7 6%, transparent); }
.research-fields .before-cell {
  color: var(--muted);
  max-width: 14rem;
}
.review-after-input {
  width: min(100%, 22rem);
  max-width: 100%;
  box-sizing: border-box;
}
.research-review-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.75rem 0 1rem;
}
.research-review-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.research-review-card {
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  border-radius: 8px;
  padding: 0.85rem 1rem 1rem;
  background: var(--card-bg, transparent);
}
.research-review-head h2 {
  margin: 0;
  font-size: 1.15rem;
}
.research-review-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.85rem;
  margin-bottom: 0.35rem;
}
.research-review-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.research-record-ref-wrap {
  display: inline-flex;
  align-items: stretch;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
  background: rgba(108, 182, 255, 0.08);
}
.research-record-ref {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
  border: none;
  border-radius: 0;
  padding: 0.2rem 0.45rem;
  background: transparent;
  width: 12.5rem;
  min-width: 12.5rem;
  max-width: 14rem;
  user-select: all;
  cursor: text;
}
.research-record-ref:focus {
  outline: none;
  background: rgba(108, 182, 255, 0.16);
}
.research-record-copy {
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0;
  margin: 0;
  padding: 0.2rem 0.5rem;
  background: transparent;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.research-record-copy:hover,
.research-record-copy.is-copied {
  color: var(--accent);
  background: rgba(108, 182, 255, 0.12);
}
.research-review-tree {
  padding: 0.15rem 0.55rem;
  font-size: 0.9rem;
}
.research-review-field {
  font-weight: 600;
  color: var(--muted, #8a9a8a);
}
.research-review-aliases,
.research-review-parent {
  margin: 0.2rem 0;
}
.research-review-sources {
  margin-top: 0.35rem;
}
.research-review-parent a {
  text-decoration: none;
}
.research-review-parent a:hover {
  text-decoration: underline;
}
.research-corroboration {
  margin: 0.45rem 0 0.25rem;
  padding: 0.45rem 0.65rem;
  border-left: 3px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}
.research-corroboration.likelihood-likely {
  border-left-color: #3d9a5f;
}
.research-corroboration.likelihood-uncertain {
  border-left-color: #c9a227;
}
.research-corroboration.likelihood-unlikely {
  border-left-color: var(--danger);
}
.research-corroboration ul {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
}
.research-corroboration .corr-supports {
  color: #8fd4a8;
}
.research-corroboration .corr-concerns {
  color: #f0a0a0;
}
.research-review-match {
  margin: 0.45rem 0 0;
}
.research-review-match summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent, #2a5a3a);
}
.research-review-match p {
  margin: 0.4rem 0 0;
  max-width: 48rem;
}
.research-review-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.65rem 0.75rem;
  align-items: center;
  margin-top: 0.75rem;
}
.research-review-actions .inline-form,
.research-review-actions .deny-form {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}
.research-review-actions .deny-why {
  min-width: 10rem;
  width: 14rem;
  flex: 1 1 auto;
}
.research-review-actions button.danger {
  color: #fff;
  background: #a33;
  border-color: #822;
}
.research-review-actions button.primary {
  font-weight: 600;
}
.research-focus .facts { margin-top: 0.5rem; }

.residences-block {
  margin: 0.85rem 0 1rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.residences-block h3 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
  color: var(--accent);
}

.residence-list { list-style: none; padding: 0; margin: 0.35rem 0; }
.residence-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: baseline;
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.residence-place { font-weight: 600; }
.residence-period { color: var(--muted); }
.residence-note { color: var(--muted); font-size: 0.92rem; }

.person-header h1 { margin-top: 0; }
.facts p { margin: 0.25rem 0; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.75rem; }

.family-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.rel-block h3 { margin: 0 0 0.35rem; font-size: 0.95rem; color: var(--accent); }
.rel-block ul { margin: 0; padding-left: 1.1rem; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.photo-card {
  margin: 0;
  background: #111822;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.photo-card img {
  width: 100%;
  display: block;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: #0b1017;
}

.photo-placeholder { padding: 2rem 1rem; text-align: center; color: var(--muted); }
.photo-card figcaption { padding: 0.45rem 0.55rem; font-size: 0.78rem; color: var(--muted); }
.photo-card a.photo-open { display: block; }
.photo-card a.photo-open:hover img { opacity: 0.92; }
.photo-card.photo-pending { border-style: dashed; border-color: #a67c3a; }
.photo-card.photo-rejected { opacity: 0.75; }
.photo-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.35rem;
}
.photo-upload {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 0.55rem;
  max-width: 28rem;
}
.photo-upload h3 { margin: 0; font-size: 1rem; }
.photo-upload label { display: grid; gap: 0.2rem; font-size: 0.85rem; color: var(--muted); }
.photo-upload input[type="text"],
.photo-upload input[type="file"] {
  color: var(--text);
}
.photo-viewer {
  max-width: min(92vw, 56rem);
  max-height: 92vh;
  padding: 0.75rem 1rem 1rem;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.photo-viewer::backdrop { background: rgba(0, 0, 0, 0.65); }
.photo-viewer img {
  display: block;
  max-width: 88vw;
  max-height: 72vh;
  margin: 0.5rem auto 0;
}
.photo-viewer-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}
.photo-viewer-caption { margin: 0.5rem 0 0; }

.prose h2 { font-size: 1.1rem; color: var(--accent); }
.prose h3 { font-size: 1rem; margin-top: 1.25rem; }
.source-list { margin-bottom: 0.5rem; }
.breadcrumb { margin-bottom: 0.75rem; }

body.login-only .container {
  max-width: 420px;
  margin-top: 4rem;
}

.login-card h1 { margin-top: 0; }

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.stack-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
  color: var(--muted);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.service-links-panel {
  margin-top: 0.75rem;
}

.service-link-list {
  margin: 0.4rem 0 0.75rem;
  padding-left: 1.2rem;
}

.service-link-add {
  margin-top: 0.35rem;
  max-width: 36rem;
}

.service-link-add-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
}

.service-link-add-row input[type="text"] {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  max-width: 28rem;
  margin-top: 0;
  padding: 0.4rem 0.65rem;
  line-height: 1.25;
  height: 2.25rem;
  box-sizing: border-box;
}

.service-link-add-row button {
  flex: 0 0 auto;
  margin-top: 0;
  height: 2.25rem;
  padding: 0 0.9rem;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.85rem;
}

.form-actions { grid-column: 1 / -1; }

.inline-form {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  margin: 0.15rem 0;
}

.stack-mini {
  flex-direction: column;
  align-items: stretch;
}

.linkish {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-decoration: underline;
}

.nav-user { color: var(--muted); font-size: 0.85rem; }

.error { color: var(--danger); }
.notice { color: #3fb950; }

.temp-password-box {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(63, 185, 80, 0.08);
}

.temp-password-value {
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  user-select: all;
  word-break: break-all;
}

.research-flash {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: min(36rem, calc(100vw - 2rem));
  padding: 0.7rem 0.85rem 0.7rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  background: #1a2a1a;
  color: #3fb950;
  font-size: 0.95rem;
}

.research-flash.is-error {
  background: #2a1515;
  color: var(--danger);
}

.research-flash.is-fading {
  opacity: 0;
  transition: opacity 0.8s ease;
}

.research-flash .flash-dismiss {
  margin: 0;
  padding: 0.1rem 0.45rem;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
}

.research-flash .flash-dismiss:hover { opacity: 1; }

#research-candidates {
  scroll-margin-top: 1rem;
}

button.danger {
  background: #3d1f24;
  border-color: var(--danger);
  margin-top: 1rem;
}

.add-row { margin-top: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }

.actions { min-width: 14rem; }

.person-actions { padding-top: 0.85rem; padding-bottom: 0.85rem; }

.person-header-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.person-header-top h1 { margin: 0; }

.person-title-block {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
}

.honor-emblems {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.honor-emblem {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.55rem 0.25rem 0.3rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  background: #111822;
  font-size: 0.8rem;
}

.honor-emblem.via {
  opacity: 0.88;
  border-style: dashed;
}

.lineage-path {
  margin: 1rem 0 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.lineage-path:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.lineage-chain {
  list-style: none;
  margin: 0.75rem 0;
  padding: 0;
}

.lineage-chain li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.45rem 0.55rem;
  border-left: 2px solid var(--border);
  margin-left: 0.35rem;
}

.lineage-chain li.is-focus {
  border-left-color: var(--accent);
  background: rgba(17, 24, 34, 0.55);
}

.lineage-chain li.is-qualifier {
  border-left-color: #c4a35a;
  background: rgba(196, 163, 90, 0.08);
}

.lineage-arrow {
  color: var(--muted);
  font-size: 0.8rem;
  margin-left: 0.25rem;
}

.honor-short {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.85rem;
  height: 1.85rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.honor-old_300 .honor-short,
.honor-emblem.honor-old_300.compact {
  background: #5c3b16;
  color: #f3d9a4;
  border-color: #a67c3a;
}

.honor-sdrt .honor-short,
.honor-emblem.honor-sdrt.compact {
  background: #163a2a;
  color: #a8e0c0;
  border-color: #2f7a55;
}

.honor-texas_ranger .honor-short,
.honor-emblem.honor-texas_ranger.compact {
  background: #1a2332;
  color: #d4c4a0;
  border-color: #6b5a3e;
}

.honor-fredonian .honor-short,
.honor-emblem.honor-fredonian.compact {
  background: #3a2418;
  color: #e8c9a0;
  border-color: #8a6240;
}

.honor-tamu .honor-short,
.honor-emblem.honor-tamu.compact {
  background: #500000;
  color: #ffffff;
  border-color: #7a1414;
}

.honor-txst .honor-short,
.honor-emblem.honor-txst.compact {
  background: #501214;
  color: #c9a24b;
  border-color: #8d734a;
}

.honor-us_army .honor-short,
.honor-emblem.honor-us_army.compact {
  background: #4b5320;
  color: #f2f0e4;
  border-color: #8a9a3a;
}

.honor-us_navy .honor-short,
.honor-emblem.honor-us_navy.compact {
  background: #002868;
  color: #ffffff;
  border-color: #3d5a9a;
}

.honor-us_mc .honor-short,
.honor-emblem.honor-us_mc.compact {
  background: #8b1a1a;
  color: #f5f0e6;
  border-color: #c4a35a;
}

.honor-us_af .honor-short,
.honor-emblem.honor-us_af.compact {
  background: #00308f;
  color: #c8d8f0;
  border-color: #5b8fd9;
}

.honor-us_cg .honor-short,
.honor-emblem.honor-us_cg.compact {
  background: #1c3a5a;
  color: #f0a020;
  border-color: #d4a017;
}

.honor-conflict_civil_war .honor-short,
.honor-emblem.honor-conflict_civil_war.compact,
.honor-conflict_wwi .honor-short,
.honor-emblem.honor-conflict_wwi.compact,
.honor-conflict_wwii .honor-short,
.honor-emblem.honor-conflict_wwii.compact,
.honor-conflict_korea .honor-short,
.honor-emblem.honor-conflict_korea.compact,
.honor-conflict_vietnam .honor-short,
.honor-emblem.honor-conflict_vietnam.compact,
.honor-conflict_gulf .honor-short,
.honor-emblem.honor-conflict_gulf.compact,
.honor-conflict_oef .honor-short,
.honor-emblem.honor-conflict_oef.compact,
.honor-conflict_oif .honor-short,
.honor-emblem.honor-conflict_oif.compact {
  background: #1a1f24;
  color: #d8dde3;
  border-color: #6b7480;
  font-size: 0.62rem;
}

.military-block { margin-top: 0.35rem; }

.honor-emblem.compact {
  min-width: 1.85rem;
  height: 1.85rem;
  padding: 0 0.35rem;
  justify-content: center;
  font-weight: 700;
  font-size: 0.68rem;
}

.honor-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.tree-honors {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  margin-top: 0.15rem;
}

.gen-stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--panel);
}
.gen-step,
.gen-step-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 0.2rem 0.55rem;
  font-weight: 600;
  line-height: 1.2;
  user-select: none;
  color: var(--text);
}
.gen-step {
  text-decoration: none;
  background: transparent;
}
.gen-stepper > :not(:last-child) {
  border-right: 1px solid var(--border);
}
.gen-step-value {
  min-width: 2.25rem;
}
a.gen-step:hover {
  background: rgba(108, 182, 255, 0.12);
  color: var(--accent);
  text-decoration: none;
}
.gen-step.is-disabled {
  color: var(--muted);
  opacity: 0.45;
  cursor: default;
}

.tree-expand-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.65rem 0 0.35rem;
}

.tree-expand-controls .button-link.active {
  border-color: var(--accent);
  color: var(--accent);
}

.chart-mode-blurb {
  margin-top: 0.25rem;
  max-width: 42rem;
}

.evidence-list li.evidence-not-likeness {
  opacity: 0.92;
  border-left: 3px solid var(--muted, #888);
  padding-left: 0.5rem;
}

.evidence-list-select {
  list-style: none;
  padding-left: 0;
}

.evidence-select-row {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  cursor: pointer;
}

.evidence-select-row input[type="radio"] {
  margin-top: 0.35rem;
  flex-shrink: 0;
}

.evidence-select-body {
  flex: 1;
  min-width: 0;
}

.evidence-list li.evidence-selected {
  outline: 2px solid var(--accent, #3d6ea5);
  outline-offset: 2px;
  border-radius: 4px;
}

.evidence-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0.75rem 0 0.25rem;
}

.evidence-panel {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border, #ccc);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface, #f6f4ef) 92%, #000 8%);
}

.evidence-panel-danger {
  border-color: color-mix(in srgb, var(--danger, #f85149) 55%, var(--border, #ccc));
}

.evidence-garbage-form {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border, #ccc);
}

.evidence-deleted-list .inline-form {
  margin-top: 0.35rem;
}

.evidence-inscription {
  margin: 0.4rem 0 0;
  padding: 0.5rem 0.65rem;
  max-width: 36rem;
  white-space: pre-wrap;
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
  font-size: 0.85rem;
  line-height: 1.35;
  background: color-mix(in srgb, var(--surface, #f6f4ef) 88%, #000 12%);
  border-left: 3px solid var(--muted, #888);
}

.evidence-edit {
  margin-top: 0.4rem;
}

.evidence-edit > summary {
  cursor: pointer;
}

.focus-honors-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.55rem;
}

.emblems-popup {
  display: inline-block;
  position: relative;
  vertical-align: baseline;
}

.emblems-popup > summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #243044;
  font-size: 0.85rem;
  color: var(--accent);
}

.emblems-popup > summary::-webkit-details-marker { display: none; }

.emblems-popup > summary::after {
  content: " ▾";
  opacity: 0.7;
  font-size: 0.75em;
}

.emblems-popup[open] > summary::after {
  content: " ▴";
}

.emblems-popup[open] > summary {
  border-color: var(--accent);
}

.emblems-panel {
  position: absolute;
  z-index: 20;
  left: 0;
  top: calc(100% + 0.25rem);
  min-width: 15rem;
  max-width: 24rem;
  padding: 0.55rem 0.7rem;
  background: var(--card, #161b22);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.emblems-column {
  list-style: none;
  margin: 0;
  padding: 0;
  position: static;
  box-shadow: none;
  background: transparent;
  border: none;
  min-width: 0;
  max-width: none;
}

.emblems-column li {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

.emblems-column li:last-child { border-bottom: none; }

.emblems-column .emblem-title {
  font-size: 0.85rem;
}

.emblems-column .emblem-note {
  font-size: 0.75rem;
}

.emblem-legend-heading {
  margin: 0.65rem 0 0.25rem;
  font-size: 0.8rem;
}

.emblems-column.emblem-legend li {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
}

.print-only { display: none; }

.gc-empty {
  margin-top: 0.35rem;
  font-size: 0.75rem;
}

.person-header .facts { margin-bottom: 0.75rem; }

.person-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-start;
}

.education-block {
  margin: 0.85rem 0 1rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.education-block h3 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
  color: var(--accent);
}

.history-wiki-block {
  margin: 0.85rem 0 1rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.history-wiki-block h3 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
  color: var(--accent);
}

.history-wiki-block ul {
  margin: 0;
  padding-left: 1.1rem;
}

.history-wiki-block li {
  margin: 0.2rem 0;
}

.education-list {
  list-style: none;
  margin: 0 0 0.65rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.education-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem;
}

.education-school { font-weight: 600; }
.education-detail { color: var(--muted); font-size: 0.9rem; }

.education-add { margin-top: 0.35rem; }

.research-question-body {
  margin: 0.35rem 0 0.5rem;
  line-height: 1.45;
  color: var(--text, inherit);
}

.inline-form { display: inline; margin: 0; }

button.linkish {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  font: inherit;
  text-decoration: underline;
}

button.linkish:hover { color: var(--accent); }

.person-header-actions .edit-details {
  min-width: min(100%, 36rem);
}

.age-line, .grave-line { color: var(--text); }

.multi-spouse-note { color: var(--text); }

.tree-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  margin: 0.45rem 0;
}

.tree-node {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  width: max-content;
  max-width: 14rem;
  min-width: 7.5rem;
  padding: 0.45rem 0.55rem;
  background: #111822;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  text-align: center;
}

.tree-node:hover { border-color: var(--accent); }

.tree-name-link {
  color: inherit;
  text-decoration: none;
}

.tree-name-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.tree-node.focus {
  border-color: var(--accent);
  border-width: 2px;
  box-shadow: 0 0 0 1px rgba(108, 182, 255, 0.35);
}

.tree-node.empty-slot {
  border-style: dashed;
  color: var(--muted);
  justify-content: center;
  font-size: 0.8rem;
}

.tree-role {
  color: var(--accent);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.1rem;
}

.tree-name {
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.tree-dates {
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 0.15rem;
}

/* —— Pedigree canvas (screen + print foundation) —— */
.pedigree-sheet {
  overflow: hidden;
}

.gramps-pedigree-viewport {
  width: 100%;
  height: min(70vh, 640px);
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(108, 182, 255, 0.06), transparent 50%),
    var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  position: relative;
}

.tree-view-controls {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.tree-view-btn {
  width: 2rem;
  height: 2rem;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(26, 35, 50, 0.92);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.tree-view-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tree-view-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Tree page: chart fills the browser — edge to edge, no inset pane */
body.page-tree {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

body.page-tree .site-header {
  flex: 0 0 auto;
}

body.page-tree .container {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
  min-height: 0;
  overflow: hidden;
}

body.page-tree .breadcrumb {
  display: none;
}

body.page-tree .tree-toolbar.card {
  flex: 0 0 auto;
  margin: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
  padding: 0.55rem 0.85rem 0.65rem;
}

body.page-tree .tree-toolbar h1 {
  font-size: 1.15rem;
  margin: 0 0 0.15rem;
}

body.page-tree .tree-toolbar > .meta {
  margin: 0 0 0.35rem;
}

body.page-tree .pedigree-sheet.card {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: var(--bg);
}

body.page-tree .gramps-pedigree-viewport {
  flex: 1 1 auto;
  width: 100%;
  height: auto;
  min-height: 0;
  border: none;
  border-radius: 0;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(108, 182, 255, 0.06), transparent 50%),
    var(--bg);
}

body.page-tree .family-group-sheet.card {
  flex: 0 1 auto;
  max-height: 40vh;
  overflow: auto;
  margin: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-bottom: none;
}

.gramps-pedigree-viewport.is-panning {
  cursor: grabbing;
}

.gramps-pedigree-svg {
  display: block;
  max-width: none;
  user-select: none;
}

.gramps-pedigree-svg .ped-link {
  fill: none;
  stroke: var(--border);
  stroke-width: 1.25;
  stroke-opacity: 0.85;
}

.gramps-pedigree-svg .ped-link-spouse {
  /* Stubs from each spouse into the marriage-year hub */
  stroke-dasharray: none;
  stroke-width: 1.75;
  stroke-opacity: 1;
}

.gramps-pedigree-svg .ped-marriage-box {
  fill: #1a2436;
  stroke: var(--border);
  stroke-width: 1.4;
}

.gramps-pedigree-svg .ped-marriage-year {
  fill: var(--muted, #9aa7b8);
  font-size: 10px;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-weight: 600;
  pointer-events: none;
}

.gramps-pedigree-svg .ped-marriage-join {
  /* Legacy hollow join; Tree mode now uses .ped-marriage-box */
  fill: #0f1419;
  stroke: var(--border);
  stroke-width: 1.6;
}

.gramps-pedigree-svg .ped-box {
  fill: #15202e;
  stroke: var(--border);
  stroke-width: 1.25;
}

.gramps-pedigree-svg .ped-box.sex-f {
  fill: #2a1f2e;
  stroke: #c47a9a;
}

.gramps-pedigree-svg .ped-box.sex-m {
  fill: #1a2436;
  stroke: #6cb6ff;
}

.gramps-pedigree-svg .ped-box.sex-u {
  fill: #1e2430;
}

.gramps-pedigree-svg .ped-box.focus {
  stroke: var(--accent);
  stroke-width: 2.25;
  fill: #1c3048;
}

.gramps-pedigree-svg .ped-box.empty {
  fill: transparent;
  stroke-dasharray: 4 3;
  stroke: #3a4658;
}

.gramps-pedigree-svg .ped-name {
  fill: var(--text);
  font-size: 11px;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-weight: 600;
}

.gramps-pedigree-svg .ped-dates,
.gramps-pedigree-svg .ped-place,
.gramps-pedigree-svg .ped-empty-label {
  fill: var(--muted);
  font-size: 10px;
  font-family: "Segoe UI", system-ui, sans-serif;
}

.gramps-pedigree-svg .ped-place {
  font-size: 9px;
  font-style: italic;
}

.gramps-pedigree-svg .ped-node-link {
  cursor: pointer;
}

.gramps-pedigree-svg .ped-node-link:hover .ped-box {
  stroke: var(--accent);
}

/* —— Gramps-style horizontal timeline —— */
.page-timeline .container {
  max-width: min(1400px, 96vw);
}

.page-timeline .pedigree-sheet {
  /* Give the chart the remaining viewport below filters */
  min-height: calc(100vh - 280px);
}

.gramps-timeline-viewport {
  width: 100%;
  height: min(78vh, calc(100vh - 260px));
  min-height: 420px;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  background:
    linear-gradient(180deg, rgba(108, 182, 255, 0.04), transparent 40%),
    var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.gramps-timeline-viewport.is-panning {
  cursor: grabbing;
}

.gramps-timeline-svg {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  user-select: none;
}

.gramps-timeline-svg .tl-label-deferred {
  opacity: 0;
  pointer-events: none;
}

.gramps-timeline-viewport.tl-zoomed-in .tl-label-deferred {
  opacity: 0.9;
  fill: var(--text);
}

.gramps-timeline-svg .tl-axis {
  stroke: var(--border);
  stroke-width: 1.5;
}

.gramps-timeline-svg .tl-tick {
  stroke: var(--border);
  stroke-width: 1;
}

.gramps-timeline-svg .tl-tick-label {
  fill: var(--muted);
  font-size: 11px;
  font-family: "Segoe UI", system-ui, sans-serif;
}

.gramps-timeline-svg .tl-focus {
  stroke: var(--accent);
  stroke-width: 1.25;
  stroke-dasharray: 4 3;
  opacity: 0.7;
}

.gramps-timeline-svg .tl-stem {
  stroke: var(--border);
  stroke-width: 1;
  opacity: 0.55;
}

.gramps-timeline-svg .tl-dot {
  stroke: #0b1220;
  stroke-width: 1;
  cursor: pointer;
}

.gramps-timeline-svg .kind-birth .tl-dot { fill: #5ecf8a; }
.gramps-timeline-svg .kind-death .tl-dot { fill: #9aa4b2; }
.gramps-timeline-svg .kind-burial .tl-dot { fill: #c4a484; }
.gramps-timeline-svg .kind-marriage .tl-dot { fill: #e8a0bf; }
.gramps-timeline-svg .kind-residence .tl-dot { fill: #6cb6ff; }
.gramps-timeline-svg .kind-education .tl-dot { fill: #7dd3c7; }
.gramps-timeline-svg .kind-military .tl-dot { fill: #c9b458; }

.gramps-timeline-svg .tl-label {
  fill: var(--muted);
  font-size: 10px;
  font-family: "Segoe UI", system-ui, sans-serif;
  cursor: pointer;
  opacity: 0.85;
}

.gramps-timeline-viewport.tl-zoomed-in .tl-label {
  opacity: 1;
  fill: var(--text);
}

.gramps-timeline-svg .tl-event {
  cursor: pointer;
}

.gramps-timeline-svg .tl-event:hover .tl-dot {
  stroke: var(--accent);
  stroke-width: 2;
}

.gramps-timeline-svg .tl-event:hover .tl-label {
  fill: var(--text);
  opacity: 1;
}

/* Fan chart slices */
.gramps-fan-svg .fan-slice {
  stroke: var(--border);
  stroke-width: 0.75;
  fill: #15202e;
}

.gramps-fan-svg .fan-slice.sex-f { fill: #2a1f2e; }
.gramps-fan-svg .fan-slice.sex-m { fill: #1a2436; }
.gramps-fan-svg .fan-slice.empty {
  fill: transparent;
  stroke-dasharray: 3 2;
}

.gramps-fan-svg .fan-center {
  fill: #1c3048;
  stroke: var(--accent);
  stroke-width: 2;
}

.gramps-fan-svg .fan-label {
  fill: var(--text);
  font-size: 11px;
  font-family: "Segoe UI", system-ui, sans-serif;
  pointer-events: none;
}

.gramps-fan-svg .fan-label.small {
  font-size: 8px;
  fill: var(--muted);
}

.gramps-fan-svg .fan-node-link:hover .fan-slice,
.gramps-fan-svg .fan-node-link:hover .fan-center {
  stroke: var(--accent);
  stroke-width: 2;
}

/* Map */
.map-viewport-wrap {
  position: relative;
  width: 100%;
}

.gramps-map-viewport {
  width: 100%;
  height: min(68vh, 520px);
  border: 1px solid var(--border);
  border-radius: 10px;
  z-index: 1;
}

.map-recenter-btn {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border, #cfc8bc);
  border-radius: 8px;
  background: var(--card-bg, #fff);
  color: var(--text, #1a2436);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  cursor: pointer;
}

.map-recenter-btn:hover {
  background: color-mix(in srgb, var(--accent, #3a6ea5) 14%, #fff);
  border-color: var(--accent, #3a6ea5);
  color: var(--accent, #3a6ea5);
}

.map-recenter-btn:focus-visible {
  outline: 2px solid var(--accent, #3a6ea5);
  outline-offset: 2px;
}

.map-time-slider {
  margin-top: 0.75rem;
}

.map-time-slider input[type="range"] {
  width: 100%;
}

.map-detail {
  margin-top: 1rem;
}

.map-detail ul {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
}

.map-points-table-wrap {
  margin-top: 1.25rem;
}

.map-points-table-wrap .table-scroll {
  max-height: 20rem;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.map-points-table-wrap .data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.map-points-table-wrap .data-table th,
.map-points-table-wrap .data-table td {
  padding: 0.45rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.map-points-table-wrap .data-table th {
  position: sticky;
  top: 0;
  background: var(--card-bg, var(--bg, #f7f4ee));
  z-index: 1;
  font-weight: 600;
}

.map-points-table-wrap .data-table tbody tr {
  cursor: pointer;
}

.map-points-table-wrap .data-table tbody tr:hover,
.map-points-table-wrap .data-table tbody tr.is-active {
  background: color-mix(in srgb, var(--accent, #3a6ea5) 12%, transparent);
}

.map-points-table-wrap .data-table .mono {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.timeline-filter-form {
  margin-top: 0.75rem;
}

.timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.timeline-legend .tl-leg::before {
  content: "";
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  margin-right: 0.35rem;
  vertical-align: middle;
  background: var(--border);
}

.timeline-legend .kind-birth::before { background: #5ecf8a; }
.timeline-legend .kind-death::before { background: #9aa4b2; }
.timeline-legend .kind-burial::before { background: #c4a484; }
.timeline-legend .kind-marriage::before { background: #e8a0bf; }
.timeline-legend .kind-residence::before { background: #6cb6ff; }
.timeline-legend .kind-education::before { background: #7dd3c7; }
.timeline-legend .kind-military::before { background: #c9b458; }

#timeline-detail ul {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
}

#timeline-detail li {
  margin-bottom: 0.55rem;
}

.family-group-sheet {
  margin-top: 1rem;
}

.pedigree-canvas {
  --ped-line: var(--border);
  --ped-line-strong: var(--accent);
  --ped-stem: 1.1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  min-width: min(100%, 52rem);
  padding: 0.35rem 0.25rem 0.75rem;
}

.ped-gen {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.ped-gen-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}

.ped-gp-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem 2.5rem;
  width: 100%;
}

.ped-gp-side {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ped-couple {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: max-content;
  margin-inline: auto;
  position: relative;
}

.ped-join {
  width: 2rem;
  height: 2px;
  background: var(--ped-line);
  flex-shrink: 0;
  position: relative;
}

.ped-couple.marriage .ped-join {
  background: var(--ped-line-strong);
  height: 3px;
}

.ped-join-dot {
  display: none;
}

.ped-couple.marriage .ped-join-dot {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  background: var(--ped-line-strong);
}

/* Vertical stem from couple/join midpoint down to next generation */
.ped-gp-side::after,
.ped-gen-parents::after,
.ped-unit-body > .ped-couple::after {
  content: "";
  display: block;
  width: 2px;
  height: var(--ped-stem);
  background: var(--ped-line);
  margin: 0 auto;
}

.ped-gen-parents:has(> .empty)::after {
  display: none;
}

.ped-other-parents {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.ped-gen-focus {
  margin-bottom: 0.25rem;
}

.ped-gen-focus .tree-node.focus {
  min-width: 9rem;
}

.ped-units {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1.35rem;
  width: 100%;
}

.ped-unit {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.65rem 0.9rem;
  background: rgba(17, 24, 34, 0.4);
}

.ped-unit-label {
  text-align: center;
  font-size: 0.85rem;
  margin-bottom: 0.55rem;
  color: var(--muted);
}

.ped-unit-label .muted { opacity: 0.85; }

.ped-unit-body {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Sibling rail: classic genealogy connector */
.ped-sibs {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: flex-start;
  list-style: none;
  margin: 0;
  padding: 0;
  width: max-content;
  max-width: 100%;
  position: relative;
}

.ped-sib {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  padding: var(--ped-stem) 0.4rem 0;
}

.ped-sib::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: var(--ped-stem);
  background: var(--ped-line);
  transform: translateX(-50%);
}

.ped-sib::after {
  content: "";
  position: absolute;
  top: 0;
  height: 2px;
  background: var(--ped-line);
  right: 50%;
  left: 0;
}

.ped-sib:first-child::after {
  left: 50%;
  right: 0;
}

.ped-sib:only-child::after {
  display: none;
}

.ped-sib:not(:first-child):not(:last-child)::after {
  left: 0;
  right: 0;
}

.ped-sib:last-child:not(:first-child)::after {
  left: 0;
  right: 50%;
}

.ped-sibs-gc {
  margin-top: 0;
}

.ped-sibs-gc .ped-sib {
  padding-top: calc(var(--ped-stem) * 0.85);
}

.ped-sibs-gc .tree-node {
  min-width: 6.5rem;
  max-width: 11rem;
  padding: 0.35rem 0.45rem;
}

.ped-sibs-gc .tree-name { font-size: 0.8rem; }

.empty.tight { margin: 0.65rem 0 0; text-align: center; }

.gc-empty { font-size: 0.75rem; }

/* —— Letter print (8.5×11) —— */
@media print {
  @page {
    size: letter landscape;
    margin: 0.45in;
  }

  :root {
    --bg: #fff;
    --panel: #fff;
    --text: #111;
    --muted: #444;
    --accent: #111;
    --border: #333;
  }

  body {
    background: #fff;
    color: #111;
    font-size: 10pt;
  }

  .no-print,
  .site-header,
  .breadcrumb,
  .tree-toolbar,
  .emblems-popup,
  .tree-honors {
    display: none !important;
  }

  .print-only { display: block !important; }

  .container {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .card {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    margin: 0;
    box-shadow: none;
  }

  .pedigree-print-header {
    text-align: center;
    margin-bottom: 0.45rem;
    border-bottom: 1.5pt solid #111;
    padding-bottom: 0.3rem;
  }

  .pedigree-print-header h1 {
    margin: 0;
    font-size: 14pt;
    color: #111;
  }

  .pedigree-print-header .meta {
    margin: 0.15rem 0 0;
    font-size: 9pt;
    color: #444;
  }

  .pedigree-sheet {
    overflow: visible;
  }

  .gramps-pedigree-viewport {
    height: auto;
    max-height: none;
    overflow: visible;
    border: none;
    border-radius: 0;
    background: #fff;
    cursor: default;
  }

  .gramps-pedigree-svg {
    max-width: 100%;
    height: auto;
  }

  .gramps-pedigree-svg .ped-link {
    stroke: #333;
    stroke-opacity: 1;
  }

  .gramps-pedigree-svg .ped-box {
    fill: #fff;
    stroke: #222;
  }

  .gramps-pedigree-svg .ped-box.sex-f,
  .gramps-pedigree-svg .ped-box.sex-m,
  .gramps-pedigree-svg .ped-box.sex-u {
    fill: #fff;
  }

  .gramps-pedigree-svg .ped-box.focus {
    stroke: #000;
    stroke-width: 2;
    fill: #f5f5f5;
  }

  .gramps-pedigree-svg .ped-box.empty {
    fill: transparent;
    stroke: #888;
  }

  .gramps-pedigree-svg .ped-name {
    fill: #111;
  }

  .gramps-pedigree-svg .ped-dates,
  .gramps-pedigree-svg .ped-empty-label {
    fill: #444;
  }

  .pedigree-canvas {
    --ped-line: #222;
    --ped-line-strong: #111;
    --ped-stem: 0.7rem;
    min-width: 0;
    width: 100%;
    padding: 0;
    gap: 0;
  }

  .ped-gen-label {
    color: #555;
    font-size: 7.5pt;
    margin-bottom: 0.2rem;
  }

  .tree-node {
    background: #fff;
    border: 1pt solid #222;
    border-radius: 2px;
    box-shadow: none;
    min-width: 1.6in;
    max-width: 2.3in;
    padding: 0.18rem 0.28rem;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .tree-node.focus {
    border-width: 1.75pt;
    box-shadow: none;
  }

  .tree-node.empty-slot {
    border-style: dashed;
    color: #666;
  }

  .tree-role {
    color: #333;
    font-size: 6.5pt;
  }

  .tree-name {
    font-size: 8.5pt;
    color: #111;
  }

  .tree-name-link {
    color: #111;
    text-decoration: none;
  }

  .tree-dates {
    color: #444;
    font-size: 7pt;
  }

  .ped-unit {
    background: transparent;
    border: 0.75pt solid #999;
    border-radius: 0;
    padding: 0.35rem 0.4rem 0.5rem;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .ped-unit-label {
    font-size: 8pt;
    color: #444;
    margin-bottom: 0.3rem;
  }

  .ped-gp-row {
    gap: 0.75rem 1.25rem;
  }

  .ped-join {
    width: 0.55in;
  }

  .ped-sib {
    padding-left: 0.2rem;
    padding-right: 0.2rem;
  }

  .ped-sibs {
    flex-wrap: wrap;
    max-width: 100%;
  }

  /* When siblings wrap, hide imperfect rail segments on wrap rows */
  .ped-sibs-gc .tree-node {
    min-width: 1.35in;
    max-width: 1.9in;
  }
}

.edit-details > summary.edit-summary {
  list-style: none;
  cursor: pointer;
  display: inline-block;
  user-select: none;
}

.edit-details > summary.edit-summary::-webkit-details-marker {
  display: none;
}

.edit-details[open] > summary.edit-summary {
  margin-bottom: 1rem;
}

.edit-form { margin-top: 0.25rem; }

.hidden { display: none !important; }

.stack-form .form-section {
  border: 1px solid var(--border, #cfc8bc);
  border-radius: 6px;
  padding: 0.75rem 1rem 1rem;
  margin: 0 0 1rem;
}

.stack-form .form-section legend {
  font-weight: 600;
  padding: 0 0.35rem;
}

.stack-form .required-note {
  font-weight: 400;
  font-size: 0.9em;
  opacity: 0.85;
}

@media (max-width: 700px) {
  .site-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .filter-form { grid-template-columns: 1fr; }
}

/* History wiki */
.history-wiki-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.history-wiki-list > li {
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 0;
}
.history-wiki-list > li:last-child { border-bottom: none; }
.history-wiki-list h3 { margin: 0 0 0.35rem; font-size: 1.1rem; }
.wiki-body { margin-top: 1rem; overflow-x: auto; }
.wiki-body h1 { font-size: 1.35rem; }
.wiki-body h2 { font-size: 1.15rem; margin-top: 1.25rem; }
.wiki-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin: 0.75rem 0;
}
.wiki-body th,
.wiki-body td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.55rem;
  text-align: left;
  vertical-align: top;
}
.wiki-body th { background: rgba(0, 0, 0, 0.2); }
.wiki-body code {
  font-size: 0.88em;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

/* Person wiki: narrative + GEDCOM infobox (Wikipedia-style) */
.wiki-person-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(16rem, 20rem);
  gap: 1.25rem;
  align-items: start;
}
.wiki-authority-note {
  margin: 0.75rem 0 0;
  padding: 0.65rem 0.8rem;
  font-size: 0.92rem;
  line-height: 1.4;
  border-left: 3px solid var(--accent, #8a6d3b);
  background: rgba(0, 0, 0, 0.12);
}
.wiki-infobox {
  position: sticky;
  top: 1rem;
  padding: 0.85rem 1rem 1rem;
}
.wiki-infobox-title {
  margin: 0 0 0.2rem;
  font-size: 1.05rem;
  line-height: 1.3;
}
.wiki-infobox-sub { margin: 0 0 0.75rem; }
.wiki-infobox-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.wiki-infobox-table th,
.wiki-infobox-table td {
  border-top: 1px solid var(--border);
  padding: 0.4rem 0.35rem;
  vertical-align: top;
  text-align: left;
}
.wiki-infobox-table th {
  width: 5.5rem;
  font-weight: 600;
  color: var(--muted, #a8a29a);
}
.wiki-infobox-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.85rem 0 0;
}
@media (max-width: 860px) {
  .wiki-person-layout {
    grid-template-columns: 1fr;
  }
  .wiki-infobox {
    position: static;
    order: -1;
  }
}

/* Lineage application worksheet */
.lineage-gen {
  border-top: 1px solid var(--border);
  padding: 0.85rem 0;
}
.lineage-gen:first-of-type { border-top: none; }
.lineage-gen h3 { margin: 0 0 0.35rem; font-size: 1.05rem; }
.lineage-vital-list { margin: 0.35rem 0 0.5rem; padding-left: 1.2rem; }
@media print {
  .site-header, .breadcrumb, .lineage-worksheet .wiki-authority-note { }
  .print-friendly { break-inside: avoid; }
}
