: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;
    flex-basis: 100%;
    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;
}

.language-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid rgba(224, 201, 165, 0.38);
  border-radius: 999px;
  background: rgba(42, 27, 14, 0.48);
}

.language-btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.3rem 0.55rem;
  color: var(--sand-100);
  background: transparent;
  font: 600 0.68rem/1 var(--font-ui);
  cursor: pointer;
  white-space: nowrap;
}

.language-btn.is-active {
  color: var(--sand-900);
  background: var(--gold);
}

.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;
}

.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);
}

.explore-search-label {
  display: block;
  margin: 0.85rem 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(224, 201, 165, 0.72);
}

.explore-search-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.4rem;
  margin: 0.85rem 0 0.35rem;
}

.explore-search-form .explore-search-label {
  flex: 1 1 12rem;
  min-width: 0;
  margin: 0;
}

.explore-search-submit {
  flex: none;
  margin-bottom: 0.05rem;
}

.explore-search-label input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid rgba(224, 201, 165, 0.28);
  background: rgba(20, 14, 10, 0.55);
  color: #f7f0e4;
  font: inherit;
  font-size: 0.92rem;
}

.explore-search-label input:focus {
  outline: none;
  border-color: rgba(201, 162, 39, 0.7);
  box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.18);
}

.explore-search-hint {
  margin: 0.4rem 0 0.85rem !important;
}

.explore-search-results {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0 0 0.85rem;
  max-height: 14rem;
  overflow: auto;
}

.explore-search-hit {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.45rem 0.55rem;
  border-radius: 10px;
  border: 1px solid rgba(224, 201, 165, 0.16);
  background: rgba(42, 27, 14, 0.55);
  color: #f7f0e4;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.explore-search-hit:hover,
.explore-search-hit:focus-visible {
  border-color: rgba(201, 162, 39, 0.55);
  background: rgba(72, 48, 24, 0.72);
  outline: none;
}

.explore-search-hit-photo,
.explore-search-hit-initials {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  flex: 0 0 auto;
  object-fit: cover;
}

.explore-search-hit-initials {
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  background: #5c7a3a;
  color: #fbf5ea;
}

.explore-search-hit-initials.sex-f { background: #a65d3f; }
.explore-search-hit-initials.sex-m { background: #3d5a80; }

.explore-search-hit-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.explore-search-hit-name {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.explore-search-hit-meta {
  font-size: 0.68rem;
  color: rgba(224, 201, 165, 0.62);
}

.explore-search-empty {
  margin: 0;
  padding: 0.45rem 0.2rem;
  font-size: 0.75rem;
  color: rgba(224, 201, 165, 0.5);
  font-style: italic;
}

.tree-subject-title {
  margin: 0 0 0.65rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 2px solid #c9a227;
  background: linear-gradient(165deg, rgba(201, 162, 39, 0.35), rgba(92, 64, 51, 0.55));
  color: #fff8e6;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
  box-shadow: 0 3px 0 rgba(92, 64, 51, 0.65);
}

.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-mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  width: 100%;
  margin-bottom: 0.55rem;
}

.branch-mode-row .branch-mode {
  width: 100%;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
}

.branch-chip {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
}

.branch-chip.is-disabled,
.branch-chip:disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

.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 1.85rem 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-close {
  position: absolute;
  top: 0.35rem;
  right: 0.4rem;
  width: 1.7rem;
  height: 1.7rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--sand-800);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
}

.guest-join-close:hover {
  opacity: 1;
  background: rgba(92, 64, 51, 0.12);
}

.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);
}

.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;
  touch-action: none;
  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;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.view-menu-handle:active {
  cursor: grabbing;
}

.view-menu-collapse {
  border: 1px solid rgba(92, 64, 51, 0.35);
  background: rgba(92, 64, 51, 0.12);
  border-radius: 7px;
  width: 24px;
  height: 24px;
  flex: none;
  line-height: 1;
  font-size: 1rem;
  font-weight: 800;
  color: var(--sand-900);
  cursor: pointer;
  padding: 0;
}

.view-menu.is-collapsed {
  gap: 0;
  overflow: hidden;
}

.view-menu.is-collapsed > :not(.view-menu-handle) {
  display: none !important;
}

.view-menu.is-collapsed {
  width: auto;
  min-width: 0;
}

.view-menu.is-collapsed .view-menu-handle {
  padding-bottom: 0.25rem;
}

/* Phones: shrink the diagram box and drop the drag-to-rearrange tools
   (they need a mouse and just add clutter on a small screen). */
@media (max-width: 800px) {
  .view-menu {
    top: 0.6rem;
    left: 0.6rem;
    width: min(160px, calc(100% - 1.2rem));
    max-height: calc(100% - 1.2rem);
    padding: 0.4rem;
    gap: 0.28rem;
    border-radius: 11px;
  }

  .view-menu .btn-3d.view-opt {
    font-size: 0.66rem;
    padding: 0.38rem 0.45rem;
    border-radius: 8px;
    box-shadow: 0 3px 0 #5c4033;
  }

  .view-menu-label {
    font-size: 0.58rem;
    margin-top: 0.2rem;
  }

  #opt-rearrange,
  #opt-reset-positions {
    display: none;
  }

  /* Phones: the diagram owns the screen — drop the decorative overlays */
  .chart-title {
    display: none;
  }

  .guest-join-banner {
    display: none !important;
  }

  .hud .badge {
    font-size: 0.58rem;
    padding: 0.25rem 0.5rem;
    max-width: calc(100vw - 1.5rem);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .view-menu.is-collapsed {
    width: auto;
  }
}

.view-menu-section,
.chart-design-options {
  display: grid;
  gap: 0.35rem;
}

.view-menu-section[hidden],
.chart-design-options[hidden],
.chart-only-tools[hidden],
.line-style-tools[hidden] {
  display: none;
}

.chart-design-field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  font-weight: 650;
  color: var(--sand-800);
}

.chart-design-check {
  grid-template-columns: auto 1fr;
  justify-items: start;
  cursor: pointer;
}

.chart-design-check input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--sand-800);
}

.chart-only-tools,
.line-style-tools {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.chart-design-field select {
  width: 105px;
  min-width: 0;
  padding: 0.28rem;
  border: 1px solid rgba(92, 64, 51, 0.35);
  border-radius: 6px;
  background: rgba(255, 250, 240, 0.88);
  color: var(--sand-900);
  font-size: 0.68rem;
}

.chart-design-field input[type="color"] {
  width: 48px;
  height: 28px;
  padding: 2px;
  border: 1px solid rgba(92, 64, 51, 0.35);
  border-radius: 6px;
  background: transparent;
}

.chart-design-field input[type="number"] {
  width: 64px;
  padding: 0.28rem 0.35rem;
  border: 1px solid rgba(92, 64, 51, 0.35);
  border-radius: 6px;
  background: rgba(255, 250, 240, 0.88);
  color: var(--sand-900);
  font-size: 0.75rem;
  text-align: right;
}

.chart-design-hint {
  margin: 0.1rem 0 0;
  font-size: 0.64rem;
  line-height: 1.35;
  color: var(--sand-700);
}

.export-format-list {
  margin: 0.35rem 0 0.85rem;
  padding-left: 1.15rem;
  color: var(--sand-700);
  font-size: 0.82rem;
  line-height: 1.45;
}

.export-format-list li {
  margin: 0.25rem 0;
}

.export-res-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.35rem 0 0.75rem;
}

.export-res-row .export-res.is-active {
  box-shadow: 0 3px 0 #5c4033, inset 0 0 0 1px rgba(201, 162, 39, 0.55);
}

.export-actions {
  flex-wrap: wrap;
}

#export-status {
  margin: 0.35rem 0;
  color: var(--sand-600);
}

.chart-title {
  position: absolute;
  top: 0.85rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  margin: 0;
  padding: 0.55rem 1.35rem;
  max-width: min(88%, 720px);
  text-align: center;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(1.35rem, 3.2vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff8e8;
  background: linear-gradient(165deg, rgba(42, 27, 14, 0.88), rgba(61, 41, 20, 0.82));
  border: 2px solid rgba(201, 162, 39, 0.75);
  border-radius: 14px;
  box-shadow: 0 4px 0 rgba(92, 64, 51, 0.75), 0 12px 28px rgba(0, 0, 0, 0.45);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-title[hidden] {
  display: none !important;
}

.chart-size-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-areas:
    ". up ."
    "left reset right"
    ". down .";
  gap: 0.3rem;
  justify-items: stretch;
  margin-bottom: 0.35rem;
}

.chart-size-btn {
  font-size: 0.9rem;
  font-weight: 800;
  padding: 0.35rem 0;
  min-width: 0;
  justify-content: center;
  touch-action: none;
  user-select: none;
}

.chart-size-btn.pad-up { grid-area: up; }
.chart-size-btn.pad-left { grid-area: left; }
.chart-size-btn.pad-reset { grid-area: reset; }
.chart-size-btn.pad-right { grid-area: right; }
.chart-size-btn.pad-down { grid-area: down; }

.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;
}

.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;
  /* Above the members-only gate (z-index 90) so Sign in is usable */
  z-index: 100;
}

.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);
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  width: 100%;
  box-sizing: border-box;
  padding-right: 4.4rem;
}

.password-eye {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  transform: translateY(-50%);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.4rem;
  height: 2rem;
  padding: 0 0.55rem;
  border: 1px solid rgba(92, 64, 51, 0.35);
  border-radius: 8px;
  background: linear-gradient(180deg, #fbf6ec, #efe2cc);
  color: var(--sand-900);
  box-shadow: 0 2px 0 #5c4033;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.password-eye:hover,
.password-eye:focus-visible {
  background: linear-gradient(180deg, #fff8ee, #f3e7d2);
  outline: none;
}

.password-eye:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

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;
}

.deploy-reminder-steps {
  margin: 0.75rem 0;
  padding-left: 1.25rem;
  line-height: 1.55;
}

.deploy-reminder-steps code,
.deploy-reminder-path code,
.deploy-reminder-warn code {
  font-size: 0.9em;
}

.deploy-reminder-warn {
  margin: 0.75rem 0;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: rgba(139, 46, 26, 0.12);
  border: 1px solid rgba(139, 46, 26, 0.35);
  color: #5c2414;
  font-size: 0.88rem;
  line-height: 1.45;
}

.deploy-reminder-path {
  font-size: 0.82rem;
  color: var(--sand-700);
  margin: 0 0 0.5rem;
}

.deploy-reminder-sub {
  margin: 1rem 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--sand-900);
}

.deploy-reminder-modal .hint,
#deploy-reminder-modal .hint {
  margin: 0.25rem 0 0.5rem;
  font-size: 0.82rem;
  color: var(--sand-700);
}

.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 {
  /* Stay opaque — do not reveal the tree under the portrait */
  background: #1a1008;
  pointer-events: auto;
}

.intro-portrait {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  opacity: 1;
  z-index: 1;
  pointer-events: none;
  transition: opacity 1.1s ease;
}

.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(12.5rem, 30vh, 16rem);
  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 language flags: pick a flag to enter in that language —— */
.intro-langs {
  position: absolute;
  /* Sits right on the fading bottom edge of Horoz's portrait,
     with "Designed by Cahit" left on its own below */
  bottom: clamp(6.5rem, 16vh, 9.5rem);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: clamp(1.4rem, 5vw, 2.6rem);
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.8s ease 0.4s;
}

.intro-overlay.is-glimpse .intro-langs,
.intro-overlay.is-ready .intro-langs {
  opacity: 1;
}

.intro-flag {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: grid;
  justify-items: center;
  gap: 0.45rem;
  transition: transform 0.15s ease;
}

.intro-flag:hover,
.intro-flag:focus-visible {
  transform: scale(1.08);
  outline: none;
}

.intro-flag svg {
  width: clamp(64px, 13vw, 88px);
  height: clamp(64px, 13vw, 88px);
  border-radius: 50%;
  display: block;
  /* Ghostly fade around the edges, like Horoz's portrait */
  -webkit-mask-image: radial-gradient(circle, #000 28%, rgba(0, 0, 0, 0.82) 48%, rgba(0, 0, 0, 0.28) 72%, transparent 92%);
  mask-image: radial-gradient(circle, #000 28%, rgba(0, 0, 0, 0.82) 48%, rgba(0, 0, 0, 0.28) 72%, transparent 92%);
}

.intro-flag-label {
  font-family: var(--font-display);
  font-size: clamp(0.78rem, 1.9vw, 0.95rem);
  letter-spacing: 0.1em;
  color: rgba(247, 240, 228, 0.85);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}

.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);
}

body.is-gated #app[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,
body.is-intro #app .workspace {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

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 {
  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: 1;
  pointer-events: none;
  background: #1a1008;
}

.intro-overlay.is-done .intro-portrait {
  opacity: 0;
  transition: opacity 1.1s ease;
}

.intro-overlay.is-done .intro-brand,
.intro-overlay.is-done .intro-hint {
  opacity: 0;
  transition: opacity 0.7s ease;
}

.intro-overlay.is-gone {
  opacity: 0;
  transition: opacity 0.45s ease;
}

/* ============================================================
   PHONES (≤800px) — kept at the END of the file on purpose so
   these rules always beat the desktop defaults above.
   The diagram is the star: thin one-row header, slim sidebar
   tray under it with filters first, wordy extras dropped.
   ============================================================ */

/* —— Header: logo row on top, then EVERY menu button below it,
      wrapping so nothing is ever cut off the screen edge —— */
@media (max-width: 800px) {
  /* Lock the app to the screen so the bottom is always reachable */
  #app {
    height: 100vh;
    height: 100dvh;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 0.25rem 0.3rem;
    row-gap: 0.3rem;
    padding: 0.25rem 0.4rem 0.35rem;
    justify-content: center;
  }

  /* Row 1: just the logo + title, centred */
  .brand {
    flex-basis: 100%;
    justify-content: center;
    gap: 0.4rem;
  }

  .brand img {
    width: 26px;
    height: 26px;
    border-width: 1px;
    box-shadow: 0 2px 0 rgba(61, 41, 20, 0.45);
  }

  .brand-text h1 {
    font-size: 0.85rem;
    white-space: nowrap;
  }

  /* The tagline is the first thing to go — it costs a whole text line */
  .brand-text p {
    display: none;
  }

  /* Row 2: all menu items together, wrapping onto extra rows if needed */
  .main-nav-links {
    order: 0;
    flex: 0 1 auto;
    flex-basis: auto;
    width: auto;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
    padding-bottom: 0;
  }

  .main-nav-links .btn-3d,
  .topbar-actions .btn-3d {
    font-size: 0.6rem;
    padding: 0.28rem 0.42rem;
    border-radius: 8px;
    white-space: nowrap;
    box-shadow: 0 2px 0 #5c4033;
  }

  .topbar-actions {
    flex: 0 1 auto;
    flex-wrap: wrap;
    justify-content: center;
    margin-left: 0;
    gap: 0.25rem;
  }

  /* The status pill on the diagram already says who you are */
  .topbar-actions .badge {
    display: none;
  }

  .language-btn {
    padding: 0.22rem 0.42rem;
    font-size: 0.6rem;
  }

  /* —— Diagram on top, slim sidebar tray underneath.
        The diagram takes whatever the tray doesn't need — no page scroll. —— */
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    overflow: hidden;
  }

  .viewport-wrap {
    order: 1;
  }

  .sidebar {
    order: 2;
    max-height: 30vh;
    border-right: none;
    border-top: 1px solid rgba(224, 201, 165, 0.18);
    padding: 0.5rem 0.6rem 0.65rem;
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 0.4rem 0.45rem;
    align-content: start;
  }

  .sidebar h2,
  .sidebar .hint,
  .sidebar .breadcrumb {
    display: none;
  }

  /* Filters jump to the top — they were buried at the bottom */
  .filter-wrap {
    order: 1;
    grid-column: 1 / -1;
    display: flex;
    gap: 0.35rem;
  }

  .filter-wrap .filter-row {
    margin: 0;
    flex: 1 1 auto;
    flex-wrap: nowrap;
  }

  .filter-chip {
    flex: 1 1 0;
    min-width: 0;
    font-size: 0.6rem;
    padding: 0.3rem 0.25rem;
    white-space: nowrap;
    box-shadow: 0 2px 0 #5c4033;
  }

  .spouse-toggle {
    order: 2;
    grid-column: 1 / -1;
    padding: 0.3rem 0.5rem;
    gap: 0.5rem;
  }

  .spouse-toggle-track {
    width: 34px;
    height: 20px;
  }

  .spouse-toggle-thumb {
    width: 14px;
    height: 14px;
  }

  .spouse-toggle.is-active .spouse-toggle-thumb {
    transform: translateX(14px);
  }

  .spouse-toggle-label strong {
    font-size: 0.7rem;
  }

  .spouse-toggle-label small {
    display: none;
  }

  /* "Whole Horoz family" duplicates the Horoz Family branch chip — drop it */
  .nav-home-btn {
    display: none;
  }

  /* The guest footer text is nice-to-have — the diagram needs the space */
  .footer-bar {
    display: none;
  }

  /* Search first in the tray — results float over the diagram so the
     keyboard / 30vh tray cannot bury them. */
  .explore-search-label {
    order: 0;
    grid-column: 1 / -1;
    margin: 0;
    font-size: 0;
  }

  .explore-search-form {
    order: 0;
    grid-column: 1 / -1;
    margin: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.3rem;
    align-items: center;
  }

  .explore-search-form .explore-search-label {
    order: unset;
    grid-column: unset;
    margin: 0;
  }

  .explore-search-submit {
    margin: 0;
    font-size: 0.62rem;
    padding: 0.42rem 0.55rem;
    white-space: nowrap;
  }

  .explore-search-label input {
    margin-top: 0;
    font-size: 0.78rem;
    padding: 0.42rem 0.5rem;
  }

  .explore-search-results:not([hidden]) {
    position: fixed;
    left: 0.55rem;
    right: 0.55rem;
    top: max(4.25rem, env(safe-area-inset-top, 0px) + 3.5rem);
    z-index: 60;
    order: unset;
    grid-column: unset;
    margin: 0;
    max-height: min(48vh, 18rem);
    padding: 0.45rem;
    border-radius: 12px;
    border: 1px solid rgba(201, 162, 39, 0.45);
    background: rgba(28, 18, 10, 0.96);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
    -webkit-overflow-scrolling: touch;
  }

  /* Branch chips: an even 3-column table so they all line up */
  .branch-list {
    order: 5;
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.3rem;
    margin: 0;
  }

  .branch-mode-row {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }

  .branch-mode-row .branch-mode {
    font-size: 0.6rem;
    padding: 0.3rem 0.25rem;
    box-shadow: 0 2px 0 #5c4033;
  }

  .branch-chip {
    width: 100%;
    min-width: 0;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    font-size: 0.6rem;
    padding: 0.3rem 0.25rem;
    gap: 0.25rem;
    box-shadow: 0 2px 0 #5c4033;
  }

  .branch-chip .swatch {
    flex: none;
    width: 9px;
    height: 9px;
  }

  /* The gold subject box duplicates what the diagram shows — drop it */
  .tree-subject-title {
    display: none;
  }

  /* —— Diagram control box: same compact sizing as the branch buttons,
        two buttons per row like the tray below the diagram —— */
  .view-menu {
    width: min(208px, calc(100% - 1.2rem));
    padding: 0.35rem;
    gap: 0.25rem;
    border-radius: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .view-menu-handle,
  .view-menu-label,
  .view-menu-section,
  .chart-design-options,
  .chart-only-tools,
  .line-style-tools {
    grid-column: 1 / -1;
  }

  .view-menu-section {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .view-menu-section .view-menu-label {
    grid-column: 1 / -1;
  }

  .view-menu-handle {
    font-size: 0.6rem;
    padding: 0.12rem 0.12rem 0.28rem;
  }

  .view-menu-collapse {
    width: 20px;
    height: 20px;
    font-size: 0.85rem;
    border-radius: 6px;
  }

  .view-menu .btn-3d.view-opt {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    justify-content: center;
    font-size: 0.6rem;
    padding: 0.3rem 0.25rem;
    border-radius: 7px;
    box-shadow: 0 2px 0 #5c4033;
  }

  .view-menu-label {
    font-size: 0.5rem;
    margin-top: 0.15rem;
  }

  .view-menu-section,
  .chart-design-options {
    gap: 0.25rem;
  }

  .chart-design-field {
    font-size: 0.6rem;
    gap: 0.3rem;
  }

  .chart-design-field select,
  .chart-design-field input {
    font-size: 0.62rem;
    min-width: 0;
    max-width: 108px;
  }
}
