@import url("https://fonts.googleapis.com/css2?family=Fraunces:wght@400;600;700&family=Space+Grotesk:wght@400;500;600&display=swap");

:root {
  --ink: #11100e;
  --sand: #efe6d9;
  --sun: #f2b63f;
  --clay: #c97b63;
  --leaf: #5b7c5a;
  --fog: #f7f2ea;
  --shadow: rgba(17, 16, 14, 0.12);
}

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

body {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #fffaf2 0%, #f3e7d8 40%, #ead8c5 100%);
  min-height: 100vh;
  position: relative;
}

.noise {
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.09'/%3E%3C/svg%3E");
  pointer-events: none;
  mix-blend-mode: multiply;
  z-index: 0;
}

.btn {
  border: 1px solid var(--ink);
  padding: 12px 22px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  background: transparent;
  cursor: pointer;
}

.btn.primary {
  background: var(--ink);
  color: var(--fog);
}

.btn.ghost {
  border-color: var(--clay);
  color: var(--clay);
}

.section {
  padding: 48px 8vw 80px;
  position: relative;
  z-index: 1;
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 32px;
}

.section-header h2 {
  font-family: "Fraunces", "Georgia", serif;
  font-size: clamp(28px, 4vw, 42px);
}

.section-header p {
  max-width: 380px;
  line-height: 1.6;
}

.tree-section {
  background: var(--fog);
  border-top: 1px solid rgba(17, 16, 14, 0.1);
  border-bottom: 1px solid rgba(17, 16, 14, 0.1);
  overflow: hidden;
}

.add-person {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  padding: 24px;
  margin-bottom: 28px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  border: 1px solid rgba(17, 16, 14, 0.08);
  box-shadow: 0 10px 24px var(--shadow);
}

.add-person .field {
  display: grid;
  gap: 8px;
}

.add-person label {
  font-size: 12px;
  letter-spacing: 1px;
}

.add-person button {
  align-self: end;
}

.tree {
  display: grid;
  gap: 28px;
  margin-bottom: 32px;
  position: relative;
}

.tree::before {
  display: none;
}

.tree::after {
  display: none;
}

.tree-level {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 28px 22px;
  position: relative;
  padding-top: 26px;
}

.tree-level::before {
  content: "";
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: rgba(17, 16, 14, 0.18);
}

.tree-level:first-child::before {
  display: none;
}

.node {
  background: white;
  border-radius: 18px;
  padding: 16px 18px;
  border: 1px solid rgba(17, 16, 14, 0.08);
  box-shadow: 0 12px 30px var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  width: min(220px, 90vw);
  text-align: center;
}

.node:hover {
  transform: translateY(-6px);
  box-shadow: 0 18px 40px rgba(17, 16, 14, 0.18);
}

.node h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.node span {
  display: block;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--leaf);
  margin-bottom: 12px;
}

.node button {
  margin-top: 10px;
  font-size: 12px;
  border: none;
  background: none;
  color: var(--clay);
  cursor: pointer;
}

.node::before {
  content: "";
  position: absolute;
  top: -26px;
  left: 50%;
  width: 1px;
  height: 26px;
  background: rgba(17, 16, 14, 0.18);
  transform: translateX(-50%);
}

.tree-level:first-child .node::before {
  display: none;
}

.avatar {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  margin: 0 auto 10px;
  background: radial-gradient(circle at top, #fff 0%, #f2eadf 100%);
  display: grid;
  place-items: center;
  font-family: "Fraunces", "Georgia", serif;
  font-size: 22px;
  border: 2px solid #f3e6d7;
  color: var(--ink);
}

.node .role {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(17, 16, 14, 0.6);
}

.details {
  background: var(--sand);
  border-radius: 24px;
  padding: 24px;
  min-height: 120px;
  border: 1px solid rgba(17, 16, 14, 0.08);
}

.details h3 {
  font-size: 22px;
  margin-bottom: 8px;
}

.details-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.details-actions .btn {
  padding: 8px 14px;
  font-size: 11px;
}

.btn.danger {
  border-color: #b84b4b;
  color: #b84b4b;
}

.detail-fields {
  display: grid;
  gap: 12px;
  margin: 12px 0 18px;
}

.detail-fields input,
.detail-fields textarea {
  width: 100%;
}

.detail-readonly {
  font-size: 14px;
  line-height: 1.4;
  color: rgba(17, 16, 14, 0.7);
}

.details-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(17, 16, 14, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 30;
}

.details-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.details-panel {
  position: relative;
  width: min(92vw, 560px);
}

.details-panel .details {
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.modal-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(17, 16, 14, 0.2);
  background: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.modal-open {
  overflow: hidden;
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.login-error {
  font-size: 13px;
  color: #8a2f2f;
  min-height: 18px;
}

.locked main {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}
.relation-list ul {
  padding-left: 18px;
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.relation-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.relation-editor {
  display: grid;
  gap: 10px;
  margin: 12px 0 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  border: 1px solid rgba(17, 16, 14, 0.08);
}

.link-button {
  border: none;
  background: none;
  color: #b84b4b;
  font-size: 12px;
  cursor: pointer;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #11100e;
  color: #f7f2ea;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
  font-size: 13px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  background: #1f4f2f;
}

.toast.error {
  background: #8a2f2f;
}

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

.story-card {
  background: rgba(255, 255, 255, 0.72);
  padding: 24px;
  border-radius: 20px;
  border: 1px solid rgba(17, 16, 14, 0.08);
}

.story-card h3 {
  margin-bottom: 12px;
}

.timeline {
  background: linear-gradient(120deg, rgba(91, 124, 90, 0.08), rgba(242, 182, 63, 0.1));
}

.timeline-track {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.timeline-item {
  background: white;
  padding: 20px;
  border-radius: 16px;
  border: 1px solid rgba(17, 16, 14, 0.08);
}

.year {
  font-family: "Fraunces", "Georgia", serif;
  font-size: 20px;
  display: block;
  margin-bottom: 8px;
  color: var(--clay);
}

.contact {
  background: var(--sand);
}

.contact-form {
  display: grid;
  gap: 16px;
  max-width: 480px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

input,
textarea {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(17, 16, 14, 0.2);
  font-family: inherit;
}

.footer {
  padding: 40px 8vw 60px;
  text-align: center;
  font-size: 14px;
}

.compact .tree {
  gap: 18px;
}

@media (max-width: 720px) {
  .nav {
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
  }

  .nav-links {
    flex-wrap: wrap;
    gap: 12px;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
