:root {
  --bg: #f7f3ec; --surface: #fffdf9; --text: #2b2620; --muted: #7a6f62; --accent: #8a5a2b; --line: #e6ddd0;
  font-family: Georgia, "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1d1a16; --surface: #26221d; --text: #ede6dc; --muted: #a89b8b; --accent: #d39b62; --line: #3a342c; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.55; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem clamp(1rem, 4vw, 2.5rem); border-bottom: 1px solid var(--line); }
.brand { font-size: 1.25rem; color: var(--text); text-decoration: none; font-weight: 600; }
nav { display: flex; align-items: center; gap: 1rem; font-family: system-ui, sans-serif; font-size: .95rem; }
nav a, nav button { color: var(--accent); background: none; border: 0; cursor: pointer; font: inherit; padding: 0; text-decoration: none; }
nav form { margin: 0; }
.me { display: inline-flex; align-items: center; gap: .5rem; color: var(--muted); }
.me img { width: 28px; height: 28px; border-radius: 50%; }
main { max-width: 760px; margin: 0 auto; padding: clamp(1.5rem, 6vw, 4rem) 1rem; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.25rem); margin: 0 0 .5rem; font-weight: 500; }
.hero p { color: var(--muted); font-size: 1.15rem; }
main .card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: clamp(1.25rem, 4vw, 2.5rem); }
main .card h1 { margin-top: 0; font-weight: 500; }
.messages { max-width: 760px; margin: 1rem auto 0; padding: 0 1rem; font-family: system-ui, sans-serif; }
.msg { padding: .75rem 1rem; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.msg.error { border-color: #c0573f; }

/* ---------- древо на главной ---------- */
:root { --male: #6f8f9c; --female: #b07a82; --card-bg: var(--surface); }
body.page-tree { overflow: hidden; display: flex; flex-direction: column; height: 100dvh; }
.tree-app { position: relative; flex: 1; min-height: 0; font-family: system-ui, sans-serif; }
.tree-canvas.f3 { position: absolute; inset: 0; background: var(--bg); --background-color: var(--bg); --text-color: var(--text); font-family: inherit; }
.tree-canvas .link { stroke: color-mix(in srgb, var(--muted) 55%, transparent) !important; stroke-width: 1.5px; }

.fc-card { display: flex; align-items: center; gap: 10px; width: 210px; height: 78px; padding: 10px 12px; border-radius: 12px;
  background: var(--card-bg); color: var(--text); border: 1px solid var(--line); border-left: 4px solid var(--male);
  box-shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 14px rgb(0 0 0 / .05); cursor: pointer; transition: transform .15s, box-shadow .15s; }
.fc-card:hover { transform: translateY(-2px); box-shadow: 0 6px 22px rgb(0 0 0 / .12); }
.fc-card.fc-f { border-left-color: var(--female); }
.fc-card.fc-dead { background: color-mix(in srgb, var(--card-bg) 82%, var(--bg)); }
.fc-card.fc-self { outline: 2px solid var(--accent); outline-offset: 2px; }
.card-main .fc-card { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent), 0 8px 24px rgb(0 0 0 / .12); }
.fc-avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font: 600 15px/1 Georgia, serif;
  color: #fff; background: var(--male); letter-spacing: .5px; }
.fc-f .fc-avatar { background: var(--female); }
.fc-dead .fc-avatar { filter: saturate(.55); }
.fc-text { min-width: 0; line-height: 1.2; }
.fc-surname { font: 600 15px/1.2 Georgia, serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-given { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-life { font-size: 12px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }

.tree-status { position: absolute; top: 45%; left: 50%; translate: -50% 0; color: var(--muted); }

.tree-search { position: absolute; top: 16px; left: 16px; width: min(340px, calc(100% - 32px)); z-index: 5; }
.tree-search input { width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font: inherit; box-shadow: 0 4px 14px rgb(0 0 0 / .06); }
.tree-search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.tree-search-results { list-style: none; margin: 6px 0 0; padding: 6px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgb(0 0 0 / .12); max-height: 50vh; overflow: auto; }
.tree-search-results button { display: flex; justify-content: space-between; gap: 1rem; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font: inherit; text-align: start; cursor: pointer; }
.tree-search-results button:hover, .tree-search-results button.active { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.tree-search-results small { color: var(--muted); white-space: nowrap; }
.tree-search-results .empty { padding: 8px 10px; color: var(--muted); }

.tree-toolbar { position: absolute; bottom: 20px; left: 50%; translate: -50% 0; display: flex; gap: 4px; padding: 5px; z-index: 5;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 6px 20px rgb(0 0 0 / .1); }
.tree-toolbar button { white-space: nowrap; min-width: 40px; height: 38px; padding: 0 12px; border: 0; border-radius: 10px; background: none; color: var(--text);
  font: 500 15px/1 system-ui, sans-serif; cursor: pointer; }
.tree-toolbar button:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.tree-toolbar button[data-action^="zoom"] { font-size: 20px; }

.tree-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(380px, 100%); z-index: 6; overflow: auto; padding: 24px;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: -10px 0 30px rgb(0 0 0 / .08); }
.tree-panel-close { position: absolute; top: 12px; right: 14px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: none;
  color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; }
.tree-panel-close:hover { background: var(--bg); }
.tp-head { display: flex; gap: 14px; align-items: center; margin: 4px 0 18px; padding-right: 30px; }
.tp-avatar { flex: none; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; color: #fff; font: 600 22px Georgia, serif; background: var(--male); }
.tp-avatar.fc-f { background: var(--female); }
.tp-head h2 { margin: 0; font: 500 22px/1.2 Georgia, serif; }
.tp-head h2 span { font-size: 17px; }
.tp-life { margin: 6px 0 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.tp-fact { display: flex; flex-direction: column; padding: 10px 0; border-top: 1px solid var(--line); }
.tp-fact span { color: var(--muted); font-size: 13px; }
.tp-note { font-size: 14px; color: var(--muted); background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.tp-rel { margin-top: 18px; }
.tp-rel h3 { margin: 0 0 8px; font: 600 12px system-ui, sans-serif; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.tp-rel ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tp-chip { display: flex; justify-content: space-between; gap: 1rem; width: 100%; padding: 9px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); border-left: 3px solid var(--male); background: var(--bg); color: var(--text); font: inherit; text-align: start; }
.tp-chip.fc-f { border-left-color: var(--female); }
.tp-chip:hover { border-color: var(--accent); }
.tp-chip small { color: var(--muted); white-space: nowrap; }

@media (max-width: 720px) {
  .tree-panel { top: auto; width: 100%; max-height: 62%; border-left: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 30px rgb(0 0 0 / .12); }
  .panel-open .tree-toolbar { display: none; }
  .top { padding-block: .75rem; }
}
