:root {
  --sand-50: #f7f0e4;
  --sand-100: #efe2cc;
  --sand-200: #e0c9a5;
  --sand-300: #d0b07e;
  --sand-400: #b8925a;
  --sand-500: #9a7340;
  --sand-600: #7a5932;
  --sand-700: #5c4033;
  --sand-800: #3d2914;
  --sand-900: #2a1b0e;
  --clay: #a65d3f;
  --gold: #c9a227;
  --mist: rgba(247, 240, 228, 0.72);
  --panel: rgba(61, 41, 20, 0.55);
  --font-ui: "Sora", "Segoe UI", sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --radius: 14px;
  --shadow-3d: 0 10px 0 #5c4033, 0 14px 28px rgba(42, 27, 14, 0.35);
  --shadow-3d-press: 0 3px 0 #5c4033, 0 6px 12px rgba(42, 27, 14, 0.3);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--sand-50);
  background:
    radial-gradient(ellipse 120% 80% at 10% -10%, #d4b483 0%, transparent 55%),
    radial-gradient(ellipse 90% 70% at 100% 0%, #a67c52 0%, transparent 50%),
    linear-gradient(165deg, #8b6914 0%, #5c4033 42%, #2a1b0e 100%);
  background-attachment: fixed;
}

@media (min-width: 801px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
}

@media (min-width: 801px) {
  #app {
    height: 100vh;
    height: 100dvh;
  }
}

/* Ensure hidden wins over .btn-3d { display: inline-flex } */
[hidden],
.btn-3d[hidden] {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: linear-gradient(180deg, rgba(247, 240, 228, 0.16), rgba(42, 27, 14, 0.35));
  border-bottom: 1px solid rgba(224, 201, 165, 0.25);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.main-nav {
  flex-wrap: wrap;
  row-gap: 0.75rem;
}

.main-nav-links {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
}

.main-nav-btn.is-active {
  pointer-events: none;
}

@media (max-width: 900px) {
  .main-nav-links {
    order: 3;
    width: 100%;
  }

  .main-nav-actions {
    margin-left: 0;
  }
}

.brand img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  object-position: 50% 28%;
  border-radius: 50%;
  border: 2px solid rgba(247, 240, 228, 0.55);
  box-shadow: 0 6px 0 rgba(61, 41, 20, 0.45);
}

.brand-text h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 2.5vw, 1.65rem);
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--sand-50);
  text-shadow: 0 2px 0 rgba(42, 27, 14, 0.45);
}

.brand-text p {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: var(--sand-200);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.badge {
  font-size: 0.72rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(201, 162, 39, 0.22);
  border: 1px solid rgba(201, 162, 39, 0.45);
  color: var(--sand-100);
}

.btn-3d {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 650;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  color: var(--sand-900);
  background: linear-gradient(180deg, #f3e6d0 0%, #c9a66b 55%, #a67c52 100%);
  padding: 0.65rem 1.05rem;
  border-radius: 12px;
  box-shadow: var(--shadow-3d);
  transform: translateY(0);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-3d:hover {
  filter: brightness(1.06);
}

.btn-3d:active {
  transform: translateY(7px);
  box-shadow: var(--shadow-3d-press);
}

.btn-3d.is-active {
  background: linear-gradient(180deg, #e8c97a 0%, #c9a227 55%, #8b6914 100%);
  color: var(--sand-900);
}

.btn-3d.ghost {
  background: linear-gradient(180deg, rgba(247, 240, 228, 0.35), rgba(154, 115, 64, 0.55));
  color: var(--sand-50);
}

.btn-3d.danger {
  background: linear-gradient(180deg, #e8b4a0 0%, #a65d3f 60%, #6e3420 100%);
  color: #fff8ee;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

@media (max-width: 800px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(45vh, 1fr) auto;
    overflow: auto;
  }

  .viewport-wrap {
    order: 1;
  }

  .sidebar {
    order: 2;
    max-height: 40vh;
    border-right: none;
    border-top: 1px solid rgba(224, 201, 165, 0.18);
  }
}

.sidebar {
  padding: 1rem;
  background: var(--panel);
  border-right: 1px solid rgba(224, 201, 165, 0.18);
  overflow: auto;
  min-height: 0;
}

.sidebar h2 {
  margin: 0 0 0.65rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--sand-100);
}

.sidebar .hint {
  margin: 0 0 1rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--sand-200);
}

.branch-list {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 1.25rem;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.35rem;
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  line-height: 1.35;
}

.crumb-link {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--sand-100);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.crumb-link:hover {
  color: var(--gold);
}

.crumb.current {
  color: var(--sand-200);
  font-weight: 650;
}

.crumb-sep {
  color: var(--sand-400);
  opacity: 0.7;
}

.branch-chip {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
}

.branch-chip .swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25), 0 2px 0 rgba(255, 255, 255, 0.25);
}

/* —— "Whole Horoz family" home action — distinct from the spouse toggle —— */
.nav-home-btn {
  appearance: none;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-align: left;
  padding: 0.55rem 0.7rem;
  margin-bottom: 1rem;
  border-radius: 14px;
  border: 1px solid rgba(201, 162, 39, 0.55);
  color: var(--sand-900);
  background: linear-gradient(180deg, #f3e6d0 0%, #e0c187 55%, #c9a227 100%);
  box-shadow: var(--shadow-3d);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.15s ease;
}

.nav-home-btn:hover { filter: brightness(1.05); }

.nav-home-btn:active {
  transform: translateY(7px);
  box-shadow: var(--shadow-3d-press);
}

.nav-home-logo {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 28%;
  border: 2px solid rgba(92, 64, 51, 0.55);
  box-shadow: 0 3px 0 rgba(61, 41, 20, 0.4);
}

.nav-home-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.nav-home-text strong {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 650;
}

.nav-home-text small {
  font-size: 0.68rem;
  color: var(--sand-700);
}

/* —— Married-in spouse switch — obviously a toggle, not the Horoz button —— */
.spouse-toggle {
  appearance: none;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-align: left;
  padding: 0.5rem 0.65rem;
  margin-bottom: 1.25rem;
  border-radius: 12px;
  border: 1px dashed rgba(224, 201, 165, 0.4);
  background: rgba(42, 27, 14, 0.4);
  color: var(--sand-100);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.spouse-toggle:hover { border-color: rgba(201, 162, 39, 0.55); }

.spouse-toggle-track {
  flex: none;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: rgba(92, 64, 51, 0.65);
  border: 1px solid rgba(224, 201, 165, 0.35);
  position: relative;
  transition: background 0.18s ease;
}

.spouse-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--sand-100);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
  transition: transform 0.18s ease, background 0.18s ease;
}

.spouse-toggle.is-active .spouse-toggle-track {
  background: linear-gradient(180deg, #6b8f71, #4d7a52);
  border-color: rgba(120, 160, 90, 0.6);
}

.spouse-toggle.is-active .spouse-toggle-thumb {
  transform: translateX(18px);
  background: #fff8ee;
}

.spouse-toggle-label {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.spouse-toggle-label strong {
  font-size: 0.85rem;
  font-weight: 650;
}

.spouse-toggle-label small {
  font-size: 0.68rem;
  color: var(--sand-300);
}

.viewport-wrap {
  position: relative;
  min-height: 0;
  height: 100%;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 236, 190, 0.22), transparent 50%),
    linear-gradient(180deg, #6b4e32 0%, #3d2914 55%, #24180c 100%);
}

#tree-canvas {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
}

.hud {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  pointer-events: none;
}

.hud > * {
  pointer-events: auto;
}

.guest-join-banner {
  position: absolute;
  right: 1rem;
  bottom: 3.25rem;
  z-index: 6;
  width: min(340px, calc(100% - 2rem));
  padding: 0.95rem 1rem 1rem;
  border-radius: 14px;
  background: linear-gradient(165deg, rgba(251, 245, 234, 0.96), rgba(232, 213, 183, 0.94));
  color: var(--sand-900);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.4), 0 4px 0 #5c4033;
  border: 1px solid rgba(92, 64, 51, 0.28);
}

.guest-join-banner[hidden] {
  display: none !important;
}

.guest-join-title {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 650;
}

.guest-join-banner p {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--sand-700);
}

.guest-join-how {
  padding-top: 0.35rem;
  border-top: 1px solid rgba(92, 64, 51, 0.18);
}

.guest-join-how strong {
  color: var(--sand-800);
}

.guest-join-banner .btn-3d {
  margin-top: 0.15rem;
}

.view-menu {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 8;
  width: min(210px, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  overflow-y: auto;
  padding: 0.55rem;
  border-radius: 14px;
  background: linear-gradient(165deg, rgba(247, 240, 228, 0.94), rgba(201, 166, 107, 0.9));
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.35), 0 4px 0 #5c4033;
  border: 1px solid rgba(92, 64, 51, 0.3);
  display: grid;
  gap: 0.35rem;
  color: var(--sand-900);
  touch-action: none;
}

.view-menu-label {
  margin: 0.35rem 0 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sand-700);
}

.view-menu-handle {
  cursor: grab;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.25rem 0.2rem 0.4rem;
  color: var(--sand-700);
  user-select: none;
}

.view-menu-handle:active {
  cursor: grabbing;
}

.view-menu .view-opt {
  width: 100%;
  justify-content: center;
  font-size: 0.75rem;
  padding: 0.48rem 0.55rem;
  box-shadow: 0 4px 0 #5c4033, 0 6px 10px rgba(42, 27, 14, 0.22);
}

.view-menu .view-opt:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #5c4033;
}

.btn-3d.tiny {
  font-size: 0.72rem;
  padding: 0.4rem 0.55rem;
  box-shadow: 0 3px 0 #5c4033;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.filter-chip {
  flex: 1 1 auto;
  justify-content: center;
  min-width: 4.2rem;
}

#opt-spouses {
  margin-bottom: 0.75rem;
}

.path-row {
  display: flex;
  gap: 0.5rem;
  font-size: 0.82rem;
  align-items: baseline;
}

.path-k {
  flex: 0 0 2.6rem;
  opacity: 0.7;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.path-result {
  margin: 0.15rem 0;
  font-size: 0.8rem;
  color: #e8d5b7;
}

.path-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.person-card.name-only {
  width: auto;
  min-width: 160px;
  max-width: min(320px, calc(100% - 2rem));
  padding: 0.75rem 0.85rem;
}

.person-card.name-only .person-name-only {
  margin: 0 0 0.55rem;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.15rem;
  font-weight: 650;
  color: var(--sand-900);
  line-height: 1.25;
}

.name-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.person-card,
.modal {
  background: linear-gradient(165deg, rgba(247, 240, 228, 0.95), rgba(224, 201, 165, 0.92));
  color: var(--sand-900);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35), 0 4px 0 #5c4033;
  border: 1px solid rgba(92, 64, 51, 0.25);
}

.person-card {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: min(360px, calc(100% - 2rem));
  padding: 1.1rem 1.15rem 1.15rem;
  display: none;
  z-index: 5;
  background: linear-gradient(165deg, #fbf5ea 0%, #e8d5b7 100%);
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.45), 0 5px 0 #5c4033;
  pointer-events: auto;
}

.person-card.peek {
  width: auto;
  min-width: 190px;
  max-width: min(260px, calc(100% - 1.5rem));
  padding: 0.7rem 0.75rem 0.75rem;
  right: auto;
  bottom: auto;
}

.person-card.peek .peek-close {
  position: absolute;
  top: 0.35rem;
  right: 0.4rem;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--sand-600);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem;
}

.person-card.peek .peek-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 0.65rem;
  align-items: center;
  padding-right: 0.85rem;
}

.person-card.peek .peek-photo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 18%;
  display: block;
  border: none;
  box-shadow: none;
  -webkit-mask-image: radial-gradient(circle at 50% 42%, #000 42%, rgba(0, 0, 0, 0.65) 64%, transparent 80%);
  mask-image: radial-gradient(circle at 50% 42%, #000 42%, rgba(0, 0, 0, 0.65) 64%, transparent 80%);
}

.person-card.peek .peek-photo--empty {
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 0.9rem;
  color: var(--sand-800);
  background: rgba(154, 115, 64, 0.22);
}

.person-card.peek .peek-given,
.person-card.peek .peek-surname,
.person-card.peek .peek-dob {
  margin: 0;
  line-height: 1.25;
}

.person-card.peek .peek-given {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--sand-900);
}

.person-card.peek .peek-surname {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 550;
  color: var(--sand-700);
}

.person-card.peek .peek-dob {
  margin-top: 0.25rem;
  font-size: 0.72rem;
  color: var(--sand-600);
}

.person-card-edit {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 2;
  font: 650 0.78rem/1 Sora, system-ui, sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.45rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(92, 64, 51, 0.35);
  background: linear-gradient(180deg, #f3e4c8, #d4b07a);
  color: #3d2a1c;
  box-shadow: 0 3px 0 #5c4033;
  cursor: pointer;
}

.person-card-edit:hover {
  filter: brightness(1.05);
}

.person-card-edit:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #5c4033;
}

.person-card-hint {
  margin: 0.35rem 0 0.65rem;
  font-size: 0.78rem;
}

.person-card.open {
  display: block;
  animation: rise 0.25s ease;
}

.person-card-head {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 0.85rem;
  align-items: center;
  margin-bottom: 0.35rem;
}

.person-photo {
  width: 88px;
  height: 88px;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 6px 0 #5c4033, 0 10px 18px rgba(42, 27, 14, 0.3);
  border: 2px solid rgba(92, 64, 51, 0.35);
  background: #d0b07e;
}

.person-photo.placeholder {
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 650;
  color: var(--sand-800);
  background: linear-gradient(160deg, #f3e6d0, #c9a66b);
}

.person-role {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sand-600);
}

.person-card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.2;
  color: var(--sand-900);
}

.person-card dl {
  margin: 0.85rem 0;
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.45rem 0.75rem;
  font-size: 0.9rem;
}

.person-card dt {
  color: var(--sand-600);
  font-weight: 650;
}

.person-card dd {
  margin: 0;
  color: var(--sand-900);
  font-weight: 600;
}

.person-notes {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--sand-700);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.footer-bar {
  padding: 0.65rem 1.25rem;
  font-size: 0.75rem;
  color: var(--sand-200);
  border-top: 1px solid rgba(224, 201, 165, 0.18);
  background: rgba(42, 27, 14, 0.4);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(42, 27, 14, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(480px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 1.25rem;
}

.modal h2 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
}

.form-grid {
  display: grid;
  gap: 0.75rem;
}

label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 600;
}

input,
select,
textarea {
  font: inherit;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(92, 64, 51, 0.35);
  background: #fff8ee;
  color: var(--sand-900);
  box-shadow: inset 0 2px 4px rgba(92, 64, 51, 0.12);
}

textarea {
  min-height: 80px;
  resize: vertical;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.error {
  color: #8b2e1a;
  font-size: 0.85rem;
  margin: 0;
}

.tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.muted {
  color: var(--sand-600);
  font-size: 0.8rem;
}

.intro-overlay[hidden] {
  display: none !important;
}

/* —— One-off Horoz portrait splash (not the homepage) —— */
.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  pointer-events: auto;
  background: #1a1008;
}

.intro-overlay.is-glimpse {
  /* Portrait stays — tree may show softly at the faded edges only */
  background: transparent;
  pointer-events: none;
}

.intro-portrait {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  opacity: 1;
  z-index: 1;
  pointer-events: none;
}

.intro-overlay.is-glimpse .intro-portrait {
  opacity: 1;
}

.intro-portrait img {
  width: min(100vw, 1400px);
  height: min(100vh, 1000px);
  object-fit: cover;
  object-position: 50% 28%;
  display: block;
  /* Soft fade into black — stronger falloff on the sides and edges */
  -webkit-mask-image: radial-gradient(
    ellipse 54% 58% at 50% 40%,
    #000 12%,
    rgba(0, 0, 0, 0.92) 28%,
    rgba(0, 0, 0, 0.45) 48%,
    transparent 72%
  );
  mask-image: radial-gradient(
    ellipse 54% 58% at 50% 40%,
    #000 12%,
    rgba(0, 0, 0, 0.92) 28%,
    rgba(0, 0, 0, 0.45) 48%,
    transparent 72%
  );
  filter: saturate(1.05) contrast(1.04);
}

.intro-hint {
  position: absolute;
  bottom: clamp(2.8rem, 8vh, 4.5rem);
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  z-index: 2;
  font-family: var(--font-display);
  font-size: clamp(0.85rem, 2.2vw, 1.05rem);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(247, 240, 228, 0.72);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.65);
  opacity: 0;
  transition: opacity 0.8s ease 0.4s;
  pointer-events: none;
  white-space: nowrap;
}

.intro-brand {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(1.5rem, 6vh, 3.5rem) 1.25rem 5rem;
  pointer-events: none;
  opacity: 1;
  text-align: center;
}

.intro-brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 5.5vw, 3.4rem);
  font-weight: 650;
  letter-spacing: 0.02em;
  color: #f7f0e4;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(42, 27, 14, 0.8);
}

.intro-credit {
  margin: 0.55rem 0 0;
  font-family: var(--font-ui);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  color: rgba(247, 240, 228, 0.55);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}

.intro-brand .intro-credit {
  position: absolute;
  bottom: clamp(0.85rem, 3.5vh, 1.75rem);
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  white-space: nowrap;
}

.intro-overlay.is-glimpse .intro-hint,
.intro-overlay.is-ready .intro-hint {
  opacity: 1;
}

/* —— Member / guest gate after intro —— */
.access-gate {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background:
    radial-gradient(ellipse 90% 70% at 50% 0%, rgba(201, 162, 39, 0.18), transparent 55%),
    rgba(26, 16, 8, 0.88);
  backdrop-filter: blur(8px);
}

.access-gate[hidden] {
  display: none !important;
}

.access-gate-card {
  width: min(420px, 100%);
  padding: 1.75rem 1.5rem 1.35rem;
  border-radius: 18px;
  background: linear-gradient(165deg, #fbf5ea 0%, #e8d5b7 100%);
  color: var(--sand-900);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.45), 0 6px 0 #5c4033;
  border: 1px solid rgba(92, 64, 51, 0.28);
  text-align: center;
}

.access-gate-logo {
  width: 72px;
  height: 72px;
  object-fit: cover;
  object-position: 50% 28%;
  border-radius: 50%;
  border: 2px solid rgba(92, 64, 51, 0.35);
  box-shadow: 0 5px 0 rgba(61, 41, 20, 0.4);
  margin: 0 auto 0.85rem;
  display: block;
}

.access-gate-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3.5vw, 1.75rem);
  font-weight: 650;
  color: var(--sand-900);
}

.access-gate-lead {
  margin: 0.65rem 0 1.15rem;
  font-size: 1rem;
  color: var(--sand-700);
}

.access-gate-actions {
  display: grid;
  gap: 0.65rem;
}

.access-gate-actions .btn-3d {
  width: 100%;
  justify-content: center;
}

.access-gate-note {
  margin: 1.1rem 0 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--sand-600);
}

.access-gate-credit {
  margin-top: 0.85rem;
  color: var(--sand-500);
}

.footer-credit {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: rgba(247, 240, 228, 0.55);
}

body.is-intro {
  overflow: hidden;
}

body.is-intro #app {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  grid-template-rows: 0 1fr 0;
}

body.is-intro #app .topbar,
body.is-intro #app .sidebar,
body.is-intro #app .footer-bar,
body.is-intro #app .view-menu,
body.is-intro #app .hud,
body.is-intro #app .person-card,
body.is-intro #app .guest-join-banner {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
  border: 0;
}

body.is-intro #app .workspace {
  grid-template-columns: 1fr;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

body.is-intro #app .viewport-wrap {
  border-radius: 0;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

body.is-intro #app #tree-canvas {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

.intro-overlay.is-done {
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.35s ease;
}

.intro-overlay.is-done .intro-portrait {
  opacity: 0;
  transition: opacity 1.35s ease;
}

.intro-overlay.is-done .intro-brand,
.intro-overlay.is-done .intro-hint {
  opacity: 0;
  transition: opacity 0.9s ease;
}
