    /* ── Tree View ────────────────────────────────────────── */
    #panel-tree {
      overflow: auto;
      padding: 24px 20px;
      background: var(--clr-bg);
      position: relative;
    }
    #tree-view-content {
      position: relative;
    }

    /* General row */
    .tree-row {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      gap: 10px;
    }
    .tree-row--ancestors { opacity: .88; }
    .tree-row--parents   { opacity: .92; }
    .tree-row--focal     { gap: 6px; }

    /* Grandparents row: slightly narrower cards so 4 fit per column */
    .tree-row--gp .tree-card { min-width: 100px; max-width: 150px; }
    /* Great-grandparents row: tight gap, extra-small cards (up to 8/column) */
    .tree-row--ggp { gap: 8px; }

    /* Father+mother couple inside an ancestor row. On narrow viewports the
       couple stacks vertically (father above mother) so the row still fits
       without horizontal scrolling – like classic printed family trees. */
    .tree-anc-pair { display: flex; gap: 10px; }
    .tree-row--ggp .tree-anc-pair { gap: 4px; }

    @media (max-width: 1880px) {
      .tree-row--ggp .tree-anc-pair {
        flex-direction: column;
        align-items: center;
        gap: 6px;
      }
    }
    @media (max-width: 1200px) {
      .tree-row--gp .tree-anc-pair {
        flex-direction: column;
        align-items: center;
        gap: 6px;
      }
    }
    @media (max-width: 900px) {
      .tree-row--parents .tree-anc-pair {
        flex-direction: column;
        align-items: center;
        gap: 8px;
      }
    }

    /* Children row: groups align to the top so grandchildren hang below */
    .tree-row--children { align-items: flex-start; }
    .tree-row--grandchildren { gap: 4px; }
    .tree-desc-group {
      display: flex;
      flex-direction: column;
      align-items: center;
    }

    /* Spacer between tree rows – visual lines are drawn by SVG overlay */
    .tree-connector {
      display: flex;
      justify-content: center;
      height: 24px;
    }

    /* ── SVG connector overlay ── */
    .tree-svg-overlay {
      position: absolute;
      top: 0; left: 0;
      pointer-events: none;
      overflow: visible;
    }

    /* ── Two-column ancestor area ── */
    .tree-ancestors-area {
      display: flex;
      gap: 24px;
      justify-content: center;
      flex-wrap: wrap;
    }
    .tree-anc-col {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: flex-end;
      gap: 0;
      flex: 1;
      min-width: 200px;
    }
    .tree-anc-col .tree-row { width: 100%; }
    .tree-anc-col .tree-connector { width: 100%; }

    /* ── Compact cards (ancestors & children) ── */
    .tree-card {
      position: relative;
      display: flex;
      flex-direction: row;
      align-items: flex-start;
      background: var(--clr-white);
      border: 1.5px solid #dfe6e9;
      border-radius: var(--radius);
      padding: 8px 10px 6px;
      min-width: 120px;
      max-width: 175px;
      box-shadow: 0 1px 4px rgba(0,0,0,.07);
      cursor: pointer;
      transition: box-shadow .15s, transform .1s, border-color .15s;
      overflow: hidden;
    }
    .tree-card--compact {
      flex-direction: column;
    }
    .tree-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--clr-primary); }

    .tree-card--ghost {
      border-style: dashed;
      background: transparent;
      color: #95a5a6;
      font-size: .8rem;
      align-items: center;
      justify-content: center;
      min-height: 64px;
      transition: background .15s, border-color .15s;
    }
    .tree-card--ghost:hover {
      background: rgba(52,152,219,.06);
      border-color: var(--clr-primary);
      color: var(--clr-primary);
      transform: none;
      box-shadow: none;
    }

    /* Extra-small card variant (great-grandparents row, grandchildren):
       fixed width so 16 cards fit a FullHD viewport without scrolling */
    .tree-card--xs {
      min-width: 0;
      width: 86px;
      max-width: 86px;
      padding: 6px 7px 5px;
    }
    .tree-card--xs .tree-card__name { font-size: .68rem; line-height: 1.25; }
    .tree-card--xs .tree-card__dates { font-size: .62rem; }
    .tree-card--xs .tree-card__avatar { display: none; }
    .tree-card--xs.tree-card--ghost {
      min-height: 44px;
      font-size: .68rem;
      padding: 4px;
      text-align: center;
    }

    .tree-card__stripe {
      position: absolute;
      top: 0; left: 0; right: 0;
      height: 3px;
      border-radius: var(--radius) var(--radius) 0 0;
    }
    .tree-card__stripe--m { background: #3498db; }
    .tree-card__stripe--f { background: #e05878; }
    .tree-card__stripe--u { background: #95a5a6; }

    .tree-card__body { flex: 1; margin-top: 4px; }
    .tree-card__name {
      font-size: .82rem;
      font-weight: 700;
      line-height: 1.3;
      color: var(--clr-dark);
      word-break: break-word;
    }
    .tree-card__dates {
      font-size: .72rem;
      color: #7f8c8d;
      margin-top: 1px;
    }
    .tree-card__avatar {
      align-self: flex-end;
      margin-top: 4px;
      position: relative;
    }
    .tree-card__avatar svg {
      width: 22px;
      height: 22px;
      color: #c8d6df;
    }
    .tree-card__link-warn {
      position: absolute;
      top: -5px;
      right: -5px;
      width: 13px;
      height: 13px;
      background: #e74c3c;
      color: #fff;
      border-radius: 50%;
      font-size: 9px;
      font-weight: 700;
      line-height: 13px;
      text-align: center;
      cursor: default;
      border: 1.5px solid #fff;
    }

    /* ── Couple connector ── */
    .tree-couple-divider {
      display: flex;
      align-items: center;
      color: #b2bec3;
    }
    .tree-couple-edit {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 32px;
      height: 32px;
      border: 1.5px solid #dfe6e9;
      border-radius: var(--radius);
      background: var(--clr-white);
      color: #95a5a6;
      cursor: pointer;
      padding: 0;
      transition: background .15s, border-color .15s, color .15s;
      box-shadow: 0 1px 3px rgba(0,0,0,.06);
    }
    .tree-couple-edit:hover {
      background: rgba(52,152,219,.08);
      border-color: var(--clr-primary);
      color: var(--clr-primary);
    }
    .tree-couple-edit--has-marriage {
      background: #fffde7;
      border-color: #f9a825;
      color: #f57f17;
    }
    .tree-couple-edit--has-marriage:hover {
      background: #fff9c4;
      border-color: #f57f17;
      color: #e65100;
    }
    .tree-couple-edit:focus-visible {
      outline: 2px solid var(--clr-primary);
      outline-offset: 2px;
    }
    .tree-couple-edit svg { width: 18px; height: 18px; }
    .tree-couple-disconnect {
      color: #c0392b;
      border-color: #e0b4b4;
    }
    .tree-couple-disconnect:hover {
      background: rgba(192,57,43,.08);
      border-color: #c0392b;
      color: #922b21;
    }

    /* ── Large focal-couple row ── */
    .tree-focal-couple {
      display: flex;
      gap: 6px;
      justify-content: center;
      flex-wrap: wrap;
      align-items: stretch;
    }

    .tree-focal-card {
      flex: 1;
      min-width: 260px;
      max-width: 48%;
      display: flex;
      flex-direction: column;
      border-radius: var(--radius);
      overflow: hidden;
      box-shadow: 0 2px 8px rgba(0,0,0,.12);
      border: 1.5px solid transparent;
    }
    .tree-focal-card--m {
      background: #dce8f3;
      border-color: #9ab8d8;
    }
    .tree-focal-card--f {
      background: #fde9d6;
      border-color: #e8a87c;
    }
    .tree-focal-card--u {
      background: #ecf0f1;
      border-color: #b2bec3;
    }
    .tree-focal-card--ghost {
      flex: 1;
      min-width: 200px;
      max-width: 48%;
      border: 2px dashed #b2bec3;
      background: transparent;
      display: flex;
      align-items: center;
      justify-content: center;
      color: #95a5a6;
      font-size: .9rem;
      border-radius: var(--radius);
      cursor: pointer;
      min-height: 120px;
      transition: background .15s, border-color .15s, color .15s;
    }
    .tree-focal-card--ghost:hover {
      background: rgba(52,152,219,.05);
      border-color: var(--clr-primary);
      color: var(--clr-primary);
    }

    .tree-focal-card__header {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      padding: 12px 14px 10px;
      background: rgba(0,0,0,.07);
    }
    .tree-focal-card--m .tree-focal-card__header { background: rgba(0,60,120,.10); }
    .tree-focal-card--f .tree-focal-card__header { background: rgba(180,80,0,.08); }

    .tree-focal-card__name-block { flex: 1; }
    .tree-focal-card__name {
      font-size: 1.05rem;
      font-weight: 700;
      color: var(--clr-dark);
      line-height: 1.3;
      word-break: break-word;
    }
    .tree-focal-card__year {
      font-size: .82rem;
      color: #546e7a;
      margin-top: 2px;
    }

    .tree-focal-card__avatar {
      width: 52px;
      height: 52px;
      border-radius: 50%;
      background: rgba(255,255,255,.5);
      border: 1.5px solid rgba(0,0,0,.12);
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      margin-left: 10px;
      position: relative;
    }
    .tree-focal-card__avatar svg {
      width: 36px;
      height: 36px;
      color: #90a4ae;
    }

    .tree-focal-card__details {
      flex: 1;
      padding: 12px 14px 8px;
      display: flex;
      flex-direction: column;
      gap: 5px;
    }
    .tree-focal-card__detail-row {
      display: grid;
      grid-template-columns: 90px 1fr;
      font-size: .82rem;
      line-height: 1.4;
    }
    .tree-focal-card__detail-label {
      color: #546e7a;
      font-weight: 600;
    }
    .tree-focal-card__detail-value {
      color: var(--clr-dark);
      word-break: break-word;
    }

    .tree-focal-card__footer {
      padding: 8px 14px 10px;
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      border-top: 1px solid rgba(0,0,0,.07);
    }
    .tree-focal-card__btn {
      padding: 4px 14px;
      border: 1px solid rgba(0,0,0,.18);
      border-radius: 4px;
      background: rgba(255,255,255,.65);
      color: var(--clr-dark);
      font-size: .8rem;
      font-weight: 600;
      cursor: pointer;
      transition: background .12s;
    }
    .tree-focal-card__btn:hover { background: rgba(255,255,255,.9); }
    .tree-focal-card__btn--delete {
      color: var(--clr-danger);
      border-color: var(--clr-danger);
    }
    .tree-focal-card__btn--delete:hover {
      background: var(--clr-danger);
      color: #fff;
    }

    /* ── Three-dot menu ── */
    .tree-focal-card__menu {
      position: relative;
      margin-left: 6px;
      flex-shrink: 0;
    }
    .tree-focal-card__menu-btn {
      background: none;
      border: none;
      cursor: pointer;
      padding: 4px 5px;
      border-radius: 4px;
      color: #546e7a;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: background .12s;
    }
    .tree-focal-card__menu-btn:hover { background: rgba(0,0,0,.10); }
    .tree-focal-card__menu-dropdown {
      display: none;
      position: fixed;
      z-index: 9200;
      background: var(--clr-white);
      border: 1px solid #dcdde1;
      border-radius: var(--radius);
      box-shadow: 0 4px 14px rgba(0,0,0,.15);
      min-width: 210px;
      overflow: hidden;
    }
    .tree-focal-card__menu-dropdown.open { display: block; }
    .tree-focal-card__menu-item {
      display: block;
      width: 100%;
      padding: 9px 14px;
      text-align: left;
      background: none;
      border: none;
      border-bottom: 1px solid #f0f0f0;
      cursor: pointer;
      font-size: .84rem;
      color: var(--clr-dark);
      transition: background .12s;
      white-space: nowrap;
    }
    .tree-focal-card__menu-item:last-child { border-bottom: none; }
    .tree-focal-card__menu-item:hover { background: #f0f4f8; }

    /* ── Family strip ── */
    .tree-family-strip {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 10px 18px;
      padding: 8px 16px;
      background: var(--clr-white);
      border: 1px solid #dfe6e9;
      border-radius: var(--radius);
      font-size: .85rem;
      color: var(--clr-dark);
      box-shadow: 0 1px 3px rgba(0,0,0,.06);
    }
    .tree-family-strip__status { font-weight: 600; }
    .tree-family-strip__children { color: #546e7a; }
    .tree-family-strip__link-btn {
      background: none;
      border: none;
      color: var(--clr-primary);
      cursor: pointer;
      font-size: .85rem;
      padding: 0;
      text-decoration: underline;
    }
    .tree-family-strip__link-btn:hover { color: #1a5276; }
    .tree-family-strip__edit-btn {
      margin-left: auto;
      padding: 3px 14px;
      border: 1px solid #dcdde1;
      border-radius: 4px;
      background: var(--clr-white);
      color: var(--clr-dark);
      font-size: .82rem;
      font-weight: 600;
      cursor: pointer;
      transition: background .12s, border-color .12s;
    }
    .tree-family-strip__edit-btn:hover { background: #f0f4f8; border-color: #b2bec3; }

    .tree-empty {
      text-align: center;
      color: #95a5a6;
      font-style: italic;
      padding: 40px 0;
    }

    /* ── Tree context menu ── */
    .tree-context-menu {
      position: fixed;
      z-index: 9999;
      margin: 0;
      padding: 4px 0;
      list-style: none;
      background: var(--clr-white);
      border: 1px solid #dcdde1;
      border-radius: var(--radius);
      box-shadow: 0 4px 16px rgba(0,0,0,.18);
      min-width: 160px;
    }
    .tree-context-menu__item {
      padding: 8px 16px;
      cursor: pointer;
      font-size: .88rem;
      color: var(--clr-dark);
      transition: background .1s;
      white-space: nowrap;
    }
    .tree-context-menu__item:hover { background: #f0f4f8; }

