:root {
  --ink: #392d1d;
  --ink-soft: #65533a;
  --paper: #ead6a9;
  --paper-light: #f4e4bd;
  --gold: #b88935;
  --gold-light: #dfb85d;
  --olive: #62633e;
  --olive-dark: #42432c;
  --sidebar: #24251d;
  --sidebar-2: #1e211b;
  --line: rgba(81, 62, 31, 0.38);
  --shadow: 0 12px 30px rgba(45, 34, 18, 0.26);
  --font-display: Georgia, 'Times New Roman', serif;
  --font-body: 'Palatino Linotype', Palatino, Georgia, serif;
  color: var(--ink);
  font-family: var(--font-body);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--sidebar);
  color: var(--ink);
}

button,
input {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
}

button:not(:disabled) {
  cursor: pointer;
}

svg {
  width: 1.25em;
  height: 1.25em;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.65;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.button {
  min-height: 38px;
  padding: 0 22px;
  border: 1px solid rgba(91, 65, 25, 0.35);
  border-radius: 9px;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-gold {
  color: #453019;
  background: linear-gradient(180deg, #e4bd63, #c6973f);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.35), 0 4px 12px rgba(0, 0, 0, 0.18);
}

.button-ghost {
  background: rgba(255, 250, 229, 0.4);
}

.icon-button {
  display: grid;
  place-items: center;
  padding: 0;
  background: transparent;
}

.eyebrow {
  margin: 0 0 8px;
  color: #836a3c;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.auth-view {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  isolation: isolate;
  background:
    linear-gradient(90deg, rgba(29, 30, 23, 0.96) 0 34%, rgba(42, 42, 29, 0.62) 58%, rgba(33, 34, 25, 0.86)),
    url('/assets/images/parchment.png') center / 650px repeat;
}

.auth-view::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: '';
  background: radial-gradient(circle at 65% 48%, transparent 20%, rgba(18, 19, 14, 0.5) 85%);
}

.auth-art {
  position: absolute;
  inset: 2% 1% 0 35%;
  z-index: -1;
  display: grid;
  place-items: end center;
  overflow: hidden;
  opacity: 0.5;
}

.auth-art img {
  width: min(95vw, 1050px);
  max-height: 96vh;
  object-fit: contain;
  filter: sepia(0.25) contrast(1.08);
  mix-blend-mode: multiply;
}

.auth-card {
  width: min(440px, calc(100vw - 32px));
  margin-left: clamp(-38vw, -31vw, -240px);
  padding: 38px 42px 34px;
  border: 1px solid rgba(210, 179, 113, 0.45);
  border-radius: 22px;
  background:
    linear-gradient(rgba(239, 218, 169, 0.93), rgba(226, 198, 139, 0.94)),
    url('/assets/images/parchment.png') center / 560px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.5), inset 0 0 45px rgba(103, 68, 25, 0.11);
}

.auth-brand,
.sidebar-brand {
  display: flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.auth-brand {
  margin-bottom: 34px;
}

.auth-brand svg,
.sidebar-brand svg {
  fill: currentColor;
  stroke: none;
}

.auth-brand svg {
  width: 58px;
  height: 58px;
  margin-right: 12px;
  color: #8a652a;
}

.auth-brand span,
.sidebar-brand span {
  display: flex;
  flex-direction: column;
}

.auth-brand small,
.sidebar-brand small {
  font-size: 11px;
  letter-spacing: 0.03em;
}

.auth-brand strong,
.sidebar-brand strong {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 500;
  line-height: 0.95;
}

.auth-card h1 {
  max-width: 330px;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(34px, 5vw, 48px);
  font-weight: 500;
  line-height: 0.96;
}

.auth-intro {
  margin: 16px 0 24px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.auth-passkey {
  width: 100%;
  height: 47px;
  margin-bottom: 14px;
  font-weight: 600;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  color: #796443;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(95, 69, 32, 0.2);
}

.auth-recovery {
  font-size: 12px;
}

.auth-form,
.parchment-dialog form {
  display: grid;
  gap: 15px;
}

.auth-step {
  display: grid;
  gap: 15px;
}

.code-step {
  gap: 13px;
}

.code-sent {
  margin: 0 0 2px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.4;
}

.code-sent strong {
  color: #4f3b22;
  font-weight: 600;
}

.auth-form .code-input {
  height: 54px;
  padding-left: 20px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 0.28em;
}

.dev-code {
  margin: -2px 0 0;
  padding: 9px 12px;
  border: 1px dashed rgba(102, 75, 31, 0.42);
  border-radius: 8px;
  color: #61471f;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  text-align: center;
  background: rgba(255, 247, 211, 0.42);
}

.auth-form label,
.parchment-dialog label {
  display: grid;
  gap: 6px;
  color: #58452d;
  font-size: 13px;
}

.auth-form input,
.parchment-dialog input,
.parchment-dialog select {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border: 1px solid rgba(86, 63, 27, 0.38);
  border-radius: 9px;
  outline: none;
  background: rgba(255, 248, 222, 0.58);
  box-shadow: inset 0 2px 4px rgba(71, 50, 23, 0.08);
}

.parchment-dialog select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #6a5030 50%),
    linear-gradient(135deg, #6a5030 50%, transparent 50%);
  background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
}

.auth-form input:focus,
.parchment-dialog input:focus {
  border-color: #9c762f;
  box-shadow: 0 0 0 3px rgba(156, 118, 47, 0.15);
}

.auth-submit {
  height: 47px;
  margin-top: 1px;
  font-weight: 600;
}

.form-error {
  min-height: 1.1em;
  margin: -5px 0 0;
  color: #8d2f25;
  font-size: 12px;
}

.text-button {
  display: block;
  margin: 17px auto 0;
  padding: 4px;
  color: #624923;
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
}

.code-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
}

.code-actions .text-button {
  margin: 13px 0 0;
  font-size: 12px;
}

.text-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.auth-demo {
  margin: 20px 0 0;
  padding-top: 15px;
  border-top: 1px solid rgba(95, 69, 32, 0.2);
  color: #796443;
  font-size: 11px;
  text-align: center;
}

.app-shell {
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  background: var(--sidebar);
}

.sidebar {
  position: relative;
  z-index: 30;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 19px 12px 14px;
  overflow: hidden;
  color: #e7dbb9;
  background:
    radial-gradient(circle at 30% 20%, rgba(141, 127, 80, 0.09), transparent 44%),
    linear-gradient(115deg, var(--sidebar), var(--sidebar-2));
  box-shadow: 6px 0 24px rgba(32, 28, 19, 0.24);
}

.sidebar::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: '';
  opacity: 0.12;
  background-image: repeating-linear-gradient(115deg, transparent 0 2px, rgba(255, 255, 255, 0.025) 3px);
}

.sidebar-brand {
  height: 54px;
  padding: 0 8px;
  color: #ddc487;
}

.sidebar-brand svg {
  width: 47px;
  height: 47px;
  margin-right: 9px;
}

.sidebar-brand small {
  color: #cfc2a0;
  font-size: 9px;
}

.sidebar-brand strong {
  color: #f2e5c4;
  font-size: 23px;
}

.primary-nav {
  display: grid;
  flex: 1 1 auto;
  gap: 2px;
  min-height: 120px;
  margin-top: 14px;
  padding-right: 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.nav-item,
.tree-entry {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  min-height: 39px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #e9dec1;
  text-align: left;
  background: transparent;
}

.nav-item svg,
.tree-entry svg {
  width: 17px;
  height: 17px;
}

.nav-item span,
.tree-entry span {
  padding-left: 7px;
}

.nav-item.active,
.tree-entry.active {
  color: #e7c779;
  border-color: rgba(196, 165, 94, 0.24);
  background: rgba(159, 137, 78, 0.22);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.06);
}

.nav-item:hover,
.tree-entry:hover {
  background: rgba(233, 218, 174, 0.08);
}

.admin-health-view { padding: 36px; overflow: auto; }
.admin-health-header { display: flex; justify-content: space-between; gap: 24px; align-items: start; margin-bottom: 24px; }
.admin-health-header h1 { margin: 4px 0 8px; font: 400 clamp(2rem, 4vw, 3.4rem) Georgia, serif; }
.admin-health-header p { margin: 0; color: var(--muted, #76664d); }
.admin-health-summary { padding: 14px 18px; border: 1px solid rgba(139, 107, 51, .24); background: rgba(255, 251, 238, .66); }
.admin-health-checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.admin-health-card { border: 1px solid rgba(139, 107, 51, .22); border-left: 5px solid #68845e; background: rgba(255, 252, 241, .86); padding: 18px; }
.admin-health-card.status-warning { border-left-color: #b18232; }
.admin-health-card.status-critical, .admin-health-card.status-unknown { border-left-color: #9b473d; }
.admin-health-card h2 { display: flex; justify-content: space-between; gap: 12px; margin: 0 0 10px; font: 600 1rem/1.3 system-ui, sans-serif; text-transform: capitalize; }
.admin-health-card h2 span { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
.admin-health-card p { margin: 0; line-height: 1.5; }

.nav-item em {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: #f3d8ac;
  font-size: 11px;
  font-style: normal;
  background: #9d4e2d;
}

.tree-switcher {
  flex: 0 1 180px;
  min-height: 76px;
  margin-top: 20px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.sidebar-label {
  margin: 0 10px 7px;
  color: #97875e;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tree-list {
  display: grid;
  gap: 2px;
}

.tree-list-empty {
  margin: 7px 10px;
  color: #a89976;
  font-size: 11px;
  font-style: italic;
}

.tree-entry {
  min-height: 35px;
  font-size: 12px;
}

.add-tree-button {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  color: #d5c9aa;
  text-align: left;
  background: transparent;
}

.add-tree-button svg {
  width: 15px;
  height: 15px;
}

.add-tree-button span {
  padding-left: 7px;
}

.premium-card {
  margin-top: auto;
  padding: 14px 17px 16px;
  border: 1px solid rgba(198, 165, 90, 0.22);
  border-radius: 14px;
  background: linear-gradient(140deg, rgba(70, 66, 47, 0.7), rgba(37, 39, 30, 0.55));
}

.premium-card h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #e3c16a;
  font-size: 13px;
}

.premium-card h2 svg {
  width: 20px;
  height: 20px;
}

.premium-card p {
  margin: 9px 0 12px;
  color: #d6cbb0;
  font-size: 11px;
  line-height: 1.4;
}

.premium-card .button {
  width: 100%;
  min-height: 31px;
  font-size: 11px;
}

.user-card {
  display: grid;
  grid-template-columns: 36px 1fr 26px;
  align-items: center;
  gap: 7px;
  min-height: 60px;
  padding: 11px 2px 2px;
}

.user-card > button:not(.icon-button) {
  padding: 0;
  color: #e8ddc0;
  text-align: left;
  background: transparent;
}

.user-card strong,
.user-card small {
  display: block;
}

.user-card strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-card small {
  margin-top: 3px;
  color: #bbaa83;
  font-size: 9px;
}

.user-card .icon-button {
  color: #bcae88;
}

.mini-portrait,
.profile-portrait,
.connection-portrait,
.person-portrait {
  display: block;
  overflow: hidden;
  border-radius: 50%;
  background-image: url('/assets/images/portrait-sprite.png');
  background-repeat: no-repeat;
  background-size: 400% 400%;
}

.mini-portrait {
  width: 36px;
  height: 36px;
  border: 2px solid #9d8550;
}

.portrait-0 { background-position: 0 0; }
.portrait-1 { background-position: 33.333% 0; }
.portrait-2 { background-position: 66.666% 0; }
.portrait-3 { background-position: 100% 0; }
.portrait-4 { background-position: 0 33.333%; }
.portrait-5 { background-position: 33.333% 33.333%; }
.portrait-6 { background-position: 66.666% 33.333%; }
.portrait-7 { background-position: 100% 33.333%; }
.portrait-8 { background-position: 0 66.666%; }
.portrait-9 { background-position: 33.333% 66.666%; }
.portrait-10 { background-position: 66.666% 66.666%; }
.portrait-11 { background-position: 100% 66.666%; }
.portrait-12 { background-position: 0 100%; }
.portrait-13 { background-position: 33.333% 100%; }
.portrait-14 { background-position: 66.666% 100%; }
.portrait-15 { background-position: 100% 100%; }

.main-stage {
  min-width: 0;
  min-height: 0;
  background: #dbc495;
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 15px;
  height: 75px;
  padding: 0 21px 0 26px;
  border-bottom: 1px solid rgba(90, 64, 27, 0.15);
  background:
    linear-gradient(rgba(239, 218, 169, 0.76), rgba(237, 211, 159, 0.78)),
    url('/assets/images/parchment.png') center / 620px repeat;
  box-shadow: 0 4px 14px rgba(91, 68, 31, 0.11);
}

.search-box {
  position: relative;
  width: min(360px, 31vw);
  flex: 0 1 360px;
}

.search-box input {
  width: 100%;
  height: 41px;
  padding: 0 42px 0 15px;
  border: 1px solid rgba(77, 57, 26, 0.38);
  border-radius: 11px;
  outline: none;
  background: rgba(246, 227, 184, 0.38);
  box-shadow: inset 0 1px 2px rgba(66, 49, 22, 0.05);
}

.search-box input::placeholder {
  color: rgba(66, 48, 25, 0.75);
}

.search-box svg {
  position: absolute;
  top: 11px;
  right: 14px;
  width: 18px;
  height: 18px;
}

.toolbar-button,
.round-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 41px;
  padding: 0 15px;
  border: 1px solid rgba(77, 57, 26, 0.34);
  border-radius: 10px;
  background: rgba(247, 229, 187, 0.3);
}

.toolbar-button svg {
  width: 18px;
  height: 18px;
}

.toolbar-button .chevron {
  width: 14px;
  height: 14px;
  transition: transform 160ms ease;
}

.filter-control {
  position: relative;
  flex: 0 0 auto;
}

.filter-button[aria-expanded='true'] {
  border-color: rgba(77, 57, 26, 0.64);
  background: rgba(247, 229, 187, 0.7);
}

.filter-button[aria-expanded='true'] .chevron {
  transform: rotate(180deg);
}

.filter-menu {
  position: absolute;
  top: calc(100% + 9px);
  left: 0;
  z-index: 50;
  display: grid;
  width: 184px;
  padding: 9px;
  border: 1px solid rgba(85, 61, 28, 0.42);
  border-radius: 12px;
  background:
    linear-gradient(rgba(241, 222, 181, 0.97), rgba(229, 204, 157, 0.98)),
    url('/assets/images/parchment.png') center / 430px;
  box-shadow: 0 12px 26px rgba(55, 38, 18, 0.25), inset 0 0 0 3px rgba(255, 241, 208, 0.25);
}

.filter-menu[hidden] {
  display: none;
}

.filter-menu p {
  margin: 1px 8px 6px;
  color: #745c39;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.filter-menu button {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  color: #46351f;
  text-align: left;
  background: transparent;
}

.filter-menu button:hover,
.filter-menu button.active {
  background: rgba(150, 113, 55, 0.16);
}

.filter-menu button.active::before {
  margin-right: 7px;
  content: '✓';
}

.generation-filter {
  display: flex;
  align-items: center;
  gap: 3px;
  margin: 0 auto;
  white-space: nowrap;
}

.generation-filter span {
  margin-right: 7px;
  font-size: 14px;
  font-weight: 600;
}

.generation-filter button {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0 9px;
  border-radius: 17px;
  background: transparent;
}

.generation-filter button.active {
  border: 1px solid rgba(94, 69, 31, 0.3);
  background: rgba(169, 127, 53, 0.23);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.25);
}

.topbar-actions {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.round-button {
  width: 41px;
  padding: 0;
  border-radius: 50%;
}

.round-button svg {
  width: 17px;
  height: 17px;
}

.mobile-menu {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.tree-viewport {
  position: relative;
  height: calc(100vh - 75px);
  overflow: hidden;
  touch-action: none;
  background:
    linear-gradient(rgba(244, 239, 226, 0.26), rgba(239, 232, 216, 0.24)),
    url('/assets/images/parchment.png') center / 630px repeat;
  cursor: grab;
}

.tree-viewport.dragging {
  cursor: grabbing;
}

.tree-viewport::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  content: '';
  opacity: 0.32;
  background:
    radial-gradient(circle at 25% 25%, transparent 0 90px, rgba(116, 85, 35, 0.13) 91px 92px, transparent 93px),
    linear-gradient(120deg, transparent 62%, rgba(106, 75, 33, 0.07));
  mix-blend-mode: multiply;
}

.tree-world {
  --scene-top: 0px;
  position: absolute;
  top: 0;
  left: 0;
  width: 1100px;
  height: 780px;
  transform-origin: 0 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.tree-world img {
  -webkit-user-drag: none;
}

.heritage-tree {
  position: absolute;
  top: calc(var(--scene-top) + 46px);
  left: 58px;
  z-index: 1;
  width: 960px;
  height: 710px;
  object-fit: contain;
  opacity: 0.85;
  pointer-events: none;
  filter: sepia(0.05) saturate(0.92) contrast(0.93) brightness(1.01) drop-shadow(0 10px 8px rgba(69, 48, 19, 0.13));
  mix-blend-mode: multiply;
}

.family-banner {
  position: absolute;
  top: 0;
  left: 345px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 410px;
  height: 111px;
  padding: 18px 35px 23px;
  text-align: center;
  background: url('/assets/images/family-banner-parchment-v2.png') center / 100% 100% no-repeat;
  filter: drop-shadow(0 2px 1px rgba(67, 46, 16, 0.24));
}

.family-banner > div {
  flex: 1 1 auto;
  min-width: 0;
}

.family-banner::before,
.family-banner::after {
  content: none;
}

.family-banner h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 31px;
  font-weight: 500;
  line-height: 1;
  text-wrap: balance;
  transform: translateY(-2px);
}

.family-banner p {
  margin: 4px 0 0;
  font-size: 12px;
  font-style: italic;
  line-height: 1.1;
  white-space: nowrap;
}

.family-banner.compact-title h1 {
  font-size: 26px;
  line-height: 0.94;
}

.family-banner.tiny-title h1 {
  font-size: 20px;
  line-height: 0.92;
}

.banner-flourish {
  margin: 25px 10px 0 0;
  color: #8f6b31;
  font-size: 18px;
}

.banner-flourish.mirrored {
  margin: 25px 0 0 10px;
  transform: scaleX(-1);
}

.branch-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.branch-line {
  fill: none;
  stroke: #65583a;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.9;
}

.branch-line.step {
  stroke-dasharray: 5 4;
}

.branch-line.adoptive { stroke-dasharray: 2 3; }
.branch-line.care { stroke-dasharray: 8 4 2 4; opacity: 0.72; }

.partnership-line {
  stroke: #65583a;
  stroke-width: 2;
}

.partnership-line.former { stroke-dasharray: 6 4; opacity: 0.66; }

.former-mark {
  fill: none;
  stroke: #65583a;
  stroke-width: 1.5;
  stroke-linecap: round;
  opacity: 0.82;
}

.branch-heart {
  fill: #f1dfb1;
  stroke: #74613d;
  stroke-width: 1.5;
  paint-order: stroke fill;
}

.person-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
}

.person-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 88px;
  height: 117px;
  padding: 9px 8px 7px;
  border: 0;
  border-radius: 47% 47% 43% 43% / 38% 38% 55% 55%;
  color: #382c1d;
  text-align: center;
  background:
    radial-gradient(circle at 50% 24%, rgba(244, 231, 198, 0.98), rgba(224, 205, 169, 0.96) 73%),
    url('/assets/images/parchment.png');
  box-shadow:
    0 0 0 2px rgba(246, 229, 186, 0.85),
    0 0 0 4px #7c7748,
    0 0 0 6px rgba(79, 74, 43, 0.28),
    0 6px 12px rgba(72, 48, 20, 0.28);
  transform: translate(-50%, -50%);
  transition: opacity 180ms ease;
}

.node-foliage {
  position: absolute;
  z-index: -1;
  bottom: -4px;
  width: 72px;
  height: 86px;
  background: url('/assets/images/person-leaf-sprig-v1.png') center / contain no-repeat;
  pointer-events: none;
}

.node-foliage.left {
  left: -43px;
  transform: scaleX(-1);
}

.node-foliage.right {
  right: -43px;
}

.person-node:hover,
.person-node:focus-visible {
  z-index: 8;
}

.person-node:focus-visible {
  outline: 2px solid rgba(142, 93, 24, 0.85);
  outline-offset: 8px;
}

.person-node.selected {
  width: 103px;
  height: 139px;
  padding-top: 10px;
  border-radius: 48% 48% 44% 44% / 38% 38% 58% 58%;
  background: radial-gradient(circle at 50% 23%, #f2e4bd, #d3b46e 85%);
  box-shadow:
    0 0 0 2px #f5e3af,
    0 0 0 5px #a8792d,
    0 0 0 8px rgba(117, 76, 17, 0.26),
    0 9px 18px rgba(69, 43, 14, 0.38);
}

.person-node.selected::after {
  position: absolute;
  bottom: -14px;
  right: 17px;
  z-index: -1;
  width: 70px;
  height: 25px;
  content: '';
  clip-path: polygon(0 0, 50% 100%, 100% 0, 74% 30%, 50% 80%, 26% 30%);
  background: #b58031;
}

.person-portrait {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border: 2px solid rgba(98, 78, 43, 0.75);
  box-shadow: inset 0 0 0 2px rgba(244, 229, 192, 0.65);
}

.selected .person-portrait {
  width: 61px;
  height: 61px;
  border-color: #7f571c;
}

.person-node strong {
  display: -webkit-box;
  max-width: 80px;
  min-height: 23px;
  margin-top: 5px;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.05;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.person-node small {
  display: block;
  margin-top: 3px;
  font-size: 8px;
  line-height: 1;
}

.selected strong {
  min-height: 27px;
  margin-top: 6px;
  font-size: 12px;
}

.selected small {
  font-size: 9px;
}

.person-node.youngest-generation {
  width: 72px;
  height: 106px;
  padding: 8px 6px 6px;
  border-radius: 48% 48% 44% 44% / 38% 38% 56% 56%;
}

.youngest-generation .person-portrait {
  width: 46px;
  height: 46px;
}

.youngest-generation strong {
  max-width: 64px;
  min-height: 21px;
  margin-top: 4px;
  font-size: 10px;
}

.youngest-generation small {
  margin-top: 2px;
  font-size: 7px;
}

.youngest-generation .node-foliage {
  bottom: -2px;
  width: 62px;
  height: 76px;
}

.youngest-generation .node-foliage.left {
  left: -37px;
}

.youngest-generation .node-foliage.right {
  right: -37px;
}

.person-node.youngest-generation.selected {
  width: 96px;
  height: 132px;
  padding-top: 9px;
}

.youngest-generation.selected .person-portrait {
  width: 58px;
  height: 58px;
}

.person-node.search-hidden {
  opacity: 0.18;
  filter: grayscale(0.8);
}

.person-node.filter-hidden {
  display: none;
}

.compass {
  position: absolute;
  top: 15px;
  left: 46px;
  z-index: 7;
  width: 68px;
  height: 78px;
  color: rgba(88, 66, 32, 0.62);
  pointer-events: none;
}

.compass svg {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 53px;
  height: 53px;
  stroke-width: 1;
}

.compass span {
  position: absolute;
  font-size: 11px;
}

.compass .north { top: 0; left: 30px; }
.compass .south { bottom: 1px; left: 30px; }
.compass .east { top: 31px; right: 0; }
.compass .west { top: 31px; left: 0; }

.zoom-controls {
  position: absolute;
  top: 123px;
  left: 28px;
  z-index: 9;
  display: grid;
  width: 44px;
  overflow: hidden;
  border: 1px solid rgba(86, 62, 27, 0.35);
  border-radius: 11px;
  background: rgba(239, 218, 172, 0.78);
  box-shadow: 0 3px 8px rgba(67, 47, 20, 0.23), inset 0 1px rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(3px);
}

.zoom-controls button {
  display: grid;
  place-items: center;
  height: 44px;
  padding: 0;
  border-bottom: 1px solid rgba(91, 68, 32, 0.18);
  background: transparent;
}

.zoom-controls button:last-child { border-bottom: 0; }
.zoom-controls button:hover { background: rgba(255, 246, 217, 0.42); }
.zoom-controls svg { width: 19px; height: 19px; }

.pan-guide {
  position: absolute;
  top: 402px;
  left: 17px;
  z-index: 8;
  width: 75px;
  color: #5f4d31;
  font-size: 10px;
  line-height: 1.2;
  text-align: center;
  pointer-events: none;
}

.pan-guide .hand {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 5px;
  border: 2px solid #837748;
  border-radius: 50%;
  color: #e6d8af;
  background: #4d5133;
  box-shadow: 0 4px 8px rgba(50, 38, 19, 0.3), inset 0 0 0 3px rgba(238, 219, 166, 0.16);
}

.pan-guide .hand svg { width: 29px; height: 29px; }

.minimap {
  position: absolute;
  bottom: 185px;
  left: 22px;
  z-index: 9;
  width: 158px;
  height: 117px;
  overflow: hidden;
  border: 2px solid rgba(95, 67, 29, 0.55);
  border-radius: 10px 13px 9px 15px;
  background: rgba(225, 201, 151, 0.86);
  box-shadow: 0 6px 14px rgba(62, 43, 19, 0.2), inset 0 0 20px rgba(90, 60, 23, 0.12);
}

.tree-viewport.stories-collapsed .minimap {
  bottom: 14px;
}

.minimap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0.75;
  filter: sepia(0.3);
  mix-blend-mode: multiply;
}

.minimap span {
  position: absolute;
  top: 37px;
  left: 45px;
  width: 56px;
  height: 43px;
  border: 2px solid #a04e2e;
  background: rgba(237, 218, 171, 0.1);
}

.profile-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 13;
  display: flex;
  flex-direction: column;
  width: 320px;
  max-height: 765px;
  height: min(765px, calc(100% - 28px));
  padding: 24px 14px 14px;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid rgba(112, 85, 48, 0.46);
  border-radius: 18px;
  background:
    linear-gradient(rgba(239, 226, 204, 0.9), rgba(224, 201, 167, 0.92)),
    url('/assets/images/parchment.png') center / 460px;
  box-shadow: 0 11px 28px rgba(63, 44, 20, 0.25), inset 0 0 0 4px rgba(247, 234, 204, 0.3);
  cursor: default;
  scrollbar-color: rgba(103, 79, 43, 0.48) transparent;
  scrollbar-width: thin;
}

.tree-viewport:not(.stories-collapsed) .profile-panel {
  height: min(765px, calc(100% - 201px));
}

.profile-panel[hidden] {
  display: none;
}

.close-profile {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  background: transparent;
}

.close-profile svg { width: 16px; height: 16px; }

.profile-leaves {
  position: absolute;
  top: -27px;
  left: -22px;
  width: 92px;
  height: 92px;
  opacity: 0.9;
  background: url('/assets/images/person-leaf-sprig-v1.png') center / contain no-repeat;
  filter: sepia(0.18) saturate(0.72) brightness(0.76);
  transform: rotate(-23deg);
  pointer-events: none;
}

.profile-leaves::after {
  content: '';
  position: absolute;
  top: 24px;
  left: -3px;
  width: 70px;
  height: 70px;
  opacity: 0.72;
  background: inherit;
  transform: rotate(41deg) scaleX(-1);
}

.profile-portrait {
  width: 128px;
  height: 128px;
  flex: 0 0 128px;
  margin: 3px auto 10px;
  border: 6px solid rgba(234, 222, 194, 0.9);
  box-shadow: 0 0 0 2px #756c49, 0 5px 12px rgba(52, 37, 18, 0.25);
}

.profile-panel > h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 500;
  text-align: center;
}

.profile-panel > p {
  margin: 4px 0 0;
  color: #57462d;
  font-size: 14px;
  text-align: center;
}

.profile-tabs {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin: 19px -1px 10px;
  border: 1px solid rgba(97, 70, 31, 0.22);
  border-radius: 10px;
  overflow: hidden;
}

.profile-tabs button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  height: 57px;
  padding: 9px 0 5px;
  border-right: 1px solid rgba(97, 70, 31, 0.18);
  background: rgba(245, 226, 183, 0.28);
}

.profile-tabs button:last-child { border-right: 0; }
.profile-tabs button.active,
.profile-tabs button[aria-selected='true'] { background: rgba(255, 243, 212, 0.5); box-shadow: inset 0 -2px #7a7145; }
.profile-tabs button:focus-visible { position: relative; z-index: 1; outline: 3px solid rgba(83, 91, 51, .55); outline-offset: -3px; }
.profile-tabs button[aria-disabled="true"],
.profile-tabs button:disabled { cursor: default; opacity: 0.5; }
.profile-tabs svg { width: 18px; height: 18px; }
.profile-tabs span { font-size: 13px; }

.profile-tab-panel {
  flex: 1 0 auto;
  min-height: 0;
}

.profile-tab-panel[hidden] { display: none; }
.profile-overview-panel { display: flex; flex-direction: column; }

.profile-story-panel { padding: 1px 3px 3px; }

.person-stories-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 3px 2px 11px;
}

.person-stories-heading h3,
.person-story-linker h3 {
  margin: 0;
  color: #604929;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
}

.person-stories-heading p {
  margin: 2px 0 0;
  color: #755e3d;
  font-size: 10px;
}

.person-story-primary {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid rgba(106, 73, 29, 0.42);
  border-radius: 8px;
  color: #4f3a20;
  font-size: 11px;
  background: rgba(191, 145, 64, 0.32);
}

.person-story-list { display: grid; gap: 9px; }

.person-story-card {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 9px;
  padding: 8px;
  border: 1px solid rgba(96, 68, 31, 0.25);
  border-radius: 11px;
  background: rgba(255, 240, 204, 0.28);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.24);
}

.person-story-thumb {
  display: block;
  height: 64px;
  border-radius: 7px;
  background-image: url('/assets/images/memory-sprite.png');
  background-repeat: no-repeat;
  background-size: 600% auto;
  box-shadow: inset 0 0 0 1px rgba(67, 47, 23, 0.28);
}

.person-story-thumb.memory-0 { background-position: 0 48%; }
.person-story-thumb.memory-1 { background-position: 20% 38%; }
.person-story-thumb.memory-2 { background-position: 40% 48%; }
.person-story-thumb.memory-3 { background-position: 60% 48%; }
.person-story-thumb.memory-4 { background-position: 80% 35%; }
.person-story-thumb.memory-5 { background-position: 100% 45%; }

.person-story-copy { min-width: 0; }
.person-story-copy h4 { margin: 1px 0 2px; overflow: hidden; font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.person-story-meta { margin: 0; overflow: hidden; color: #725a38; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.person-story-excerpt { display: -webkit-box; margin: 6px 0 0; overflow: hidden; color: #554128; font-family: var(--font-display); font-size: 11px; line-height: 1.25; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }

.person-story-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.person-story-action {
  min-width: 0;
  min-height: 27px;
  padding: 0 3px;
  border: 1px solid rgba(91, 64, 29, 0.25);
  border-radius: 6px;
  color: #594126;
  font-size: 9px;
  background: rgba(255, 246, 219, 0.3);
}

.person-story-action:hover,
.person-story-primary:hover { background: rgba(255, 241, 201, 0.65); }
.person-story-action.danger { color: #7e3a2e; }

.person-stories-empty {
  display: grid;
  justify-items: center;
  padding: 18px 12px;
  border: 1px dashed rgba(100, 72, 34, 0.32);
  border-radius: 11px;
  color: #735a39;
  text-align: center;
  background: rgba(255, 241, 207, 0.18);
}

.person-stories-empty > span { color: #9a7a40; font-size: 28px; line-height: 1; }
.person-stories-empty strong { margin-top: 3px; color: #5c4528; font-size: 12px; }
.person-stories-empty p { margin: 5px 0 0; font-size: 10px; line-height: 1.4; }

.person-story-linker {
  margin-top: 12px;
  padding: 11px;
  border: 1px solid rgba(97, 70, 31, 0.2);
  border-radius: 11px;
  background: rgba(244, 226, 184, 0.23);
}

.person-story-linker h3 { font-size: 15px; }
.person-story-linker > p { margin: 6px 0 0; color: #715a3a; font-size: 10px; line-height: 1.4; }
.person-story-link-form { display: grid; grid-template-columns: minmax(0, 1fr) 52px; gap: 6px; margin-top: 8px; }
.person-story-link-form select {
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  border: 1px solid rgba(89, 63, 28, 0.34);
  border-radius: 7px;
  color: #4f3b22;
  font-size: 10px;
  background: rgba(255, 246, 220, 0.55);
}

.person-story-link-form button {
  border: 1px solid rgba(105, 73, 30, 0.38);
  border-radius: 7px;
  color: #4f3a21;
  font-size: 10px;
  background: rgba(190, 143, 61, 0.3);
}

.person-story-link-form button:disabled { opacity: 0.5; }
.person-story-error { margin: 0 2px 9px; color: #84382e; font-size: 10px; line-height: 1.35; }
.profile-story-panel[aria-busy="true"] { opacity: 0.72; }
.profile-tabs button.active { background: rgba(255, 243, 212, 0.5); }
.profile-tabs button:disabled { color: #75684f; opacity: 0.55; cursor: default; }
.profile-tabs button:focus-visible { position: relative; z-index: 1; outline-offset: -3px; }
.profile-tabs svg { width: 18px; height: 18px; }
.profile-tabs span { font-size: 13px; }

.person-profile-content {
  display: flex;
  min-height: 0;
  flex: 1 0 auto;
  flex-direction: column;
}

.person-profile-content[hidden],
.person-more-content[hidden] { display: none; }

.profile-facts {
  flex: 0 0 auto;
  display: grid;
  gap: 8px;
  margin: 3px 6px 12px;
}

.profile-facts > div {
  display: grid;
  grid-template-columns: 105px 1fr;
  gap: 4px;
  align-items: start;
  font-size: 14px;
}

.profile-facts dt {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #6c5737;
}

.profile-facts dt svg { width: 13px; height: 13px; }
.profile-facts dd { margin: 0; }

.connections {
  flex: 0 0 auto;
  min-height: 168px;
  margin-top: auto;
  padding: 10px 10px 8px;
  border: 1px solid rgba(97, 70, 31, 0.2);
  border-radius: 12px;
  background: rgba(244, 226, 184, 0.25);
}

.connections h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 500;
}

#connections-list {
  display: grid;
  gap: 6px;
}

.connection-row {
  display: grid;
  grid-template-columns: 25px 1fr;
  align-items: center;
  gap: 7px;
}

.connection-portrait {
  width: 25px;
  height: 25px;
  border: 1px solid #7f714d;
}

.connection-row strong,
.connection-row small {
  display: block;
  line-height: 1.1;
}

.connection-row strong { font-size: 14px; font-weight: 500; }
.connection-row small { color: #6c5b40; font-size: 13px; }

.view-profile-button {
  flex: 0 0 auto;
  min-height: 36px;
  margin-top: 12px;
  border: 1px solid rgba(94, 67, 29, 0.4);
  border-radius: 9px;
  background: rgba(178, 137, 66, 0.32);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.25);
  font-size: 13.5px;
}

.profile-media {
  min-height: 260px;
  flex: 1 0 auto;
  margin: 2px 0 0;
}

.profile-media[hidden] { display: none; }

.profile-media-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding: 4px 5px 10px;
  border-bottom: 1px solid rgba(97, 70, 31, .2);
}

.profile-media-header h3 { margin: 0; font: 500 19px/1.1 var(--font-display); }
.profile-media-header p { margin: 4px 0 0; color: #6d5839; font-size: 11px; line-height: 1.35; }
.profile-media-add { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 5px 9px; border: 1px solid rgba(100, 75, 35, .4); border-radius: 8px; background: rgba(177, 136, 63, .34); font-size: 12px; }
.profile-media-add svg { width: 12px; height: 12px; }
.profile-media-actions { padding: 8px 5px 3px; }
.profile-media-actions button { padding: 0; color: #5d6039; background: transparent; font-size: 11px; text-decoration: underline; text-underline-offset: 2px; }
.profile-media-actions button:disabled { color: #8b806b; cursor: default; text-decoration: none; }

.profile-media-status { min-height: 25px; padding: 5px; color: #6e5a3d; font-size: 10.5px; }
.profile-media-status[data-error='true'] { color: #813e31; }
.profile-media-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 1px 4px 8px; }

.profile-media-card {
  min-width: 0;
  overflow: hidden;
  padding: 0;
  border: 1px solid rgba(87, 64, 31, .28);
  border-radius: 9px;
  background: rgba(250, 236, 203, .36);
  box-shadow: 0 3px 8px rgba(68, 48, 24, .09);
  text-align: left;
}

.profile-media-card:hover { transform: translateY(-1px); box-shadow: 0 5px 12px rgba(68, 48, 24, .15); }
.profile-media-card:focus-visible { outline: 3px solid rgba(83, 91, 51, .55); outline-offset: 2px; }
.profile-media-preview { display: grid; aspect-ratio: 4 / 3; place-items: center; overflow: hidden; border-bottom: 1px solid rgba(87, 64, 31, .2); background: rgba(77, 69, 48, .11); }
.profile-media-preview img { width: 100%; height: 100%; object-fit: cover; }
.profile-media-preview .media-document-mark { width: 38px; height: 48px; font-size: 9px; }
.profile-media-card-copy { display: block; min-width: 0; padding: 7px 8px 8px; }
.profile-media-card-copy strong,
.profile-media-card-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-media-card-copy strong { font: 500 13px/1.2 var(--font-display); }
.profile-media-card-copy small { margin-top: 3px; color: #735f40; font-size: 9px; }

.profile-media-empty,
.profile-media-loading { grid-column: 1 / -1; display: grid; min-height: 190px; place-items: center; align-content: center; padding: 18px 12px; border: 1px dashed rgba(89, 68, 36, .27); border-radius: 10px; color: #715e41; text-align: center; }
.profile-media-empty svg { width: 32px; height: 32px; margin-bottom: 7px; color: #717748; }
.profile-media-empty h4 { margin: 0; font: 500 20px/1.1 var(--font-display); }
.profile-media-empty p { margin: 7px 0 12px; font-size: 11px; line-height: 1.35; }
.profile-media-empty button { min-height: 31px; padding: 5px 10px; font-size: 11px; }
.profile-media-loading { gap: 10px; font-size: 11px; }
.profile-media-loading::before { width: 23px; height: 23px; border: 3px solid rgba(84, 91, 52, .18); border-top-color: #62683f; border-radius: 50%; animation: media-spin .75s linear infinite; content: ''; }

.profile-media-detail { grid-column: 1 / -1; min-width: 0; }
.profile-media-back { padding: 2px 0 8px; color: #5f623b; background: transparent; font-size: 11px; }
.profile-media-detail-preview { display: grid; min-height: 150px; max-height: 250px; place-items: center; overflow: hidden; border: 1px solid rgba(80, 58, 28, .28); border-radius: 9px; background: rgba(69, 61, 43, .09); }
.profile-media-detail-preview img { width: 100%; max-height: 250px; object-fit: contain; }
.profile-media-detail h4 { overflow-wrap: anywhere; margin: 10px 0 0; font: 500 20px/1.1 var(--font-display); }
.profile-media-detail > p { margin: 6px 0 10px; color: #5f4d34; font-size: 11px; white-space: pre-wrap; }
.profile-media-detail-meta { margin: 0; padding: 8px 0; border-top: 1px solid rgba(80, 58, 28, .18); }
.profile-media-detail-meta div { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 6px; font-size: 10px; }
.profile-media-detail-meta dt { color: #755f3e; text-transform: uppercase; letter-spacing: .06em; }
.profile-media-detail-meta dd { overflow-wrap: anywhere; margin: 0; }
.profile-media-detail-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.profile-media-detail-actions .button { min-height: 31px; padding: 6px 9px; font-size: 10px; text-decoration: none; }
.profile-media-detail-actions .button-danger { margin-left: auto; }
.person-media-link-copy { margin: -3px 0 15px; color: #705b3b; font-size: 12px; }
.person-more-content {
  display: flex;
  min-height: 0;
  flex: 1 0 auto;
  flex-direction: column;
  padding: 2px 2px 0;
}

.person-more-content > header { padding: 2px 7px 10px; }
.person-more-content > header .eyebrow { margin: 0 0 2px; font-size: 9px; }

.person-more-content > header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
}

.person-more-content > header > p:last-child {
  margin: 3px 0 0;
  color: #6b583b;
  font-size: 11px;
  line-height: 1.35;
}

.person-more-actions {
  display: grid;
  gap: 6px;
}

.person-more-actions > button {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 49px;
  padding: 7px 10px;
  border: 1px solid rgba(94, 67, 29, 0.24);
  border-radius: 10px;
  color: #493820;
  text-align: left;
  background: rgba(255, 243, 210, 0.26);
}

.person-more-actions > button:hover { background: rgba(255, 243, 210, 0.52); }

.person-more-actions > button > svg {
  width: 20px;
  height: 20px;
  padding: 6px;
  box-sizing: content-box;
  border-radius: 50%;
  color: #765924;
  background: rgba(184, 142, 66, 0.18);
}

.person-more-actions > button span,
.person-more-actions > button strong,
.person-more-actions > button small { display: block; min-width: 0; }
.person-more-actions > button strong { font-size: 12px; font-weight: 600; }
.person-more-actions > button small { margin-top: 2px; color: #715d3f; font-size: 10px; }
.person-more-actions > button b { color: #826b43; font-size: 21px; font-weight: 400; }

.person-more-quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 8px;
}

.person-more-quick-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 32px;
  border: 1px solid rgba(94, 67, 29, 0.3);
  border-radius: 8px;
  color: #5b4628;
  font-size: 10px;
  background: rgba(178, 137, 66, 0.16);
}

.person-more-quick-actions svg { width: 12px; height: 12px; }

.person-more-danger {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 9px;
  border-top: 1px solid rgba(120, 58, 42, 0.19);
}

.person-more-danger > div { min-width: 0; flex: 1; }
.person-more-danger strong,
.person-more-danger small { display: block; }
.person-more-danger strong { color: #6f352d; font-size: 10px; }
.person-more-danger small { margin-top: 2px; color: #725f46; font-size: 9px; line-height: 1.25; }

.person-more-danger button {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid rgba(119, 53, 38, 0.4);
  border-radius: 7px;
  color: #78392d;
  font-size: 9px;
  background: rgba(255, 240, 210, 0.3);
}

.story-dock {
  position: absolute;
  right: 38px;
  bottom: 13px;
  left: 16px;
  z-index: 12;
  display: grid;
  grid-template-columns: 165px minmax(0, 1fr) 117px 34px;
  align-items: center;
  gap: 12px;
  height: 171px;
  padding: 11px 15px 10px 26px;
  border: 1px solid rgba(95, 66, 29, 0.48);
  border-radius: 21px;
  background:
    linear-gradient(rgba(239, 218, 171, 0.93), rgba(230, 204, 152, 0.96)),
    url('/assets/images/parchment.png') center / 580px;
  box-shadow: 0 12px 30px rgba(53, 37, 17, 0.34), inset 0 0 0 4px rgba(248, 231, 190, 0.28);
  cursor: default;
}

.story-restore:hover {
  background-color: rgba(255, 240, 201, 0.88);
}

.story-restore {
  position: absolute;
  bottom: 14px;
  left: 50%;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid rgba(95, 66, 29, 0.48);
  border-radius: 11px;
  color: #4e3b24;
  font-size: 12px;
  font-style: italic;
  background:
    linear-gradient(rgba(239, 218, 171, 0.96), rgba(230, 204, 152, 0.98)),
    url('/assets/images/parchment.png') center / 580px;
  box-shadow: 0 7px 18px rgba(53, 37, 17, 0.28), inset 0 0 0 3px rgba(248, 231, 190, 0.22);
  transform: translateX(-50%);
}

.story-restore svg {
  width: 16px;
  height: 16px;
}

.story-restore .restore-chevron {
  transform: rotate(180deg);
}

.story-restore.is-open {
  bottom: 135px;
  left: 42px;
  min-height: 34px;
  padding: 0 10px;
  transform: none;
}

.story-restore.is-open .restore-chevron {
  transform: none;
}

.tree-viewport:not(.stories-collapsed) .story-heading h2 {
  visibility: hidden;
}

.story-heading {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3px 0 20px;
}

.story-heading h2 {
  margin: 0;
  font-size: 13px;
  font-style: italic;
  font-weight: 500;
}

.story-heading button,
.story-next {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(91, 66, 31, 0.4);
  border-radius: 50%;
  background: rgba(247, 229, 189, 0.4);
}

.story-heading button { align-self: center; }
.story-heading svg,
.story-next svg { width: 16px; height: 16px; }

.story-list {
  display: grid;
  grid-auto-columns: minmax(112px, 1fr);
  grid-auto-flow: column;
  gap: 12px;
  min-width: 0;
  overflow: hidden;
}

.story-card {
  min-width: 0;
  height: 143px;
  overflow: hidden;
  border: 1px solid rgba(93, 66, 29, 0.35);
  border-radius: 8px;
  background: rgba(238, 218, 174, 0.56);
  box-shadow: 0 3px 7px rgba(69, 48, 21, 0.13);
}

.story-image {
  height: 99px;
  background-image: url('/assets/images/memory-sprite.png');
  background-repeat: no-repeat;
  background-size: 600% auto;
}

.story-image.memory-0 { background-position: 0 48%; }
.story-image.memory-1 { background-position: 20% 38%; }
.story-image.memory-2 { background-position: 40% 48%; }
.story-image.memory-3 { background-position: 60% 48%; }
.story-image.memory-4 { background-position: 80% 35%; }
.story-image.memory-5 { background-position: 100% 45%; }

.story-card strong,
.story-card small {
  display: block;
  overflow: hidden;
  padding: 0 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.story-card strong {
  margin-top: 6px;
  font-size: 9px;
  font-weight: 500;
}

.story-card small {
  margin-top: 2px;
  color: #6f5b3d;
  font-size: 8px;
}

.add-story {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  height: 143px;
  border: 1px dashed rgba(92, 64, 28, 0.55);
  border-radius: 9px;
  background: rgba(248, 230, 188, 0.16);
}

.add-story b { font-size: 32px; font-weight: 300; }
.add-story span { font-size: 9px; }

.story-next { justify-self: center; }

.toast-region {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  display: grid;
  gap: 8px;
}

.toast {
  max-width: 320px;
  padding: 11px 15px;
  border: 1px solid rgba(218, 184, 109, 0.55);
  border-radius: 10px;
  color: #f3e5c2;
  background: #303127;
  box-shadow: var(--shadow);
  animation: toast-in 180ms ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

.parchment-dialog {
  width: min(520px, calc(100vw - 30px));
  max-height: calc(100vh - 30px);
  overflow-y: auto;
  padding: 0;
  border: 1px solid rgba(92, 64, 28, 0.5);
  border-radius: 18px;
  color: var(--ink);
  background:
    linear-gradient(rgba(240, 218, 170, 0.96), rgba(228, 200, 145, 0.97)),
    url('/assets/images/parchment.png') center / 520px;
  box-shadow: 0 22px 70px rgba(32, 24, 13, 0.55), inset 0 0 0 4px rgba(247, 232, 194, 0.36);
}

.parchment-dialog::backdrop {
  background: rgba(25, 25, 20, 0.58);
  backdrop-filter: blur(3px);
}

.parchment-dialog form {
  position: relative;
  padding: 31px 34px 28px;
}

.parchment-dialog h2 {
  margin: -5px 0 9px;
  font-family: var(--font-display);
  font-size: 31px;
  font-weight: 500;
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  padding: 0;
  background: transparent;
}

.dialog-close svg { width: 17px; height: 17px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid .wide { grid-column: 1 / -1; }

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.dialog-action-spacer { flex: 1; }

.button-danger {
  border-color: rgba(119, 53, 38, 0.52);
  color: #78392d;
  background: rgba(255, 240, 210, 0.32);
}

.button-danger:hover { background: rgba(142, 62, 44, 0.12); }

.relationship-manager {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(90, 65, 30, 0.24);
  border-radius: 11px;
  background: rgba(255, 245, 211, 0.2);
}

.relationship-manager h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
}

#relationship-list { display: grid; gap: 7px; }

.relationship-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 126px auto;
  align-items: center;
  gap: 8px;
}

.relationship-row strong,
.relationship-row small { display: block; }
.relationship-row strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.relationship-row small { color: #715b3d; font-size: 10px; }
.relationship-row select { height: 34px; font-size: 11px; }

.relationship-remove {
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid rgba(119, 53, 38, 0.35);
  border-radius: 7px;
  color: #78392d;
  font-size: 10px;
  background: rgba(255, 244, 216, 0.32);
}

.relationship-empty { margin: 0; color: #715b3d; font-size: 11px; font-style: italic; }

@media (max-width: 1180px) {
  .topbar { gap: 9px; padding-right: 12px; padding-left: 14px; }
  .generation-filter span { display: none; }
  .share-button span { display: none; }
  .profile-panel { width: 300px; }
  .story-dock { right: 20px; grid-template-columns: 130px minmax(0, 1fr) 104px 30px; }
  .story-list { grid-auto-columns: minmax(105px, 1fr); }
}

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 230px;
    transform: translateX(-105%);
    transition: transform 220ms ease;
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: grid; }
  .generation-filter { display: none; }
  #topbar-account-button { display: none; }
  .search-box { width: auto; flex: 1; }
  .filter-button span { display: none; }
  .story-dock { grid-template-columns: 95px minmax(0, 1fr) 92px 30px; left: 10px; right: 10px; }
  .story-list { grid-auto-columns: minmax(112px, 1fr); }
  .profile-panel { right: 8px; }
}

@media (max-width: 700px) {
  .topbar { height: 64px; }
  .tree-viewport { height: calc(100vh - 64px); }
  .filter-button,
  .share-button { display: none; }
  .topbar-actions { margin-left: 0; }
  .search-box input { height: 42px; }
  .profile-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 72%;
    height: auto;
    overflow: auto;
    border-radius: 22px 22px 0 0;
  }
  .tree-viewport:not(.stories-collapsed) .profile-panel,
  .tree-viewport.stories-collapsed .profile-panel { height: auto; }
  .profile-leaves { display: none; }
  .person-more-content { padding-bottom: max(3px, env(safe-area-inset-bottom)); }
  .story-dock {
    right: 8px;
    bottom: 8px;
    left: 8px;
    grid-template-columns: 1fr 82px;
    height: 135px;
    padding: 9px;
    border-radius: 15px;
  }
  .story-heading,
  .story-next { display: none; }
  .story-list { grid-auto-columns: 104px; gap: 8px; }
  .story-card { height: 115px; }
  .story-image { height: 75px; }
  .add-story { height: 115px; }
  .minimap { display: none; }
  .story-restore.is-open { bottom: 101px; left: 22px; }
  .compass { transform: scale(0.85); transform-origin: top left; }
  .zoom-controls {
    top: auto;
    right: auto;
    bottom: 151px;
    left: 50%;
    grid-template-columns: repeat(4, 44px);
    width: 176px;
    transform: translateX(-50%);
  }
  .zoom-controls button {
    border-right: 1px solid rgba(91, 68, 32, 0.18);
    border-bottom: 0;
  }
  .zoom-controls button:last-child { border-right: 0; }
  .pan-guide { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .dialog-actions { flex-wrap: wrap; }
  .relationship-row { grid-template-columns: minmax(0, 1fr) 112px; }
  .relationship-remove { grid-column: 2; justify-self: end; }
  .auth-card { margin-left: 0; padding: 30px 25px; }
  .auth-art { inset: 10% -25% 0 5%; opacity: 0.22; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
