/* ============================================================================
   /trees/{slug} — просмотрщик одного дерева. Тема html/derevo.html.
   Главное отличие — полноэкранный режим: <html, body> = 100vh, overflow:hidden.
   ========================================================================= */

:root {
	--k-bg:        #EFEDE6;
	--k-surface:   #FAF9F5;
	--k-ink:       #16150F;
	--k-ink-soft:  #5C594D;
	--k-ink-faint: #8C897C;
	--k-line:      #D9D5C9;
	--k-green:     #0E4D40;
	--k-green-deep:#093229;
	--k-green-soft:#E2EBE6;
	--k-clay:      #C7622E;
	--k-clay-soft: #F2E0D3;
}

html, body { height: 100%; }
body {
	background: var(--k-bg) !important;
	color: var(--k-ink) !important;
	font-family: 'Manrope', sans-serif !important;
	font-size: 16px;
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
	display: flex; flex-direction: column;
	overflow: hidden !important;
}
body::before {
	content: ""; position: fixed; inset: 0; z-index: 9999; pointer-events: none; opacity: .035;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
main#main { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0; }

.site-footer { display: none !important; }

.btn {
	font-family: 'Manrope', sans-serif; font-weight: 700; font-size: 14px;
	border: none; cursor: pointer;
	padding: 10px 16px; border-radius: 100px;
	transition: transform .15s, background .2s;
	display: inline-flex; align-items: center; gap: 7px;
	text-decoration: none;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--k-green); color: #fff; }
.btn-primary:hover { background: var(--k-green-deep); }
.btn-ghost { background: var(--k-surface); color: var(--k-ink); border: 1.5px solid var(--k-line); }
.btn-ghost:hover { border-color: var(--k-ink); }

.crumb-row {
	flex: none;
	background: rgba(239,237,230,.86);
	border-bottom: 1px solid var(--k-line);
	padding: 8px 24px;
}
.crumb {
	font-size: 14px; font-weight: 600; color: var(--k-ink-faint);
	display: flex; gap: 8px; align-items: center;
}
.crumb a { color: var(--k-ink-faint); text-decoration: none; }
.crumb a:hover { color: var(--k-green); }
.crumb .sep { opacity: .5; }
@media (max-width: 760px) { .crumb-row { display: none; } }

.toolbar {
	flex: none;
	display: flex; align-items: center; gap: 16px;
	padding: 14px 24px;
	background: var(--k-surface);
	border-bottom: 1.5px solid var(--k-line);
	flex-wrap: wrap; z-index: 40;
}
.tinfo h1 {
	font-family: 'Unbounded', sans-serif !important;
	font-size: 1.3rem; font-weight: 700; color: var(--k-ink);
	letter-spacing: -.02em; line-height: 1.05;
}
.tinfo .meta {
	font-size: 13px; color: var(--k-ink-soft); font-weight: 600;
	display: flex; gap: 14px; margin-top: 3px; flex-wrap: wrap;
}
.tinfo .meta b { color: var(--k-green); }
.tactions { display: flex; gap: 9px; margin-left: auto; flex-wrap: wrap; }
.viewtoggle {
	display: flex;
	background: var(--k-bg);
	border: 1.5px solid var(--k-line);
	border-radius: 100px; padding: 3px;
}
.viewtoggle button {
	border: none; background: transparent;
	font-family: 'Manrope', sans-serif; font-weight: 700; font-size: 13px;
	padding: 7px 14px; border-radius: 100px;
	cursor: pointer; color: var(--k-ink-soft);
}
.viewtoggle button.on { background: var(--k-green); color: #fff; }

.viewport {
	position: relative; flex: 1; min-height: 0;
	overflow: hidden; cursor: grab; touch-action: none;
	background: radial-gradient(circle at 1px 1px, var(--k-line) 1px, transparent 0) 0 0/26px 26px;
}
.viewport.drag { cursor: grabbing; }
.stage { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
.conn { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; }
.conn .marriage { fill: none; stroke: var(--k-clay); stroke-width: 2; stroke-dasharray: 5 5; opacity: .6; }

.node {
	position: absolute;
	width: 176px; height: 86px;
	background: var(--k-surface);
	border: 1.5px solid var(--k-line);
	border-radius: 15px; padding: 12px 14px;
	display: flex; gap: 11px; align-items: center;
	cursor: pointer;
	transition: box-shadow .18s, border-color .18s, transform .18s;
	box-shadow: 0 4px 14px -8px rgba(14,77,64,.3);
}
.node:hover {
	border-color: var(--k-green);
	box-shadow: 0 16px 30px -16px rgba(14,77,64,.5);
	transform: translateY(-2px);
}
.node.sel {
	border-color: var(--k-green);
	box-shadow: 0 0 0 3px var(--k-green-soft), 0 16px 30px -14px rgba(14,77,64,.55);
}
.node.founder { border-color: var(--k-clay); }
.node.founder.sel {
	box-shadow: 0 0 0 3px var(--k-clay-soft), 0 16px 30px -14px rgba(199,98,46,.5);
}
.nmono {
	width: 40px; height: 40px; border-radius: 11px;
	background: var(--k-green-soft); color: var(--k-green);
	display: flex; align-items: center; justify-content: center;
	font-family: 'Unbounded', sans-serif; font-weight: 700; font-size: 14px;
	flex: none;
}
.node.founder .nmono { background: var(--k-clay-soft); color: var(--k-clay); }
.ninfo { min-width: 0; }
.nname {
	font-weight: 700; font-size: 14.5px; line-height: 1.2;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
	color: var(--k-ink);
}
.nyears { font-size: 12.5px; color: var(--k-ink-soft); font-weight: 600; }
.crown {
	position: absolute; top: -9px; left: 14px;
	font-size: 11px; font-weight: 800; letter-spacing: .04em;
	background: var(--k-clay); color: #fff;
	padding: 2px 9px; border-radius: 100px;
}

/* ===== Список ===== */
.listview {
	position: absolute; inset: 0; overflow-y: auto;
	background: var(--k-bg); z-index: 20;
}
.lv-inner { max-width: 760px; margin: 0 auto; padding: 26px 20px 60px; }
.lv-gen { margin-bottom: 26px; }
.lv-gentitle {
	font-family: 'Unbounded', sans-serif; font-weight: 700; font-size: 13px;
	letter-spacing: .04em; text-transform: uppercase; color: var(--k-green);
	display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.lv-gentitle::after { content: ""; flex: 1; height: 1.5px; background: var(--k-line); }
.lv-gentitle span {
	background: var(--k-green-soft); color: var(--k-green);
	border-radius: 100px; padding: 1px 9px; font-size: 12px;
}
.lv-row {
	display: flex; align-items: center; gap: 13px; width: 100%;
	text-align: left; cursor: pointer;
	background: var(--k-surface); border: 1.5px solid var(--k-line);
	border-radius: 14px; padding: 11px 14px; margin-bottom: 8px;
	transition: border-color .15s, transform .15s, box-shadow .15s;
}
.lv-row:hover {
	border-color: var(--k-green); transform: translateX(3px);
	box-shadow: 0 10px 22px -16px rgba(14,77,64,.5);
}
.lv-row.founder { border-color: var(--k-clay); }
.lv-mono {
	width: 42px; height: 42px; border-radius: 11px; flex: none;
	background: var(--k-green-soft); color: var(--k-green);
	display: flex; align-items: center; justify-content: center;
	font-family: 'Unbounded', sans-serif; font-weight: 700; font-size: 14px;
}
.lv-row.founder .lv-mono { background: var(--k-clay-soft); color: var(--k-clay); }
.lv-main { min-width: 0; display: flex; flex-direction: column; }
.lv-name {
	font-weight: 700; font-size: 15px; color: var(--k-ink);
	display: flex; align-items: center; gap: 8px;
}
.lv-name em {
	font-style: normal; font-size: 10.5px; font-weight: 800; letter-spacing: .04em;
	background: var(--k-clay); color: #fff; padding: 2px 8px; border-radius: 100px;
	text-transform: uppercase;
}
.lv-sub { font-size: 13px; color: var(--k-ink-soft); font-weight: 600; }

/* ===== Веер ===== */
.fanview {
	position: absolute; inset: 0; overflow: hidden;
	background: radial-gradient(circle at 50% 50%, var(--k-surface), var(--k-bg) 70%);
	z-index: 20;
}
.fanview .fan-seg {
	stroke: var(--k-bg); stroke-width: 2; cursor: pointer;
	transition: opacity .15s, filter .15s;
}
.fanview .fan-seg:hover { opacity: .82; filter: brightness(1.08); }
.fanview .fan-lbl {
	fill: #fff; font-family: 'Manrope', sans-serif; font-weight: 700;
	font-size: 12px; pointer-events: none;
	paint-order: stroke; stroke: rgba(9,50,41,.35); stroke-width: 2.4px;
}

.zoom {
	position: absolute; right: 18px; bottom: 18px;
	display: flex; flex-direction: column; gap: 6px; z-index: 30;
}
.zoom button {
	width: 42px; height: 42px; border-radius: 12px;
	border: 1.5px solid var(--k-line); background: var(--k-surface);
	font-size: 20px; font-weight: 700; cursor: pointer;
	color: var(--k-ink);
	display: flex; align-items: center; justify-content: center;
	transition: .15s;
}
.zoom button:hover { border-color: var(--k-green); color: var(--k-green); }
#spinetoggle { border-style: dashed; }
#spinetoggle:hover { border-style: solid; }

/* Во время drag убираем дорогие эффекты — box-shadow и transition */
.viewport.drag .node {
	box-shadow: none !important;
	transition: none !important;
}

.zlabel {
	position: absolute; left: 18px; bottom: 18px;
	background: var(--k-surface); border: 1.5px solid var(--k-line);
	border-radius: 100px; padding: 8px 15px;
	font-size: 13px; font-weight: 700; color: var(--k-ink-soft); z-index: 30;
}

.hint {
	position: absolute; left: 50%; top: 16px;
	transform: translateX(-50%);
	background: rgba(9,50,41,.9); color: #fff;
	font-size: 12.5px; font-weight: 600;
	padding: 8px 16px; border-radius: 100px;
	z-index: 30; transition: opacity .4s;
}

.panel {
	position: absolute; top: 0; right: 0;
	height: 100%; width: 360px;
	background: var(--k-surface);
	border-left: 1.5px solid var(--k-line);
	box-shadow: -20px 0 50px -30px rgba(0,0,0,.4);
	transform: translateX(100%);
	transition: transform .32s cubic-bezier(.2,.7,.2,1);
	z-index: 45;
	display: flex; flex-direction: column; overflow: hidden;
}
.panel.open { transform: none; }
@media (max-width: 560px) { .panel { width: 100%; } }

.p-top {
	background: linear-gradient(150deg, var(--k-green), var(--k-green-deep));
	color: #fff; padding: 26px 24px; position: relative;
}
.p-close {
	position: absolute; top: 16px; right: 16px;
	width: 32px; height: 32px;
	border-radius: 9px; border: none;
	background: rgba(255,255,255,.16); color: #fff;
	font-size: 17px; cursor: pointer; transition: .15s;
}
.p-close:hover { background: rgba(255,255,255,.28); }
.p-mono {
	width: 62px; height: 62px; border-radius: 16px;
	background: rgba(255,255,255,.18);
	display: flex; align-items: center; justify-content: center;
	font-family: 'Unbounded', sans-serif;
	font-weight: 700; font-size: 22px; margin-bottom: 16px;
}
.p-top h2 {
	font-family: 'Unbounded', sans-serif !important;
	font-size: 1.5rem; font-weight: 700;
	margin-bottom: 4px; color: #fff; letter-spacing: -.02em;
}
.p-top .pyears { font-weight: 600; color: rgba(255,255,255,.78); font-size: 14px; }

.p-body { padding: 22px 24px; overflow-y: auto; flex: 1; }
.p-row {
	display: flex; gap: 12px;
	padding: 13px 0;
	border-bottom: 1px solid var(--k-line);
	font-size: 14.5px;
}
.p-row .k { color: var(--k-ink-faint); font-weight: 700; width: 96px; flex: none; }
.p-row .v { font-weight: 600; color: var(--k-ink); }

.p-sec {
	font-size: 12px; letter-spacing: .06em;
	text-transform: uppercase; color: var(--k-clay);
	font-weight: 800; margin: 22px 0 12px;
}
.p-note { color: var(--k-ink-soft); font-size: 14.5px; }
.p-actions {
	padding: 18px 24px;
	border-top: 1.5px solid var(--k-line);
	display: flex; gap: 9px;
}
.p-actions .btn { flex: 1; justify-content: center; }

/* ===== Мобильная версия ===== */
@media (max-width: 640px) {
	.toolbar { gap: 10px; padding: 10px 14px; }
	.tinfo h1 { font-size: 1.1rem; }
	.tinfo .meta { gap: 10px; font-size: 12px; }
	.tactions { width: 100%; margin-left: 0; }
	.viewtoggle { flex: 1; justify-content: center; }
	.viewtoggle button { flex: 1; padding: 8px 10px; }
	.zoom { right: 12px; bottom: 12px; }
	.zoom button { width: 46px; height: 46px; }
	.zlabel { left: 12px; bottom: 12px; padding: 7px 12px; }
	.hint { display: none; }
	.node { width: 156px; height: 78px; padding: 10px 12px; gap: 9px; }
	.nmono { width: 34px; height: 34px; }
	.nname { font-size: 13.5px; }
}
