/* Family Genealogy Tree */
.fgt-tree {
	--fgt-h: 700px;
	--fgt-line: #8a8f98;
	--fgt-line-w: 2px;
	--fgt-spouse: #c2185b;
	--fgt-spouse-w: 3px;
	--fgt-m: #5b8def;
	--fgt-f: #e06c9f;
	--fgt-o: #9b8ac4;
	--fgt-card: #f6efe6;
	--fgt-ink: #1f2933;
	--fgt-muted: #66707c;
	--fgt-ui: #ffffff;
	--fgt-border: #e3e6ea;
	--fgt-accent: #2563eb;
	position: relative;
	margin: 1.5em 0;
	color: var(--fgt-ink);
	font-family: inherit;
	line-height: 1.35;
	text-align: left;
}
.fgt-tree *, .fgt-tree *::before, .fgt-tree *::after { box-sizing: border-box; }

/* Buttons are reset so themes don't restyle them */
/* (0,1,1) specificity so the plugin's own (0,2,0) rules below always win */
.fgt-tree button:where(.fgt-btn, .fgt-x, .fgt-plus, .fgt-pencil), .fgt-tree :where(.fgt-menu) button {
	all: unset;
	box-sizing: border-box;
	cursor: pointer;
	font-family: inherit;
}
.fgt-tree svg { display: block; }

/* Toolbar --------------------------------------------------------------- */
.fgt-toolbar {
	display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
	margin-bottom: 10px;
}
.fgt-title { font-size: 1.35em; font-weight: 700; letter-spacing: -0.01em; }
.fgt-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.fgt-group { display: inline-flex; align-items: center; background: var(--fgt-ui); border: 1px solid var(--fgt-border); border-radius: 10px; padding: 2px; }
.fgt-tree .fgt-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	min-width: 32px; height: 32px; padding: 0 8px; border-radius: 8px;
	font-size: 13px; font-weight: 600; color: var(--fgt-ink); line-height: 1; white-space: nowrap;
	transition: background .15s, color .15s;
}
.fgt-tree .fgt-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fgt-tree .fgt-group .fgt-btn:hover { background: #f1f3f5; }
.fgt-tree .fgt-btn:focus-visible, .fgt-tree .fgt-plus:focus-visible, .fgt-tree .fgt-pencil:focus-visible { outline: 2px solid var(--fgt-accent); outline-offset: 2px; }
.fgt-tree .fgt-zoom-label { min-width: 52px; font-variant-numeric: tabular-nums; color: var(--fgt-muted); }
.fgt-tree .fgt-edit-toggle { background: var(--fgt-ink); color: #fff; padding: 0 14px; height: 36px; border-radius: 10px; }
.fgt-tree .fgt-edit-toggle:hover { opacity: .9; }
.fgt-tree .fgt-edit-toggle.is-on { background: #16a34a; }
.fgt-edit-tools { display: none; }
.fgt-editing .fgt-edit-tools { display: inline-flex; }

.fgt-search { position: relative; }
.fgt-search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--fgt-muted); pointer-events: none; }
.fgt-search-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.fgt-tree input.fgt-search-input {
	height: 38px; width: 190px; margin: 0; padding: 0 12px 0 32px; border: 1px solid var(--fgt-border); border-radius: 10px;
	background: var(--fgt-ui); font: inherit; font-size: 14px; color: var(--fgt-ink); box-shadow: none;
}
.fgt-tree input.fgt-search-input:focus { outline: none; border-color: var(--fgt-accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }

/* Viewport --------------------------------------------------------------- */
.fgt-viewport {
	position: relative; overflow: hidden; height: var(--fgt-h);
	border: 1px solid var(--fgt-border); border-radius: 14px;
	background-color: #fbfbfa;
	cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
	outline: none;
}
.fgt-viewport.is-panning { cursor: grabbing; }

/* Backgrounds ------------------------------------------------------------- */
.fgt-viewport::before {
	content: ""; position: absolute; inset: 0; pointer-events: none;
	background-repeat: no-repeat; background-size: cover; background-position: center;
}
.fgt-bg-dots .fgt-viewport { background-image: radial-gradient(#dfe3e8 1px, transparent 1px); background-size: 22px 22px; }
.fgt-bg-heritage .fgt-viewport { background-color: #f6efe2; }
.fgt-bg-heritage .fgt-viewport::before { background-image: url(../img/heritage-tree.svg); background-position: center bottom; }
.fgt-bg-watercolor .fgt-viewport { background-color: #f3fafa; }
.fgt-bg-watercolor .fgt-viewport::before { background-image: url(../img/watercolor.svg); }
.fgt-bg-plain .fgt-viewport { background-color: #ffffff; }
.fgt-bg-custom .fgt-viewport::before { background-image: linear-gradient(rgba(255, 255, 255, .35), rgba(255, 255, 255, .35)), var(--fgt-bg-img); }

.fgt-bg-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.fgt-tree button.fgt-bg-tile {
	all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; gap: 6px;
	padding: 6px; border-radius: 12px; border: 2px solid transparent; font-size: 13px; font-weight: 600; color: var(--fgt-ink);
}
.fgt-tree button.fgt-bg-tile:hover { background: #f4f6f8; }
.fgt-tree button.fgt-bg-tile[aria-checked="true"] { border-color: var(--fgt-accent); background: #eff4ff; }
.fgt-tree button.fgt-bg-tile:focus-visible { outline: 2px solid var(--fgt-accent); outline-offset: 2px; }
.fgt-bg-swatch { display: block; height: 64px; border-radius: 8px; border: 1px solid var(--fgt-border); background: #fbfbfa center / cover no-repeat; }
.fgt-sw-default { background-image: repeating-linear-gradient(135deg, #f1f3f5 0 8px, #fff 8px 16px); }
.fgt-sw-heritage { background-image: url(../img/heritage-tree.svg); background-position: center bottom; }
.fgt-sw-watercolor { background-image: url(../img/watercolor.svg); }
.fgt-sw-dots { background-image: radial-gradient(#cfd5dc 1px, transparent 1px); background-size: 10px 10px; background-repeat: repeat; }
.fgt-sw-plain { background: #fff; }
.fgt-sw-custom { background: #eef1f4; position: relative; }
.fgt-sw-custom::after { content: "+"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 26px; color: var(--fgt-muted); }
@media (max-width: 480px) { .fgt-bg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Branch view & folding ---------------------------------------------------- */
.fgt-chip {
	display: inline-flex; align-items: center; gap: 8px; padding: 3px 4px 3px 10px; border-radius: 999px;
	background: #eef3ff; color: #1e40af; font-size: 13px; max-width: 100%;
}
.fgt-chip[hidden] { display: none; }
.fgt-chip-ico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; display: block; }
.fgt-chip-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fgt-tree button.fgt-chip-x { min-width: 26px; height: 26px; padding: 0; border-radius: 50%; color: #1e40af; }
.fgt-tree button.fgt-chip-x:hover { background: #dbe6ff; }
.fgt-tree button.fgt-chip-x svg { width: 14px; height: 14px; }

.fgt-tree button.fgt-fold {
	position: absolute; z-index: 3; right: -9px; bottom: -9px; min-width: 26px; height: 22px; padding: 0 7px; border-radius: 11px;
	background: #fff; border: 1px solid #cfd5dc; color: var(--fgt-muted); font-size: 12px; font-weight: 700; line-height: 1;
	box-shadow: 0 1px 3px rgba(16, 24, 40, .12); opacity: 0; transition: opacity .15s;
}
.fgt-tree button.fgt-fold.is-folded { opacity: 1; background: var(--fgt-accent); border-color: var(--fgt-accent); color: #fff; }
.fgt-tree button.fgt-focus-btn {
	position: absolute; z-index: 3; left: 6px; top: 6px; min-width: 0; width: 26px; height: 26px; padding: 0; border-radius: 8px;
	background: #fff; color: var(--fgt-ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .18); opacity: 0; transition: opacity .15s;
}
.fgt-tree button.fgt-focus-btn svg { width: 15px; height: 15px; }
.fgt-style-compact button.fgt-focus-btn { top: 50%; left: auto; right: 38px; transform: translateY(-50%); }
.fgt-person:hover .fgt-fold, .fgt-person.is-selected .fgt-fold, .fgt-person:focus-within .fgt-fold,
.fgt-person:hover .fgt-focus-btn, .fgt-person.is-selected .fgt-focus-btn, .fgt-person:focus-within .fgt-focus-btn { opacity: 1; }
@media (hover: none) { .fgt-tree button.fgt-fold, .fgt-tree button.fgt-focus-btn { opacity: .9; } }

.fgt-style-card .fgt-person.is-folded .fgt-card, .fgt-style-compact .fgt-person.is-folded .fgt-card {
	box-shadow: 5px 5px 0 -1px var(--fgt-card), 5px 5px 0 0 rgba(16, 24, 40, .14), 10px 10px 0 -1px var(--fgt-card), 10px 10px 0 0 rgba(16, 24, 40, .1);
}
.fgt-style-compact .fgt-person.is-folded .fgt-card { box-shadow: 4px 4px 0 -1px #f4f5f7, 4px 4px 0 0 #c9ced5; }
.fgt-person.fgt-dim { opacity: .4; transition: opacity .3s; }
.fgt-person.fgt-dim:hover, .fgt-person.fgt-dim:focus-within { opacity: .85; }
.fgt-person.is-focus .fgt-card { outline: 3px solid var(--fgt-accent); outline-offset: 4px; }
.fgt-style-circle .fgt-person.is-focus .fgt-card { outline: none; }
.fgt-style-circle .fgt-person.is-focus .fgt-avatar { box-shadow: 0 0 0 5px #fff, 0 0 0 8px var(--fgt-accent); }
.fgt-tree button.fgt-up {
	position: absolute; left: 0; top: 0; z-index: 2; min-width: 0; height: 28px; padding: 0 12px; gap: 6px; border-radius: 14px;
	background: #fff; border: 1px solid #cfd8ea; color: var(--fgt-accent); font-size: 12.5px; box-shadow: 0 2px 8px rgba(16, 24, 40, .1);
}
.fgt-tree button.fgt-up:hover { background: #eff4ff; }
.fgt-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.fgt-stage.fgt-glide { transition: transform .4s cubic-bezier(.3, .7, .2, 1); }
.fgt-lines { position: absolute; left: 0; top: 0; overflow: visible; }
.fgt-nodes { position: absolute; left: 0; top: 0; }

.fgt-hint {
	position: absolute; left: 50%; bottom: 14px; transform: translate(-50%, 6px);
	background: rgba(31, 41, 51, .88); color: #fff; font-size: 13px; padding: 7px 12px; border-radius: 8px;
	opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; white-space: nowrap;
}
.fgt-hint.is-on { opacity: 1; transform: translate(-50%, 0); }

.fgt-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.fgt-empty-title { font-size: 16px; color: var(--fgt-muted); }

/* Lines ------------------------------------------------------------------ */
.fgt-ln { fill: none; stroke: var(--fgt-line); stroke-width: var(--fgt-line-w); stroke-linejoin: round; }
.fgt-ln.fgt-k-spouse { stroke: var(--fgt-spouse); stroke-width: var(--fgt-spouse-w); }
.fgt-ln.fgt-ls-dashed { stroke-dasharray: 8 6; }
.fgt-ln.fgt-ls-dotted { stroke-dasharray: 0.1 6; stroke-linecap: round; }
.fgt-ln.fgt-k-spouse.fgt-ls-dotted { stroke-dasharray: 0.1 7; }
.fgt-ln.fgt-k-stub { opacity: .6; }
.fgt-hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: none; }
.fgt-editing .fgt-hit { pointer-events: stroke; cursor: pointer; }
.fgt-editing .fgt-hit:hover { stroke: rgba(37, 99, 235, .22); }

/* People ----------------------------------------------------------------- */
.fgt-person { position: absolute; left: 0; top: 0; cursor: pointer; outline: none; --g: var(--fgt-o); }
.fgt-person.fgt-g-m { --g: var(--fgt-m); }
.fgt-person.fgt-g-f { --g: var(--fgt-f); }
.fgt-person.fgt-new { animation: fgt-pop .45s ease-out; }
@keyframes fgt-pop { from { opacity: 0; } to { opacity: 1; } }
.fgt-person.fgt-found .fgt-card { animation: fgt-found 1.6s ease-out; }
@keyframes fgt-found { 0%, 40% { box-shadow: 0 0 0 6px rgba(37, 99, 235, .55); } 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); } }

.fgt-card { width: 100%; height: 100%; position: relative; transition: box-shadow .2s, transform .2s; }
.fgt-avatar { flex: none; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.fgt-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; margin: 0; max-width: none; border-radius: 0; }
.fgt-avatar span { font-weight: 700; letter-spacing: .02em; }
.fgt-name { font-weight: 700; color: var(--fgt-ink); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.fgt-alt { color: var(--fgt-muted); font-size: 11.5px; line-height: 1.3; font-style: italic; margin-top: 1px; padding: 0 3px; max-width: 100%; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.fgt-style-compact .fgt-alt { display: block; white-space: nowrap; text-overflow: ellipsis; }
.fgt-style-card .fgt-meta, .fgt-style-circle .fgt-meta { width: 100%; min-width: 0; }
.fgt-style-circle .fgt-alt { text-transform: none; letter-spacing: 0; }
.fgt-style-compact .fgt-alt { font-size: 11px; margin-top: 0; }
.fgt-style-compact .has-alt .fgt-dates { margin-top: 0; font-size: 11.5px; }
.fgt-dates { color: var(--fgt-muted); font-size: 12px; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fgt-person:hover .fgt-card, .fgt-person:focus-visible .fgt-card, .fgt-person.is-selected .fgt-card { box-shadow: 0 6px 18px rgba(16, 24, 40, .14); }
.fgt-person:focus-visible .fgt-card { outline: 2px solid var(--fgt-accent); outline-offset: 2px; }

/* Style: photo cards */
.fgt-style-card .fgt-card {
	display: flex; flex-direction: column; align-items: center; text-align: center;
	padding: 12px 10px 10px; background: var(--fgt-card); border-radius: 14px;
	border-top: 4px solid var(--g); box-shadow: 0 1px 3px rgba(16, 24, 40, .08);
}
.fgt-style-card .fgt-avatar { width: 66px; height: 66px; border-radius: 50%; background: var(--g); color: #fff; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .12); margin-bottom: 8px; }
.fgt-style-card .fgt-avatar span { font-size: 22px; }
.fgt-style-card .fgt-name { font-size: 14px; }
.fgt-style-card .fgt-alt { max-width: 100%; }

/* Style: round avatars */
.fgt-style-circle .fgt-card { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 2px; }
.fgt-style-circle .fgt-avatar { width: 84px; height: 84px; border-radius: 50%; border: 3px solid var(--g); background: #fff; color: var(--g); margin-bottom: 8px; box-shadow: 0 0 0 5px rgba(255, 255, 255, .9); }
.fgt-style-circle .fgt-avatar span { font-size: 27px; }
.fgt-style-circle .fgt-name { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: #555d66; }
.fgt-style-circle .fgt-person:hover .fgt-card, .fgt-style-circle .fgt-person.is-selected .fgt-card { box-shadow: none; }
.fgt-style-circle .fgt-person:hover .fgt-avatar, .fgt-style-circle .fgt-person.is-selected .fgt-avatar { box-shadow: 0 0 0 5px rgba(255, 255, 255, .9), 0 6px 16px rgba(16, 24, 40, .18); }
.fgt-style-circle .fgt-person.fgt-found .fgt-card { animation: none; }
.fgt-style-circle .fgt-person.fgt-found .fgt-avatar { animation: fgt-found 1.6s ease-out; }

/* Style: compact boxes */
.fgt-style-compact .fgt-card { display: flex; align-items: center; background: #f4f5f7; border: 1px solid #d5d9df; border-radius: 6px; overflow: hidden; }
.fgt-style-compact .fgt-avatar { width: 46px; height: 100%; background: var(--g); color: #fff; opacity: .92; }
.fgt-style-compact .fgt-avatar span { font-size: 15px; }
.fgt-style-compact .fgt-meta { padding: 0 10px; min-width: 0; flex: 1; }
.fgt-style-compact .fgt-name { font-size: 13.5px; -webkit-line-clamp: 1; }
.fgt-style-compact .fgt-card::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--g); opacity: .35; }

/* Edit mode: + buttons ---------------------------------------------------- */
.fgt-tree button.fgt-plus {
	position: absolute; z-index: 3; width: 26px; height: 26px; border-radius: 50%;
	display: flex; align-items: center; justify-content: center;
	background: var(--fgt-accent); color: #fff; font-size: 19px; font-weight: 600; line-height: 1;
	box-shadow: 0 2px 6px rgba(37, 99, 235, .4); border: 2px solid #fff;
	opacity: 0; transform: scale(.6); transition: opacity .15s, transform .15s;
}
.fgt-tree button.fgt-plus:hover { transform: scale(1.12) !important; }
.fgt-tree button.fgt-pencil {
	position: absolute; z-index: 3; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 8px;
	display: flex; align-items: center; justify-content: center; background: #fff; color: var(--fgt-ink);
	box-shadow: 0 1px 4px rgba(0, 0, 0, .18); opacity: 0; transition: opacity .15s;
}
.fgt-tree button.fgt-pencil svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fgt-style-compact button.fgt-pencil { top: 50%; transform: translateY(-50%); right: 6px; }
.fgt-person:hover .fgt-plus, .fgt-person.is-selected .fgt-plus, .fgt-person:focus-within .fgt-plus { opacity: 1; transform: scale(1); }
.fgt-person:hover .fgt-pencil, .fgt-person.is-selected .fgt-pencil, .fgt-person:focus-within .fgt-pencil { opacity: 1; }
@media (hover: none) { .fgt-editing .fgt-plus { opacity: .85 !important; transform: scale(1) !important; } .fgt-editing .fgt-pencil { opacity: 1; } }

/* Vertical: parent on top, siblings left/right, spouse+child below */
.fgt-tree.fgt-o-vertical .fgt-p-parent { left: 50%; top: -13px; margin-left: -13px; }
.fgt-tree.fgt-o-vertical .fgt-p-below { left: 50%; bottom: -13px; margin-left: -13px; }
.fgt-tree.fgt-o-vertical .fgt-p-before { left: -13px; top: 50%; margin-top: -13px; }
.fgt-tree.fgt-o-vertical .fgt-p-after { right: -13px; top: 50%; margin-top: -13px; }
/* Horizontal: parent on the ancestor side */
.fgt-tree.fgt-o-horizontal .fgt-p-parent { left: -13px; top: 50%; margin-top: -13px; }
.fgt-tree.fgt-o-horizontal .fgt-p-below { right: -13px; top: 50%; margin-top: -13px; }
.fgt-tree.fgt-o-horizontal-rtl .fgt-p-parent { right: -13px; top: 50%; margin-top: -13px; }
.fgt-tree.fgt-o-horizontal-rtl .fgt-p-below { left: -13px; top: 50%; margin-top: -13px; }
.fgt-tree.fgt-o-horizontal .fgt-p-before, .fgt-tree.fgt-o-horizontal-rtl .fgt-p-before { left: 50%; top: -13px; margin-left: -13px; }
.fgt-tree.fgt-o-horizontal .fgt-p-after, .fgt-tree.fgt-o-horizontal-rtl .fgt-p-after { left: 50%; bottom: -13px; margin-left: -13px; }
.fgt-tree.fgt-style-circle.fgt-o-vertical .fgt-p-parent { top: -16px; }

/* Busy / toast ------------------------------------------------------------- */
.fgt-busy .fgt-viewport, .fgt-busy .fgt-modal { cursor: progress; }
.fgt-busy .fgt-modal-foot .fgt-primary { opacity: .6; pointer-events: none; }
.fgt-toast {
	position: absolute; left: 50%; bottom: 70px; max-width: min(70%, 520px); z-index: 6; translate: -50% 0; text-align: center;
	background: #16a34a; color: #fff; font-size: 13px; font-weight: 600; padding: 9px 14px; border-radius: 10px;
	box-shadow: 0 6px 18px rgba(0, 0, 0, .18); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: none;
}
.fgt-toast.is-err { background: #dc2626; }
.fgt-toast.is-on { opacity: 1; transform: none; }

/* Menu --------------------------------------------------------------------- */
.fgt-menu {
	position: fixed; z-index: 100000; background: #fff; border: 1px solid var(--fgt-border); border-radius: 12px;
	box-shadow: 0 12px 32px rgba(16, 24, 40, .18); padding: 6px; min-width: 200px;
}
.fgt-tree .fgt-menu button { display: block; width: 100%; padding: 10px 12px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--fgt-ink); }
.fgt-tree .fgt-menu button:hover, .fgt-tree .fgt-menu button:focus-visible { background: #eff4ff; color: var(--fgt-accent); }

/* Modal -------------------------------------------------------------------- */
.fgt-backdrop {
	position: fixed; inset: 0; z-index: 100001; background: rgba(15, 23, 42, .5);
	display: flex; align-items: center; justify-content: center; padding: 16px; animation: fgt-pop .15s ease-out;
}
.fgt-modal {
	width: min(540px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: #fff; color: var(--fgt-ink);
	border-radius: 16px; box-shadow: 0 24px 60px rgba(0, 0, 0, .3); font-size: 14px;
}
.fgt-modal-sm { width: min(380px, 100%); }
.fgt-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 6px; }
.fgt-tree .fgt-modal-head h3 { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.3; color: var(--fgt-ink); }
.fgt-tree button.fgt-x { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--fgt-muted); flex: none; }
.fgt-tree button.fgt-x:hover { background: #f1f3f5; }
.fgt-tree button.fgt-x svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.fgt-modal-body { padding: 10px 22px 6px; }
.fgt-modal-foot { display: flex; align-items: center; gap: 8px; padding: 14px 22px 20px; flex-wrap: wrap; justify-content: flex-end; }
.fgt-spacer { flex: 1; }

.fgt-form { display: flex; flex-direction: column; gap: 12px; }
.fgt-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.fgt-row.fgt-row-sfx { grid-template-columns: 1fr 110px; }
.fgt-shown { font-size: 13px; color: var(--fgt-muted); margin-top: -4px; min-height: 1em; }
.fgt-tree .fgt-mid-toggle {
	height: 38px; min-width: 44px; padding: 0 12px; border-radius: 10px; background: var(--fgt-ui);
	border: 1px solid var(--fgt-border); font-size: 13px; font-weight: 700; color: var(--fgt-ink);
}
.fgt-tree .fgt-mid-toggle:hover { background: #f1f3f5; }
.fgt-tree .fgt-mid-toggle.is-on { background: #eef3ff; border-color: #c7d6fb; color: #1e40af; }
.fgt-field { display: flex; flex-direction: column; gap: 5px; margin: 0; }
.fgt-label { font-size: 12px; font-weight: 700; color: var(--fgt-muted); text-transform: uppercase; letter-spacing: .04em; }
.fgt-tree .fgt-input {
	width: 100%; height: 40px; margin: 0; padding: 8px 11px; border: 1px solid #d0d5dc; border-radius: 9px; background: #fff;
	font: inherit; font-size: 14px; color: var(--fgt-ink); box-shadow: none; max-width: none; line-height: 1.3;
}
.fgt-tree textarea.fgt-input { height: auto; min-height: 64px; resize: vertical; }
.fgt-tree select.fgt-input { padding-right: 28px; }
.fgt-tree .fgt-input:focus { outline: none; border-color: var(--fgt-accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.fgt-inline { display: flex; gap: 8px; }
.fgt-inline .fgt-input { flex: 1; }
.fgt-check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; margin: 0; }
.fgt-check.fgt-field { flex-direction: row; height: 40px; }
.fgt-tree .fgt-check input { width: 17px; height: 17px; margin: 0; accent-color: var(--fgt-accent); flex: none; }
.fgt-checks { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border: 1px solid #e6e9ed; border-radius: 9px; max-height: 150px; overflow: auto; }
.fgt-hidden { display: none !important; }
.fgt-relbox { margin-top: 16px; padding-top: 14px; border-top: 1px dashed #dde1e6; display: flex; flex-direction: column; gap: 12px; }
.fgt-rels { display: flex; flex-direction: column; gap: 6px; }
.fgt-rel { display: grid; grid-template-columns: 64px 1fr 190px 32px; align-items: center; gap: 8px; }
.fgt-rel-kind { font-size: 12px; color: var(--fgt-muted); font-weight: 700; }
.fgt-rel-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fgt-rel .fgt-input { height: 34px; padding: 4px 8px; font-size: 13px; }
.fgt-muted { color: var(--fgt-muted); margin: 0; }
.fgt-muted-sm { color: var(--fgt-muted); font-weight: 400; font-size: 13px; }
.fgt-tree button.fgt-linkbtn { all: unset; cursor: pointer; align-self: flex-start; color: var(--fgt-accent); font-size: 13px; font-weight: 600; margin-top: -4px; }
.fgt-tree button.fgt-linkbtn:hover { text-decoration: underline; }
.fgt-tree button.fgt-linkbtn:focus-visible { outline: 2px solid var(--fgt-accent); outline-offset: 2px; border-radius: 4px; }
.fgt-rel-sub { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 8px; margin: -2px 0 6px; }
.fgt-rel-sub .fgt-label { grid-column: 2; font-size: 11px; }
.fgt-rel-sub .fgt-input { grid-column: 2; height: 34px; font-size: 13px; padding: 4px 8px; }

.fgt-tree .fgt-primary { background: var(--fgt-accent); color: #fff; height: 40px; padding: 0 18px; border-radius: 10px; }
.fgt-tree .fgt-primary:hover { background: #1d4ed8; }
.fgt-tree .fgt-primary svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.fgt-tree .fgt-secondary { background: #f1f3f5; color: var(--fgt-ink); height: 40px; padding: 0 16px; border-radius: 10px; }
.fgt-tree .fgt-secondary:hover { background: #e6e9ed; }
.fgt-tree .fgt-danger { color: #dc2626; height: 40px; padding: 0 12px; border-radius: 10px; }
.fgt-tree .fgt-danger:hover { background: #fef2f2; }
.fgt-tree .fgt-icon-btn { width: 32px; height: 32px; padding: 0; color: var(--fgt-muted); }
.fgt-tree .fgt-icon-btn:hover { background: #fef2f2; color: #dc2626; }
.fgt-tree .fgt-btn[disabled] { opacity: .5; pointer-events: none; }

.fgt-details { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding-bottom: 12px; --g: var(--fgt-o); }
.fgt-details.fgt-g-m { --g: var(--fgt-m); }
.fgt-details.fgt-g-f { --g: var(--fgt-f); }
.fgt-avatar-lg { width: 120px; height: 120px; border-radius: 50%; background: var(--g); color: #fff; border: 4px solid #fff; box-shadow: 0 0 0 3px var(--g); }
.fgt-avatar-lg span { font-size: 40px; }
.fgt-facts { display: grid; grid-template-columns: auto auto; gap: 4px 14px; margin: 0; text-align: left; }
.fgt-facts dt { font-size: 12px; font-weight: 700; color: var(--fgt-muted); text-transform: uppercase; letter-spacing: .04em; margin: 0; }
.fgt-facts dd { margin: 0; font-weight: 600; }
.fgt-notes { white-space: pre-wrap; color: #3d4752; margin: 0; max-width: 100%; }

/* Full screen ----------------------------------------------------------------- */
.fgt-tree.fgt-full, .fgt-tree.fgt-max { margin: 0; padding: 14px; background: #fff; display: flex; flex-direction: column; }
.fgt-tree.fgt-max { position: fixed; inset: 0; z-index: 99999; }
.fgt-tree.fgt-full .fgt-viewport, .fgt-tree.fgt-max .fgt-viewport { flex: 1; height: auto; }
html.fgt-noscroll { overflow: hidden; }

@media (max-width: 640px) {
	.fgt-tools { margin-left: 0; width: 100%; }
	.fgt-search { flex: 1; }
	.fgt-tree input.fgt-search-input { width: 100%; }
	.fgt-row, .fgt-row.fgt-row-sfx { grid-template-columns: 1fr; }
	.fgt-rel { grid-template-columns: 1fr 32px; }
	.fgt-rel-kind { grid-column: 1 / -1; }
	.fgt-rel .fgt-input { grid-column: 1; }
}

/* Admin meta box */
#fgt_editor .inside { margin: 0; padding: 4px 12px 12px; }
#fgt_editor .fgt-tree { margin: 0; }

/* Floating legend + corrections buttons ------------------------------------ */
.fgt-tree button.fgt-fab {
	position: absolute; z-index: 5; bottom: 14px; height: 42px; min-width: 42px; padding: 0 16px 0 12px; gap: 8px; border-radius: 21px;
	background: rgba(255, 255, 255, .94); color: var(--fgt-ink); border: 1px solid var(--fgt-border);
	box-shadow: 0 6px 18px rgba(16, 24, 40, .14); font-size: 13px; font-weight: 700;
	-webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); transition: transform .15s, box-shadow .15s, background .15s;
}
.fgt-tree button.fgt-fab:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(16, 24, 40, .18); background: #fff; }
.fgt-tree button.fgt-fab-left { left: 14px; }
.fgt-tree button.fgt-fab-right { right: 14px; background: var(--fgt-accent); color: #fff; border-color: transparent; }
.fgt-tree button.fgt-fab-right:hover { background: #1d4ed8; }
.fgt-tree button.fgt-fab-left.is-on { background: #eef3ff; color: #1e40af; border-color: #c7d6fb; }
.fgt-fab-ico svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }
@media (max-width: 560px) {
	.fgt-fab-text { display: none; }
	.fgt-tree button.fgt-fab { padding: 0; width: 44px; justify-content: center; }
}

.fgt-legend {
	position: absolute; z-index: 5; left: 14px; bottom: 66px; width: min(300px, calc(100% - 28px)); max-height: calc(100% - 84px); overflow: auto;
	background: #fff; border: 1px solid var(--fgt-border); border-radius: 14px; box-shadow: 0 16px 40px rgba(16, 24, 40, .2);
	padding: 12px 14px 14px; font-size: 13px; cursor: default; animation: fgt-pop .15s ease-out;
}
.fgt-legend[hidden] { display: none; }
.fgt-lg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.fgt-lg-head strong { font-size: 15px; }
.fgt-legend .fgt-x { width: 28px; height: 28px; min-width: 0; padding: 0; }
.fgt-lg-title { margin: 10px 0 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--fgt-muted); }
.fgt-legend ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.fgt-legend li { display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 10px; margin: 0; line-height: 1.35; }
.fgt-lg-sw { display: flex; align-items: center; justify-content: center; height: 22px; }
.fgt-lg-sw svg { width: 44px; height: 12px; overflow: visible; }
.fgt-lg-icon svg, .fgt-legend .fgt-lg-sw.fgt-lg-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fgt-lg-dots { gap: 4px; }
.fgt-lg-dots i { width: 12px; height: 12px; border-radius: 50%; display: block; background: var(--fgt-o); }
.fgt-lg-dots i.fgt-g-m { background: var(--fgt-m); }
.fgt-lg-dots i.fgt-g-f { background: var(--fgt-f); }
.fgt-lg-fold { background: var(--fgt-accent); color: #fff; border-radius: 10px; padding: 2px 7px; font-size: 11px; }
.fgt-lg-text em { color: var(--fgt-muted); font-size: 12px; }
.fgt-lg-m { border: 1px solid var(--fgt-border); border-radius: 8px; padding: 1px 7px; font-size: 12px; }
.fgt-lg-plus { width: 20px; height: 20px; border-radius: 50%; background: var(--fgt-accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.fgt-legend .fgt-lg-sw small { margin-left: 4px; font-size: 10px; color: var(--fgt-muted); }

.fgt-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.fgt-thanks { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 16px 0 6px; }
.fgt-thanks strong { font-size: 16px; }
.fgt-thanks-ico { width: 52px; height: 52px; border-radius: 50%; background: #dcfce7; color: #16a34a; display: flex; align-items: center; justify-content: center; }
.fgt-thanks-ico svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.fgt-modal-foot .fgt-secondary svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Drag siblings to reorder (edit mode) ---------------------------------------- */
.fgt-dragging .fgt-viewport, .fgt-dragging .fgt-person { cursor: grabbing; }
.fgt-person.is-dragged { z-index: 10; opacity: .95; }
.fgt-person.is-dragged .fgt-card { box-shadow: 0 18px 40px rgba(16, 24, 40, .28); }
.fgt-style-circle .fgt-person.is-dragged .fgt-avatar { box-shadow: 0 18px 40px rgba(16, 24, 40, .28); }
.fgt-person.is-drop-target .fgt-card { outline: 2px dashed rgba(37, 99, 235, .45); outline-offset: 4px; }
.fgt-style-circle .fgt-person.is-drop-target .fgt-card { outline: none; }
.fgt-style-circle .fgt-person.is-drop-target .fgt-avatar { outline: 2px dashed rgba(37, 99, 235, .55); outline-offset: 4px; }
.fgt-drop-marker {
	position: absolute; z-index: 9; border-radius: 3px; background: var(--fgt-accent);
	box-shadow: 0 0 0 4px rgba(37, 99, 235, .18); pointer-events: none; transition: left .12s, top .12s;
}
.fgt-lg-drag { font-size: 16px; color: var(--fgt-accent); }
.fgt-dragging .fgt-plus, .fgt-dragging .fgt-pencil, .fgt-dragging .fgt-fold:not(.is-folded), .fgt-dragging .fgt-focus-btn { opacity: 0 !important; pointer-events: none; }

.fgt-check.fgt-check-sm { font-size: 13px; margin-top: -4px; color: var(--fgt-ink); }

/* Related name updates dialog ---------------------------------------------- */
.fgt-modal-nc { width: min(600px, 100%); }
.fgt-nc-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; }
.fgt-nc-row { display: grid; grid-template-columns: 20px 1fr; gap: 2px 10px; align-items: center; padding: 10px 12px; border: 1px solid #e6e9ed; border-radius: 10px; cursor: pointer; margin: 0; }
.fgt-nc-row:hover { background: #f8fafc; }
.fgt-tree .fgt-nc-row input { width: 17px; height: 17px; margin: 0; accent-color: var(--fgt-accent); }
.fgt-nc-names { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; min-width: 0; }
.fgt-nc-before { color: var(--fgt-muted); text-decoration: line-through; text-decoration-color: rgba(102, 112, 124, .5); }
.fgt-nc-arrow { color: var(--fgt-accent); font-weight: 700; }
.fgt-nc-why { grid-column: 2; color: var(--fgt-muted); font-size: 12px; }
.fgt-custom-box { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px dashed #d0d5dc; border-radius: 10px; background: #fafbfc; }
.fgt-custom-box .fgt-check-sm { margin-top: 0; }

/* Privacy ------------------------------------------------------------------- */
.fgt-avatar-lock { background: #e9ecef !important; color: #868e96 !important; }
.fgt-avatar-lock svg { width: 42%; height: 42%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fgt-style-circle .fgt-avatar-lock { border-color: #ced4da; }
.fgt-card-private .fgt-name { color: #868e96; font-weight: 600; }
.fgt-style-card .fgt-card.fgt-card-private { border-top-color: #ced4da; justify-content: center; }
.fgt-lock-badge { position: absolute; top: 8px; left: 8px; width: 22px; height: 22px; border-radius: 50%; background: #343a40; color: #fff; display: flex; align-items: center; justify-content: center; z-index: 2; }
.fgt-lock-badge svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.fgt-style-compact .fgt-lock-badge { top: 4px; left: 30px; width: 18px; height: 18px; }
.fgt-private-toggle { align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: #f8f9fa; border: 1px solid #e9ecef; font-size: 13.5px; }
.fgt-private-toggle svg, .fgt-living-note svg, .fgt-fb-privacy svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.fgt-private-toggle input { margin-top: 1px !important; }
.fgt-living-note, .fgt-fb-privacy { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.fgt-lg-note { margin: 10px 0 0; padding-top: 8px; border-top: 1px dashed #e3e6ea; color: var(--fgt-muted); font-size: 12px; line-height: 1.45; }
.fgt-preview-bar { display: inline-flex; align-items: center; gap: 8px; padding: 3px 4px 3px 12px; border-radius: 999px; background: #fff7e6; color: #92400e; border: 1px solid #fcd9a3; font-size: 13px; font-weight: 600; }
.fgt-preview-bar[hidden] { display: none; }
.fgt-preview-bar svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; display: block; }
.fgt-tree button.fgt-preview-exit { height: 28px; min-width: 0; padding: 0 12px; border-radius: 14px; background: #92400e; color: #fff; font-size: 12.5px; }
.fgt-previewing .fgt-viewport { box-shadow: 0 0 0 3px #fcd9a3; }
.fgt-previewing .fgt-edit-toggle { opacity: .4; pointer-events: none; }

/* Deceased people: muted shade ------------------------------------------------ */
.fgt-dec-muted .fgt-person.fgt-deceased, .fgt-dec-cross .fgt-person.fgt-deceased { --g: color-mix(in srgb, var(--fgt-o) 15%, #a3a8ae); }
.fgt-dec-muted .fgt-person.fgt-deceased.fgt-g-m, .fgt-dec-cross .fgt-person.fgt-deceased.fgt-g-m { --g: color-mix(in srgb, var(--fgt-m) 35%, #a3a8ae); }
.fgt-dec-muted .fgt-person.fgt-deceased.fgt-g-f, .fgt-dec-cross .fgt-person.fgt-deceased.fgt-g-f { --g: color-mix(in srgb, var(--fgt-f) 35%, #a3a8ae); }
.fgt-dec-muted.fgt-style-card .fgt-deceased .fgt-card, .fgt-dec-cross.fgt-style-card .fgt-deceased .fgt-card { background: color-mix(in srgb, var(--fgt-card) 72%, #d9dadd); }
.fgt-dec-muted.fgt-style-compact .fgt-deceased .fgt-card, .fgt-dec-cross.fgt-style-compact .fgt-deceased .fgt-card { background: #ebecee; }
.fgt-dec-muted .fgt-deceased .fgt-avatar img, .fgt-dec-cross .fgt-deceased .fgt-avatar img { filter: grayscale(.7); }
.fgt-dec-muted .fgt-deceased .fgt-name, .fgt-dec-cross .fgt-deceased .fgt-name { color: #4b5158; }
.fgt-dec-muted.fgt-style-circle .fgt-deceased .fgt-avatar, .fgt-dec-cross.fgt-style-circle .fgt-deceased .fgt-avatar { background: #f3f3f4; }
.fgt-cross { color: #6b7178; font-weight: 600; }
.fgt-lg-dec { display: block; width: 26px; height: 18px; border-radius: 5px; background: color-mix(in srgb, #f6efe6 72%, #d9dadd); border-top: 3px solid #a3a8ae; }
