/* ─── Arbre généalogique (arbre.js) — préfixe ft- pour ne rien heurter ─── */
.ft-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.ft-head h1 { font-family: var(--serif); font-size: 44px; font-weight: 600; line-height: 1; }
.ft-head .sub { color: var(--text-dim); font-size: 14px; margin-top: 8px; }
.ft-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.ft-toolbar select, .ft-toolbar input { background: var(--bg-elev); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: 9px 12px; font: inherit; font-size: 14px; }
.ft-toolbar select:focus, .ft-toolbar input:focus { outline: none; border-color: var(--gold-dim); }
.ft-toolbar select { max-width: 320px; }
.ft-search { position: relative; }
.ft-search input { width: 240px; }
.ft-sugg { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); z-index: 30; max-height: 280px; overflow-y: auto; }
.ft-sugg button { display: block; width: 100%; text-align: left; padding: 9px 12px; font-size: 13px; color: var(--text); background: none; border: 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.ft-sugg button:last-child { border-bottom: 0; }
.ft-sugg button:hover { background: var(--gold-soft); color: var(--gold); }
.ft-sugg .mute { color: var(--text-mute); font-size: 12px; margin-left: 6px; }
.ft-btn { background: var(--bg-elev); border: 1px solid var(--border); color: var(--text-dim); border-radius: var(--radius); padding: 8px 12px; font-size: 13px; cursor: pointer; transition: all .15s; }
.ft-btn:hover { border-color: var(--gold-dim); color: var(--gold); }

.ft-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.ft-viewport { position: relative; height: calc(100vh - 250px); min-height: 460px; background: radial-gradient(ellipse at top, #141416 0%, var(--bg) 70%); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; touch-action: none; cursor: grab; user-select: none; }
.ft-viewport.dragging { cursor: grabbing; }
.ft-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.ft-links { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.ft-links path { fill: none; stroke: var(--gold-dim); stroke-opacity: .55; stroke-width: 1.5; }
.ft-zoom { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 5; }
.ft-zoom button { width: 36px; height: 36px; background: var(--bg-elev); border: 1px solid var(--border); color: var(--text-dim); border-radius: var(--radius); font-size: 16px; cursor: pointer; }
.ft-zoom button:hover { color: var(--gold); border-color: var(--gold-dim); }

/* Carte « foyer » */
.ft-foyer { position: absolute; display: flex; align-items: stretch; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; transition: border-color .15s, box-shadow .15s; }
.ft-foyer:hover { border-color: var(--gold-dim); }
.ft-foyer.hl { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft), 0 0 24px rgba(212,175,55,.25); }
.ft-person { display: flex; align-items: center; gap: 9px; padding: 9px 10px; flex: none; width: var(--w, 168px); min-width: 0; overflow: hidden; cursor: pointer; text-decoration: none; color: inherit; }
.ft-person + .ft-person { border-left: 1px dashed var(--border); }
.ft-person.spouse { opacity: .85; }
.ft-person.spouse .ft-av { width: 32px; height: 32px; font-size: 13px; }
.ft-person.spouse .ft-name { font-size: 12.5px; }
.ft-av { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--bg-elev); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-size: 16px; color: var(--gold-dim); overflow: hidden; }
.ft-av img { width: 100%; height: 100%; object-fit: cover; }
.ft-person.deceased .ft-av { filter: grayscale(1); opacity: .7; }
.ft-txt { flex: 1; min-width: 0; }
.ft-name { font-size: 13.5px; font-weight: 500; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ft-meta { font-size: 11px; color: var(--text-mute); margin-top: 2px; white-space: nowrap; }
.ft-cross { color: var(--gold-dim); margin-left: 3px; }
.ft-toggle { position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%); height: 22px; min-width: 22px; padding: 0 7px; border-radius: 11px; background: var(--bg-elev); border: 1px solid var(--gold-dim); color: var(--gold); font-size: 11px; cursor: pointer; z-index: 2; white-space: nowrap; }
.ft-toggle:hover { background: var(--gold-soft); }

/* Panneau « pas encore dans l'arbre » */
.ft-panel { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; max-height: calc(100vh - 250px); min-height: 460px; overflow-y: auto; }
.ft-panel h3 { font-family: var(--serif); font-size: 22px; font-weight: 600; }
.ft-panel .hint { font-size: 12px; color: var(--text-mute); margin: 6px 0 12px; line-height: 1.5; }
.ft-panel input { width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: 9px 12px; font: inherit; font-size: 14px; margin-bottom: 8px; }
.ft-panel input:focus { outline: none; border-color: var(--gold-dim); }
.ft-group { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-mute); margin: 14px 0 6px; }
.ft-row { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: var(--radius); text-decoration: none; color: inherit; }
.ft-row:hover { background: var(--gold-soft); }
.ft-row .ft-av { width: 30px; height: 30px; font-size: 12px; }
.ft-row .n { font-size: 13.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ft-row .f { font-size: 11px; color: var(--text-mute); }

/* Liste mobile */
.ft-tabs { display: none; gap: 8px; margin-bottom: 14px; }
.ft-list details { border-left: 1px solid var(--border); margin-left: 14px; }
.ft-list > details { border-left: 0; margin-left: 0; }
.ft-list summary { list-style: none; cursor: pointer; padding: 4px 0 4px 10px; }
.ft-list summary::-webkit-details-marker { display: none; }
.ft-list .ft-foyer { position: static; display: inline-flex; flex-wrap: wrap; max-width: 100%; }
.ft-list .ft-person { width: auto; max-width: 220px; }
.ft-list .ft-count { display: block; width: fit-content; font-size: 11px; color: var(--gold-dim); margin: 4px 0 0 8px; white-space: nowrap; }
.ft-list details[open] > summary .ft-count::before { content: "▾ "; }
.ft-list details:not([open]) > summary .ft-count::before { content: "▸ "; }
.ft-list .leaf { padding: 4px 0 4px 10px; margin-left: 14px; border-left: 1px solid var(--border); }

/* Bloc « Famille » de la fiche personne */
.ft-family { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 24px; }
.ft-family .lbl { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-mute); margin-bottom: 6px; }
.ft-family .ft-row { padding: 5px 4px; }
.ft-family .empty { font-size: 13px; color: var(--text-mute); font-style: italic; }

@media (max-width: 1024px) {
  .ft-layout { grid-template-columns: 1fr 250px; }
}
@media (max-width: 720px) {
  .ft-head h1 { font-size: 34px; }
  .ft-layout { display: block; }
  .ft-tabs { display: flex; }
  .ft-viewport, .ft-zoom { display: none; }
  .ft-panel { max-height: none; min-height: 0; }
  .ft-layout[data-tab="tree"] .ft-panel { display: none; }
  .ft-layout[data-tab="todo"] .ft-list { display: none; }
  .ft-toolbar select, .ft-search input { width: 100%; max-width: none; font-size: 16px; }
  .ft-search { flex: 1 1 100%; }
  .ft-panel input { font-size: 16px; }
}
@media (min-width: 721px) {
  .ft-list { display: none; }
}

/* ─── v2 : panneau repliable, mini-fiche ─── */
.ft-layout { transition: grid-template-columns .2s; }
.ft-layout.panel-closed { grid-template-columns: 1fr 44px; }
.ft-stage { position: relative; min-width: 0; }
.ft-panel { position: relative; }
.ft-panel-toggle { position: absolute; top: 12px; right: 12px; z-index: 2; display: flex; align-items: center; gap: 8px; background: none; border: 0; color: var(--text-dim); cursor: pointer; padding: 4px; }
.ft-panel-toggle:hover { color: var(--gold); }
.ft-panel-toggle .arrow { font-size: 22px; line-height: 1; display: inline-block; transition: transform .2s; }
.ft-panel-toggle .vlabel { display: none; }
.ft-layout.panel-closed .ft-panel { padding: 12px 0; overflow: hidden; }
.ft-layout.panel-closed .ft-panel-body { display: none; }
.ft-layout.panel-closed .ft-panel-toggle { position: static; flex-direction: column; width: 100%; height: 100%; gap: 14px; }
.ft-layout.panel-closed .ft-panel-toggle .arrow { transform: rotate(180deg); }
.ft-layout.panel-closed .ft-panel-toggle .vlabel { display: block; writing-mode: vertical-rl; transform: rotate(180deg); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.ft-panel-toggle .vlabel b { color: var(--gold); font-weight: 500; margin-top: 6px; }
.ft-panel h3 { padding-right: 34px; }
.ft-person.sel .ft-av { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-soft); }
.ft-person.sel .ft-name { color: var(--gold); }
.ft-sep { height: 1px; background: var(--border); margin: 14px 0; }

.ft-card { position: absolute; top: 12px; right: 12px; width: 320px; max-height: calc(100% - 24px); overflow-y: auto; z-index: 20; background: var(--bg-elev); border: 1px solid var(--gold-dim); border-radius: 8px; padding: 18px; box-shadow: 0 18px 48px rgba(0,0,0,.6); }
.ft-c-close { position: absolute; top: 8px; right: 10px; background: none; border: 0; color: var(--text-mute); font-size: 22px; cursor: pointer; line-height: 1; }
.ft-c-close:hover { color: var(--gold); }
.ft-c-head { display: flex; gap: 14px; align-items: center; padding-right: 20px; }
.ft-c-photo { flex: none; width: 64px; height: 64px; border-radius: 50%; overflow: hidden; background: var(--bg-card); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-size: 26px; color: var(--gold-dim); }
.ft-c-photo img { width: 100%; height: 100%; object-fit: cover; }
.ft-c-name { font-family: var(--serif); font-size: 23px; font-weight: 600; line-height: 1.1; }
.ft-c-meta { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.ft-c-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 6px; }
.ft-c-actions .ft-btn { text-decoration: none; font-size: 12px; padding: 6px 10px; }
.ft-c-rel { margin-top: 10px; }
.ft-c-rel .lbl, .ft-c-form .lbl { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-mute); margin-bottom: 4px; }
.ft-c-rel .ft-row { padding: 4px; }
.ft-c-note { font-size: 13px; color: var(--text-dim); margin-top: 10px; font-style: italic; }
.ft-c-form { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.ft-c-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ft-c-grid label { font-size: 11px; color: var(--text-dim); display: flex; flex-direction: column; gap: 4px; }
.ft-c-grid label.wide { grid-column: 1 / -1; }
.ft-c-grid input { background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: 8px 10px; font: inherit; font-size: 13px; width: 100%; }
.ft-c-grid input:focus { outline: none; border-color: var(--gold-dim); }
.ft-c-save { margin-top: 12px; width: 100%; background: var(--gold); color: #0a0a0b; border: 0; border-radius: var(--radius); padding: 10px; font-weight: 600; font-size: 13px; cursor: pointer; }
.ft-c-save:disabled { opacity: .6; cursor: wait; }

@media (max-width: 720px) {
  .ft-layout.panel-closed { display: block; }
  .ft-panel-toggle { display: none; }
  .ft-layout.panel-closed .ft-panel-body { display: block; }
  .ft-card { position: fixed; top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 78vh; border-radius: 14px 14px 0 0; border-bottom: 0; }
  .ft-c-grid input { font-size: 16px; }
}

/* ─── v3 : noms entiers (2 lignes max), arbre miniature de la mini-fiche ─── */
.ft-name { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.18; overflow-wrap: anywhere; }
.ft-person { padding: 8px 10px; }
.ft-person.spouse .ft-name { font-size: 12.5px; }
.ft-row .n { white-space: normal; overflow-wrap: anywhere; line-height: 1.25; }
.ft-sugg button { white-space: normal; }

.ft-mini { margin-top: 14px; padding: 12px 8px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; text-align: center; }
.ft-mrow { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.ft-mlbl { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-mute); }
.ft-mnone { font-size: 12px; color: var(--text-mute); font-style: italic; }
.ft-mv { width: 1px; height: 16px; background: var(--gold-dim); margin: 6px auto; opacity: .7; }
.ft-mv.dashed { background: none; border-left: 1px dashed var(--border); }
.ft-mcouple { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px; }
.ft-mplus { color: var(--gold-dim); font-size: 12px; padding: 0 2px; }
.ft-mkids { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
.ft-mchip { display: inline-flex; align-items: center; gap: 6px; max-width: 128px; padding: 4px 8px 4px 4px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 18px; text-decoration: none; color: var(--text); font-size: 12px; line-height: 1.2; text-align: left; transition: border-color .15s; }
a.ft-mchip:hover { border-color: var(--gold-dim); color: var(--gold); }
.ft-mchip .ft-av { width: 24px; height: 24px; font-size: 11px; }
.ft-mchip span { overflow-wrap: anywhere; }
.ft-mchip.me { border-color: var(--gold); background: var(--gold-soft); color: var(--gold); font-weight: 500; }
.ft-mchip.deceased .ft-av { filter: grayscale(1); opacity: .7; }

/* ─── v4 : « + » de l'arbre miniature, sélecteur de participant·e, annulation ─── */
.ft-madd { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px 0 8px; border-radius: 16px; border: 1px dashed var(--gold-dim); background: transparent; color: var(--gold-dim); font-size: 12px; cursor: pointer; transition: all .15s; }
.ft-madd:hover { color: var(--gold); border-color: var(--gold); background: var(--gold-soft); }
.ft-mcouple .ft-madd, .ft-mkids .ft-madd { width: 30px; padding: 0; justify-content: center; font-size: 16px; }
.ft-mcouple .ft-madd span, .ft-mkids .ft-madd span { display: none; }
.ft-mrow.empty .ft-madd span { display: inline; }
.ft-mkids .ft-madd:only-child { width: auto; padding: 0 10px 0 8px; font-size: 12px; }
.ft-mkids .ft-madd:only-child span { display: inline; }

.ft-pick { margin-top: 10px; padding: 12px; border: 1px solid var(--gold-dim); border-radius: 8px; background: var(--bg-card); }
.ft-pick-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; color: var(--gold); margin-bottom: 8px; }
.ft-pick-head button { background: none; border: 0; color: var(--text-mute); font-size: 18px; cursor: pointer; line-height: 1; }
.ft-pick input { width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: 8px 10px; font: inherit; font-size: 13px; }
.ft-pick input:focus { outline: none; border-color: var(--gold-dim); }
.ft-pick-list { margin-top: 6px; max-height: 240px; overflow-y: auto; }
.ft-pick-list button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 4px; background: none; border: 0; border-radius: var(--radius); color: var(--text); text-align: left; cursor: pointer; }
.ft-pick-list button:hover { background: var(--gold-soft); }
.ft-pick-list .ft-av { width: 26px; height: 26px; font-size: 11px; }
.ft-pick-list .n { font-size: 13px; line-height: 1.25; }
.ft-pick-list small { display: block; font-size: 11px; color: var(--text-mute); }
.ft-pick-hint { font-size: 12px; color: var(--text-mute); padding: 6px 2px; }
.ft-pick-text { font-size: 13.5px; line-height: 1.45; }
.ft-pick-warn { font-size: 12.5px; line-height: 1.45; margin-top: 8px; padding: 8px 10px; border-left: 2px solid var(--gold); background: var(--gold-soft); color: var(--accent); }
.ft-pick-actions { display: flex; gap: 8px; margin-top: 12px; }
.ft-pick-actions .ft-c-save { margin-top: 0; flex: 1; }
.ft-undo { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 8px 10px; border-radius: var(--radius); background: var(--gold-soft); font-size: 12px; color: var(--text); }
.ft-undo span { flex: 1; }
.ft-undo button { background: none; border: 1px solid var(--gold-dim); color: var(--gold); border-radius: var(--radius); padding: 4px 10px; font-size: 12px; cursor: pointer; }
@media (max-width: 720px) { .ft-pick input { font-size: 16px; } }

/* ─── v5 : placer depuis le panneau ─── */
.ft-outrow { display: flex; align-items: center; gap: 4px; }
.ft-outrow .ft-row { flex: 1; min-width: 0; }
.ft-place { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px dashed var(--gold-dim); background: transparent; color: var(--gold-dim); font-size: 16px; line-height: 1; cursor: pointer; transition: all .15s; }
.ft-place:hover { color: var(--gold); border-color: var(--gold); background: var(--gold-soft); }
.ft-c-note strong { color: var(--text); font-style: normal; }
.ft-mini.flash { animation: ftFlash 1.4s ease-out; }
@keyframes ftFlash { 0% { box-shadow: 0 0 0 0 rgba(212,175,55,.6); border-color: var(--gold); } 100% { box-shadow: 0 0 0 14px rgba(212,175,55,0); } }
