/* ---------------------------------------------------------------
   Kinline — a family tree builder.
   Palette: archival paper with a forest accent; ink over soft
   grey-green. Names are set in a serif, the way a record would be.
   --------------------------------------------------------------- */

:root {
  color-scheme: light dark;

  --ground: #edefea;
  --ground-grid: #dfe3dd;
  --surface: #ffffff;
  --surface-2: #f4f6f1;
  --surface-3: #e8ebe5;

  --ink: #181c1a;
  --ink-2: #505b54;
  --ink-3: #7b857d;

  --rule: #d5dad2;
  --rule-strong: #b6bdb6;

  --accent: #2f6b55;
  --accent-ink: #ffffff;
  --accent-soft: #e2ede7;
  --accent-line: #3e7e66;

  --danger: #a6482f;
  --danger-soft: #f6e6e0;

  --edge: #9ba79e;
  --edge-soft: #bcc5bd;

  /* A partnership that is not the current one. */
  --surface-former: #f7f3ea;
  --rule-former: #d9d0bd;

  /* Somebody who married in rather than being related. Mauve is the one hue
     not already carrying a meaning here — green is the relation chip, red the
     deceased chip, sand a former partnership, grey a death. */
  --surface-inlaw: #f3eef7;
  --rule-inlaw: #cfc2dd;

  /* The chip that stands in place of an age. */
  --chip-gone-bg: #fbe7d9;
  --chip-gone-ink: #9d4a24;

  /* A card for somebody no longer living. Clearly darker than a living card
     — and clearly darker than the page ground too, rather than level with it,
     which is what made an earlier attempt vanish into the page. */
  --surface-gone: #dde2dc;
  --rule-gone: #bcc4bb;
  --avatar-gone: #ccd3cb;

  --shadow-1: 0 1px 2px rgba(24, 28, 26, .07);
  --shadow-2: 0 1px 2px rgba(24, 28, 26, .06), 0 6px 18px rgba(24, 28, 26, .07);
  --shadow-3: 0 12px 40px rgba(24, 28, 26, .18);

  --sans: "IBM Plex Sans", ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;

  --radius: 8px;
  --radius-lg: 12px;
  --rail-w: 268px;
  --top-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #14181a;
    --ground-grid: #1d2225;
    --surface: #1e2427;
    --surface-2: #252c2f;
    --surface-3: #2c3437;

    --ink: #e7ebe7;
    --ink-2: #a7b2aa;
    --ink-3: #7c877f;

    --rule: #2f3739;
    --rule-strong: #414a4c;

    --accent: #6cb394;
    --accent-ink: #0f1614;
    --accent-soft: #1d2f28;
    --accent-line: #6cb394;

    --danger: #d4846a;
    --danger-soft: #33211b;

    --edge: #5d6a63;
    --edge-soft: #414b46;

    --surface-former: #242320;
    --rule-former: #3a362d;
    --surface-inlaw: #262230;
    --rule-inlaw: #403651;

    --chip-gone-bg: #3b2519;
    --chip-gone-ink: #e0a17f;

    --surface-gone: #323a3d;
    --rule-gone: #4c5558;
    --avatar-gone: #3e474a;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-2: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .3);
    --shadow-3: 0 12px 40px rgba(0, 0, 0, .5);
    }
}

[data-theme="dark"] {
  --ground: #14181a;
  --ground-grid: #1d2225;
  --surface: #1e2427;
  --surface-2: #252c2f;
  --surface-3: #2c3437;
  --ink: #e7ebe7;
  --ink-2: #a7b2aa;
  --ink-3: #7c877f;
  --rule: #2f3739;
  --rule-strong: #414a4c;
  --accent: #6cb394;
  --accent-ink: #0f1614;
  --accent-soft: #1d2f28;
  --accent-line: #6cb394;
  --danger: #d4846a;
  --danger-soft: #33211b;
  --edge: #5d6a63;
  --edge-soft: #414b46;
  --surface-former: #242320;
  --rule-former: #3a362d;
  --surface-inlaw: #262230;
  --rule-inlaw: #403651;
  --chip-gone-bg: #3b2519;
  --chip-gone-ink: #e0a17f;
  --surface-gone: #323a3d;
  --rule-gone: #4c5558;
  --avatar-gone: #3e474a;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .3);
  --shadow-3: 0 12px 40px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

/* A class that sets `display` otherwise beats the UA rule for [hidden],
   which would leave hidden panels and fields on screen. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

h1, h2, h3 { margin: 0; font-weight: 600; text-wrap: balance; }

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

.muted { color: var(--ink-2); }
.spacer { flex: 1; }

.label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 5px;
}

.hint { margin: 6px 0 0; font-size: 11.5px; color: var(--ink-3); }

/* ---------------------------------------------------------- topbar */

.topbar {
  height: var(--top-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  position: relative;
  z-index: 30;
}

.topbar__brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.topbar__brand h1 { font-family: var(--serif); font-size: 19px; letter-spacing: .01em; }
.mark { width: 22px; height: 22px; color: var(--accent); flex: none; }

.topbar__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------------------------------------------------------- buttons */

.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { background: var(--surface-3); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { filter: brightness(1.07); background: var(--accent); }
.btn--primary:active { filter: brightness(.95); background: var(--accent); }

.btn--icon { width: 30px; padding: 6px 0; text-align: center; font-size: 15px; line-height: 1; }
.btn--small { font-size: 12px; padding: 4px 9px; }
.btn--flat { border-left: 0; border-right: 0; border-radius: 0; min-width: 54px; font-variant-numeric: tabular-nums; }
.btn--flat.is-active { color: var(--accent); font-weight: 600; background: var(--accent-soft); }
.btn--flat .reset-glyph { margin-left: 4px; font-size: 11px; }
.btn--quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn--quiet:hover { background: var(--surface-2); }
.btn--danger-quiet { border-color: transparent; background: transparent; color: var(--danger); }
.btn--danger-quiet:hover { background: var(--danger-soft); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.zoomgroup { display: flex; align-items: stretch; }
.zoomgroup .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.zoomgroup .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }

.menu { position: relative; }

.treeswitch { margin-left: 4px; }
.btn--tree {
  display: flex; align-items: center; gap: 6px;
  max-width: 220px;
  font-family: var(--serif);
  font-size: 14px;
  padding: 5px 10px;
}
.btn--tree > span:first-child {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.caret { color: var(--ink-3); font-size: 10px; flex: none; }

.menu__label {
  margin: 2px 4px 4px;
  font-size: 9.5px; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-3);
}
.menu__panel .treeitem {
  display: flex; align-items: baseline; gap: 8px;
  width: 100%;
}
.menu__panel .treeitem.is-on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.treeitem__count { margin-left: auto; font-size: 10.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.treeitem.is-on .treeitem__count { color: var(--accent); }

.modal--narrow { max-width: min(94vw, 380px); }
.menu__panel {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 216px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  padding: 5px;
  z-index: 40;
}
.menu__panel button {
  display: block; width: 100%; text-align: left;
  font: inherit; font-size: 13px; color: var(--ink);
  background: none; border: 0; border-radius: 6px;
  padding: 7px 10px; cursor: pointer;
}
.menu__panel button:hover { background: var(--surface-2); }
.menu__panel button.is-danger { color: var(--danger); }
.menu__panel button.is-danger:hover { background: var(--danger-soft); }
.menu__panel hr { border: 0; border-top: 1px solid var(--rule); margin: 5px 4px; }

/* ---------------------------------------------------------- shell */

.shell { display: flex; height: calc(100% - var(--top-h)); }

/* ---------------------------------------------------------- rail */

.rail {
  width: var(--rail-w);
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.rail__head { padding: 12px; border-bottom: 1px solid var(--rule); }
.rail__count { margin: 8px 2px 0; font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.rail__list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; min-height: 0; }
.rail__empty { padding: 20px 16px; }
.rail__empty p { margin: 0 0 8px; font-size: 13px; }

.railitem {
  display: flex; align-items: center; gap: 9px;
  width: 100%; text-align: left;
  font: inherit; background: none; border: 0;
  padding: 7px 8px; border-radius: 7px; cursor: pointer;
  color: var(--ink);
}
.railitem:hover { background: var(--surface-2); }
.railitem.is-selected { background: var(--accent-soft); }
.railitem__name { font-family: var(--serif); font-size: 14px; line-height: 1.2; }
.railitem__meta { font-size: 11px; color: var(--ink-3); }
.railitem__text { min-width: 0; }
.railitem__text > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------- stage */

.stage {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  cursor: grab;
  background-color: var(--ground);
  background-image:
    radial-gradient(circle at 1px 1px, var(--ground-grid) 1px, transparent 0);
  background-size: 24px 24px;
  outline: none;
}
.stage.is-panning { cursor: grabbing; }

.edges, .world {
  position: absolute;
  top: 0; left: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.edges { overflow: visible; pointer-events: none; }
.world { pointer-events: none; }
.world > * { pointer-events: auto; }

.stage__hint {
  position: absolute;
  left: 50%; bottom: 14px;
  transform: translateX(-50%);
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-3);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 5px 13px;
  pointer-events: none;
  transition: opacity .35s ease;
}
.stage__hint.is-hidden { opacity: 0; }

/* ---------------------------------------------------------- card */

.card {
  position: absolute;
  width: 236px;
  min-height: 190px;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: 14px 12px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  transition: box-shadow .14s ease, border-color .14s ease, transform .14s ease;
}
.card:hover { box-shadow: var(--shadow-2); border-color: var(--edge); }
.card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow-2);
}
.card.is-dimmed { opacity: .38; }

/* Connected sideways rather than down the line. Both are quiet enough not to
   compete with anything on the card, and far enough apart from each other to
   be told apart in a row. */
.card--former {
  background: var(--surface-former);
  border-color: var(--rule-former);
}
.card--former:hover { border-color: var(--rule-former); }

.card--married-in {
  background: var(--surface-inlaw);
  border-color: var(--rule-inlaw);
}
.card--married-in:hover { border-color: var(--rule-inlaw); }

/* Somebody no longer living. Declared after the tint so the grey ground wins
   where a record is both; the warm border survives, which keeps the two facts
   separate — the ground says whether they are living, the edge says how they
   joined the tree. */
.card--deceased {
  background: var(--surface-gone);
  border-color: var(--rule-gone);
}
.card--deceased:hover { border-color: var(--rule-gone); }
.card--former.card--deceased { border-color: var(--rule-former); }
.card--former.card--deceased:hover { border-color: var(--rule-former); }
.card--married-in.card--deceased { border-color: var(--rule-inlaw); }
.card--married-in.card--deceased:hover { border-color: var(--rule-inlaw); }
/* The portrait frame would otherwise vanish into the greyer card. */
.card--deceased .avatar { background: var(--avatar-gone); }

.avatar {
  flex: none;
  background: var(--surface-3);
  border: 1px solid var(--rule-strong);
  overflow: hidden;
  display: grid; place-items: center;
  font-family: var(--serif);
  color: var(--ink-3);
  width: 46px; height: 46px;
  font-size: 16px;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* The portrait leads the card. */
.avatar--card { width: 114px; height: 114px; font-size: 36px; }
/* Genealogical convention: circle for female, square for male, octagon
   for non-binary and unspecified. Shape, not color. */
.avatar--female { border-radius: 50%; }
.avatar--male { border-radius: 5px; }
.avatar--nonbinary, .avatar--unspecified {
  border-radius: 5px;
  clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%);
}

.card__name {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.22;
  letter-spacing: .005em;
  max-width: 100%;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
/* A deceased record carries it in the name as well as the chip, so it reads
   even where the chips are cut off. */
.card--deceased .card__name { font-style: italic; }

.card__maiden {
  margin: -3px 0 0;
  font-size: 11.5px; font-style: italic; color: var(--ink-3);
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.card__meta {
  display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; margin: 1px 0 0;
}
.chip {
  font-size: 10.5px;
  line-height: 1;
  padding: 4px 7px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--rule);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis;
}
.chip--relation { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.chip--age { font-variant-numeric: tabular-nums; }
.chip--deceased {
  background: var(--chip-gone-bg);
  border-color: transparent;
  color: var(--chip-gone-ink);
  font-weight: 600;
}

.card__note {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--ink-2);
  max-width: 100%;
  overflow-wrap: anywhere;
}
.card__note:empty { display: none; }

/* Counter-scaled against the map's zoom, so the labels stay the size they are
   at 100% instead of shrinking away when you zoom out. */
.card__actions {
  position: absolute;
  top: -13px; right: 8px;
  transform: scale(var(--btn-scale, 1));
  transform-origin: 100% 0;
  display: flex; gap: 3px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: 7px;
  box-shadow: var(--shadow-2);
  opacity: 0;
  transition: opacity .12s ease;
}
.card:hover .card__actions,
.card.is-selected .card__actions,
.card__actions:focus-within { opacity: 1; }

.cardbtn {
  font: inherit; font-size: 11px;
  border: 0; background: none; color: var(--ink-2);
  padding: 3px 7px; border-radius: 5px; cursor: pointer;
}
.cardbtn:hover { background: var(--surface-2); color: var(--ink); }
.cardbtn--danger:hover { background: var(--danger-soft); color: var(--danger); }
.cardbtn--connect { color: var(--accent); font-weight: 600; }

/* ---------------------------------------------------------- edges */

.edge { fill: none; stroke: var(--edge); stroke-width: 1.5; }
.edge--union { stroke-width: 2; }
.edge--sibling { stroke: var(--edge-soft); stroke-dasharray: 5 4; }
/* A partnership that is not the current one. */
.edge--former { stroke-width: 1.6; stroke-dasharray: 7 5; stroke: var(--edge-soft); }
.edge.is-lit { stroke: var(--accent-line); stroke-width: 2.4; }
.edge-node { fill: var(--edge); }
.edge-node.is-lit { fill: var(--accent-line); }

/* ---------------------------------------------------------- forms */

.field { display: block; min-width: 0; }
.field input[type="text"],
.field input[type="search"],
.field select,
.field textarea {
  font: inherit; font-size: 13px;
  width: 100%;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: 7px 9px;
}
.field textarea { resize: vertical; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field--search input { background: var(--surface-2); }
.field input:disabled { opacity: .45; cursor: not-allowed; }

.checkline {
  display: flex; align-items: center; gap: 6px;
  margin-top: 7px; font-size: 12px; color: var(--ink-2);
  cursor: pointer; user-select: none;
}
.checkline input { accent-color: var(--accent); margin: 0; }
.relation__other { margin-top: 7px; }
.field--slider { display: flex; align-items: center; gap: 9px; }
.field--slider .label { margin: 0; }
.field--slider input[type="range"] { flex: 1; accent-color: var(--accent); min-width: 0; }
.btn--step {
  width: 28px; padding: 3px 0; font-size: 15px; line-height: 1.25;
  text-align: center; flex: none;
}
.cropzoom__value {
  font-size: 11.5px; color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  min-width: 38px; text-align: right;
}

.grid { display: grid; gap: 12px; }
.grid--2 { grid-template-columns: 1fr 1fr; }
.grid--3 { grid-template-columns: 1fr 1fr .7fr; }

/* ---------------------------------------------------------- modal */

.modal {
  border: 0; padding: 0;
  background: transparent;
  max-width: min(94vw, 460px);
  width: 100%;
  color: var(--ink);
}
.modal--wide { max-width: min(94vw, 720px); }
.modal::backdrop { background: rgba(16, 20, 18, .42); backdrop-filter: blur(2px); }

.modal__inner {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.modal__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 14px 12px 18px;
  border-bottom: 1px solid var(--rule);
}
.modal__head h2 { font-family: var(--serif); font-size: 18px; }

.modal__body { padding: 18px; overflow-y: auto; display: grid; gap: 14px; align-content: start; }

.modal__foot {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--rule);
  background: var(--surface-2);
}

.personlayout { grid-template-columns: 176px 1fr; gap: 20px; }
.personlayout__fields { display: grid; gap: 12px; align-content: start; }

.photostage { display: grid; gap: 8px; justify-items: start; }
.photostage__preview {
  width: 148px; height: 148px;
  background: var(--surface-2);
  border: 1px solid var(--rule-strong);
  display: grid; place-items: center;
  overflow: hidden;
  font-size: 34px;
}
.photostage__preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photostage__placeholder { font-size: 11.5px; color: var(--ink-3); }
.photostage__buttons { display: flex; gap: 6px; flex-wrap: wrap; }

.cropbody { justify-items: center; }
.cropstage {
  position: relative; width: 320px; height: 320px;
  border-radius: var(--radius); overflow: hidden;
  background: var(--surface-3);
  cursor: grab; touch-action: none;
  justify-self: center;
}
.cropstage.is-dragging { cursor: grabbing; }
.cropstage canvas { display: block; width: 100%; height: 100%; }
.cropstage__mask {
  position: absolute; inset: 0; pointer-events: none;
  background: rgba(16, 20, 18, .5);
  -webkit-mask-image: radial-gradient(circle at 50% 50%, transparent 0 126px, #000 127px);
  mask-image: radial-gradient(circle at 50% 50%, transparent 0 126px, #000 127px);
}
.cropstage__mask::after {
  content: ""; position: absolute;
  left: 50%; top: 50%; width: 252px; height: 252px;
  transform: translate(-50%, -50%);
  border: 1.5px solid rgba(255, 255, 255, .82);
  border-radius: 50%;
}

.connect__subject { margin: 0; font-size: 13px; color: var(--ink-2); }
.connect__subject strong { font-family: var(--serif); font-size: 15px; color: var(--ink); font-weight: 500; }

.segmented { display: flex; gap: 0; border: 1px solid var(--rule-strong); border-radius: var(--radius); overflow: hidden; }
.segmented button {
  flex: 1; font: inherit; font-size: 12.5px; font-weight: 500;
  padding: 7px 4px; border: 0; border-right: 1px solid var(--rule-strong);
  background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.segmented button:last-child { border-right: 0; }
.segmented button:hover { background: var(--surface-2); }
.segmented button.is-on { background: var(--accent); color: var(--accent-ink); }

.tabs { display: flex; gap: 16px; border-bottom: 1px solid var(--rule); }
.tabs button {
  font: inherit; font-size: 12.5px; font-weight: 500;
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 7px 0; margin-bottom: -1px; color: var(--ink-3); cursor: pointer;
}
.tabs button.is-on { color: var(--ink); border-bottom-color: var(--accent); }

.tabpanel { display: grid; gap: 12px; }

.picklist { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; border: 1px solid var(--rule); border-radius: var(--radius); }
.picklist li + li { border-top: 1px solid var(--rule); }
.picklist button {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  font: inherit; background: none; border: 0; padding: 8px 10px; cursor: pointer; color: var(--ink);
}
.picklist button:hover { background: var(--surface-2); }
.picklist button.is-on { background: var(--accent-soft); }
.picklist__name { font-family: var(--serif); font-size: 14px; }
.picklist__meta { font-size: 11px; color: var(--ink-3); }
.picklist__empty { padding: 14px; font-size: 12.5px; color: var(--ink-3); }

.avatar--mini { width: 26px; height: 26px; font-size: 11px; }

/* ---------------------------------------------------------- toast */

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--ink); color: var(--ground);
  font-size: 12.5px; padding: 9px 16px; border-radius: 999px;
  box-shadow: var(--shadow-3); z-index: 90;
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

@media (max-width: 860px) {
  .rail { display: none; }
  .personlayout { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 12px; gap: 10px; }
  .shell { height: calc(100% - 96px); }
}

/* ------------------------------------------------------- connections */

.connlist { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 4px; }
.connlist li {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px 5px 8px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface-2);
}
.connlist__kind {
  font-size: 9.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-3); width: 56px; flex: none;
}
.connlist__name { font-family: var(--serif); font-size: 13px; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.connlist__empty { font-size: 12px; color: var(--ink-3); padding: 2px 0 6px; }
.connlist__badge {
  font-size: 9.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft);
  border-radius: 4px; padding: 3px 6px; flex: none;
}
.connlist__make { color: var(--accent) !important; font-weight: 500; flex: none; }
.connlist__make:hover { background: var(--accent-soft) !important; color: var(--accent) !important; }

.connlist button {
  font: inherit; font-size: 11px; border: 0; background: none;
  color: var(--ink-3); padding: 3px 6px; border-radius: 5px; cursor: pointer;
}
.connlist button:hover { background: var(--danger-soft); color: var(--danger); }

/* ======================================================= the circles map

   The social map reuses the person cards and the pan/zoom surface. What is
   new is the hubs — you at the centre, a disc per circle around you — and
   four edge kinds that have to stay apart visually: the spokes out to each
   circle, the lines down to its people, the dashed line to a second circle
   somebody also belongs to, and a tie between two people. */

.viewswitch {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: var(--surface-2);
}

.btn--view {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  padding: 4px 13px;
  border-radius: 7px;
  font-size: 12.5px;
}

.btn--view:hover { background: var(--surface-3); color: var(--ink); }

.btn--view.is-on {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.09);
}

/* ---------------------------------------------------------------- hubs */

.hub {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-sizing: border-box;
  text-align: center;
  border-radius: 12px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--rule);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.07);
  cursor: default;
}

/* You sit at the centre, so you read as the origin rather than as one more
   stop on the map. */
.hub--you {
  border-radius: 50%;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.16);
}

.hub__you { font-size: 17px; font-weight: 650; letter-spacing: 0.01em; }
.hub--you .hub__sub { color: color-mix(in srgb, var(--accent-ink) 78%, transparent); }

.hub--circle {
  cursor: pointer;
  /* The circle's own colour, as a band down the leading edge rather than a
     fill, so ten circles do not turn the map into a paint chart. */
  border-left: 4px solid var(--hub-colour, var(--accent));
}

.hub--circle:hover { border-color: var(--rule-strong); border-left-color: var(--hub-colour); }
.hub--circle:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }

.hub__name {
  font-size: 13.5px;
  font-weight: 620;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hub__sub {
  font-size: 10.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --------------------------------------------------------------- edges */

/* From you out to a circle: the structure of the map, so it is the quietest
   line of the four. */
.edge--spoke { stroke: var(--edge-soft); stroke-width: 1.4; }

/* From a circle down to one of its people. */
.edge--member { stroke: var(--edge); stroke-width: 1.5; }

/* Somebody is in this circle too, but is drawn in another. */
.edge--also { stroke: var(--edge-soft); stroke-width: 1.3; stroke-dasharray: 6 5; }

/* One person to another, irrespective of circle. */
.edge--tie { stroke: var(--accent-line); stroke-width: 1.5; stroke-dasharray: 2 4; opacity: 0.85; }

/* ------------------------------------------------- the circle editor */

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }

.swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid rgb(0 0 0 / 0.14);
  padding: 0;
  cursor: pointer;
}

.swatch.is-on {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink);
}

.memberlist { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }

.memberlist__row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 12.5px;
}

.memberlist__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.memberlist__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memberlist__empty { font-size: 12.5px; color: var(--ink-3); padding: 4px 2px; }

.pill {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  flex: none;
}

.pill--met { background: var(--accent-soft); color: var(--accent); }

.joinrow { display: flex; gap: 6px; margin-top: 8px; }
.joinrow select { flex: 1 1 auto; min-width: 0; }
.joinrow input { flex: 1 1 auto; min-width: 0; }

.field__hint { font-size: 11.5px; color: var(--ink-3); margin: 4px 0 0; }
.field__hint--lead { margin: 0 0 12px; }
.field__label { font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
                text-transform: uppercase; color: var(--ink-3); }
.modal__spacer { flex: 1; }

/* -------------------------------------------------- the round node

   On the circles map a record is a disc: the face, with the name on a label
   beneath it. The disc is the whole visual, so there is no card chrome
   around it — a rectangle would fight the radial layout it sits in. */

.card--round {
  width: 132px;
  min-height: 0;
  padding: 0;
  gap: 8px;
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
}

.disc {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  flex: none;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-1);
  font-family: var(--serif);
  font-size: 38px;
  color: var(--ink-3);
  transition: box-shadow .14s ease, border-color .14s ease;
}

.disc img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card--round:hover .disc { box-shadow: var(--shadow-2); }

.card--round.is-selected {
  background: transparent;
  border: 0;
}

.card--round.is-selected .disc {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-2);
}

.card--round:focus-visible { outline: none; }
.card--round:focus-visible .disc { outline: 2px solid var(--accent-line); outline-offset: 3px; }

.card__label {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-width: 100%;
}

.card--round .card__name {
  font-size: 13.5px;
  line-height: 1.22;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.card--round .card__how {
  margin: 0;
  font-size: 11px;
  line-height: 1.25;
  color: var(--ink-3);
  overflow-wrap: anywhere;
}

/* A deceased contact keeps the family map's convention. */
.card--round.card--deceased .disc { filter: grayscale(.5); opacity: .88; }
.card--round.card--deceased .card__name { font-style: italic; }

/* The actions hang off the disc, not off a card edge that is not there. */
.card--round .card__actions { top: -10px; right: -4px; }


.rail__emptytitle { font-weight: 600; color: var(--ink); }

/* ========================================================= flashcards

   The study view takes the whole window: a face, nothing else, until you
   turn it over. Everything that is not the card is kept quiet — a thin bar
   of progress above, two verdicts below. */

.study {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: var(--ground);
}

body.is-studying { overflow: hidden; }

.study__bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}

.study__progress { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }

.study__count {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  flex: none;
}

.study__track {
  flex: 1;
  display: flex;
  height: 4px;
  min-width: 60px;
  border-radius: 999px;
  background: var(--surface-3);
  /* The track does the rounding, so the two runs meet at a hard edge in the
     middle and only the outer ends are capped. */
  overflow: hidden;
}

/* Two runs rather than one: what you knew, and what you did not. Together
   they are how far through the deck you are. */
.study__fill {
  height: 100%;
  width: 0;
  transition: width .18s ease;
}

.study__fill--pass { background: var(--accent); }
.study__fill--fail { background: var(--danger); }

.study__tally { display: flex; gap: 6px; flex: none; }

.tally {
  font-size: 11.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  padding: 1px 8px;
  border-radius: 999px;
  min-width: 26px;
  text-align: center;
}

.tally--pass { background: var(--accent-soft); color: var(--accent); }
.tally--fail { background: var(--danger-soft); color: var(--danger); }

.study__barbtns { display: flex; gap: 6px; flex: none; }

/* ------------------------------------------------------- the card */

.study__stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  min-height: 0;
}

.flashcard {
  width: min(420px, 90vw);
  /* Tall enough for a face above and the connections below, without the
     card changing size as it turns. */
  height: min(520px, calc(100vh - 230px));
  perspective: 1400px;
  cursor: pointer;
  border-radius: var(--radius-lg);
}

.flashcard:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 4px; }

.flashcard__inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform .42s cubic-bezier(.2, .7, .3, 1);
  transform-style: preserve-3d;
}

.flashcard.is-flipped .flashcard__inner { transform: rotateY(180deg); }

.flashcard__face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

.flashcard__face--front { justify-content: center; gap: 14px; padding: 20px; }
.flashcard__face--back {
  transform: rotateY(180deg);
  justify-content: flex-start;
  padding: 26px 22px 22px;
  overflow-y: auto;
}

.flashcard__body {
  /* Centred when the back is short, scrolled when it is long. */
  margin-block: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.flashcard__photo {
  width: 100%;
  flex: 1;
  min-height: 0;
  object-fit: cover;
  border-radius: var(--radius-md);
  background: var(--surface-3);
}

.flashcard__blank {
  flex: 1;
  width: 100%;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--surface-3);
  color: var(--ink-3);
  font-size: 68px;
  font-weight: 300;
}

.flashcard__nophoto { margin: 0; font-size: 12px; color: var(--ink-3); }

.flashcard__from {
  margin: 0;
  font-size: 11px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-3);
  flex: none;
}

.flashcard__relation {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: 999px;
}

.flashcard__name {
  font-family: var(--serif);
  font-size: 27px;
  line-height: 1.15;
  margin: 8px 0 0;
  overflow-wrap: anywhere;
}

.flashcard__maiden {
  margin: 2px 0 0;
  font-style: italic;
  font-size: 13.5px;
  color: var(--ink-2);
}

.flashcard__none { margin: 18px 0 0; font-size: 13px; color: var(--ink-3); }

.fact {
  width: 100%;
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 10px;
  text-align: left;
  padding: 9px 0;
  border-top: 1px solid var(--rule);
}

.fact:first-of-type { margin-top: 16px; }

.fact__label {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding-top: 2px;
}

.fact__names { font-size: 13.5px; line-height: 1.45; overflow-wrap: anywhere; }

.flashcard__score {
  margin: 16px 0 0;
  font-size: 11.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.study__hint { margin: 0; font-size: 12px; color: var(--ink-3); }

/* ---------------------------------------------------- the verdicts */

.study__verdict {
  display: flex;
  gap: 10px;
  padding: 14px 16px 18px;
  justify-content: center;
}

.btn--verdict {
  flex: 1;
  max-width: 215px;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
}

.btn--pass { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Inverts on hover. The background has to be restated: the plain .btn:hover
   rule sets a near-white one, and without this the white label disappeared
   into it. */
.btn--pass:hover {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent);
}

.btn--pass:active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.btn--fail { background: var(--surface); border-color: var(--rule-strong); color: var(--danger); }
.btn--fail:hover { background: var(--danger-soft); }

.verdict__key {
  font-size: 11px;
  opacity: .62;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------- the score */

.study__done {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 32px 24px;
  text-align: center;
}

.done__title { font-family: var(--serif); font-size: 34px; margin: 0; }
.done__line { margin: 4px 0 0; color: var(--ink-2); font-size: 14px; }

.done__label {
  margin: 26px 0 8px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.done__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 620px;
}

.done__list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px 5px 5px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12.5px;
}

.done__list img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }

.done__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 30px;
}

/* --------------------------------------------------- the deck builder */

.sourcelist {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--rule);
  border-radius: 9px;
}

.sourcelist__tree {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 9px 11px 4px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--rule);
}

.sourcelist__tree:not(:first-child) { border-top: 1px solid var(--rule); }

.sourcelist__row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 11px;
}

.sourcelist__row + .sourcelist__row { border-top: 1px solid var(--surface-3); }
.sourcelist__row.is-empty { opacity: .5; }

.sourcelist__label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
  font-size: 13px;
}

.sourcelist__icon { color: var(--ink-3); width: 8px; text-align: center; }

.sourcelist__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sourcelist__count {
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  flex: none;
}

.sourcelist__actions { display: flex; gap: 6px; margin-top: 6px; }

.checkline--wide { margin-top: 4px; }

.decksummary {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  font-size: 12.5px;
  color: var(--ink-2);
}

.decksummary--warn {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 26%, transparent);
  color: var(--danger);
}

@media (prefers-reduced-motion: reduce) {
  .flashcard__inner { transition: none; }
  .study__fill { transition: none; }
}

/* The circle hub carries the same actions a card does: add somebody to this
   circle, or edit the circle itself. */
.hub--circle { position: absolute; }

.hub__actions {
  /* Fully clear of the hub: it is only 58px tall and the name sits at the
     top of it, so anything overlapping covers the thing being labelled. */
  top: -26px;
  right: 4px;
}

.hub--circle:hover .hub__actions,
.hub--circle:focus-within .hub__actions { opacity: 1; }

/* A person known through another person, rather than from a circle. */
.edge--via { stroke: var(--accent-line); stroke-width: 1.6; opacity: .75; }

.memberlist__dot--via {
  background: var(--accent);
  border-radius: 2px;
  transform: rotate(45deg);
}

.viarow {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
}
