:root {
  --sidebar-bg: #1C1008;
  --accent: #8B1A1A;
  --accent-hover: #A52020;
  --cream: #F5EDD8;
  --card-bg: #FFFFFF;
  --text-muted: #6B6B6B;
  --border: #E5DDD0;
  --male-bg: #DBEAFE;
  --female-bg: #FCE7F3;
  --dead-bg: #F3F4F6;
}

body {
  background: var(--cream);
}

.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  min-height: 100vh;
  flex-shrink: 0;
}

.mobile-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 70;
  width: min(320px, 86vw);
  height: 100vh;
  background: var(--sidebar-bg);
  transform: translateX(-100%);
  transition: transform .2s ease;
  overflow-y: auto;
}

.mobile-sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, .45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

body.menu-open {
  overflow: hidden;
}

body.menu-open .mobile-sidebar {
  transform: translateX(0);
}

body.menu-open .mobile-sidebar-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: #ccc;
  border-radius: 8px;
  cursor: pointer;
  transition: .15s;
}

.nav-item:hover {
  background: rgba(139, 26, 26, .3);
  color: #fff;
}

.nav-item.active {
  background: var(--accent);
  color: #fff;
}

.tree-node {
  width: 156px;
  height: 84px;
  border-radius: 14px;
  position: absolute;
  padding: 10px 12px;
  font-size: 14px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(77, 55, 30, .12);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.tree-node:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(77, 55, 30, .16);
}

.tree-node-male {
  background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
  border: 1.5px solid #8bb8f8;
}

.tree-node-female {
  background: linear-gradient(180deg, #fce7f3 0%, #fbcfe8 100%);
  border: 1.5px solid #f59bcb;
}

.tree-node-dead {
  background: var(--dead-bg);
  border: 1.5px solid #D1D5DB;
  opacity: .85;
}

.tree-node-inlaw {
  border-style: dashed !important;
}

.tree-node.selected {
  outline: 2.5px dashed var(--accent);
  outline-offset: 3px;
}

.tree-node-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  color: #1f2937;
  white-space: normal;
  overflow-wrap: anywhere;
}

.tree-node-meta {
  margin-top: 4px;
  font-size: 12px;
  color: #5b6576;
}

.tree-node-generation {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  color: #6b7280;
}

.tree-canvas-shell {
  background: linear-gradient(180deg, #ffffff 0%, #f8f8f8 100%);
  border-color: #e5e7eb;
}

.tree-canvas {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, rgba(156, 163, 175, .10) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(156, 163, 175, .10) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(156, 163, 175, .10) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(156, 163, 175, .10) 75%);
  background-size: 28px 28px;
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
}

.tree-detail-panel {
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, .08), rgba(255, 255, 255, 0) 42%),
    linear-gradient(180deg, #7f0f0f 0%, #590808 100%);
  border-left-color: #460707;
}

.tree-panel-close-btn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .35);
  background: linear-gradient(180deg, rgba(255, 255, 255, .24), rgba(255, 255, 255, .08));
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 8px 16px rgba(0, 0, 0, .2);
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}

.tree-panel-close-btn:hover {
  transform: translateY(-1px);
  background: linear-gradient(180deg, rgba(255, 255, 255, .3), rgba(255, 255, 255, .14));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 10px 18px rgba(0, 0, 0, .25);
}

.tree-panel-btn {
  width: 100%;
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .01em;
  color: #fff;
  box-shadow: 0 6px 14px rgba(0, 0, 0, .2);
  transition: transform .15s ease, filter .15s ease, box-shadow .15s ease;
}

.tree-panel-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 9px 18px rgba(0, 0, 0, .24);
}

.tree-panel-btn-spouse {
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
  border-color: rgba(191, 219, 254, .42);
}

.tree-panel-btn-child {
  background: linear-gradient(180deg, #22c55e 0%, #15803d 100%);
  border-color: rgba(187, 247, 208, .4);
}

.tree-panel-btn-edit {
  background: linear-gradient(180deg, #f59e0b 0%, #b45309 100%);
  border-color: rgba(253, 230, 138, .42);
}

.tree-panel-btn-delete {
  background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);
  border-color: rgba(254, 202, 202, .38);
}

.tree-panel-btn-ghost {
  color: #fff;
  background: linear-gradient(180deg, rgba(255, 255, 255, .2), rgba(255, 255, 255, .08));
  border-color: rgba(255, 255, 255, .35);
}

.tree-panel-btn-save {
  background: linear-gradient(180deg, #0ea5a4 0%, #0f766e 100%);
  border-color: rgba(153, 246, 228, .42);
}

.tree-action-secondary {
  background: #fff;
  color: #6b2a13;
  border: 1px solid #e4cfad;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  transition: .15s;
}

.tree-action-secondary:hover {
  background: #fff8ea;
}

.tree-node-search-hit {
  box-shadow: 0 0 0 3px rgba(139, 26, 26, .18), 0 2px 6px rgba(0, 0, 0, .08);
}

.tree-node-search-active {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
  animation: treePulse 1.25s ease-in-out infinite;
}

@keyframes treePulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 3px rgba(139, 26, 26, .18), 0 2px 6px rgba(0, 0, 0, .08);
  }
  50% {
    transform: scale(1.04);
    box-shadow: 0 0 0 8px rgba(139, 26, 26, .12), 0 6px 18px rgba(0, 0, 0, .12);
  }
}

.stat-card {
  background: #fff;
  border: 0.5px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  cursor: pointer;
  font-size: 14px;
  transition: .15s;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-green {
  background: rgb(10, 148, 6);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  cursor: pointer;
  font-size: 14px;
  transition: .15s;
}

.btn-green:hover {
  background: rgb(5, 117, 3);
}

.cal-cell {
  min-height: 72px;
  border: 0.5px solid var(--border);
  padding: 4px;
  font-size: 12px;
}

.cal-clickable {
  cursor: pointer;
  transition: background-color .15s ease;
}

.cal-clickable:hover {
  background: #f8f3e8;
}

.cal-day-number {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.cal-today {
  background: #FEF3C7;
}

.cal-sunday {
  color: #DC2626;
}

.cal-saturday {
  color: #2563EB;
}

.event-pill {
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  margin-top: 2px;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 430px 1fr;
}

.auth-left {
  background: linear-gradient(165deg, #1c1008 0%, #571111 58%, #8B1A1A 100%);
  color: #f4d8ad;
}

.auth-card {
  width: min(430px, 92vw);
  border: 1px solid #eadfce;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .08);
}

@media (max-width: 900px) {
  .auth-shell {
    display: block;
  }

  .auth-left {
    display: none;
  }
}
