/* Rodokmen map. Mobile first; the desktop layout starts at 768 px. */

:root {
  --paper: #f7f4ed;
  --card: #fffdf8;
  --ink: #1d2a22;
  --ink-2: #4c574f;
  --ink-3: #6c756e;
  --line: #ddd6c8;
  --accent: #24392d;
  --accent-ink: #fffdf8;
  --focus: #b5541c;
  --note: #fbf0d9;
  --note-line: #e3c27c;
  --shadow: 0 1px 2px rgb(29 42 34 / 0.12), 0 6px 20px rgb(29 42 34 / 0.14);
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.4 var(--sans);
  -webkit-text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

h2,
h3 {
  margin: 0;
  font-weight: 600;
}
a {
  color: var(--accent);
}
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#map {
  position: fixed;
  inset: 0;
  background: #ece7dc;
}

.leaflet-container {
  font: 12px/1.4 var(--sans);
}
.leaflet-control-attribution {
  font-size: 11px;
}

/* Top bar: search and two round buttons */
.topbar {
  position: fixed;
  top: calc(8px + var(--safe-top));
  left: 8px;
  right: 8px;
  z-index: 1000;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  pointer-events: none;
}
.topbar > * {
  pointer-events: auto;
}

.search {
  position: relative;
  flex: 1;
  min-width: 0;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 13px;
  width: 20px;
  height: 20px;
  color: var(--ink-3);
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 46px;
  padding: 0 44px 0 44px;
  border: 1px solid var(--line);
  border-radius: 23px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  box-shadow: var(--shadow);
  -webkit-appearance: none;
  appearance: none;
}
.search input::-webkit-search-cancel-button {
  display: none;
}
.search input:focus {
  outline: none;
  border-color: var(--accent);
}
.search .clear {
  position: absolute;
  right: 4px;
  top: 3px;
}

.results {
  position: absolute;
  top: 52px;
  left: 0;
  right: 0;
  max-height: min(60dvh, 420px);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overscroll-behavior: contain;
}
.results ul {
  list-style: none;
  margin: 0;
  padding: 4px 0;
}
.results li {
  display: flex;
  flex-direction: column;
  padding: 9px 16px;
  cursor: pointer;
  min-height: 44px;
  justify-content: center;
}
.results li[aria-selected='true'],
.results li:hover {
  background: #efe9dc;
}
.results .name {
  font-weight: 600;
}
.results .district {
  color: var(--ink-2);
  font-size: 14px;
}
.results-note {
  margin: 0;
  padding: 8px 16px 12px;
  color: var(--ink-2);
  font-size: 14px;
}
.results-note:empty {
  display: none;
}

.round-button,
.icon-button {
  display: inline-grid;
  place-items: center;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--ink);
}
.round-button {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.round-button[aria-expanded='true'] {
  background: var(--accent);
  color: var(--accent-ink);
}
.round-button svg {
  width: 22px;
  height: 22px;
}
.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
}
.icon-button:hover {
  background: #efe9dc;
}
.icon-button svg {
  width: 20px;
  height: 20px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--accent);
  border-radius: 22px;
  background: var(--card);
  color: var(--accent);
  font: 600 15px/1 var(--sans);
  text-decoration: none;
  cursor: pointer;
}
.button.primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.button svg {
  width: 16px;
  height: 16px;
}

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

/* Layers panel */
.panel {
  position: fixed;
  z-index: 1001;
  top: calc(62px + var(--safe-top));
  right: 8px;
  width: min(340px, calc(100vw - 16px));
  max-height: calc(100dvh - 80px - var(--safe-top));
  overflow-y: auto;
  padding: 12px 16px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.panel-head h2 {
  font: 600 20px/1.2 var(--serif);
}
.panel h3,
.dialog-body h3 {
  margin: 16px 0 6px;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.panel p {
  margin: 4px 0 8px;
  font-size: 14px;
}
.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
}
.switch-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}
.overlay-item {
  padding: 2px 0 8px;
}
.overlay-item input[type='range'] {
  width: 100%;
  accent-color: var(--accent);
}

/* Legend (a Leaflet control) */
.legend {
  max-width: min(260px, calc(100vw - 90px));
  padding: 8px 10px;
  background: rgb(255 253 248 / 0.95);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  color: var(--ink);
  font: 12px/1.3 var(--sans);
}
.legend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  font: 600 12px/1.3 var(--sans);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.legend-head svg {
  width: 14px;
  height: 14px;
  flex: none;
  transition: transform 0.15s;
}
.legend[data-collapsed='true'] .legend-head svg {
  transform: rotate(-90deg);
}
.legend[data-collapsed='true'] ul {
  display: none;
}
.legend ul {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  gap: 3px;
}
.legend li {
  display: flex;
  align-items: center;
  gap: 7px;
}
.swatch {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgb(0 0 0 / 0.25);
}

/* Place sheet: bottom sheet on phones, side card on desktop */
.sheet {
  position: fixed;
  z-index: 1002;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 46dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 18px calc(18px + var(--safe-bottom));
  background: var(--card);
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -6px 24px rgb(29 42 34 / 0.18);
  animation: sheet-up 0.2s ease-out;
}
.sheet::before {
  content: '';
  display: block;
  width: 40px;
  height: 4px;
  margin: 0 auto 8px;
  border-radius: 2px;
  background: var(--line);
}
.sheet:focus {
  outline: none;
}
@keyframes sheet-up {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .sheet {
    animation: none;
  }
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.sheet .eyebrow {
  margin: 0 0 2px;
  font-size: 13px;
  color: var(--ink-2);
}
.sheet h2 {
  font: 600 24px/1.15 var(--serif);
  overflow-wrap: anywhere;
}
.sheet .meta {
  margin: 4px 0 0;
  color: var(--ink-2);
  font-size: 14px;
}
.sheet section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.sheet h3 {
  margin-bottom: 6px;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.sheet .archive-name {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font: 600 19px/1.25 var(--serif);
}
.sheet .archive-name .swatch {
  width: 12px;
  height: 12px;
}
.sheet .viewer-note {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--ink-2);
}
.sheet .also-check {
  margin: 12px 0 0;
  padding: 10px 12px;
  background: var(--note);
  border: 1px solid var(--note-line);
  border-radius: 10px;
  font-size: 14px;
}
.sheet .also-check p {
  margin: 0;
}
.sheet .also-check p + p {
  margin-top: 4px;
  color: var(--ink-2);
  font-size: 13px;
}
.sheet .outside {
  margin: 12px 0 0;
}
.sheet p.secondary {
  margin: 0;
  font-size: 14px;
}
.link-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.link-list li + li {
  border-top: 1px solid #eee8db;
}
.link-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 8px 0;
  font-size: 15px;
  text-decoration: none;
}
.link-list a:hover span {
  text-decoration: underline;
}
/* External-link icon: every link that leaves the app carries one. */
.sheet a:not(.button) svg {
  width: 14px;
  height: 14px;
  flex: none;
  margin-left: 3px;
  vertical-align: -2px;
  color: var(--ink-3);
}

/* Settings dialog */
dialog {
  width: min(440px, calc(100vw - 16px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
}
dialog::backdrop {
  background: rgb(29 42 34 / 0.35);
}
.dialog-body {
  padding: 14px 18px 18px;
}
.dialog-body p {
  margin: 6px 0;
  font-size: 14px;
}
fieldset.language {
  margin: 10px 0 0;
  padding: 0;
  border: 0;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}
fieldset.language legend {
  padding: 0;
  margin-bottom: 6px;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}
fieldset.language label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  cursor: pointer;
}
fieldset.language input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
.check-results {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  font-size: 14px;
}
.check-results li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px solid #eee8db;
}
.status {
  font-weight: 600;
  white-space: nowrap;
}
.status.ok {
  color: #1f6b33;
}
.status.ok::before {
  content: '✓ ';
}
.status.bad {
  color: #a3271f;
}
.status.bad::before {
  content: '✕ ';
}
.status.off {
  color: var(--ink-3);
}

/* Update prompt and messages */
.toast {
  position: fixed;
  z-index: 1100;
  left: 50%;
  bottom: calc(16px + var(--safe-bottom));
  transform: translateX(-50%);
  box-shadow: var(--shadow);
  border-radius: 22px;
}
.message {
  position: fixed;
  z-index: 1100;
  left: 8px;
  right: 8px;
  top: calc(64px + var(--safe-top));
  margin: 0;
  padding: 12px 14px;
  background: #fbe3df;
  border: 1px solid #e2a59c;
  border-radius: 10px;
  color: #6b1a12;
}

@media (min-width: 768px) {
  .topbar {
    left: 12px;
    right: 12px;
    top: 12px;
  }
  .search {
    flex: 0 1 380px;
  }
  .topbar .round-button:first-of-type {
    margin-left: auto;
  }
  .panel {
    right: 12px;
    top: 66px;
  }
  .sheet {
    left: 12px;
    right: auto;
    top: 70px;
    bottom: auto;
    width: 380px;
    max-height: calc(100dvh - 94px);
    padding: 12px 20px 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
  .sheet::before {
    display: none;
  }
  .message {
    left: 12px;
    right: auto;
    width: 380px;
  }
}

/* Working on the Tree: Propose, Drafts, my Proposals, review and history (add-proposals-and-review).
   A full-screen panel over the map, phone first. */
.round-button {
  position: relative;
}
.count-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--focus);
  color: #fff;
  font: 600 12px/20px var(--sans);
}
.drafts-toast {
  bottom: calc(72px + var(--safe-bottom));
}

.work {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  background: var(--paper);
}
.work-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(8px + var(--safe-top)) 12px 4px 16px;
}
.work-head h1 {
  margin: 0;
  font: 600 22px/1.2 var(--serif);
}
.work-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 0 12px 8px;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.tab {
  flex: none;
  padding: 10px 12px;
  border-radius: 18px;
  color: var(--ink-2);
  font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
}
.tab[aria-current='page'] {
  background: var(--accent);
  color: var(--accent-ink);
}
.work-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px calc(24px + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
}
.work-body > * {
  max-width: 680px;
  margin-left: auto;
  margin-right: auto;
}
.work-body h2 {
  margin: 4px auto 6px;
  font: 600 20px/1.25 var(--serif);
}
.work-body h3 {
  margin: 0 0 6px;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.small {
  font-size: 13px;
}
.empty {
  padding: 24px 0;
  color: var(--ink-2);
  text-align: center;
}
.warning {
  color: #8a4b0f;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.card {
  margin-bottom: 12px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-bottom: 6px;
}
.card-head .author {
  font-weight: 600;
}
.card-head a {
  font-weight: 600;
  text-decoration: none;
}
.chip {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 11px;
  background: #ece6d8;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 20px;
}
.status-pending {
  background: #fbf0d9;
  color: #7a5410;
}
.status-accepted {
  background: #dcefe0;
  color: #1f6b33;
}
.status-rejected {
  background: #f6dedb;
  color: #8f2a20;
}
.badge.agent {
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 9px;
  background: #e3e8f6;
  color: #2f4479;
  font-size: 11px;
  font-weight: 600;
  vertical-align: 1px;
}
.proposal-note {
  margin: 4px 0 8px;
  font-style: italic;
}
.changes {
  margin: 6px 0 8px;
  padding-left: 20px;
  font-size: 15px;
}
.changes li {
  margin: 3px 0;
}
.changes li.conflict {
  color: #8a4b0f;
}
.compare {
  padding-left: 2px;
}
.citation {
  margin: 8px 0;
  padding: 8px 10px;
  background: #f3efe5;
  border-radius: 10px;
  font-size: 14px;
}
.citation p {
  margin: 0;
}
.citation blockquote {
  margin: 6px 0 0;
  font-family: var(--serif);
  white-space: pre-wrap;
}
.decision-note {
  margin: 8px 0 0;
  padding: 8px 10px;
  background: var(--note);
  border: 1px solid var(--note-line);
  border-radius: 10px;
  font-size: 14px;
}
.conflict-box {
  margin: 6px 0;
  padding: 8px 10px;
  background: var(--note);
  border: 1px solid var(--note-line);
  border-radius: 10px;
  color: var(--ink);
}
.conflict-box p {
  margin: 0 0 4px;
}
.choice + .choice {
  margin-top: 6px;
}
.radio-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  cursor: pointer;
}
.radio-row input {
  width: 20px;
  height: 20px;
  flex: none;
  accent-color: var(--accent);
}

.form-section {
  margin: 12px auto;
}
.field {
  display: block;
  margin: 8px 0;
}
.field > span {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  color: var(--ink-2);
}
.field input,
.field select,
.field textarea,
.picker-search input,
.label-add-row input,
.work-body > textarea,
.card textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: 16px/1.35 var(--sans);
}
.field textarea,
.card textarea {
  resize: vertical;
}
.field input:focus,
.field select:focus,
.field textarea:focus,
.picker-search input:focus {
  outline: none;
  border-color: var(--accent);
}
.picker {
  margin: 10px 0;
  padding: 8px 12px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
.picker legend {
  padding: 0 4px;
  font-size: 14px;
  font-weight: 600;
}
.picked {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
}
.picker-results {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}
.picker-item {
  width: 100%;
  min-height: 44px;
  padding: 8px 4px;
  border: 0;
  border-bottom: 1px solid #eee8db;
  background: none;
  color: var(--ink);
  font: 15px/1.3 var(--sans);
  text-align: left;
  cursor: pointer;
}
.picker-results p:empty,
.picker-search p:empty {
  display: none;
}
.picker-search p {
  margin: 4px 0 0;
}
.link-button {
  min-height: 40px;
  padding: 0 6px;
  border: 0;
  background: none;
  color: var(--accent);
  font: 15px/1 var(--sans);
  text-decoration: underline;
  cursor: pointer;
}
.new-person {
  display: grid;
  gap: 0 10px;
  grid-template-columns: 1fr 1fr;
}
.new-person .field:nth-child(3),
.new-person .link-button {
  grid-column: 1 / -1;
  justify-self: start;
}
.person-list .button {
  margin: 4px 0 8px;
}
.kind-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
  margin-top: 12px;
}
.kind-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 84px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
}
.kind-card strong {
  font: 600 17px/1.2 var(--serif);
}
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}
.segmented label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  font-size: 14px;
  cursor: pointer;
}
.segmented input {
  accent-color: var(--accent);
}
.photo-row {
  margin: 10px 0 6px;
}
.photos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.thumb {
  position: relative;
  display: block;
  margin: 0;
  width: 96px;
  height: 96px;
  border-radius: 8px;
  overflow: hidden;
  background: #e7e1d3;
}
.thumb img,
img.thumb {
  width: 96px;
  height: 96px;
  object-fit: cover;
  display: block;
}
.thumb .icon-button.small {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 28px;
  height: 28px;
  background: rgb(255 255 255 / 0.85);
  font-size: 18px;
  line-height: 1;
}
.form-status {
  min-height: 1.2em;
  margin: 6px 0;
  font-size: 14px;
  color: var(--ink-2);
}
.form-status.error {
  color: #a3271f;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.merge-tool summary {
  min-height: 40px;
  font-weight: 600;
  cursor: pointer;
  line-height: 40px;
}
.undo-box:not(:empty) {
  margin-top: 8px;
}
/* The later Proposals to undo first, newest first, each with its own Undo. */
.undo-blockers {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}
.undo-blocker {
  margin: 8px 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

/* The family screens (add-family-view): the tree as the signed-in home, People, person pages,
   Settings and signing in, over the map; tabs at the bottom for a signed-in Member. */
:root {
  --tabbar-h: 58px;
  --living: #2f6b45;
  --possible: #8a6d1f;
}
body.signed-in #map {
  bottom: calc(var(--tabbar-h) + var(--safe-bottom));
}
body.signed-in .sheet,
body.signed-in .toast,
body.signed-in .year-filter,
body.signed-in .life-chip {
  margin-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
}
body.signed-in .work {
  bottom: calc(var(--tabbar-h) + var(--safe-bottom));
}
body:not([data-screen='map']) .topbar,
body:not([data-screen='map']) .panel,
body:not([data-screen='map']) .year-filter,
body:not([data-screen='map']) .life-chip,
body:not([data-screen='map']) .sheet {
  visibility: hidden;
}
body[data-screen='map'] .screen,
body[data-screen='work'] .screen {
  display: none;
}
.toast,
.drafts-toast {
  z-index: 1400;
}

.screen {
  position: fixed;
  inset: 0 0 0 0;
  z-index: 1150;
  overflow-y: auto;
  background: var(--paper);
  padding-top: var(--safe-top);
  -webkit-overflow-scrolling: touch;
}
body.signed-in .screen {
  bottom: calc(var(--tabbar-h) + var(--safe-bottom));
}
.screen h1 {
  margin: 0 0 8px;
  font: 600 24px/1.2 var(--serif);
}
.screen h2 {
  margin: 18px 0 6px;
  font: 600 18px/1.25 var(--serif);
}
.screen-body {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 14px 28px;
}
.offline-note,
.as-of {
  margin: 8px 14px 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--note);
  border: 1px solid var(--note-line);
  font-size: 13px;
}
.screen-body .as-of {
  margin: 8px 0;
}

/* Tabs */
.tabbar {
  position: fixed;
  z-index: 1300;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
}
.tabbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  color: var(--ink-2);
  font-size: 12px;
  text-decoration: none;
}
.tabbar-item svg {
  width: 22px;
  height: 22px;
}
.tabbar-item[aria-current='page'] {
  color: var(--accent);
  font-weight: 600;
}
.tabbar-item[aria-current='page'] svg {
  stroke-width: 2.5;
}

/* The tree */
.tree-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.screen-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.tree-head .icon-link {
  margin-left: auto;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--ink);
}
.tree-head .icon-link svg {
  width: 22px;
  height: 22px;
}
.button.small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
}
.stepper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 13px;
  color: var(--ink-2);
}
.stepper output {
  min-width: 16px;
  text-align: center;
  font-weight: 600;
  color: var(--ink);
}
.icon-button.small {
  width: 32px;
  height: 32px;
  font: 600 18px/1 var(--sans);
  background: #efe9dc;
}
.icon-button:disabled {
  opacity: 0.4;
  cursor: default;
}
.tree-area {
  position: relative;
  flex: 1;
  min-height: 0;
}
.tree-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
.tree-canvas.ready .tree-view,
.tree-canvas.ready .tree-node {
  transition: transform 0.35s ease;
}
.tree-lines {
  animation: fade-in 0.3s 0.2s both;
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
.tree-node {
  cursor: pointer;
  animation: fade-in 0.25s both;
}
.tree-node .box {
  fill: var(--card);
  stroke: var(--line);
  stroke-width: 1.5;
}
.tree-node.male .box {
  fill: #f3f6f8;
}
.tree-node.female .box {
  fill: #faf3f1;
}
.tree-node.is-focus .box {
  stroke: var(--accent);
  stroke-width: 3;
}
.tree-node.living .box {
  stroke: var(--living);
  stroke-dasharray: none;
}
.tree-node.living .years {
  fill: var(--living);
}
.tree-node.possible .box {
  stroke: var(--possible);
  stroke-dasharray: 5 3;
}
.tree-node:focus-visible {
  outline: none;
}
.tree-node:focus-visible .box {
  stroke: var(--focus);
  stroke-width: 3;
}
.tree-node text {
  fill: var(--ink);
  stroke: none;
  font: 12px/1 var(--sans);
}
.tree-node .given {
  font-weight: 600;
}
.tree-node .years {
  font-size: 11px;
  fill: var(--ink-2);
}
.tree-node .more {
  stroke: var(--ink-3);
  stroke-width: 2;
}
.tree-lines .line {
  stroke: var(--ink-3);
  stroke-width: 1.5;
}
.tree-lines .line.dashed {
  stroke-dasharray: 5 4;
}
/* A weak link: no Citation of normal or higher confidence supports it. */
.tree-lines .line.weak {
  stroke: var(--possible);
  stroke-width: 2;
  stroke-dasharray: 1.5 3.5;
  stroke-linecap: round;
}
.tree-node .possible-mark circle {
  fill: var(--possible);
  stroke: var(--card);
  stroke-width: 1.5;
}
.tree-node .possible-mark text {
  fill: #fff;
  font-weight: 700;
  font-size: 12px;
}
.zoom-buttons {
  position: absolute;
  right: 10px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.zoom-buttons .round-button {
  width: 38px;
  height: 38px;
  font: 600 18px/1 var(--sans);
  opacity: 0.92;
}
.other-parents {
  position: absolute;
  left: 10px;
  bottom: 12px;
  max-width: calc(100% - 80px);
  margin: 0;
  padding: 6px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
}
.unrelated-switch {
  position: absolute;
  left: 10px;
  top: 8px;
}
@media (prefers-reduced-motion: reduce) {
  .tree-canvas.ready .tree-view,
  .tree-canvas.ready .tree-node {
    transition: none;
  }
  .tree-lines,
  .tree-node {
    animation: none;
  }
}

/* People */
.people-box {
  margin: 4px 0 10px;
}
.people-box input {
  padding-right: 16px;
}
.person-results {
  list-style: none;
  margin: 0;
  padding: 0;
}
.person-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line);
}
.person-result .matched {
  display: block;
}
.person-name {
  font-weight: 600;
}
.years {
  color: var(--ink-2);
  font-size: 14px;
  white-space: nowrap;
}
.mark {
  display: inline-block;
  margin-left: 4px;
  padding: 0 7px;
  border-radius: 9px;
  background: #e3efe6;
  color: var(--living);
  font-size: 12px;
  line-height: 18px;
}

/* Person page */
.person-head {
  display: flex;
  gap: 12px;
  align-items: center;
}
.portrait {
  width: 72px;
  height: 90px;
  object-fit: cover;
  border-radius: 10px;
}
.person-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 4px;
}
.person-actions .form-status {
  flex-basis: 100%;
  margin: 0;
}
.card .prompt {
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--note);
  border: 1px solid var(--note-line);
  font-size: 14px;
}
.names,
.families,
.events,
.plain-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.names > li,
.families > li,
.plain-list > li {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.children {
  margin: 6px 0 0;
  padding-left: 18px;
}
.citations {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
}
.citation-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  text-align: left;
}
.chip.confidence.low,
.chip.confidence.very_low {
  background: #fbe9d0;
}
.chip.confidence.high,
.chip.confidence.very_high {
  background: #e3efe6;
}
.citation-detail {
  padding: 6px 0 4px 10px;
  border-left: 3px solid var(--line);
}
.citation-detail blockquote {
  margin: 0 0 6px;
  font-family: var(--serif);
}

/* Settings and signing in */
.settings-screen .card h2 {
  margin-top: 0;
}
.member-head,
.member-controls,
.member-person {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.member-controls select {
  margin-left: 6px;
  min-height: 36px;
}
.invite-form {
  display: grid;
  gap: 8px;
}
/* The Owner's Agents: each with its tokens; a new token shown once; revoking asked in the page */
.agent h4,
.token-once h4 {
  margin: 10px 0 2px;
  font-size: 14px;
}
.agent-usage > span {
  display: block;
}
.agent-tokens > li {
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
}
.agent-tokens > li:last-child {
  border-bottom: 0;
}
.agent-tokens > li.revoked .token-head {
  color: var(--ink-2);
}
.token-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-size: 14px;
}
.token-prefix,
.token-value {
  font:
    14px/1.4 ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    'Liberation Mono',
    monospace;
}
.agent-tokens p {
  margin: 2px 0;
}
.token-once,
.confirm {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--note);
  border: 1px solid var(--note-line);
}
.token-once h4 {
  margin-top: 0;
}
.token-value {
  display: block;
  margin: 8px 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow-wrap: anywhere;
  user-select: all;
}
.token-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.confirm {
  background: #fbefed;
  border-color: #e2b3ad;
}
.confirm p {
  margin: 0 0 8px;
}
.button.danger {
  background: #8f2a20;
  border-color: #8f2a20;
  color: #fff;
}
.agent-form {
  display: grid;
  gap: 4px;
}
.agent-form .button {
  justify-self: start;
}
.sign-in-form {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}
.sign-in-choices > .button {
  width: 100%;
  margin: 8px 0;
}
.status-pending {
  background: #fbf0d9;
}

/* The family on the map */
.family-pin,
.family-cluster {
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font: 600 13px/1 var(--sans);
  box-shadow: 0 1px 4px rgb(29 42 34 / 0.35);
}
.family-pin {
  background: var(--accent);
  border: 2px solid var(--card);
}
.family-cluster {
  background: rgb(36 57 45 / 0.85);
  border: 3px solid rgb(255 253 248 / 0.9);
  font-size: 14px;
}
.year-filter {
  position: fixed;
  z-index: 900;
  left: 8px;
  bottom: calc(10px + var(--safe-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(330px, calc(100vw - 70px));
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.year-sliders {
  flex: 1;
  display: grid;
  gap: 2px;
}
.year-sliders input {
  width: 100%;
}
.year-sliders .map-unrelated {
  min-height: 32px;
  font-size: 13px;
}
.year-sliders .map-unrelated input {
  width: 18px;
}
.mark.possible {
  background: #f3ead2;
  color: var(--possible);
}
.year-sliders output {
  font-weight: 600;
  font-size: 14px;
}
.year-filter .play {
  width: 40px;
  height: 40px;
  font-size: 14px;
}
.life-chip {
  position: fixed;
  z-index: 900;
  left: 50%;
  top: calc(64px + var(--safe-top));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  font-size: 14px;
}
.life-label {
  font: 600 12px/1.2 var(--sans);
}
.family-here {
  margin-top: 10px;
}
.here-persons li {
  padding: 4px 0;
}

/* Research leads (research-leads spec): the Leads list, a lead's page, and the leads of a Place on its sheet. */
.lead-list,
.search-records,
.lead-history {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}
.lead-history li {
  padding: 3px 0;
  color: var(--ink-2);
}
.lead-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0 12px;
  margin-bottom: 12px;
}
.lead-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
}
.field-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 10px;
}
.search-record {
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.search-record p {
  margin: 2px 0;
}
.chip.lead-status.open {
  background: #fbf0d9;
  color: #7a5410;
}
.chip.lead-status.in_progress {
  background: #dde9f6;
  color: #1d4f86;
}
.chip.lead-status.found {
  background: #dcefe0;
  color: #1f6b33;
}
.chip.lead-status.not_found {
  background: #ece6d8;
  color: var(--ink-2);
}
.place-leads {
  margin-top: 10px;
}
.place-leads li {
  padding: 4px 0;
}
.person-leads {
  margin-top: 18px;
}

/* Labels and research notes (tree-model spec, "Labels on Persons", "Research notes on records"). */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  list-style: none;
  margin: 0.5rem 0;
  padding: 0;
}

.chips .chip .icon-button {
  margin-left: 0.25rem;
}

.research-notes {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--note);
  border: 1px solid var(--note-line);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
}

.label-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.documents {
  list-style: none;
  margin: 6px 0;
  padding: 0;
}
.documents li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

/* ---------------------------------------------------------------- scan reading */

.chip.ai {
  margin-left: 4px;
  background: #e5e9f7;
  color: #2c3d7a;
  font-size: 11px;
  line-height: 18px;
  vertical-align: middle;
}
.chip.ai[hidden] {
  display: none;
}
.kind-card.read {
  grid-column: 1 / -1;
  border-color: #b9c3e6;
  background: #f5f7fd;
}
.note {
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--note);
  border: 1px solid var(--note-line);
}
.scans {
  display: grid;
  gap: 12px;
}
.scan {
  margin: 0;
}
.crop-frame {
  position: relative;
  display: inline-block;
  max-width: 100%;
  touch-action: none;
  user-select: none;
  cursor: crosshair;
}
.crop-frame img {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  border-radius: 8px;
}
.crop-box {
  position: absolute;
  border: 2px solid var(--focus);
  background: rgb(181 84 28 / 0.12);
  pointer-events: none;
}
.crop-box[hidden] {
  display: none;
}
.year-row,
.name-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: end;
}
.work-body > .reading-check {
  max-width: 1200px;
}
.reading-layout {
  display: grid;
  gap: 14px;
}
.scan-pane {
  display: grid;
  gap: 10px;
}
.scan-page {
  margin: 0;
}
.scan-page img {
  display: block;
  width: 100%;
  max-height: 45vh;
  object-fit: contain;
  border-radius: 8px;
  background: #e7e1d3;
}
.transcription {
  margin: 6px 0;
  padding: 6px 10px;
  border-left: 3px solid var(--line);
  font-family: var(--serif);
  font-size: 15px;
  white-space: pre-wrap;
}
pre.transcription {
  overflow-x: auto;
}
.card.entry.confirmed {
  border-color: #9ccaa8;
}
.card.entry.skipped {
  opacity: 0.6;
}
.read-person {
  margin: 10px 0;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.read-person-head {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: baseline;
}
.matches {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}
.match {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.match.chosen {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: #eef3ef;
}
.lead {
  margin: 8px 0;
  padding: 8px 10px;
  border: 1px dashed var(--line);
  border-radius: 10px;
}
.lead p {
  margin: 2px 0;
}
@media (min-width: 900px) {
  .reading-layout {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    align-items: start;
  }
  .scan-pane {
    position: sticky;
    top: 0;
  }
  .scan-page img {
    max-height: 80vh;
  }
}
