.giapha-tree-app {
	--giapha-tree-border: #d8dee8;
	--giapha-tree-text: #172033;
	--giapha-tree-muted: #64748b;
	--giapha-tree-surface: #fff;
	--giapha-tree-primary: #7b3f1d;
	--giapha-tree-primary-soft: #f8eee7;
	--giapha-tree-line: #aeb8c7;
	position: relative;
	width: 100%;
	color: var(--giapha-tree-text);
	font-size: 15px;
}
.giapha-tree-toolbar {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
	padding: 12px;
	border: 1px solid var(--giapha-tree-border);
	border-radius: 12px 12px 0 0;
	background: #f8fafc;
	position: relative;
	z-index: 20;
}
.giapha-tree-toolbar__group { display: flex; gap: 6px; align-items: center; }
.giapha-tree-button,
.giapha-tree-icon-button {
	appearance: none;
	border: 1px solid #c8d0dc;
	border-radius: 7px;
	background: #fff;
	color: #243047;
	font: inherit;
	line-height: 1.2;
	min-height: 36px;
	padding: 8px 11px;
	cursor: pointer;
}
.giapha-tree-icon-button { min-width: 36px; padding: 7px; font-size: 18px; }
.giapha-tree-button:hover,
.giapha-tree-icon-button:hover,
.giapha-tree-button:focus-visible,
.giapha-tree-icon-button:focus-visible { border-color: var(--giapha-tree-primary); color: var(--giapha-tree-primary); outline: 2px solid rgba(123,63,29,.16); outline-offset: 1px; }
.giapha-tree-button.is-active { background: var(--giapha-tree-primary); border-color: var(--giapha-tree-primary); color: #fff; }
.giapha-tree-button:disabled,
.giapha-tree-icon-button:disabled { opacity: .45; cursor: not-allowed; }
.giapha-tree-search { position: relative; min-width: min(280px, 100%); flex: 1 1 240px; }
.giapha-tree-search input,
.giapha-tree-filter select {
	width: 100%;
	min-height: 38px;
	border: 1px solid #c8d0dc;
	border-radius: 7px;
	background: #fff;
	padding: 7px 10px;
	font: inherit;
}
.giapha-tree-filter { flex: 0 1 190px; }
.giapha-tree-search__results {
	position: absolute;
	left: 0;
	right: 0;
	top: calc(100% + 5px);
	z-index: 100;
	max-height: 360px;
	overflow: auto;
	border: 1px solid var(--giapha-tree-border);
	border-radius: 9px;
	background: #fff;
	box-shadow: 0 12px 30px rgba(15,23,42,.15);
}
.giapha-tree-search__item {
	width: 100%;
	display: flex;
	align-items: center;
	gap: 9px;
	border: 0;
	border-bottom: 1px solid #eef1f5;
	background: #fff;
	padding: 8px 10px;
	text-align: left;
	cursor: pointer;
}
.giapha-tree-search__item:hover { background: #f8fafc; }
.giapha-tree-search__text { display: grid; min-width: 0; }
.giapha-tree-search__text strong,
.giapha-tree-search__text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.giapha-tree-search__text small { color: var(--giapha-tree-muted); }
.giapha-tree-search__portrait,
.giapha-tree-list__portrait { width: 42px; height: 42px; border-radius: 50%; overflow: hidden; flex: 0 0 auto; background: #e7ebf1; display: grid; place-items: center; }
.giapha-tree-search__portrait img,
.giapha-tree-list__portrait img { width: 100%; height: 100%; object-fit: cover; }
.giapha-tree-search__empty { padding: 12px; color: var(--giapha-tree-muted); }
.giapha-tree-status { padding: 9px 12px; border-inline: 1px solid var(--giapha-tree-border); background: #fff8e5; color: #755600; }
.giapha-tree-status.is-error { background: #fff0f0; color: #9b1c1c; }
.giapha-tree-status.is-warning { background: #fff8e5; color: #755600; }
.giapha-tree-view { border: 1px solid var(--giapha-tree-border); border-top: 0; border-radius: 0 0 12px 12px; background: #fff; }
.giapha-family-chart { height: clamp(560px, 72vh, 920px); min-height: 520px; }
.giapha-family-chart__canvas { padding: 28px 44px 80px; }
.giapha-tree-help { margin: 0; padding: 9px 14px; border-top: 1px solid #edf0f4; color: var(--giapha-tree-muted); font-size: 13px; background: #fbfcfd; }

/* Tree layout */
.giapha-fc-tree,
.giapha-fc-tree ul {
	margin: 0;
	padding-top: 30px;
	padding-left: 0;
	position: relative;
	display: flex;
	justify-content: center;
	align-items: flex-start;
	width: max-content;
	list-style: none;
}
.giapha-fc-tree { padding-top: 0; }
.giapha-fc-tree li {
	position: relative;
	padding: 30px 12px 0;
	text-align: center;
	list-style: none;
}
.giapha-fc-tree > li { padding-top: 0; }
.giapha-fc-tree li::before,
.giapha-fc-tree li::after {
	content: '';
	position: absolute;
	top: 0;
	right: 50%;
	width: 50%;
	height: 30px;
	border-top: 1.5px solid var(--giapha-tree-line);
}
.giapha-fc-tree li::after { right: auto; left: 50%; border-left: 1.5px solid var(--giapha-tree-line); }
.giapha-fc-tree li:only-child::before,
.giapha-fc-tree li:only-child::after { display: none; }
.giapha-fc-tree li:only-child { padding-top: 0; }
.giapha-fc-tree li:first-child::before,
.giapha-fc-tree li:last-child::after { border: 0 none; }
.giapha-fc-tree li:last-child::before { border-right: 1.5px solid var(--giapha-tree-line); border-radius: 0 5px 0 0; }
.giapha-fc-tree li:first-child::after { border-radius: 5px 0 0 0; }
.giapha-fc-tree ul::before {
	content: '';
	position: absolute;
	top: 0;
	left: 50%;
	width: 0;
	height: 30px;
	border-left: 1.5px solid var(--giapha-tree-line);
}
.giapha-fc-groups { gap: 5px; }
.giapha-fc-group { min-width: max-content; }
.giapha-fc-group__label {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	min-height: 30px;
	max-width: 220px;
	padding: 5px 10px;
	border: 1px dashed #b8c2d0;
	border-radius: 999px;
	background: #f8fafc;
	font-size: 12px;
	color: #556176;
}
.giapha-fc-group__label a { color: var(--giapha-tree-primary); text-decoration: none; font-weight: 600; }
.giapha-fc-children { padding-top: 28px !important; }
.giapha-fc-card {
	position: relative;
	width: 238px;
	max-width: 238px;
	border: 1px solid #cfd7e3;
	border-radius: 13px;
	background: var(--giapha-tree-surface);
	box-shadow: 0 5px 16px rgba(15,23,42,.09);
	text-align: left;
	overflow: hidden;
	transition: opacity .18s ease, transform .18s ease, box-shadow .18s ease;
}
.giapha-fc-card:hover { box-shadow: 0 8px 25px rgba(15,23,42,.14); }
.giapha-fc-card.is-filtered-out { opacity: .18; filter: grayscale(.85); }
.giapha-fc-card.is-focused { box-shadow: 0 0 0 4px rgba(123,63,29,.28), 0 12px 30px rgba(15,23,42,.18); transform: translateY(-3px); }
.giapha-fc-card__main { display: flex; align-items: stretch; }
.giapha-fc-card__profile { min-width: 0; flex: 1 1 auto; display: flex; align-items: center; gap: 10px; padding: 11px; color: inherit; text-decoration: none; }
.giapha-fc-card__profile:hover .giapha-fc-card__name { color: var(--giapha-tree-primary); }
.giapha-fc-portrait {
	width: var(--giapha-tree-image-size);
	height: var(--giapha-tree-image-size);
	min-width: var(--giapha-tree-image-size);
	border-radius: 10px;
	overflow: hidden;
	background: #e7ebf1;
	display: grid;
	place-items: center;
	color: #536176;
	font-size: 26px;
	font-weight: 700;
}
.giapha-fc-portrait img,
.giapha-fc-spouse__portrait img { width: 100%; height: 100%; object-fit: cover; }
.giapha-fc-card__content { min-width: 0; display: grid; gap: 3px; }
.giapha-fc-card__name { display: block; color: #182235; line-height: 1.25; overflow-wrap: anywhere; }
.giapha-fc-card__meta { display: block; font-size: 12px; line-height: 1.35; color: var(--giapha-tree-muted); }
.giapha-fc-toggle {
	width: 34px;
	border: 0;
	border-left: 1px solid #edf0f4;
	background: #f8fafc;
	color: var(--giapha-tree-primary);
	font-size: 18px;
	cursor: pointer;
}
.giapha-fc-toggle:hover { background: var(--giapha-tree-primary-soft); }
.giapha-fc-badge { position: absolute; top: 4px; right: 38px; padding: 2px 7px; border-radius: 99px; background: #7b3f1d; color: #fff; font-size: 10px; letter-spacing: .02em; }
.giapha-fc-spouses { border-top: 1px solid #edf0f4; display: grid; background: #fbfcfd; }
.giapha-fc-spouse { display: flex; align-items: center; gap: 8px; padding: 7px 10px; color: inherit; text-decoration: none; border-bottom: 1px solid #edf0f4; }
.giapha-fc-spouse:last-child { border-bottom: 0; }
.giapha-fc-spouse:hover { background: var(--giapha-tree-primary-soft); }
.giapha-fc-spouse.is-focused { box-shadow: inset 0 0 0 3px rgba(123,63,29,.3); }
.giapha-fc-spouse__portrait { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; overflow: hidden; background: #e7ebf1; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.giapha-fc-spouse__info { min-width: 0; display: grid; }
.giapha-fc-spouse__name { font-size: 12px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.giapha-fc-spouse__years { font-size: 11px; color: var(--giapha-tree-muted); }
.giapha-fc-card__children-count { padding: 5px 10px; border-top: 1px solid #edf0f4; color: var(--giapha-tree-muted); font-size: 11px; text-align: center; }
.giapha-fc-cycle { padding: 10px; border: 1px solid #ef4444; color: #b91c1c; background: #fff1f2; border-radius: 8px; }
.giapha-fc-initials { line-height: 1; }

/* List */
.giapha-tree-list-wrap { overflow-x: auto; }
.giapha-tree-list { width: 100%; border-collapse: collapse; margin: 0; }
.giapha-tree-list th,
.giapha-tree-list td { padding: 10px 11px; border-bottom: 1px solid #e7ebf1; text-align: left; vertical-align: middle; }
.giapha-tree-list th { background: #f8fafc; color: #3b475b; font-size: 13px; white-space: nowrap; }
.giapha-tree-list__photo { width: 58px; }
.giapha-tree-list__name { display: block; font-weight: 700; color: var(--giapha-tree-primary); text-decoration: none; }
.giapha-tree-list td small { display: block; color: var(--giapha-tree-muted); margin-top: 2px; }
.giapha-tree-list__focus { border: 0; background: transparent; color: var(--giapha-tree-primary); text-decoration: underline; cursor: pointer; padding: 0; font: inherit; }
.giapha-tree-list__empty { text-align: center !important; padding: 28px !important; color: var(--giapha-tree-muted); }
.giapha-tree-pagination { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px; }
.giapha-tree-pagination__info { color: var(--giapha-tree-muted); }
.giapha-tree-app:fullscreen { background: #fff; padding: 8px; overflow: auto; }
.giapha-tree-app:fullscreen .giapha-family-chart { height: calc(100vh - 145px); }

@media (max-width: 900px) {
	.giapha-tree-toolbar { align-items: stretch; }
	.giapha-tree-search { order: -1; flex-basis: 100%; }
	.giapha-tree-filter { flex: 1 1 180px; }
	.giapha-tree-controls { flex-basis: 100%; flex-wrap: wrap; }
	.giapha-family-chart { height: 68vh; min-height: 500px; }
	.giapha-fc-card { width: 210px; max-width: 210px; }
	.giapha-fc-tree li { padding-inline: 8px; }
}
@media (max-width: 620px) {
	.giapha-tree-toolbar__group.giapha-tree-view-switch { width: 100%; }
	.giapha-tree-view-switch .giapha-tree-button { flex: 1; }
	.giapha-tree-filter { flex-basis: 100%; }
	.giapha-tree-controls .giapha-tree-button { flex: 1 1 145px; }
	.giapha-family-chart { min-height: 460px; }
	.giapha-fc-card { width: 190px; max-width: 190px; }
	.giapha-fc-portrait { --giapha-tree-image-size: 56px; }
	.giapha-tree-list thead { display: none; }
	.giapha-tree-list,
	.giapha-tree-list tbody,
	.giapha-tree-list tr,
	.giapha-tree-list td { display: block; width: 100%; }
	.giapha-tree-list tr { position: relative; padding: 10px 10px 10px 72px; border-bottom: 1px solid #dfe5ed; min-height: 72px; }
	.giapha-tree-list td { border: 0; padding: 2px 0; }
	.giapha-tree-list__photo { position: absolute; left: 12px; top: 12px; width: 48px !important; }
}
