:root {
  --bg: #f4eee6;
  --cream: #fffaf4;
  --card: rgba(255, 255, 255, 0.88);
  --text: #2a211b;
  --muted: #7b6b5f;
  --primary: #8b5a34;
  --primary-dark: #4f301d;
  --gold: #d7a86e;
  --line: #bd8757;
  --danger: #9c2f22;
  --shadow: 0 22px 60px rgba(64, 39, 22, 0.16);
  --radius: 28px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(215, 168, 110, 0.35), transparent 32%),
    radial-gradient(circle at bottom right, rgba(139, 90, 52, 0.18), transparent 34%),
    linear-gradient(135deg, #f4eee6, #fffaf4);
}

button {
  font: inherit;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(460px, 100%);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(139, 90, 52, 0.18);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  border-radius: 34px;
  padding: 36px;
  animation: enterSoft 0.7s ease both;
}

.brand-badge,
.eyebrow {
  display: inline-flex;
  background: #f1dcc4;
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.login-card h1 {
  margin: 18px 0 10px;
  font-size: clamp(2rem, 5vw, 2.7rem);
  line-height: 1.05;
}

.login-card p {
  color: var(--muted);
  line-height: 1.6;
}

form {
  display: grid;
  gap: 18px;
  margin-top: 28px;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 800;
}

input {
  width: 100%;
  border: 1px solid rgba(139, 90, 52, 0.25);
  border-radius: 18px;
  padding: 15px 16px;
  font-size: 1rem;
  background: rgba(255, 250, 244, 0.86);
  outline: none;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(139, 90, 52, 0.14);
}

form button,
.primary-button {
  border: none;
  border-radius: 18px;
  padding: 15px 18px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

form button:hover,
.primary-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(79, 48, 29, 0.26);
}

.form-message {
  color: var(--danger);
  font-weight: 800;
  min-height: 22px;
}

.family-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 16px clamp(18px, 4vw, 46px);
  background: rgba(255, 250, 244, 0.82);
  border-bottom: 1px solid rgba(139, 90, 52, 0.16);
  backdrop-filter: blur(18px);
}

.brand {
  font-size: 1.55rem;
  font-weight: 1000;
  color: var(--primary-dark);
}

.family-header p {
  margin: 2px 0 0;
  color: var(--muted);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.soft-button,
.ghost-button {
  border: 1px solid rgba(139, 90, 52, 0.22);
  border-radius: 999px;
  padding: 11px 16px;
  font-weight: 900;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.72);
  color: var(--primary-dark);
  transition: transform 0.2s ease, background 0.2s ease;
}

.soft-button:hover,
.ghost-button:hover {
  transform: translateY(-2px);
  background: white;
}

.ghost-button {
  color: #7a271d;
}

.family-page {
  padding: clamp(18px, 4vw, 46px);
}

.hero-family {
  max-width: 1280px;
  margin: 0 auto 24px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(139, 90, 52, 0.14);
  box-shadow: var(--shadow);
  border-radius: 34px;
  padding: clamp(24px, 4vw, 44px);
}

.hero-family h1 {
  margin: 16px 0 12px;
  font-size: clamp(2.3rem, 7vw, 5.6rem);
  line-height: 0.95;
  color: var(--primary-dark);
}

.hero-family p {
  max-width: 760px;
  color: var(--muted);
  line-height: 1.7;
  font-size: 1.05rem;
}

.tracking-panel {
  max-width: 1280px;
  margin: 0 auto 22px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.tracking-line {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
}

.track-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: max-content;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(139, 90, 52, 0.14);
  border-radius: 999px;
  padding: 8px 14px 8px 8px;
  animation: enterSoft 0.35s ease both;
}

.track-item:not(:last-child)::after {
  content: "";
  width: 40px;
  height: 2px;
  background: var(--line);
  margin-left: 6px;
}

.track-item span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--primary));
  color: white;
  font-weight: 1000;
}

.track-item p {
  margin: 0;
  font-weight: 900;
  color: var(--primary-dark);
}

.tree-shell {
  max-width: 100%;
  margin: 0 auto;
}

.tree-canvas {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 14px 0 36px;
  scroll-behavior: smooth;
}

.tree-flow {
  display: flex;
  align-items: flex-start;
  gap: 58px;
  width: max-content;
  min-width: 100%;
  padding: 10px clamp(4px, 2vw, 28px);
}

.tree-flow.full-tree {
  flex-wrap: wrap;
  width: 100%;
  justify-content: center;
}

.family-column {
  position: relative;
  width: min(520px, calc(100vw - 44px));
  min-height: 560px;
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 250, 244, 0.76));
  border: 1px solid rgba(139, 90, 52, 0.16);
  border-radius: 38px;
  box-shadow: var(--shadow);
  padding: 28px;
  animation: slideFamily 0.62s cubic-bezier(.2,.8,.2,1) both;
  animation-delay: var(--delay);
}

.family-column:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -58px;
  width: 58px;
  height: 4px;
  background: linear-gradient(90deg, var(--line), rgba(189, 135, 87, 0.15));
  transform: translateY(-50%);
}

.family-column:not(:last-child)::before {
  content: "";
  position: absolute;
  top: calc(50% - 7px);
  right: -62px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--line);
  box-shadow: 0 0 0 7px rgba(189, 135, 87, 0.16);
}

.family-parents {
  display: flex;
  justify-content: center;
  gap: 18px;
  width: 100%;
}

.family-children {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  width: 100%;
}

.family-union {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  color: var(--primary-dark);
}

.family-union span {
  height: 3px;
  background: var(--line);
  border-radius: 999px;
}

.family-union strong {
  background: #f1dcc4;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.92rem;
  text-align: center;
}

.family-person {
  width: 150px;
  border: none;
  border-radius: 28px;
  padding: 12px 12px 14px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 14px 32px rgba(64, 39, 22, 0.13);
  cursor: pointer;
  color: var(--text);
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    background 0.22s ease;
}

.family-person:hover {
  transform: translateY(-8px) scale(1.035);
  box-shadow: 0 24px 48px rgba(64, 39, 22, 0.2);
  background: white;
}

.family-person.parent {
  width: 170px;
}

.photo-ring {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 5px;
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(215, 168, 110, 0.85), rgba(139, 90, 52, 0.82));
  margin-bottom: 12px;
}

.photo-ring img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 20px;
  object-fit: cover;
  background: #ead8c5;
}

.person-name {
  display: block;
  font-weight: 1000;
  line-height: 1.16;
}

.branch-hint {
  display: inline-flex;
  margin-top: 8px;
  font-size: 0.72rem;
  font-weight: 900;
  color: var(--primary-dark);
  background: #f3e0ca;
  border-radius: 999px;
  padding: 6px 9px;
}

.branch-hint.muted {
  color: var(--muted);
  background: rgba(123, 107, 95, 0.11);
}

.no-children,
.empty-state {
  width: 100%;
  border: 1px dashed rgba(139, 90, 52, 0.28);
  border-radius: 22px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
  font-weight: 800;
}

.person-panel {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  width: min(360px, calc(100vw - 44px));
  background: rgba(255, 250, 244, 0.94);
  border: 1px solid rgba(139, 90, 52, 0.18);
  box-shadow: 0 28px 80px rgba(32, 20, 13, 0.25);
  border-radius: 34px;
  padding: 28px;
  backdrop-filter: blur(18px);
  animation: panelIn 0.34s ease both;
}

.person-panel.hidden {
  display: none;
}

.panel-close {
  position: absolute;
  right: 12px;
  top: 12px;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  background: #f1dcc4;
  color: var(--primary-dark);
  font-size: 1.4rem;
  cursor: pointer;
}

.person-panel img {
  width: 132px;
  height: 132px;
  border-radius: 28px;
  object-fit: cover;
  display: block;
  margin-bottom: 18px;
  box-shadow: 0 18px 34px rgba(64, 39, 22, 0.16);
}

.person-panel h2 {
  margin: 0 0 8px;
  color: var(--primary-dark);
}

.person-panel p {
  color: var(--muted);
  line-height: 1.5;
}

@keyframes slideFamily {
  from {
    opacity: 0;
    transform: translateX(54px) scale(0.96);
    filter: blur(8px);
  }

  to {
    opacity: 1;
    transform: translateX(0) scale(1);
    filter: blur(0);
  }
}

@keyframes enterSoft {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 850px) {
  .family-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
  }

  .soft-button,
  .ghost-button {
    flex: 1;
  }

  .family-column {
    width: calc(100vw - 36px);
    min-height: auto;
    padding: 22px;
  }

  .tree-flow {
    gap: 32px;
  }

  .family-column:not(:last-child)::after,
  .family-column:not(:last-child)::before {
    right: -34px;
  }

  .family-column:not(:last-child)::after {
    width: 34px;
  }

  .family-parents {
    gap: 12px;
  }

  .family-person,
  .family-person.parent {
    width: 138px;
  }

  .hero-family {
    border-radius: 28px;
  }

  .person-panel {
    left: 16px;
    right: 16px;
    bottom: 16px;
    width: auto;
  }
}

@media (max-width: 520px) {
  .family-page {
    padding: 14px;
  }

  .hero-family {
    padding: 22px;
  }

  .family-column {
    padding: 18px;
  }

  .family-person,
  .family-person.parent {
    width: 128px;
  }

  .family-union {
    gap: 8px;
  }

  .family-union strong {
    font-size: 0.78rem;
  }
}