:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --text: #2d2a26;
  --muted: #8a857c;
  --accent: #3f6b4f;
  --accent-dark: #2f513a;
  --border: #e7e3dc;
  --danger: #c0392b;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header { background: var(--card); border-bottom: 1px solid var(--border); }
.nav-inner {
  max-width: 1000px; margin: 0 auto;
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 12px 24px;
}
.brand {
  font-weight: 700; font-size: 18px; color: var(--text);
  margin-right: 12px;
}
.brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: 4px; flex-wrap: wrap; margin-right: auto; }
.nav-links a {
  padding: 7px 12px; border-radius: 6px; color: var(--text);
  font-size: 14px; font-weight: 500;
}
.nav-links a:hover { background: #efece6; text-decoration: none; }

main { max-width: 1000px; margin: 0 auto; padding: 24px; }

h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 19px; margin: 28px 0 12px; }
h3 { font-size: 16px; margin: 16px 0 8px; }

.muted { color: var(--muted); font-size: 90%; }

.flash { max-width: 1000px; margin: 12px auto 0; padding: 0 24px; }
.flash p {
  background: #e7f3ea; border-left: 4px solid var(--accent);
  padding: 10px 14px; border-radius: 6px; color: #1f4a2c; margin: 6px 0;
}

.btn {
  display: inline-block; padding: 8px 16px; background: var(--accent);
  color: #fff !important; border-radius: 6px; border: none;
  font-size: 14px; font-weight: 500; cursor: pointer;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--accent) !important; border: 1px solid var(--accent); }
.btn.ghost:hover { background: #eef3ef; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 20px; margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.card p:first-child { margin-top: 0; }

.people { list-style: none; padding: 0; margin: 0; }
.people li { margin-bottom: 8px; }
.people a.person-link {
  display: flex; align-items: baseline; gap: 10px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 11px 14px;
  color: var(--text); font-size: 15px;
}
.people a.person-link:hover {
  border-color: var(--accent); text-decoration: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.people a.person-link .dates { margin-left: auto; }

.search { display: flex; gap: 8px; margin-bottom: 20px; }
.search input[type=text] {
  flex: 1; max-width: 480px; padding: 10px 14px; font-size: 15px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card);
}

.edit label { display: block; margin: 14px 0; font-size: 14px; font-weight: 500; }
.edit input[type=text], .edit select, .edit textarea {
  width: 100%; max-width: 520px; padding: 9px 12px; font-size: 15px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card);
  margin-top: 4px; font-family: inherit;
}
.edit input:focus, .edit select:focus, .edit textarea:focus {
  outline: none; border-color: var(--accent);
}

.note { background: #fdf6e3; border-left: 4px solid #e0b84c; padding: 10px 14px; border-radius: 6px; }

.photo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.photo-grid figure { margin: 0; }
.photo-grid img {
  width: 100%; height: 140px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--border); display: block;
}

.danger-btn {
  background: var(--danger); color: #fff; border: none; border-radius: 6px;
  padding: 3px 9px; cursor: pointer; font-size: 13px;
}
.danger-btn:hover { background: #a93226; }

.upload { margin-top: 20px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.upload input[type=text] { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; }

table.access {
  border-collapse: collapse; width: 100%; background: var(--card);
  border: 1px solid var(--border); border-radius: 8px;
}
table.access th, table.access td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
table.access th { background: #efece6; }

/* визуальное дерево */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-left: 26px; }
.tree li { position: relative; padding: 6px 0 6px 26px; }
.tree li::before {
  content: ""; position: absolute; left: 0; top: 0;
  border-left: 1px solid #cfc9bf; height: 100%;
}
.tree li:last-child::before { height: 16px; }
.tree li::after {
  content: ""; position: absolute; left: 0; top: 16px;
  border-top: 1px solid #cfc9bf; width: 20px;
}
.tree .node {
  display: inline-flex; align-items: baseline; gap: 8px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 12px; font-size: 14px;
}
.tree .node a { color: var(--text); font-weight: 500; }
.tree .node .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  object-fit: cover; vertical-align: middle;
  border: 1px solid var(--border); flex-shrink: 0;
}
.tree .node .avatar-empty {
  display: inline-flex; align-items: center; justify-content: center;
  background: #efece6; font-size: 13px;
}
.events { list-style: none; padding: 0; margin: 0; }
.events li {
  display: flex; gap: 10px; align-items: center;
  padding: 6px 0; border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.events li:last-child { border-bottom: none; }
.events .when { margin-left: auto; }
.events .ev-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 17px; flex-shrink: 0;
}
.events li.type-birthday .ev-icon { background: #eaf4e0; }
.events li.type-death .ev-icon { background: #efefef; }
.events li.type-marriage .ev-icon { background: #fdeaea; }
.events li.type-birthday .name { color: #7a8c3a; font-weight: 500; }
.events li.type-death .name { color: #000000; font-weight: 700; }
.events li.type-marriage .name { color: #b0385a; }
.status-alive .name { color: #7a8c3a; }
.status-dead .name { color: #000000; font-weight: 700; }
.status-unknown .name { color: #2563eb; }

