@font-face {
  font-family: "Pinar";
  src: url("assets/fonts/Pinar-FD-VF.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "PinarLatin";
  src: url("assets/fonts/Pinar-VF.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Leila";
  src: url("assets/fonts/E-Leila.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "Leila";
  src: url("assets/fonts/Leila-Light.ttf") format("truetype");
  font-weight: 300;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #15221f;
  --muted: #66726f;
  --paper: #f7f8f6;
  --panel: #ffffff;
  --line: #d9dfdc;
  --green: #24554c;
  --green-2: #dcebe6;
  --wine: #8a2f45;
  --gold: #b98528;
  --blue: #315d7e;
  --shadow: 0 18px 45px rgba(21, 34, 31, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: "Pinar", "PinarLatin", Tahoma, sans-serif;
  line-height: 1.75;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.app-shell {
  min-height: 100vh;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(220px, auto) minmax(0, 1fr) auto;
  grid-template-areas: "brand nav actions";
  align-items: center;
  gap: 8px clamp(10px, 1.6vw, 20px);
  padding: 10px clamp(12px, 2.4vw, 28px);
  border-bottom: 1px solid rgba(36, 85, 76, 0.14);
  background: rgba(247, 248, 246, 0.94);
  backdrop-filter: blur(18px);
}

.brand {
  grid-area: brand;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(36, 85, 76, 0.22);
  border-radius: 50%;
  background: #fff;
  color: var(--green);
  font-family: "Leila", "Pinar", sans-serif;
  font-size: 1.8rem;
  box-shadow: 0 10px 24px rgba(36, 85, 76, 0.1);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand strong {
  display: block;
  font-size: 0.96rem;
  font-weight: 820;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
}

.primary-nav {
  grid-area: nav;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-wrap: wrap;
  min-width: 0;
}

.nav-item,
.quick-button,
.soft-action,
.primary-action,
.danger-action,
.tab {
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.nav-item svg {
  width: 19px;
  height: 19px;
}

.nav-item.active,
.nav-item:hover {
  background: var(--green-2);
  color: var(--green);
  border-color: rgba(36, 85, 76, 0.16);
}

.quick-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
  white-space: nowrap;
}

.tabari-date-ribbon {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border: 1px solid rgba(185, 133, 40, 0.22);
  border-radius: var(--radius);
  background: #fffaf0;
  color: #72521a;
  font-size: 0.78rem;
  font-weight: 760;
  white-space: nowrap;
}

.quick-button,
.soft-action {
  min-height: 36px;
  padding: 0 10px;
  background: #fff;
  color: var(--green);
  border-color: rgba(36, 85, 76, 0.16);
}

.quick-button.emphasis,
.primary-action {
  min-height: 38px;
  padding: 0 13px;
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.quick-actions .quick-button {
  min-height: 34px;
  padding: 0 9px;
}

.quick-actions .quick-button.emphasis {
  min-height: 36px;
  padding: 0 11px;
}

.signout-button {
  background: #fff1f3;
  color: #9a243d;
  border-color: rgba(138, 47, 69, 0.2);
}

.danger-action {
  min-height: 40px;
  padding: 0 14px;
  background: #fff1f3;
  color: #9a243d;
  border-color: rgba(138, 47, 69, 0.2);
}

.nav-item:hover,
.quick-button:hover,
.soft-action:hover,
.primary-action:hover,
.danger-action:hover,
.tab:hover {
  transform: translateY(-1px);
}

main {
  padding: clamp(18px, 3vw, 34px);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto 20px;
  max-width: 1420px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--wine);
  font-size: 0.82rem;
  font-weight: 760;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 1.18;
}

h2 {
  margin-bottom: 14px;
  font-size: clamp(1.4rem, 2.5vw, 2rem);
}

.home-view {
  max-width: 1420px;
  margin: 0 auto;
}

.intro-hero {
  position: relative;
  display: flex;
  min-height: min(58vh, 560px);
  align-items: flex-end;
  overflow: hidden;
  border-radius: var(--radius);
  background:
    linear-gradient(to left, rgba(21, 34, 31, 0.82), rgba(21, 34, 31, 0.48) 48%, rgba(21, 34, 31, 0.08) 82%),
    url("assets/images/pirouz_king.png") left 42% / cover;
  box-shadow: var(--shadow);
}

.intro-copy {
  width: min(720px, 100%);
  padding: clamp(24px, 5vw, 56px);
  color: #fff;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.24);
}

.intro-copy .eyebrow {
  color: #f3d79e;
}

.intro-copy h1 {
  font-size: clamp(3rem, 8vw, 6.7rem);
  letter-spacing: 0;
}

.intro-copy p {
  max-width: 620px;
  margin: 14px 0 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: clamp(1rem, 2vw, 1.28rem);
}

.site-directory {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.feature-card {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 14px;
  align-items: center;
  min-height: 116px;
  padding: 18px;
  text-align: right;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  box-shadow: 0 12px 28px rgba(21, 34, 31, 0.06);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.feature-card:hover {
  transform: translateY(-2px);
  border-color: rgba(36, 85, 76, 0.28);
  box-shadow: 0 18px 34px rgba(21, 34, 31, 0.1);
}

.feature-card svg {
  width: 52px;
  height: 52px;
  padding: 12px;
  border-radius: 50%;
  background: var(--green-2);
  color: var(--green);
}

.feature-card strong,
.feature-card small {
  display: block;
}

.feature-card strong {
  font-size: 1.05rem;
}

.feature-card small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.86rem;
}

.tree-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tree-wide-action {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.84rem;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(36, 85, 76, 0.16);
  border-radius: 50%;
  background: #fff;
  color: var(--green);
  transition: transform 160ms ease, border-color 160ms ease;
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

.icon-button:hover {
  transform: translateY(-1px);
  border-color: rgba(36, 85, 76, 0.36);
}

.tree-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  max-width: none;
  margin: 0 auto;
}

.tree-sidebar {
  align-self: start;
  display: grid;
  grid-template-columns: minmax(220px, 340px) 1fr minmax(260px, auto);
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 12px 28px rgba(21, 34, 31, 0.06);
}

.root-nav {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 4px;
  scrollbar-width: thin;
}

.root-nav-title {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
}

.tree-color-legend {
  grid-column: 1 / -1;
  display: none;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.76rem;
}

.tree-layout.focused-subtree-layout .tree-color-legend {
  display: flex;
}

.tree-color-legend-title {
  font-weight: 780;
}

.tree-color-legend > span:not(.tree-color-legend-title) {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.family-color-swatch {
  display: inline-block;
  width: 11px;
  height: 11px;
  border: 1px solid transparent;
  border-radius: 50%;
}

.family-color-green {
  border-color: #4d8463;
  background: #d9ecdf;
}

.family-color-blue {
  border-color: #547fa4;
  background: #dce9f4;
}

.family-color-red {
  border-color: #ad5b6d;
  background: #f2d9df;
}

.root-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(36, 85, 76, 0.14);
  border-radius: 999px;
  background: #fff;
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 760;
  white-space: nowrap;
}

.root-chip small {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: #eef5f2;
  color: var(--muted);
  font-size: 0.72rem;
}

.root-chip.active {
  border-color: rgba(36, 85, 76, 0.36);
  background: var(--green-2);
  box-shadow: 0 8px 20px rgba(36, 85, 76, 0.1);
}

.focused-root-chip {
  cursor: default;
}

.focus-return-chip {
  border-color: rgba(138, 47, 69, 0.24);
  color: var(--wine);
}

.search-result-chip {
  cursor: default;
}

.tree-view .section-head {
  max-width: none;
}

.search-box {
  position: relative;
  display: block;
}

.search-box svg {
  position: absolute;
  top: 50%;
  right: 12px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  transform: translateY(-50%);
}

.search-box input,
label input,
label textarea,
label select,
.relationship-picker select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  outline: none;
}

.search-box input {
  height: 44px;
  padding: 0 40px 0 12px;
}

.relationship-search-box {
  margin-top: 6px;
}

.relationship-search-box input {
  margin-top: 0;
}

.relationship-picker select[multiple] {
  line-height: 1.7;
}

.relationship-picker select[size] {
  min-height: 132px;
  padding-block: 6px;
}

.relationship-picker-wide {
  grid-column: 1 / -1;
}

.relationship-picker[hidden] {
  display: none;
}

.relationship-message {
  margin: 4px 0 0;
}

.relationship-search-box input:disabled {
  background: #f3f5f3;
  color: var(--muted);
  cursor: not-allowed;
}

label input,
label select,
.relationship-picker select {
  min-height: 42px;
  padding: 0 10px;
  margin-top: 6px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.82rem;
}

.inline-check input {
  width: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--green);
}

label input:disabled {
  background: #f3f5f3;
  color: var(--muted);
}

label textarea {
  padding: 10px;
  margin-top: 6px;
  resize: vertical;
}

.field-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.card-color-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.card-color-field legend {
  margin-bottom: 6px;
}

.card-color-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.card-color-choice {
  position: relative;
  cursor: pointer;
}

.card-color-choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.card-color-choice-body {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

.card-color-choice:hover .card-color-choice-body {
  border-color: rgba(36, 85, 76, 0.34);
}

.card-color-choice input:checked + .card-color-choice-body {
  border-color: var(--green);
  background: #f4faf7;
  box-shadow: inset 0 0 0 1px rgba(36, 85, 76, 0.12);
}

.card-color-choice input[value="red"]:checked + .card-color-choice-body {
  border-color: var(--wine);
  background: #fff1f3;
  color: var(--wine);
  box-shadow: inset 0 0 0 1px rgba(138, 47, 69, 0.12);
}

.card-color-choice input:focus-visible + .card-color-choice-body {
  outline: 3px solid rgba(185, 133, 40, 0.28);
  outline-offset: 2px;
}

.card-color-swatch {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border: 1px solid rgba(21, 34, 31, 0.18);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.82);
}

.card-color-swatch-default {
  background: #fff;
}

.card-color-swatch-red {
  background: var(--wine);
}

.person-mention {
  display: inline;
  padding: 0 3px;
  border: 0;
  border-radius: 5px;
  background: rgba(36, 85, 76, 0.1);
  color: var(--green);
  font: inherit;
  font-weight: 800;
  line-height: inherit;
  cursor: pointer;
}

.person-mention:hover {
  background: rgba(36, 85, 76, 0.18);
}

.mention-menu {
  position: fixed;
  z-index: 5000;
  display: grid;
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid rgba(36, 85, 76, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 40px rgba(21, 34, 31, 0.18);
}

.mention-menu[hidden] {
  display: none;
}

.mention-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  text-align: right;
}

.mention-option:hover,
.mention-option.active {
  background: var(--green-2);
}

.mention-option strong,
.mention-option span,
.mention-option small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mention-option span {
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 760;
  direction: ltr;
}

.mention-option small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.74rem;
}

label input:focus,
label textarea:focus,
label select:focus,
.relationship-picker select:focus,
.search-box input:focus {
  border-color: rgba(36, 85, 76, 0.55);
  box-shadow: 0 0 0 3px rgba(36, 85, 76, 0.11);
}

.tree-stage {
  direction: ltr;
  width: 100%;
  min-height: 680px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f4faf7;
  box-shadow: var(--shadow);
}

.tree-canvas {
  position: relative;
  direction: rtl;
  width: 1420px;
  height: 760px;
  transform-origin: top left;
}

.tree-lines,
.tree-nodes {
  position: absolute;
  inset: 0;
}

.tree-lines {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.tree-lines line,
.tree-lines polyline {
  shape-rendering: geometricPrecision;
}

.tree-lines .descent-line {
  stroke: rgba(35, 83, 116, 0.76);
  stroke-width: 3;
  stroke-linecap: round;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.8)) drop-shadow(0 0 2px rgba(35, 83, 116, 0.18));
}

.tree-lines .wrapped-family-connector,
.tree-lines .shelf-marriage-line,
.tree-lines .cross-row-marriage-line {
  stroke-linejoin: round;
}

.tree-lines .marriage-line {
  stroke: rgba(138, 47, 69, 0.62);
  stroke-width: 2.7;
  stroke-linecap: round;
}

.tree-stage.focused-subtree {
  min-height: 260px;
  background: #f6fbf8;
}

.tree-stage.focused-subtree .person-name {
  font-size: 0.98rem;
  font-weight: 820;
}

.tree-lines .routed-marriage-line {
  stroke-width: 2.4;
}

.tree-lines .shelf-marriage-line {
  stroke-width: 2.8;
}

.tree-lines .marriage-dot {
  fill: #fff;
  stroke: var(--wine);
  stroke-width: 2;
}

.tree-lines .descent-junction {
  fill: #fff;
  stroke: rgb(35, 83, 116);
  stroke-width: 2.4;
}

.person-node {
  position: absolute;
  direction: rtl;
  display: grid;
  justify-items: center;
  width: 138px;
  min-height: 158px;
  padding: 10px 8px;
  border: 1px solid rgba(36, 85, 76, 0.18);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  box-shadow: 0 12px 28px rgba(21, 34, 31, 0.09);
  cursor: pointer;
  transform: translate(-50%, -50%);
}

.person-node.branch-open {
  border-color: var(--gold);
}

.person-node.active-root {
  box-shadow: 0 14px 32px rgba(36, 85, 76, 0.16);
}

.person-node.branch-bridge {
  border-style: dashed;
}

.branch-toggle {
  position: absolute;
  top: -11px;
  left: -11px;
  z-index: 3;
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid rgba(185, 133, 40, 0.36);
  border-radius: 999px;
  background: #fff;
  color: var(--gold);
  font-weight: 820;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(21, 34, 31, 0.1);
}

.branch-toggle[hidden] {
  display: none;
}

.branch-link {
  position: absolute;
  top: -11px;
  right: -11px;
  z-index: 3;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(49, 93, 126, 0.3);
  border-radius: 999px;
  background: #fff;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 820;
  box-shadow: 0 8px 18px rgba(21, 34, 31, 0.1);
}

.branch-link[hidden] {
  display: none;
}

.person-node.gender-male {
  border-color: rgba(49, 93, 126, 0.24);
}

.person-node.gender-female {
  border-color: rgba(138, 47, 69, 0.22);
}

.person-node.card-color-red {
  border-color: #74263a;
  background: #963149;
  color: #fff;
  box-shadow: 0 14px 30px rgba(116, 38, 58, 0.24);
}

.person-node.card-color-red.branch-open {
  border-color: #ddb45b;
}

.person-node.card-color-red .avatar {
  background: #f6dbe1;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.62);
}

.person-node.card-color-red.active-root {
  box-shadow: 0 16px 34px rgba(116, 38, 58, 0.3);
}

.tree-stage.focused-subtree .person-node.family-role-father,
.tree-stage.focused-subtree .person-node.family-role-parent,
.tree-stage.focused-subtree .person-node.family-role-child {
  border-color: #4d8463;
  background: #e4f2e8;
  color: #173b2b;
  box-shadow: 0 12px 28px rgba(49, 105, 74, 0.15);
}

.tree-stage.focused-subtree .person-node.family-role-father .avatar,
.tree-stage.focused-subtree .person-node.family-role-parent .avatar,
.tree-stage.focused-subtree .person-node.family-role-child .avatar {
  background: #cfe5d6;
  box-shadow: 0 0 0 1px rgba(77, 132, 99, 0.28);
}

.tree-stage.focused-subtree .person-node.family-role-mother {
  border-color: #547fa4;
  background: #e5eff8;
  color: #17364f;
  box-shadow: 0 12px 28px rgba(59, 104, 143, 0.15);
}

.tree-stage.focused-subtree .person-node.family-role-mother .avatar {
  background: #cfdfed;
  box-shadow: 0 0 0 1px rgba(84, 127, 164, 0.28);
}

.tree-stage.focused-subtree .person-node.family-role-inlaw {
  border-color: #ad5b6d;
  background: #f7e5e9;
  color: #542330;
  box-shadow: 0 12px 28px rgba(138, 47, 69, 0.14);
}

.tree-stage.focused-subtree .person-node.family-role-inlaw .avatar {
  background: #edd0d7;
  box-shadow: 0 0 0 1px rgba(173, 91, 109, 0.28);
}

.tree-stage.focused-subtree .person-node[class*="family-role-"]:hover,
.tree-stage.focused-subtree .person-node[class*="family-role-"].selected {
  border-color: var(--gold);
  box-shadow: 0 16px 34px rgba(185, 133, 40, 0.2);
}

.person-node:hover,
.person-node.selected {
  border-color: var(--gold);
  box-shadow: 0 16px 34px rgba(185, 133, 40, 0.18);
}

.person-node.search-match {
  border-color: var(--gold);
  box-shadow: 0 16px 34px rgba(185, 133, 40, 0.2);
}

.person-node.search-context {
  opacity: 0.74;
}

.person-node:hover,
.person-node:focus-within {
  z-index: 5;
}

.person-node:focus-visible {
  outline: 3px solid rgba(185, 133, 40, 0.3);
  outline-offset: 4px;
}

.avatar {
  width: 82px;
  height: 82px;
  overflow: hidden;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--green-2);
  box-shadow: 0 0 0 1px rgba(36, 85, 76, 0.17);
}

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

.person-name {
  display: block;
  margin-top: 8px;
  font-size: 0.88rem;
  font-weight: 780;
  line-height: 1.45;
}

.person-node.dimmed {
  opacity: 0.27;
}

.tree-empty {
  position: absolute;
  top: 120px;
  left: 50%;
  display: grid;
  gap: 8px;
  min-width: min(520px, calc(100vw - 64px));
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  color: var(--muted);
  text-align: center;
  box-shadow: 0 14px 32px rgba(21, 34, 31, 0.08);
  transform: translateX(-50%);
}

.tree-empty strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.node-actions {
  position: absolute;
  top: calc(100% - 3px);
  left: 50%;
  z-index: 4;
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  width: 148px;
  padding: 5px;
  border: 1px solid rgba(36, 85, 76, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 24px rgba(21, 34, 31, 0.12);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -4px);
  transition: opacity 160ms ease, transform 160ms ease;
}

body.admin-mode .node-actions {
  display: grid;
}

body.admin-mode .person-node:hover .node-actions,
body.admin-mode .person-node:focus-within .node-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.node-actions button {
  min-height: 26px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #f4faf7;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 760;
  line-height: 1;
}

.node-actions button:hover {
  border-color: rgba(36, 85, 76, 0.22);
  background: var(--green-2);
}

.node-actions button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.5;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  max-width: 1420px;
  margin: 0 auto;
}

.gallery-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 12px 26px rgba(21, 34, 31, 0.07);
}

.gallery-image-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: zoom-in;
}

.gallery-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.gallery-card-copy {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.gallery-card h3 {
  margin-bottom: 4px;
  font-size: 1.05rem;
}

.gallery-card p,
.muted {
  color: var(--muted);
}

.gallery-edit-button.admin-only {
  justify-self: start;
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.gallery-viewer-dialog {
  width: min(96vw, 1180px);
}

.gallery-viewer-card {
  width: min(96vw, 1180px);
  max-height: 92vh;
  padding: 14px;
  gap: 12px;
}

.gallery-viewer-card img {
  display: block;
  width: 100%;
  max-height: 74vh;
  object-fit: contain;
  border-radius: var(--radius);
  background: #eef2ef;
}

.gallery-viewer-copy {
  padding: 0 4px 4px;
}

.gallery-viewer-copy h2 {
  margin: 0;
  font-size: 1.2rem;
}

.gallery-viewer-copy p {
  margin: 4px 0 0;
  color: var(--muted);
}

.gallery-viewer-share {
  margin-top: 12px;
}

.social-panel {
  display: grid;
  gap: 22px;
  max-width: 1180px;
  margin: 0 auto;
}

.social-creators-section,
.social-feed-section {
  display: grid;
  gap: 12px;
}

.social-section-title h2 {
  margin: 0;
  font-size: 1.25rem;
}

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

.social-influencer-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 12px 26px rgba(21, 34, 31, 0.06);
}

.social-influencer-card img,
.social-post-head img {
  width: 58px;
  height: 58px;
  border: 3px solid #fff;
  border-radius: 50%;
  object-fit: cover;
  background: var(--green-2);
  box-shadow: 0 0 0 1px rgba(36, 85, 76, 0.16);
}

.social-influencer-card img {
  width: 72px;
  height: 72px;
}

.social-influencer-card h3,
.social-influencer-card p,
.social-post-copy h3,
.social-post-copy p {
  margin: 0;
}

.social-influencer-card span,
.social-influencer-card small,
.social-post-head span,
.social-post-copy time {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
}

.social-influencer-card p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.9rem;
}

.social-influencer-card .admin-only {
  grid-column: 2;
  justify-self: start;
}

.social-feed {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.social-post-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 16px 34px rgba(21, 34, 31, 0.08);
}

.social-post-head {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
}

.social-post-head strong {
  display: block;
}

.social-post-media img,
.social-post-media video {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #eef2ef;
}

.social-post-copy {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.social-post-copy p {
  color: var(--muted);
}

.calendar-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.calendar-panel {
  display: grid;
  gap: 16px;
  max-width: 1420px;
  margin: 0 auto;
}

.calendar-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(185, 133, 40, 0.18);
  border-radius: var(--radius);
  background: #fffaf0;
  color: #72521a;
}

.calendar-summary-main,
.calendar-live {
  display: grid;
  gap: 2px;
}

.calendar-summary-main {
  min-width: 0;
}

.calendar-summary-main > span {
  font-size: 1.08rem;
  font-weight: 820;
}

.calendar-date-row {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  max-width: 100%;
  white-space: nowrap;
}

.calendar-date-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  color: #755317;
  font-size: 0.83rem;
  font-weight: 720;
  line-height: 1.5;
}

.calendar-date-tabari {
  color: #6f4c0f;
}

.calendar-date-gregorian {
  color: var(--blue);
}

.calendar-date-jalali {
  color: var(--green);
}

.calendar-date-weekday {
  color: var(--wine);
}

.calendar-date-divider {
  width: 1px;
  height: 20px;
  border-radius: 999px;
  background: linear-gradient(180deg, transparent, rgba(185, 133, 40, 0.48), transparent);
}

.calendar-summary small,
.calendar-live small {
  color: #80612b;
}

.calendar-live {
  min-width: 150px;
  text-align: center;
}

.calendar-live strong {
  color: var(--green);
  font-size: 1.18rem;
  line-height: 1.2;
}

.calendar-event-guide {
  justify-self: end;
  margin: -4px 0 0;
  color: #80612b;
  font-size: 0.76rem;
  font-weight: 520;
  text-align: left;
}

.calendar-weather {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(36, 85, 76, 0.12);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 10px 24px rgba(21, 34, 31, 0.05);
}

.weather-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.weather-head h2 {
  margin: 0;
  color: var(--green);
  font-size: 1.02rem;
}

.weather-head small {
  color: var(--muted);
}

.weather-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.weather-card {
  display: grid;
  gap: 3px;
  min-height: 142px;
  padding: 12px;
  border: 1px solid rgba(36, 85, 76, 0.12);
  border-radius: 8px;
  background: #f8faf8;
}

.weather-card h3,
.weather-card p {
  margin: 0;
}

.weather-card h3 {
  color: var(--ink);
  font-size: 0.95rem;
}

.weather-degree {
  display: inline-flex;
  align-items: baseline;
  direction: ltr;
  unicode-bidi: isolate;
  font-family: "PinarLatin", "Pinar", Tahoma, sans-serif;
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1;
}

.weather-card strong {
  color: var(--green);
  font-size: 1.45rem;
  line-height: 1.2;
}

.weather-degree-low {
  color: var(--blue);
  font-size: 0.47rem;
}

.weather-degree-high {
  color: var(--gold);
  font-size: 0.47rem;
}

.weather-card p {
  font-size: 0.49rem;
  line-height: 1.35;
}

.weather-card small {
  font-size: 0.46rem;
  line-height: 1.4;
}

.weather-card small,
.weather-card p,
.weather-error {
  color: var(--muted);
}

.weather-error {
  padding: 12px;
  border-radius: 8px;
  background: #fff7f2;
}

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

.calendar-month {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 214px;
  padding: 14px;
  border: 1px solid rgba(36, 85, 76, 0.14);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 12px 26px rgba(21, 34, 31, 0.06);
}

.calendar-month.special-period {
  grid-template-rows: auto 1fr auto;
  align-content: stretch;
  border-color: rgba(185, 133, 40, 0.28);
  background: #fffdf7;
}

.calendar-month-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.calendar-month-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.month-number {
  display: inline-grid;
  min-width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--green-2);
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 820;
  line-height: 1;
}

.month-number.extra {
  min-width: 54px;
  padding: 0 9px;
  border-radius: 999px;
  background: #f7eddc;
  color: #72521a;
  font-size: 0.74rem;
}

.calendar-month h2 {
  margin: 0;
  color: var(--green);
  font-size: 1rem;
}

.calendar-month-note {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.25;
  white-space: nowrap;
}

.calendar-month.special-period .calendar-month-note {
  align-self: end;
  justify-self: start;
  padding-top: 8px;
}

.calendar-month.special-period .calendar-days {
  align-self: start;
}

.calendar-days {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.calendar-day {
  display: inline-grid;
  grid-template-rows: 1fr 6px;
  min-width: 0;
  min-height: 31px;
  place-items: center;
  padding: 3px 0 2px;
  border: 1px solid rgba(36, 85, 76, 0.1);
  border-radius: 7px;
  background: #f8faf8;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 720;
  line-height: 1;
}

.calendar-day.has-event {
  border-color: rgba(185, 133, 40, 0.38);
  background: #fffaf0;
  color: #72521a;
}

button.calendar-day:hover {
  transform: translateY(-1px);
  border-color: rgba(185, 133, 40, 0.56);
  box-shadow: 0 8px 14px rgba(185, 133, 40, 0.12);
}

.calendar-event-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
}

.calendar-day.today {
  border-color: rgba(138, 47, 69, 0.34);
  background: #fff1f3;
  color: var(--wine);
  box-shadow: inset 0 0 0 1px rgba(138, 47, 69, 0.18);
}

.calendar-day.today .calendar-event-dot {
  background: var(--wine);
}

.calendar-day.leap-day {
  grid-column: span 2;
  background: #f7eddc;
  color: #72521a;
}

.calendar-event-card {
  max-width: 680px;
}

.calendar-event-detail {
  display: grid;
  gap: 18px;
}

.calendar-event-item {
  display: grid;
  gap: 10px;
}

.calendar-event-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.calendar-event-head span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--green-2);
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 780;
}

.calendar-event-head time {
  font-size: 0.86rem;
  font-weight: 720;
}

.calendar-event-item h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.35rem, 3vw, 2rem);
}

.calendar-event-item p {
  margin: 0;
  color: var(--ink);
}

.calendar-event-source,
.calendar-event-source a {
  color: var(--muted);
}

.history-panel {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 clamp(4px, 2vw, 18px);
}

.history-calligraphy {
  margin-bottom: 26px;
  color: var(--wine);
  font-family: "Leila", "Pinar", sans-serif;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
  text-align: center;
}

.history-articles {
  display: grid;
  gap: 10px;
}

.history-index-item {
  display: grid;
  grid-template-columns: minmax(112px, 150px) minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border: 1px solid rgba(36, 85, 76, 0.16);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(31, 46, 42, 0.06);
}

.history-index-item time,
.article-head time {
  color: var(--green);
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
}

.history-index-item h2 {
  margin: 0;
  font-size: clamp(1.05rem, 2.2vw, 1.35rem);
}

.article-page {
  display: grid;
  gap: 18px;
  max-width: 980px;
  margin: 0 auto;
}

.article-detail-panel,
.article-comment-box,
.article-admin-comments {
  display: grid;
  gap: 16px;
}

.history-article {
  display: block;
}

.article-body {
  display: grid;
  gap: 14px;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.article-head {
  display: grid;
  gap: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.article-head h2,
.article-head p,
.article-body p,
.article-references h4,
.history-figure {
  margin: 0;
}

.article-head h2 {
  font-size: clamp(1.3rem, 3vw, 1.85rem);
}

.article-head p,
.article-references,
.history-figure figcaption {
  color: var(--muted);
}

.article-body p {
  font-size: 1.05rem;
}

.history-figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 4px;
}

.history-figure img,
.history-figure video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f1ea;
}

.history-figure figcaption {
  padding-top: 7px;
  font-size: 0.92rem;
}

.article-references {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.article-references h4 {
  color: var(--ink);
  font-size: 1rem;
}

.article-references ol {
  margin: 0;
  padding-right: 20px;
}

.article-references li + li {
  margin-top: 4px;
}

.article-comment-box,
.article-admin-comments,
.article-share-box {
  padding: clamp(18px, 3vw, 26px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.article-comment-box h2,
.article-comment-box p,
.article-admin-comments h2,
.article-share-box h2,
.article-share-box p {
  margin: 0;
}

.article-share-box {
  display: grid;
  gap: 14px;
}

.article-share-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.article-share-preview {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid rgba(36, 85, 76, 0.14);
  border-radius: 8px;
  background: #f8faf8;
}

.article-share-preview strong {
  color: var(--ink);
  font-size: 1.04rem;
}

.article-share-preview span,
.article-share-preview p {
  color: var(--muted);
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(36, 85, 76, 0.15);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 760;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.share-icon {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  background: transparent;
}

.share-icon svg {
  display: block;
  width: 24px;
  height: 24px;
  fill: currentColor;
  stroke: none;
}

.share-button.telegram .share-icon {
  color: #2aabee;
}

.share-button.whatsapp .share-icon {
  color: #25d366;
}

.share-button.instagram .share-icon {
  color: #c13584;
}

.share-button.facebook .share-icon {
  color: #1877f2;
}

.share-button:hover {
  transform: translateY(-1px);
  border-color: rgba(36, 85, 76, 0.32);
  box-shadow: 0 10px 22px rgba(21, 34, 31, 0.08);
}

.article-comment-form {
  display: grid;
  gap: 12px;
}

body.admin-mode .article-admin-comments.admin-only {
  display: grid;
}

.modal {
  width: min(94vw, 920px);
  border: 0;
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(21, 34, 31, 0.38);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  display: grid;
  gap: 14px;
  width: min(94vw, 480px);
  max-width: 100%;
  max-height: min(86vh, 900px);
  overflow: auto;
  margin: auto;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.modal-card.large {
  width: min(94vw, 920px);
}

.modal-close {
  position: absolute;
  top: 12px;
  left: 12px;
}

.person-detail {
  display: grid;
  gap: 18px;
}

.detail-head {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 16px;
  align-items: center;
}

.detail-head .avatar {
  width: 112px;
  height: 112px;
}

.detail-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
}

.detail-meta span {
  padding: 3px 9px;
  border-radius: 999px;
  background: #f1f4f3;
}

.lineage-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.lineage-stat {
  display: grid;
  gap: 2px;
  align-content: center;
  min-height: 78px;
  padding: 10px;
  border: 1px solid rgba(36, 85, 76, 0.14);
  border-radius: var(--radius);
  background: #fbfcfa;
}

.lineage-stat-children {
  grid-column: span 2;
}

.lineage-stat strong {
  color: var(--gold);
  font-size: 1.35rem;
  font-weight: 860;
  line-height: 1.1;
}

.lineage-stat span {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 760;
}

.lineage-stat small {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.5;
}

.detail-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.detail-gallery img,
.detail-gallery video,
.submission-media img,
.submission-media video {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius);
  object-fit: cover;
  background: #eef2ef;
}

.request-form {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(36, 85, 76, 0.14);
  border-radius: var(--radius);
  background: #f7faf8;
}

.request-form h3 {
  margin: 0;
  font-size: 1.08rem;
}

.detail-admin-tools {
  display: none;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(185, 133, 40, 0.24);
  border-radius: var(--radius);
  background: #fffaf0;
}

body.admin-mode .person-detail .detail-admin-tools.admin-only {
  display: grid;
}

.detail-admin-head {
  display: grid;
  gap: 12px;
}

.detail-admin-head h3,
.detail-admin-head p {
  margin: 0;
}

.detail-admin-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-upload-form {
  display: grid;
  gap: 12px;
}

.submission-list {
  display: grid;
  gap: 12px;
}

.submission-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.submission-card.status-pending {
  border-color: rgba(185, 133, 40, 0.34);
  background: #fffaf0;
}

.submission-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.submission-head h3,
.submission-head p,
.submission-card p {
  margin: 0;
}

.submission-head > span,
.submission-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.submission-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.submission-meta span {
  padding: 3px 9px;
  border-radius: 999px;
  background: #f1f4f3;
}

.submission-media {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.empty-state {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: #fbfcfb;
}

.editor-heading {
  display: grid;
  gap: 4px;
  padding-left: 46px;
}

.editor-heading .muted {
  margin: 0;
}

.person-merge-panel {
  display: grid;
  gap: 12px;
  margin-top: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.person-merge-panel[hidden] {
  display: none;
}

.person-merge-heading,
.person-merge-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.person-merge-heading h3,
.person-merge-heading p,
.person-merge-preview p,
.person-merge-message {
  margin: 0;
}

.person-merge-heading p,
.person-merge-actions small,
.person-merge-preview > p {
  grid-column: 1 / -1;
  color: var(--muted);
}

.merge-current-badge {
  padding: 4px 9px;
  border: 1px solid rgba(36, 85, 76, 0.18);
  border-radius: 999px;
  background: var(--green-2);
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 780;
  white-space: nowrap;
}

.person-merge-panel select {
  width: 100%;
  min-height: 148px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  line-height: 1.8;
  outline: none;
}

.person-merge-panel select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(36, 85, 76, 0.1);
}

.person-merge-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  padding-block: 12px;
  border-block: 1px solid var(--line);
}

.person-merge-summary {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding-inline: 14px;
}

.person-merge-summary + .person-merge-summary {
  border-inline-start: 1px solid var(--line);
}

.person-merge-summary strong,
.person-merge-summary span,
.person-merge-summary small {
  overflow-wrap: anywhere;
}

.person-merge-summary strong {
  color: var(--ink);
  font-size: 1rem;
}

.person-merge-summary span,
.person-merge-summary small {
  color: var(--muted);
  font-size: 0.8rem;
}

.person-merge-handle {
  direction: ltr;
  text-align: right;
  unicode-bidi: isolate;
}

.person-merge-role {
  color: var(--green) !important;
  font-weight: 780;
}

.person-merge-summary.duplicate .person-merge-role,
.person-merge-warning {
  color: var(--wine) !important;
}

.person-merge-warning {
  grid-column: 1 / -1;
  margin: 10px 14px 0;
  font-size: 0.82rem;
  font-weight: 760;
}

.person-merge-actions small {
  max-width: 520px;
  font-size: 0.78rem;
}

.batch-add-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(36, 85, 76, 0.14);
  border-radius: var(--radius);
  background: #fbfcfb;
}

.batch-add-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.batch-add-head h3,
.batch-add-head p,
.batch-preview-summary,
.batch-format-note span,
.batch-status + small {
  margin: 0;
}

.batch-add-head p,
.batch-format-note span,
.batch-status + small {
  color: var(--muted);
}

.batch-format-note {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px dashed rgba(36, 85, 76, 0.2);
  border-radius: var(--radius);
  background: #fff;
}

.batch-format-note code {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--green-2);
  color: var(--green);
  white-space: normal;
  overflow-wrap: anywhere;
}

.batch-preview {
  display: grid;
  gap: 10px;
}

.batch-preview.empty-state {
  display: block;
}

.batch-preview-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.batch-preview-summary span {
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef3f1;
  color: var(--muted);
  font-size: 0.78rem;
}

.batch-table-wrap {
  max-height: 440px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.batch-preview-table {
  width: 100%;
  min-width: 1350px;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.batch-preview-table th,
.batch-preview-table td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.batch-preview-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7faf8;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
}

.batch-preview-table input,
.batch-preview-table select {
  width: 100%;
  min-width: 94px;
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.batch-preview-table tr.has-error input,
.batch-preview-table tr.has-error select {
  border-color: rgba(138, 47, 69, 0.34);
}

.batch-status {
  display: inline-flex;
  align-items: center;
  width: max-content;
  margin-bottom: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 760;
  white-space: nowrap;
}

.batch-status.ok {
  background: var(--green-2);
  color: var(--green);
}

.batch-status.warning {
  background: #fff4dd;
  color: var(--gold);
}

.batch-status.error {
  background: #fdebed;
  color: var(--wine);
}

.batch-status + small {
  display: block;
  min-width: 180px;
  font-size: 0.72rem;
  line-height: 1.6;
}

.admin-only {
  display: none;
}

body.admin-mode .admin-only {
  display: inline-flex;
}

.admin-panel {
  display: grid;
  gap: 18px;
}

.admin-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.tab {
  min-height: 36px;
  padding: 0 12px;
  background: #fff;
  border-color: var(--line);
}

.tab.active {
  background: var(--green-2);
  color: var(--green);
  border-color: rgba(36, 85, 76, 0.22);
}

.admin-tab {
  display: none;
}

.admin-tab.active {
  display: grid;
  gap: 16px;
}

.sync-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(185, 133, 40, 0.24);
  border-radius: var(--radius);
  background: #fffaf0;
}

.full-backup-owner-tools {
  display: none;
}

body.owner-mode .full-backup-owner-tools {
  display: grid;
}

.full-backup-panel {
  gap: 12px;
  padding: 14px 0;
  border-block: 1px solid var(--line);
}

.full-backup-panel > strong {
  color: var(--ink);
  font-size: 0.98rem;
}

.backup-progress {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 0;
  border-radius: 5px;
  accent-color: var(--green);
}

.backup-progress[hidden] {
  display: none;
}

.sync-diagnostics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.sync-diagnostics span {
  padding: 4px 9px;
  border: 1px solid rgba(36, 85, 76, 0.14);
  border-radius: 999px;
  background: #fff;
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  margin-top: 28px;
  color: var(--muted);
}

.check-label input {
  width: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--green);
}

.error-message {
  color: #9a243d;
}

.warning-message {
  color: #72521a;
}

.sync-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  display: none;
  max-width: min(440px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid rgba(36, 85, 76, 0.2);
  border-radius: var(--radius);
  background: #fff;
  color: var(--green);
  box-shadow: var(--shadow);
  line-height: 1.6;
}

body.admin-mode .sync-toast.visible {
  display: block;
}

.sync-toast.warning {
  border-color: rgba(185, 133, 40, 0.36);
  background: #fffaf0;
  color: #72521a;
}

.sync-toast.error {
  border-color: rgba(154, 36, 61, 0.28);
  background: #fff1f3;
  color: #9a243d;
}

.admin-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px;
  border: 1px solid rgba(36, 85, 76, 0.14);
  border-radius: var(--radius);
  background: #f4faf7;
}

.admin-note p {
  margin: 0;
  color: var(--muted);
}

.editor-form {
  display: grid;
  gap: 13px;
}

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

.form-actions,
.data-tools {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.compact-list {
  display: grid;
  gap: 8px;
}

.compact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
}

.compact-row button {
  flex: 0 0 auto;
}

.form-message {
  min-height: 24px;
  margin: 0;
  color: var(--green);
}

@media (max-width: 1320px) {
  .site-header {
    grid-template-columns: minmax(220px, 1fr) auto;
    grid-template-areas:
      "brand actions"
      "nav nav";
  }

  .primary-nav {
    justify-content: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .primary-nav::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 980px) {
  .site-header {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "nav"
      "actions";
    align-items: stretch;
  }

  .primary-nav,
  .quick-actions {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .primary-nav::-webkit-scrollbar,
  .quick-actions::-webkit-scrollbar {
    display: none;
  }

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

  .tree-sidebar {
    grid-template-columns: 1fr;
    order: 2;
  }

  .tree-layout.focused-subtree-layout .tree-sidebar {
    order: -1;
  }

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

  .calendar-summary {
    grid-template-columns: 1fr 1fr;
  }

  .calendar-event-guide {
    grid-column: 1 / -1;
    text-align: left;
  }

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

@media (max-width: 640px) {
  main {
    padding: 16px;
  }

  .brand small {
    display: none;
  }

  .section-head {
    display: grid;
    align-items: start;
  }

  .nav-item {
    min-width: 128px;
  }

  .intro-hero {
    min-height: 480px;
    background-position: center;
  }

  .intro-copy {
    padding: 24px 18px;
  }

  .feature-card {
    grid-template-columns: 46px 1fr;
    min-height: 102px;
    padding: 14px;
  }

  .feature-card svg {
    width: 46px;
    height: 46px;
  }

  .site-directory {
    grid-template-columns: 1fr;
  }

  .site-directory {
    display: grid;
  }

  .calendar-summary {
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
  }

  .calendar-live {
    text-align: right;
  }

  .calendar-date-row {
    flex-wrap: wrap;
    white-space: normal;
  }

  .weather-head {
    display: grid;
  }

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

  .social-influencer-card,
  .social-post-head {
    grid-template-columns: 52px 1fr;
  }

  .social-influencer-card img,
  .social-post-head img {
    width: 52px;
    height: 52px;
  }

  .social-influencer-card .admin-only,
  .social-post-head .admin-only {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .tree-stage {
    min-height: 540px;
  }

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

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

  .person-merge-summary + .person-merge-summary {
    margin-top: 10px;
    padding-top: 10px;
    border-inline-start: 0;
    border-top: 1px solid var(--line);
  }

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

  .lineage-stat-children {
    grid-column: 1 / -1;
  }

  .history-index-item {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .article-share-head,
  .share-actions {
    display: grid;
  }

  .share-button {
    justify-content: center;
  }

  .modal-card {
    padding: 22px 16px;
  }
}
