:root {
  --bg: #f6efe5;
  --bg-accent: #ead7c2;
  --panel: rgba(255, 251, 246, 0.84);
  --panel-strong: rgba(89, 54, 37, 0.9);
  --text: #2d211a;
  --muted: #6f5849;
  --line: rgba(86, 57, 41, 0.15);
  --shadow: 0 24px 70px rgba(68, 42, 28, 0.12);
  --accent: #9d5c3d;
  --accent-soft: #d7ad8d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.7), transparent 32%),
    linear-gradient(135deg, #f8f2ea 0%, #f2e6d8 48%, #ead7c2 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(circle at center, black, transparent 82%);
}

.page-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.hero {
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 28px;
  background:
    linear-gradient(140deg, rgba(255, 251, 246, 0.9), rgba(241, 223, 205, 0.82)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='320' viewBox='0 0 320 320'%3E%3Cg fill='none' stroke='%23d7ad8d' stroke-opacity='.28'%3E%3Cpath d='M30 90c40-50 110-70 160-30s80 110 50 150'/%3E%3Cpath d='M50 210c20-30 80-60 130-35s70 70 65 105'/%3E%3C/g%3E%3C/svg%3E");
  box-shadow: var(--shadow);
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1,
.page-panel h2 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-weight: 600;
  line-height: 0.95;
}

.hero h1 {
  text-align: center;
  font-size: clamp(3.4rem, 8vw, 6.8rem);
  white-space: nowrap;
}

.hero__text,
.section-copy,
.home-notes p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.hero__copy {
  display: grid;
  gap: 12px;
  justify-items: center;
}

.family-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 22px 0;
}

.nav-wrap {
  position: relative;
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin: 22px auto 0;
  border: 0;
  border-radius: 999px;
  background: var(--panel-strong);
  box-shadow: 0 10px 24px rgba(70, 39, 23, 0.08);
  cursor: pointer;
}

.menu-toggle span {
  position: absolute;
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: #fff8f0;
  transition: transform 180ms ease, opacity 180ms ease;
}

.menu-toggle span:nth-child(1) {
  transform: translateY(-6px);
}

.menu-toggle span:nth-child(3) {
  transform: translateY(6px);
}

.menu-toggle.is-open span:nth-child(1) {
  transform: rotate(45deg);
}

.menu-toggle.is-open span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.is-open span:nth-child(3) {
  transform: rotate(-45deg);
}

.nav-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: rgba(255, 252, 247, 0.78);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(70, 39, 23, 0.08);
  transition: transform 180ms ease, background 180ms ease, color 180ms ease;
}

.nav-button:hover,
.nav-button:focus-visible,
.upload-zone:hover,
.upload-zone:focus-visible {
  transform: translateY(-2px);
}

.nav-button.is-active {
  background: var(--panel-strong);
  color: #fff8f0;
}

.page-panel {
  display: none;
  padding: 28px;
  border-radius: 28px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow);
}

.page-panel.is-visible {
  display: block;
}

.intro-layout,
.family-page {
  display: grid;
  gap: 26px;
}

.intro-layout {
  justify-items: center;
  text-align: center;
}

.page-panel h2 {
  font-size: clamp(2.4rem, 6vw, 4.8rem);
}

.family-page__header {
  display: grid;
  gap: 14px;
}

.family-page__header .section-copy:empty {
  display: none;
}

.family-photo {
  width: min(100%, 920px);
  display: block;
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow);
  object-fit: cover;
}

.gallery-wrap {
  min-height: 180px;
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 12px;
}

.thumb-card,
.thumb-card--empty {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.thumb-card {
  display: grid;
  align-items: stretch;
  cursor: pointer;
}

.thumb-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-card__file {
  display: grid;
  place-items: center;
  padding: 12px;
  text-align: center;
  background:
    linear-gradient(150deg, rgba(157, 92, 61, 0.18), rgba(255, 255, 255, 0.88)),
    rgba(255, 255, 255, 0.86);
}

.thumb-card__ext {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.thumb-card__name {
  margin-top: 8px;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--muted);
  word-break: break-word;
}

.thumb-card__meta {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: 8px 10px;
  background: linear-gradient(180deg, transparent, rgba(41, 25, 16, 0.78));
  color: white;
  font-size: 0.7rem;
  line-height: 1.3;
}

.asset-modal {
  width: min(1120px, calc(100% - 24px));
  max-width: 1120px;
  height: min(88vh, 920px);
  max-height: 88vh;
  padding: 0;
  border: 0;
  background: transparent;
}

.asset-modal::backdrop {
  background: rgba(22, 13, 8, 0.72);
  backdrop-filter: blur(4px);
}

.asset-modal[open] {
  display: grid;
  place-items: center;
}

.asset-modal__panel {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: 100%;
  height: 100%;
  padding: 18px;
  border-radius: 28px;
  background: rgba(255, 251, 246, 0.98);
  box-shadow: 0 24px 90px rgba(22, 13, 8, 0.3);
}

.asset-modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: rgba(45, 33, 26, 0.1);
  color: var(--text);
  font-size: 1.8rem;
  cursor: pointer;
}

.asset-modal__topbar {
  display: flex;
  justify-content: center;
  padding: 6px 52px 18px 4px;
}

.asset-modal__caption {
  margin-top: 20px;
  color: var(--text);
  line-height: 1.6;
  text-align: center;
}

.asset-modal__caption--bottom {
  margin-top: 20px;
  padding: 14px 18px;
  border-radius: 18px;
  background: #e4d0bb;
}

.asset-modal__caption:empty {
  display: none;
}

.asset-modal__caption a {
  color: var(--accent);
  font-weight: 700;
  text-decoration-thickness: 2px;
  word-break: break-word;
}

.asset-modal__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.modal-action {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(89, 54, 37, 0.1);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.modal-action:disabled {
  opacity: 0.45;
  cursor: default;
}

.modal-action--danger {
  background: rgba(146, 48, 36, 0.14);
  color: #8d2b1b;
}

.asset-modal__viewport {
  min-height: 0;
  overflow: auto;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(250, 245, 238, 0.9), rgba(240, 230, 219, 0.9));
  border: 1px solid rgba(86, 57, 41, 0.12);
}

.asset-modal__stage {
  --modal-zoom: 1;
  --modal-pan-x: 0px;
  --modal-pan-y: 0px;
  min-height: fit-content;
  display: grid;
  place-items: start center;
  padding: 20px 24px;
  touch-action: none;
}

.modal-zoomable {
  transform: translate(var(--modal-pan-x), var(--modal-pan-y)) scale(var(--modal-zoom));
  transform-origin: center center;
  transition: transform 180ms ease;
  will-change: transform;
  touch-action: none;
}

.modal-zoomable.is-draggable {
  cursor: grab;
}

.modal-zoomable.is-dragging {
  cursor: grabbing;
  transition: none;
}

.asset-modal__image,
.asset-modal__pdf {
  max-width: min(100%, 920px);
  max-height: 100%;
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(22, 13, 8, 0.12);
}

.asset-modal__image {
  display: block;
}

.asset-modal__pdf {
  width: min(100%, 900px);
  height: min(70vh, 760px);
  background: white;
}

.asset-modal__text,
.asset-modal__docx {
  width: min(100%, 860px);
  padding: 24px;
  border-radius: 18px;
  background: white;
  box-shadow: 0 12px 40px rgba(22, 13, 8, 0.08);
}

.asset-modal__text {
  white-space: pre-wrap;
  line-height: 1.7;
}

.asset-modal__text a {
  color: var(--accent);
  font-weight: 700;
  text-decoration-thickness: 2px;
  word-break: break-word;
}

.asset-modal__docx p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.thumb-card--empty {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 24px;
}

.thumb-card--empty p {
  margin: 0;
  max-width: 32ch;
  text-align: center;
  color: var(--muted);
  line-height: 1.6;
}

.upload-zone {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 34px 22px;
  border: 2px dashed rgba(157, 92, 61, 0.34);
  border-radius: 24px;
  background: rgba(255, 252, 248, 0.74);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.upload-zone.is-dragging {
  border-color: var(--accent);
  background: rgba(255, 243, 233, 0.96);
}

.upload-zone__title {
  font-size: 1.15rem;
  font-weight: 800;
}

.upload-zone__subtitle {
  color: var(--muted);
  text-align: center;
  line-height: 1.55;
}

.upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mobile-upload-actions {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.mobile-upload-button {
  display: none;
  position: relative;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  background: rgba(89, 54, 37, 0.9);
  color: #fff8f0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.mobile-upload-button span {
  pointer-events: none;
}

.mobile-upload-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  border: 0;
}

.caption-dialog {
  width: min(560px, calc(100% - 24px));
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: rgba(255, 251, 246, 0.98);
  box-shadow: 0 24px 90px rgba(22, 13, 8, 0.3);
}

.caption-dialog::backdrop {
  background: rgba(22, 13, 8, 0.6);
  backdrop-filter: blur(4px);
}

.caption-dialog__panel {
  display: grid;
  gap: 14px;
  padding: 24px;
}

.caption-dialog__title {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 2rem;
  line-height: 1;
}

.caption-dialog__copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.caption-dialog__input {
  width: 100%;
  min-height: 140px;
  padding: 14px 16px;
  border: 1px solid rgba(86, 57, 41, 0.16);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font: inherit;
  line-height: 1.6;
  resize: vertical;
}

.caption-dialog__input:focus {
  outline: 2px solid rgba(157, 92, 61, 0.22);
  outline-offset: 2px;
}

.caption-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.caption-dialog__button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: rgba(89, 54, 37, 0.9);
  color: #fff8f0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.caption-dialog__button--secondary {
  background: rgba(89, 54, 37, 0.12);
  color: var(--text);
}

.password-dialog {
  width: min(460px, calc(100% - 24px));
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: rgba(255, 251, 246, 0.98);
  box-shadow: 0 24px 90px rgba(22, 13, 8, 0.3);
}

.password-dialog::backdrop {
  background: rgba(22, 13, 8, 0.6);
  backdrop-filter: blur(4px);
}

.password-dialog__panel {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.password-dialog__title {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 2rem;
  line-height: 1;
}

.password-dialog__input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(86, 57, 41, 0.16);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font: inherit;
}

.password-dialog__input:focus {
  outline: 2px solid rgba(157, 92, 61, 0.22);
  outline-offset: 2px;
}

.password-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.password-dialog__button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: rgba(89, 54, 37, 0.9);
  color: #fff8f0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.password-dialog__button--secondary {
  background: rgba(89, 54, 37, 0.12);
  color: var(--text);
}

@media (max-width: 900px) {
  .thumb-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 20px, 1200px);
    padding-top: 18px;
    position: relative;
  }

  .hero,
  .page-panel {
    padding: 22px;
    border-radius: 24px;
  }

  .hero h1,
  .page-panel h2 {
    line-height: 1;
  }

  .hero h1 {
    white-space: normal;
  }

  .nav-wrap {
    position: absolute;
    top: 28px;
    left: 14px;
    z-index: 30;
  }

  .menu-toggle {
    display: inline-flex;
    position: relative;
    top: 0;
    left: 0;
    margin-top: 0;
    z-index: 21;
    background: rgba(89, 54, 37, 0.76);
    backdrop-filter: blur(10px);
  }

  .family-nav {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    transform: none;
    width: min(220px, calc(100vw - 52px));
    z-index: 20;
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0;
    border-radius: 20px;
    overflow: hidden;
    background: rgba(255, 251, 246, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.75);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
  }

  .family-nav.is-open {
    display: grid;
  }

  .nav-button {
    width: 100%;
    text-align: center;
    border-radius: 0;
    box-shadow: none;
    background: rgba(255, 252, 247, 0.58);
    border-bottom: 1px solid rgba(86, 57, 41, 0.1);
  }

  .nav-button:last-child {
    border-bottom: 0;
  }

  .thumb-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }

  .family-page__header .section-copy {
    font-size: 0.92rem;
    line-height: 1.5;
  }

  .upload-zone__title {
    font-size: 1rem;
  }

  .upload-zone__subtitle {
    font-size: 0.88rem;
    line-height: 1.45;
  }

  .upload-zone {
    display: none;
  }

  .mobile-upload-actions {
    display: grid;
  }

  .mobile-upload-button {
    display: inline-flex;
  }

  .asset-modal {
    width: calc(100% - 12px);
    height: calc(100vh - 12px);
    max-height: calc(100vh - 12px);
    margin-top: 20px;
  }

  .asset-modal__panel {
    padding: 14px;
    border-radius: 22px;
  }

  .asset-modal__topbar {
    display: grid;
    grid-template-columns: 1fr;
    padding-right: 44px;
  }

  .asset-modal__actions {
    justify-content: center;
  }

  .modal-action[data-zoom-in],
  .modal-action[data-zoom-out] {
    display: none;
  }

  .caption-dialog__panel {
    padding: 20px;
  }

  .password-dialog__panel {
    padding: 20px;
  }
}
