:root {
  color-scheme: light;
  --bg: #f7f6f2;
  --card: #fffefa;
  --text: #292e29;
  --muted: #747b70;
  --border: #e3e5dc;
  --border-strong: #c5cebe;
  --accent: #41694b;
  --accent-soft: #edf2e8;
  --shadow: 0 4px 18px rgba(40, 52, 37, 0.04);
}

body {
  background: var(--bg);
}
[hidden] {
  display: none !important;
}
button,
input {
  font: inherit;
}
button {
  cursor: pointer;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
.viewport:focus-visible {
  outline: 3px solid #86a889;
  outline-offset: 3px;
}
button {
  color: var(--text);
}
a {
  text-decoration: none;
}
.shell {
  max-width: 1560px;
  margin: auto;
  padding: 40px 36px 24px;
}
.crumb {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 28px;
}
.heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}
.eyebrow {
  display: block;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.68rem;
  font-weight: 650;
}
h1 {
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 400;
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: -0.035em;
  margin: 10px 0;
}
.heading p {
  color: var(--muted);
  margin: 0;
}
.private {
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 0.75rem;
  white-space: nowrap;
}
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 32px;
  margin: 25px 0 30px;
  color: var(--muted);
  font-size: 0.85rem;
}
.stats b {
  color: var(--text);
  font-size: 1.1rem;
  margin-right: 5px;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}
.tree-panel,
.details,
.relatives {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.toolbar {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--border);
}
.views,
.zoom {
  display: flex;
  gap: 4px;
  align-items: center;
}
.toolbar button {
  border: 0;
  background: transparent;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
}
.views button[aria-pressed='true'] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}
.toolbar button:hover {
  background: var(--accent-soft);
}
.zoom output {
  font-size: 0.75rem;
  min-width: 42px;
  text-align: center;
  color: var(--muted);
}
.zoom #fit {
  border: 1px solid var(--border);
  margin-left: 6px;
}
.tree-hint {
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0 18px;
  line-height: 1.6;
}
.viewport {
  height: 680px;
  overflow: auto;
  background-color: #f5f6f0;
  background-image: radial-gradient(#d5dccf 1px, transparent 1px);
  background-size: 20px 20px;
  overscroll-behavior: contain;
}
#tree-space {
  position: relative;
}
#tree {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: top left;
}
.connections {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.connections path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.connection-halo {
  stroke: #f5f6f0;
  stroke-width: 7;
}
.connection-line {
  stroke: var(--connection-color);
  stroke-width: 2.2;
}
.connection circle {
  fill: var(--connection-color);
}
.connection-muted .connection-line,
.connection-muted circle {
  opacity: 0.35;
}
.connection-active .connection-line {
  stroke-width: 3.2;
}
.node {
  position: absolute;
  width: 224px;
  height: 158px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  text-align: left;
  border: 1px solid #d8dfd1;
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 3px 10px #293d2210;
}
.node:hover {
  border-color: var(--accent);
  background: #f8fbf4;
}
.node.selected {
  border: 2px solid var(--accent);
  padding: 15px 17px;
  box-shadow: 0 0 0 4px #41694b12;
}
.node-root {
  background: #eaf1e4;
}
.node-nonblood {
  background: #fafaf6;
  border-color: #e1e5dc;
  color: #596154;
  box-shadow: 0 2px 6px #293d2208;
}
.node-nonblood:hover {
  background: #fdfdf9;
  border-color: #c7cebf;
}
.node-nonblood.selected {
  border-color: #969e90;
  box-shadow: 0 0 0 4px #969e9012;
}
.node-nonblood .node-relation {
  color: #78816f;
}
.node-relation {
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 10px;
}
.node-full-name {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
}
.node-maiden {
  font-size: 10px;
  color: var(--muted);
  margin-top: 6px;
}
.node-date {
  font-size: 11px;
  color: var(--muted);
  margin-top: auto;
}
.uncertain {
  color: #95651c;
}
.tree-footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 18px;
  font-size: 0.68rem;
  color: var(--muted);
}
.sidebar {
  display: grid;
  gap: 18px;
}
.details,
.relatives {
  padding: 22px;
}
.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  color: var(--accent);
  margin: 18px 0 12px;
  font-family: Georgia, serif;
  font-size: 22px;
}
.details h2 {
  font-size: 1.2rem;
  font-weight: 550;
  line-height: 1.4;
  margin: 0 0 8px;
}
.maiden,
.muted {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.6;
}
dl {
  margin: 20px 0;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
dt {
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 6px;
}
dd {
  font-size: 0.85rem;
  margin: 0;
}
h3 {
  margin: 18px 0 6px;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.75rem;
}
.person-link {
  display: block;
  text-align: left;
  font-size: 0.8rem;
  line-height: 1.5;
  background: none;
  border: 0;
  color: var(--accent);
  padding: 5px 0;
}
.person-link:hover {
  text-decoration: underline;
}
.person-notes {
  border-top: 1px solid var(--border);
  margin-top: 18px;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--muted);
}
.relatives h2 {
  font-size: 0.9rem;
  margin: 0 0 16px;
}
.relatives h2 span {
  font-weight: 400;
  color: var(--muted);
  margin-left: 8px;
}
input {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  padding: 11px;
}
#search {
  font-size: 0.75rem;
}
#people-list {
  max-height: 380px;
  overflow-y: auto;
  margin: 14px -10px -8px;
}
.list-person {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 10px;
  border-radius: 8px;
}
.list-person:hover,
.list-person.selected {
  background: var(--accent-soft);
}
.details-nonblood {
  background: #fafaf6;
  border-color: #e1e5dc;
  box-shadow: 0 2px 6px #293d2208;
}
.details-nonblood .eyebrow,
.list-nonblood {
  color: #596154;
}
.list-nonblood:hover,
.list-nonblood.selected {
  background: #f5f6f0;
}
.details-nonblood .avatar,
.list-nonblood .list-avatar {
  color: #78816f;
  background: #f0f2eb;
}
.list-avatar {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  background: #edf0e9;
  border-radius: 50%;
  color: var(--accent);
  font-size: 10px;
}
.list-person strong {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.45;
}
.list-person small {
  display: block;
  color: var(--muted);
  font-size: 0.65rem;
  margin-top: 3px;
}
.notes {
  margin-top: 28px;
  max-width: 850px;
}
.notes h2 {
  font-size: 0.95rem;
  font-weight: 600;
}
.notes ul {
  padding-left: 18px;
}
.notes li,
.notes p {
  font-size: 0.8rem;
  line-height: 1.8;
  color: var(--muted);
}
footer {
  margin-top: 28px;
  font-size: 0.7rem;
  color: var(--muted);
}
.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-box {
  max-width: 420px;
  width: 100%;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.gate-box h1 {
  font-size: 2rem;
}
.gate-box p {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.6;
}
.gate-box label {
  display: block;
  font-size: 0.8rem;
  margin: 24px 0 8px;
}
#gate-submit {
  width: 100%;
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 8px;
  padding: 12px;
  margin-top: 16px;
  font-weight: 600;
}
#gate-submit:disabled {
  opacity: 0.6;
}
#gate-error {
  color: #a6442d;
}
@media (max-width: 1000px) {
  .shell {
    padding: 28px 20px;
  }
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
  .viewport {
    height: 560px;
  }
}
@media (max-width: 600px) {
  .shell {
    padding: 24px 12px;
  }
  .heading {
    display: block;
  }
  .private {
    display: inline-block;
    margin-top: 18px;
  }
  .stats {
    gap: 10px 18px;
    font-size: 0.75rem;
  }
  .toolbar {
    padding: 12px;
  }
  .sidebar {
    grid-template-columns: minmax(0, 1fr);
  }
  .viewport {
    height: 480px;
  }
}
