:root {
  --bg: #fbfaf7;
  --ink: #1f1d1a;
  --muted: #6b655c;
  --rule: #d9d3c7;
  --accent: #7a3b2e;
  --accent-bg: #f2e9e2;
  --nav-bg: #f3efe7;
  --max: 760px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 17px;
  line-height: 1.55;
}

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

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  overflow-x: hidden;
}

.sidebar {
  background: var(--nav-bg);
  border-right: 1px solid var(--rule);
  padding: 1.8rem 1.4rem;
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow-y: auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
}

.sidebar h1 {
  font-family: "Iowan Old Style", Georgia, serif;
  font-size: 1.25rem;
  margin: 0 0 0.4rem 0;
  letter-spacing: 0.01em;
}

.sidebar h1 a { color: var(--ink); }
.sidebar h1 a:hover { text-decoration: none; color: var(--accent); }

.sidebar .tagline {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 1.6rem 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 1.6rem 0 0.4rem 0;
  font-weight: 600;
}

.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar li {
  margin: 0;
}

.sidebar li a {
  display: block;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  color: var(--ink);
  line-height: 1.3;
}

.sidebar li a:hover {
  background: var(--accent-bg);
  text-decoration: none;
}

.sidebar li a[aria-current="page"] {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}

main {
  padding: 3rem 3rem 5rem 3rem;
  max-width: calc(var(--max) + 6rem);
  min-width: 0;
}

main.wide-page {
  max-width: none;
  width: 100%;
}

main h1 {
  font-size: 2rem;
  margin: 0 0 0.3rem 0;
  line-height: 1.15;
}

main .subtitle {
  color: var(--muted);
  font-style: italic;
  margin: 0 0 2rem 0;
}

main h2 {
  font-size: 1.3rem;
  margin-top: 2.2rem;
  margin-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.25rem;
}

main h3 {
  font-size: 1.05rem;
  margin-top: 1.6rem;
  margin-bottom: 0.4rem;
}

main p { margin: 0 0 1rem 0; }

main ul, main ol {
  margin: 0 0 1rem 1.2rem;
  padding: 0;
}

main li { margin-bottom: 0.3rem; }

.factbox {
  background: #fff;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  padding: 1rem 1.2rem;
  margin: 0 0 2rem 0;
  font-size: 0.95rem;
}

.factbox dl {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.35rem 1rem;
  margin: 0;
}

.factbox dt {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 0.15rem;
}

.factbox dd { margin: 0; }

.tree {
  background: #fff;
  border: 1px solid var(--rule);
  padding: 1.2rem 1.4rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.92rem;
  line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  margin: 0 0 2rem 0;
}

.tree-caption {
  max-width: var(--max);
  font-size: 1.05rem;
  line-height: 1.55;
}

.family-tree {
  margin: 1.2rem 0 2.4rem 0;
  width: min(1400px, calc(100vw - 340px));
  max-width: calc(100vw - 340px);
}

.family-tree-scroll {
  background: #f7efe4;
  border: 1px solid var(--rule);
  border-radius: 4px;
  max-height: 82vh;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0.75rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

.family-tree-scroll:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.family-tree svg {
  display: block;
  width: 1400px;
  max-width: none;
  height: auto;
}

.family-tree figcaption {
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.45;
  margin-top: 0.7rem;
  max-width: var(--max);
}

.source-note {
  font-size: 0.88rem;
  color: var(--muted);
  border-top: 1px solid var(--rule);
  margin-top: 2.5rem;
  padding-top: 1rem;
}

.source-note a { color: var(--muted); text-decoration: underline; }

.research-page {
  max-width: calc(var(--max) + 11rem);
}

main.wide-page.research-page {
  max-width: none;
  width: 100%;
}

.research-page > p,
.research-page > h1,
.research-page > h2,
.research-page > .subtitle,
.research-page > .factbox,
.research-page > .callout,
.research-page > .source-note {
  max-width: var(--max);
}

.research-brief {
  background: #fffdf9;
  border-top: 3px solid var(--accent);
  border-bottom: 1px solid var(--rule);
  margin: 1.6rem 0 2.4rem 0;
  padding: 1.25rem 1.35rem 1.35rem 1.35rem;
}

.research-brief h2 {
  border-bottom: none;
  margin: 0 0 0.65rem 0;
  padding-bottom: 0;
}

.section-kicker {
  color: var(--muted);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
}

.research-brief-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-top: 1.1rem;
}

.research-brief-grid > div {
  border-top: 1px solid var(--rule);
  padding-top: 0.85rem;
}

.research-brief-grid h3 {
  color: var(--accent);
  font-size: 1rem;
  margin: 0 0 0.45rem 0;
}

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

.evidence-list li {
  align-items: start;
  border-top: 1px solid var(--rule);
  display: grid;
  gap: 1rem;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  margin-bottom: 0;
  padding: 0.85rem 0;
}

.evidence-list li:last-child {
  border-bottom: 1px solid var(--rule);
}

.evidence-list p {
  margin: 0;
}

.target-list li {
  margin-bottom: 0.65rem;
  padding-left: 0.1rem;
}

.target-list .status-pill {
  margin-right: 0.5rem;
}

.status-pill {
  border-radius: 999px;
  display: inline-block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1;
  padding: 0.28rem 0.55rem;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-proven {
  background: #e6efe9;
  color: #255b38;
}

.status-likely {
  background: #edf0dd;
  color: #58631f;
}

.status-possible {
  background: #e7eef1;
  color: #345b66;
}

.status-negative {
  background: #f1e6df;
  color: #7a3b2e;
}

.status-open {
  background: #eee8f1;
  color: #594768;
}

.research-detail {
  border-top: 1px solid var(--rule);
  margin: 0;
  padding: 0.15rem 0;
}

.research-detail:last-of-type {
  border-bottom: 1px solid var(--rule);
}

.research-detail > summary {
  align-items: flex-start;
  cursor: pointer;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  list-style: none;
  padding: 0.85rem 0;
}

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

.research-detail > summary::after {
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--accent);
  content: "+";
  flex: 0 0 auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  font-weight: 700;
  height: 1.45rem;
  line-height: 1.3rem;
  margin-top: 0.05rem;
  text-align: center;
  width: 1.45rem;
}

.research-detail[open] > summary::after {
  content: "-";
}

.detail-label {
  display: block;
  min-width: 0;
}

.detail-title {
  display: block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.25;
}

.detail-note {
  color: var(--muted);
  display: block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.82rem;
  line-height: 1.35;
  margin-top: 0.18rem;
}

.research-detail > *:not(summary) {
  max-width: var(--max);
}

.research-detail > .register-table,
.research-detail > .tree {
  max-width: 100%;
}

.breadcrumbs {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.breadcrumbs a { color: var(--muted); }

.photo-plate {
  margin: 1.2rem 0 2rem 0;
}

.photo-plate img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: #fff;
}

.photo-plate figcaption {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
  margin-top: 0.45rem;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.2rem 0 2rem 0;
}

.photo-grid .photo-plate {
  margin: 0;
}

.source-document {
  max-width: 980px;
}

.document-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 1.1rem 0 2rem 0;
  max-width: 1120px;
}

.document-card {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 4px;
  margin: 0;
  min-width: 0;
  overflow: hidden;
}

.document-card figcaption {
  border-bottom: 1px solid var(--rule);
  color: var(--muted);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.82rem;
  line-height: 1.35;
  padding: 0.65rem 0.75rem;
}

.document-card figcaption strong {
  color: var(--ink);
}

.document-frame {
  background: #f8f4ed;
  border: 0;
  display: block;
  height: 460px;
  width: 100%;
}

.raw-document-list {
  display: grid;
  gap: 0.75rem;
  margin: 1.1rem 0 2rem 0;
}

.raw-document {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
}

.raw-document summary {
  cursor: pointer;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  padding: 0.7rem 0.85rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.3;
}

.raw-document summary strong {
  color: var(--ink);
}

.raw-document summary span {
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 0.78rem;
}

.raw-document-frame {
  border-top: 1px solid var(--rule);
  height: 520px;
}

.raw-document-image {
  background: #fff;
  border-top: 1px solid var(--rule);
  display: block;
  height: auto;
  width: 100%;
}

.raw-document-note {
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.9rem;
  padding: 0.85rem;
}

.register-table {
  border-collapse: collapse;
  margin: 1rem 0 1.6rem 0;
  font-size: 0.92rem;
}

.table-scroll {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  margin: 1rem 0 1.6rem 0;
}

.table-scroll .register-table {
  min-width: 980px;
  margin: 0;
}

.table-scroll .mckenna-grave-table {
  min-width: 2450px;
}

.table-scroll .sibling-verification-table {
  min-width: 1180px;
}

.sibling-verification-table th:nth-child(3),
.sibling-verification-table td:nth-child(3) {
  min-width: 450px;
}

.mckenna-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 0.65rem;
  scrollbar-color: var(--accent) var(--accent-bg);
  scrollbar-width: thin;
}

.mckenna-table-wrap::-webkit-scrollbar {
  height: 14px;
}

.mckenna-table-wrap::-webkit-scrollbar-track {
  background: var(--accent-bg);
  border-radius: 999px;
}

.mckenna-table-wrap::-webkit-scrollbar-thumb {
  background: var(--accent);
  border: 3px solid var(--accent-bg);
  border-radius: 999px;
}

.register-table th,
.register-table td {
  border: 1px solid var(--rule);
  padding: 0.45rem 0.7rem;
  text-align: left;
  vertical-align: top;
}

.register-table th {
  background: rgba(0,0,0,0.04);
  font-weight: 600;
}

.grave-thumb {
  width: 112px;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.25;
}

.grave-thumb img {
  display: block;
  width: 72px;
  max-height: 112px;
  object-fit: cover;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: #fff;
}

.grave-thumb figcaption {
  margin-top: 0.35rem;
}

.grave-thumb figcaption span,
.grave-thumb-empty small span {
  color: var(--muted);
}

.grave-thumb-empty {
  min-height: 104px;
  border: 1px dashed var(--rule);
  border-radius: 4px;
  padding: 0.55rem;
  background: rgba(255,255,255,0.55);
}

.grave-thumb-empty span {
  display: block;
  color: var(--accent);
  font-weight: 600;
}

.grave-thumb-empty small {
  display: block;
  margin-top: 0.4rem;
}

.badge-note {
  display: inline-block;
  margin-top: 0.25rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  background: rgba(255,255,255,0.65);
  color: var(--muted);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.72rem;
  white-space: nowrap;
}

.table-muted {
  color: var(--muted);
}

.probability-cell {
  min-width: 210px;
}

.child-names-cell {
  min-width: 190px;
}

.probability-score {
  display: inline-block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 1.05rem;
  line-height: 1;
  margin-bottom: 0.35rem;
}

.probability-high {
  color: var(--accent);
}

.probability-medium {
  color: #7a5a14;
}

.probability-low {
  color: #61713b;
}

.callout {
  background: var(--accent-bg);
  border-left: 4px solid var(--accent);
  padding: 1rem 1.25rem 1rem 1.4rem;
  margin: 1.4rem 0 2rem 0;
  border-radius: 4px;
}

.callout h3 {
  margin-top: 0;
  margin-bottom: 0.6rem;
  font-size: 1.05rem;
  color: var(--accent);
  letter-spacing: 0.01em;
}

.callout p {
  margin: 0.5rem 0;
}

.callout .register-table {
  font-size: 0.86rem;
  background: #fff;
}

.callout-aliases .register-table td:first-child {
  white-space: nowrap;
  font-size: 0.92rem;
}

.lead-form {
  background: #fff;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  padding: 1rem 1.2rem;
  margin: 1.2rem 0 2rem 0;
}

.lead-form label {
  display: block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 0.45rem;
  text-transform: uppercase;
  color: var(--muted);
}

.lead-form textarea {
  display: block;
  width: 100%;
  min-height: 9rem;
  resize: vertical;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.8rem 0.9rem;
  color: var(--ink);
  background: #fffdfa;
  font: inherit;
  line-height: 1.45;
}

.lead-form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lead-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-top: 0.8rem;
}

.lead-actions button,
.lead-delete {
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.55rem 0.75rem;
}

.lead-actions button:hover,
.lead-delete:hover {
  background: #5f2e24;
}

.lead-status {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.lead-list-panel {
  margin-top: 2rem;
}

.lead-list {
  list-style: none;
  margin: 1rem 0 0 0;
  padding: 0;
}

.lead-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: start;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.85rem;
  margin-bottom: 0.75rem;
}

.lead-item input {
  margin-top: 0.3rem;
}

.lead-body p {
  margin: 0 0 0.35rem 0;
  white-space: pre-wrap;
}

.lead-body time {
  color: var(--muted);
  display: block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.78rem;
}

.lead-item.is-done .lead-body p {
  color: var(--muted);
  text-decoration: line-through;
}

.lead-delete {
  background: #fff;
  color: var(--accent);
  padding: 0.4rem 0.6rem;
}

.lead-delete:hover {
  color: #fff;
}

.empty-state {
  color: var(--muted);
  font-style: italic;
}

.qa-transcript {
  font-size: 0.96rem;
}

.qa-page {
  border-left: 3px solid var(--rule);
  margin: 1.2rem 0;
  padding-left: 1rem;
}

.qa-page h4 {
  color: var(--accent);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  margin: 0 0 0.6rem 0;
  text-transform: uppercase;
}

.qa-transcript dl {
  margin: 0;
}

.qa-transcript dt {
  color: var(--ink);
  font-weight: 700;
  margin-top: 0.65rem;
}

.qa-transcript dd {
  margin: 0.15rem 0 0.55rem 0;
}

.transcript-note {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--muted);
  padding: 0.75rem 0.9rem;
}

.audio-source {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 4px;
  margin: 1rem 0;
  padding: 0.85rem 0.9rem;
}

.audio-source p {
  margin: 0.35rem 0;
}

.audio-source audio {
  display: block;
  margin: 0.65rem 0 0.35rem 0;
  width: 100%;
}

.interview-transcript {
  font-size: 0.96rem;
}

.interview-transcript h4 {
  border-top: 1px solid var(--rule);
  color: var(--accent);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  margin: 1.1rem 0 0.55rem 0;
  padding-top: 0.9rem;
  text-transform: uppercase;
}

.interview-transcript h4:first-child {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.interview-transcript p {
  margin: 0.65rem 0;
}

.source-pages {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 4px;
  margin: 0.75rem 0 1rem 0;
}

.source-pages summary {
  color: var(--accent);
  cursor: pointer;
  display: inline-flex;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  list-style: none;
  padding: 0.55rem 0.75rem;
  text-transform: uppercase;
}

.source-pages summary::-webkit-details-marker {
  display: none;
}

.source-pages summary::before {
  content: "+";
  margin-right: 0.45rem;
}

.source-pages[open] summary::before {
  content: "-";
}

.source-page-grid {
  display: grid;
  gap: 1rem;
  margin: 0 1rem 1rem 1rem;
}

.source-page {
  margin: 0;
}

.source-page img {
  background: #f8f4ed;
  border: 1px solid var(--rule);
  border-radius: 4px;
  display: block;
  height: auto;
  width: 100%;
}

.source-page figcaption {
  color: var(--muted);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.78rem;
  margin-top: 0.35rem;
}

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; border-right: none; border-bottom: 1px solid var(--rule); }
  main { padding: 2rem 1.4rem 4rem 1.4rem; }
  .family-tree {
    width: 100%;
    max-width: 100%;
  }
  .family-tree-scroll {
    padding: 0.6rem;
  }
  .photo-grid { grid-template-columns: 1fr; }
  .document-grid { grid-template-columns: 1fr; }
  .document-frame { height: 420px; }
  .mckenna-table-wrap { max-width: 100%; }
  .register-table { font-size: 0.84rem; }
  .register-table th,
  .register-table td { padding: 0.35rem 0.45rem; }
  .research-brief-grid { grid-template-columns: 1fr; }
  .evidence-list li { grid-template-columns: 1fr; gap: 0.45rem; }
  .status-pill { justify-self: start; }
  .lead-actions { align-items: flex-start; flex-direction: column; }
  .lead-item { grid-template-columns: auto minmax(0, 1fr); }
  .lead-delete { grid-column: 2; justify-self: start; }
}
