:root {
  --paper: #ffffff;
  --ink: #050505;
  --muted: #64605b;
  --line: #181512;
  --leaf: #596b41;
  --flower: #b94f58;
  --gold: #8e6f25;
  --node: #ffffff;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "Libre Baskerville", Georgia, serif;
}

button {
  font: inherit;
}

.floral-frame {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.floral-frame::before,
.floral-frame::after {
  position: absolute;
  width: min(14vw, 132px);
  min-width: 64px;
  aspect-ratio: 1;
  background-image: url("data:image/svg+xml,%3Csvg width='180' height='180' viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23596b41' stroke-width='5' stroke-linecap='round'%3E%3Cpath d='M27 148C58 109 93 84 152 55'/%3E%3Cpath d='M54 118c-18 0-31-8-39-24 21-2 36 5 44 20'/%3E%3Cpath d='M92 91c-8-18-4-34 13-48 9 21 6 36-8 48'/%3E%3Cpath d='M122 75c16-10 32-11 47-1-16 14-32 17-49 8'/%3E%3C/g%3E%3Cg fill='%23b94f58'%3E%3Ccircle cx='144' cy='49' r='11'/%3E%3Ccircle cx='159' cy='48' r='9'/%3E%3Ccircle cx='150' cy='36' r='9'/%3E%3Ccircle cx='134' cy='38' r='8'/%3E%3C/g%3E%3Cg fill='%23d99aa0'%3E%3Ccircle cx='38' cy='141' r='9'/%3E%3Ccircle cx='25' cy='137' r='7'/%3E%3Ccircle cx='32' cy='126' r='7'/%3E%3C/g%3E%3Ccircle cx='147' cy='45' r='4' fill='%239b792c'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  content: "";
  opacity: 0.56;
}

.floral-frame::before {
  top: 12px;
  left: 12px;
}

.floral-frame::after {
  right: 12px;
  bottom: 12px;
  transform: rotate(180deg);
}

.page-shell {
  position: relative;
  z-index: 1;
  width: calc(100% - 10px);
  margin: 0 auto;
  padding: 18px 0 36px;
}

.masthead {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 6px 0 34px;
  text-align: center;
}

.lettermark {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: clamp(76px, 8vw, 106px);
  height: clamp(76px, 8vw, 106px);
  margin: 0;
  border: 2px solid var(--ink);
  border-radius: 50%;
  color: var(--ink);
  font-family: "Pirata One", "Old English Text MT", Georgia, serif;
  font-size: clamp(4.2rem, 7.5vw, 6rem);
  line-height: 1;
}

.lettermark::before,
.lettermark::after {
  position: absolute;
  width: 42%;
  height: 2px;
  background: var(--ink);
  content: "";
}

.lettermark::before {
  left: -28%;
}

.lettermark::after {
  right: -28%;
}

h1 {
  margin: 0;
  font-size: clamp(1.1rem, 2.2vw, 1.75rem);
  letter-spacing: 0;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.plain-button {
  min-height: 30px;
  padding: 5px 11px;
  border: 1px solid rgba(5, 5, 5, 0.72);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
}

.plain-button.secondary {
  color: var(--muted);
}

.tree {
  display: grid;
  gap: 26px;
  width: 100%;
}

.see-all-link {
  display: block;
  margin: 24px auto 0;
  border: 0;
  border-bottom: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
}

.generation {
  display: grid;
  justify-items: center;
  width: 100%;
}

.focused-generation {
  padding-top: 2px;
}

.person-wrap {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 0;
}

.person-node,
.add-person {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 74px;
  max-width: 136px;
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid rgba(24, 21, 18, 0.78);
  border-radius: 4px;
  background: var(--node);
  color: var(--ink);
  cursor: default;
  white-space: nowrap;
}

.person-node.has-children {
  cursor: pointer;
}

.person-node.has-children:hover,
.person-node.has-children:focus-visible {
  outline: 2px solid rgba(24, 21, 18, 0.18);
  outline-offset: 2px;
}

.focus-node {
  min-width: 128px;
  padding-inline: 14px;
  font-weight: 700;
}

.root-node {
  min-width: 230px;
  min-height: 36px;
  border-width: 2px;
  font-size: 0.92rem;
}

.couple-names {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 7px;
  min-width: 0;
}

.couple-ampersand {
  color: var(--muted);
  font-size: 0.68em;
  font-weight: 400;
}

.person-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
  font-size: clamp(0.62rem, 0.85vw, 0.78rem);
  line-height: 1.1;
}

.focus-node .person-name,
.root-node .person-name {
  font-size: clamp(0.76rem, 1.1vw, 0.92rem);
}

.placeholder {
  color: var(--muted);
  font-style: italic;
}

.person-note {
  color: var(--gold);
  font-size: 0.48rem;
  font-weight: 700;
  text-transform: uppercase;
}

.child-badge {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 700;
}

.receded-sibling .person-node {
  min-width: 48px;
  max-width: 92px;
  min-height: 23px;
  padding: 3px 5px;
  opacity: 0.34;
  transform: scale(0.86);
  transform-origin: top center;
}

.receded-sibling .person-name,
.receded-sibling .child-badge {
  font-size: 0.54rem;
}

.active-sibling .person-node {
  border-width: 2px;
  box-shadow: 0 0 0 3px rgba(5, 5, 5, 0.05);
}

.connector {
  position: relative;
  width: 100%;
  height: 24px;
}

.connector::before {
  position: absolute;
  top: 0;
  left: 50%;
  width: 1px;
  height: 100%;
  background: var(--line);
  content: "";
}

.generation-row {
  position: relative;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  margin: 0;
  padding: 12px 2px 0;
  overflow-x: auto;
  overflow-y: visible;
  list-style: none;
  scrollbar-width: thin;
}

.generation-row::before {
  position: absolute;
  top: 0;
  left: max(8px, 3%);
  right: max(8px, 3%);
  height: 1px;
  background: var(--line);
  content: "";
}

.generation-row > li {
  position: relative;
  flex: 0 0 auto;
  min-width: 0;
}

.generation-row > li::before {
  position: absolute;
  top: -12px;
  left: 50%;
  width: 1px;
  height: 12px;
  background: var(--line);
  content: "";
}

.add-person {
  border-style: dashed;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 700;
}

.node-actions {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.mini-action {
  min-height: 20px;
  padding: 2px 6px;
  border: 1px dashed rgba(24, 21, 18, 0.52);
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.58rem;
  font-weight: 700;
}

.remove-action {
  border-color: rgba(126, 30, 30, 0.46);
  color: #7e1e1e;
}

.admin-shell {
  position: relative;
  z-index: 1;
  width: calc(100% - 10px);
  margin: 0 auto;
  padding: 18px 0 36px;
}

.admin-login,
.admin-actions {
  display: grid;
  justify-content: center;
  gap: 8px;
  margin: 0 auto 24px;
  text-align: center;
}

.login-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.login-row input {
  min-height: 30px;
  width: min(260px, 60vw);
  border: 1px solid rgba(5, 5, 5, 0.72);
  border-radius: 6px;
  padding: 5px 8px;
  font: inherit;
}

.admin-actions {
  grid-auto-flow: column;
  align-items: center;
}

.admin-link {
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 700;
}

.admin-status {
  min-height: 1.2em;
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.all-mode {
  gap: 14px;
}

.all-mode .connector {
  height: 14px;
}

.all-mode .generation-row {
  padding-top: 8px;
  gap: 4px;
}

.all-mode .generation-row > li::before {
  top: -8px;
  height: 8px;
}

.all-mode .person-node,
.all-mode .add-person {
  min-width: 50px;
  max-width: 96px;
  min-height: 22px;
  padding: 3px 5px;
}

.all-mode .root-node {
  min-width: 170px;
}

.all-mode .person-name {
  font-size: 0.52rem;
}

.all-mode .focus-node .person-name,
.all-mode .root-node .person-name {
  font-size: 0.62rem;
}

.all-mode .child-badge,
.all-mode .person-note {
  font-size: 0.46rem;
}

.edit-mode .person-name {
  outline: none;
  border-bottom: 1px dashed rgba(5, 5, 5, 0.38);
}

.edit-mode .person-name:focus {
  border-bottom-style: solid;
}

@media (max-width: 860px) {
  .page-shell {
    width: calc(100% - 6px);
  }

  .masthead {
    padding-bottom: 28px;
  }

  .tree {
    gap: 22px;
  }

  .person-node,
  .add-person {
    min-width: 66px;
    max-width: 118px;
    min-height: 27px;
    padding: 4px 6px;
  }

  .root-node {
    min-width: 190px;
  }

  .generation-row {
    justify-content: flex-start;
    gap: 4px;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .page-shell {
    width: calc(100% - 4px);
    padding-top: 8px;
  }

  .masthead {
    gap: 5px;
    padding-bottom: 22px;
  }

  .lettermark {
    width: 58px;
    height: 58px;
    font-size: 3.3rem;
  }

  h1 {
    font-size: 1rem;
  }

  .tree {
    gap: 18px;
  }

  .connector {
    height: 18px;
  }

  .generation-row {
    padding-top: 10px;
  }

  .generation-row > li::before {
    top: -10px;
    height: 10px;
  }

  .person-node,
  .add-person {
    min-width: 58px;
    max-width: 100px;
    min-height: 23px;
    padding: 3px 5px;
  }

  .person-name {
    font-size: 0.55rem;
  }

  .focus-node .person-name,
  .root-node .person-name {
    font-size: 0.68rem;
  }

  .child-badge {
    font-size: 0.48rem;
  }

  .receded-sibling .person-node {
    min-width: 42px;
    max-width: 76px;
  }

  .floral-frame::before,
  .floral-frame::after {
    opacity: 0.3;
  }
}
