:root {
      --bg: #f4f4f5;
      --paper: #ffffff;
      --ink: #18181b;
      --muted: #52525b;
      --line: #e4e4e7;
      --accent: #2563eb;
      --accent-soft: #dbeafe;
      --ok: #15803d;
      --ok-bg: #dcfce7;
      --warn: #b45309;
      --warn-bg: #ffedd5;
      --danger: #b42318;
      --danger-bg: #fee2e2;
      --shadow: 0 1px 2px rgba(24, 24, 27, .06), 0 8px 24px rgba(24, 24, 27, .06);
      --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
      --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
      --field-bg: #ffffff;
      --field-ink: #18181b;
      --placeholder: #71717a;
      --btn: #2563eb;
      --btn-ink: #ffffff;
      --glow: #eff6ff;
    }
    html[data-palette="parchment"] {
      --bg: #f6f1e8; --paper: #fffdf8; --ink: #2a241c; --muted: #4a433a; --line: #e4d9c8;
      --accent: #6b4f2e; --accent-soft: #efe4d2; --btn: #6b4f2e; --btn-ink: #fff8ec;
      --field-bg: #fffdf8; --field-ink: #2a241c; --placeholder: #8a8074; --glow: #fff8ec;
      --warn: #8a4b12; --warn-bg: #f8ead8;
    }
    html[data-palette="slate"] {
      --bg: #f1f5f9; --paper: #fff; --ink: #0f172a; --muted: #475569; --line: #e2e8f0;
      --accent: #334155; --accent-soft: #e2e8f0; --btn: #334155; --btn-ink: #fff;
      --field-bg: #fff; --glow: #f8fafc;
    }
    html[data-palette="ocean"] {
      --bg: #f0fdfa; --paper: #fff; --ink: #134e4a; --muted: #0f766e; --line: #ccfbf1;
      --accent: #0d9488; --accent-soft: #ccfbf1; --btn: #0d9488; --btn-ink: #fff;
      --field-bg: #fff; --glow: #ccfbf1;
    }
    html[data-palette="forest"] {
      --bg: #f0fdf4; --paper: #fff; --ink: #14532d; --muted: #166534; --line: #dcfce7;
      --accent: #16a34a; --accent-soft: #dcfce7; --btn: #15803d; --btn-ink: #fff;
      --field-bg: #fff; --glow: #dcfce7;
    }
    html[data-palette="dusk"] {
      --bg: #f5f3ff; --paper: #fff; --ink: #2e1065; --muted: #6d28d9; --line: #ede9fe;
      --accent: #7c3aed; --accent-soft: #ede9fe; --btn: #7c3aed; --btn-ink: #fff;
      --field-bg: #fff; --glow: #ede9fe;
    }
    * { box-sizing: border-box; }
    body {
      margin: 0;
      color: var(--ink);
      background-color: var(--bg);
      background-image: radial-gradient(90rem 32rem at 8% -8%, var(--glow) 0%, transparent 58%);
      background-repeat: no-repeat;
      background-attachment: fixed;
      font-family: var(--sans);
      line-height: 1.5;
    }
    a { color: var(--accent); }
    header.appbar {
      background: var(--paper);
      border-bottom: 1px solid var(--line);
      padding: .85rem 1.25rem;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 1rem;
      position: sticky;
      top: 0;
      z-index: 10;
    }
    header.appbar h1 {
      margin: 0;
      font-family: var(--serif);
      font-size: 1.25rem;
      font-weight: 600;
    }
    header.appbar h1 a { color: inherit; text-decoration: none; }
    .nav-toggle { display: none; }
    header nav { display: flex; gap: .9rem; align-items: center; flex-wrap: wrap; font-size: .92rem; }
    @media (max-width: 800px) {
      header.appbar { flex-wrap: nowrap; align-items: center; padding: .55rem .8rem; }
      header.appbar h1 { font-size: 1.05rem; }
      .nav-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        flex: 0 0 auto; width: 2.4rem; height: 2.4rem; padding: 0;
        background: var(--accent-soft); color: var(--ink);
      }
      .burger, .burger::before, .burger::after {
        display: block; width: 1.1rem; height: 2px; background: currentColor; position: relative;
      }
      .burger::before, .burger::after { content: ""; position: absolute; left: 0; }
      .burger::before { top: -.35rem; }
      .burger::after { top: .35rem; }
      header nav {
        display: none;
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        flex-direction: column;
        align-items: stretch;
        gap: .35rem;
        padding: .75rem 1rem 1rem;
        background: var(--paper);
        border-bottom: 1px solid var(--line);
        box-shadow: var(--shadow);
      }
      header.appbar { position: sticky; }
      header nav.open { display: flex; }
      header .search input { width: 100%; }
    }
    header nav a { color: var(--muted); text-decoration: none; }
    header nav a:hover, header nav a.active { color: var(--ink); }
    header nav a.active { font-weight: 700; }
    header .search { display: flex; gap: .35rem; align-items: center; }
    header .search input { width: 9rem; }
    html[data-theme="dark"], html[data-palette="ink"][data-theme="dark"] {
      --bg: #18181b; --paper: #27272a; --ink: #fafafa; --muted: #a1a1aa; --line: #3f3f46;
      --accent: #93c5fd; --accent-soft: #1e3a5f; --ok-bg: #14532d; --warn-bg: #7c2d12;
      --danger-bg: #7f1d1d; --shadow: none; --field-bg: #18181b; --field-ink: #fafafa;
      --placeholder: #71717a; --btn: #60a5fa; --btn-ink: #18181b; --glow: #27272a;
    }
    html[data-palette="parchment"][data-theme="dark"] {
      --bg: #1c1915; --paper: #2a241c; --ink: #f3ece2; --muted: #c4b8a8; --line: #3f372d;
      --accent: #d4b48a; --accent-soft: #3a3228; --btn: #c4a574; --btn-ink: #1c1915;
      --field-bg: #1c1915; --field-ink: #f3ece2; --glow: #2a241c;
    }
    html[data-palette="slate"][data-theme="dark"] {
      --bg: #0f172a; --paper: #1e293b; --ink: #f8fafc; --muted: #94a3b8; --line: #334155;
      --accent: #cbd5e1; --accent-soft: #334155; --btn: #cbd5e1; --btn-ink: #0f172a; --field-bg: #0f172a; --glow: #1e293b;
    }
    html[data-palette="ocean"][data-theme="dark"] {
      --bg: #042f2e; --paper: #134e4a; --ink: #ccfbf1; --muted: #5eead4; --line: #115e59;
      --accent: #2dd4bf; --accent-soft: #115e59; --btn: #2dd4bf; --btn-ink: #042f2e; --field-bg: #042f2e; --glow: #134e4a;
    }
    html[data-palette="forest"][data-theme="dark"] {
      --bg: #052e16; --paper: #14532d; --ink: #dcfce7; --muted: #86efac; --line: #166534;
      --accent: #4ade80; --accent-soft: #166534; --btn: #4ade80; --btn-ink: #052e16; --field-bg: #052e16; --glow: #14532d;
    }
    html[data-palette="dusk"][data-theme="dark"] {
      --bg: #1e1b4b; --paper: #312e81; --ink: #ede9fe; --muted: #c4b5fd; --line: #4338ca;
      --accent: #c4b5fd; --accent-soft: #4338ca; --btn: #a78bfa; --btn-ink: #1e1b4b; --field-bg: #1e1b4b; --glow: #312e81;
    }
    @media (prefers-color-scheme: dark) {
      html[data-theme="auto"] {
        --bg: #18181b; --paper: #27272a; --ink: #fafafa; --muted: #a1a1aa; --line: #3f3f46;
        --accent: #93c5fd; --accent-soft: #1e3a5f; --field-bg: #18181b; --field-ink: #fafafa;
        --btn: #60a5fa; --btn-ink: #18181b; --glow: #27272a; --shadow: none;
      }
      html[data-palette="parchment"][data-theme="auto"] {
        --bg: #1c1915; --paper: #2a241c; --ink: #f3ece2; --muted: #c4b8a8; --line: #3f372d;
        --accent: #d4b48a; --accent-soft: #3a3228; --btn: #c4a574; --btn-ink: #1c1915; --field-bg: #1c1915;
      }
      html[data-palette="slate"][data-theme="auto"] {
        --bg: #0f172a; --paper: #1e293b; --ink: #f8fafc; --muted: #94a3b8; --line: #334155;
        --accent: #cbd5e1; --accent-soft: #334155; --btn: #cbd5e1; --btn-ink: #0f172a; --field-bg: #0f172a;
      }
      html[data-palette="ocean"][data-theme="auto"] {
        --bg: #042f2e; --paper: #134e4a; --ink: #ccfbf1; --muted: #5eead4; --line: #115e59;
        --accent: #2dd4bf; --accent-soft: #115e59; --btn: #2dd4bf; --btn-ink: #042f2e; --field-bg: #042f2e;
      }
      html[data-palette="forest"][data-theme="auto"] {
        --bg: #052e16; --paper: #14532d; --ink: #dcfce7; --muted: #86efac; --line: #166534;
        --accent: #4ade80; --accent-soft: #166534; --btn: #4ade80; --btn-ink: #052e16; --field-bg: #052e16;
      }
      html[data-palette="dusk"][data-theme="auto"] {
        --bg: #1e1b4b; --paper: #312e81; --ink: #ede9fe; --muted: #c4b5fd; --line: #4338ca;
        --accent: #c4b5fd; --accent-soft: #4338ca; --btn: #a78bfa; --btn-ink: #1e1b4b; --field-bg: #1e1b4b;
      }
    }
    @media print {
      header, .actions, nav, .modal-back, button, .btn { display: none !important; }
      main { max-width: none; }
    }
    main { max-width: 980px; margin: 0 auto; padding: 1.5rem 1.15rem 3rem; }
    .messages { list-style: none; padding: 0; margin: 0 0 1rem; }
    .messages li {
      padding: .65rem .85rem;
      border-radius: 10px;
      background: var(--ok-bg);
      border: 1px solid #cfe3d5;
      margin-bottom: .4rem;
    }
    .messages li.error, .messages li.danger {
      background: var(--danger-bg);
      border-color: #f0a8a0;
      color: #8a1c14;
      font-weight: 600;
    }
    .messages li.warning {
      background: #fff3cd;
      border-color: #e6c35c;
      color: #6b4e00;
    }
    .card {
      background: var(--paper);
      border: 1px solid var(--line);
      border-radius: 14px;
      box-shadow: var(--shadow);
      padding: 1.1rem 1.2rem;
    }
    .stack { display: flex; flex-direction: column; gap: .75rem; }
    .stack.tight { gap: .45rem; }
    .row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
    .split { display: grid; gap: 1rem; }
    h2, h3 { font-family: var(--serif); font-weight: 600; }
    h2 { margin: 0 0 .2rem; font-size: 1.55rem; }
    h3 { margin: 0 0 .45rem; font-size: 1.05rem; }
    .lede { color: var(--muted); margin: 0 0 .65rem; }
    .lede:empty { display: none; }
    p { margin: 0 0 .65rem; }
    p:last-child { margin-bottom: 0; }
    form p { margin: 0 0 .55rem; }
    label.field, .field {
      display: flex;
      flex-direction: column;
      gap: .25rem;
      font-size: .78rem;
      color: var(--muted);
      font-weight: 600;
      flex: 0 1 auto;
    }
    .field-head {
      display: inline-flex;
      align-items: center;
      gap: .3rem;
      flex-wrap: nowrap;
      white-space: nowrap;
    }
    .row > .field { flex: 1 1 10rem; }
    input, select, textarea, button, .btn {
      font: inherit;
      padding: .45rem .6rem;
      border-radius: 8px;
      border: 1px solid var(--line);
      background: var(--field-bg);
      color: var(--field-ink);
    }
    input::placeholder, textarea::placeholder {
      color: var(--placeholder);
      opacity: 1;
      font-weight: 400;
    }
    input:not(:placeholder-shown), textarea:not(:placeholder-shown) {
      font-weight: 600;
      color: var(--field-ink);
    }
    textarea { min-height: 5.5rem; width: 100%; resize: vertical; }
    textarea.short { min-height: 3.5rem; }
    details.fold { margin-top: .65rem; }
    details.fold > summary {
      cursor: pointer;
      font-weight: 600;
      font-size: .88rem;
      color: var(--muted);
      list-style: none;
    }
    details.fold > summary::-webkit-details-marker { display: none; }
    details.fold > summary::before { content: "▸ "; }
    details.fold[open] > summary::before { content: "▾ "; }
    details.fold[open] > summary { margin-bottom: .5rem; }
    button, .btn {
      cursor: pointer;
      background: var(--btn);
      color: var(--btn-ink);
      border: none;
      font-weight: 600;
      text-decoration: none;
      display: inline-block;
    }
    button.secondary, .btn.secondary { background: var(--accent-soft); color: var(--ink); }
    button.small, .btn.small { padding: .3rem .55rem; font-size: .85rem; }
    .muted { color: var(--muted); font-size: .9rem; }
    .badge {
      display: inline-block;
      padding: .1rem .5rem;
      border-radius: 999px;
      font-size: .75rem;
      font-weight: 600;
      background: var(--accent-soft);
      color: var(--accent);
    }
    .badge.warn { background: var(--warn-bg); color: var(--warn); }
    ul.plain { list-style: none; padding: 0; margin: 0; }
    ul.plain li { padding: .35rem 0; border-bottom: 1px solid var(--line); }
    ul.plain li:last-child { border-bottom: 0; }
    .row-line { display: flex; flex-wrap: nowrap; align-items: flex-start; gap: .35rem .6rem; width: 100%; }
    .row-line .row-main { flex: 1 1 auto; min-width: 0; }
    .row-line form { margin-left: auto; flex: 0 0 auto; }
    .icon-x {
      margin-left: 0;
      background: none;
      color: var(--muted);
      padding: .05rem .4rem;
      font-size: 1.15rem;
      line-height: 1;
      font-weight: 400;
      border-radius: 4px;
    }
    .icon-x:hover { color: var(--danger); background: var(--danger-bg); }
    .person-link { font-weight: 600; text-decoration: none; color: var(--ink); }
    .person-link:hover { color: var(--accent); }
    .story {
      border-top: 1px solid var(--line);
      padding: 0.85rem 0;
    }
    .story:first-child { border-top: 0; padding-top: 0; }
    .narrow { max-width: 28rem; }
    form.logout { display: inline; }
    form.logout button {
      background: none;
      color: var(--muted);
      padding: 0;
      font-weight: 500;
    }
    .help { font-size: .82rem; color: var(--muted); font-weight: 400; }
    .errorlist { color: var(--danger); font-size: .88rem; padding-left: 1.1rem; }
    .actions { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; margin-top: .35rem; }
    .actions a, .actions button.linkish {
      font-size: .82rem;
      font-weight: 600;
      background: none;
      color: var(--muted);
      padding: 0;
      border: none;
    }
    .conf {
      display: inline-flex;
      align-items: center;
      gap: .35rem;
      font-size: .78rem;
      color: var(--muted);
      font-weight: 600;
    }
    .conf select { padding: .2rem .35rem; width: auto; }
    header .who a { color: inherit; text-decoration: none; font-weight: 600; }
    header .who a:hover { color: var(--accent); }
    .cert {
      display: inline-block;
      min-width: 1.1rem;
      font-size: .72rem;
      font-weight: 700;
      color: var(--accent);
      cursor: pointer;
      vertical-align: baseline;
      line-height: 1;
    }
    .cert-pop {
      position: absolute;
      z-index: 40;
      background: var(--paper);
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: .55rem .7rem;
      box-shadow: var(--shadow);
      width: 10.5rem;
      max-width: calc(100vw - 1.5rem);
    }
    .cert-pop input[type="range"] {
      width: 100%;
      margin: .35rem 0 0;
      padding: 0;
      accent-color: var(--accent);
      background: transparent;
      border: none;
    }
    .hist { font-size: .75rem; font-weight: 600; color: var(--muted); margin-left: .35rem; }
    .star { background: none; border: none; color: var(--muted); font-size: 1.15rem; padding: 0; cursor: pointer; }
    .star.on { color: #c9a227; }
    .chips { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin: .35rem 0; }
    .chip, .chip-form button {
      background: var(--accent-soft);
      color: var(--accent);
      border-radius: 999px;
      padding: .1rem .55rem;
      font-size: .78rem;
      font-weight: 600;
      border: none;
      text-decoration: none;
    }
    .chip.on { background: var(--accent); color: #fff; }
    .chip-add input { font-size: .8rem; padding: .15rem .4rem; }
    .modal-back {
      position: fixed; inset: 0; background: rgba(40,30,16,.35); z-index: 30;
      display: none; align-items: center; justify-content: center;
    }
    .modal-back.on { display: flex; }
    .modal {
      background: var(--paper);
      border-radius: 14px;
      padding: 1.1rem 1.2rem;
      width: min(36rem, 94vw);
      max-height: 86vh;
      overflow: auto;
      box-shadow: var(--shadow);
    }
    .pick-list { list-style: none; padding: 0; margin: .4rem 0 0; display: flex; flex-direction: column; gap: .4rem; }
    .pick-list li.pick-tile {
      display: grid;
      grid-template-columns: 2.4rem minmax(0, 1fr) auto;
      gap: .55rem;
      align-items: center;
      padding: .45rem .55rem;
      border: 1px solid var(--line);
      border-radius: 10px;
      background: var(--paper);
    }
    .pick-thumb, .pick-ph {
      width: 2.4rem; height: 2.4rem; border-radius: 6px; object-fit: cover;
      background: var(--accent-soft);
      flex: 0 0 auto;
    }
    .pick-ph { display: block; }
    .pick-tile .who { display: block; }
    .pick-list .who { font-weight: 600; color: var(--ink); text-decoration: none; }
    .rel-grid {
      list-style: none; padding: 0; margin: 0;
      display: flex; flex-wrap: wrap; gap: .65rem;
      align-items: stretch;
    }
    .rel-grid > .muted { flex: 1 1 100%; padding: .2rem 0; border: 0; }
    .rel-tile {
      position: relative;
      flex: 1 1 11rem;
      max-width: 18rem;
      min-width: 10rem;
      padding: .7rem .85rem .65rem;
      border: 1px solid var(--line);
      border-radius: 12px;
      background: var(--accent-soft);
      display: flex; flex-direction: column; gap: .25rem;
    }
    html[data-theme="dark"] .rel-tile { background: var(--paper); }
    .rel-tile.ended { opacity: .82; border-style: dashed; }
    .rel-tile.add {
      background: transparent;
      border-style: dashed;
      min-height: 5.5rem;
    }
    .rel-tile.add > .fold { margin: 0; }
    .rel-tile.add > .fold > summary { color: var(--ink); font-size: .95rem; }
    .rel-tile.add > .fold > summary::before { content: "+ "; }
    .rel-tile.add > .fold[open] > summary::before { content: "+ "; }
    .rel-tile.add:has(details[open]) { flex: 1 1 100%; max-width: none; }
    .rel-tile-head {
      display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .45rem;
      padding-right: 1.4rem;
    }
    .rel-tile-name {
      font-weight: 700;
      font-size: 1.05rem;
      text-decoration: none;
      color: var(--ink);
      line-height: 1.25;
    }
    .rel-tile-name:hover { color: var(--accent); }
    .rel-tile-meta { font-size: .86rem; }
    .rel-tile-x {
      position: absolute; top: .35rem; right: .3rem; margin: 0;
    }
    .rel-tile-more { margin-top: .35rem; }
    .rel-thumb {
      width: 100%; height: 7.5rem; object-fit: cover; border-radius: 8px;
      background: var(--paper);
    }
    .rel-thumb.ph { display: block; height: 4.5rem; }
    .search-grid .rel-tile { flex: 1 1 12rem; max-width: 16rem; background: var(--paper); }
    .search-grid.rows { flex-direction: column; }
    .search-grid.rows .rel-tile {
      flex: 1 1 auto; max-width: none; width: 100%;
      flex-direction: row; align-items: center; gap: .75rem;
    }
    .search-grid.rows .rel-thumb { width: 3rem; height: 3rem; flex: 0 0 auto; }
    .search-grid.rows .rel-thumb.ph { height: 3rem; }
    .view-toggle { display: flex; gap: .35rem; margin: 0; }
    .portrait-box {
      padding: .7rem;
      border: 1px solid var(--line);
      border-radius: 12px;
      background: var(--accent-soft);
    }
    html[data-theme="dark"] .portrait-box { background: var(--bg); }
    .tree-card.unknown { border-style: dashed; opacity: .7; cursor: default; }
    .ll { margin: 0 0 .85rem; }
    .ll-tools { display: flex; align-items: center; gap: .35rem; margin-bottom: .35rem; }
    .ll-scroll { overflow-x: auto; max-width: 100%; }
    .ll-svg { display: block; height: auto; }
    .ll-axis { stroke: var(--line); stroke-width: 2; }
    .ll-stem { stroke: var(--accent); stroke-width: 1; }
    .ll-dot { fill: var(--accent); }
    .ll-dot.fuzzy { fill: var(--paper); stroke: var(--accent); stroke-width: 2; }
    .ll-span { fill: var(--accent); opacity: .28; }
    .ll-label, .ll-year { fill: var(--muted); font-size: 11px; }
    .ll-unknown { margin: .35rem 0 0; }
    .fc-unit { display: flex; flex-direction: column; align-items: center; gap: .45rem; }
    .cite-pop .pick-list, .tiptap-person .pick-list { width: 100%; }
    .cite-pop .pick-tile, .tiptap-person .pick-tile { width: 100%; }
    .portraits { display: flex; flex-wrap: wrap; gap: 1rem; }
    .portraits figure { margin: 0; }
    .portraits img {
      display: block;
      width: min(100%, 18rem);
      max-height: 22rem;
      height: auto;
      object-fit: contain;
      border-radius: 12px;
      background: var(--accent-soft);
    }
    button.img-zoom {
      background: none;
      border: none;
      padding: 0;
      cursor: zoom-in;
    }
    .lightbox {
      position: fixed;
      inset: 0;
      background: rgba(20, 16, 10, .82);
      z-index: 50;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 1.5rem;
    }
    .lightbox.on { display: flex; }
    .lightbox img { max-width: 96vw; max-height: 92vh; object-fit: contain; border-radius: 8px; }
    .rich-body ul, .rich-body ol { margin: .35rem 0 .35rem 1.2rem; }
    .draft-status { min-height: 1.2em; }
    .md-tabs { display: flex; gap: .75rem; margin-bottom: .35rem; }
    .md-tabs .on { color: var(--ink); font-weight: 700; }
    .md-preview { min-height: 6rem; }
    .note-line { font-size: .9rem; margin: .35rem 0; }
    .note-line form, .note-line details { display: inline; }
    .inline-fold > summary { display: inline; }
    details.section > summary {
      font-family: var(--serif);
      font-weight: 600;
      font-size: 1.05rem;
      cursor: pointer;
      list-style: none;
      margin-bottom: .45rem;
    }
    details.section > summary::-webkit-details-marker { display: none; }
    details.section > summary::before { content: "▾ "; color: var(--muted); }
    details.section:not([open]) > summary { margin-bottom: 0; }
    details.section:not([open]) > summary::before { content: "▸ "; }
    .ProseMirror { min-height: 8rem; outline: none; }
    .ProseMirror p { margin: 0 0 .65rem; }
    .tiptap-wrap { border: 1px solid var(--line); border-radius: 8px; background: var(--field-bg); }
    .tiptap-bar {
      display: flex; flex-wrap: wrap; align-items: center; gap: .15rem;
      padding: .3rem .4rem; border-bottom: 1px solid var(--line);
    }
    .tiptap-bar .tb {
      width: 1.85rem; height: 1.85rem; padding: 0;
      background: transparent; color: var(--ink);
      border-radius: 6px; font-weight: 700; font-size: .9rem;
      display: inline-flex; align-items: center; justify-content: center;
    }
    .tiptap-bar .tb:hover { background: var(--accent-soft); }
    .tiptap-bar .tb.on { background: var(--accent-soft); color: var(--accent); }
    .tb-u { text-decoration: underline; }
    .tiptap-person { padding: .5rem .75rem; border-bottom: 1px solid var(--line); }
    .tiptap-surface { padding: .65rem .75rem; }
    .family-grid {
      display: grid;
      gap: 1rem;
    }
    @media (min-width: 720px) {
      .family-grid { grid-template-columns: repeat(3, 1fr); }
    }
    .page-head {
      display: grid;
      gap: 1rem;
    }
    .page-head h2 {
      display: flex;
      flex-wrap: wrap;
      align-items: baseline;
      gap: .35rem .5rem;
    }
    @media (min-width: 720px) {
      .page-head.has-photo { grid-template-columns: 1fr 16rem; align-items: start; }
    }
    .page-head .facts { display: flex; flex-wrap: wrap; gap: .2rem 1rem; }
    .page-head .facts span { color: var(--ink); font-weight: 600; }
    .quiet-actions { margin: .35rem 0 .15rem; }
    .tip { cursor: help; }
    .tip-mark { font-weight: 700; opacity: .7; }
    .badge.tip { position: relative; }
    @media (min-width: 720px) {
      .family-grid { gap: .75rem; }
    }
    @media (max-width: 719px) {
      .rel-tile { min-width: 8.5rem; padding: .55rem .65rem .5rem; }
      .rel-tile-name { font-size: .95rem; }
      .page-head .lede { font-size: .88rem; }
      details.section > summary { font-size: 1rem; }
    }
    blockquote {
      margin: .35rem 0;
      padding-left: .7rem;
      border-left: 3px solid var(--line);
      color: var(--muted);
    }
    .sel-pop {
      position: absolute;
      z-index: 35;
      background: #2a241c;
      color: #fff;
      border-radius: 8px;
      padding: .25rem .5rem;
      font-size: .8rem;
    }
    .sel-pop button { background: none; color: #fff; border: none; font-weight: 600; cursor: pointer; }
    .sel-pop .cert { color: #ffe7b8; vertical-align: middle; min-width: 1rem; }
    .cite-pop {
      position: absolute;
      z-index: 36;
      width: min(22rem, calc(100vw - 2rem));
      background: var(--paper);
      color: var(--ink);
      border: 1px solid var(--line);
      border-radius: 10px;
      box-shadow: var(--shadow);
      padding: .75rem;
    }
    .cite-pop blockquote { max-height: 4.5rem; overflow: auto; }
    .cites blockquote { font-size: .95rem; }
    .change-diff {
      margin: .35rem 0;
      padding: .45rem .55rem;
      background: var(--accent-soft);
      border-radius: 8px;
      font-size: .92rem;
      white-space: pre-wrap;
    }
    .change-diff del {
      background: var(--danger-bg);
      color: var(--danger);
      text-decoration: line-through;
    }
    .change-diff ins {
      background: var(--ok-bg);
      color: var(--ok);
      text-decoration: none;
    }
    mark.span-cert, mark.span-cite, mark.span-discuss {
      padding: 0 .15rem;
      border-radius: 3px;
    }
    mark.span-cert { background: var(--accent-soft); }
    mark.span-cite { background: #e4eef8; box-shadow: inset 0 -2px 0 #6a8caf; }
    mark.span-discuss { background: #f7ecd4; box-shadow: inset 0 -2px 0 #b0893e; }
    mark.span-cert sup { font-size: .65em; margin-left: .15rem; color: var(--accent); }
    .ftree { display: flex; flex-direction: column; align-items: center; gap: 1.1rem; overflow-x: auto; padding: .4rem 0; }
    .ftree-gen { display: flex; flex-wrap: wrap; justify-content: center; gap: .75rem 1.1rem; }
    .ftree-branch { display: flex; flex-direction: column; align-items: center; gap: .55rem; }
    .tree-card {
      display: flex; flex-direction: column; align-items: center; gap: .15rem;
      min-width: 6.5rem; max-width: 8.5rem; text-align: center;
      padding: .45rem .4rem; border: 1px solid var(--line); border-radius: 10px;
      background: var(--paper); text-decoration: none; color: inherit;
    }
    .tree-card.focus { border-color: var(--accent); box-shadow: var(--shadow); }
    .ftree-focus-row .tree-card:not(.focus) { border-style: double; }
    .ftree-sibs .tree-card { opacity: .92; }
    .tree-card.kind-event { border-style: dashed; }
    .tree-card img, .tree-ph {
      width: 3.2rem; height: 3.2rem; border-radius: 8px; object-fit: cover;
      background: var(--accent-soft);
    }
    .tree-name { font-weight: 700; font-size: .88rem; }
    .tree-slug { font-size: .72rem; color: var(--muted); }
    .tree-wrap { overflow-x: auto; }
    .fc { position: relative; min-height: 8rem; }
    .fc-with-tools { display: flex; flex-direction: row; align-items: stretch; gap: .45rem; }
    .fc-tools {
      position: static;
      display: flex; flex-direction: column; gap: .35rem;
      padding-top: .35rem; flex: 0 0 auto;
    }
    .fc-with-tools .fc-viewport { flex: 1 1 auto; min-width: 0; }
    .fc-viewport {
      overflow: auto; width: 100%; min-height: 16rem; max-height: min(72vh, 40rem);
      touch-action: none; border-radius: 10px; background: transparent;
    }
    .fc-world { transform-origin: 0 0; position: relative; width: max-content; }
    .fc-stage { width: max-content; min-width: 100%; }

    .fc-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
    .fc-line { stroke: var(--accent); stroke-width: 1.6; fill: none; }
    .fc-line.couple { stroke-width: 2; }
    .fc-line.ended { stroke: var(--danger); }
    .fc-stage { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 1.85rem; padding: .6rem 0; }
    .fc-row { display: flex; flex-wrap: nowrap; justify-content: center; gap: .7rem 1rem; }
    .fc-unit { display: flex; flex-direction: column; align-items: center; gap: .45rem; padding: .2rem .4rem; }
    .tree-card.ended { border-style: dashed; }
    .fc-kids-layer { position: relative; width: 100%; min-height: 1px; }
    .fc-kidgroup {
      position: static;
      display: flex; flex-direction: row; flex-wrap: wrap;
      gap: .65rem 1rem; justify-content: center; max-width: 42rem;
    }
    .origin-tag {
      display: inline-block; margin-left: .35rem; padding: .05rem .45rem;
      border-radius: 999px; font-size: .72rem; font-weight: 700;
      background: var(--accent-soft); color: var(--accent); vertical-align: middle;
    }
    .origin-tag a { color: inherit; text-decoration: none; }
    .tree-card.deceased { opacity: .72; }
    .tree-card.deceased .tree-name::after { content: " †"; }
    .table-wrap { overflow-x: auto; }
    .plain-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
    .plain-table th, .plain-table td { text-align: left; vertical-align: top; padding: .45rem .6rem; border-bottom: 1px solid var(--line); }
    .plain-table th { font-weight: 700; }
