/* Family Tree. Colours come from the shared themes (themes.css); the values here are what the page
   falls back to before that file loads. */
:root {
  --bg: #0a0a0b;
  --card: #111113;
  --tile: #1d1d21;
  --border: #232327;
  --text: #f4f4f5;
  --muted: #8b8b94;
  --accent: #5eead4;
  --danger: #f87171;
  --card-hover: #151518;
  --border-strong: #34343a;
  --on-accent: #04201c;
  --glow-a: #5eead4;
  --glow-b: #818cf8;
  --s-watching: #60a5fa;
  --s-completed: #4ade80;
  --s-planned: #a78bfa;
  --s-on_hold: #fbbf24;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;

  /* gender accents on cards (the gender is also written in the side panel, so colour is never the only cue) */
  --g-male: var(--s-watching);
  --g-female: var(--s-planned);
  --g-other: var(--s-on_hold);
  --g-unknown: var(--border-strong);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif;
  transition: background 0.3s, color 0.3s;
}
main { width: 100%; min-height: 100vh; padding: clamp(16px, 3vw, 48px) clamp(16px, 3vw, 48px) 64px; }
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--muted); font-size: 0.9rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input, select, textarea {
  font: inherit; color: var(--text); width: 100%;
  background: var(--tile); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px;
}
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
textarea { resize: vertical; }
select { width: auto; max-width: 100%; }
input:disabled, select:disabled { opacity: 0.5; }

/* ---- header, buttons, hero (same as the other DurpeeSquid sites) ---- */
.i { flex: none; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 16px;
  padding-bottom: 20px; margin-bottom: 36px; border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.badge {
  flex: none; display: inline-grid; place-items: center; width: 44px; height: 44px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  font-weight: 600; letter-spacing: 0.02em; color: inherit; text-decoration: none;
}
.badge:hover { border-color: var(--accent); }
.wordmark { font: 700 0.8rem var(--mono); letter-spacing: 0.14em; text-transform: uppercase; white-space: nowrap; }
.sep { flex: none; width: 1px; height: 18px; background: var(--border); }
.handle { font: 0.85rem var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 14px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  font: inherit; font-size: 0.9rem; font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--card-hover); border-color: var(--border-strong); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; font-weight: 600; }
.btn.primary:hover { background: var(--accent); filter: brightness(1.1); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.small { padding: 5px 10px; font-size: 0.82rem; border-radius: 10px; }
.btn.icon-btn { padding: 7px; border-radius: 10px; }
.btn[aria-pressed=true] { border-color: var(--accent); color: var(--accent); }
.link-btn { background: none; border: 0; padding: 0; margin-left: 6px; font: inherit; font-size: 0.82rem; color: var(--accent); cursor: pointer; text-decoration: underline; }

.hero { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 20px 24px; margin-bottom: 28px; }
.eyebrow {
  display: flex; align-items: center; gap: 8px; margin: 0 0 10px;
  font: 0.75rem var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
}
.dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 2.4s ease-out infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
h1 { font-size: clamp(2rem, 5vw, 2.75rem); letter-spacing: -0.03em; line-height: 1.1; overflow-wrap: anywhere; }
.statpanel { display: flex; background: var(--card); border: 1px solid var(--border); border-radius: 16px; }
.stat-cell { padding: 12px 22px; border-left: 1px solid var(--border); min-width: 0; }
.stat-cell:first-child { border-left: 0; }
.stat-label { display: block; margin-bottom: 4px; font: 0.68rem var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.stat-value { font: 0.95rem var(--mono); }
@media (max-width: 640px) { .statpanel { width: 100%; } .stat-cell { flex: 1; padding: 12px 14px; } }
footer.foot { margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--border); font: 0.72rem var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora i { position: absolute; width: 46vmax; height: 46vmax; border-radius: 50%; filter: blur(90px); opacity: 0.18; animation: drift 26s ease-in-out infinite alternate; }
.aurora i:nth-child(1) { top: -18vmax; left: -12vmax; background: var(--glow-a); }
.aurora i:nth-child(2) { top: 12vmax; right: -16vmax; background: var(--glow-b); animation-duration: 32s; animation-delay: -9s; }
.aurora i:nth-child(3) { bottom: -24vmax; left: 24vw; background: var(--accent); opacity: 0.1; animation-duration: 38s; animation-delay: -15s; }
@keyframes drift { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(6vmax, 4vmax, 0) scale(1.15); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.panel { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 20px; margin-bottom: 24px; }
.panel h2 { font-size: 1.1rem; margin-bottom: 8px; }
.panel.start { max-width: 640px; }
.lead { margin-bottom: 16px; font-size: 1rem; }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 50; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 12px 18px; border-radius: 14px; background: var(--card); color: var(--text); max-width: calc(100vw - 32px);
  border: 1px solid var(--border-strong); box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.5); transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--danger); color: var(--danger); }

/* ---- directory of public trees ---- */
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.person-link { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--tile); border: 1px solid var(--border); border-radius: 14px; color: inherit; text-decoration: none; transition: transform 0.2s, border-color 0.2s; }
.person-link:hover { transform: translateY(-3px); border-color: var(--accent); }
.dir-text { display: grid; min-width: 0; }
.dir-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dir-sub { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- avatars ---- */
.avatar {
  flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; overflow: hidden;
  font-weight: 700; font-size: 0.85rem; object-fit: cover;
  background: linear-gradient(135deg, var(--glow-a), var(--glow-b)); color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.avatar.big { width: 68px; height: 68px; font-size: 1.5rem; }

/* ---- toolbar ---- */
.tree-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.find { position: relative; flex: 0 1 280px; min-width: 200px; }
.find input { padding-left: 34px; border-radius: 12px; }
.find-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.find-results {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 4px; list-style: none;
  background: var(--card); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.5);
}
.find-item, .find-empty { display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 0.92rem; }
.find-item.active, .find-item:hover { background: var(--tile); }
.find-empty { color: var(--muted); cursor: default; }
.find-sub { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.find-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.seg { display: inline-flex; }
.seg .btn { border-radius: 0; }
.seg .btn:first-child { border-radius: 12px 0 0 12px; }
.seg .btn:last-child { border-radius: 0 12px 12px 0; border-left: 0; }
.seg .btn.on { background: var(--accent); color: var(--on-accent); border-color: transparent; font-weight: 600; }

.focus-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--muted); padding: 6px 12px; border: 1px solid var(--border); border-radius: 99px; background: var(--card); }
.focus-chip strong { color: var(--text); font-weight: 600; }

/* ---- the drawing ---- */
.stage { display: flex; gap: 14px; height: clamp(520px, calc(100vh - 330px), 900px); }
.canvas {
  position: relative; flex: 1; min-width: 0; overflow: hidden; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--muted) 22%, transparent) 1px, transparent 0) 0 0 / 28px 28px,
    var(--card);
  border: 1px solid var(--border); border-radius: 16px;
}
.canvas.panning { cursor: grabbing; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.world.flying { transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }
.edges { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.edge { fill: none; stroke: color-mix(in srgb, var(--muted) 70%, transparent); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.edge.partner { stroke-width: 2.4; }
.edge.dashed { stroke-dasharray: 6 5; }
.edge.hl { stroke: var(--accent); stroke-width: 2.8; }

.card {
  position: absolute; width: 184px; height: 76px; display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 10px;
  text-align: left; color: var(--text); font: inherit; cursor: pointer;
  background: var(--card-hover); border: 1px solid var(--border-strong); border-left: 5px solid var(--c, var(--g-unknown)); border-radius: 14px;
  transition: border-color 0.15s, box-shadow 0.2s, transform 0.2s;
}
.card[data-gender=male] { --c: var(--g-male); }
.card[data-gender=female] { --c: var(--g-female); }
.card[data-gender=other] { --c: var(--g-other); }
.card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.6); }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent), 0 12px 28px -12px color-mix(in srgb, var(--accent) 60%, transparent); }
.card.focus::after {
  content: ''; position: absolute; inset: -6px; border-radius: 19px; border: 1.5px dashed var(--accent); pointer-events: none;
}
.card[data-living=no] .avatar { filter: grayscale(0.7); }
.card[data-placeholder=yes] { border-style: dashed; background: transparent; }
.card[data-placeholder=yes] .card-name { font-style: italic; color: var(--muted); }
.card-text { display: grid; min-width: 0; line-height: 1.25; }
.card-name { font-weight: 600; font-size: 0.9rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.card-sub { font: 0.72rem var(--mono); color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag-me {
  position: absolute; top: -9px; right: 10px; padding: 0 8px; border-radius: 99px; font: 700 0.62rem var(--mono); letter-spacing: 0.08em; text-transform: uppercase;
  background: var(--accent); color: var(--on-accent);
}
.zoom { position: absolute; right: 12px; bottom: 12px; z-index: 5; display: grid; gap: 6px; cursor: default; }
.zoom .btn { background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(6px); }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 14px 0 0; padding: 0; font-size: 0.8rem; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend li[class^=k-]:not(.k-line)::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.k-female { --c: var(--g-female); } .k-male { --c: var(--g-male); } .k-other { --c: var(--g-other); } .k-unknown { --c: var(--g-unknown); }

/* ---- side window ---- */
.side {
  flex: none; width: 400px; overflow-y: auto; scrollbar-color: var(--border-strong) transparent;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
}
.side-head { display: flex; gap: 14px; align-items: flex-start; padding: 18px 16px 6px 18px; }
.side-title { flex: 1; min-width: 0; }
.side-title h2 { font-size: 1.3rem; letter-spacing: -0.02em; line-height: 1.2; overflow-wrap: anywhere; }
.side-title p { margin-top: 2px; }
.life { font: 0.85rem var(--mono); color: var(--muted); }
.side-body { padding: 8px 18px 20px; display: grid; gap: 16px; }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-row:empty { display: none; }
.pill {
  padding: 1px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; color: var(--muted);
  background: var(--tile); border: 1px solid var(--border);
}
.pill.rel { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.side-actions, .danger-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.danger-row { padding-top: 12px; border-top: 1px solid var(--border); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 0.92rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.rel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.rel-head h3 { margin: 0 !important; }
.bio h3, .rel-section h3 { font: 0.7rem var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 400; margin-bottom: 8px; }
.bio p { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.95rem; }
.note { line-height: 1.5; }
.rel-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rel-row { display: flex; align-items: center; gap: 6px; }
.rel-person {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px 8px; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--tile); border: 1px solid var(--border); border-radius: 12px;
}
.rel-person:hover { border-color: var(--accent); }
.rel-person .avatar { width: 30px; height: 30px; font-size: 0.72rem; }
.rel-text { display: grid; min-width: 0; line-height: 1.25; }
.rel-name { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel-sub { font-size: 0.75rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel-sub:empty { display: none; }
select.kind { padding: 5px 8px; font-size: 0.8rem; border-radius: 8px; }

/* ---- dialogs and forms ---- */
dialog.modal {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 20px; color: var(--text);
  background: var(--card); border: 1px solid var(--border); border-radius: 16px; overflow-y: auto;
}
dialog.modal.wide { width: min(660px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(0, 0, 0, 0.65); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-head h2 { font-size: 1.15rem; overflow-wrap: anywhere; }
.form, .person-fields { display: grid; gap: 14px; }
.field { display: grid; gap: 4px; align-content: start; }
.field-label { font-size: 0.78rem; color: var(--muted); }
.hint { font-size: 0.75rem; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.92rem; cursor: pointer; }
.foot-row { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.foot-row.spread { justify-content: space-between; }
.form-error { color: var(--danger); font-size: 0.9rem; min-height: 0; }
.form-error:empty { display: none; }
.confirm p { margin-bottom: 16px; }
.who-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 1rem; }
.who-line select { font-weight: 600; }
.who-line.none .of, .who-line.none select[name=anchor] { display: none; }
.options { display: grid; gap: 12px; }
.options:empty { display: none; }
.existing { display: grid; gap: 12px; }
.fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px 12px; margin: 0; display: grid; gap: 10px; }
.fieldset legend { font-size: 0.78rem; color: var(--muted); padding: 0 6px; }
.radio { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.radio input { margin-top: 5px; }
.radio span { display: grid; }
.radio small { color: var(--muted); }
.share-row { display: flex; gap: 8px; }

/* ---- small screens: the side window goes underneath ---- */
@media (max-width: 820px) {
  .stage { flex-direction: column; height: auto; }
  .canvas { flex: none; height: 62vh; min-height: 360px; }
  .stage.with-side .canvas { height: 42vh; min-height: 300px; }
  .side { width: auto; }
  .find { flex-basis: 100%; }
  .spacer { display: none; }
}

.living-row { align-items: end; }
.living-row .check { padding-bottom: 9px; }
.more-fields > summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; width: fit-content; margin-bottom: 12px; }
.more-fields > summary:hover { color: var(--text); }
