:root {
  --canvas: #f4f6f9;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-dim: #eef1f5;
  --ink: #16202e;
  --muted: #667085;
  --line: #e1e6ee;
  --line-strong: #b7c0cd;
  --accent: #3556d6;
  --accent-hover: #2a45b3;
  --accent-soft: #e8edfc;
  --accent-ink: #ffffff;
  --danger: #d1435b;
  --ok: #1f9d6a;
  --male: #4a7fe0;
  --female: #e0679a;
  --unknown: #9aa3b2;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 6px 20px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, 0.14);
  --nav-h: 56px;
  --appbar-h: 52px;
  --sab: env(safe-area-inset-bottom, 0px);
  --sat: env(safe-area-inset-top, 0px);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --canvas: #0f141c;
    --bg: #0f141c;
    --surface: #182030;
    --surface-dim: #212b3d;
    --ink: #eef2f8;
    --muted: #98a2b3;
    --line: #2a3446;
    --line-strong: #7c879a;
    --accent: #7c96ff;
    --accent-hover: #97acff;
    --accent-soft: #232c4a;
    --accent-ink: #0f141c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --canvas: #0f141c;
  --bg: #0f141c;
  --surface: #182030;
  --surface-dim: #212b3d;
  --ink: #eef2f8;
  --muted: #98a2b3;
  --line: #2a3446;
  --line-strong: #7c879a;
  --accent: #7c96ff;
  --accent-hover: #97acff;
  --accent-soft: #232c4a;
  --accent-ink: #0f141c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
}
body {
  margin: 0;
  min-height: 100%;
  background: var(--canvas);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-h) + var(--sab));
}
body.is-fullscreen {
  height: 100dvh;
  overflow: hidden;
  padding-bottom: 0;
}
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
img {
  max-width: 100%;
  display: block;
}
h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
}
p {
  margin: 0 0 0.6em;
}
svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
button {
  font: inherit;
  color: inherit;
}
[hidden] {
  display: none !important;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 0.87rem;
}
.center {
  text-align: center;
}
.inline {
  display: inline;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.main {
  min-height: calc(100dvh - var(--nav-h) - var(--sab));
}
.is-fullscreen .main {
  height: 100dvh;
  min-height: 0;
}

.appbar {
  display: none;
}
.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  height: calc(var(--nav-h) + var(--sab));
  padding-bottom: var(--sab);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 500;
  text-decoration: none;
}
.nav__item svg {
  width: 22px;
  height: 22px;
}
.nav__item svg {
  padding: 3px 12px;
  box-sizing: content-box;
  border-radius: 999px;
  transition: background 0.15s;
}
.nav__item.is-active {
  color: var(--accent);
}
.nav__item.is-active svg {
  background: var(--accent-soft);
}
.nav__item:hover {
  text-decoration: none;
  color: var(--ink);
}

@media (min-width: 900px) {
  body {
    padding-bottom: 0;
    padding-top: var(--appbar-h);
  }
  .nav {
    display: none;
  }
  .appbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 24px;
    height: var(--appbar-h);
    padding: 0 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
  }
  .appbar__brand {
    display: flex;
    align-items: baseline;
    gap: 10px;
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
  }
  .appbar__brand small {
    color: var(--muted);
    font-weight: 400;
  }
  .appbar__links {
    display: flex;
    gap: 4px;
    margin-left: auto;
  }
  .appbar__links a {
    padding: 6px 12px;
    color: var(--muted);
    border-radius: var(--radius);
    font-weight: 500;
  }
  .appbar__links a:hover {
    color: var(--ink);
    background: var(--surface-dim);
    text-decoration: none;
  }
  .appbar__links a.is-active {
    color: var(--accent);
    background: var(--accent-soft);
  }
  .appbar__links a {
    border-radius: 999px;
  }
  .main {
    min-height: calc(100dvh - var(--appbar-h));
  }
  .is-fullscreen .main {
    height: calc(100dvh - var(--appbar-h));
  }
}

.container {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}
.container--narrow {
  max-width: 640px;
}
@media (min-width: 900px) {
  .container {
    padding: 24px 32px 64px;
  }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: calc(6px + var(--sat)) 12px 6px;
  background: color-mix(in srgb, var(--canvas) 92%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
@media (min-width: 900px) {
  .topbar {
    top: var(--appbar-h);
    padding: 28px 32px 8px;
    max-width: 1104px;
    margin: 0 auto;
  }
  .topbar .back {
    margin-left: -8px;
  }
}
.topbar__title {
  flex: 1;
  font-size: 1.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (min-width: 900px) {
  .topbar__title {
    font-size: 1.45rem;
  }
}
.topbar__actions {
  display: flex;
  gap: 10px;
}
.back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  color: var(--ink);
}
.back svg {
  width: 20px;
  height: 20px;
}
.back:hover {
  background: var(--surface-dim);
  text-decoration: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 550;
  font-size: 0.93rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover {
  text-decoration: none;
  background: var(--surface-dim);
}
.btn:active {
  transform: translateY(1px);
}
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 30%, transparent);
}
.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn--ghost {
  background: transparent;
  border-color: transparent;
}
.btn--ghost:hover {
  background: var(--surface-dim);
}
.btn--danger {
  color: var(--danger);
}
.btn--sm {
  min-height: 30px;
  padding: 3px 10px;
  font-size: 0.85rem;
}
.btn--lg {
  min-height: 44px;
  font-size: 1rem;
  padding: 8px 20px;
}
.btn--block {
  width: 100%;
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.iconbtn {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.iconbtn svg {
  width: 20px;
  height: 20px;
}
.iconbtn:hover {
  background: var(--surface-dim);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.form--card {
  margin-top: 32px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.form--card h3 {
  font-size: 1.05rem;
}
.form--inline {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 560px) {
  .form-row {
    grid-template-columns: 1fr 1fr;
  }
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.field__label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}
.input {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.input:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input--lg {
  min-height: 46px;
  font-size: 1rem;
}
textarea.input {
  resize: vertical;
  min-height: 110px;
  line-height: 1.5;
}
select.input {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}
.has-error .input {
  border-color: var(--danger);
}
.field__error,
.form-error {
  color: var(--danger);
  font-size: 0.87rem;
  margin: 0;
}
.form-error {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
}
.date-field__row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 8px;
}
.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 8px 0;
}
.form-actions--row {
  align-items: center;
}
.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: var(--surface-dim);
}
.seg__item {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  font-weight: 550;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
  transition: background 0.15s, color 0.15s;
}
.seg__item input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.seg__item:has(input:checked),
.seg__item.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.seg--sm .seg__item {
  min-height: 30px;
  font-size: 0.8rem;
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  cursor: pointer;
}
.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  margin: 0;
}

.avatar {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--surface-dim);
  border: 2px solid var(--unknown);
  overflow: hidden;
  color: var(--muted);
  font-weight: 600;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar--m {
  border-color: var(--male);
}
.avatar--f {
  border-color: var(--female);
}
.avatar--dead img {
  filter: grayscale(0.7);
}
.avatar--sm {
  width: 40px;
  height: 40px;
  font-size: 0.8rem;
}
.avatar--md {
  width: 52px;
  height: 52px;
}
.avatar--lg {
  width: 84px;
  height: 84px;
  font-size: 1.4rem;
}
.avatar--xl {
  width: 128px;
  height: 128px;
  font-size: 2rem;
}

.prow {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  min-width: 0;
  flex: 1;
}
.prow:hover {
  background: var(--surface-dim);
  text-decoration: none;
}
.prow__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.prow__name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prow__meta {
  font-size: 0.82rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.relrow {
  display: flex;
  align-items: center;
  gap: 10px;
}
.letter {
  margin-top: 28px;
}
.letter__title {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0 12px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}
.searchbar {
  margin: 8px 0 14px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid transparent;
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 500;
}
.chip:hover {
  text-decoration: none;
  border-color: var(--muted);
}
.chip button {
  border: 0;
  background: transparent;
  padding: 0 0 0 2px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}
.chip button:hover {
  color: var(--danger);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chips:empty {
  display: none;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
@media (min-width: 900px) {
  .card {
    padding: 32px;
  }
}
.card__head {
  display: flex;
  gap: 20px;
  align-items: center;
}
.card__name {
  font-size: 1.35rem;
  line-height: 1.2;
}
.card__sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 24px 0 8px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.card__footer {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 28px;
}
.relgroup {
  margin-top: 28px;
}
.relgroup__title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
  padding: 0 4px;
}
.relgroup__list {
  margin: 0 -12px;
}
.relgroup__more {
  font-size: 0.8rem;
  text-transform: none;
  letter-spacing: 0;
}
.relgroup__list {
  display: flex;
  flex-direction: column;
}
.bio {
  padding: 0 4px;
}
.bio p {
  margin: 0 0 0.7em;
  line-height: 1.6;
}
.who {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 8px 0 28px;
}
.strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 0 12px;
  scroll-snap-type: x mandatory;
}
.strip__item {
  flex: 0 0 auto;
  width: 96px;
  height: 96px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  scroll-snap-align: start;
  background: var(--surface-dim);
}
.strip__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
@media (min-width: 560px) {
  .grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }
}
@media (min-width: 900px) {
  .grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
  }
}
.tile {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface-dim);
  display: block;
}
.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tile img {
  transition: transform 0.25s;
}
.tile:hover img {
  transform: scale(1.03);
}
.filters {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 14px;
  align-items: end;
  margin: 4px 0 24px;
}
@media (max-width: 559px) {
  .filters {
    grid-template-columns: 1fr 1fr;
  }
  .filters .btn {
    grid-column: 1 / -1;
  }
}
.more {
  margin-top: 16px;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(12, 12, 12, 0.97);
  color: #ececea;
  display: grid;
  grid-template-rows: 1fr auto;
  touch-action: none;
}
.lightbox__stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 12px;
  overflow: hidden;
}
.lightbox__stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform 0.1s;
}
.lightbox__close,
.lightbox__nav {
  position: absolute;
  top: calc(8px + var(--sat));
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 2;
}
.lightbox__close {
  right: 12px;
}
.lightbox__nav {
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.8rem;
  display: none;
}
.lightbox__nav--prev {
  left: 12px;
}
.lightbox__nav--next {
  right: 12px;
}
@media (min-width: 900px) {
  .lightbox__nav {
    display: block;
  }
}
.lightbox__info {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 20px calc(24px + var(--sab));
  max-height: 45dvh;
  overflow-y: auto;
}
.lightbox__caption {
  font-size: 1rem;
  margin: 0 0 2px;
}
.lightbox__date {
  color: rgba(236, 236, 234, 0.65);
  font-size: 0.85rem;
  margin: 0 0 6px;
}
.lightbox__people {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.lightbox__people a {
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 2px 8px;
  border-radius: var(--radius);
  font-size: 0.85rem;
}
.lightbox__actions {
  display: flex;
  gap: 8px;
}
.lightbox .btn--ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}
.lightbox .btn--ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}
.lightbox__form {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #ececea;
}
.lightbox__form .input {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}
.lightbox__form .field__label {
  color: rgba(236, 236, 234, 0.65);
}
.lightbox__form .chip {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.lightbox__form .chip button {
  color: rgba(255, 255, 255, 0.7);
}
.lightbox__form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.suggest {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  max-height: 200px;
  overflow-y: auto;
}
.suggest button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.suggest button:hover {
  background: var(--surface-dim);
}
.suggest small {
  color: var(--muted);
  margin-left: 6px;
}

.tree {
  position: relative;
  height: 100dvh;
  overflow: hidden;
  background: var(--canvas);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
@media (min-width: 900px) {
  .tree {
    height: calc(100dvh - var(--appbar-h));
  }
}
.tree__canvas,
.tree__canvas svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.tree__canvas svg {
  display: block;
  cursor: grab;
}
.tree__canvas svg.is-dragging {
  cursor: grabbing;
}
.tree__canvas .node.selected .card {
  stroke: var(--accent);
  stroke-width: 2;
}
.tree__canvas .node:hover .card {
  stroke: var(--accent);
  stroke-opacity: 0.6;
}
.tree__canvas .node.selected:hover .card {
  stroke: var(--accent);
}
.tree__empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.tree__top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--sat)) 16px 12px 16px;
  pointer-events: none;
}
.tree__top > * {
  pointer-events: auto;
}
.tree__family {
  font-weight: 650;
  font-size: 1rem;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
@media (min-width: 900px) {
  .tree__family {
    display: none;
  }
  .tree__top {
    justify-content: flex-end;
    padding: 16px;
  }
}
.tree__search {
  position: absolute;
  top: calc(8px + var(--sat));
  left: 12px;
  right: 12px;
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px;
}
@media (min-width: 900px) {
  .tree__search {
    top: 16px;
    left: auto;
    right: 16px;
    width: 380px;
  }
}
.tree__results {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  max-height: 50dvh;
  overflow-y: auto;
}
.tree__results:empty {
  display: none;
}
.tree__results button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.tree__results button:hover,
.tree__results button:focus {
  background: var(--surface-dim);
}
.tree__results small {
  color: var(--muted);
  margin-left: auto;
}
.tree__controls {
  position: absolute;
  right: 16px;
  bottom: calc(var(--nav-h) + var(--sab) + 16px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
@media (min-width: 900px) {
  .tree__controls {
    bottom: 24px;
    right: 24px;
  }
}
.fab {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1.25rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s, background 0.15s;
}
.fab:active {
  transform: scale(0.96);
}
.fab svg {
  width: 18px;
  height: 18px;
}
.fab:hover {
  background: var(--surface-dim);
  text-decoration: none;
}
.fab--desktop {
  display: none;
}
@media (min-width: 900px) {
  .fab--desktop {
    display: inline-flex;
  }
}
.fab--add {
  position: absolute;
  left: 16px;
  bottom: calc(var(--nav-h) + var(--sab) + 16px);
  width: 52px;
  height: 52px;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1.7rem;
  z-index: 5;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 40%, transparent);
}
@media (min-width: 900px) {
  .fab--add {
    bottom: 24px;
    left: 24px;
  }
}
.fab--add:hover {
  background: var(--accent-hover);
}
.tree__mode {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--sab) + 16px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 4;
}
@media (min-width: 900px) {
  .tree__mode {
    bottom: 24px;
  }
}
.mode {
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  margin: 0;
}
.mode__btn {
  border: 0;
  border-radius: 999px;
  background: transparent;
  padding: 7px 14px;
  font-weight: 550;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.mode__btn.is-active {
  background: var(--accent);
  color: var(--accent-ink);
}
.tree__focus {
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--surface);
  padding: 2px 10px;
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  height: 88dvh;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-lg);
  transform: translateY(calc(100% - 96px));
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex;
  flex-direction: column;
  touch-action: none;
}
.sheet[data-state='half'] {
  transform: translateY(45%);
}
.sheet[data-state='full'] {
  transform: translateY(0);
}
.sheet.is-dragging {
  transition: none;
}
.sheet__handle {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  padding: 10px 0 6px;
  cursor: grab;
}
.sheet__handle span {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
}
.sheet__close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 0;
  background: var(--surface-dim);
  cursor: pointer;
}
.sheet__body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 24px calc(32px + var(--sab));
  touch-action: pan-y;
}
.sheet__body .card {
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}
@media (min-width: 900px) {
  .sheet {
    left: auto;
    top: 0;
    bottom: 0;
    width: 400px;
    height: auto;
    border-radius: 0;
    border-left: 1px solid var(--line);
    box-shadow: none;
    transform: translateX(100%);
  }
  .sheet[data-state] {
    transform: translateX(0);
  }
  .sheet__handle {
    display: none;
  }
  .sheet {
    width: 420px;
  }
  .sheet__body {
    padding: 24px 28px 40px;
  }
  .sheet__close {
    top: 16px;
    right: 20px;
  }
  .sheet__body .card__head {
    padding-right: 44px;
  }
}

.login {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.page-login {
  padding: 0;
}
.login__card {
  width: 100%;
  max-width: 400px;
  padding: 40px 36px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
}
.login__logo {
  width: 52px;
  height: 52px;
  margin-bottom: 18px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login__logo svg {
  width: 28px;
  height: 28px;
}
.login__title {
  font-size: 1.3rem;
}
.login__hint {
  color: var(--muted);
  margin: 8px 0 24px;
}
.login__form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login__back {
  display: inline-block;
  margin-top: 16px;
  font-size: 0.9rem;
}

.menu {
  margin-top: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.menu__title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 16px 20px 8px;
}
.menu__item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 16px 20px;
  color: var(--ink);
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  text-align: left;
  font-weight: 500;
  cursor: pointer;
}
.menu__item small {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
}
.menu__item:hover {
  background: var(--surface-dim);
  text-decoration: none;
}
.notice {
  padding: 24px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.photo-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--ink);
}
.photo-cta .btn {
  flex: 0 0 auto;
}
.notice--danger {
  border-color: var(--danger);
}
.notice--ok {
  border-color: var(--ok);
  color: var(--ok);
}
.notice h2 {
  font-size: 1.1rem;
  margin-bottom: 8px;
}
.empty {
  text-align: center;
  padding: 56px 16px;
  color: var(--muted);
}
.empty .btn {
  margin-top: 8px;
}
.msg__title {
  font-size: 1.5rem;
  margin: 40px 0 8px;
}

.person-select__filter {
  margin-bottom: 6px;
}

.upload {
  gap: 20px;
}
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 20px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover {
  border-color: var(--accent);
}
.dropzone.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.dropzone__icon {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.dropzone__icon svg {
  width: 26px;
  height: 26px;
}
.dropzone__text {
  font-weight: 500;
}
.upload__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.upload__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.9rem;
}
.upload__item img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--surface-dim);
}
.upload__item span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload__item small {
  color: var(--muted);
}
.upload__item.is-done small {
  color: var(--ok);
}
.upload__item.is-error small {
  color: var(--danger);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

.latin-names {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px 4px;
  margin: 4px 0 0;
}
.latin-names .field__label {
  padding: 0 6px;
}
.latin-names p {
  margin: 0 0 10px;
}
