:root {
      --bg: #f6f1e8;
      --paper: #fffdf8;
      --ink: #2a241c;
      --muted: #4a433a;
      --line: #e4d9c8;
      --accent: #6b4f2e;
      --accent-soft: #efe4d2;
      --ok: #2f6b45;
      --ok-bg: #e8f4ec;
      --warn: #8a4b12;
      --warn-bg: #f8ead8;
      --danger: #b42318;
      --danger-bg: #fde8e6;
      --shadow: 0 1px 2px rgba(60, 40, 16, .05), 0 8px 24px rgba(60, 40, 16, .06);
      --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
      --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
      --field-bg: #fffdf8;
      --field-ink: #2a241c;
      --placeholder: #8a8074;
      --btn: #6b4f2e;
      --btn-ink: #fff8ec;
      --glow: #fff8ec;
    }
    * { 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; }
    header nav { display: flex; gap: .9rem; align-items: center; flex-wrap: wrap; font-size: .92rem; }
    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"] {
      --bg: #1c1915;
      --paper: #2a241c;
      --ink: #f3ece2;
      --muted: #c4b8a8;
      --line: #3f372d;
      --accent: #d4b48a;
      --accent-soft: #3a3228;
      --ok-bg: #1e3326;
      --warn-bg: #3a2c18;
      --danger-bg: #3a1c18;
      --shadow: none;
      --field-bg: #1c1915;
      --field-ink: #f3ece2;
      --placeholder: #8d8274;
      --btn: #c4a574;
      --btn-ink: #1c1915;
      --glow: #2a241c;
    }
    @media (prefers-color-scheme: dark) {
      html:not([data-theme="light"]) {
        --bg: #1c1915;
        --paper: #2a241c;
        --ink: #f3ece2;
        --muted: #c4b8a8;
        --line: #3f372d;
        --accent: #d4b48a;
        --accent-soft: #3a3228;
        --ok-bg: #1e3326;
        --warn-bg: #3a2c18;
        --danger-bg: #3a1c18;
        --shadow: none;
        --field-bg: #1c1915;
        --field-ink: #f3ece2;
        --placeholder: #8d8274;
        --btn: #c4a574;
        --btn-ink: #1c1915;
        --glow: #2a241c;
      }
    }
    @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;
    }
    .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; }
    .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: super;
      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; }
    .pick-list li {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: .75rem;
      padding: .45rem 0;
      border-bottom: 1px solid var(--line);
    }
    .pick-list li:last-child { border-bottom: 0; }
    .pick-list .who { font-weight: 600; color: var(--ink); text-decoration: none; }
    .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; }
    .family-grid {
      display: grid;
      gap: 1rem;
    }
    @media (min-width: 720px) {
      .family-grid { grid-template-columns: repeat(3, 1fr); }
    }
    .page-head {
      display: grid;
      gap: 1rem;
    }
    @media (min-width: 720px) {
      .page-head.has-photo { grid-template-columns: 18rem 1fr; align-items: start; }
    }
    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; }
