/* NotesPro ```ahnentafel``` block — family tree. Default theme "poster": red board, handwriting. */

.ahnentafel-block {
  --at-bg: #ec4b3c;
  --at-bg-2: #e2402f;
  --at-ink: #3a120c;
  --at-ink-soft: #5c2117;
  --at-line: #3a120c;
  --at-card-bg: transparent;
  --at-card-border: transparent;
  --at-card-hover: rgba(255, 255, 255, 0.18);
  --at-photo-frame: #f7f1e6;
  --at-font: 'Segoe Print', 'Bradley Hand', 'Comic Sans MS', 'Chalkboard SE', 'Patrick Hand', cursive;
  --at-gap: 22px;
  position: relative;
  margin: 1rem 0;
  color: var(--at-ink);
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.12), transparent 45%),
    linear-gradient(160deg, var(--at-bg), var(--at-bg-2));
  border-radius: 6px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.25);
  font-family: var(--at-font);
  overflow: hidden;
}

.ahnentafel-block--classic {
  --at-bg: #f6efe0;
  --at-bg-2: #ede2c8;
  --at-ink: #2f2418;
  --at-ink-soft: #6a5536;
  --at-line: #8a6d45;
  --at-card-bg: #fffaf0;
  --at-card-border: #c9b38a;
  --at-card-hover: #fff3d9;
  --at-photo-frame: #fff;
  --at-font: Georgia, 'Times New Roman', serif;
}

.ahnentafel-block--light {
  --at-bg: #ffffff;
  --at-bg-2: #f4f6fa;
  --at-ink: #1f2937;
  --at-ink-soft: #64748b;
  --at-line: #94a3b8;
  --at-card-bg: #fff;
  --at-card-border: #cbd5e1;
  --at-card-hover: #eef4ff;
  --at-photo-frame: #fff;
  --at-font: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.ahnentafel-block--dark {
  --at-bg: #1e2430;
  --at-bg-2: #161b24;
  --at-ink: #e5e7eb;
  --at-ink-soft: #9ca3af;
  --at-line: #64748b;
  --at-card-bg: #262d3b;
  --at-card-border: #3b4557;
  --at-card-hover: #2f3849;
  --at-photo-frame: #e5e7eb;
  --at-font: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.ahnentafel-block:fullscreen,
.ahnentafel-block.is-pseudo-fullscreen {
  display: flex;
  flex-direction: column;
  margin: 0;
  border-radius: 0;
}

.ahnentafel-block.is-pseudo-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1900;
}

.ahnentafel-block:fullscreen .at-viewport,
.ahnentafel-block.is-pseudo-fullscreen .at-viewport {
  flex: 1;
  max-height: none;
}

/* ---- toolbar */
.at-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 4px;
}

.at-title {
  flex: 1;
  font-size: 26px;
  line-height: 1.2;
  font-weight: 700;
}

.at-count {
  font-size: 13px;
  color: var(--at-ink-soft);
}

.at-tools {
  display: flex;
  gap: 4px;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.at-tool {
  min-width: 30px;
  height: 28px;
  padding: 0 8px;
  font-size: 14px;
  color: var(--at-ink);
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 5px;
  cursor: pointer;
}

.ahnentafel-block--dark .at-tool { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.15); }
.at-tool:hover { background: rgba(255, 255, 255, 0.6); }
.ahnentafel-block--dark .at-tool:hover { background: rgba(255, 255, 255, 0.16); }
.at-tool--zoom { min-width: 54px; font-variant-numeric: tabular-nums; }
.at-tool--add { font-weight: 700; }

/* ---- viewport */
.at-viewport {
  overflow: auto;
  max-height: 80vh;
  padding: 8px 14px 18px;
  cursor: grab;
  outline: none;
  /* Two-finger pinch zooms the tree, not the page. */
  touch-action: pan-x pan-y;
  overscroll-behavior: contain;
}

.at-viewport:focus-visible { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6); }
.at-viewport.is-panning { cursor: grabbing; user-select: none; }
.at-viewport.is-panning * { cursor: grabbing !important; }
.at-viewport img { -webkit-user-drag: none; user-select: none; }

.at-canvas {
  display: inline-block;
  min-width: 100%;
}

.at-empty {
  margin: 12px 4px;
  font-size: 15px;
  color: var(--at-ink-soft);
}

/* ---- tree layout (nested lists, connector lines) */
.at-tree ul {
  position: relative;
  display: flex;
  justify-content: center;
  margin: 0;
  padding: var(--at-gap) 0 0;
}

.at-tree li {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--at-gap) 6px 0;
  list-style: none;
}

.at-tree li::before,
.at-tree li::after {
  content: '';
  position: absolute;
  top: 0;
  right: 50%;
  width: 50%;
  height: var(--at-gap);
  border-top: 2px solid var(--at-line);
}

.at-tree li::after {
  right: auto;
  left: 50%;
  border-left: 2px solid var(--at-line);
}

.at-tree li:only-child::before,
.at-tree li:only-child::after { display: none; }
.at-tree li:only-child { padding-top: 0; }
.at-tree li:first-child::before,
.at-tree li:last-child::after { border: 0 none; }
.at-tree li:last-child::before { border-right: 2px solid var(--at-line); border-radius: 0 6px 0 0; }
.at-tree li:first-child::after { border-radius: 6px 0 0 0; }

.at-tree ul ul::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 0;
  height: var(--at-gap);
  border-left: 2px solid var(--at-line);
}

.at-tree > ul.at-roots {
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 48px;
  padding-top: 0;
}

.at-tree > ul.at-roots > li { padding-top: 0; }
.at-tree > ul.at-roots > li::before,
.at-tree > ul.at-roots > li::after { display: none; }

/* ---- family (couple + photos) */
.at-family {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.at-couple {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.at-marriage {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  color: var(--at-ink);
}

.at-person {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 48px;
  padding: 3px 6px;
  font: inherit;
  color: inherit;
  text-align: center;
  background: var(--at-card-bg);
  border: 1px solid var(--at-card-border);
  border-radius: 6px;
}

button.at-person { cursor: pointer; }
button.at-person:hover,
button.at-person:focus-visible {
  background: var(--at-card-hover);
  outline: none;
}

.at-person-photo {
  width: 64px;
  height: 78px;
  object-fit: cover;
  background: var(--at-photo-frame);
  border: 4px solid var(--at-photo-frame);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.at-person-name {
  font-size: 17px;
  line-height: 1.15;
  border-bottom: 1.5px solid currentColor;
}

.ahnentafel-block--light .at-person-name,
.ahnentafel-block--dark .at-person-name,
.ahnentafel-block--classic .at-person-name { border-bottom: 0; font-weight: 600; font-size: 15px; }

.at-person-dates {
  font-size: 12px;
  color: var(--at-ink-soft);
}

.at-tree li li .at-person-name { font-size: 15px; }
.at-tree li li li .at-person-name { font-size: 14px; }
.at-tree li li li li .at-person-name { font-size: 13px; }

/* ---- branch colours ({col=…} on a line): names and lines of the whole branch */
.at-tree li.has-color {
  --at-line: var(--at-branch);
  color: var(--at-branch);
}

.at-tree li.has-color .at-marriage { color: var(--at-branch); }

/* On the red poster, coloured names get a light backing so they stay readable. */
.ahnentafel-block--poster .at-tree li.has-color .at-person {
  background: rgba(255, 250, 240, 0.72);
}

.ahnentafel-block--poster .at-tree li.has-color .at-person-dates { color: #4b3a30; }

/* multi-marriage branch labels */
.at-tree li.at-branch { padding-left: 14px; padding-right: 14px; }

.at-branch-label {
  font-size: 12px;
  color: var(--at-ink-soft);
  white-space: nowrap;
}

/* ---- photos */
.at-photos {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 460px;
  margin: 4px 0 2px;
}

.at-canvas > .at-photos { max-width: none; margin-bottom: 16px; }

.at-photo {
  margin: 0;
  padding: 5px 5px 4px;
  background: var(--at-photo-frame);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
}

.ahnentafel-block--poster .at-photo--0 { transform: rotate(-1.5deg); }
.ahnentafel-block--poster .at-photo--1 { transform: rotate(1.2deg); }
.ahnentafel-block--poster .at-photo--2 { transform: rotate(-0.6deg); }

.at-photo img {
  display: block;
  max-width: 220px;
  max-height: 160px;
  cursor: zoom-in;
  filter: grayscale(0.15);
}

.at-photo figcaption {
  padding-top: 3px;
  font-size: 12px;
  text-align: center;
  color: #3a2a20;
}

/* ---- editor dialog */
.at-dlg-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
}

.at-dlg {
  display: flex;
  flex-direction: column;
  width: min(720px, 100%);
  max-height: 100%;
  color: var(--bs-body-color, #222);
  background: var(--bs-body-bg, #fff);
  border: 1px solid var(--bs-border-color, #999);
  border-radius: 8px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.45);
  font: 14px/1.4 system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.at-dlg-head,
.at-dlg-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
}

.at-dlg-head { font-weight: 700; border-bottom: 1px solid var(--bs-border-color, #ccc); }
.at-dlg-head span { flex: 1; }
.at-dlg-foot { flex-wrap: wrap; border-top: 1px solid var(--bs-border-color, #ccc); }
.at-dlg-spacer { flex: 1; }

.at-dlg-close {
  color: inherit;
  background: none;
  border: 0;
  font-size: 16px;
  cursor: pointer;
}

.at-dlg-body {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px 12px;
  padding: 12px 14px;
  overflow: auto;
}

.at-dlg-marriage {
  align-self: center;
  font-size: 22px;
  font-weight: 700;
}

.at-dlg fieldset {
  min-width: 0;
  margin: 0;
  padding: 8px 10px 10px;
  border: 1px solid var(--bs-border-color, #ccc);
  border-radius: 6px;
}

.at-dlg legend {
  float: none;
  width: auto;
  margin: 0;
  padding: 0 4px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.75;
}

.at-dlg-person {
  display: flex;
  gap: 10px;
}

.at-dlg-photo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 88px;
  overflow: hidden;
  background: rgba(127, 127, 127, 0.12);
  border: 1px dashed rgba(127, 127, 127, 0.6);
  border-radius: 4px;
  cursor: pointer;
}

.at-dlg-photo img { width: 100%; height: 100%; object-fit: cover; }
.at-dlg-photo-empty { font-size: 30px; opacity: 0.5; }

.at-dlg-fields {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.at-dlg label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  font-weight: 600;
}

.at-dlg input[type='text'] {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  padding: 4px 8px;
  font: 14px system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: inherit;
  background: transparent;
  border: 1px solid var(--bs-border-color, #999);
  border-radius: 4px;
}

.at-dlg-photo-row {
  display: flex;
  gap: 6px;
}

.at-dlg-family { grid-column: 1 / -1; }

.at-dlg-fphotos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.at-dlg-fphotos:empty { display: none; }

.at-dlg-fphoto {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--bs-border-color, #ccc);
  border-radius: 4px;
}

.at-dlg-fphoto img { width: 54px; height: 42px; object-fit: cover; }
.at-dlg-fphoto input[type='text'] { width: 150px; }

.at-dlg-hint { margin: 6px 0 0; font-size: 12px; opacity: 0.7; }
.at-dlg-error { grid-column: 1 / -1; margin: 0; font-weight: 600; color: #dc3545; }

.at-dlg-btn {
  padding: 4px 10px;
  font: 13px system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: inherit;
  white-space: nowrap;
  background: rgba(127, 127, 127, 0.12);
  border: 1px solid rgba(127, 127, 127, 0.45);
  border-radius: 4px;
  cursor: pointer;
}

.at-dlg-btn:hover { background: rgba(127, 127, 127, 0.25); }
.at-dlg-btn--icon { padding: 2px 7px; }
.at-dlg-btn--primary { color: #fff; background: #0d6efd; border-color: #0d6efd; }
.at-dlg-btn--primary:hover { background: #0b5ed7; }
.at-dlg-btn--danger { color: #dc3545; border-color: rgba(220, 53, 69, 0.5); }
.at-dlg-btn--danger.is-armed { color: #fff; background: #dc3545; }

/* ---- colour picker */
.at-color {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.at-swatch {
  width: 24px;
  height: 24px;
  padding: 0;
  background: var(--sw, transparent);
  border: 2px solid rgba(127, 127, 127, 0.45);
  border-radius: 50%;
  cursor: pointer;
}

.at-swatch--none {
  font-size: 14px;
  line-height: 1;
  color: inherit;
  background: transparent;
}

.at-swatch.is-active {
  border-color: #0d6efd;
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.35);
}

.at-color-input {
  width: 34px;
  height: 26px;
  padding: 0;
  background: none;
  border: 1px solid rgba(127, 127, 127, 0.45);
  border-radius: 4px;
  cursor: pointer;
}

.at-dlg--small { width: min(460px, 100%); }
.at-dlg-body--single { grid-template-columns: 1fr; }

.at-dlg-color-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
}

.at-dlg select {
  padding: 4px 8px;
  font: 14px system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: inherit;
  background: transparent;
  border: 1px solid var(--bs-border-color, #999);
  border-radius: 4px;
}

.at-dlg select option { color: #222; }

@media (max-width: 640px) {
  .at-dlg-body { grid-template-columns: 1fr; }
  .at-dlg-marriage { justify-self: center; }
  .at-title { font-size: 20px; }
}

@media print {
  .ahnentafel-block .at-tools { display: none; }
  .ahnentafel-block .at-viewport { max-height: none; overflow: visible; }
}

/* ---- drag & drop of people (edit mode) */
.ahnentafel-block[data-at-editable] button.at-person { touch-action: none; }
.ahnentafel-block.is-dragging-person .at-viewport,
.ahnentafel-block.is-dragging-person .at-viewport * { cursor: grabbing !important; }

.at-person.is-dragging { opacity: 0.35; }

.at-person.is-drop-target {
  background: rgba(255, 255, 255, 0.85);
  outline: 3px dashed #0d6efd;
  outline-offset: 2px;
}

.ahnentafel-block--dark .at-person.is-drop-target { background: rgba(13, 110, 253, 0.25); }

.at-person.is-drop-invalid {
  outline: 3px dashed #dc3545;
  outline-offset: 2px;
  opacity: 0.7;
}

.at-viewport.is-drop-root { box-shadow: inset 0 0 0 3px rgba(13, 110, 253, 0.55); }

.at-drag-ghost {
  position: fixed;
  z-index: 2100;
  padding: 4px 10px;
  font: 600 13px system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: #fff;
  pointer-events: none;
  background: #0d6efd;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.at-rel-menu {
  position: fixed;
  z-index: 2100;
  display: flex;
  flex-direction: column;
  min-width: 220px;
  padding: 6px;
  font: 14px system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--bs-body-color, #222);
  background: var(--bs-body-bg, #fff);
  border: 1px solid var(--bs-border-color, #999);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.at-rel-title {
  padding: 4px 8px 6px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.7;
}

.at-rel-menu button {
  padding: 6px 10px;
  font: inherit;
  color: inherit;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}

.at-rel-menu button:hover:not([disabled]),
.at-rel-menu button:focus-visible { background: rgba(13, 110, 253, 0.12); outline: none; }
.at-rel-menu button[disabled] { opacity: 0.45; cursor: not-allowed; }
.at-rel-menu .at-rel-cancel { margin-top: 4px; border-top: 1px solid var(--bs-border-color, #ddd); border-radius: 0 0 5px 5px; opacity: 0.8; }

/* ---- pictures & text per person: button at each person */
.at-pwrap {
  position: relative;
  display: inline-flex;
}

.at-info-btn {
  position: absolute;
  top: -10px;
  left: calc(100% - 7px);
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 1px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  font: 600 11px/1 system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: #3a120c;
  background: rgba(255, 250, 240, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.25);
  border-radius: 999px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  opacity: 0.35;
  transition: opacity 0.12s, transform 0.12s;
}

.at-info-btn.has-info { opacity: 1; }
.at-pwrap:hover .at-info-btn,
.at-info-btn:focus-visible { opacity: 1; }
.at-info-btn:hover { transform: scale(1.12); }
.at-info-icon { font-size: 11px; }
.at-info-count { padding-left: 1px; }

.ahnentafel-block--dark .at-info-btn { color: #e5e7eb; background: #2f3849; border-color: #475569; }

/* ---- pictures & text panel */
.at-info { position: relative; width: min(880px, 100%); height: min(760px, 100%); }
.at-info:not(.is-editing) { height: auto; max-height: 100%; }

.at-info-portrait {
  width: 40px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
}

.at-info-title { flex: 1; font-size: 17px; }
.at-info-title small { font-weight: 400; opacity: 0.7; }

.at-info-body {
  flex: 1;
  min-height: 0;
  padding: 14px 16px;
  overflow: auto;
}

.at-info-empty { margin: 8px 0; opacity: 0.7; font-style: italic; }

.at-info-text {
  margin-bottom: 14px;
  font-size: 15px;
  line-height: 1.55;
}

.at-info-text > :first-child { margin-top: 0; }
.at-info-text > :last-child { margin-bottom: 0; }
.at-info-text img { max-width: 100%; }

.at-info-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.at-info-thumb {
  margin: 0;
  padding: 5px;
  background: #fff;
  border: 1px solid rgba(127, 127, 127, 0.3);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  cursor: zoom-in;
}

.at-info-thumb:focus-visible { outline: 3px solid #0d6efd; }

.at-info-thumb img {
  display: block;
  width: 100%;
  height: 120px;
  object-fit: cover;
}

.at-info-thumb figcaption {
  padding-top: 4px;
  font-size: 12px;
  color: #3a2a20;
  text-align: center;
}

.at-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2070;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 56px;
  background: rgba(0, 0, 0, 0.9);
}

.at-lightbox figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
}

.at-lightbox img {
  max-width: 100%;
  max-height: calc(100% - 32px);
  object-fit: contain;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.6);
}

.at-lightbox figcaption {
  padding-top: 8px;
  color: #f1f5f9;
  font-size: 14px;
  text-align: center;
}

.at-lightbox figcaption span { opacity: 0.6; padding-left: 8px; }

.at-lightbox-nav,
.at-lightbox-close {
  position: absolute;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.at-lightbox-nav { top: 50%; width: 40px; height: 56px; margin-top: -28px; font-size: 32px; line-height: 1; }
.at-lightbox-prev { left: 8px; }
.at-lightbox-next { right: 8px; }
.at-lightbox-close { top: 10px; right: 10px; width: 34px; height: 34px; font-size: 16px; }
.at-lightbox-nav:hover,
.at-lightbox-close:hover { background: rgba(255, 255, 255, 0.25); }

.at-info-body--edit { display: flex; flex-direction: column; gap: 8px; }
.at-info-label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; }

.at-info textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 140px;
  padding: 8px 10px;
  font: 14px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: inherit;
  background: transparent;
  border: 1px solid var(--bs-border-color, #999);
  border-radius: 4px;
  resize: vertical;
}

.at-info-pic-list { display: flex; flex-direction: column; gap: 6px; }
.at-info-pic-list:empty { display: none; }

.at-info-pic-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--bs-border-color, #ccc);
  border-radius: 4px;
}

.at-info-pic-row img { width: 64px; height: 48px; object-fit: cover; border-radius: 3px; }
.at-info-pic-row input { flex: 1; }
