/* Шежіре — дизайн-система.
   Тёплая «бумажная» основа, графитовый текст, один акцент (глубокая бирюза — көк),
   приглушённое золото для орнамента. Скругления 8/12/16, тени почти незаметны. */

:root {
    --bg: #F5F3EE;
    --surface: #FFFFFF;
    --surface-2: #FAF8F4;
    --surface-3: #F0EDE6;
    --line: #E7E2D8;
    --line-2: #D8D2C6;
    --text: #1D1B18;
    --text-2: #5E5950;
    --text-3: #938C81;
    --accent: #1C5D63;
    --accent-hover: #154B50;
    --accent-soft: #E4EEED;
    --accent-text: #FFFFFF;
    --gold: #A07B34;
    --gold-soft: #F3EBDA;
    --stone: #6C655B;
    --stone-soft: #EDE9E2;
    --danger: #A63E2E;
    --danger-soft: #F6E6E2;
    --warn: #8E6417;
    --warn-soft: #F5EDDA;
    --ok: #2D6A4E;
    --ok-soft: #E2EEE7;
    --overlay: rgba(24, 22, 19, 0.36);
    --shadow-1: 0 1px 2px rgba(29, 27, 24, 0.05);
    --shadow-2: 0 1px 2px rgba(29, 27, 24, 0.04), 0 4px 14px rgba(29, 27, 24, 0.06);
    --shadow-3: 0 18px 50px rgba(29, 27, 24, 0.18);
    --r-s: 8px;
    --r-m: 12px;
    --r-l: 16px;
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --header-h: 56px;
    --tab-h: 62px;
    --side-w: 236px;
    --panel-w: 440px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #131210;
    --surface: #1B1A17;
    --surface-2: #201E1B;
    --surface-3: #292723;
    --line: #2D2A26;
    --line-2: #3B3833;
    --text: #ECE8E1;
    --text-2: #A9A297;
    --text-3: #7B756C;
    --accent: #72B8B2;
    --accent-hover: #8CC8C2;
    --accent-soft: #1D3231;
    --accent-text: #0D1716;
    --gold: #CDAC69;
    --gold-soft: #2B2519;
    --stone: #A39C91;
    --stone-soft: #262420;
    --danger: #E38E7C;
    --danger-soft: #36211C;
    --warn: #D6AE62;
    --warn-soft: #2E2617;
    --ok: #82BE9C;
    --ok-soft: #1B2A22;
    --overlay: rgba(0, 0, 0, 0.55);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.25);
    --shadow-3: 0 18px 50px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
}

/* ---------- Основа ---------- */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.45;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    padding-bottom: calc(var(--tab-h) + var(--safe-b));
}
html.elder body { zoom: 1.16; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.i { flex: 0 0 auto; display: inline-block; vertical-align: middle; }
.muted { color: var(--text-3); }
.hint { font-size: 13px; color: var(--text-2); line-height: 1.5; }
.link { color: var(--accent); font-weight: 500; text-align: left; padding: 0; }
.link:hover { text-decoration: underline; text-underline-offset: 2px; }
.rel-link { font-weight: 500; }

/* ---------- Шапка ---------- */

.app-header {
    position: sticky; top: 0; z-index: 40;
    height: var(--header-h);
    display: flex; align-items: center; gap: 8px;
    padding: 0 12px 0 16px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid transparent;
    transition: border-color .2s;
}
body.scrolled .app-header { border-bottom-color: var(--line); }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: var(--r-s); display: grid; place-items: center; background: var(--accent); color: var(--accent-text); }
.brand-mark .i { width: 20px; height: 20px; }
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--text-3); letter-spacing: 0; margin-top: -2px; }
.header-spacer { flex: 1; }
.icon-btn {
    position: relative; width: 40px; height: 40px; border-radius: var(--r-s);
    display: inline-grid; place-items: center; color: var(--text-2);
    transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 32px; height: 32px; }
.bell-dot {
    position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 600;
    display: none; align-items: center; justify-content: center; border: 2px solid var(--bg);
}
.account-btn {
    display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 4px;
    border-radius: 18px; border: 1px solid var(--line-2); background: var(--surface); font-size: 14px; font-weight: 500;
    max-width: 180px;
}
.account-btn .avatar { width: 28px; height: 28px; font-size: 12px; }
.account-btn span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-btn.guest { padding: 0 14px; background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.status-bar { display: none; align-items: center; gap: 8px; padding: 8px 16px; font-size: 13px; background: var(--warn-soft); color: var(--warn); }
.invite-banner { display: none; align-items: center; gap: 12px; margin: 8px 16px 0; padding: 12px 14px; border-radius: var(--r-m); background: var(--accent-soft); font-size: 14px; }
.invite-banner span { flex: 1; }

/* ---------- Нижние вкладки / боковая панель ---------- */

.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    display: grid; grid-template-columns: repeat(4, 1fr); align-items: center;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(16px);
    -webkit-backdrop-filter: saturate(1.4) blur(16px);
    border-top: 1px solid var(--line);
}
.tabbar .side-brand, .tabbar .side-foot { display: none; }
.tab {
    position: relative; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--text-3); font-size: 11px; font-weight: 500; letter-spacing: 0.01em;
}
.tab .i { width: 23px; height: 23px; }
.tab[aria-current="page"] { color: var(--accent); }
.tab:hover { color: var(--text); }
.tab[aria-current="page"]:hover { color: var(--accent); }
.tab-add .add-square {
    width: 46px; height: 38px; border-radius: var(--r-m); display: grid; place-items: center;
    background: var(--accent); color: var(--accent-text); box-shadow: var(--shadow-1);
}
.tab-add .add-square .i { width: 22px; height: 22px; }
.tab-add .tab-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.tab-badge {
    position: absolute; top: 6px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
    background: var(--danger); color: #fff; font-size: 10px; font-weight: 600; display: none; align-items: center; justify-content: center;
}

/* ---------- Страницы ---------- */

main#app-pages { min-width: 0; }
.page { display: none; padding: 4px 16px 32px; max-width: 760px; margin: 0 auto; }
.page.active { display: block; animation: pageIn .18s ease-out; }
@keyframes pageIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
#page-tree { max-width: none; padding: 0 0 24px; }
.page-title { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin: 10px 0 4px; }
.page-lead { color: var(--text-2); font-size: 14px; margin-bottom: 18px; }
.subbar { display: flex; align-items: center; gap: 4px; margin: 4px -8px 10px; min-height: 44px; }
.subbar h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.subbar .icon-btn { color: var(--text); }

.block { margin-top: 26px; }
.block:first-child { margin-top: 8px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.block-head h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.block-head .link { font-size: 14px; }
.section-title { font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); margin: 22px 0 8px; }

/* ---------- Карточки, группы, строки ---------- */

.card-box, .card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 16px;
    margin-bottom: 12px;
}
.card-box h3, .card h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; }
.group + .group { margin-top: 12px; }
.row {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 10px 14px;
    text-align: left; border-bottom: 1px solid var(--line); background: transparent; color: inherit;
}
.group > .row:last-child, .group > :last-child .row:last-child { border-bottom: 0; }
button.row:hover, a.row:hover, .row[role="button"]:hover { background: var(--surface-2); text-decoration: none; }
.row-icon { width: 34px; height: 34px; border-radius: var(--r-s); display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex: 0 0 auto; }
.row-icon.accent { background: var(--accent-soft); color: var(--accent); }
.row-icon.gold { background: var(--gold-soft); color: var(--gold); }
.row-icon.stone { background: var(--stone-soft); color: var(--stone); }
.row-icon.danger { background: var(--danger-soft); color: var(--danger); }
.row-main { flex: 1; min-width: 0; }
.row-title { display: block; font-size: 15px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.row-sub { display: block; font-size: 13px; color: var(--text-2); margin-top: 1px; }
.row-end { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 13px; }
.row.danger .row-title { color: var(--danger); }
.row.compact { min-height: 46px; padding: 8px 14px; }
.row.wrap { flex-wrap: wrap; align-items: flex-start; padding-top: 14px; padding-bottom: 14px; }
.row-below { flex: 1 1 100%; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-left: 58px; }

.list-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.list-item:last-child { border-bottom: 0; }
.list-item > span:first-child { color: var(--text-2); }

/* ---------- Кнопки ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 40px; padding: 0 14px; border-radius: var(--r-s);
    border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
    font-size: 14px; font-weight: 500; line-height: 1.2; text-align: center; white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn .i { width: 18px; height: 18px; }
.btn-primary, .btn-success { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover, .btn-success:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--text); }
.btn-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn-soft:hover { background: color-mix(in srgb, var(--accent-soft) 70%, var(--accent) 12%); border-color: transparent; }
.btn-block { display: flex; width: 100%; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn-lg { min-height: 48px; font-size: 15px; padding: 0 18px; }
.btn-google { background: var(--surface); }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.action-grid .btn { white-space: normal; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice-grid .btn { flex-direction: column; min-height: 88px; gap: 8px; font-size: 15px; }
.choice-grid .btn .i { width: 24px; height: 24px; color: var(--accent); }

/* Сегментный переключатель */
.seg { display: inline-flex; padding: 2px; border-radius: var(--r-s); background: var(--surface-3); gap: 2px; }
.seg button {
    display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 6px;
    font-size: 13px; font-weight: 500; color: var(--text-2); white-space: nowrap;
}
.seg button .i { width: 17px; height: 17px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; justify-content: center; }

/* Переключатель вкл/выкл */
.switch { position: relative; width: 44px; height: 26px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 13px; background: var(--line-2); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Поля ---------- */

.field { margin-bottom: 14px; }
.field label, .field-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
input[type="text"], input[type="tel"], input[type="search"], input[type="date"], input[type="number"], input:not([type]),
select, textarea, .page-input {
    width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--r-s);
    border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font-size: 15px;
    transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
select { appearance: none; -webkit-appearance: none; padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23938C81' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='m6 9.5 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input[type="file"] { font-size: 14px; padding: 8px 0; }
.field-row { display: flex; gap: 8px; align-items: stretch; }
.field-row > * { flex: 1; min-width: 0; }
.field-row .field { margin-bottom: 0; }
.radio-row { display: flex; flex-wrap: wrap; gap: 8px; }
.radio-row label {
    display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; margin: 0;
    border: 1px solid var(--line-2); border-radius: var(--r-s); background: var(--surface); font-size: 14px; font-weight: 500; color: var(--text); cursor: pointer;
}
.radio-row label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.radio-row input { accent-color: var(--accent); }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; margin: 10px 0 14px; cursor: pointer; line-height: 1.45; }
.check input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--accent); flex: 0 0 auto; }
.auto-hint { font-size: 12px; color: var(--text-3); margin-top: 6px; }
details.more-fields { margin: 4px 0 14px; border-top: 1px solid var(--line); padding-top: 12px; }
details.more-fields summary { cursor: pointer; font-size: 14px; font-weight: 500; color: var(--accent); margin-bottom: 12px; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
details.more-fields summary::-webkit-details-marker { display: none; }
details.more-fields summary::after { content: ""; width: 8px; height: 8px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(45deg) translateY(-3px); transition: transform .2s; }
details.more-fields[open] summary::after { transform: rotate(225deg) translate(-2px, -1px); }
.voice-btn { flex: 0 0 44px !important; padding: 0; }
.voice-btn.listening { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

/* ---------- Значки, уведомления ---------- */

.chip {
    display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border-radius: 6px;
    background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 500; white-space: nowrap; vertical-align: middle;
}
.chip .i { width: 14px; height: 14px; }
.chip.pending { background: var(--warn-soft); color: var(--warn); }
.chip.applied, .chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.rejected { background: var(--danger-soft); color: var(--danger); }
.chip.reverted, .chip.locked { background: var(--stone-soft); color: var(--stone); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.gold { background: var(--gold-soft); color: var(--gold); }
.notice {
    display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-m);
    background: var(--warn-soft); color: var(--text); font-size: 14px; line-height: 1.5; margin: 10px 0;
}
.notice > .i { color: var(--warn); margin-top: 1px; }
.notice.info { background: var(--accent-soft); }
.notice.info > .i { color: var(--accent); }
.notice.ok { background: var(--ok-soft); }
.notice.ok > .i { color: var(--ok); }
.notice.danger { background: var(--danger-soft); }
.notice.danger > .i { color: var(--danger); }
.notice .notice-body { flex: 1; min-width: 0; }
.notice b { font-weight: 600; }
.danger-zone { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.otp-dev { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--r-s); background: var(--gold-soft); color: var(--gold); font-size: 14px; font-weight: 500; }
.progress { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin: 10px 0; }
.progress > div { height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s ease; }
.stat-row { display: flex; gap: 10px; }
.stat-row > div { flex: 1; padding: 12px; border-radius: var(--r-s); background: var(--surface-2); border: 1px solid var(--line); }
.stat-row b { display: block; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.stat-row span { font-size: 12px; color: var(--text-2); }

/* ---------- Аватар ---------- */

.avatar {
    width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto; overflow: hidden;
    display: grid; place-items: center; background: var(--surface-3); color: var(--text-2);
    font-size: 15px; font-weight: 600; object-fit: cover;
}
.avatar.f { background: var(--gold-soft); color: var(--gold); }
.avatar.deceased { filter: grayscale(.6); }
img.avatar { background: var(--surface-3); }
.avatar.xl { width: 72px; height: 72px; font-size: 28px; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }

/* ---------- Шежіре: поиск, путь, вид ---------- */

.tree-top { background: var(--bg); padding: 4px 16px 6px; }
.tree-top-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.search-box { position: relative; flex: 1 1 100%; min-width: 0; }
.search-box > [data-icon] { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; display: flex; }
#treeViewSeg { flex: 1 1 100%; display: flex; }
#treeViewSeg button { flex: 1; justify-content: center; }
@media (min-width: 640px) {
    .search-box { flex: 1 1 auto; }
    #treeViewSeg { flex: 0 0 auto; }
    #treeViewSeg button { flex: 0 0 auto; }
}
.search-box input { padding-left: 40px; min-height: 44px; border-radius: var(--r-m); background: var(--surface); }
.search-results-dropdown, .search-dropdown {
    display: none; position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 60;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: var(--shadow-3);
    max-height: min(60vh, 440px); overflow-y: auto; padding: 4px;
}
.input-group, .field[style*="position:relative"] { position: relative; }
.dropdown-item { padding: 10px 12px; border-radius: var(--r-s); cursor: pointer; font-size: 15px; }
.dropdown-item b { font-weight: 500; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-2); outline: none; }
.dropdown-item .sub-fio { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.dropdown-empty { cursor: default; color: var(--text-2); }
.dropdown-empty:hover { background: none; }

.crumbs-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; min-height: 34px; }
.crumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; font-size: 13.5px; color: var(--text-2); white-space: nowrap; }
.crumbs::-webkit-scrollbar { display: none; }
.crumb { padding: 5px 7px; border-radius: 6px; color: var(--text-2); font-weight: 500; }
.crumb:hover { background: var(--surface-3); color: var(--text); }
.crumb.current { color: var(--text); }
.crumb-sep { color: var(--text-3); display: inline-flex; }
.crumb-sep .i { width: 14px; height: 14px; }
.crumbs .placeholder { color: var(--text-3); padding: 5px 2px; }
.mybranch-btn { flex: 0 0 auto; }

.guest-hero {
    margin: 4px 16px 10px; padding: 16px; border-radius: var(--r-m);
    background: var(--surface); border: 1px solid var(--line); display: flex; gap: 14px; align-items: flex-start;
}
.guest-hero .hero-mark { width: 40px; height: 40px; border-radius: var(--r-s); display: grid; place-items: center; background: var(--gold-soft); color: var(--gold); flex: 0 0 auto; }
.guest-hero h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 4px; }
.guest-hero p { font-size: 13.5px; color: var(--text-2); }
.guest-hero .hero-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.guest-hero .hero-close { margin: -6px -6px 0 0; }
.guest-hero .hero-stats { font-size: 12px; color: var(--text-3); margin-top: 10px; }
.hero-notable { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 12px; }
.hero-notable:empty { display: none; }
.hero-label { font-size: 12px; color: var(--text-3); margin-right: 2px; }
.hero-chip { height: 28px; padding: 0 10px; border-radius: 6px; font-size: 12.5px; font-weight: 500; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); }
.hero-chip:hover { border-color: var(--gold); color: var(--gold); }
.hero-chip.more { color: var(--accent); }

/* Колонки */
.tree-scroll { overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding: 0 16px; padding: 4px 16px 0; scrollbar-width: thin; }
.tree-columns { display: flex; gap: 12px; align-items: flex-start; min-height: 50vh; }
.tree-column {
    flex: 0 0 auto; width: calc(100vw - 32px); max-width: 340px; scroll-snap-align: start;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden;
}
.column-header { display: flex; align-items: center; gap: 4px; min-height: 48px; padding: 6px 8px 6px 6px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.col-title { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; color: var(--text); padding-left: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-sub { display: block; font-size: 11.5px; font-weight: 500; color: var(--text-3); margin-top: 1px; }
.col-back { width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center; color: var(--text-2); }
.col-back:hover { background: var(--surface-3); }
.col-spacer { width: 0; }

.person-card {
    position: relative; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 12px;
    border-bottom: 1px solid var(--line); cursor: pointer; transition: background .12s;
}
.person-card:last-child { border-bottom: 0; }
.person-card:hover { background: var(--surface-2); }
.person-card.active { background: var(--accent-soft); }
.person-card.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 2px 2px 0; background: var(--accent); }
.person-card.is-me .person-name::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); margin-left: 6px; vertical-align: middle; }
.person-details { flex: 1; min-width: 0; }
.person-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.person-name { font-size: 15px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-card.deceased .person-name { color: var(--text); }
.person-years { font-size: 12.5px; color: var(--text-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lock-icon { color: var(--text-3); display: inline-flex; }
.lock-icon .i { width: 13px; height: 13px; }
.kin-tag { flex: 0 0 auto; font-size: 11.5px; font-weight: 500; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 5px; }
.person-card.active .kin-tag { background: var(--surface); }
.clan-tag { flex: 0 0 auto; font-size: 11.5px; font-weight: 500; color: var(--gold); }
.notable-tag { flex: 0 0 auto; font-size: 11px; font-weight: 500; color: var(--gold); background: var(--gold-soft); padding: 1px 6px; border-radius: 5px; }
.card-actions { display: flex; align-items: center; gap: 2px; color: var(--text-3); }
.spouse-btn { width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; color: var(--text-3); }
.spouse-btn:hover { background: var(--surface-3); color: var(--text); }
.spouse-btn .i { width: 17px; height: 17px; }
.children-count { font-size: 12.5px; font-weight: 500; color: var(--text-3); min-width: 18px; text-align: right; }
.card-actions .chev { width: 16px; height: 16px; color: var(--text-3); }
.person-card .avatar { width: 36px; height: 36px; font-size: 14px; }
.hidden-card .person-name { color: var(--text-3); font-weight: 400; }
.hidden-group { display: flex; flex-direction: column; width: 100%; padding: 12px 14px; text-align: left; font-size: 14px; font-weight: 500; color: var(--text-2); border-bottom: 1px solid var(--line); }
.hidden-group small { font-size: 12px; font-weight: 400; color: var(--text-3); margin-top: 2px; }
.hidden-group:hover { background: var(--surface-2); }
.load-more-btn { width: 100%; padding: 12px; font-size: 14px; font-weight: 500; color: var(--accent); }
.load-more-btn:hover { background: var(--surface-2); }
.data-error-box { margin: 16px; padding: 18px; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); color: var(--text-2); font-size: 14px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

/* ---------- Сызба (схема) ---------- */

.dg-toolbar { display: flex; align-items: center; gap: 8px; padding: 0 16px 8px; flex-wrap: wrap; }
.dg-toolbar .dg-label { font-size: 12.5px; color: var(--text-3); font-weight: 500; margin-right: -2px; }
.dg-toolbar .spacer { flex: 1; }
.dg-toolbar .btn-sm { min-height: 36px; }
@media (max-width: 480px) { .dg-toolbar .lbl { display: none; } .dg-toolbar .btn-sm { width: 38px; padding: 0; } .dg-toolbar { gap: 6px; } }
.dg-zoom { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r-s); background: var(--surface); overflow: hidden; }
.dg-zoom button { width: 36px; height: 34px; display: grid; place-items: center; color: var(--text-2); }
.dg-zoom button + button { border-left: 1px solid var(--line); }
.dg-zoom button:hover { background: var(--surface-2); color: var(--text); }
.dg-stage {
    position: relative; margin: 0 16px; height: calc(100vh - var(--header-h) - var(--tab-h) - var(--safe-b) - 252px); min-height: 340px;
    border-radius: var(--r-m); border: 1px solid var(--line); overflow: hidden; touch-action: none; cursor: grab;
    background-color: var(--surface-2);
    background-image: radial-gradient(circle, color-mix(in srgb, var(--text-3) 28%, transparent) 1px, transparent 1.2px);
    background-size: 22px 22px;
}
.dg-stage.dragging { cursor: grabbing; }
.dg-stage svg { position: absolute; left: 0; top: 0; overflow: visible; user-select: none; -webkit-user-select: none; }
.dg-note { position: absolute; left: 12px; bottom: 10px; font-size: 12px; color: var(--text-3); background: color-mix(in srgb, var(--surface) 85%, transparent); padding: 4px 8px; border-radius: 6px; pointer-events: none; max-width: calc(100% - 24px); }
.dg-node { cursor: pointer; }
.dg-node rect.box { fill: var(--surface); stroke: var(--line-2); stroke-width: 1; transition: stroke .15s; }
.dg-node:hover rect.box, .dg-node:focus rect.box { stroke: var(--accent); }
.dg-node:focus { outline: none; }
.dg-node.root rect.box { stroke: var(--accent); stroke-width: 1.8; }
.dg-node.anc rect.box { stroke-dasharray: 4 3; fill: var(--surface-2); }
.dg-node.hid rect.box { fill: var(--surface-3); stroke-dasharray: 4 3; }
.dg-node.f .sex { fill: var(--gold); }
.dg-node .sex { fill: var(--accent); }
.dg-node .nm { fill: var(--text); font-size: 13px; font-weight: 600; }
.dg-node .yr { fill: var(--text-3); font-size: 11px; }
.dg-node .sp { fill: var(--text-2); font-size: 11px; }
.dg-node.dead .nm { fill: var(--text-2); }
.dg-edge { fill: none; stroke: var(--line-2); stroke-width: 1.3; }
.dg-edge.anc { stroke-dasharray: 4 4; }
.dg-edge.gap { stroke-dasharray: 1.5 4; stroke-width: 1.8; stroke: var(--text-3); }
.dg-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--text-2); font-size: 14px; }

/* ---------- Окна: шторка снизу на телефоне, панель справа на компьютере ---------- */

.modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 70; background: var(--overlay);
    align-items: flex-end; justify-content: center; animation: fadeIn .18s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-card {
    position: relative; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
    background: var(--surface); border-radius: var(--r-l) var(--r-l) 0 0; padding: 22px 18px calc(22px + var(--safe-b));
    box-shadow: var(--shadow-3); animation: sheetUp .22s cubic-bezier(.2, .8, .2, 1);
}
.modal-card::before { content: ""; position: absolute; top: 7px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--line-2); }
.close-modal-btn {
    position: absolute; top: 12px; right: 12px; z-index: 2; width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center; color: var(--text-2); background: var(--surface-3); font-size: 0;
}
.close-modal-btn:hover { color: var(--text); background: var(--line); }
.modal-title { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; margin: 2px 44px 16px 0; }
#formModal { z-index: 80; }
#sheetMenu { z-index: 90; }
#sevenAtaModal { z-index: 78; }

/* Меню действий */
.sheet-menu .modal-card { padding-top: 26px; }
.sheet-menu-title { font-size: 13px; color: var(--text-3); font-weight: 500; margin: 0 40px 10px 4px; }
.sheet-menu .group { border: 0; background: transparent; }
.sheet-menu .row { border-radius: var(--r-s); border-bottom: 0; min-height: 50px; }
.sheet-menu .row:hover { background: var(--surface-2); }

/* ---------- Карточка человека ---------- */

.pc-head { display: flex; gap: 14px; align-items: center; margin: 2px 40px 14px 0; }
.pc-head .avatar { cursor: zoom-in; }
.pc-name { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.pc-meta { font-size: 13.5px; color: var(--text-2); margin-top: 3px; }
.pc-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pc-relation {
    display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--r-m);
    background: var(--accent-soft); margin-bottom: 14px;
}
.pc-relation .rel-term { font-size: 16px; font-weight: 600; color: var(--accent); }
.pc-relation .rel-sub { font-size: 13px; color: var(--text-2); }
.pc-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0 0 14px; }
.pc-action {
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: var(--r-m);
    font-size: 12px; font-weight: 500; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--line);
}
.pc-action .i { width: 22px; height: 22px; color: var(--accent); }
.pc-action:hover { background: var(--surface-3); color: var(--text); }
.pc-cta { display: flex; gap: 8px; margin-bottom: 16px; }
.pc-cta .btn { flex: 1; }
.pc-section { margin-top: 18px; }
.pc-section > h3 { font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; }
.facts { border-top: 1px solid var(--line); }
.fact { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.fact > span:first-child { color: var(--text-2); flex: 0 0 auto; }
.fact > span:last-child { text-align: right; min-width: 0; overflow-wrap: anywhere; }
.pc-notes { font-size: 14px; line-height: 1.6; white-space: pre-wrap; color: var(--text); }
.source-item { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; display: flex; gap: 10px; }
.source-item:last-child { border-bottom: 0; }
.source-item .i { color: var(--text-3); margin-top: 1px; }
.source-item b { font-weight: 500; }
.memorial-box { padding: 14px; border-radius: var(--r-m); background: var(--stone-soft); }
.memorial-box .mem-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: var(--stone); }
.mem-dates { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 6px; }
.mem-dates span { font-size: 12.5px; padding: 4px 8px; border-radius: 6px; background: var(--surface); color: var(--text-2); }
.mem-dates span.next { color: var(--text); font-weight: 500; box-shadow: inset 0 0 0 1px var(--stone); }
.grave-photo { margin-top: 10px; border-radius: var(--r-s); max-height: 220px; object-fit: cover; width: 100%; }
.pc-login { margin-top: 18px; }
.pc-audio audio { width: 100%; margin-top: 4px; }

/* Родство со мной */
.kin-box { padding: 14px; border-radius: var(--r-m); background: var(--accent-soft); margin-bottom: 14px; }
.kin-box .kin-label { font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); }
.kin-term { font-size: 18px; font-weight: 600; color: var(--accent); margin-top: 2px; letter-spacing: -0.01em; }
.kin-path { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 10px; }
.kin-path .kp { font-size: 12.5px; font-weight: 500; padding: 4px 8px; border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; animation: kpIn .3s both; }
.kin-path .kp.me { background: var(--accent); color: var(--accent-text); }
.kin-path .kp.top { box-shadow: inset 0 0 0 1px var(--gold); color: var(--gold); }
.kin-path .arrow { color: var(--text-3); font-size: 13px; animation: kpIn .3s both; }
@keyframes kpIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* 7 ата */
.ata-chain { position: relative; margin: 6px 0 4px; }
.ata-chain::before { content: ""; position: absolute; left: 15px; top: 18px; bottom: 18px; width: 1.5px; background: var(--line-2); }
.ata-item {
    position: relative; display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 6px; border-radius: var(--r-s); text-align: left;
}
.ata-item:hover { background: var(--surface-2); }
.ata-dot { position: relative; z-index: 1; width: 20px; height: 20px; margin: 0 6px 0 5px; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--line-2); display: grid; place-items: center; flex: 0 0 auto; }
.ata-item.self .ata-dot { border-color: var(--accent); background: var(--accent); }
.ata-item.top .ata-dot { border-color: var(--gold); }
.ata-main { flex: 1; min-width: 0; }
.ata-name { font-size: 15px; font-weight: 500; }
.ata-years { font-size: 12.5px; color: var(--text-3); }
.ata-num { font-size: 12px; font-weight: 500; color: var(--text-3); white-space: nowrap; }
.ata-gap { position: relative; display: flex; align-items: center; gap: 12px; padding: 4px 6px; font-size: 12.5px; color: var(--text-3); font-style: italic; }
.ata-gap .ata-dot { width: 8px; height: 8px; margin: 0 12px 0 11px; border-style: dashed; background: var(--bg); }
.ata-note { font-size: 13px; color: var(--text-2); padding: 10px 12px; border-radius: var(--r-s); background: var(--surface-2); margin-bottom: 8px; }

/* ---------- Әулет ---------- */

.home-head { margin: 10px 0 2px; }
.home-head h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.home-head p { font-size: 14px; color: var(--text-2); margin-top: 4px; }
.date-tile {
    flex: 0 0 auto; width: 46px; height: 50px; border-radius: var(--r-s); border: 1px solid var(--line);
    display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--surface);
}
.date-tile b { font-size: 18px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; }
.date-tile small { font-size: 10.5px; color: var(--text-3); margin-top: 3px; text-transform: lowercase; }
.date-tile.mem { background: var(--stone-soft); border-color: transparent; color: var(--stone); }
.date-tile.event { background: var(--gold-soft); border-color: transparent; color: var(--gold); }
.date-tile.juma { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.date-tile.today { border-color: var(--accent); }
.when { font-size: 12.5px; color: var(--text-3); white-space: nowrap; }
.when.soon { color: var(--accent); font-weight: 500; }
.question-card { padding: 18px; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); position: relative; overflow: hidden; }
.question-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--gold); }
.question-card .q-label { font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--gold); }
.question-card .q-text { font-size: 18px; font-weight: 500; line-height: 1.4; letter-spacing: -0.01em; margin: 8px 0 14px; }
.answers { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.answer { padding: 10px 12px; border-radius: var(--r-s); background: var(--surface-2); font-size: 14px; }
.answer small { display: block; font-size: 12px; color: var(--text-3); margin-top: 4px; }
.feed-item { display: flex; gap: 12px; padding: 14px; border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: 0; }
.feed-icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex: 0 0 auto; }
.feed-icon.birth { background: var(--accent-soft); color: var(--accent); }
.feed-icon.death { background: var(--stone-soft); color: var(--stone); }
.feed-icon.family_event { background: var(--gold-soft); color: var(--gold); }
.feed-body { flex: 1; min-width: 0; font-size: 14px; line-height: 1.5; }
.feed-body b { font-weight: 600; }
.feed-meta { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
.feed-photo { margin-top: 8px; border-radius: var(--r-s); max-height: 260px; object-fit: cover; cursor: zoom-in; }
.feed-quote { margin-top: 8px; padding-left: 12px; border-left: 2px solid var(--line-2); color: var(--text-2); font-style: italic; }
.reactions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.reaction { height: 28px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--line-2); font-size: 12.5px; font-weight: 500; color: var(--text-2); background: var(--surface); }
.reaction:hover { border-color: var(--text-3); color: var(--text); }
.reaction.mine { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.mission-row .btn { flex: 0 0 auto; }
.holiday-note { font-size: 13px; color: var(--text-2); margin-top: 6px; }
.empty-block { padding: 18px; border-radius: var(--r-m); border: 1px dashed var(--line-2); color: var(--text-2); font-size: 14px; }

/* ---------- Мен ---------- */

.me-head { display: flex; align-items: center; gap: 14px; margin: 12px 0 4px; }
.me-head h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.me-head p { font-size: 13.5px; color: var(--text-2); margin-top: 2px; }
.mod-item { padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.5; }
.mod-item:last-child { border-bottom: 0; }
.mod-meta { font-size: 12.5px; color: var(--text-3); margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mod-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.mod-actions select { width: auto; min-height: 36px; font-size: 13px; }
.diff { margin-top: 6px; padding: 8px 10px; border-radius: var(--r-s); background: var(--surface-2); font-size: 13px; }
.diff s { color: var(--danger); }
.diff ins { color: var(--ok); text-decoration: none; font-weight: 500; }
.dup-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.login-card { padding: 22px 18px; }
.login-card .brand-mark { width: 44px; height: 44px; margin-bottom: 14px; }
.login-card .brand-mark .i { width: 28px; height: 28px; }
.login-card h2 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 6px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.settings-row:last-child { border-bottom: 0; }
.settings-row .row-title { font-size: 15px; }
.settings-row.stack { flex-direction: column; align-items: stretch; }

/* ---------- Добавить ---------- */

.add-intro { font-size: 13.5px; color: var(--text-2); margin: 0 4px 12px; }

/* ---------- Календарь ---------- */

.month-header { font-size: 13px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); margin: 22px 0 8px; }
.today-line { font-size: 14px; color: var(--text-2); margin-bottom: 6px; }

/* ---------- Инструменты: родство, неке, карта, игра ---------- */

.tool-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 16px; }
.result-card { margin-top: 14px; padding: 16px; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); }
.verdict { display: flex; gap: 12px; align-items: flex-start; }
.verdict .v-icon { width: 40px; height: 40px; border-radius: var(--r-s); display: grid; place-items: center; flex: 0 0 auto; }
.verdict.blocked .v-icon { background: var(--danger-soft); color: var(--danger); }
.verdict.allowed .v-icon { background: var(--ok-soft); color: var(--ok); }
.verdict.unknown .v-icon { background: var(--warn-soft); color: var(--warn); }
.verdict h4 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.verdict.blocked h4 { color: var(--danger); }
.verdict.allowed h4 { color: var(--ok); }
.verdict p { font-size: 13.5px; color: var(--text-2); line-height: 1.55; }
.distance { font-size: 40px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.distance-label { font-size: 12px; color: var(--text-3); }
.map-svg { width: 100%; height: auto; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); margin-bottom: 12px; }
.city-row { display: flex; align-items: center; gap: 10px; padding: 10px 0 4px; font-size: 15px; }
.city-row b { font-weight: 500; flex: 1; }
.city-count { font-size: 13px; color: var(--text-3); }
.game-slots { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.game-slot { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 12px; border-radius: var(--r-s); border: 1px dashed var(--line-2); font-size: 14px; }
.game-slot span { font-size: 12px; color: var(--text-3); width: 56px; }
.game-slot b { font-weight: 500; }
.game-slot.ok { border-style: solid; border-color: var(--ok); background: var(--ok-soft); }
.game-slot.bad { border-color: var(--danger); animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.game-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.game-chip { min-height: 40px; padding: 0 14px; border-radius: var(--r-s); border: 1px solid var(--line-2); background: var(--surface); font-weight: 500; font-size: 14px; }
.game-chip:hover { border-color: var(--accent); }
.game-chip.used { opacity: .35; pointer-events: none; }
.game-q { font-size: 18px; font-weight: 500; margin: 10px 0 12px; }
.medal { width: 56px; height: 56px; margin: 4px auto 12px; border-radius: 50%; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold); }
.medal .i { width: 28px; height: 28px; }
.medal:empty { display: none; }
.qr-box { width: min(260px, 70vw); margin: 0 auto 10px; padding: 14px; border-radius: var(--r-m); background: #fff; border: 1px solid var(--line); }
.qr-box svg { display: block; width: 100%; height: auto; }
.scan-video { width: 100%; border-radius: var(--r-m); background: #000; }
.meet-result { text-align: center; margin-bottom: 12px; }
.meet-result .big { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.poster-preview { width: 100%; border-radius: var(--r-m); border: 1px solid var(--line); margin-bottom: 12px; }

/* Истории, запись голоса */
.story { padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.6; }
.story:last-child { border-bottom: 0; }
.story-q { font-size: 13px; color: var(--gold); font-weight: 500; margin-bottom: 4px; }
.story-meta { font-size: 12.5px; color: var(--text-3); margin-top: 6px; }
.story audio { width: 100%; margin-top: 6px; }
.recorder { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: var(--r-s); background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 12px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line-2); }
.recorder.on .rec-dot { background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* Уведомления */
.notif { display: flex; gap: 12px; width: 100%; padding: 12px 6px; border-bottom: 1px solid var(--line); text-align: left; align-items: flex-start; }
.notif:last-child { border-bottom: 0; }
.notif .row-icon { width: 32px; height: 32px; }
.notif b { display: block; font-weight: 400; font-size: 14px; line-height: 1.45; }
.notif.unread b { font-weight: 600; }
.notif small { display: block; font-size: 12px; color: var(--text-3); margin-top: 3px; }

/* ---------- Тост, загрузка, просмотр фото ---------- */

.toast {
    position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 14px); z-index: 100;
    transform: translate(-50%, 10px); opacity: 0; pointer-events: none;
    max-width: min(440px, calc(100vw - 32px)); padding: 11px 16px; border-radius: var(--r-m);
    background: var(--text); color: var(--bg); font-size: 14px; font-weight: 500; box-shadow: var(--shadow-3);
    transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r-s); }
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-card { height: 58px; margin: 8px 12px; }
.skeleton-line { height: 12px; margin: 10px 0; }
.skeleton-line.short { width: 60%; }
.skeleton-circle { width: 56px; height: 56px; border-radius: 50%; margin-bottom: 14px; }
.skeleton-block { height: 120px; margin-bottom: 12px; border-radius: var(--r-m); }
#photoViewer { display: none; position: fixed; inset: 0; z-index: 110; background: rgba(10, 10, 9, .9); align-items: center; justify-content: center; padding: 20px; cursor: zoom-out; }
#photoViewer img { max-width: 100%; max-height: 100%; border-radius: var(--r-s); }

/* ---------- Компьютер: боковая панель и карточка справа ---------- */

@media (min-width: 1024px) {
    body { padding-bottom: 0; padding-left: var(--side-w); }
    .app-header { padding-left: 24px; }
    .app-header .brand { display: none; }
    .tabbar {
        top: 0; right: auto; width: var(--side-w); height: auto; padding: 18px 12px; display: flex; flex-direction: column; gap: 2px;
        align-items: stretch; border-top: 0; border-right: 1px solid var(--line); background: var(--surface-2);
        backdrop-filter: none; -webkit-backdrop-filter: none;
    }
    .tabbar .side-brand { display: flex; padding: 2px 8px 22px; }
    .tab { flex-direction: row; justify-content: flex-start; gap: 12px; height: 42px; padding: 0 12px; border-radius: var(--r-s); font-size: 14.5px; color: var(--text-2); }
    .tab .i { width: 21px; height: 21px; }
    .tab:hover { background: var(--surface-3); }
    .tab[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
    .tab[aria-current="page"] .i { color: var(--accent); }
    .tab-add { order: 10; margin-top: 14px; height: 42px; padding: 0; justify-content: center; background: var(--accent); color: var(--accent-text); }
    .tab-add:hover { background: var(--accent-hover); color: var(--accent-text); }
    .tab-add .add-square { width: auto; height: auto; background: none; box-shadow: none; }
    .tab-add .tab-label { position: static; width: auto; height: auto; clip: auto; overflow: visible; }
    .tab-badge { top: 12px; left: auto; right: 12px; }
    .tabbar .side-foot { display: block; margin-top: auto; padding: 12px; font-size: 12px; color: var(--text-3); line-height: 1.5; order: 20; }
    .page { padding: 8px 32px 48px; }
    #page-tree { padding: 0 0 32px; }
    .tree-top { position: sticky; top: var(--header-h); z-index: 30; padding: 6px 24px 10px; }
    .tree-scroll { padding: 4px 24px 0; scroll-padding: 0 24px; scroll-snap-type: none; }
    .tree-column { width: 300px; }
    .guest-hero { margin: 4px 24px 12px; }
    .dg-toolbar { padding: 0 24px 10px; }
    .dg-stage { margin: 0 24px; height: calc(100vh - var(--header-h) - 196px); }
    .toast { bottom: 24px; }

    /* Карточка человека — панель справа, дерево остаётся видно */
    #infoModal { background: transparent; pointer-events: none; justify-content: flex-end; align-items: stretch; animation: none; }
    #infoModal .modal-card {
        pointer-events: auto; width: var(--panel-w); max-width: none; max-height: none; height: 100%;
        border-radius: 0; border-left: 1px solid var(--line); box-shadow: -12px 0 40px rgba(29, 27, 24, .07);
        padding: 24px 22px 32px; animation: panelIn .22s cubic-bezier(.2, .8, .2, 1);
    }
    #infoModal .modal-card::before { display: none; }
    body.panel-open main#app-pages { margin-right: var(--panel-w); }
    body.panel-open .app-header { margin-right: var(--panel-w); }
    @keyframes panelIn { from { transform: translateX(24px); opacity: .5; } to { transform: none; opacity: 1; } }

    .modal-overlay:not(#infoModal) { align-items: center; padding: 24px; }
    .modal-overlay:not(#infoModal) .modal-card { border-radius: var(--r-l); max-height: 86vh; padding: 26px 24px; animation: dialogIn .2s ease-out; }
    .modal-overlay:not(#infoModal) .modal-card::before { display: none; }
    @keyframes dialogIn { from { transform: scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
    .sheet-menu .modal-card { max-width: 380px; }
}

@media (min-width: 1280px) {
    .tree-column { width: 320px; }
}

@media (max-width: 380px) {
    .pc-actions { gap: 4px; }
    .pc-action { font-size: 11px; padding: 9px 2px; }
    .account-btn span.name { display: none; }
    .account-btn { padding: 0 4px; }
    .account-btn.guest { padding: 0 12px; }
}

/* ---------- Печать сызбы (PDF) ---------- */

#printArea { display: none; }
@media print {
    @page { size: A3 landscape; margin: 12mm; }
    body.printing { padding: 0 !important; background: #fff; zoom: 1 !important; }
    body.printing > *:not(#printArea) { display: none !important; }
    body.printing #printArea { display: block; color: #1D1B18; }
    #printArea h1 { font-size: 16pt; font-weight: 600; margin-bottom: 4mm; }
    #printArea p { font-size: 9pt; color: #5E5950; margin-bottom: 6mm; }
    #printArea svg { width: 100%; height: auto; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
