/* Шажара, облик «Сад»: шалфейная подложка, белые карточки, зелёный главный цвет, круглые аватары. Сначала телефон, потом стол. */
:root {
  --bg: #F3F6F0;
  --card: #FFFFFF;
  --card-2: #EEF3ED;            /* мягкая подложка внутри белого: наведение, вложенные блоки */
  --ink: #1C2B22;
  --muted: #5A6A5F;
  --line: #E1E8E2;              /* тонкие разделители */
  --line-strong: #B5C9BC;       /* линии дерева и списка, пунктиры */
  --field: #7F998A;             /* рамка полей ввода: видна на белом */
  --acc: #2E6A4A;
  --acc-ink: #1F5138;
  --acc-soft: #E4EFE7;
  --acc-soft-2: #D5E8DC;
  --rose: #8A4A12;              /* женская линия: тёплая охра */
  --rose-line: #C77A2E;
  --rose-soft: #F7E1C8;
  --warn: #8F2E20;              /* опасное и расхождения */
  --warn-soft: #F6DEDA;
  --gold: #C77A2E;              /* внимание: счётчики, подсказки */
  --gold-soft: #F7E1C8;
  --ok-soft: #D5E8DC;
  --ok-ink: #1F5138;
  --dead-bg: #E3E8E2;
  --dead-line: #9AA89E;
  --dead-ink: #4A5A50;
  --shadow: 0 6px 20px rgba(28, 43, 34, .12);
  --r: 22px;
  --r-sm: 14px;
  --display: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --body: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 var(--body); color: var(--ink); background: var(--bg); }
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--acc-ink); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.15; }
h1 { font-size: 1.6rem; margin: 0 0 6px; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
p { margin: 0 0 10px; }
.lead { color: var(--muted); font-size: 1rem; max-width: 60ch; }
.muted { color: var(--muted); }
.small { font-size: .87rem; }
.nowrap { white-space: nowrap; }

/* шапка */
header.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(243, 246, 240, .94); backdrop-filter: blur(6px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.2rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.logo {
  display: inline-grid; place-items: center; flex: 0 0 auto; width: 40px; height: 40px; border-radius: 14px;
  background: var(--acc); color: #fff; font-weight: 700; font-size: 20px; line-height: 1;
}
.logo svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.crumb { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
@media (max-width: 480px) { body.has-tabs .top .brand span:last-child { display: none; } }

main { max-width: 920px; margin: 0 auto; padding: 8px 16px 16px; }
body.has-tabs main { padding-bottom: calc(98px + env(safe-area-inset-bottom)); }

/* вкладки: на телефоне плавают над нижним краем, на столе лежат под шапкой. Посередине профиль: круг «Я» */
nav.tabs {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 5;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center;
  min-height: 66px; padding: 0 4px; border-radius: 33px;
  background: linear-gradient(180deg, #FFFFFF 0%, #F7FAF7 100%);
  box-shadow: 0 8px 18px rgba(28, 43, 34, .16), 0 1px 2px rgba(28, 43, 34, .10);
}
nav.tabs a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 58px; font-size: .72rem; font-weight: 500; color: var(--muted); white-space: nowrap;
  transition: transform .12s ease; -webkit-tap-highlight-color: transparent;
}
nav.tabs a:hover { text-decoration: none; }
nav.tabs a:active { transform: scale(.94); }                      /* отклик на нажатие */
nav.tabs a.active { color: var(--acc-ink); font-weight: 700; }
nav.tabs .tic { position: relative; display: flex; align-items: center; justify-content: center; width: 52px; height: 30px; }
nav.tabs a.active .tic::before { content: ""; position: absolute; inset: 0; border-radius: 15px; background: linear-gradient(180deg, #EAF5ED 0%, #D2E7D9 100%); }
nav.tabs .ico { position: relative; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
nav.tabs .ico .fl { fill: none; }
nav.tabs a.active .ico { stroke-width: 2; }
nav.tabs a.active .ico .fl { fill: #CFE5D6; }                      /* у открытой вкладки значок двухцветный */
nav.tabs.pop a.active .tic::before { animation: tab-in .42s cubic-bezier(.34, 1.56, .64, 1) both; }
nav.tabs.pop a.active .ico { animation: ico-in .5s cubic-bezier(.34, 1.56, .64, 1) both; }
.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 999px; background: var(--gold-soft); color: var(--rose); font-size: .68rem; font-weight: 700; text-align: center; font-family: var(--body); }
nav.tabs .badge { position: absolute; left: 30px; top: -4px; height: 17px; line-height: 17px; padding: 0 5px; background: #C2531B; color: #fff; font-size: 10px; box-shadow: 0 0 0 2px #fff; }

/* профиль в меню: полоса поднимается выступом вокруг круга «Я»; кольцо показывает, насколько заполнена анкета */
nav.tabs a.me { align-self: stretch; min-height: 66px; }
nav.tabs a.me:active { transform: none; }
nav.tabs .hump { position: absolute; left: 50%; top: -17px; margin-left: -48px; width: 96px; height: 18px; fill: #fff; filter: drop-shadow(0 -1px 1px rgba(28, 43, 34, .05)); pointer-events: none; }
.mering {
  position: absolute; left: 50%; top: -12px; margin-left: -28px; width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: conic-gradient(#E9A23B 0 var(--p, 0%), #D0E2D6 var(--p, 0%) 100%);
  box-shadow: 0 4px 10px rgba(46, 106, 74, .26); transition: transform .12s ease;
}
.mering::after {                                                   /* пока анкета не полна, круг мягко «дышит» */
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none; opacity: 0;
  box-shadow: 0 7px 18px rgba(46, 106, 74, .5), 0 0 0 5px rgba(46, 106, 74, .10); animation: me-breathe 3.2s ease-in-out infinite;
}
.mering.full { background: #9CCBAE; }
.mering.full::after { animation: none; }
nav.tabs a.me:active .mering { transform: scale(.93); }
.mebtn {
  position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 50%;
  background: linear-gradient(145deg, #429069 0%, #2E6A4A 52%, #22523A 100%); color: #fff; font-size: 19px; font-weight: 700; line-height: 1;
  box-shadow: 0 0 0 2px #fff, inset 0 1px 0 rgba(255, 255, 255, .38);
}
.mebtn.long { font-size: 13px; }
nav.tabs a.me.active .mebtn { box-shadow: 0 0 0 2px #fff, inset 0 0 0 2px var(--acc), inset 0 0 0 4.5px #fff; }
.me-label { display: none; }
@keyframes tab-in { from { transform: scaleX(.4); opacity: 0; } to { transform: scaleX(1); opacity: 1; } }
@keyframes ico-in { from { transform: translateY(6px) scale(.78); } to { transform: translateY(0) scale(1); } }
@keyframes me-breathe { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { nav.tabs *, nav.tabs *::before, nav.tabs *::after { animation: none !important; transition: none !important; } }
@media (min-width: 720px) {
  body.has-tabs main { padding-bottom: 32px; }
  nav.tabs {
    position: sticky; top: 60px; bottom: auto; left: auto; right: auto; display: flex; justify-content: flex-start; gap: 4px;
    min-height: 0; max-width: 888px; margin: 0 auto 4px; padding: 6px; border-radius: 28px; box-shadow: none; background: var(--card);
  }
  nav.tabs a { flex: 0 0 auto; flex-direction: row; gap: 8px; min-height: 0; font-size: .92rem; padding: 8px 14px; border-radius: 22px; }
  nav.tabs a.active { background: var(--acc-soft); }
  nav.tabs .tic { display: contents; }                             /* значок и счётчик встают в ряд вкладки, счётчик после подписи */
  nav.tabs a.active .tic::before { display: none; }
  nav.tabs .ico { width: 18px; height: 18px; }
  nav.tabs .badge { position: static; order: 3; box-shadow: none; }
  nav.tabs a.me { order: 9; margin-left: auto; align-self: auto; min-height: 0; padding: 4px 14px 4px 5px; }
  nav.tabs .hump { display: none; }
  .mering { position: static; margin: 0; width: 32px; height: 32px; box-shadow: none; }
  .mering::after { display: none; }
  .mebtn { width: 26px; height: 26px; font-size: 12px; box-shadow: 0 0 0 1.5px #fff; }
  .mebtn.long { font-size: 9px; }
  nav.tabs a.me.active .mebtn { box-shadow: 0 0 0 1.5px #fff; }
  .me-label { display: inline; }
}

/* кнопки и поля */
.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 8px 18px; border-radius: 23px;
  border: none; background: var(--acc-soft); color: var(--acc-ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
}
.btn:hover { text-decoration: none; background: var(--acc-soft-2); }
.btn.primary { background: var(--acc); color: #fff; }
.btn.primary:hover { background: var(--acc-ink); }
.btn.ghost { background: var(--card); color: var(--ink); }
.btn.ghost:hover { background: var(--card-2); }
.card .btn.ghost, .sheet .btn.ghost, .people .btn.ghost, .fb-panel .btn.ghost, .tour-tip .btn.ghost, .timeline .btn.ghost { background: var(--bg); }
.card .btn.ghost:hover, .sheet .btn.ghost:hover { background: var(--acc-soft); }
.card.soft .btn.ghost, .card.soft .btn:not(.primary):not(.danger) { background: var(--card); }
.btn.small { min-height: 38px; padding: 4px 14px; border-radius: 19px; font-size: .9rem; font-weight: 500; white-space: nowrap; }
.btn.wide { flex: 1; }
.btn.chip { min-height: 38px; border-radius: 999px; padding: 6px 14px; background: var(--acc-soft); color: var(--acc-ink); }
button.link { background: none; border: none; color: var(--muted); padding: 0 4px; font: inherit; text-decoration: underline; cursor: pointer; }
.icon-btn, .icon-link {
  display: inline-grid; place-items: center; flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%;
  border: none; background: var(--card); color: var(--ink); cursor: pointer; font: inherit; font-size: 20px;
}
.icon-btn:hover, .icon-link:hover { background: var(--acc-soft); text-decoration: none; }
.card .icon-btn, .sheet .icon-btn, .tour-pill .icon-btn { background: var(--bg); }
.icon-btn.small { width: 36px; height: 36px; font-size: 18px; }
.icon-btn svg, .icon-link svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
input, select, textarea {
  font: inherit; font-size: 16px; min-height: 46px; padding: 8px 14px; border: 1.5px solid var(--field); border-radius: var(--r-sm);
  background: #fff; color: var(--ink); width: 100%;
}
.card input, .card select, .card textarea { background: #F7F9F6; }
textarea { resize: vertical; }
input[type="file"] { padding: 6px; font-size: .9rem; color: var(--muted); }
input[type="file"]::file-selector-button { margin-right: 10px; padding: 7px 14px; border: none; border-radius: 17px; background: var(--acc-soft); color: var(--acc-ink); font: inherit; font-weight: 600; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--acc); }
input, textarea { caret-color: var(--acc); }
input::placeholder, textarea::placeholder { color: #64746A; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft-2); background: #fff; }
input { min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row input { flex: 1 1 160px; width: auto; }
.row select { width: auto; max-width: 100%; min-width: 0; flex: 1 1 160px; }
.inline { display: inline; }
.search { margin-bottom: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 14px; }

/* анкета */
.anketa .fld { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; align-items: center; padding: 7px 0; }
.anketa .fld > label { font-size: .87rem; font-weight: 500; color: var(--muted); }
.anketa .fld.custom { grid-template-columns: 1fr 1fr; padding: 4px 0; }
.seg { display: flex; gap: 4px; padding: 4px; background: var(--acc-soft); border-radius: 26px; }
.seg.wrap { flex-wrap: wrap; border-radius: 24px; }
.seg-opt { flex: 1; }
.seg.wrap .seg-opt { flex: 0 0 auto; }
.seg-opt input { position: absolute; opacity: 0; width: 0; height: 0; min-height: 0; }
.seg-opt span { display: block; text-align: center; padding: 10px 12px; border-radius: 22px; color: var(--acc-ink); font-weight: 500; cursor: pointer; }
.seg-opt input:checked + span { background: var(--acc); color: #fff; font-weight: 600; }
.seg-opt input:focus-visible + span { outline: 2px solid var(--acc-ink); outline-offset: 2px; }
.save-bar { position: sticky; bottom: calc(84px + env(safe-area-inset-bottom)); display: flex; gap: 8px; padding: 10px 0; background: linear-gradient(transparent, var(--bg) 30%); }
@media (min-width: 720px) { .save-bar { bottom: 0; } }
.save-bar .btn { padding-left: 14px; padding-right: 14px; white-space: nowrap; }
@media (max-width: 400px) { .save-bar .btn { padding-left: 11px; padding-right: 11px; font-size: .92rem; } }
body.tg-main .save-bar { display: none; }            /* в Telegram кнопка родная, внизу экрана */
body.tg-main.has-tabs main { padding-bottom: calc(98px + env(safe-area-inset-bottom)); }
@media (max-width: 719px) {
  body.kbd nav.tabs, body.kbd .fb-btn, body.kbd .fb-panel { display: none; }
  body.kbd.has-tabs main { padding-bottom: 24px; }
  body.kbd .save-bar { position: static; background: none; }
  body:has(.save-bar) .fb-btn { bottom: calc(152px + env(safe-area-inset-bottom)); }
}
@media (min-width: 720px) { body:has(.save-bar) .fb-btn { bottom: 76px; } }
.preview { background: var(--gold-soft); color: var(--rose); border-radius: var(--r-sm); padding: 8px 12px; margin: 10px 0 0; font-size: .95rem; }
@media (max-width: 560px) {
  .anketa .fld { grid-template-columns: 1fr; gap: 4px; }
}

/* карточки */
.card { background: var(--card); border-radius: var(--r); padding: 16px; margin-bottom: 12px; }
.card.soft { background: var(--acc-soft); }
.cards { list-style: none; padding: 0; margin: 0; }
.flash { background: var(--ok-soft); color: var(--ok-ink); border-radius: 16px; padding: 10px 14px; margin-bottom: 12px; font-weight: 500; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 12px; margin: 18px 0 8px; }
.section-head h1, .section-head h2 { margin: 0; }
.tag { display: inline-block; font-size: .78rem; font-weight: 600; padding: 3px 10px; border-radius: 12px; background: var(--acc-soft); color: var(--acc-ink); max-width: 100%; overflow-wrap: anywhere; line-height: 1.5; }
.card.soft .tag { background: var(--card); }
.tag.short { white-space: nowrap; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.gold { background: var(--acc); color: #fff; }            /* «это вы» */

/* аватары, люди */
.avatar {
  display: inline-grid; place-items: center; flex: 0 0 auto; overflow: hidden;
  width: 44px; height: 44px; border-radius: 50%; font-weight: 700; font-size: 1.1rem;
  background: var(--acc-soft-2); color: var(--acc-ink);
}
.avatar.f { background: var(--rose-soft); color: var(--rose); }
.avatar.dead { background: var(--dead-bg); color: var(--dead-ink); }
.avatar.me { background: var(--acc); color: #fff; }
.avatar.big { width: 92px; height: 92px; font-size: 2.2rem; box-shadow: 0 0 0 4px var(--bg), 0 0 0 6px var(--line-strong); }
.avatar.photo { object-fit: cover; }
.album { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-bottom: 10px; }
.shot { margin: 0; min-width: 0; }
.shot img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-sm); background: var(--card-2); }
.shot.main img { outline: 2px solid var(--acc); outline-offset: 2px; }
.shot figcaption { display: flex; flex-wrap: wrap; gap: 2px 8px; margin-top: 6px; font-size: .82rem; }
.shot figcaption button.link { padding: 0; }
.upload input[type=file] { max-width: 100%; }
.people { list-style: none; padding: 4px 0; margin: 0; background: var(--card); border-radius: var(--r); overflow: hidden; }
.people li + li { border-top: 1px solid var(--line); }
.person-row, .cover { display: flex; align-items: center; gap: 12px; padding: 10px 16px; color: inherit; }
.person-row:hover, .cover:hover { text-decoration: none; background: var(--card-2); }
.person-row .body, .cover .body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.person-row strong, .cover strong { overflow-wrap: anywhere; font-weight: 600; font-size: 1rem; line-height: 1.25; }
.chev { color: var(--muted); font-size: 1.4rem; }
.tree-card { padding: 4px 0; overflow: hidden; }

/* дом и старт */
.hero { padding: 8px 0 18px; }
.hero .btn { margin-top: 6px; margin-right: 6px; }
.hero .btn + .btn { margin-left: 0; }                           /* на новой строке кнопка не съезжает вправо */
.start .card { padding: 18px; }
.step label { display: block; font-weight: 700; font-size: 1.25rem; margin: 6px 0 10px; }
.small-actions { margin-top: 8px; }
.mini-chain { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-direction: column; align-items: flex-start; }
.mini-chain li { position: relative; padding-left: 22px; }
.mini-chain li::before { content: ""; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: var(--line-strong); }
.mini-chain li:first-child::before { top: 50%; }
.mini-chain li:last-child::before { bottom: 50%; }
.mini-chain li::after { content: ""; position: absolute; left: 4px; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; background: var(--acc); }
.mini-node { display: inline-block; margin: 4px 0; padding: 7px 14px; border-radius: 18px; background: var(--acc-soft); color: var(--acc-ink); font-weight: 600; }
.mini-node.me { background: var(--acc); color: #fff; }

/* дерево */
.lineage-note { background: var(--rose-soft); color: var(--rose); border-radius: var(--r-sm); padding: 8px 12px; margin: 0 0 10px; }
.lineage-note a { color: var(--rose); text-decoration: underline; }
.tree-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.stats { display: flex; gap: 14px; color: var(--muted); font-size: .92rem; }
.stats b { color: var(--ink); }
.viewport-wrap { position: relative; }
.viewport {
  overflow: auto; height: min(62vh, 560px); border-radius: var(--r);
  background: var(--card); cursor: grab; touch-action: pan-x pan-y;
}
.viewport.dragging { cursor: grabbing; }
.viewport, .viewport svg, .viewport svg text { user-select: none; -webkit-user-select: none; }
.viewport svg { display: block; }
.viewport .node { cursor: pointer; }
.zoom { display: flex; gap: 8px; justify-content: flex-end; margin: 8px 0 0; }   /* под деревом, ничего не закрывает */
@media (max-width: 719px) { .viewport { height: min(54vh, 500px); } .zoom { justify-content: space-between; } .zoom .icon-btn { flex: 1 1 auto; border-radius: 22px; } }

/* полный экран: системный или накладка */
.viewport-wrap.full, .viewport-wrap:fullscreen {
  position: fixed; inset: 0; z-index: 50; background: var(--card);
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}
.viewport-wrap.full .viewport, .viewport-wrap:fullscreen .viewport { height: 100%; border-radius: 0; }
.viewport-wrap.full .zoom, .viewport-wrap:fullscreen .zoom { position: absolute; margin: 0; bottom: calc(14px + env(safe-area-inset-bottom, 0)); right: 14px; justify-content: flex-end; }
.viewport-wrap.full .zoom .icon-btn, .viewport-wrap:fullscreen .zoom .icon-btn { flex: 0 0 auto; border-radius: 50%; background: var(--bg); }
.exit-full { position: absolute; top: calc(12px + env(safe-area-inset-top, 0)); right: 14px; z-index: 51; min-height: 38px; padding: 6px 14px; box-shadow: var(--shadow); }
.viewport-wrap.full .sheet, .viewport-wrap:fullscreen .sheet { bottom: calc(70px + env(safe-area-inset-bottom, 0)); }
body.has-full { overflow: hidden; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 6px 0 4px; padding: 0; list-style: none; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend li.wide { white-space: normal; flex: 1 1 100%; }
.legend-box { margin: 4px 0 10px; }
.legend-box > summary { cursor: pointer; font-size: .87rem; color: var(--muted); list-style: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 0; }
.legend-box > summary::-webkit-details-marker { display: none; }
.legend-box > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; }
.legend-box[open] > summary::before { transform: rotate(45deg); }
.tree-hint { margin: 8px 0 0; }
details.more > .anketa { margin: 0 16px 10px; }
details.more > p { margin-left: 16px; margin-right: 16px; }
.loose .fld > label:empty { display: none; }
.sw { display: inline-block; width: 16px; height: 16px; border-radius: 50%; background: var(--acc-soft-2); vertical-align: -3px; }
.sw.f { background: var(--rose-soft); }
.sw.d { background: var(--dead-bg); }
.sw.e { background: transparent; border: 1.5px dashed var(--dead-line); }
.sw.x { background: var(--acc); box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--acc); }
.sw.t { width: auto; height: auto; padding: 0 6px; border-radius: 999px; background: var(--acc); color: #fff; font-size: .7rem; line-height: 1.4; }
.ln { display: inline-block; width: 26px; height: 0; border-top: 2px solid var(--line-strong); vertical-align: middle; }
.ln.dash { border-top-style: dashed; border-color: var(--acc); }

/* меню по нажатию на человека */
.sheet {
  position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 3;
  background: var(--card); border-radius: 26px;
  padding: 14px 14px 16px; box-shadow: 0 -2px 30px rgba(28, 43, 34, .24);
}
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sheet-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sheet-title b { font-size: 1.05rem; line-height: 1.2; }
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet-grid .btn { min-height: 44px; padding: 6px 10px; font-size: .92rem; }
.sheet-grid .btn.primary { grid-column: 1 / -1; min-height: 46px; font-size: 1rem; }
.sheet-grid form { display: contents; }
.sheet-grid form .btn { width: 100%; }

/* вопросы */
.question .q-text { font-weight: 700; font-size: 1.1rem; margin-bottom: 2px; }
.question .q-hint { margin-bottom: 10px; }
.q-form { display: flex; flex-direction: column; gap: 10px; }      /* поля и кнопки формы с зазором, где бы форма ни стояла */
.q-form > label { margin-bottom: -4px; }
.question .q-link { display: inline-block; margin-top: 8px; }

/* карточка человека: аватар и имя по центру; в формах шапка строкой */
.profile { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; margin: 10px 0 14px; }
.profile.compact { flex-direction: row; align-items: center; text-align: left; margin: 4px 0 10px; }
.profile.compact .avatar.big { width: 56px; height: 56px; font-size: 1.4rem; box-shadow: none; }
.profile h1 { margin: 0 0 4px; font-size: 1.5rem; line-height: 1.15; }
.profile h1.long { font-size: 1.3rem; }
.profile .also { margin-bottom: 2px; }
.profile .meta { color: var(--muted); line-height: 1.4; }
.profile-text { min-width: 0; max-width: 100%; }
.profile .tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 8px; }
.profile.compact .tags { justify-content: flex-start; }
.profile .tags:empty { display: none; }
.profile-text .tag { margin: 0; }
.profile .avatar.big { flex: 0 0 auto; }
.rel-grid { display: flex; flex-direction: column; gap: 10px; }
.rel-row { display: grid; grid-template-columns: 130px 1fr; gap: 8px; align-items: baseline; }
.rel-label { color: var(--muted); font-size: .87rem; font-weight: 500; }
.rel-order { margin-left: 6px; font-weight: 600; }
.rel-value { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 16px;
  background: var(--acc-soft); color: var(--acc-ink); font-weight: 600; font-size: .92rem;
}
.chip.f { background: var(--rose-soft); color: var(--rose); }
.chip.empty { background: transparent; border: 1.5px dashed var(--line-strong); color: var(--muted); font-weight: 500; }
.chip-wrap { display: inline-flex; align-items: center; gap: 4px; }
.chip-x { border: none; background: var(--warn-soft); color: var(--warn); border-radius: 50%; width: 28px; height: 28px; line-height: 1; font: inherit; font-weight: 700; cursor: pointer; padding: 0; }
.rel-grid .rel-only { display: none; }
.rel-grid.editing .rel-only { display: inline-flex; }
.section-head.tight { margin: 0 0 10px; align-items: center; }
.section-head.tight h2 { flex: 1 1 auto; }
.section-head.tight .btn, .section-head.tight form { flex: 0 0 auto; white-space: nowrap; }
.chip:hover { text-decoration: none; filter: brightness(.96); }
.horizon { margin-top: 12px; }
.facts { margin: 0; }
.fact { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.fact:last-child { border-bottom: none; }
.fact dt { color: var(--muted); font-size: .87rem; font-weight: 500; padding-top: 1px; }
.fact dd { margin: 0; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.fact-item { display: flex; flex-direction: column; gap: 1px; }
.answer { display: block; background: var(--bg); border-radius: var(--r-sm); padding: 8px 12px; margin: 4px 0 2px; }
details.ask { margin-top: 8px; }
details.ask > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; font-weight: 600; color: var(--acc-ink); }
details.ask > summary::-webkit-details-marker { display: none; }
details.ask > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--acc-ink); border-bottom: 2px solid var(--acc-ink); transform: rotate(-45deg); transition: transform .15s; }
details.ask[open] > summary::before { transform: rotate(45deg); }
details.ask form { margin-top: 8px; }
.fact-item.alt { padding-left: 10px; border-left: 2px solid var(--line-strong); }
.fact-item.alt .fact-value { color: var(--muted); }
.fact-value { white-space: pre-line; }
.fact-meta:empty { display: none; }
.fact dd .tag { margin-top: 2px; }
@media (max-width: 560px) {
  .rel-row, .fact { grid-template-columns: 1fr; gap: 3px; }
}
/* удаление и ошибки */
.btn.danger { background: var(--warn-soft); color: var(--warn); }
.btn.danger:hover { background: #F0CEC8; }
.danger-text { color: var(--warn) !important; }
.avatar.danger { background: var(--warn-soft); color: var(--warn); }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 22px; height: 22px; min-height: 0; margin-top: 1px; flex: 0 0 auto; }
.muted-card .cover { cursor: default; }
.muted-card strong { color: var(--muted); }
.settings { margin-top: 18px; }

/* «Неудобно?» */
.fb-btn {
  position: fixed; left: 12px; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 6;
  padding: 7px 14px; border-radius: 999px; border: none; background: var(--card);
  color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; box-shadow: 0 2px 10px rgba(28, 43, 34, .14);
}
@media (min-width: 720px) { .fb-btn { bottom: 16px; } }
.fb-panel {
  position: fixed; left: 12px; right: 12px; bottom: calc(134px + env(safe-area-inset-bottom)); z-index: 7;
  max-width: 420px; background: var(--card); border-radius: var(--r);
  padding: 14px; box-shadow: 0 10px 30px rgba(28, 43, 34, .25); display: flex; flex-direction: column; gap: 8px;
}
.fb-panel textarea { background: #F7F9F6; }
@media (min-width: 720px) { .fb-panel { bottom: 60px; } }

/* сводка для админа */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-bottom: 12px; }
.tile { background: var(--bg); border-radius: 16px; padding: 10px 12px; display: flex; flex-direction: column; }
.tile b { font-size: 1.6rem; line-height: 1.1; }
.tile span { color: var(--muted); font-size: .82rem; }
.tile.bad b { color: var(--warn); }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; padding-top: 8px; overflow-x: auto; }
.bar { flex: 1 0 14px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar i { display: block; width: 100%; min-height: 2px; background: var(--acc); border-radius: 4px 4px 0 0; opacity: .85; }
.bar span { font-size: .62rem; color: var(--muted); margin-top: 2px; }
.tablewrap { overflow-x: auto; }
.fb-quote { margin: 0 0 10px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--bg); }
.fb-quote p { margin: 0 0 4px; white-space: pre-line; }

/* панель администратора: тёмная шапка, боковая навигация на столе, вкладки сверху на телефоне */
body.admin { background: var(--bg); }
.adm-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 18px; background: #1C2B22; color: #E4EFE7; }
.adm-brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 1.2rem; }
.adm-brand:hover { text-decoration: none; }
.logo.dark { background: #E4EFE7; color: #1C2B22; }
.adm-tag { font-size: .8rem; font-weight: 400; color: #B5C9BC; margin-left: 6px; }
.adm-exit { color: #D5E8DC; font-size: .9rem; white-space: nowrap; }
.adm-shell { display: grid; grid-template-columns: 200px 1fr; gap: 20px; max-width: 1180px; margin: 0 auto; padding: 18px 16px 40px; }
.adm-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 14px; align-self: start; }
.adm-nav a { padding: 9px 14px; border-radius: 18px; color: var(--ink); }
.adm-nav a:hover { background: var(--acc-soft); text-decoration: none; }
.adm-nav a.active { background: var(--acc); color: #fff; }
.adm-main { min-width: 0; max-width: none; margin: 0; padding: 0; }
.adm-main .card { overflow-x: auto; }                /* широкая таблица прокручивается в карточке, а не тащит страницу вбок */
@media (max-width: 760px) {
  .adm-shell { grid-template-columns: 1fr; gap: 12px; }
  .adm-nav { flex-direction: row; overflow-x: auto; position: static; gap: 4px; padding-bottom: 4px; }
  .adm-nav a { white-space: nowrap; background: var(--card); }
  .adm-tag { display: none; }
}
.sys-link { margin-top: 24px; }

/* экспорт */
.export-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.export-item { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 16px; background: var(--bg); color: var(--ink); }
.export-item:hover { text-decoration: none; background: var(--acc-soft); }
.export-item b { font-size: 1.05rem; color: var(--ink); }
.export-item span { color: var(--muted); font-size: .88rem; }
.export-item.primary { background: var(--acc); }
.export-item.primary:hover { background: var(--acc-ink); }
.export-item.primary b, .export-item.primary span { color: #fff; }

/* переключатель вида */
.view-switch { display: inline-flex; gap: 4px; padding: 4px; background: var(--card); border-radius: 26px; }
.seg-link { padding: 10px 16px; border-radius: 22px; color: #3D4F44; font-weight: 500; text-align: center; }
.seg-link:hover { text-decoration: none; background: var(--card-2); }
.seg-link.on, .seg-link.on:hover { background: var(--acc); color: #fff; font-weight: 600; }

/* дерево списком */
.outline { padding: 2px 2px 2px 0; overflow-x: auto; }
.ol-list { list-style: none; margin: 0; padding: 0 0 0 22px; position: relative; }
.ol-list.ol-root { padding-left: 2px; }
.ol-list:not(.ol-root)::before { content: ""; position: absolute; left: 9px; top: 0; bottom: 26px; border-left: 2px solid var(--line-strong); }
.ol-item { position: relative; margin: 8px 0; }
.ol-list:not(.ol-root) > .ol-item::before { content: ""; position: absolute; left: -13px; top: 28px; width: 13px; border-top: 2px solid var(--line-strong); }
.ol-card {
  display: flex; align-items: center; gap: 10px; width: fit-content; min-width: 280px; max-width: 520px;
  background: var(--card); border-radius: 18px; padding: 10px 14px 10px 12px; cursor: pointer;
  box-shadow: inset 4px 0 0 var(--branch, var(--acc));
}
.ol-card.empty { outline: 1.5px dashed var(--line-strong); outline-offset: -1.5px; }
.ol-card.focus { box-shadow: inset 4px 0 0 var(--branch, var(--acc)), 0 0 0 2px var(--line-strong); }
.ol-card.me { box-shadow: inset 4px 0 0 var(--acc), 0 0 0 2px var(--acc); }
.ol-av { width: 40px; height: 40px; font-size: 1rem; }
.ol-body { min-width: 0; }
.ol-toggle {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 3px;
  min-width: 30px; height: 30px; padding: 0 8px; border: none; border-radius: 15px;
  background: var(--acc-soft); color: var(--acc-ink); font: inherit; font-size: .75rem; font-weight: 700; cursor: pointer;
}
.ol-toggle:hover { background: var(--acc-soft-2); }
.ol-toggle .chev { display: inline-block; width: 7px; height: 7px; border-right: 2px solid var(--acc-ink); border-bottom: 2px solid var(--acc-ink); transform: rotate(45deg); margin-top: -3px; transition: transform .15s; }
.ol-toggle .ol-count { display: none; }
.ol-item.collapsed > .ol-card .ol-toggle .chev { transform: rotate(-45deg); margin-top: 0; }
.ol-item.collapsed > .ol-card .ol-toggle .ol-count { display: inline; }
.ol-item.collapsed > .ol-card .ol-toggle { background: var(--acc); color: #fff; }
.ol-item.collapsed > .ol-card .ol-toggle .chev { border-color: #fff; }
.ol-item.collapsed > .ol-list { display: none; }
.ol-head { display: block; }                          /* галочка идёт сразу за именем, годы отдельной строкой */
.ol-head .verified, .ol-head .dot { margin-left: 4px; }
.ol-head .tag { margin-top: 3px; }
.ol-name { font-weight: 600; font-size: 1rem; color: var(--ink); }
.ol-card.dead .ol-name { color: var(--muted); }
.ol-years { display: block; color: var(--muted); font-size: .87rem; font-variant-numeric: tabular-nums; }
.ol-spouses { margin-top: 4px; font-size: .87rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chip.small { padding: 2px 10px; font-size: .85rem; }
/* супруги в списке: длинные имена переносятся, поэтому не пилюля, а плашка с малым скруглением */
.ol-spouses .chip { border-radius: 12px; padding: 4px 10px; line-height: 1.3; text-align: left; white-space: normal; display: inline-block; }
.ol-sub { color: var(--muted); font-size: .87rem; margin-top: 2px; }
@media (max-width: 560px) {
  .ol-list { padding-left: 10px; }
  .ol-list:not(.ol-root)::before { left: 3px; }
  .ol-list:not(.ol-root) > .ol-item::before { left: -7px; width: 7px; }
  .ol-card { min-width: 232px; gap: 8px; padding: 9px 12px 9px 10px; }
  .ol-av { width: 36px; height: 36px; font-size: .95rem; }
  .ol-toggle { min-width: 28px; height: 28px; padding: 0 6px; }
}

.priv-row { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.priv-val { font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.priv-row .btn.small { width: auto; padding: 2px 12px; }

/* панель над деревом: на телефоне две ровные строки, на столе одна */
.tree-tools { display: grid; gap: 8px; margin: 6px 0 8px; }
.tree-tools .view-switch { display: grid; grid-template-columns: repeat(3, 1fr); }
.tree-tools .collapse-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tree-tools .collapse-row .btn { padding-left: 6px; padding-right: 6px; white-space: nowrap; }
.collapse-note { margin: 0 0 6px; }
@media (min-width: 720px) {
  .tree-tools { grid-template-columns: auto 1fr; align-items: center; }
  .tree-tools .view-switch { display: inline-grid; }
  .tree-tools .collapse-row { display: flex; }
}
.settings .actions-row { margin-top: 6px; }
.settings .actions-row .btn { margin: 0; }
@media (max-width: 719px) { .settings .actions-row { align-items: stretch; } .settings .actions-row .btn, .settings .actions-row form { flex: 1 1 130px; } .settings .actions-row .btn { display: flex; align-items: center; justify-content: center; text-align: center; padding-left: 8px; padding-right: 8px; font-size: .9rem; } .settings .actions-row .btn.wide-m { flex-basis: 100%; } .settings .actions-row form { display: flex; } .settings .actions-row form .btn { width: 100%; } }

/* кнопки под шапкой карточки: на телефоне заполняют строки ровно */
@media (max-width: 719px) {
  .actions { gap: 8px; }
  .actions > .btn, .actions > form { flex: 1 1 140px; }
  .actions .btn { padding-left: 10px; padding-right: 10px; }
  .actions > form .btn { width: 100%; }
}
@media (min-width: 720px) { .profile:not(.compact) + .actions, .profile:not(.compact) ~ .actions { justify-content: center; } }

/* в сети: зелёная точка у тех, кто был в приложении последние пять минут */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); vertical-align: middle; margin-left: 4px; }
.dot.online { background: #2E9D5F; box-shadow: 0 0 0 2px #DFF2E6; }
.tag .dot { margin: 0 2px 0 0; }
.tag.online { background: #DFF2E6; color: #245C3A; }
.tag.online .dot { background: #2E9D5F; }
.online-text { color: #245C3A; font-weight: 700; }
.verified.online-badge { background: #2E9D5F; }

/* подтвердил себя: вошёл через Telegram и отметил «это я» */
.verified { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: var(--acc); color: #fff; font-size: 11px; font-weight: 700; line-height: 1; vertical-align: middle; margin-left: 4px; flex: 0 0 auto; }
.chip .verified { width: 14px; height: 14px; font-size: 10px; }
.tag .verified { margin: 0 2px 0 0; width: 14px; height: 14px; font-size: 10px; }
.verified.linked { background: var(--rose-line); }
.link-row { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.link-row:last-of-type { border-bottom: 0; }
.link-row .body { flex: 1 1 240px; }
.link-code { display: inline-block; font-size: 1.5rem; letter-spacing: .16em; padding: 6px 14px; background: var(--bg); border: 1.5px dashed var(--line-strong); border-radius: var(--r-sm); margin: 2px 0 8px; }
.code-box { padding: 8px 0 4px; border-top: 1px solid var(--line); margin-top: 6px; }
.link-row .link-break { flex: 0 0 auto; }
.link-decide { margin-top: 8px; }
details.more.plain { background: none; padding: 0; margin-top: 8px; }
details.more.plain > summary { padding: 6px 0; }
details.more.plain > form { margin: 0; }

.send-box { margin-top: 14px; }

.lang-switch { text-align: center; margin: 22px 0 64px; }
.lang-switch a { color: var(--muted); }

/* меню по тапу в списке и ленте: поверх страницы, над вкладками */
.sheet-wrap .sheet { position: fixed; left: 8px; right: 8px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 30; box-shadow: 0 8px 30px rgba(28, 43, 34, .24); }
@media (min-width: 720px) { .sheet-wrap .sheet { bottom: 16px; max-width: 520px; margin: 0 auto; } }

/* рассказы */
.tale { padding: 10px 0; border-top: 1px solid var(--line); }
.tale:first-of-type { border-top: 0; }
.tale-title { font-weight: 600; margin-bottom: 4px; }
.tale audio { width: 100%; max-width: 420px; display: block; margin: 2px 0 4px; }
.tale-text { margin: 0 0 4px; white-space: pre-wrap; }

/* лента времени */
.timeline { margin-top: 8px; background: var(--card); border-radius: var(--r); padding: 8px 14px 14px; overflow-x: clip; }
.tl-axis, .tl-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 6px; }
.tl-axis { position: sticky; top: 0; background: var(--card); z-index: 2; padding: 6px 0; border-bottom: 1px solid var(--line); }
.tl-axis .tl-track { position: relative; height: 16px; background-image: none; }
.tl-axis i { position: absolute; top: 0; font-style: normal; font-size: .72rem; color: var(--muted); transform: translateX(-50%); }
.tl-axis i:first-child { transform: none; }
.tl-axis i:last-child { transform: translateX(-100%); }
.tl-gen { font-size: .78rem; color: var(--muted); margin: 12px 0 4px; padding-top: 8px; border-top: 1px solid var(--line); }
.tl-axis + .tl-gen { border-top: 0; margin-top: 4px; }
.tl-row { padding: 2px 0; border-radius: 10px; cursor: pointer; }
.tl-row.on { background: var(--acc-soft); }
.tl-label { font-size: .86rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-track { position: relative; height: 22px; background-image: linear-gradient(to right, var(--line) 1px, transparent 1px); background-size: 25% 100%; }
.tl-bar { position: absolute; top: 4px; height: 14px; border-radius: 7px; background: var(--acc-soft-2); border: 1.5px solid var(--acc); box-sizing: border-box; overflow: visible; }
.tl-bar.f { background: var(--rose-soft); border-color: var(--rose-line); }
.tl-bar.dead { background: var(--dead-bg); border-color: var(--dead-line); }
.tl-bar.est { border-style: dashed; background: transparent; }
.tl-row.me .tl-bar { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--acc); }
.tl-bar b { position: absolute; left: 100%; top: -3px; margin-left: 6px; font-size: .7rem; font-weight: 400; color: var(--muted); white-space: nowrap; }
.tl-bar.right b { left: auto; right: 100%; margin-left: 0; margin-right: 6px; }
.sh-facts { display: block; margin-top: 4px; color: var(--ink); }
@media (max-width: 719px) { .tl-axis, .tl-row { grid-template-columns: 88px minmax(0, 1fr); } .tl-label { font-size: .76rem; } }

/* портрет рода */
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.metric { display: flex; flex-direction: column; gap: 2px; background: var(--card); border-radius: 18px; padding: 12px 14px; min-width: 0; }
.metric b { font-size: 1.9rem; line-height: 1.1; color: var(--ink); }
.metric .k { font-size: .82rem; color: var(--muted); }
.metric .plain { color: inherit; }
.name-bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 28px; align-items: center; gap: 8px; }
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { display: block; height: 12px; background: var(--bg); border-radius: 6px; }
.bar-fill { display: block; height: 12px; border-radius: 6px; background: var(--acc); }
.bar-fill.f { background: var(--rose-line); }
.bar-n { text-align: right; color: var(--muted); }
.cols { display: flex; align-items: flex-end; gap: 10px; padding: 6px 0 4px; overflow-x: auto; }
.col { flex: 1 0 56px; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 56px; }
.col-v { font-weight: 700; }
.col-bar { display: block; width: 100%; background: var(--acc); border-radius: 8px 8px 0 0; }
.col-l { font-size: .74rem; color: var(--muted); text-align: center; line-height: 1.1; }
.btn-row.stack { flex-direction: column; align-items: stretch; }
.btn-row.stack .btn { width: 100%; text-align: center; }

/* панель: аккаунты */
.filters { margin-bottom: 12px; }
.filters input[name=q] { flex: 1 1 180px; }
table.accounts { table-layout: fixed; width: 100%; min-width: 840px; font-size: .9rem; }
table.accounts th, table.accounts td { padding: 10px 10px; }
table.accounts th:nth-child(1) { width: 30%; }
table.accounts th:nth-child(2) { width: 27%; }
table.accounts th:nth-child(3) { width: 10%; }
table.accounts th:nth-child(4) { width: 9%; }
table.accounts th:nth-child(5) { width: 24%; }
table.accounts tr.stuck td { background: #FCF3E6; }
.acc-name { font-weight: 700; font-size: 1rem; line-height: 1.2; }
.acc-tg { margin-top: 2px; display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: .86rem; }
.acc-tg span:first-child { color: var(--acc-ink); }
.acc-meta { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 3px 6px; font-size: .8rem; color: var(--muted); align-items: center; }
.acc-meta > span:not(.pill)::after { content: "·"; margin-left: 6px; color: var(--line-strong); }
.acc-meta > span:last-child::after { content: none; }
.acc-stuck { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 9px; font-size: .74rem; font-weight: 500; line-height: 1.6; background: var(--bg); color: var(--muted); white-space: nowrap; }
.pill.bad { background: var(--warn-soft); color: var(--warn); }
.pill.warn { background: var(--gold-soft); color: var(--rose); }
.pill.role-admin { background: var(--acc-soft-2); color: var(--acc-ink); }
.pill.role-member { background: var(--acc-soft); color: var(--acc-ink); }
.acc-tree { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 2px 0; }
.acc-tree a { font-weight: 700; }
.acc-claimed { margin-top: 6px; font-size: .82rem; line-height: 1.35; }
.acc-work b { font-size: 1.1rem; }
.acc-work div { line-height: 1.25; }
.acc-seen { white-space: nowrap; line-height: 1.25; }
.acc-roles form { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.acc-roles .check { margin: 0; white-space: nowrap; }
.acc-roles .btn { margin-top: 2px; }

/* инструкция */
.help-toc { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.help-toc a { font-weight: 600; }
.help h2 { margin-top: 0; }
.help p, .help li { line-height: 1.5; }
.help ol, .help ul { padding-left: 22px; }
.help li { margin: 4px 0; }

/* поле даты */
.date-box { display: grid; gap: 3px; }
.date-hint:empty { display: none; }
.date-hint.warn { color: var(--warn); font-weight: 700; }
.date-switch { justify-self: start; font-size: .82rem; }

/* добавление родственника: коротко, остальное под «знаю больше» */
.add-form .name-row { display: flex; gap: 8px; align-items: center; }
.add-form .name-row input { flex: 1 1 auto; font-size: 1.1rem; }
.add-form .name-row .btn { flex: 0 0 auto; white-space: nowrap; }
.add-form .save-bar { margin: 12px 0; }
details.more { padding: 0; }
details.more > summary { cursor: pointer; padding: 14px 16px; font-weight: 600; color: var(--ink); list-style: none; display: flex; align-items: center; gap: 10px; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; }
details.more[open] > summary::before { transform: rotate(45deg); }
details.more > .fld, details.more > p { margin-left: 16px; margin-right: 16px; }
details.more[open] { padding-bottom: 10px; }

/* участники и приглашения: поле и кнопка одной высоты, кнопки ровными долями */
.pick-row { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.pick-row select { flex: 1 1 180px; width: auto; min-width: 0; max-width: 100%; }
.pick-row .btn { flex: 0 0 auto; min-height: 46px; }
@media (max-width: 719px) { .pick-row .btn { flex: 1 1 100%; } }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row > * { flex: 1 1 auto; min-width: 0; }
.btn-row form { display: flex; }
.btn-row form .btn { flex: 1 1 auto; }
.btn-row .btn { min-height: 42px; padding-left: 14px; padding-right: 14px; font-size: .92rem; white-space: nowrap; }
.member-form { flex: 1 1 100%; gap: 8px; align-items: stretch; }
.member-form select { flex: 1 1 auto; max-width: none; }
.member-form .btn { min-height: 46px; flex: 0 0 auto; }
@media (min-width: 720px) { .member-form { flex: 0 0 auto; } .member-form select { max-width: 220px; } }

/* участники и приглашения */
.members { list-style: none; margin: 0; padding: 0; }
.member { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.member:last-child { border-bottom: 0; }
.member .body { flex: 1 1 200px; display: flex; flex-direction: column; }
.invites { margin-top: 12px; }
.invite .link-text { display: block; word-break: break-all; font-size: .85rem; padding: 8px 10px; background: var(--bg); border-radius: 12px; }
.who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.invite-box { margin: 8px 0; }
.invite-box .invite { display: grid; gap: 6px; }
body.in-tg .top .brand span:last-child { display: none; }
body.in-tg .logout { display: none; }

/* порядок детей */
.order-list { list-style: none; padding: 0; margin: 0; }
.order-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.order-row:last-child { border-bottom: none; }
.order-num { width: 52px; padding-left: 4px; padding-right: 4px; text-align: center; font-weight: 700; }
.order-name { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.order-btns { display: flex; gap: 4px; }
@media (max-width: 480px) { .order-row { gap: 8px; } .order-row .avatar { display: none; } .order-btns .icon-btn { width: 40px; height: 40px; } }

table.history { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.history.log { min-width: 520px; }
table.history th, table.history td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.history th { color: var(--muted); font-weight: 500; font-size: .87rem; }
table.history tr.retracted td { color: var(--muted); text-decoration: line-through; }

/* режим обучения: затемнённые заслонки вокруг цели, рамка, подсказка, полоски «остановлено» и «продолжить» */
.tour-block { position: fixed; z-index: 60; background: rgba(20, 32, 25, .58); }
.tour-cover { position: fixed; z-index: 60; }
.tour-ring { position: fixed; z-index: 61; pointer-events: none; border: 3px solid var(--rose-line); border-radius: var(--r-sm); }
.tour-tip {
  position: fixed; z-index: 62; left: 12px; right: 12px; max-width: 440px; margin: 0 auto;
  background: var(--card); border-radius: var(--r);
  padding: 16px 16px 14px; box-shadow: 0 12px 36px rgba(20, 32, 25, .35);
}
.tour-tip h2 { font-size: 1.15rem; margin: 8px 0 6px; }
.tour-tip p { margin: 0 0 12px; }
.tour-head { display: flex; align-items: center; gap: 10px; }
.tour-count { font-size: .78rem; font-weight: 600; padding: 3px 10px; border-radius: 12px; background: var(--acc-soft); color: var(--acc-ink); }
.tour-dots { display: flex; gap: 4px; margin-left: auto; }
.tour-dots i { width: 6px; height: 6px; border-radius: 3px; background: #CFDCD3; }
.tour-dots i.on { width: 16px; background: var(--acc); }
.tour-foot { display: flex; align-items: center; gap: 8px; }
.tour-foot .link { margin-right: auto; min-height: 44px; }
.tour-arrow { position: absolute; width: 14px; height: 14px; background: var(--card); transform: rotate(45deg); }
.tour-arrow.up { top: -7px; }
.tour-arrow.down { bottom: -7px; }
.tour-tip.center { bottom: calc(16px + env(safe-area-inset-bottom)); padding-top: 22px; text-align: center; }
.tour-tip.center .tour-foot { flex-direction: column; align-items: stretch; margin-bottom: 10px; }
.tour-tip.center p:last-child { margin-bottom: 0; }
.tour-mark {
  display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 20px;
  background: var(--acc); color: #fff; font-size: 28px; font-weight: 700; line-height: 1;
}
.tour-toast {
  position: fixed; z-index: 62; left: 12px; right: 12px; bottom: calc(88px + env(safe-area-inset-bottom)); max-width: 440px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--ink); color: #fff; border-radius: 18px; box-shadow: var(--shadow);
}
.tour-toast a { color: #BFE3CC; font-weight: 600; white-space: nowrap; }
.tour-pill {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; padding: 8px 8px 8px 14px;
  background: var(--gold-soft); color: var(--rose); border-radius: 18px;
}
.tour-pill span { margin-right: auto; font-weight: 500; }
.tour-pill .btn { background: var(--card); }
@media (min-width: 720px) { .tour-toast { bottom: 16px; } }
.tour-box { background: var(--acc-soft); }
.tour-box .btn.ghost { background: var(--card); }

/* мелкие правки облика */
.cover .avatar.big, .person-row .avatar.big { width: 52px; height: 52px; font-size: 1.3rem; box-shadow: none; }
.sheet-grid .btn:not(.primary) { font-size: .88rem; padding: 6px 8px; }
@media (max-width: 400px) { .sheet-grid .btn:not(.primary) { font-size: .82rem; padding: 6px 4px; } }

/* открытая страница для тех, кто ещё не вошёл: её же показывает ссылка в чате */
.landing { display: flex; flex-direction: column; gap: 14px; max-width: 560px; margin: 0 auto; }
.landing h1 { font-size: 1.9rem; line-height: 1.1; margin: 6px 0 8px; }
.landing .lead { font-size: 1.05rem; margin: 0; }
.landing .btn { width: 100%; min-height: 50px; font-size: 1rem; }
.landing .center { text-align: center; margin: 0; }
.land-tree { display: flex; justify-content: center; padding: 14px 0 10px; margin: 0; }
.land-svg { width: min(300px, 80%); height: auto; font-family: var(--body); }
.land-features { display: flex; flex-direction: column; gap: 16px; margin: 0; }
.land-ft { display: flex; gap: 12px; align-items: flex-start; }
.land-ic { flex: 0 0 auto; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--acc-soft); color: var(--acc-ink); }
.land-ic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.land-ft b { display: block; }
.land-ft span { color: var(--muted); }
body:has(.landing) .fb-btn { display: none; }

/* карандаш рядом с названием дерева: переименовать может админ */
.title-edit { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--card); color: var(--muted); vertical-align: middle; margin-left: 4px; }
.title-edit:hover { background: var(--acc-soft); color: var(--acc-ink); text-decoration: none; }
.title-edit svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* кнопки, стоящие подряд вне рядов (форма в строке рядом с кнопкой или ссылкой), не слипаются */
form.inline + .btn, form.inline + form.inline, .btn + form.inline, .btn + .btn { margin-left: 6px; }
.row > .btn + .btn, .row > form.inline, .row > .btn + form.inline, .btn-row .btn + .btn, .actions .btn + .btn, .actions form.inline + .btn, .actions .btn + form.inline,
.sheet-grid .btn + .btn, .save-bar .btn + .btn, .pick-row .btn, .tour-foot .btn + .btn, .q-form > .btn + .btn, .actions-row .btn + .btn, .actions-row form.inline, .actions-row form.inline + .btn, .actions-row .btn + form.inline { margin-left: 0; }

/* панель администратора: ряды кнопок переносятся, поля формы стоят столбиком с зазором */
.adm-main .row { flex-wrap: wrap; }
form.stack { display: flex; flex-direction: column; gap: 8px; }
form.stack > label { margin-bottom: -4px; }

/* профиль: своя карточка и настройки на одной странице */
.avatar.big.mine { box-shadow: 0 0 0 4px var(--bg), 0 0 0 6px var(--acc); }
.fill-bar { height: 8px; border-radius: 4px; background: var(--card); overflow: hidden; margin: 10px 0; }
.fill-bar span { display: block; height: 100%; border-radius: 4px; background: var(--acc); }
.fill p { margin: 0 0 10px; }
.fill p:last-child { margin-bottom: 0; }
.add-link { font-weight: 600; }
.card .note { margin: 10px 0 0; }
.me-rel { display: flex; align-items: center; gap: 12px; padding: 7px 0; color: inherit; }
.me-rel:hover { text-decoration: none; }
.me-rel .body, .me-cand .body, .set-row .body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.me-rel strong, .me-cand strong { font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.me-ic { flex: 0 0 auto; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--acc-soft); color: var(--acc-ink); }
.me-ic svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.me-sep { height: 1px; background: var(--line); margin: 8px 0; }
.me-kids { margin: 2px 0 8px; }
.me-btns { margin-top: 14px; }
.me-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.me-tiles .tile { color: inherit; min-width: 0; }
.me-tiles .tile:hover { text-decoration: none; background: var(--acc-soft); }
.me-tiles .tile b { color: var(--acc-ink); }
.me-cands { display: flex; flex-direction: column; margin-top: 8px; }
.me-cand { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.me-cand + .me-cand { border-top: 1px solid var(--acc-soft-2); }
.me-cand form { flex: 0 0 auto; }
#find details.more.plain { margin-top: 12px; }
.set-block { display: flex; flex-direction: column; gap: 6px; padding: 4px 0 14px; }
.set-label { font-size: .87rem; font-weight: 500; color: var(--muted); }
.set-block .seg-link { flex: 1; }
.set-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); color: inherit; }
.set-row:last-child { padding-bottom: 0; }
.set-row form { flex: 0 0 auto; }
a.set-link:hover { text-decoration: none; }
.me-out { text-align: center; margin: 4px 0 0; }
.me-out p { margin: 8px 0 0; }
.me-home { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: inherit; margin-bottom: 14px; }
.me-home:hover { text-decoration: none; background: var(--card-2); }
.me-home .body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.me-home strong { font-weight: 600; overflow-wrap: anywhere; }
.me-dot { flex: 0 0 auto; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(145deg, #429069 0%, #2E6A4A 52%, #22523A 100%); color: #fff; font-weight: 700; font-size: 1.1rem; }
.me-dot.long { font-size: .8rem; }
