:root{
  color-scheme: light;

  /* Nostalgic, soothing palette (paper + ink) */
  --bg: #f4efe6;
  --bg-2: #efe6d8;
  --ink: rgba(40, 32, 24, 0.92);
  --ink-2: rgba(40, 32, 24, 0.72);
  --line: rgba(40, 32, 24, 0.14);

  /* Layout sizing */
  --page-pad: 22px;
  --content-max: 1200px;

  /* Tree (SVG) */
  --tree-link: rgba(64, 52, 38, 0.42);
  --tree-union-dot: rgba(64, 52, 38, 0.25);
  --tree-card-bg: rgba(255,255,255,0.72);
  --tree-card-stroke: rgba(64, 52, 38, 0.16);
  --tree-photo-ph: rgba(64, 52, 38, 0.08);
  --tree-photo-ring: rgba(64, 52, 38, 0.18);
  --tree-text-strong: rgba(40, 32, 24, 0.92);
  --tree-text-soft: rgba(40, 32, 24, 0.70);
}

*{ box-sizing: border-box; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 800px at 20% 10%, var(--bg-2), var(--bg));
  color: var(--ink);
}

/* Top bar */
.topbar{
  position: sticky;
  top: 0;
  z-index: 10;

  /* visuals stay on the full-width sticky bar */
  padding: 8px var(--page-pad);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
  background: rgba(244, 239, 230, 0.86);
}

/* NEW: constrain header contents to match <main> width */
.topbar-inner{
  max-width: var(--content-max);
  margin: 0 auto;

  display: grid;
  grid-template-columns: 1fr auto 1fr; /* left / centered title / right */
  align-items: center;
  gap: 16px;
}

.brand .logo{
  font-weight: 800;
  letter-spacing: 0.2px;
  font-size: 18px;
  line-height: 1.1;
}

.brand .tag{
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--ink-2);
}

/* Center navbar callout (centered within topbar-inner) */
.nav-family{
  white-space: nowrap;

  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 12.5px;
  line-height: 1;

  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(40, 32, 24, 0.18);
  background: rgba(255,255,255,0.36);
  box-shadow: 0 8px 18px rgba(40, 32, 24, 0.06);
  backdrop-filter: blur(6px);

  /* changed for grid centering */
  justify-self: center;
  margin: 0;
}

/* Top-right brand mark */
.topbar-right{
  display:flex;
  align-items:center;
  justify-content:center;

  /* changed for grid */
  justify-self: end;
  margin-left: 0;
}

.nav-logo{
  display:block;
  width: 50px;
  height: 50px;
  filter: drop-shadow(0 4px 10px rgba(40, 32, 24, 0.16));
  opacity: 0.95;
}

/* Main content wrapper */
main{
  padding: 10px var(--page-pad) 22px;
  max-width: var(--content-max);
  margin: 0 auto;
}

/* Tree canvas */
#canvas{
  position: relative;
  margin-top: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    radial-gradient(900px 560px at 15% 10%, rgba(255,255,255,0.70), rgba(255,255,255,0.00)),
    radial-gradient(700px 520px at 80% 20%, rgba(176, 204, 196, 0.22), rgba(255,255,255,0.00)),
    linear-gradient(180deg, rgba(255,255,255,0.25), rgba(255,255,255,0.10));
  overflow:hidden;

  height: calc(100vh - 100px);
  min-height: 520px;

  box-shadow: 0 14px 40px rgba(40, 32, 24, 0.08);
}

#treeSvg{
  width:100%;
  height:100%;
  display:block;
}

/* Fit-to-screen button */
.fit-btn{
  position:absolute;
  top: 12px;
  right: 12px;
  z-index: 6;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.72);
  color: var(--ink);
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(40, 32, 24, 0.10);
  backdrop-filter: blur(6px);
}
.fit-btn:hover{ background: rgba(255,255,255,0.86); }
.fit-btn:active{ transform: translateY(1px); }

/* Footer */
.footer{
  margin-top: 18px;
  padding-top: 5px;
  border-top: 1px solid rgba(40, 32, 24, 0.10);
}

.foot-inner{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 12px;
  padding: 10px 0 6px; /* match header/content edges */
  color: var(--ink-2);
  font-size: 13px;
}

.foot-brand{
  font-weight: 800;
  color: var(--ink);
}

.foot-sub{
  margin-top: 2px;
}

/* Mobile + responsive tightening */
@media (max-width: 860px){
  :root{
    --page-pad: 16px;
    --content-max: 1100px;
  }

  /* Center label gets cramped on small screens — hide it */
  .nav-family{ display: none; }

  main{
    padding: 10px var(--page-pad) 12px;
  }

  /* Key: stop forcing a tall viewport; let content determine height */
  #canvas{
    height: auto;
    min-height: 440px; /* was 360px */
  }

  #treeSvg{
    height: auto;
  }
}

@media (max-width: 600px){
  :root{ --page-pad: 12px; }

  .topbar{
    padding: 12px var(--page-pad);
    gap: 10px;
  }

  main{
    padding: 8px var(--page-pad) 10px;
  }

  /* keep tight behavior (do NOT reintroduce fixed height) */
  #canvas{
    height: auto;
    min-height: 400px; /* was 320px */
  }
}

@media (max-width: 475px){
  :root{ --page-pad: 10px; }

  .topbar{
    padding: 10px var(--page-pad);
  }

  main{
    padding: 6px var(--page-pad) 8px;
  }

  #canvas{
    height: auto;
    min-height: 260px; /* was 300px */
    border-radius: 14px;
  }

  .fit-btn{
    top: 10px;
    right: 10px;
    padding: 8px 10px;
    font-size: 13px;
  }
}
