/* ==========================================================================
   MyFamilio — основной стиль
   ========================================================================== */

:root {
  --bg: #f7f3ea;
  --bg-deep: #efe8da;
  --surface: #fffdf9;
  --surface-soft: #fbf8f1;
  --ink: #202a24;
  --ink-soft: #43514a;
  --muted: #748077;
  --line: #e4ddd0;
  --line-strong: #d2c8b7;
  --accent: #2f6b4f;
  --accent-dark: #22513b;
  --accent-soft: #dfeae3;
  --accent-tint: #eef4ef;
  --terracotta: #b4713c;
  --terracotta-soft: #f3e3d4;
  --danger: #a8443d;
  --danger-dark: #8b352f;
  --danger-soft: #f9e9e7;
  --shadow-sm: 0 1px 2px rgba(31, 41, 35, 0.04);
  --shadow: 0 18px 45px -22px rgba(31, 41, 35, 0.25), 0 2px 6px rgba(31, 41, 35, 0.04);
  --radius: 18px;
  --radius-sm: 12px;
  --header-h: 73px;
  --font-body: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont,
    "Helvetica Neue", Arial, sans-serif;
  --font-display: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --sex-m: #5b83a6;
  --sex-f: #b06a8a;
  --sex-u: #99938a;
}

/* --- Reset ---------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(1100px 620px at 8% -12%, #fdfaf3 0%, transparent 62%),
    radial-gradient(900px 520px at 102% -4%, #f3ecdf 0%, transparent 58%),
    var(--bg);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

main {
  flex: 1 0 auto;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.015em;
  line-height: 1.12;
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 3.5vw, 2.9rem);
}

h2 {
  font-size: clamp(1.35rem, 2.1vw, 1.7rem);
}

h3 {
  font-size: 1.15rem;
}

p {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Layout --------------------------------------------------------------- */
.container {
  width: min(1200px, calc(100% - 3rem));
  margin-inline: auto;
}

.page {
  padding: 2.6rem 0 5rem;
}

.narrow-page {
  width: min(840px, 100%);
  margin-inline: auto;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.84rem;
}

.nowrap {
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-link {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}

.text-link:hover {
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.6rem;
}

/* --- Header --------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: rgba(247, 243, 234, 0.86);
  border-bottom: 1px solid rgba(210, 200, 183, 0.65);
  backdrop-filter: blur(14px);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--accent-dark);
  flex: 0 0 auto;
}

.brand:hover {
  color: var(--accent);
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: inline-flex;
  color: var(--accent);
}

.brand-mark svg {
  width: 100%;
  height: 100%;
}

.brand-mark-sm {
  width: 24px;
  height: 24px;
}

.brand-text {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.nav-link {
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-soft);
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  background: rgba(223, 234, 227, 0.65);
  color: var(--accent-dark);
}

.nav-link.is-active {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.nav-user-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex: 0 0 auto;
}

.account-menu {
  position: relative;
}

.account-trigger {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  max-width: 220px;
  padding: 0.32rem 0.55rem 0.32rem 0.34rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.84rem;
  cursor: pointer;
}

.account-trigger::-webkit-details-marker {
  display: none;
}

.account-trigger::marker {
  content: "";
}

.account-trigger:hover,
.account-menu[open] .account-trigger {
  border-color: var(--line-strong);
  background: var(--surface-soft);
  color: var(--accent-dark);
}

.account-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 130px;
}

.account-caret {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1;
  transition: transform 0.15s ease;
}

.account-menu[open] .account-caret {
  transform: rotate(180deg);
}

.account-panel {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  z-index: 60;
  min-width: 220px;
  max-width: min(280px, calc(100vw - 2rem));
  padding: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.account-label {
  margin: 0;
  padding: 0.35rem 0.65rem 0.2rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.account-email {
  margin: 0;
  padding: 0 0.65rem 0.45rem;
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.account-link {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.account-link:hover,
.account-link.is-active {
  background: var(--accent-tint);
  color: var(--accent-dark);
}

.account-logout-form {
  margin: 0.2rem 0 0;
  padding-top: 0.2rem;
  border-top: 1px solid var(--line);
}

.account-logout {
  color: var(--danger);
}

.account-logout:hover {
  background: var(--danger-soft);
  color: var(--danger-dark);
}

/* --- Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.72rem 1.15rem;
  border: 1px solid transparent;
  border-radius: 11px;
  font-size: 0.91rem;
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease,
    transform 0.16s ease, box-shadow 0.16s ease;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px -10px rgba(47, 107, 79, 0.75);
}

.btn-primary:hover {
  background: var(--accent-dark);
  color: #fff;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-color: transparent;
}

.btn-secondary:hover {
  background: #d3e3d8;
  color: var(--accent-dark);
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn-ghost:hover {
  border-color: var(--line-strong);
  background: #fff;
  color: var(--ink);
}

.btn-quiet {
  background: transparent;
  color: var(--muted);
}

.btn-quiet:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: var(--danger-dark);
  color: #fff;
}

.btn-sm {
  padding: 0.5rem 0.8rem;
  font-size: 0.82rem;
  border-radius: 9px;
}

.btn-lg {
  padding: 0.9rem 1.5rem;
  font-size: 0.98rem;
  border-radius: 12px;
}

.btn-block {
  width: 100%;
}

.heading-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* --- Badges --------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.24rem 0.62rem;
  border-radius: 999px;
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-public {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.badge-private {
  background: #ece6da;
  color: #7d7463;
}

.badge-soft {
  background: #f4efe5;
  color: #6f685c;
  font-weight: 600;
}

.badge-neutral {
  background: #eef0ee;
  color: #5b665f;
  font-weight: 600;
}

.badge-living {
  background: #e6f0e8;
  color: #2c6b47;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 700;
  vertical-align: 2px;
}

/* --- Messages ------------------------------------------------------------- */
.messages {
  display: grid;
  gap: 0.5rem;
  margin-top: 1rem;
}

.message {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.message.is-hiding {
  opacity: 0;
  transform: translateY(-4px);
}

.message-icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent-dark);
  margin-top: 0.05rem;
}

.message-success {
  border-color: #c5ddcd;
  background: #f4faf5;
}

.message-error {
  border-color: #e8c9c5;
  background: #fdf5f4;
}

.message-error .message-icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.message-warning {
  border-color: #ead7b9;
  background: #fdf9f1;
}

.message-warning .message-icon {
  background: var(--terracotta-soft);
  color: var(--terracotta);
}

/* --- Page headings -------------------------------------------------------- */
.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.page-heading-compact {
  margin-bottom: 1.5rem;
}

.page-lead {
  color: var(--muted);
  margin-top: 0.5rem;
  max-width: 62ch;
}

.section {
  margin-top: 3rem;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.1rem;
}

.section-head p {
  margin-top: 0.25rem;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 1.2rem;
}

.breadcrumbs a {
  color: var(--muted);
}

.breadcrumbs a:hover {
  color: var(--accent);
}

/* --- Landing -------------------------------------------------------------- */
.landing-page {
  padding-top: 0;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center;
  padding-top: clamp(2.5rem, 5vw, 4.5rem);
  padding-bottom: clamp(2.5rem, 4vw, 4rem);
}

.hero-copy {
  max-width: 34rem;
}

.hero h1 {
  font-size: clamp(2.6rem, 5.1vw, 4.25rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
}

.hero h1 em {
  color: var(--accent);
  font-style: italic;
  white-space: nowrap;
}

.hero-lead {
  margin-top: 1.3rem;
  font-size: 1.06rem;
  line-height: 1.65;
  color: var(--ink-soft);
  max-width: 46ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.8rem;
}

.hero-points {
  list-style: none;
  display: grid;
  gap: 0.55rem;
  margin-top: 2rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.hero-points li {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
}

.hero-points li::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
  transform: translateY(-2px);
}

.hero-art-wrap {
  width: 100%;
  max-width: 590px;
  justify-self: end;
}

.hero-art {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 30px 45px rgba(50, 58, 52, 0.1));
}

.hero-node-name {
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 650;
  fill: #2a352e;
}

.hero-node-years {
  font-family: var(--font-body);
  font-size: 9px;
  fill: #7b857d;
}

.hero-node-initial {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
}

.hero-node-initial-m {
  fill: #466b8a;
}

.hero-node-initial-f {
  fill: #975a77;
}

.hero-caption text {
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 600;
  fill: #6f7a72;
  letter-spacing: 0.03em;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.feature-card {
  background: rgba(255, 253, 249, 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-family: var(--font-display);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.feature-card h2 {
  font-size: 1.18rem;
  margin-bottom: 0.5rem;
}

.feature-card p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

.public-trees {
  padding-top: 4rem;
}

.tree-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.tree-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  overflow: hidden;
}

.tree-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--line-strong);
}

.tree-card-link {
  padding: 1.3rem 1.35rem 1.15rem;
  display: block;
  flex: 1;
}

.tree-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.tree-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: var(--accent-tint);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tree-card-icon svg {
  width: 29px;
  height: 29px;
}

.tree-card h3 {
  font-size: 1.22rem;
  margin-bottom: 0.35rem;
}

.tree-card-desc {
  font-size: 0.87rem;
  color: var(--muted);
  line-height: 1.55;
  min-height: 2.6em;
}

.tree-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  margin-top: 1rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.tree-card-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.tree-card-meta span + span::before {
  content: "·";
  color: var(--line-strong);
}

.tree-card-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.tree-card-actions .btn {
  flex: 1;
}

.cta-band {
  margin-top: 4.5rem;
  margin-bottom: 2rem;
  padding: clamp(2rem, 4vw, 3rem);
  border-radius: 26px;
  background:
    radial-gradient(700px 300px at 100% 0%, rgba(255, 255, 255, 0.09), transparent 60%),
    var(--accent-dark);
  color: #f6f1e6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.cta-copy h2 {
  color: #fffdf7;
  font-size: clamp(1.6rem, 2.5vw, 2.1rem);
  margin-bottom: 0.4rem;
}

.cta-copy p {
  color: rgba(246, 241, 230, 0.72);
  max-width: 52ch;
  font-size: 0.94rem;
}

.cta-band .btn-primary {
  background: #f5efe2;
  color: var(--accent-dark);
  box-shadow: none;
  flex: 0 0 auto;
}

.cta-band .btn-primary:hover {
  background: #fffdf8;
}

/* --- Statistics & dashboard ---------------------------------------------- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-card {
  position: relative;
  padding: 1.3rem 1.4rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
}

.stat-card-accent {
  background: linear-gradient(135deg, #f0f5f0, #e5eee7);
  border-color: #cfdfd3;
}

.stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: 2.5rem;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--accent-dark);
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.stat-icon {
  position: absolute;
  right: 1rem;
  bottom: 0.8rem;
  font-size: 1.7rem;
  opacity: 0.16;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 253, 249, 0.55);
  padding: clamp(2rem, 5vw, 3.5rem);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
}

.empty-state h3 {
  font-size: 1.4rem;
}

.empty-state p {
  color: var(--muted);
  max-width: 44ch;
  font-size: 0.92rem;
}

.empty-art {
  width: 150px;
  max-width: 60%;
  margin-bottom: 0.3rem;
  opacity: 0.9;
}

.empty-art svg {
  width: 100%;
  height: auto;
}

.recent-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}

.recent-person {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.recent-person:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
  color: inherit;
}

.recent-person-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.recent-person-text strong {
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-person-text small {
  font-size: 0.73rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Avatars -------------------------------------------------------------- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #ece7dc;
  color: #6b6254;
  font-weight: 700;
  overflow: hidden;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-xs {
  width: 30px;
  height: 30px;
  font-size: 0.66rem;
}

.avatar-sm {
  width: 38px;
  height: 38px;
  font-size: 0.74rem;
}

.avatar-md {
  width: 46px;
  height: 46px;
  font-size: 0.82rem;
}

.avatar-lg {
  width: 68px;
  height: 68px;
  font-size: 1.1rem;
}

.avatar-xl {
  width: 108px;
  height: 108px;
  font-size: 1.8rem;
  border-radius: 50%;
}

.sex-M {
  background: #e3ecf3;
  color: #42698a;
}

.sex-F {
  background: #f5e5ed;
  color: #945b77;
}

.sex-U {
  background: #ebe8e1;
  color: #777063;
}

/* --- Card ----------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.05rem 1.35rem;
  border-bottom: 1px solid var(--line);
}

.card-head h2 {
  font-size: 1.2rem;
}

.card > .prose {
  padding: 1.2rem 1.4rem 1.4rem;
}

/* --- Auth ----------------------------------------------------------------- */
.auth-layout {
  width: min(980px, 100%);
  margin: 1.5rem auto 4rem;
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, 0.94fr);
  gap: 1.5rem;
  align-items: stretch;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: clamp(1.6rem, 4vw, 2.8rem);
}

.auth-card h1 {
  font-size: clamp(2rem, 4vw, 2.6rem);
}

.auth-lead {
  margin-top: 0.4rem;
  font-size: 0.92rem;
}

.auth-form {
  margin-top: 1.6rem;
  display: grid;
  gap: 1rem;
}

.auth-form .btn {
  margin-top: 0.3rem;
}

.auth-switch {
  margin-top: 1.4rem;
  font-size: 0.87rem;
  color: var(--muted);
  text-align: center;
}

.auth-switch a {
  color: var(--accent);
  font-weight: 600;
}

.hero-note {
  margin-top: 0.85rem;
  max-width: 46ch;
}

.auth-invite {
  margin-top: 1.1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  display: grid;
  gap: 0.35rem;
}

.auth-invite p {
  margin: 0;
  font-size: 0.9rem;
}

.auth-invite .small {
  font-size: 0.78rem;
}

.auth-aside {
  border-radius: 24px;
  background:
    radial-gradient(420px 240px at 110% 0%, rgba(255, 255, 255, 0.1), transparent 60%),
    linear-gradient(160deg, #315c46, #224533 70%);
  color: #f4eee2;
  padding: clamp(1.8rem, 4vw, 2.8rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2rem;
}

.auth-points {
  list-style: none;
  display: grid;
  gap: 0.6rem;
  font-size: 0.87rem;
  color: rgba(244, 238, 226, 0.85);
}

.auth-points li {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
}

.auth-points li::before {
  content: "✦";
  color: #d9c7a5;
  font-size: 0.65rem;
}

.auth-aside h2 {
  color: #f8f3e8;
  font-size: 1.5rem;
  margin-bottom: 0.4rem;
}

.auth-aside p {
  margin: 0;
  color: rgba(244, 238, 226, 0.84);
  font-size: 0.9rem;
  line-height: 1.55;
}

.auth-switch span {
  margin: 0 0.35rem;
  color: var(--line-strong);
}

.auth-steps {
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 1.1rem;
  margin-top: 1rem;
}

.auth-steps li {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 0.7rem;
  align-items: start;
  font-size: 0.88rem;
  color: rgba(244, 238, 226, 0.84);
}

.auth-steps li span {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(244, 238, 226, 0.28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #f4eee2;
}

/* --- Forms ---------------------------------------------------------------- */
.form-card {
  padding: clamp(1.2rem, 3vw, 2rem);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-section {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--line);
}

.form-section:first-of-type {
  padding-top: 0;
}

.form-section:last-of-type {
  border-bottom: 0;
}

.form-section-head {
  margin-bottom: 1rem;
}

.form-section-head h2 {
  font-size: 1.22rem;
}

.form-section-head p {
  color: var(--muted);
  font-size: 0.84rem;
  margin-top: 0.2rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field > label {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--ink-soft);
}

.req {
  color: var(--terracotta);
  margin-left: 0.15rem;
}

.input {
  width: 100%;
  padding: 0.68rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 0.92rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder {
  color: #a9a397;
}

.input:hover {
  border-color: #bfb4a2;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.14);
}

textarea.input {
  resize: vertical;
  min-height: 90px;
  line-height: 1.55;
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23748077' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  padding-right: 2rem;
}

input[type="file"].input {
  padding: 0.55rem;
  background: var(--surface-soft);
  font-size: 0.84rem;
}

input[type="date"].input {
  min-height: 42px;
}

.help {
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.45;
}

.help ul {
  list-style: none;
  margin: 0.3rem 0 0;
}

.help a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.field-error {
  font-size: 0.78rem;
  color: var(--danger);
  font-weight: 600;
}

.has-error .input {
  border-color: #d9a49f;
  background: #fffafa;
}

.field-checkbox {
  flex-direction: row;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
}

.checkbox {
  width: 18px;
  height: 18px;
  margin-top: 0.1rem;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.form-error {
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  background: var(--danger-soft);
  border: 1px solid #e8c9c5;
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding-top: 1.5rem;
}

.form-actions-tight {
  padding-top: 0.8rem;
}

.current-photo {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.context-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  background: var(--accent-tint);
  border: 1px solid #cadfd1;
  margin-bottom: 1.2rem;
}

.context-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex: 0 0 auto;
}

.context-banner strong {
  display: block;
  font-size: 0.92rem;
}

.context-banner p {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-top: 0.15rem;
}

.context-change {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

/* --- Danger zone ---------------------------------------------------------- */
.danger-card {
  margin-top: 1.5rem;
  padding: 1.35rem 1.4rem;
  border-color: #e6c7c2;
  background: linear-gradient(180deg, #fffdfc, #fdf6f5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.danger-card h2 {
  font-size: 1.12rem;
  margin-bottom: 0.2rem;
}

.danger-card p {
  font-size: 0.84rem;
  max-width: 60ch;
}

.danger-card form {
  flex: 0 0 auto;
}

.danger-card-compact {
  display: block;
  padding: 1rem 1.2rem;
}

.danger-card-compact summary {
  cursor: pointer;
  font-weight: 650;
  font-size: 0.86rem;
  color: var(--danger);
  list-style: none;
}

.danger-card-compact summary::-webkit-details-marker {
  display: none;
}

.danger-card-compact summary::after {
  content: "+";
  float: right;
  font-weight: 500;
}

.danger-card-compact[open] summary::after {
  content: "×";
}

.danger-card-compact p {
  margin: 0.7rem 0;
}

/* --- Person list ---------------------------------------------------------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}

.filter-search {
  position: relative;
  flex: 1;
  min-width: 220px;
}

.filter-search svg {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.filter-search .input {
  padding-left: 2.4rem;
}

.filter-bar > .select {
  width: auto;
  min-width: 150px;
}

.person-table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.person-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 720px;
}

.person-table th {
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.person-table td {
  padding: 0.72rem 1rem;
  border-bottom: 1px solid #eee9de;
  vertical-align: middle;
  color: var(--ink-soft);
}

.person-table tbody tr:last-child td {
  border-bottom: 0;
}

.person-table tbody tr:hover {
  background: #fcfaf5;
}

.person-cell {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
}

.person-cell:hover {
  color: var(--accent);
}

.person-cell > span:last-child {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.person-cell strong {
  font-weight: 650;
  white-space: nowrap;
}

.person-cell small {
  color: var(--muted);
  font-size: 0.73rem;
}

.row-actions {
  text-align: right;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
  font-size: 0.84rem;
}

.page-link {
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink-soft);
}

.page-link:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.page-link.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.page-info {
  color: var(--muted);
}

/* --- Person profile ------------------------------------------------------- */
.person-hero {
  display: flex;
  align-items: center;
  gap: 1.6rem;
  padding: clamp(1.2rem, 3vw, 2rem);
  margin-bottom: 1.3rem;
  background:
    radial-gradient(700px 300px at 100% 0%, #f2f5ef, transparent 65%),
    var(--surface);
}

.person-hero-body {
  flex: 1;
  min-width: 0;
}

.person-hero-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
}

.person-hero h1 {
  font-size: clamp(1.9rem, 3.2vw, 2.65rem);
}

.person-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.65rem;
}

.person-years {
  font-size: 0.9rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  margin-right: 0.25rem;
}

.readonly-note {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  background: #efe9dc;
  border: 1px solid #e3dac9;
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin-bottom: 1.3rem;
}

.readonly-note a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.person-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
  gap: 1.3rem;
  align-items: start;
}

.person-main {
  display: grid;
  gap: 1.3rem;
  min-width: 0;
}

.person-main > *,
.person-side > * {
  min-width: 0;
}

.person-side {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.facts-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.2rem 1.4rem;
  margin: 0;
  padding: 1.3rem 1.4rem 1.45rem;
}

.fact dt {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.fact dd {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink);
}

.fact-extra {
  display: block;
  color: var(--muted);
  font-size: 0.79rem;
  margin-top: 0.15rem;
}

.prose {
  font-size: 0.94rem;
  line-height: 1.72;
  color: var(--ink-soft);
}

.prose p {
  margin: 0 0 0.85rem;
}

.prose p:last-child {
  margin-bottom: 0;
}

.inline-details {
  position: relative;
}

.inline-details > summary {
  list-style: none;
  cursor: pointer;
}

.inline-details > summary::-webkit-details-marker {
  display: none;
}

.inline-details:not([open]) > .event-form {
  display: none;
}

.event-form {
  position: absolute;
  right: 0;
  top: calc(100% + 0.55rem);
  z-index: 20;
  width: min(600px, calc(100vw - 4rem));
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: grid;
  gap: 0.85rem;
}

.event-form .form-grid {
  gap: 0.75rem;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 1.3rem 1.4rem 0.4rem;
}

.timeline-item {
  position: relative;
  padding: 0 2rem 1.25rem 1.45rem;
  margin-left: 0.32rem;
  border-left: 1px solid var(--line);
}

.timeline-item:last-child {
  border-color: transparent;
  padding-bottom: 0.8rem;
}

.timeline-dot {
  position: absolute;
  left: -4.5px;
  top: 0.38rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--surface);
}

.timeline-head {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.timeline-head strong {
  font-size: 0.9rem;
}

.timeline-date {
  font-size: 0.76rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.timeline-place {
  font-size: 0.8rem;
  color: var(--terracotta);
  margin-top: 0.15rem;
}

.timeline-desc {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-top: 0.3rem;
  line-height: 1.55;
}

.timeline-remove {
  position: absolute;
  top: -0.15rem;
  right: 0;
}

.relation-block {
  padding: 1rem 1.35rem 0.35rem;
  border-bottom: 1px solid var(--line);
}

.relation-block:last-child {
  border-bottom: 0;
  padding-bottom: 1.2rem;
}

.relation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
}

.relation-head h3 {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.mini-link {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.mini-link:hover {
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.relation-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.34rem 0;
  border-radius: 8px;
}

.relation-person {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  flex: 1;
  padding: 0.15rem 0.2rem;
  border-radius: 8px;
  color: var(--ink);
}

.relation-person:hover {
  background: var(--surface-soft);
  color: var(--accent-dark);
}

.relation-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.relation-text strong {
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.relation-text small {
  font-size: 0.72rem;
  color: var(--muted);
}

.relation-empty {
  font-size: 0.8rem;
  color: #9b958a;
  padding: 0.35rem 0.2rem 0.55rem;
}

.relation-hint {
  font-size: 0.74rem;
  color: var(--terracotta);
  padding: 0.25rem 0.2rem 0.6rem;
}

.unlink-form {
  display: flex;
  flex: 0 0 auto;
}

.icon-btn {
  width: 25px;
  height: 25px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #a49d91;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.relation-row:hover .icon-btn,
.relation-row:focus-within .icon-btn,
.timeline-item:hover .icon-btn,
.timeline-item:focus-within .icon-btn {
  opacity: 1;
}

.icon-btn:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.icon-btn-edit {
  opacity: 1;
  font-size: 0.8rem;
}

.icon-btn-edit:hover {
  background: var(--surface-soft);
  color: var(--accent);
}

@media (hover: none) {
  .icon-btn {
    opacity: 1;
  }
}

.side-card {
  padding: 1.1rem 1.2rem;
}

.side-card-title {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.55rem;
}

.side-links {
  display: grid;
  gap: 0.1rem;
}

.side-links a {
  padding: 0.42rem 0.2rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  border-bottom: 1px solid #f0ebe1;
}

.side-links a:last-child {
  border-bottom: 0;
}

.side-links a:hover {
  color: var(--accent);
}

.link-existing > summary {
  cursor: pointer;
  font-weight: 650;
  font-size: 0.88rem;
  color: var(--accent-dark);
  list-style: none;
}

.link-existing > summary::-webkit-details-marker {
  display: none;
}

.link-existing > summary::after {
  content: "+";
  float: right;
  font-weight: 500;
  color: var(--muted);
}

.link-existing[open] > summary::after {
  content: "×";
}

.link-existing p {
  margin-top: 0.4rem;
}

.link-form {
  display: grid;
  gap: 0.3rem;
  margin-top: 0.8rem;
}

.link-form .field {
  margin-bottom: 0.45rem;
}

/* --- Tree page ------------------------------------------------------------ */
.tree-page-main {
  height: calc(100dvh - var(--header-h));
  overflow: hidden;
  padding: 0;
  width: 100%;
  max-width: none;
}

.tree-app {
  position: relative;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: 100%;
  background: var(--bg);
}

.tree-sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #fcfaf5;
  border-right: 1px solid var(--line);
}

.tree-sidebar-close {
  display: none;
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 2;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  align-items: center;
  justify-content: center;
}

.tree-sidebar-close:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

.tree-sidebar-head {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid #eee8dc;
}

.back-link {
  display: inline-block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.65rem;
}

.back-link:hover {
  color: var(--accent);
}

.tree-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
}

.tree-title-row h1 {
  font-size: 1.42rem;
  line-height: 1.15;
  min-width: 0;
  overflow-wrap: anywhere;
}

.tree-sidebar-head > .small {
  margin-top: 0.3rem;
}

.tree-sidebar-desc {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 0.55rem;
}

.tree-sidebar-actions {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.95rem;
}

.sidebar-search {
  position: relative;
  margin: 0.9rem 1.1rem 0.7rem;
}

.sidebar-search .search-icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.sidebar-search input {
  width: 100%;
  padding: 0.58rem 0.7rem 0.58rem 2.2rem;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fff;
  font-size: 0.84rem;
}

.sidebar-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.13);
}

.sidebar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.8rem;
  padding: 0 1.2rem 0.7rem;
  font-size: 0.68rem;
  color: var(--muted);
}

.sidebar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot-m {
  background: var(--sex-m);
}

.legend-dot-f {
  background: var(--sex-f);
}

.legend-dot-u {
  background: var(--sex-u);
}

.sidebar-legend-lines {
  padding-top: 0;
  margin-top: -0.35rem;
}

.legend-line {
  display: inline-block;
  width: 18px;
  height: 0;
  border-top: 2px solid #c58f65;
}

.legend-line-divorce {
  border-top-style: dashed;
  opacity: 0.75;
}

.legend-line-parent {
  border-top-color: #c2b7a4;
}

.person-index {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 0.65rem 0.8rem;
  scrollbar-width: thin;
}

.sidebar-loading {
  padding: 0.6rem;
}

.person-index-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.55rem;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  color: var(--ink);
  transition: background 0.14s ease;
}

.person-index-item:hover {
  background: #f1ece1;
}

.person-index-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.person-index-name {
  font-size: 0.81rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person-index-meta {
  font-size: 0.69rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person-index-empty {
  padding: 0.7rem 0.55rem;
}

.tree-sidebar-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  padding: 0.75rem 1.2rem;
  border-top: 1px solid #eee8dc;
  font-size: 0.75rem;
}

.tree-sidebar-footer a {
  color: var(--muted);
}

.tree-sidebar-footer a:hover {
  color: var(--accent);
}

.tree-canvas-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.tree-toolbar {
  height: 54px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
  background: rgba(252, 250, 245, 0.9);
  border-bottom: 1px solid var(--line);
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.tool-btn {
  height: 32px;
  min-width: 32px;
  padding: 0 0.45rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  line-height: 1;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.tool-btn:hover {
  background: #fff;
  border-color: var(--line-strong);
}

.tool-btn svg {
  width: 17px;
  height: 17px;
}

.tool-btn-wide {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0 0.7rem;
}

.tool-btn[data-action="sidebar"] {
  display: none;
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--line);
  margin: 0 0.2rem;
}

.zoom-label {
  min-width: 44px;
  text-align: center;
  font-size: 0.74rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.toolbar-hint {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}

.tree-canvas {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  outline: none;
  background-color: #f1ece1;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(150, 140, 122, 0.32) 0.8px, transparent 0.8px),
    radial-gradient(800px 500px at 18% 0%, rgba(255, 253, 247, 0.85), transparent 60%);
  background-size: 22px 22px, 100% 100%;
}

.tree-canvas.is-panning {
  cursor: grabbing;
}

.tree-stage {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.tree-edges {
  position: absolute;
  top: 0;
  left: 0;
  overflow: visible;
  pointer-events: none;
}

.tree-nodes {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* contacts / edges */
.edge {
  fill: none;
  stroke: #bdb2a0;
  stroke-width: 1.55;
  stroke-linecap: round;
  transition: stroke 0.15s ease;
}

.edge-parent {
  stroke: #c2b7a4;
}

.edge-parent--secondary {
  stroke-dasharray: 2 5;
  opacity: 0.4;
}

.edge-partnership {
  stroke: #c58f65;
  stroke-width: 1.9;
}

.edge-partnership--ended {
  stroke-dasharray: 5 4;
  opacity: 0.75;
}

.edge-partnership--secondary {
  stroke-dasharray: 3 5;
  opacity: 0.5;
}

.edge-union-dot {
  fill: var(--terracotta);
  stroke: #f1ece1;
  stroke-width: 1.5;
}

/* nodes */
.node {
  position: absolute;
  width: 188px;
  height: 84px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 11px 9px;
  border: 1px solid #e4dccf;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 7px 20px -12px rgba(44, 52, 46, 0.3), 0 1px 2px rgba(44, 52, 46, 0.03);
  pointer-events: auto;
  color: var(--ink);
  text-decoration: none;
  transition: box-shadow 0.16s ease, border-color 0.16s ease, background 0.16s ease;
  z-index: 1;
}

.node::before {
  content: "";
  position: absolute;
  top: 0;
  left: 13px;
  right: 13px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--sex-color, var(--sex-u));
  opacity: 0.9;
}

.node:hover {
  border-color: var(--sex-color, var(--line-strong));
  box-shadow: 0 12px 26px -12px rgba(44, 52, 46, 0.38), 0 2px 4px rgba(44, 52, 46, 0.05);
  color: var(--ink);
  z-index: 3;
}

.node--m {
  --sex-color: var(--sex-m);
}

.node--f {
  --sex-color: var(--sex-f);
}

.node--u {
  --sex-color: var(--sex-u);
}

.node.is-root {
  border-color: #c9d9cd;
}

.node.is-focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.17), 0 8px 22px -12px rgba(44, 52, 46, 0.35);
}

.node.is-highlighted {
  animation: nodePulse 0.85s ease-in-out 2;
}

@keyframes nodePulse {
  0%,
  100% {
    box-shadow: 0 7px 20px -12px rgba(44, 52, 46, 0.3);
  }
  45% {
    box-shadow: 0 0 0 7px rgba(47, 107, 79, 0.22), 0 9px 24px -10px rgba(44, 52, 46, 0.35);
  }
}

.node-avatar {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f0ece3;
  color: #6e6557;
  font-size: 0.78rem;
  font-weight: 700;
  overflow: hidden;
}

.node--m .node-avatar {
  background: #e6eef4;
  color: #42698a;
}

.node--f .node-avatar {
  background: #f5e6ed;
  color: #945b77;
}

.node-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.node-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.node-name {
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-years {
  font-size: 0.71rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-place {
  font-size: 0.66rem;
  color: #9b9588;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.05rem;
}

.tree-loader,
.tree-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.86rem;
  color: var(--muted);
  background: rgba(241, 236, 225, 0.78);
  backdrop-filter: blur(1px);
  z-index: 5;
}

.loader-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: loaderPulse 1s ease-in-out infinite;
}

@keyframes loaderPulse {
  0%,
  100% {
    transform: scale(0.75);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.1);
    opacity: 1;
  }
}

.tree-error {
  color: var(--danger);
  text-align: center;
  padding: 2rem;
}

.tree-empty {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  text-align: center;
  padding: 2rem;
  background: rgba(241, 236, 225, 0.55);
}

.tree-empty h2 {
  font-size: 1.7rem;
}

.tree-empty p {
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 40ch;
}

.tree-empty .empty-art {
  width: 110px;
}

/* --- Footer --------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: rgba(252, 250, 245, 0.65);
  padding: 1.4rem 0;
  flex: 0 0 auto;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent-dark);
}

/* --- Photo gallery -------------------------------------------------------- */
.photo-gallery-card .card-head {
  flex-wrap: wrap;
}

.card-head-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.9rem;
  padding: 1.2rem 1.35rem 1.4rem;
}

.photo-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.photo-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
}

.photo-card-media {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--bg-deep);
}

.photo-card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-card-body {
  display: grid;
  gap: 0.22rem;
  min-width: 0;
  padding: 0.7rem 0.8rem 0.8rem;
}

.photo-card-title {
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.3;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.photo-card-meta {
  color: var(--muted);
  font-size: 0.72rem;
}

.photo-card-people {
  color: var(--accent);
  font-size: 0.72rem;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-empty {
  padding: 1.6rem 1.35rem;
  text-align: center;
}

.photo-empty p {
  margin: 0;
  font-size: 0.88rem;
}

/* --- People picker -------------------------------------------------------- */
.people-picker-field {
  gap: 0.55rem;
}

.people-search {
  max-width: 420px;
}

.people-picker-list {
  display: grid;
  gap: 0.1rem;
  max-height: 270px;
  overflow-y: auto;
  padding: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.people-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  padding: 0.42rem 0.5rem;
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 0.88rem;
  cursor: pointer;
}

.people-option:hover {
  background: #fff;
}

.people-option input {
  flex: 0 0 auto;
}

.people-option span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.people-picker-empty {
  padding: 0.4rem 0.5rem;
}

/* --- Photo detail --------------------------------------------------------- */
.photo-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 1.3rem;
  align-items: start;
}

.photo-detail-main {
  overflow: hidden;
}

.photo-detail-image {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: #f3eee5;
}

.photo-detail-image img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 74vh;
  object-fit: contain;
  border-radius: 8px;
}

.photo-detail-side {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.photo-detail-body {
  display: grid;
  gap: 0.8rem;
  padding: 1.05rem 1.3rem;
}

.photo-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.85rem;
}

.photo-meta-row a {
  color: var(--accent);
  font-weight: 600;
}

.photo-label {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.photo-people {
  display: grid;
  gap: 0.35rem;
}

.photo-people-list {
  display: grid;
  gap: 0.2rem;
}

.photo-people-list .relation-person {
  padding: 0.3rem 0.2rem;
}

.photo-uploaded {
  margin: 0;
}

.photo-detail-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0 1.3rem 1.2rem;
}

.photo-detail-actions form {
  display: flex;
}

/* ==========================================================================
   Адаптивность
   ========================================================================== */
@media (max-width: 1100px) {
  .tree-grid,
  .recent-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .person-layout {
    grid-template-columns: minmax(0, 1fr) 340px;
  }

  .facts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .hero {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
    gap: 2rem;
  }

  .hero-art-wrap {
    max-width: 480px;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }

  .feature-card {
    padding: 1.25rem;
  }

  .person-layout {
    grid-template-columns: 1fr;
  }

  .photo-detail-layout {
    grid-template-columns: 1fr;
  }

  .person-side {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .person-side > .card:first-child {
    grid-column: 1 / -1;
  }

  .tree-sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(322px, 88vw);
    transform: translateX(-103%);
    transition: transform 0.22s ease;
    box-shadow: 20px 0 45px -30px rgba(31, 41, 35, 0.45);
  }

  .tree-app {
    grid-template-columns: minmax(0, 1fr);
  }

  .tree-sidebar-close {
    display: inline-flex;
  }

  .tree-app.sidebar-open .tree-sidebar {
    transform: none;
  }

  .tool-btn[data-action="sidebar"] {
    display: inline-flex;
  }

  .toolbar-hint {
    display: none;
  }
}

@media (max-width: 780px) {
  .container {
    width: calc(100% - 2rem);
  }

  .page {
    padding-top: 1.8rem;
    padding-bottom: 3.5rem;
  }

  .site-header {
    height: auto;
    min-height: var(--header-h);
  }

  .header-inner {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.55rem 0;
  }

  .site-nav {
    flex-wrap: wrap;
    gap: 0.15rem;
  }

  .nav-link {
    padding: 0.4rem 0.55rem;
    font-size: 0.84rem;
  }

  .account-trigger {
    max-width: 190px;
  }

  .account-name {
    max-width: 100px;
  }

  .hero {
    grid-template-columns: 1fr;
    padding-top: 2.2rem;
  }

  .hero-art-wrap {
    max-width: 520px;
    justify-self: center;
    order: -1;
    margin-bottom: 0.5rem;
  }

  .hero h1 {
    font-size: clamp(2.35rem, 9vw, 3.2rem);
  }

  .hero h1 em {
    white-space: normal;
  }

  .hero-lead {
    font-size: 0.98rem;
  }

  .page-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .page-heading > .btn {
    width: 100%;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .stats-row {
    grid-template-columns: 1fr;
  }

  .tree-grid,
  .recent-grid {
    grid-template-columns: 1fr;
  }

  .cta-band {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.4rem;
  }

  .cta-band .btn {
    width: 100%;
  }

  .auth-layout {
    grid-template-columns: 1fr;
    margin-top: 0.5rem;
  }

  .auth-aside {
    display: none;
  }

  .form-grid,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .form-section {
    padding: 1.2rem 0;
  }

  .event-form {
    position: fixed;
    left: 1rem;
    right: 1rem;
    top: auto;
    bottom: 1rem;
    width: auto;
    max-height: 70vh;
    overflow-y: auto;
    z-index: 80;
  }

  .facts-grid {
    grid-template-columns: 1fr 1fr;
  }

  .person-hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 1rem;
  }

  .person-hero-head {
    flex-direction: column;
    gap: 1rem;
  }

  .person-hero .heading-actions {
    width: 100%;
  }

  .person-hero .heading-actions .btn {
    flex: 1;
  }

  .person-side {
    grid-template-columns: 1fr;
  }

  .person-side > .card:first-child {
    grid-column: auto;
  }

  .filter-bar > .select,
  .filter-bar > .btn {
    flex: 1;
  }

  .danger-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .danger-card form,
  .danger-card .btn {
    width: 100%;
  }

  .pagination {
    justify-content: space-between;
    gap: 0.5rem;
  }

  .tree-page-main {
    height: auto;
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
  }

  .tree-app {
    height: auto;
    min-height: 0;
    flex: 1 1 auto;
  }

  .tree-toolbar {
    padding: 0 0.6rem;
  }

  .zoom-label {
    min-width: 36px;
  }

  .tree-sidebar-head {
    padding: 1rem;
  }
}

@media (max-width: 520px) {
  .hero-points {
    font-size: 0.83rem;
  }

  .hero-actions .btn {
    width: 100%;
  }

  .brand-text {
    font-size: 1.12rem;
  }

  .account-trigger {
    max-width: 160px;
  }

  .account-name {
    max-width: 72px;
  }

  .account-panel {
    position: fixed;
    top: var(--account-panel-top, 140px);
    right: 1rem;
    left: 1rem;
    width: auto;
    min-width: 0;
    max-width: none;
    margin: 0;
  }

  .nav-link {
    font-size: 0.8rem;
  }

  .stat-value {
    font-size: 2.1rem;
  }

  .person-meta {
    gap: 0.35rem;
  }

  .avatar-xl {
    width: 86px;
    height: 86px;
    font-size: 1.45rem;
  }

  .facts-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.65rem;
    padding: 1rem;
  }

  .photo-card-body {
    padding: 0.6rem;
  }

  .photo-card-title {
    font-size: 0.82rem;
  }

  .photo-gallery-card .card-head-actions {
    width: 100%;
  }

  .photo-gallery-card .card-head-actions .btn {
    flex: 1;
  }

  .photo-detail-image {
    padding: 0.5rem;
  }

  .photo-detail-actions .btn {
    flex: 1;
  }

  .people-picker-list {
    max-height: 220px;
  }

  .timeline {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .timeline-item {
    padding-right: 1.7rem;
  }

  .side-card {
    padding: 1rem;
  }

  .tree-title-row {
    flex-direction: column;
    gap: 0.3rem;
  }

  .tool-btn-wide {
    display: none;
  }

  .person-table {
    min-width: 620px;
  }
}

/* --- Совместный доступ ---------------------------------------------------- */
.access-callout {
  margin-top: 1.5rem;
  padding: 1.35rem 1.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.access-callout h2 {
  font-size: 1.12rem;
  margin-bottom: 0.2rem;
}

.access-callout p {
  font-size: 0.84rem;
  max-width: 60ch;
}

.access-section {
  padding: 1.25rem 1.35rem;
  margin-bottom: 1.15rem;
}

.access-section .card-head {
  padding: 0 0 0.85rem;
  margin-bottom: 1rem;
  align-items: flex-start;
}

.access-section .card-head h2 {
  font-size: 1.12rem;
}

.access-section .card-head p {
  margin: 0.15rem 0 0;
}

.invite-form {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.invite-form .field {
  margin: 0;
  min-width: 180px;
  flex: 1 1 180px;
}

.member-list {
  display: flex;
  flex-direction: column;
}

.member-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.7rem 0;
  border-top: 1px solid var(--line);
}

.member-row:first-child {
  border-top: 0;
}

.member-person {
  display: flex;
  flex-direction: column;
  flex: 1 1 160px;
  min-width: 120px;
}

.member-name {
  font-size: 0.9rem;
}

.member-meta {
  color: var(--muted);
  font-size: 0.74rem;
}

.member-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.member-actions .select {
  width: auto;
  padding: 0.4rem 0.55rem;
  font-size: 0.8rem;
}

.danger-text {
  color: var(--danger);
}

.share-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.share-link .input {
  flex: 1 1 280px;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.78rem;
}

.share-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.85rem;
}

.avatar-owner {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.member-empty {
  padding: 0.5rem 0 0.15rem;
}

@media (max-width: 760px) {
  .access-callout {
    flex-direction: column;
    align-items: flex-start;
  }

  .access-callout .btn {
    width: 100%;
  }

  .access-section .card-head {
    flex-direction: column;
    gap: 0.65rem;
  }

  .access-section .card-head > .btn {
    width: 100%;
  }

  .member-actions,
  .member-actions .btn,
  .share-link .btn {
    width: 100%;
  }

  .member-actions .select {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
