/*
 * Оформление «Тамга и войлок»: пергамент, тёмная хвоя гор, золото тамг
 * и марена карачаевских войлочных ковров (кийиз).
 */
:root {
  --bg-deep: #f2ece0;
  --bg-surface: #fffdf8;
  --bg-elevated: #f8f3e9;
  --bg-glass: rgba(255, 253, 248, 0.94);
  --parchment: #f6eedc;
  --parchment-border: #dccdab;
  --ink: #14211c;
  --ink-soft: #1f3129;
  --text-main: #1d2420;
  --text-secondary: #5b625b;
  --text-muted: #8f948b;
  --gold: #a87a26;
  --gold-light: #7a5714;
  --gold-bright: #d8b35e;
  --gold-dim: rgba(168, 122, 38, 0.10);
  --gold-border: rgba(168, 122, 38, 0.34);
  --emerald: #1f5c47;
  --emerald-dim: rgba(31, 92, 71, 0.09);
  --madder: #9b3a2a;
  --madder-dim: rgba(155, 58, 42, 0.09);
  --crimson: #b3283d;
  --azure: #1d6fa5;
  --border-subtle: #e4dac6;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-card: 0 1px 2px rgba(20, 33, 28, 0.04), 0 12px 32px -12px rgba(20, 33, 28, 0.14);
  --font-display: 'Cormorant Garamond', 'Georgia', 'Times New Roman', serif;
  --font-ui: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(circle at 12% 10%, rgba(166, 120, 35, 0.06) 0%, transparent 42%),
    radial-gradient(circle at 88% 18%, rgba(30, 107, 78, 0.06) 0%, transparent 45%);
  color: var(--text-main);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  min-height: 100vh;
}

/* Header & Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 2px 14px rgba(28, 38, 32, 0.04);
}

.header-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-emblem {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f7efe0, #efe2c6);
  border: 1px solid var(--gold-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-weight: 800;
  font-size: 20px;
}

.brand-text h1 {
  font-size: 18.5px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-subtitle {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.nav-tabs {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.nav-btn {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 15px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.18s ease;
}

.nav-btn:hover {
  border-color: var(--gold-border);
  color: var(--text-main);
  background: var(--bg-surface);
}

.nav-btn.active {
  background: var(--emerald);
  color: #ffffff;
  border-color: var(--emerald);
  box-shadow: 0 4px 12px rgba(30, 107, 78, 0.2);
}

.nav-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--gold-dim);
  color: var(--gold-light);
  font-weight: 700;
}

/* Shared Invite Banner */
.invite-banner {
  max-width: 1320px;
  margin: 16px auto 0;
  padding: 0 20px;
  display: none;
}

.invite-banner.visible {
  display: block;
}

.invite-banner-inner {
  background: linear-gradient(90deg, rgba(166, 120, 35, 0.10), rgba(30, 107, 78, 0.10));
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* Main Container */
.main-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 22px 60px;
}

.view-section {
  display: none;
  animation: fadeIn 0.2s ease-out;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* KPI Strip */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 15px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-card);
}

.kpi-label {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.kpi-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.kpi-sub {
  font-size: 12px;
  color: var(--emerald);
  font-weight: 600;
}

/* Cards & Grid Layouts */
.grid-2col {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 22px;
  align-items: start;
}

@media (max-width: 980px) {
  .grid-2col {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.card-title {
  font-size: 16.5px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 3px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-main);
  transition: all 0.16s ease;
  text-decoration: none;
}

.btn:hover {
  border-color: var(--gold-border);
  background: var(--bg-deep);
}

.btn-primary,
.btn-gold {
  background: var(--emerald);
  color: #ffffff;
  border-color: var(--emerald);
  font-weight: 600;
}

.btn-primary:hover,
.btn-gold:hover {
  background: #17563e;
  color: #ffffff;
}

.btn-emerald {
  background: var(--emerald-dim);
  color: var(--emerald);
  border-color: rgba(30, 107, 78, 0.3);
  font-weight: 600;
}

.btn-emerald:hover {
  background: rgba(30, 107, 78, 0.18);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
}

/* Tamga Parchment Plate */
.tamga-plate {
  width: 60px;
  height: 46px;
  background: var(--parchment);
  border: 1px solid var(--parchment-border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  flex-shrink: 0;
}

.tamga-plate img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.tamga-plate.lg {
  width: 84px;
  height: 62px;
  padding: 6px;
}

.tamga-plate.sm {
  width: 44px;
  height: 34px;
  padding: 3px;
}

/* Generation Builder (Section 1) */
.profile-switcher-bar {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.gen-tier {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
}

.gen-tier.discovered-tier {
  border-color: rgba(30, 107, 78, 0.4);
  background: linear-gradient(180deg, rgba(30, 107, 78, 0.06), #ffffff);
}

.gen-tier-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
  flex-wrap: wrap;
}

.gen-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--emerald);
  letter-spacing: 0.01em;
}

.gen-tag {
  font-size: 11.5px;
  padding: 2px 9px;
  border-radius: 999px;
  background: #ece7da;
  color: var(--text-secondary);
  font-weight: 600;
}

.gen-tag.merged {
  background: var(--emerald-dim);
  color: var(--emerald);
  border: 1px solid rgba(30, 107, 78, 0.3);
  font-weight: 600;
}

.ancestor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.person-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  position: relative;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.person-box:focus-within {
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(30, 107, 78, 0.08);
}

.person-box.auto-merged {
  border-color: rgba(30, 107, 78, 0.45);
  background: rgba(30, 107, 78, 0.04);
}

.person-fields {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.role-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.field-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid #dcd5c4;
  color: var(--text-main);
  border-radius: 9px;
  padding: 8px 11px;
  font-size: 13.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field-input:focus {
  outline: none;
  background: var(--bg-surface);
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(30, 107, 78, 0.1);
}

.field-input-lg {
  padding: 13px 15px;
  font-size: 15.5px;
  border-radius: 11px;
}

/* Clan Autocomplete */
.clan-picker-wrap {
  position: relative;
}

.clan-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  z-index: 60;
  background: var(--bg-surface);
  border: 1px solid var(--gold-border);
  border-radius: 12px;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 14px 34px rgba(28, 38, 32, 0.16);
  display: none;
}

.clan-dropdown.open {
  display: block;
}

.clan-option {
  padding: 9px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border-bottom: 1px solid #f1ece1;
}

.clan-option:hover {
  background: var(--bg-elevated);
}

.clan-option-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
}

.clan-option-sub {
  font-size: 12px;
  color: var(--gold);
}

/* Auto-merge Discovery Alert */
.merge-alert {
  background: rgba(30, 107, 78, 0.08);
  border: 1px solid rgba(30, 107, 78, 0.35);
  border-radius: 12px;
  padding: 13px 16px;
  margin-top: 12px;
}

.merge-alert-title {
  font-weight: 700;
  color: var(--emerald);
  font-size: 14px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Heraldic Shield & Tamga Pattern Preview */
.shield-stage {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.shield-coat {
  width: 100%;
  max-width: 390px;
  background: var(--bg-surface);
  border: 2px solid #c9b483;
  border-radius: 18px 18px 40px 40px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(28, 38, 32, 0.07);
}

.shield-coat-header {
  text-align: center;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.shield-coat-header h3 {
  font-size: 15.5px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: 0.02em;
}

.shield-coat-header p {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.shield-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.shield-cell {
  background: var(--parchment);
  border: 1px solid var(--parchment-border);
  border-radius: 12px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: var(--text-main);
  min-height: 112px;
  justify-content: space-between;
}

.shield-cell-role {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
}

.shield-cell img {
  height: 46px;
  max-width: 110px;
  object-fit: contain;
  margin: 4px 0;
}

.shield-cell-clan {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-main);
}

.shield-cell-krc {
  font-size: 11px;
  color: var(--gold-light);
  font-weight: 600;
}

.reading-scroll {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px 15px;
}

.reading-scroll h4 {
  font-size: 12.5px;
  color: var(--emerald);
  margin-bottom: 8px;
  font-weight: 700;
}

.reading-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border-subtle);
  font-size: 13px;
}

.reading-line:last-child {
  border-bottom: none;
}

/* Social Link & Kinship Matcher (Section 2) */
.share-url-box {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 10px 0 14px;
}

.share-url-input {
  flex: 1;
  min-width: 0;
  text-overflow: ellipsis;
  background: transparent;
  border: none;
  color: var(--emerald);
  font-family: monospace;
  font-size: 13px;
  outline: none;
}

.share-caption-box {
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.share-link-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--gold-border);
  background: var(--bg-elevated);
  color: var(--emerald);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.share-link-chip:hover {
  border-color: var(--emerald);
}

.kinship-result-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.kinship-result-card:hover {
  border-color: var(--gold-border);
}

.kinship-degree-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--emerald-dim);
  color: var(--emerald);
  border: 1px solid rgba(30, 107, 78, 0.3);
}

.kinship-degree-badge.inlaw {
  background: var(--gold-dim);
  color: var(--gold-light);
  border-color: var(--gold-border);
}

.kinship-path-chain {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.chain-node {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 12px;
}

.chain-node.common-ancestor {
  border-color: var(--emerald);
  background: var(--emerald-dim);
  color: var(--emerald);
  font-weight: 700;
}

/* Analytics Charts & Tables (Section 3) */
.bar-chart-row {
  display: grid;
  grid-template-columns: 155px 1fr 110px;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.bar-track {
  width: 100%;
  height: 12px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--emerald));
  border-radius: 999px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
}

/* Full 805 Clans Catalog Grid (Section 4) */
.clans-browser-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 12px;
}

.clan-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.clan-card:hover {
  border-color: var(--emerald);
  background: var(--bg-surface);
  transform: translateY(-2px);
}

.alpha-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 12px 0 16px;
}

.alpha-pill {
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.alpha-pill:hover {
  border-color: var(--gold-border);
  color: var(--text-main);
}

.alpha-pill.active {
  background: var(--emerald);
  color: #ffffff;
  border-color: var(--emerald);
}

/* ========================================================================== */
/* ONBOARDING WIZARD MODAL (ЖИВОЙ ДИАЛОГ ЗНАКОМСТВА)                          */
/* ========================================================================== */
.wizard-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(26, 34, 29, 0.42);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.wizard-backdrop.open {
  display: flex;
}

.wizard-modal {
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 22px;
  box-shadow: 0 24px 64px rgba(24, 34, 28, 0.18);
  padding: 28px 30px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wizard-question-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wizard-question-title {
  font-size: 21px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.35;
}

.wizard-chosen-clan-badge {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--parchment);
  border: 1px solid var(--parchment-border);
  border-radius: 14px;
}

.wizard-clean-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wizard-lang-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wizard-lang-btn {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px 20px;
  cursor: pointer;
  color: var(--text-main);
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: all 0.16s ease;
}

.wizard-lang-btn:hover,
.wizard-lang-btn.active {
  border-color: var(--emerald);
  background: var(--emerald-dim);
  color: var(--emerald);
}

.other-nation-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--emerald);
  cursor: pointer;
  user-select: none;
  margin-top: 2px;
  font-weight: 500;
}

.other-nation-box {
  background: var(--bg-elevated);
  border: 1px dashed var(--border-subtle);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.children-list-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.child-row {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: 8px;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 10px;
}

/* Старшие колена отцовской линии (5-е и выше, добавляются по одному) */
.deep-line-hint {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.deep-gen-row {
  padding: 10px 0;
  border-top: 1px dashed var(--border-subtle);
}
.deep-gen-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--gold-light);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.deep-line-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.auto-surname-hint {
  font-size: 11px;
  color: var(--emerald);
  margin: -2px 0 4px;
}

/* Боковые ветви: родственники (дети пар предков, их дети и т.д.) */
.rel-family {
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  margin-bottom: 10px;
  background: var(--bg-elevated);
}
.rel-family > summary {
  cursor: pointer;
  padding: 10px 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  list-style: none;
}
.rel-family > summary::-webkit-details-marker {
  display: none;
}
.rel-family > summary::before {
  content: '▸';
  color: var(--gold);
}
.rel-family[open] > summary::before {
  content: '▾';
}
.rel-family-title {
  font-weight: 700;
  font-size: 13px;
}
.rel-family-couple {
  font-size: 12px;
  color: var(--text-secondary);
  flex: 1;
}
.rel-family-body {
  padding: 0 12px 12px;
}
.rel-node {
  margin-top: 8px;
}
.rel-children {
  margin-left: 18px;
  padding-left: 10px;
  border-left: 2px solid var(--border-subtle);
}
.rel-card {
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  padding: 8px 10px;
}
.rel-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.rel-card-actions {
  display: flex;
  gap: 6px;
}
.rel-fields {
  display: grid;
  grid-template-columns: 110px 1fr 1fr;
  gap: 6px;
}
.rel-fields .rel-note {
  grid-column: 1 / -1;
}
@media (max-width: 640px) {
  .rel-fields {
    grid-template-columns: 1fr;
  }
}

/* =====================================================================
 * ОФОРМЛЕНИЕ «ТАМГА И ВОЙЛОК» — слой поверх базовых стилей
 * ===================================================================== */

body {
  font-family: var(--font-ui);
  background-color: var(--bg-deep);
  /* Едва заметный ромбический орнамент войлочного ковра */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cpath d='M28 6l10 22-10 22-10-22z' fill='none' stroke='%23a87a26' stroke-opacity='0.07' stroke-width='1.2'/%3E%3Cpath d='M28 20l4 8-4 8-4-8z' fill='%239b3a2a' fill-opacity='0.05'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #efe7d6 0%, var(--bg-deep) 420px);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Шапка: тёмная хвоя гор, силуэт Эльбруса ---------- */
.site-header {
  position: relative;
  background:
    radial-gradient(ellipse at 50% -40%, rgba(216, 179, 94, 0.22), transparent 60%),
    linear-gradient(180deg, var(--ink) 0%, var(--ink-soft) 100%);
  border-bottom: none;
  box-shadow: none;
  backdrop-filter: none;
  color: #f3ead6;
}

.header-inner {
  padding: 22px 22px 6px;
  align-items: center;
}

.brand-emblem {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #2c463a, #13201b);
  border: 1.5px solid var(--gold-bright);
  box-shadow: 0 0 0 4px rgba(216, 179, 94, 0.12);
  color: var(--gold-bright);
}

.brand-emblem svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.005em;
  line-height: 1.1;
  color: #fbf4e2;
  flex-wrap: wrap;
}

.brand-text h1 .nav-badge {
  font-family: var(--font-ui);
  background: rgba(216, 179, 94, 0.14);
  color: var(--gold-bright);
  border: 1px solid rgba(216, 179, 94, 0.35);
}

.brand-subtitle {
  color: rgba(243, 234, 214, 0.68);
  font-size: 13px;
  margin-top: 4px;
  letter-spacing: 0.02em;
}

.lang-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(216, 179, 94, 0.22);
}

.lang-switcher .alpha-pill {
  background: transparent;
  border: none;
  color: rgba(243, 234, 214, 0.75);
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 600;
}

.lang-switcher .alpha-pill:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.lang-switcher .alpha-pill.active {
  background: var(--gold-bright);
  color: var(--ink);
}

.header-ridge {
  height: 54px;
  margin-top: 4px;
  line-height: 0;
}

.header-ridge svg {
  width: 100%;
  height: 100%;
  display: block;
}

.ridge-far {
  fill: rgba(216, 179, 94, 0.16);
}

.ridge-near {
  fill: #efe7d6;
}

/* ---------- Липкая панель разделов ---------- */
.nav-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(242, 236, 224, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}

.nav-bar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 22px;
}

.nav-bar .nav-tabs {
  gap: 2px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-bar .nav-tabs::-webkit-scrollbar {
  display: none;
}

.nav-btn {
  background: transparent;
  border: none;
  border-radius: 0;
  border-bottom: 2.5px solid transparent;
  padding: 14px 14px 12px;
  font-size: 13.5px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.nav-btn:hover {
  background: transparent;
  color: var(--text-main);
  border-bottom-color: var(--gold-border);
}

.nav-btn.active {
  background: transparent;
  color: var(--ink);
  border-bottom-color: var(--madder);
  box-shadow: none;
}

.nav-badge {
  background: var(--madder-dim);
  color: var(--madder);
}

/* ---------- Показатели ---------- */
.main-container {
  padding-top: 26px;
}

.kpi-strip {
  gap: 16px;
  margin-bottom: 26px;
}

.kpi-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md);
  padding: 18px 20px 16px;
}

.kpi-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--madder), var(--gold-bright), var(--emerald));
}

.kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 700;
  line-height: 1.05;
  color: var(--ink);
  flex-wrap: wrap;
}

#kpi-raw-mentions {
  font-family: var(--font-ui);
}

/* Текстовые значения (например «Известно колен по отцу: 12») — компактнее чисел */
#kpi-autofilled {
  font-size: 24px;
  line-height: 1.15;
}

.kpi-sub {
  color: var(--emerald);
  font-size: 12px;
}

/* ---------- Карточки и заголовки ---------- */
.card {
  border-radius: var(--radius-lg);
  padding: 26px;
  background: var(--bg-surface);
}

.card-header {
  border-bottom: none;
  padding-bottom: 16px;
  margin-bottom: 18px;
  position: relative;
}

/* Разделитель с ромбом посередине */
.card-header::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 9px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='9' viewBox='0 0 18 9'%3E%3Cpath d='M9 0l4.5 4.5L9 9 4.5 4.5z' fill='%23a87a26'/%3E%3C/svg%3E") center / 18px 9px no-repeat,
    linear-gradient(90deg, transparent, var(--gold-border) 15%, var(--gold-border) 85%, transparent) center / 100% 1px no-repeat;
}

.card-title {
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--ink);
}

.card-subtitle {
  font-size: 13.5px;
  line-height: 1.55;
  margin-top: 6px;
}

/* ---------- Кнопки ---------- */
.btn {
  font-family: var(--font-ui);
  border-radius: 999px;
  background: var(--bg-surface);
  border-color: var(--border-subtle);
  font-weight: 600;
}

.btn:hover {
  background: var(--bg-elevated);
  border-color: var(--gold);
}

.btn-primary,
.btn-gold {
  background: var(--emerald);
  border-color: var(--emerald);
  color: #fff;
  box-shadow: 0 6px 16px -8px rgba(31, 92, 71, 0.7);
}

.btn-primary:hover,
.btn-gold:hover {
  background: #184a39;
  border-color: #184a39;
}

.btn-emerald {
  background: var(--emerald-dim);
  border-color: rgba(31, 92, 71, 0.28);
  color: var(--emerald);
}

.btn-emerald:hover {
  background: rgba(31, 92, 71, 0.16);
  border-color: var(--emerald);
}

.btn:focus-visible,
.nav-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- Поля ---------- */
.field-input {
  font-family: var(--font-ui);
  background: var(--bg-surface);
  border-color: #ddd2bc;
  border-radius: var(--radius-sm);
}

.field-input:focus {
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(31, 92, 71, 0.12);
}

.field-input::placeholder {
  color: #aaa596;
}

/* ---------- Анкета: колена ---------- */
.profile-switcher-bar {
  background: var(--parchment);
  border-color: var(--parchment-border);
}

.gen-tier {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius-md);
  padding: 18px 18px 16px;
  margin-bottom: 16px;
}

.gen-tier:nth-child(2n) {
  border-left-color: var(--madder);
}

.gen-tier.discovered-tier {
  border-left-color: var(--emerald);
  background: linear-gradient(180deg, rgba(31, 92, 71, 0.05), var(--bg-surface) 120px);
}

.gen-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.gen-tag {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.gen-tag.merged {
  background: var(--emerald-dim);
}

.ancestor-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

/* Карточка человека: круглая тамга слева, подпись строкой сверху, поля под ней */
.person-box {
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
}

.person-box:hover {
  border-color: var(--parchment-border);
}

.person-box:focus-within {
  background: var(--bg-surface);
}

.person-box .tamga-plate {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--parchment);
  border: 1.5px solid var(--parchment-border);
  box-shadow: inset 0 0 0 3px #fffaf0;
  padding: 10px;
}

.role-label {
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
}

.role-label > span:last-child {
  font-weight: 500;
  font-size: 11px !important;
  color: var(--gold-light) !important;
}

.auto-surname-hint {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--emerald);
  background: var(--emerald-dim);
  border-radius: 999px;
  padding: 1px 9px;
  margin: 0;
}

.other-nation-toggle {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Старшие колена */
.deep-gen-row {
  border-top: 1px solid var(--border-subtle);
  padding: 12px 0 4px;
}

.deep-gen-label {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--ink);
}

.deep-gen-label .gen-tag {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  min-width: 38px;
  justify-content: center;
  display: inline-flex;
  color: var(--gold-light);
  border-color: var(--gold-border);
  background: var(--gold-dim);
}

.deep-line-hint {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
  background: var(--parchment);
  border: 1px dashed var(--parchment-border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  margin-bottom: 12px;
}

/* ---------- Родственники: древо с ветвями ---------- */
.rel-family {
  background: var(--bg-surface);
  border-color: var(--border-subtle);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease;
}

.rel-family[open] {
  border-color: var(--parchment-border);
}

.rel-family > summary {
  padding: 12px 14px;
}

.rel-family > summary::before {
  font-size: 12px;
  color: var(--madder);
}

.rel-family-title {
  font-size: 13.5px;
  color: var(--ink);
}

.rel-children {
  margin-left: 22px;
  padding-left: 0;
  border-left: none;
  position: relative;
}

/* Ветви: вертикальная линия рода и отводы к каждому ребёнку */
.rel-children > .rel-node {
  position: relative;
  padding-left: 18px;
}

.rel-children > .rel-node::before {
  content: '';
  position: absolute;
  left: 0;
  top: -8px;
  bottom: 0;
  border-left: 2px solid var(--parchment-border);
}

.rel-children > .rel-node:last-child::before {
  bottom: auto;
  height: 30px;
}

.rel-children > .rel-node::after {
  content: '';
  position: absolute;
  left: 0;
  top: 22px;
  width: 16px;
  border-top: 2px solid var(--parchment-border);
}

.rel-card {
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.rel-card:focus-within {
  background: var(--bg-surface);
  border-color: var(--emerald);
}

/* ---------- Родовой узор (щит) ---------- */
.shield-stage {
  background:
    radial-gradient(circle at 50% 0%, rgba(216, 179, 94, 0.16), transparent 60%),
    var(--bg-elevated);
  border-color: var(--parchment-border);
}

.shield-coat {
  background: var(--bg-surface);
  border: 2px solid var(--gold);
  box-shadow:
    0 0 0 5px #fffcf4,
    0 0 0 6px var(--gold-border),
    0 18px 40px -18px rgba(20, 33, 28, 0.35);
}

.shield-coat-header h3 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}

.shield-cell {
  background: var(--parchment);
  border-color: var(--parchment-border);
}

.shield-cell-clan {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
}

.shield-cell-empty {
  width: 46px;
  height: 46px;
  margin: 6px 0;
  border-radius: 50%;
  border: 1.5px dashed var(--parchment-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--text-muted);
}

.kinship-degree-badge {
  background: var(--emerald-dim);
  border-color: rgba(31, 92, 71, 0.26);
}

.kinship-result-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
}

.merge-alert {
  border-radius: var(--radius-md);
  border-left: 4px solid var(--emerald);
}

.wizard-question-title {
  font-family: var(--font-display);
}

/* ---------- Телефоны ---------- */
@media (max-width: 640px) {
  .header-inner {
    padding: 16px 16px 4px;
  }

  .brand-text h1 {
    font-size: 23px;
  }

  .brand-emblem {
    width: 42px;
    height: 42px;
  }

  .header-ridge {
    height: 32px;
  }

  .nav-bar-inner,
  .main-container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .kpi-strip {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .kpi-card {
    padding: 14px;
  }

  .kpi-value {
    font-size: 30px;
  }

  #kpi-autofilled {
    font-size: 17px;
  }

  .card {
    padding: 18px 14px;
  }

  .card-title {
    font-size: 21px;
  }

  .gen-tier {
    padding: 14px 12px;
  }

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

  .rel-children {
    margin-left: 8px;
  }
}

/* Анкете — больше места, щит справа фиксированной ширины */
.grid-2col {
  grid-template-columns: minmax(0, 1fr) 420px;
}

@media (max-width: 1180px) {
  .grid-2col {
    grid-template-columns: 1fr;
  }
}

/* Варианты тамги рода */
.tamga-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.tamga-variant-btn {
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--gold-light);
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  border-radius: 999px;
  padding: 1px 7px;
  cursor: pointer;
  white-space: nowrap;
}

.tamga-variant-btn:hover {
  background: rgba(168, 122, 38, 0.18);
}

.tamga-variants {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 130px;
  flex-shrink: 0;
}

/* ---------- Вход и профиль участника ---------- */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.account-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-btn {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid var(--gold-bright);
  background: var(--gold-bright);
  color: var(--ink);
}

.account-btn.ghost {
  background: transparent;
  color: #f3ead6;
  border-color: rgba(216, 179, 94, 0.45);
}

.account-btn:hover {
  filter: brightness(1.08);
}

.account-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px 4px 4px;
  border-radius: 999px;
  border: 1px solid rgba(216, 179, 94, 0.4);
  background: rgba(255, 255, 255, 0.06);
  color: #fbf4e2;
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 13px;
}

.account-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--gold-bright);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
}

.account-avatar.lg {
  width: 52px;
  height: 52px;
  font-size: 18px;
}

.account-dot {
  position: absolute;
  top: 2px;
  left: 26px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--madder);
  border: 2px solid var(--ink);
}

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

.auth-modal {
  position: relative;
  max-width: 440px;
  background: var(--bg-surface);
  border-top: 4px solid var(--gold);
}

.auth-close {
  position: absolute;
  top: 14px;
  right: 16px;
  border: none;
  background: transparent;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
}

.auth-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
}

.auth-sub {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-top: -6px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
}

.auth-submit {
  width: 100%;
  padding: 12px 16px;
  font-size: 14.5px;
}

.auth-submit:disabled {
  opacity: 0.6;
  cursor: wait;
}

.auth-links {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
}

.auth-links a {
  color: var(--emerald);
  font-weight: 600;
  text-decoration: none;
}

.auth-links a:hover {
  text-decoration: underline;
}

.auth-note {
  font-size: 12.5px;
  color: var(--text-muted);
}

.auth-error,
.auth-warn,
.auth-ok {
  font-size: 13px;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  line-height: 1.5;
}

.auth-error {
  background: var(--madder-dim);
  color: var(--madder);
  border: 1px solid rgba(155, 58, 42, 0.3);
}

.auth-warn {
  background: var(--gold-dim);
  color: var(--gold-light);
  border: 1px solid var(--gold-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.auth-ok {
  background: var(--emerald-dim);
  color: var(--emerald);
}

.auth-profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

@media (max-width: 640px) {
  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

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

.auth-consent {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--parchment);
  border: 1px solid var(--parchment-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.auth-consent input {
  margin-top: 3px;
  flex-shrink: 0;
}

/* ---------- «Подробнее»: статус и страница памяти ---------- */
.details-wrap {
  margin-top: 2px;
}

.details-toggle {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  padding: 2px 0;
  cursor: pointer;
}

.details-toggle:hover {
  color: var(--emerald);
}

.details-summary {
  color: var(--gold-light);
  font-weight: 700;
}

.details-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin-top: 6px;
  padding: 10px;
  background: var(--parchment);
  border: 1px solid var(--parchment-border);
  border-radius: var(--radius-sm);
}

.details-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.details-field.wide,
.details-note {
  grid-column: 1 / -1;
}

.details-note {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

.spouse-details {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Другие жёны / матери детей ---------- */
.wife-block {
  margin-top: 8px;
}

.wife-card {
  border-style: dashed;
  border-color: var(--gold-border);
  background: var(--gold-dim);
}

.add-wife-btn {
  margin-top: 8px;
  font-size: 12px;
  border-style: dashed;
}

/* ---------- Панель общей родословной ---------- */
.graph-panel {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--parchment-border);
  border-left: 4px solid var(--emerald);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.graph-panel.muted {
  border-left-color: var(--gold);
  font-size: 13px;
  color: var(--text-secondary);
}

.graph-panel-title {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  color: var(--ink);
}

.graph-subtitle {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 4px;
}

.graph-note {
  font-size: 13px;
  line-height: 1.5;
}

.graph-note.muted {
  color: var(--text-muted);
}

.match-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
}

.match-text {
  font-size: 13px;
  line-height: 1.5;
  flex: 1;
  min-width: 220px;
}

.match-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.kin-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}

.kin-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

.kin-degree {
  font-size: 12.5px;
  color: var(--emerald);
  font-weight: 600;
}

.kin-ancestor {
  font-size: 12px;
  color: var(--text-secondary);
  align-self: center;
}

/* ---------- Уведомления ---------- */
.bell-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(216, 179, 94, 0.4);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  font-size: 16px;
}

.bell-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--madder);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 18px;
  font-family: var(--font-ui);
}

.notif-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 60vh;
  overflow-y: auto;
}

.notif-item {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-main);
  cursor: pointer;
}

.notif-item.unread {
  border-left: 3px solid var(--madder);
  background: var(--bg-surface);
}

.notif-time {
  font-size: 11px;
  color: var(--text-muted);
}

/* ---------- Сообщения ---------- */
.msg-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  min-height: 480px;
}

.msg-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-right: 1px solid var(--border-subtle);
  padding-right: 16px;
}

.msg-conv {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  cursor: pointer;
  font-family: var(--font-ui);
}

.msg-conv.active {
  border-color: var(--emerald);
  background: var(--emerald-dim);
}

.msg-conv-name {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--ink);
}

.msg-conv-degree {
  font-size: 11.5px;
  color: var(--emerald);
}

.msg-conv-last {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.msg-thread-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.msg-thread-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}

.msg-thread-actions {
  display: flex;
  gap: 6px;
}

.msg-warning {
  font-size: 12.5px;
  line-height: 1.5;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--madder-dim);
  color: var(--madder);
  border: 1px solid rgba(155, 58, 42, 0.25);
}

.msg-report {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
}

.msg-list {
  flex: 1;
  min-height: 240px;
  max-height: 52vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--parchment);
  border: 1px solid var(--parchment-border);
}

.msg-bubble {
  align-self: flex-start;
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 14px 14px 14px 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}

.msg-body {
  white-space: pre-wrap;
}

.msg-bubble.mine {
  align-self: flex-end;
  border-radius: 14px 14px 4px 14px;
  background: var(--emerald);
  border-color: var(--emerald);
  color: #fff;
}

.msg-time {
  display: block;
  font-size: 10.5px;
  opacity: 0.7;
  margin-top: 2px;
}

.msg-compose {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.msg-compose textarea {
  flex: 1;
  resize: vertical;
}

.msg-hint,
.msg-empty p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.msg-empty {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}

.kin-write {
  margin-left: 8px;
}

.kin-no-account {
  margin-left: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

@media (max-width: 760px) {
  .msg-layout {
    grid-template-columns: 1fr;
  }

  .msg-sidebar {
    border-right: none;
    padding-right: 0;
  }

  .msg-report {
    grid-template-columns: 1fr;
  }
}


/* ---------- Тукъум и новости ---------- */
.community-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.community-tabs .alpha-pill {
  border-radius: 999px;
  padding: 6px 14px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.community-tabs .alpha-pill.active {
  background: var(--ink);
  color: var(--gold-bright);
  border-color: var(--ink);
}

.community-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 820px;
}

.post {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.post.announcement {
  border-left: 4px solid var(--madder);
  background: linear-gradient(180deg, var(--madder-dim), var(--bg-surface) 80px);
}

.post-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  align-items: baseline;
}

.post-author {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

.post-meta {
  font-size: 11.5px;
  color: var(--text-muted);
}

.post-flag {
  font-size: 12px;
  font-weight: 700;
  color: var(--madder);
}

.post-body,
.comment-body {
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.post-comments {
  border-top: 1px dashed var(--border-subtle);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.comment {
  font-size: 13px;
  line-height: 1.5;
}

.comment-form,
.appoint-form {
  display: flex;
  gap: 6px;
}

.post-composer,
.vote-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--parchment);
  border: 1px solid var(--parchment-border);
}

.post-composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.link-btn {
  align-self: flex-start;
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
  font-family: var(--font-ui);
}

.vote {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--parchment-border);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vote.closed {
  opacity: 0.85;
}

.vote-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.vote-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.vote-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.vote-bar {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--emerald-dim);
  z-index: 0;
}

.vote-label,
.vote-count,
.vote-option .btn {
  position: relative;
  z-index: 1;
}

.vote-label {
  flex: 1;
  font-size: 13.5px;
}

.vote-count {
  font-weight: 800;
  color: var(--emerald);
}

.vote-candidates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 4px;
}

.expert-list {
  margin: 0 0 6px 18px;
  font-size: 14px;
  line-height: 1.7;
}

/* Атрибут hidden сильнее display: grid/flex у блоков формы */
[hidden] {
  display: none !important;
}


/* ---------- Доверие и защита от самозванцев ---------- */
.kin-trust {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.link-btn.danger {
  color: var(--madder);
}

.match-card.claim {
  border-color: var(--madder);
  background: var(--madder-dim);
}

.match-card.waiting {
  background: var(--bg-elevated);
  border-style: dashed;
}

.claim-warning {
  font-weight: 700;
  color: var(--madder);
  margin-bottom: 4px;
}

.msg-warning.strong {
  font-weight: 700;
  border-width: 2px;
}


/* ---------- Тамга рода: решение Тёре ---------- */
.clan-card-note {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.tamga-pick {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 6px 0;
}

.tamga-pick-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.vote-label .tamga-plate,
.vote-title + .tamga-plate,
.graph-note .tamga-plate {
  display: inline-flex;
  vertical-align: middle;
  margin: 0 6px;
}


/* ---------- Шапка: название посередине, язык и вход в правом верхнем углу ---------- */
.site-header .header-inner {
  position: relative;
  display: flex;
  justify-content: center;
}

.site-header .header-side {
  display: none;
}

.site-header .brand {
  flex-direction: column;
  text-align: center;
  gap: 8px;
  max-width: 640px;
}

.site-header .brand-text h1 {
  justify-content: center;
}

.site-header .header-actions {
  position: absolute;
  top: 18px;
  right: 22px;
  flex-wrap: nowrap;
  gap: 8px;
}

.lang-menu {
  position: relative;
}

.lang-current {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  color: #f3ead6;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(216, 179, 94, 0.45);
}

.lang-current:hover {
  background: rgba(255, 255, 255, 0.1);
}

.lang-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 60;
  min-width: 240px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--gold-border);
  box-shadow: 0 12px 32px rgba(28, 38, 32, 0.18);
}

.lang-option {
  text-align: left;
  font-family: var(--font-ui);
  font-size: 14px;
  padding: 9px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
}

.lang-option:hover {
  background: var(--gold-dim);
}

.lang-option.active {
  font-weight: 700;
  color: var(--emerald);
}

/* Разделы помещаются целиком: если не влезают в одну строку — переносятся, а не обрезаются */
.nav-bar .nav-tabs {
  flex-wrap: wrap;
  justify-content: center;
  overflow-x: visible;
}

@media (max-width: 1180px) {
  .site-header .header-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .site-header .header-actions {
    position: static;
    order: -1;
    width: auto;
    justify-content: flex-end;
  }

  .site-header .brand {
    align-self: center;
  }
}

/* Список языков открывается поверх строки разделов */
.site-header {
  z-index: 50;
}

/* ---------- Карточка тукъума: корень и формы на языке пользователя ---------- */
.clan-card-root {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  line-height: 1.15;
  color: var(--text-main);
}

.clan-card-forms {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.clan-card-forms span:first-child {
  color: var(--emerald);
  font-weight: 700;
}

/* ---------- Другой народ: фамилия и род ---------- */
.nation-extra {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 6px;
}

@media (max-width: 640px) {
  .nation-extra {
    grid-template-columns: 1fr;
  }
}

.clan-option-group {
  padding: 6px 10px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: var(--bg-elevated);
}

/* ===== Фамильное древо (окно «Показать фамильное древо») ===== */
.ft-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg-deep);
  flex-direction: column;
}
.ft-overlay.open {
  display: flex;
}
.ft-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}
.ft-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
}
.ft-sub {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.ft-body {
  flex: 1;
  overflow: auto;
  padding: 18px 16px 40px;
}
.ft-side {
  margin-bottom: 34px;
}
.ft-side-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: var(--gold-light);
  margin-bottom: 10px;
}
/* Дерево сверху вниз: линии рисуются рамками псевдоэлементов */
.ft-tree,
.ft-tree ul {
  display: flex;
  justify-content: center;
  padding: 18px 0 0;
  margin: 0;
  position: relative;
  list-style: none;
  width: max-content;
  min-width: 100%;
}
.ft-tree {
  padding-top: 0;
}
.ft-tree li {
  position: relative;
  padding: 18px 6px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.ft-tree > li {
  padding-top: 0;
}
.ft-tree li::before,
.ft-tree li::after {
  content: '';
  position: absolute;
  top: 0;
  right: 50%;
  width: 50%;
  height: 18px;
  border-top: 2px solid var(--gold-border);
}
.ft-tree li::after {
  right: auto;
  left: 50%;
  border-left: 2px solid var(--gold-border);
}
.ft-tree li:only-child::before,
.ft-tree li:only-child::after {
  display: none;
}
.ft-tree li:only-child {
  padding-top: 0;
}
.ft-tree li:first-child::before,
.ft-tree li:last-child::after {
  border: 0 none;
}
.ft-tree li:last-child::before {
  border-right: 2px solid var(--gold-border);
}
.ft-tree > li::before,
.ft-tree > li::after {
  display: none;
}
.ft-tree ul::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  height: 18px;
  border-left: 2px solid var(--gold-border);
}
.ft-couple {
  display: flex;
  gap: 4px;
  align-items: stretch;
  padding: 4px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
}
.ft-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 92px;
  max-width: 130px;
  padding: 6px 8px;
  border-radius: 9px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  font: inherit;
  font-size: 12px;
  color: var(--text-main);
  cursor: pointer;
  text-align: center;
}
.ft-card:hover {
  border-color: var(--gold);
}
.ft-m {
  border-top: 3px solid var(--azure);
}
.ft-f {
  border-top: 3px solid var(--madder);
}
.ft-me {
  background: var(--gold-dim);
  border-color: var(--gold);
}
.ft-partner {
  opacity: 0.92;
}
.ft-empty {
  border: 1.5px dashed var(--parchment-border);
  background: transparent;
  color: var(--text-muted);
}
.ft-empty .ft-name {
  font-weight: 600;
  font-size: 11.5px;
}
.ft-tamga {
  width: 26px;
  height: 26px;
  object-fit: contain;
}
.ft-name {
  font-weight: 800;
  line-height: 1.2;
}
.ft-surname {
  font-size: 11.5px;
  color: var(--text-secondary);
}
.ft-role,
.ft-years {
  font-size: 10.5px;
  color: var(--text-muted);
}
.ft-union-label {
  font-size: 10.5px;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
}
.ft-note {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 3px;
}
.ft-add {
  border: 1.5px dashed var(--parchment-border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 2px 10px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.ft-add:hover {
  color: var(--gold-light);
  border-color: var(--gold);
}
.ft-highlight {
  outline: 3px solid var(--gold-bright);
  outline-offset: 2px;
  transition: outline-color 0.3s;
}
/* Род известен, имя — нет («?»); имя, которое вписала родня, — курсивом */
.ft-unknown .ft-name {
  color: var(--text-muted);
}
.ft-suggested {
  font-style: italic;
  color: var(--emerald);
}
/* Древо одного человека: предки слева направо */
.pd-tree {
  width: max-content;
  min-width: 100%;
}
.pd-node {
  display: flex;
  align-items: center;
}
.pd-self {
  position: relative;
  padding: 4px 18px 4px 0;
}
.pd-self::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  width: 18px;
  border-top: 2px solid var(--gold-border);
}
.pd-node:not(:has(> .pd-parents)) > .pd-self::after {
  display: none;
}
.pd-parents {
  display: flex;
  flex-direction: column;
  border-left: 2px solid var(--gold-border);
  padding-left: 14px;
  margin: 6px 0;
}
.pd-tree .ft-card {
  min-width: 120px;
  max-width: 160px;
}
.ft-selected {
  outline: 3px solid var(--gold-bright);
  outline-offset: 1px;
}
.ft-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
/* Окошко правки человека прямо в древе */
.ft-editor {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  padding: 12px 16px 14px;
  box-shadow: 0 -10px 30px -18px rgba(20, 33, 28, 0.35);
}
.ft-editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.ft-editor-role {
  font-weight: 800;
  color: var(--gold-light);
}
.ft-editor-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
}
.ft-editor-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.tree-of-btn {
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  border-radius: 8px;
  padding: 0 6px;
  cursor: pointer;
  font-size: 13px;
  line-height: 20px;
}
.tree-of-btn:hover {
  border-color: var(--gold);
}
/* В окошке правки внизу экрана список фамилий открывается вверх */
.ft-editor .clan-picker-wrap {
  position: relative;
}
.ft-editor .clan-dropdown {
  top: auto;
  bottom: calc(100% + 5px);
  max-height: 50vh;
}
.ft-save-status {
  align-self: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--emerald);
}

/* Переключатель видов древа: круг рода / круг предков / схема */
.ft-modes {
  display: inline-flex;
  gap: 2px;
  margin-top: 8px;
  padding: 2px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}
.ft-mode {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 4px 12px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
}
.ft-mode.active {
  background: var(--emerald);
  color: #fff;
}
/* Круговое древо */
.ft-body-fan {
  position: relative;
  overflow: hidden;
  padding: 0;
}
.fan-svg {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  user-select: none;
}
.fan-svg:active {
  cursor: grabbing;
}
.fan-seg {
  cursor: pointer;
  stroke-width: 1;
}
.fan-seg > path,
.fan-seg > circle {
  stroke: var(--bg-surface);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}
.fan-seg:hover > path,
.fan-seg:hover > circle {
  filter: brightness(0.94);
}
.fan-empty > path {
  stroke: var(--parchment-border);
  stroke-dasharray: 4 3;
}
.fan-path > path,
.fan-path > circle {
  stroke: var(--gold);
  stroke-width: 2;
}
.fan-sel > path,
.fan-sel > circle {
  stroke: var(--gold-bright);
  stroke-width: 4;
}
.fan-text {
  fill: var(--ink);
  stroke: none;
  font-size: 11.5px;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
}
.fan-empty .fan-text {
  fill: var(--text-muted);
}
.fan-center {
  font-size: 14px;
}
.fan-sub {
  font-size: 10.5px;
  font-weight: 600;
  fill: var(--text-secondary);
}
.fan-tools {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.fan-legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 3px 10px;
}
.fan-legend-path {
  width: 18px;
  height: 0;
  border-top: 3px solid var(--gold);
}

/* 3D-древо */
.ft3d-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
  background: radial-gradient(ellipse at 50% 85%, rgba(168, 122, 38, 0.10), transparent 60%);
}
.ft3d-canvas:active {
  cursor: grabbing;
}

/* Окошко правки: строки «муж / жена», «отец», «мать» */
.ft-editor {
  max-height: 55vh;
  overflow-y: auto;
}
.ft-sub-row {
  display: grid;
  grid-template-columns: 64px minmax(120px, 1fr) minmax(150px, 1.3fr) auto;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}
.ft-main-row {
  grid-template-columns: auto minmax(120px, 1fr) minmax(150px, 1.3fr);
  margin-top: 0;
}
.ft-sub-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}
.ft-chip {
  justify-self: start;
  grid-column: 2 / -1;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  border-radius: 999px;
  padding: 4px 12px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.ft-chip:hover {
  border-color: var(--gold);
}
.ft-chip-go {
  grid-column: auto;
  padding: 4px 10px;
}
.ft-link {
  grid-column: 2 / -1;
  justify-self: start;
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: underline dotted;
  cursor: pointer;
}
.ft-link:hover {
  color: var(--gold-light);
}
@media (max-width: 640px) {
  .ft-sub-row,
  .ft-main-row {
    grid-template-columns: 1fr;
  }
  .ft-chip {
    grid-column: auto;
  }
}

.ft-switches {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.ft-lines .ft-mode.active {
  background: var(--gold);
}

/* ===== Древо: поиск, путь переходов, подсказки, карточка сбоку ===== */
.ft-search-wrap {
  flex: 1 1 220px;
  max-width: 320px;
}
.ft-search {
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
}
.ft-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  font-size: 12.5px;
}
.ft-crumb {
  border: 0;
  background: none;
  padding: 2px 4px;
  font: inherit;
  color: var(--emerald);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline dotted;
}
.ft-crumb:hover {
  color: var(--gold-light);
}
.ft-crumb-sep {
  color: var(--text-muted);
}
.ft-crumb-current {
  font-weight: 800;
  color: var(--ink);
}
.ft-tips {
  position: absolute;
  left: 16px;
  top: 16px;
  max-width: 380px;
  background: var(--bg-surface);
  border: 1px solid var(--gold-border);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
  font-size: 13px;
  z-index: 3;
}
.ft-tips-title {
  font-weight: 800;
  color: var(--gold-light);
  margin-bottom: 6px;
}
.ft-tips ol {
  margin: 0 0 10px;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}
.ft-danger {
  margin-left: auto;
}
.ft-danger:hover {
  border-color: var(--madder);
  color: var(--madder);
}
.ft-years-row input {
  max-width: 140px;
}
/* На широком экране карточка человека — справа, а не полосой снизу: древо остаётся видно целиком */
@media (min-width: 1000px) {
  #ft-editor-wrap:not(:empty) {
    position: absolute;
    right: 16px;
    top: calc(var(--ft-head-h, 150px) + 12px);
    bottom: 16px;
    width: 400px;
    z-index: 4;
    display: flex;
    flex-direction: column;
    pointer-events: none;
  }
  #ft-editor-wrap .ft-editor {
    pointer-events: auto;
    max-height: 100%;
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    box-shadow: 0 18px 40px -18px rgba(20, 33, 28, 0.45);
  }
  #ft-editor-wrap .ft-sub-row,
  #ft-editor-wrap .ft-main-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  #ft-editor-wrap .ft-sub-label {
    margin-top: 4px;
  }
  #ft-editor-wrap .ft-chip {
    grid-column: auto;
  }
  #ft-editor-wrap .ft-years-row input {
    max-width: none;
  }
}

/* Шкала заполнения анкеты */
.profile-progress {
  margin: 4px 0 14px;
}
.pp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
}
.pp-sub {
  color: var(--text-muted);
  font-size: 12px;
}
.pp-done {
  color: var(--emerald);
  font-weight: 700;
}
.pp-bar {
  margin-top: 6px;
  height: 8px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}
.pp-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--emerald), var(--gold));
  transition: width 0.4s ease;
}

/* ===== Телефон: меню разделов — одна строка с прокруткой вбок, цифры — компактно ===== */
@media (max-width: 640px) {
  .nav-bar .nav-tabs {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav-bar .nav-tabs .nav-btn {
    flex: 0 0 auto;
    scroll-snap-align: start;
    white-space: nowrap;
  }
  .kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .kpi-card {
    padding: 10px 12px;
  }
  .kpi-label {
    font-size: 10px;
    letter-spacing: 0.04em;
  }
  .kpi-value {
    font-size: 20px;
  }
  .kpi-sub {
    display: none;
  }
  .site-header h1,
  .site-header .site-title {
    font-size: 24px;
  }
  /* в окне древа шапка тоже компактнее */
  .ft-header {
    padding: 10px 12px;
    flex-direction: column;
  }
  .ft-sub {
    display: none;
  }
  .ft-header-actions {
    justify-content: flex-start;
  }
  .ft-search-wrap {
    max-width: none;
    flex-basis: 100%;
  }
}

/* Телефон и планшет: карточка человека — выдвижная панель поверх древа (древо не сжимается) */
@media (max-width: 999px) {
  #ft-editor-wrap:not(:empty) {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
  }
  #ft-editor-wrap .ft-editor {
    max-height: 52vh;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -12px 30px -12px rgba(20, 33, 28, 0.4);
  }
}
@media (max-width: 640px) {
  .ft-title {
    font-size: 19px;
  }
  .ft-switches {
    gap: 6px;
  }
  .ft-modes {
    margin-top: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    max-width: 100%;
    scrollbar-width: none;
  }
  .ft-mode {
    padding: 4px 9px;
    font-size: 12px;
    white-space: nowrap;
  }
  .ft-header-actions .btn {
    padding: 4px 8px;
    font-size: 12px;
  }
  .ft-crumbs {
    margin-top: 4px;
    font-size: 11.5px;
  }
  .fan-legend {
    display: none;
  }
  .fan-tools {
    right: 8px;
    bottom: 8px;
  }
}


/* ===== Тёмная тема: html[data-theme="dark"] (кнопка 🌙 в шапке) или настройка устройства, если тема не выбрана ===== */
html[data-theme='dark'] {
  color-scheme: dark;
  --bg-deep: #111714;
  --bg-surface: #19211d;
  --bg-elevated: #202a25;
  --bg-glass: rgba(25, 33, 29, 0.94);
  --parchment: #222b26;
  --parchment-border: #3b4740;
  --ink: #eeece4;
  --ink-soft: #dedcd2;
  --text-main: #e7e5dd;
  --text-secondary: #aeb2a8;
  --text-muted: #80857c;
  --gold: #d6a84e;
  --gold-light: #e4c074;
  --gold-bright: #ecce82;
  --gold-dim: rgba(214, 168, 78, 0.13);
  --gold-border: rgba(214, 168, 78, 0.36);
  --emerald: #55b48b;
  --emerald-dim: rgba(85, 180, 139, 0.14);
  --madder: #de8270;
  --madder-dim: rgba(222, 130, 112, 0.14);
  --crimson: #e6697a;
  --azure: #63afe3;
  --border-subtle: #2f3a34;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px -12px rgba(0, 0, 0, 0.6);
}
html[data-theme='dark'] body {
  background: var(--bg-deep);
  color: var(--text-main);
}
/* тамги нарисованы чёрным — в тёмной теме светлые линии */
html[data-theme='dark'] img[src*='tamgas/'],
html[data-theme='dark'] img[src^='data:image/svg'] {
  filter: invert(1) hue-rotate(180deg) brightness(1.05);
}
/* сектора круга остаются светлыми — подписи на них тёмные */
html[data-theme='dark'] .fan-text {
  fill: #14211c;
}
html[data-theme='dark'] .fan-empty .fan-text {
  fill: var(--text-muted);
}
.theme-toggle {
  border: 1px solid rgba(216, 179, 94, 0.45);
  background: rgba(0, 0, 0, 0.18);
  color: #f3e6c4;
  border-radius: 999px;
  width: 38px;
  height: 38px;
  font-size: 16px;
  cursor: pointer;
}
.theme-toggle:hover {
  border-color: var(--gold-bright);
}
/* шапка и активная вкладка остаются тёмно-хвойными в обеих темах (их фон был цветом текста) */
html[data-theme='dark'] .site-header {
  background:
    radial-gradient(ellipse at 50% -40%, rgba(216, 179, 94, 0.18), transparent 60%),
    linear-gradient(180deg, #0c130f 0%, #16241d 100%);
}
html[data-theme='dark'] .community-tabs .alpha-pill.active {
  background: #0c130f;
  border-color: var(--gold-border);
}
html[data-theme='dark'] .nav-bar {
  background: rgba(17, 23, 20, 0.92);
}
html[data-theme='dark'] .ridge-near {
  fill: var(--bg-deep);
}

/* Выбор народа при первом входе (площадка «Миллетим»; показывается, когда открытых разделов больше одного) */
.people-picker {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(12, 19, 15, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.people-picker-card {
  background: var(--bg-surface);
  border-radius: 20px;
  padding: 24px;
  max-width: 760px;
  width: 100%;
  box-shadow: var(--shadow-card);
}
.people-picker-title {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  color: var(--ink);
}
.people-picker-sub {
  color: var(--text-secondary);
  margin: 4px 0 16px;
}
.people-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}
.people-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  font: inherit;
  cursor: pointer;
}
.people-card:hover {
  border-color: var(--gold);
}
.people-card-name {
  font-weight: 800;
  color: var(--ink);
}
.people-card-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Подвал сайта */
.site-footer {
  margin-top: 32px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  padding: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}
.site-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: center;
}
.site-footer-brand {
  font-weight: 700;
  color: var(--ink);
}
.site-footer-sep {
  color: var(--text-muted);
}
.site-footer a {
  color: var(--emerald);
  font-weight: 700;
  text-decoration: none;
}
.site-footer a:hover {
  text-decoration: underline;
}

/* Родственные ресурсы */
.resources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.resource-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  text-decoration: none;
  color: var(--text-main);
  transition: border-color 0.2s, transform 0.2s;
}
.resource-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
}
.resource-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}
.resource-host {
  font-size: 12px;
  color: var(--text-muted);
}
.resource-desc {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin: 4px 0 6px;
}
.resource-go {
  margin-top: auto;
  font-weight: 700;
  color: var(--emerald);
  font-size: 13px;
}
.resource-empty {
  color: var(--text-muted);
}
