:root {
  --family-bg: #fffefa;
  --family-surface: #ffffff;
  --family-surface-soft: #f6f3ec;
  --family-green: #2f6b3f;
  --family-green-hover: #255832;
  --family-text: #172018;
  --family-text-secondary: #4e5b51;
  --family-text-muted: #7c857b;
  --family-border: #e8e1d6;
  --family-overlay: rgba(13, 17, 14, 0.9);
  --family-focus: #d9a441;
  --family-error: #9d352b;
  --family-font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --family-container: 1180px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --button-height: 42px;
  --tap-target: 44px;
  --family-header-control-size: 46px;
  --family-header-control-size-mobile: 50px;
  --avatar-sm: 34px;
  --avatar-md: 58px;
  --shadow-soft: 0 12px 32px rgba(40, 32, 18, 0.08);
  --breakpoint-mobile: 720px;
  --breakpoint-tablet: 1024px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  background: #ffffff;
  color: var(--family-text);
  font-family: var(--family-font);
  letter-spacing: 0;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--family-bg);
}

body.is-lightbox-open {
  overflow: hidden;
}

body.is-avatar-modal-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

:focus-visible {
  outline: 3px solid var(--family-focus);
  outline-offset: 3px;
}

.family-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-5);
  width: min(var(--family-container), calc(100% - 32px));
  min-height: 64px;
  margin: var(--space-4) auto 0;
  padding: 0 var(--space-4);
  border: 1px solid rgba(226, 217, 201, 0.75);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}

.family-brand,
.family-nav,
.family-topbar__actions {
  display: flex;
  align-items: center;
}

.family-brand {
  gap: var(--space-2);
  min-width: max-content;
  font-size: 15px;
  font-weight: 700;
}

.family-brand__logo {
  width: 38px;
  height: 42px;
  object-fit: contain;
  flex: 0 0 auto;
}

.family-nav {
  flex: 1;
  justify-content: center;
  gap: var(--space-2);
}

.family-nav a,
.family-mobile-menu__item {
  min-height: 34px;
  padding: 9px 13px;
  border-radius: 999px;
  color: var(--family-text-secondary);
  font-size: 14px;
  font-weight: 600;
}

.family-nav a:hover,
.family-mobile-menu__item:hover,
.family-nav a[aria-current="page"] {
  background: #e7efdf;
  color: var(--family-green);
}

.family-topbar__actions {
  gap: var(--space-2);
  margin-left: auto;
}

.family-search-link,
.icon-button,
.family-menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--family-header-control-size);
  height: var(--family-header-control-size);
  border: 1px solid var(--family-border);
  border-radius: 999px;
  background: var(--family-surface);
  color: var(--family-text);
  cursor: pointer;
}

.family-search-link span {
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-radius: 50%;
  position: relative;
}

.family-search-link span::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 2px;
  right: -6px;
  bottom: -3px;
  background: currentColor;
  transform: rotate(45deg);
  transform-origin: center;
}

.family-user-menu {
  position: relative;
}

.family-user-menu summary {
  list-style: none;
  cursor: pointer;
}

.family-user-menu summary::-webkit-details-marker {
  display: none;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--avatar-md);
  height: var(--avatar-md);
  border-radius: 50%;
  background: #dfe9d9;
  color: var(--family-green);
  font-weight: 800;
  object-fit: cover;
  overflow: hidden;
  white-space: nowrap;
}

.avatar--small {
  width: 38px;
  height: 38px;
  font-size: 12px;
  line-height: 1;
  text-transform: uppercase;
}

.family-user-menu__panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  padding: var(--space-3);
  border: 1px solid var(--family-border);
  border-radius: var(--radius-md);
  background: var(--family-surface);
  box-shadow: var(--shadow-soft);
}

.family-user-menu__panel p,
.family-user-menu__panel a,
.family-user-menu__panel button {
  display: block;
  width: 100%;
  margin: 0;
  padding: 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--family-text-secondary);
  text-align: left;
}

.family-user-menu__panel a:hover,
.family-user-menu__panel button:hover {
  background: var(--family-surface-soft);
}

.family-user-menu__identity {
  color: var(--family-text) !important;
  text-decoration: none;
}

.family-user-menu__identity strong {
  display: block;
  font-size: 15px;
}

.family-menu-button {
  display: none;
}

.family-menu-button span,
.family-menu-button::before,
.family-menu-button::after {
  content: "";
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.family-menu-button {
  flex-direction: column;
  gap: 4px;
}

.family-mobile-menu {
  position: sticky;
  top: 86px;
  z-index: 19;
  display: grid;
  gap: var(--space-2);
  width: min(var(--family-container), calc(100% - 32px));
  margin: var(--space-2) auto 0;
  padding: var(--space-3);
  border: 1px solid var(--family-border);
  border-radius: var(--radius-md);
  background: var(--family-surface);
  box-shadow: var(--shadow-soft);
}

.family-mobile-menu__identity {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 50px;
  padding: var(--space-2) var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--family-border);
  color: var(--family-text);
  font-weight: 700;
}

.family-mobile-menu__logout {
  margin: var(--space-2) 0 0;
  padding-top: var(--space-2);
  border-top: 1px solid var(--family-border);
}

.family-mobile-menu__logout button {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 9px 13px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--family-text-secondary);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.family-mobile-menu__logout button:hover {
  background: var(--family-surface-soft);
  color: var(--family-green);
}

.family-mobile-menu[hidden] {
  display: none;
}

.family-page {
  width: min(var(--family-container), calc(100% - 32px));
  margin: var(--space-5) auto var(--space-7);
}

.family-hero {
  position: relative;
  display: grid;
  width: 100%;
  min-width: 0;
  aspect-ratio: 16 / 8;
  min-height: 0;
  max-height: 560px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--family-surface-soft);
  box-shadow: var(--shadow-soft);
}

.family-hero__image,
.family-hero__fallback {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
  object-position: center top;
  transform: scale(1.03);
  transform-origin: 50% 28%;
}

.family-hero__fallback {
  background:
    linear-gradient(135deg, rgba(47, 107, 63, 0.32), rgba(217, 164, 65, 0.28)),
    var(--family-surface-soft);
}

.family-hero::after {
  content: "";
  grid-area: 1 / 1;
  background:
    radial-gradient(ellipse at 18% 82%, rgba(9, 14, 10, 0.68), rgba(9, 14, 10, 0.2) 38%, rgba(9, 14, 10, 0) 66%),
    linear-gradient(90deg, rgba(18, 28, 19, 0.78), rgba(18, 28, 19, 0.2) 42%, rgba(18, 28, 19, 0.04));
}

.family-hero__copy {
  position: relative;
  z-index: 1;
  grid-area: 1 / 1;
  align-self: end;
  max-width: 520px;
  padding: clamp(28px, 5vw, 56px) clamp(28px, 5vw, 56px) clamp(22px, 3.4vw, 40px);
  color: #fffaf0;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.72);
}

.family-hero h1,
.page-head h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.03;
  font-weight: 800;
}

.family-hero p,
.page-head p {
  margin: var(--space-3) 0 0;
  color: inherit;
  font-size: 17px;
  line-height: 1.55;
}

.family-hero p {
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.55);
}

.family-hero .button {
  text-shadow: none;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.26);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--button-height);
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
}

.button--primary {
  margin-top: var(--space-5);
  background: var(--family-green);
  color: #fffaf0;
}

.button--primary:hover {
  background: var(--family-green-hover);
}

.button--secondary {
  border-color: var(--family-border);
  background: var(--family-surface);
  color: var(--family-green);
}

.page-actions,
.form-actions,
.selection-toolbar,
.album-photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.page-actions .button,
.form-actions .button,
.selection-toolbar .button {
  margin-top: 0;
}

.selection-toolbar {
  padding: var(--space-3);
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: var(--family-surface-soft);
}

.selection-toolbar span {
  min-width: 96px;
  font-weight: 800;
}

.button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.meta-line {
  color: var(--family-text-muted) !important;
  font-size: 14px !important;
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.filter-tabs a {
  min-height: 38px;
  padding: 9px 14px;
  border: 1px solid var(--family-border);
  border-radius: 999px;
  background: var(--family-surface);
  color: var(--family-text-secondary);
  font-weight: 700;
}

.filter-tabs a[aria-current="page"] {
  border-color: var(--family-green);
  background: #e7efdf;
  color: var(--family-green);
}

.notice-link {
  max-width: 760px;
  margin: 0 0 var(--space-5);
  padding: var(--space-3) var(--space-4);
  border-left: 4px solid var(--family-green);
  border-radius: var(--radius-sm);
  background: #eef5e8;
  color: var(--family-text-secondary);
  font-weight: 700;
}

.notice-link a {
  color: var(--family-green);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.upload-notice {
  width: 100%;
  max-width: none;
}

.family-form,
.upload-form,
.select-photos-form {
  display: grid;
  gap: var(--space-4);
  max-width: 760px;
}

.upload-form {
  width: 100%;
  max-width: none;
}

.upload-form--wide {
  align-items: stretch;
}

.upload-form--wide > *,
.upload-form--wide .family-form--embedded {
  width: 100%;
  min-width: 0;
}

.family-form--embedded {
  max-width: none;
}

.album-add-filters {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  align-items: end;
  margin-bottom: var(--space-4);
}

.select-photos-form {
  max-width: none;
}

.family-form label,
.upload-form label,
.album-add-filters .check-row {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
  color: var(--family-text-secondary);
  font-weight: 700;
}

.album-add-filters .check-row {
  display: inline-flex;
  align-items: center;
  min-height: var(--button-height);
}

.family-form input,
.family-form textarea,
.family-form select,
.upload-form input,
.upload-form textarea,
.upload-form select {
  width: 100%;
  min-height: var(--button-height);
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: var(--family-surface);
  color: var(--family-text);
  padding: 10px 12px;
}

.album-add-filters .check-row input {
  width: auto;
  min-height: auto;
}

.album-add-filters .form-actions {
  grid-column: 1 / -1;
}

.family-form textarea,
.upload-form textarea {
  min-height: 110px;
  resize: vertical;
}

.upload-form > .form-help {
  max-width: none;
}

.segmented-field,
.cover-picker,
.album-date-fields {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-4);
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
}

.cover-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
}

.segmented-field legend,
.cover-picker legend,
.album-date-fields legend {
  color: var(--family-text-secondary);
  font-weight: 800;
}

.segmented-field label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.album-date-fields label {
  flex: 1 1 180px;
}

.album-date-fields .form-help {
  flex: 1 0 100%;
}

.cover-choice {
  position: relative;
  display: grid !important;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-2);
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: var(--family-surface);
  cursor: pointer;
}

.cover-choice:has(.cover-choice__radio:checked) {
  border-color: var(--family-green);
  box-shadow: 0 0 0 2px rgba(47, 107, 63, 0.16);
}

.cover-choice__radio {
  position: absolute;
  width: 1px !important;
  height: 1px;
  min-height: 0 !important;
  opacity: 0;
  pointer-events: none;
}

.cover-choice__preview {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--family-surface-soft);
}

.cover-choice__preview img,
.cover-choice__preview .media-fallback {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.cover-choice__badge {
  position: absolute;
  left: var(--space-2);
  bottom: var(--space-2);
  max-width: calc(100% - var(--space-4));
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(23, 32, 24, 0.82);
  color: #fffaf0;
  font-size: 12px;
  line-height: 1.2;
}

.cover-choice__meta {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: var(--space-2);
  align-items: center;
  color: var(--family-text-muted);
  font-size: 12px;
  font-weight: 700;
}

.cover-choice__meta span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cover-choice__control {
  width: 16px;
  height: 16px;
  border: 2px solid var(--family-border);
  border-radius: 50%;
  background: var(--family-surface);
}

.cover-choice:has(.cover-choice__radio:checked) .cover-choice__control {
  border-color: var(--family-green);
  box-shadow: inset 0 0 0 4px var(--family-surface);
  background: var(--family-green);
}

.danger-zone {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--family-border);
}

.album-photo-actions {
  margin-top: var(--space-4);
}

.album-photo-actions .button {
  max-width: 100%;
  min-height: 36px;
  overflow-wrap: anywhere;
}

.select-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: var(--space-3);
}

.select-photo {
  position: relative;
  display: grid;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-2);
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: var(--family-surface);
  cursor: pointer;
}

.select-photo img,
.select-photo .media-fallback {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  object-fit: cover;
}

.select-photo span {
  color: var(--family-text-muted);
  font-size: 13px;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 220px;
  width: 100%;
  padding: var(--space-5);
  border: 2px dashed var(--family-border);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 248, 0.72);
  cursor: pointer;
}

.drop-zone span {
  color: var(--family-text);
  font-size: 1.08rem;
  font-weight: 900;
}

.drop-zone input {
  max-width: 100%;
  border: 0;
  background: transparent;
}

.upload-summary {
  color: var(--family-text-secondary);
  font-weight: 800;
}

.upload-list,
.upload-history,
.upload-items {
  display: grid;
  gap: var(--space-3);
}

.upload-result-stack {
  display: grid;
  gap: var(--space-5);
}

.upload-result-stack > .notice-link {
  margin-bottom: 0;
}

.upload-result-stack > .upload-items {
  margin-top: 0;
}

.upload-error-block {
  display: grid;
  gap: var(--space-2);
  max-width: 100%;
  padding: var(--space-3);
  border: 1px solid #c86464;
  border-radius: var(--radius-sm);
  background: #fff1f1;
  color: #8f1f2b;
}

.upload-error-block[hidden] {
  display: none;
}

.upload-error-block ul,
.upload-error-block .errorlist {
  display: grid;
  gap: var(--space-1);
  margin: 0;
  padding-left: 1.2rem;
}

.upload-error-block strong,
.upload-item__error {
  color: #8f1f2b;
}

.upload-preview,
.upload-card,
.upload-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: center;
  min-width: 0;
  padding: var(--space-3);
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: var(--family-surface);
}

.upload-card,
.upload-item {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.upload-preview img {
  width: 72px;
  height: 54px;
  border-radius: 6px;
  object-fit: cover;
}

.upload-preview strong,
.upload-card strong,
.upload-item strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.upload-card span,
.upload-item span,
.upload-item p {
  color: var(--family-text-muted);
}

.upload-item .upload-item__error {
  color: #8f1f2b;
}

.rules-page {
  display: grid;
  gap: var(--space-6);
  max-width: 860px;
}

.rules-page section {
  display: grid;
  gap: var(--space-3);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--family-border);
}

.rules-page h2,
.rules-page p {
  margin: 0;
}

.rules-page ul {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding-left: 22px;
  color: var(--family-text-secondary);
}

.button:active,
.icon-button:active {
  transform: translateY(1px);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.family-section {
  margin-top: var(--space-7);
}

.section-title,
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.section-title h2,
.page-head h1 {
  color: var(--family-text);
}

.section-title h2 {
  margin: 0;
  font-size: 23px;
  line-height: 1.2;
}

.section-title a,
.breadcrumbs a {
  color: var(--family-green);
  font-weight: 700;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}

.photo-grid__item {
  position: relative;
  min-width: 0;
}

.photo-grid--all {
  --family-photo-card-min: 200px;
  --family-photo-card-max: 220px;
  grid-template-columns: repeat(auto-fill, minmax(var(--family-photo-card-min), var(--family-photo-card-max)));
  justify-content: space-between;
}

.photo-thumb {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--family-surface-soft);
  box-shadow: 0 1px 0 rgba(33, 38, 31, 0.06);
}

.photo-thumb img,
.media-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-thumb:hover img {
  transform: scale(1.025);
}

.photo-thumb img {
  transition: transform 180ms ease;
}

.photo-remove-form {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
}

.photo-remove-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 250, 240, 0.8);
  border-radius: 999px;
  background: rgba(34, 38, 30, 0.72);
  color: #fffaf0;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.photo-remove-button:hover,
.photo-remove-button:focus-visible {
  background: #8a2d24;
  outline: 2px solid #fffaf0;
  outline-offset: 2px;
}

.photos-toolbar {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: center;
  margin-bottom: var(--space-4);
}

.people-search,
.sort-control,
.photos-filter-panel label {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
  color: var(--family-text-secondary);
  font-size: 13px;
  font-weight: 800;
}

.sort-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.people-search__box {
  position: relative;
  min-width: 0;
}

.people-search input,
.sort-control select,
.photos-filter-panel input,
.photos-filter-panel select {
  width: 100%;
  min-height: var(--button-height);
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: var(--family-surface);
  color: var(--family-text);
  padding: 0 var(--space-3);
}

.people-search__results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 12;
  display: grid;
  gap: var(--space-1);
  max-height: 320px;
  overflow: auto;
  padding: var(--space-2);
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: var(--family-surface);
  box-shadow: var(--shadow-soft);
}

.people-search__result {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-2);
  align-items: center;
  min-height: 46px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--family-text);
  text-align: left;
  cursor: pointer;
}

.people-search__result:hover {
  background: var(--family-surface-soft);
}

.people-search__result strong,
.people-search__result small {
  display: block;
}

.people-search__result small {
  color: var(--family-text-muted);
}

.filter-chip-row,
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.filter-chip-row {
  min-height: 30px;
}

.active-filters {
  margin: 0 0 var(--space-4);
}

.filter-chip,
.filter-reset {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 30px;
  max-width: 100%;
  padding: 5px 10px;
  border: 1px solid var(--family-border);
  border-radius: 999px;
  background: var(--family-surface);
  color: var(--family-green);
  font-size: 13px;
  font-weight: 800;
}

.filter-chip button {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: #e7efdf;
  color: var(--family-green);
  cursor: pointer;
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.segmented-control label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 4px 10px;
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: var(--family-surface);
  color: var(--family-text-secondary);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.segmented-control--sort {
  align-items: center;
}

.segmented-control--sort label {
  min-height: var(--button-height);
  padding: 0 18px;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1.2;
}

.segmented-control--sort label:has(input:checked) {
  border-color: var(--family-green);
  background: var(--family-green);
  color: #fffaf0;
}

.segmented-control input {
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}

.segmented-control label:has(input:checked) {
  border-color: var(--family-green);
  background: #e7efdf;
  color: var(--family-green);
}

.people-mode {
  margin-top: var(--space-2);
  padding: 0;
  border: 0;
}

.segmented-field legend {
  margin-bottom: var(--space-2);
}

.filter-reset {
  background: transparent;
}

.photos-filter-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 10;
  width: min(720px, 100%);
  padding: var(--space-4);
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: var(--family-surface);
  box-shadow: var(--shadow-soft);
}

.photos-filter-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.photos-filter-panel__head h2 {
  margin: 0;
  color: var(--family-text);
  font-size: 20px;
  line-height: 1.2;
}

.icon-button.photos-filter-panel__close {
  width: 34px;
  height: 34px;
  border-color: #c8d8c0;
  background: #e7efdf;
  color: var(--family-green-hover);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.icon-button.photos-filter-panel__close span {
  color: var(--family-green-hover);
}

.icon-button.photos-filter-panel__close:hover,
.icon-button.photos-filter-panel__close:focus-visible {
  border-color: var(--family-green);
  background: #f3f8ef;
  color: var(--family-green-hover);
}

.icon-button.photos-filter-panel__close:hover span,
.icon-button.photos-filter-panel__close:focus-visible span {
  color: var(--family-green-hover);
}

.photos-filter-panel .people-search {
  margin-bottom: var(--space-4);
}

.photos-filter-panel__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

.photos-filter-panel__album,
.photos-filter-panel__checks {
  grid-column: 1 / -1;
}

.photos-filter-panel__checks {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
  align-items: center;
}

.check-control {
  display: inline-flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--button-height);
}

.check-control input {
  width: auto;
  min-height: 0;
}

.photos-filter-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  justify-content: flex-end;
  margin-top: var(--space-4);
}

.photos-filter-panel__actions .button {
  margin-top: 0;
  min-height: var(--button-height);
  padding-top: 0;
  padding-bottom: 0;
}

.photo-card {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
  color: var(--family-text);
}

.photo-card__media {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--family-surface-soft);
  box-shadow: 0 1px 0 rgba(33, 38, 31, 0.06);
}

.photo-card__media img,
.photo-card__media .media-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 180ms ease;
}

.photo-card:hover img {
  transform: scale(1.025);
}

.photo-card__meta {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 34px;
  color: var(--family-text-muted);
  font-size: 13px;
  font-weight: 700;
}

.album-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: var(--space-2);
  border-radius: 50%;
  background: var(--family-green);
}

.media-fallback {
  display: block;
  background:
    linear-gradient(135deg, rgba(47, 107, 63, 0.18), transparent),
    #e6dfd1;
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

.catalog-sections {
  display: grid;
  gap: var(--space-7);
}

.catalog-section {
  display: grid;
  gap: var(--space-4);
}

.album-grid--home {
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.album-card {
  overflow: hidden;
  border: 1px solid rgba(226, 217, 201, 0.82);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 248, 0.82);
  box-shadow: 0 10px 24px rgba(40, 32, 18, 0.06);
}

.album-card__cover {
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--family-surface-soft);
}

.album-card__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 180ms ease;
}

.album-card:hover .album-card__cover img {
  transform: scale(1.025);
}

.album-card__body,
.album-card__copy {
  padding: var(--space-4);
}

.album-card h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.album-card p {
  margin: var(--space-2) 0 0;
  color: var(--family-text-secondary);
  font-size: 13px;
  line-height: 1.45;
}

.album-card__description {
  color: var(--family-text-muted);
}

.album-card__owner {
  color: var(--family-text-muted) !important;
}

.system-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 24px;
  padding: 3px 9px;
  border: 1px solid #c9d8be;
  border-radius: 999px;
  background: #edf5e8;
  color: var(--family-green);
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.people-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--space-4);
}

.person-chip {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-4);
  border: 1px solid rgba(226, 217, 201, 0.82);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 248, 0.76);
  text-align: center;
}

.person-chip strong {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.person-chip span {
  color: var(--family-text-muted);
  font-size: 12px;
}

.page-head {
  display: grid;
  align-items: start;
  justify-content: start;
  margin-top: var(--space-6);
}

.page-head > div {
  min-width: 0;
  max-width: 760px;
}

.breadcrumbs {
  min-width: 0;
  color: var(--family-text-muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.page-head__description {
  max-width: 720px;
  color: var(--family-text-secondary);
}

.empty-state {
  padding: var(--space-6);
  border: 1px dashed var(--family-border);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 248, 0.62);
}

.empty-state--wide {
  padding: var(--space-7);
  text-align: center;
}

.empty-state h2 {
  margin: 0;
  font-size: 20px;
}

.empty-state p {
  margin: var(--space-2) auto 0;
  max-width: 520px;
  color: var(--family-text-secondary);
}

.family-pagination {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-6);
}

.family-pagination a,
.family-pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  border: 1px solid var(--family-border);
  border-radius: 999px;
  background: var(--family-surface);
  color: var(--family-text-secondary);
  font-weight: 700;
}

.family-pagination [aria-current="page"] {
  border-color: var(--family-green);
  background: var(--family-green);
  color: #fff;
}

.family-toast {
  margin-bottom: var(--space-4);
}

.family-toast p {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: #e7efdf;
  color: var(--family-green);
}

.lightbox[hidden] {
  display: none;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  padding: 24px;
}

.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: var(--family-overlay);
}

.lightbox__dialog {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) minmax(0, auto);
  gap: var(--space-4);
  width: min(1120px, 100%);
  height: calc(100vh - 48px);
  max-height: calc(100vh - 48px);
  margin: 0 auto;
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: #0f120f;
  color: #f7f3ea;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  overflow: hidden;
}

.lightbox__top,
.lightbox__tools,
.lightbox__stage {
  display: flex;
  align-items: center;
}

.lightbox__top {
  position: relative;
  z-index: 4;
  justify-content: space-between;
  gap: var(--space-3);
}

.lightbox__top p {
  margin: 0;
  color: #d8d2c6;
}

.lightbox__tools {
  gap: var(--space-2);
}

.lightbox__edit {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  color: #fffaf0;
  font-size: 13px;
  font-weight: 800;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fffaf0;
  font-size: 20px;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.15);
}

.lightbox__stage {
  position: relative;
  z-index: 1;
  align-items: stretch;
  min-height: 0;
  gap: var(--space-3);
  overflow: hidden;
}

.lightbox__figure {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: var(--space-3);
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  overflow: hidden;
}

.lightbox__image-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  min-width: 0;
  isolation: isolate;
}

.lightbox__image-wrap img {
  display: block;
  max-height: 100%;
  width: auto;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.lightbox__figure figcaption {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  color: #d8d2c6;
  font-size: 14px;
}

.lightbox__nav {
  align-self: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fffaf0;
  font-size: 28px;
  cursor: pointer;
}

.lightbox__nav:disabled {
  opacity: 0.35;
  cursor: default;
}

.lightbox__meta {
  position: relative;
  z-index: 2;
  min-height: 0;
  max-height: clamp(96px, 20vh, 180px);
  overflow: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: var(--space-3);
  background: #0f120f;
}

.lightbox__description {
  margin-bottom: var(--space-3);
  color: #f7f3ea;
  white-space: pre-wrap;
}

.lightbox__albums {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  color: #f7f3ea;
}

.lightbox__albums a {
  color: #f2d28a;
  overflow-wrap: anywhere;
}

.lightbox__albums-label {
  font-weight: 700;
}

.lightbox__albums-separator {
  color: #9f9688;
}

.lightbox__meta h2 {
  margin: 0 0 var(--space-2);
  font-size: 15px;
}

.family-photo-edit {
  display: grid;
  grid-template-columns: minmax(240px, 420px) minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}

.family-photo-edit__preview {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--family-surface-soft);
}

.family-photo-edit__preview img,
.family-photo-edit__preview .media-fallback {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.family-photo-edit__fields {
  display: grid;
  gap: var(--space-3);
}

.family-photo-edit__fields label {
  display: grid;
  gap: var(--space-2);
  color: var(--family-text-secondary);
  font-size: 13px;
  font-weight: 800;
}

.family-photo-edit__fields input,
.family-photo-edit__fields select,
.family-photo-edit__fields textarea {
  width: 100%;
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: var(--family-surface);
  color: var(--family-text);
  padding: 10px 12px;
}

.lightbox-people {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  min-width: 0;
}

.lightbox-person {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 5px 10px 5px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fffaf0;
  font-size: 13px;
}

.lightbox-person .avatar {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

.face-layer {
  position: absolute;
  z-index: 2;
  overflow: visible;
  pointer-events: none;
}

.face-box {
  position: absolute;
  padding: 0;
  border: 2px solid #f4d06f;
  border-radius: 8px;
  background: transparent;
  box-shadow: 0 0 0 1px rgba(15, 18, 15, 0.35), 0 8px 18px rgba(0, 0, 0, 0.24);
  pointer-events: auto;
}

.face-box span {
  position: absolute;
  left: 0;
  bottom: calc(100% + 4px);
  display: none;
  max-width: 180px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(15, 18, 15, 0.88);
  color: #fffaf0;
  font-size: 12px;
  white-space: nowrap;
}

.face-box span.face-box__label--below {
  top: calc(100% + 4px);
  bottom: auto;
}

.face-box span.face-box__label--right {
  right: 0;
  left: auto;
}

.face-box:hover span,
.face-box:focus-visible span,
.face-box.is-active span {
  display: block;
}

.tree-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.tree-picker label {
  display: grid;
  gap: var(--space-2);
  color: var(--family-text-secondary);
  font-size: 13px;
}

.tree-picker select {
  min-height: var(--button-height);
  min-width: 220px;
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: var(--family-surface);
  color: var(--family-text);
}

.family-tree-shell {
  overflow: hidden;
  border: 1px solid var(--family-border);
  border-radius: var(--radius-lg);
  background: rgba(255, 253, 248, 0.72);
  box-shadow: var(--shadow-soft);
}

.tree-toolbar {
  position: relative;
  z-index: 85;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  border-bottom: 1px solid var(--family-border);
  overflow-x: auto;
  overflow-y: visible;
}

.tree-toolbar-more {
  display: none;
}

.tree-toolbar .button {
  margin-top: 0;
  min-height: 34px;
  padding-inline: 12px;
  white-space: nowrap;
}

.tree-mode-toggle,
.tree-pins {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.58);
  color: var(--family-text-secondary);
  font-size: 12px;
  font-weight: 700;
}

.tree-search {
  position: relative;
  flex: 0 0 min(260px, 34vw);
}

.tree-search input {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  background: var(--family-surface);
  color: var(--family-text);
}

.tree-search-results {
  position: absolute;
  z-index: 70;
  top: calc(100% + 6px);
  left: 0;
  width: min(360px, calc(100vw - 24px));
  max-height: 320px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: var(--family-surface);
  box-shadow: var(--shadow-soft);
}

.tree-search-results[hidden],
.tree-settings[hidden],
.tree-route-panel[hidden] {
  display: none;
}

.tree-search-result {
  display: grid;
  grid-template-columns: 32px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 0 8px;
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--family-text);
  text-align: left;
  cursor: pointer;
}

.tree-search-result span {
  grid-row: 1 / 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e5ecdf;
  color: var(--family-green);
  font-weight: 800;
}

.tree-search-result small {
  color: var(--family-text-muted);
}

.tree-settings {
  position: absolute;
  z-index: 95;
  top: 62px;
  right: 12px;
  display: grid;
  gap: 8px;
  width: min(320px, calc(100vw - 24px));
  padding: 10px;
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: var(--family-surface);
  box-shadow: var(--shadow-soft);
}

.tree-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--family-text);
  font-weight: 800;
}

.tree-sheet-head button,
.tree-sheet-close {
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  text-align: center;
}

.tree-settings button {
  min-height: 38px;
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--family-green);
  font-weight: 700;
  text-align: left;
}

.tree-route-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--family-border);
  background: #fbfaf6;
}

.tree-route-panel span {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 6px 10px;
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: var(--family-surface);
  font-size: 12px;
  font-weight: 700;
}

.tree-route-panel p {
  flex: 1 1 100%;
  margin: 0;
  color: var(--family-text-secondary);
  font-size: 13px;
}

.tree-mode-toggle input {
  width: 36px;
  min-width: 36px;
  height: 20px;
  accent-color: var(--family-green);
}

.tree-warning {
  margin: var(--space-3);
  color: var(--family-error);
}

.tree-viewport {
  position: relative;
  height: 620px;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.tree-canvas {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}

.tree-lines,
.tree-cards {
  position: absolute;
  inset: 0;
}

.tree-edge {
  fill: none;
  stroke: #c9bfae;
  stroke-width: 2;
  pointer-events: none;
}

.tree-edge-spouse {
  stroke: #809c73;
  stroke-dasharray: 7 5;
}

.tree-edge-family {
  stroke: #b1a48f;
}

.full-tree-card {
  position: absolute;
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: var(--family-surface);
  box-shadow: 0 10px 22px rgba(40, 32, 18, 0.08);
  cursor: pointer;
  user-select: none;
}

.full-tree-card.is-focus {
  border-color: var(--family-green);
  box-shadow: 0 0 0 3px rgba(85, 120, 72, 0.16), 0 14px 28px rgba(40, 32, 18, 0.12);
}

.full-tree-card.is-selected {
  outline: 3px solid rgba(217, 164, 65, 0.44);
  outline-offset: 2px;
}

.full-tree-card.is-route {
  border-color: #9b5d2e;
  box-shadow: 0 0 0 3px rgba(155, 93, 46, 0.18), 0 14px 28px rgba(40, 32, 18, 0.14);
}

.full-tree-card.is-route-end::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 2px solid #9b5d2e;
  border-radius: var(--radius-sm);
  pointer-events: none;
}

.full-tree-card.is-dimmed,
.tree-family-node.is-dimmed-soft {
  opacity: 0.44;
}

.full-tree-card.is-pinned,
.tree-family-node.is-pinned {
  border-color: #8d7438;
}

.tree-family-node.is-pinned {
  background: #fff7df;
}

.tree-avatar-placeholder,
.full-tree-card img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: #dfe9d9;
  color: var(--family-green);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.tree-card-copy strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.tree-person-link {
  display: -webkit-box;
  overflow: hidden;
  color: var(--family-text);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.15;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.tree-card-copy small,
.tree-card-copy span {
  display: block;
  margin-top: 3px;
  color: var(--family-text-muted);
  font-size: 12px;
}

.tree-node-actions button,
.tree-branch-menu button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--family-green);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.tree-family-node,
.tree-branch-stub {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--family-border);
  border-radius: 999px;
  background: #fffdfa;
}

.tree-family-node {
  padding: 0;
  border-color: #c8bda9;
  background: #c8bda9;
  text-align: center;
  color: #8d7438;
  font-size: 10px;
  font-weight: 800;
  pointer-events: none;
}

.tree-family-node strong {
  overflow-wrap: anywhere;
  color: var(--family-text-secondary);
  font-size: 11px;
  line-height: 1.2;
}

.tree-node-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.tree-branch-stub {
  padding: 0 10px;
  border-style: dashed;
  background: #fbfaf4;
  color: var(--family-text-secondary);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.tree-branch-stub strong,
.tree-branch-stub span {
  display: block;
  overflow-wrap: anywhere;
}

.tree-branch-stub span {
  color: var(--family-text-muted);
  font-size: 12px;
}

.tree-branch-menu {
  position: fixed;
  z-index: 60;
  display: grid;
  gap: 6px;
  width: min(240px, calc(100vw - 16px));
  padding: 8px;
  border: 1px solid var(--family-border);
  border-radius: var(--radius-md);
  background: var(--family-surface);
  box-shadow: var(--shadow-soft);
}

.tree-branch-control {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 104px;
  min-height: 38px;
  padding: 2px;
  transform: scale(var(--tree-control-scale, 1));
  transform-origin: center top;
}

.tree-branch-control span {
  min-width: 18px;
  color: var(--family-text-secondary);
  font-size: 12px;
  font-weight: 800;
}

.tree-branch-main,
.tree-more-button {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 34px;
  border: 1px solid var(--family-border);
  border-radius: 999px;
  background: var(--family-surface);
  color: var(--family-green);
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
}

.tree-branch-main {
  min-width: 46px;
  padding: 0 10px;
}

.tree-more-button {
  width: 34px;
  padding: 0;
}

.tree-person-context {
  position: fixed;
  z-index: 80;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: var(--family-surface);
  box-shadow: var(--shadow-soft);
}

.tree-person-context strong {
  align-self: center;
  overflow: hidden;
  padding: 0 8px;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-person-context--canvas {
  display: none;
}

.tree-person-context button {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--family-green);
  font-size: 12px;
  font-weight: 800;
}

.tree-person-context button:not(.tree-sheet-close) {
  grid-column: span 1;
}

.tree-edge.is-route {
  stroke: #9b5d2e;
  stroke-width: 4;
  stroke-dasharray: none;
}

.tree-canvas[data-detail="small"] .full-tree-card {
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 6px;
  padding: 5px 7px;
  border-color: #bac9ae;
  background: #eff5e9;
  box-shadow: none;
}

.tree-canvas[data-detail="small"] .tree-node-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--family-green);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
}

.tree-node-short-name {
  overflow: hidden;
  color: var(--family-text);
  font-size: 12px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-canvas[data-detail="tiny"] .full-tree-card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
}

.tree-canvas[data-detail="tiny"] .tree-node-marker {
  width: 16px;
  height: 16px;
  border: 2px solid #5d7352;
  border-radius: 999px;
  background: #dfe9d9;
}

.tree-canvas[data-detail="small"] .full-tree-card.is-focus,
.tree-canvas[data-detail="tiny"] .full-tree-card.is-focus .tree-node-marker {
  border-color: var(--family-green);
  box-shadow: 0 0 0 4px rgba(47, 107, 63, 0.22);
}

.tree-canvas[data-detail="small"] .full-tree-card.is-route,
.tree-canvas[data-detail="tiny"] .full-tree-card.is-route .tree-node-marker {
  border-color: #9b5d2e;
  background: #f6e3d0;
  box-shadow: 0 0 0 4px rgba(155, 93, 46, 0.2);
}

.tree-canvas[data-detail="tiny"] .full-tree-card.is-route-end .tree-node-marker {
  width: 20px;
  height: 20px;
  background: #9b5d2e;
}

.tree-canvas[data-detail="small"] .tree-branch-control,
.tree-canvas[data-detail="tiny"] .tree-branch-control {
  display: none;
}

.tree-branch-menu button {
  width: 100%;
  min-height: 38px;
  text-align: left;
}

@media (max-width: 1024px) {
  .album-grid,
  .album-grid--home {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .photo-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .photo-grid--all {
    --family-photo-card-min: 180px;
    --family-photo-card-max: 200px;
    grid-template-columns: repeat(auto-fill, minmax(var(--family-photo-card-min), var(--family-photo-card-max)));
  }

  .people-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .family-topbar {
    position: relative;
    z-index: 50;
    width: calc(100% - 20px);
    min-height: 58px;
    margin-top: 10px;
    padding: 0 var(--space-3);
  }

  .family-nav,
  .family-search-link,
  .family-user-menu {
    display: none;
  }

  .family-menu-button {
    display: inline-flex;
  }

  .family-menu-button,
  .avatar--small {
    width: 42px;
    height: 42px;
  }

  .family-brand__logo {
    width: 32px;
    height: 36px;
  }

  .family-brand {
    min-width: 0;
  }

  .family-page,
  .family-mobile-menu {
    width: calc(100% - 20px);
  }

  .family-mobile-menu {
    position: static;
  }

  .family-page {
    margin-top: var(--space-4);
  }

  .family-hero,
  .family-hero__image,
  .family-hero__fallback {
    aspect-ratio: auto;
    min-height: 420px;
    max-height: 620px;
  }

  .family-hero__image,
  .family-hero__fallback {
    transform: scale(1);
    object-position: var(--hero-mobile-focus-position, center top);
  }

  .family-hero::after {
    background:
      radial-gradient(ellipse at 50% 84%, rgba(9, 14, 10, 0.7), rgba(9, 14, 10, 0.18) 44%, rgba(9, 14, 10, 0) 72%),
      linear-gradient(0deg, rgba(18, 28, 19, 0.82), rgba(18, 28, 19, 0.12));
  }

  .family-hero__copy {
    padding: var(--space-5) var(--space-5) var(--space-4);
  }

  .family-hero h1,
  .page-head h1 {
    font-size: 38px;
  }

  .section-title,
  .page-head {
    display: grid;
    gap: var(--space-2);
  }

  .breadcrumbs {
    min-width: 0;
  }

  .photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
  }

  .photo-grid--all {
    --family-photo-card-min: 160px;
    --family-photo-card-max: 180px;
    grid-template-columns: repeat(auto-fill, minmax(var(--family-photo-card-min), var(--family-photo-card-max)));
  }

  .photos-toolbar {
    grid-template-columns: 1fr;
    align-items: end;
  }

  .sort-control {
    grid-column: 1 / -1;
  }

  .photos-filter-toggle {
    width: 100%;
  }

  .sort-control {
    display: grid;
  }

  .segmented-control--sort label {
    flex: 1 1 150px;
  }

  .photos-filter-panel {
    position: fixed;
    inset: auto 10px max(10px, env(safe-area-inset-bottom));
    width: auto;
    max-height: min(78vh, 640px);
    overflow: auto;
  }

  .photos-filter-panel .people-search {
    grid-column: auto;
  }

  .photos-filter-panel__grid {
    grid-template-columns: 1fr;
  }

  .photos-filter-panel__actions .button {
    flex: 1 1 120px;
    margin-top: 0;
  }

  .photo-card__meta {
    display: grid;
    gap: 2px;
    font-size: 12px;
  }

  .family-photo-edit {
    grid-template-columns: 1fr;
  }

  .lightbox__edit {
    min-height: 34px;
    padding: 0 9px;
    font-size: 12px;
  }

  .album-grid,
  .album-grid--home,
  .people-row {
    grid-template-columns: 1fr;
  }

  .album-card {
    display: grid;
    grid-template-columns: 118px 1fr;
  }

  .album-card__cover {
    height: 100%;
    min-height: 118px;
    aspect-ratio: auto;
  }

  .person-chip {
    grid-template-columns: var(--avatar-md) 1fr;
    justify-items: start;
    text-align: left;
  }

  .person-chip span {
    grid-column: 2;
  }

  .lightbox {
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
  }

  .lightbox__dialog {
    height: calc(100vh - 20px);
    max-height: calc(100vh - 20px);
    padding: var(--space-3);
    border-radius: var(--radius-md);
  }

  .lightbox__stage {
    display: grid;
    grid-template-columns: 38px 1fr 38px;
    gap: var(--space-2);
  }

  .lightbox__image-wrap {
    min-height: 0;
  }

  .lightbox__image-wrap img {
    max-height: 100%;
  }

  .lightbox__nav {
    width: 38px;
    height: 38px;
  }

  .tree-picker {
    display: grid;
  }

  .tree-picker label,
  .tree-picker select,
  .tree-picker .button {
    width: 100%;
  }

  .tree-viewport {
    height: min(620px, calc(100svh - 220px));
    min-height: 500px;
  }

  .tree-toolbar {
    align-items: center;
    overflow-x: clip;
    padding: 8px;
  }

  .tree-toolbar .button,
  .tree-mode-toggle,
  .tree-pins {
    min-height: 38px;
    flex: 0 0 auto;
  }

  .tree-search {
    flex: 1 0 100%;
    order: 10;
    display: block;
  }

  .tree-search-results {
    position: fixed;
    top: 118px;
    left: 10px;
    right: 10px;
    width: auto;
    max-height: 46vh;
  }

  .tree-settings {
    position: fixed;
    top: auto;
    right: 10px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
    max-height: min(52svh, 430px);
    overflow: auto;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }

  .tree-settings .tree-search {
    width: 100%;
    flex-basis: auto;
  }

  .tree-settings .tree-search-results {
    top: 164px;
  }

  .tree-route-panel:not([hidden]) {
    position: fixed;
    z-index: 80;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: 10px;
    max-height: min(42svh, 320px);
    overflow: auto;
    border: 1px solid var(--family-border);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    box-shadow: var(--shadow-soft);
  }

  .tree-route-panel span {
    flex: 1 1 calc(50% - 8px);
    max-width: none;
  }

  .tree-route-panel .button {
    flex: 1 1 calc(50% - 8px);
  }

  .tree-person-context.is-sheet {
    position: fixed;
    top: auto;
    display: grid;
    grid-template-columns: 1fr auto;
    max-height: min(38svh, 260px);
    overflow: auto;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }

  .tree-person-context.is-sheet button {
    min-height: 44px;
  }

  .tree-person-context.is-sheet button:not(.tree-sheet-close) {
    grid-column: span 1;
  }

  .tree-branch-main,
  .tree-more-button {
    min-width: 44px;
    min-height: 44px;
  }

  .tree-branch-control {
    min-width: 112px;
    min-height: 48px;
  }

  .page-actions,
  .form-actions,
  .selection-toolbar {
    align-items: stretch;
  }

  .album-add-filters {
    grid-template-columns: 1fr;
  }

  .page-actions .button,
  .form-actions .button,
  .selection-toolbar .button {
    width: 100%;
  }

  .select-photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .upload-preview,
  .upload-card,
  .upload-item {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .drop-zone {
    min-height: 180px;
    padding: var(--space-4);
  }

  .upload-card,
  .upload-item {
    grid-template-columns: 1fr;
  }

  .upload-preview img {
    width: 56px;
    height: 48px;
  }
}

.breadcrumbs {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  max-width: var(--family-container);
  margin: 0 auto var(--space-4);
  padding: 0 var(--space-5);
  color: var(--family-text-muted);
  font-size: 0.92rem;
}

.breadcrumbs a {
  color: var(--family-green);
}

.breadcrumbs span::before {
  content: "/";
  margin-right: var(--space-2);
  color: var(--family-text-muted);
}

.section-title--stacked {
  align-items: end;
}

.section-title--stacked p {
  margin: var(--space-2) 0 0;
  color: var(--family-text-secondary);
}

.section-count {
  color: var(--family-text-muted);
  font-weight: 700;
}

.people-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 240px) auto auto;
  gap: var(--space-3);
  align-items: end;
  margin-top: var(--space-5);
}

.people-toolbar label,
.avatar-zoom {
  display: grid;
  gap: var(--space-2);
  color: var(--family-text-secondary);
  font-size: 0.9rem;
  font-weight: 700;
}

.people-toolbar input,
.people-toolbar select,
.avatar-zoom input {
  min-height: var(--button-height);
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: var(--family-surface);
  color: var(--family-text);
  padding: 0 var(--space-3);
}

.people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--space-4);
}

.person-card,
.relative-card {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
  border: 1px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: var(--family-surface);
  padding: var(--space-4);
  box-shadow: var(--shadow-soft);
}

.person-card {
  justify-items: center;
  text-align: center;
  min-height: 190px;
}

.person-card strong,
.relative-card strong {
  overflow-wrap: normal;
  word-break: normal;
}

.person-card strong {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.person-card span,
.person-card small,
.relative-card small,
.person-years {
  color: var(--family-text-muted);
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: var(--avatar-md);
  height: var(--avatar-md);
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--family-green);
  color: #fff;
  font-weight: 800;
  object-fit: cover;
}

.avatar.avatar--small {
  width: 38px;
  height: 38px;
  font-size: 12px;
  line-height: 1;
}

.avatar--large {
  width: 92px;
  height: 92px;
  font-size: 1.35rem;
}

.avatar--hero {
  width: 160px;
  height: 160px;
  font-size: 2.4rem;
}

.person-profile {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-6);
  align-items: center;
  max-width: var(--family-container);
  margin: 0 auto var(--space-6);
  padding: 0 var(--space-5);
}

.person-profile h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 1;
}

.person-profile__copy {
  display: grid;
  gap: var(--space-3);
}

.person-profile__copy p {
  max-width: 760px;
  margin: 0;
  color: var(--family-text-secondary);
}

.person-profile__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.person-profile__actions .button {
  width: 190px;
  min-height: 46px;
  margin-top: 0;
  border-radius: 999px;
  white-space: nowrap;
}

.relative-groups {
  display: grid;
  gap: var(--space-4);
}

.relative-group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-3);
}

.relative-card {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
}

.relative-card span {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
}

.person-years {
  display: grid;
  gap: 2px;
}

.avatar-modal[hidden] {
  display: none;
}

.avatar-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: var(--space-4);
}

.avatar-modal__backdrop {
  position: absolute;
  inset: 0;
  background: var(--family-overlay);
}

.avatar-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  border-radius: var(--radius-sm);
  background: var(--family-surface);
  padding: var(--space-5);
}

.avatar-modal__dialog header,
.avatar-modal__dialog footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.avatar-start {
  display: grid;
  gap: var(--space-5);
  margin-top: var(--space-4);
}

.avatar-start__current {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: var(--space-5);
  align-items: center;
}

.avatar-start__current > img,
.avatar-start__current > .media-fallback {
  width: 100%;
  max-height: 420px;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: var(--family-surface-soft);
}

.avatar-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.avatar-choice {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-2);
  border: 2px solid var(--family-border);
  border-radius: var(--radius-sm);
  background: var(--family-surface);
  color: var(--family-text);
  text-align: left;
  cursor: pointer;
}

.avatar-choice img,
.avatar-choice .media-fallback {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  object-fit: cover;
}

.avatar-choice span {
  display: grid;
  gap: 2px;
  min-height: 34px;
}

.avatar-choice strong,
.avatar-choice small {
  font-size: 13px;
}

.avatar-choice small {
  color: var(--family-green);
  font-weight: 800;
}

.avatar-choice.is-selected {
  border-color: var(--family-green);
  box-shadow: 0 0 0 3px rgba(47, 107, 63, 0.14);
}

.avatar-choice.is-current {
  background: #f5f8f0;
}

.avatar-crop-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: var(--space-5);
  align-items: center;
  margin: var(--space-4) 0;
}

.avatar-crop-stage {
  position: relative;
  aspect-ratio: 1;
  min-height: 280px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: #111;
  touch-action: none;
}

.avatar-crop-stage img {
  position: absolute;
  inset: 0 auto auto 0;
  max-width: none;
  transform-origin: 0 0;
  user-select: none;
  pointer-events: none;
}

.avatar-crop-box {
  position: absolute;
  inset: 14%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.42);
}

.avatar-preview {
  display: grid;
  place-items: center;
}

.avatar-preview canvas {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: var(--family-surface-soft);
}

.avatar-zoom {
  margin-bottom: var(--space-4);
}

@media (max-width: 760px) {
  .breadcrumbs {
    padding: 0 var(--space-4);
  }

  .people-toolbar {
    grid-template-columns: 1fr;
  }

  .people-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .person-profile {
    grid-template-columns: 1fr;
    justify-items: start;
    padding: 0 var(--space-4);
  }

  .avatar--hero {
    width: 128px;
    height: 128px;
  }

  .person-profile__actions {
    flex-direction: column;
  }

  .person-profile__actions .button {
    width: 190px;
    min-height: 46px;
  }

  .avatar-crop-layout {
    grid-template-columns: 1fr;
  }

  .avatar-start__current {
    grid-template-columns: 1fr;
  }

  .avatar-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .avatar-modal__dialog {
    padding: var(--space-4);
  }
}

@media (max-width: 380px) {
  .family-topbar {
    gap: var(--space-2);
  }

  .family-brand span:last-child {
    max-width: 78px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .album-card {
    grid-template-columns: 104px 1fr;
  }

  .album-card__body {
    padding: var(--space-3);
  }
}
