:root {
  --bg: #fff8f4;
  --bg-2: #fff1ea;
  --card: rgba(255, 255, 255, 0.78);
  --card-solid: #ffffff;
  --text: #302523;
  --muted: #806f6a;
  --rose: #d96a88;
  --rose-dark: #b94f70;
  --rose-soft: #ffe1ea;
  --line: rgba(104, 77, 70, 0.14);
  --shadow: 0 22px 70px rgba(104, 58, 56, 0.15);
  --shadow-soft: 0 16px 42px rgba(104, 58, 56, 0.11);
  --radius-xl: 34px;
  --radius-lg: 24px;
  --radius-md: 16px;
  --max: 1160px;
}

* { box-sizing: border-box; }

html { min-height: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 5%, rgba(255, 225, 234, 0.96), transparent 34rem),
    radial-gradient(circle at 90% 12%, rgba(255, 214, 199, 0.72), transparent 30rem),
    linear-gradient(180deg, var(--bg) 0%, #fff 58%, #fff7f2 100%);
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, textarea { font: inherit; }
textarea { resize: vertical; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  width: min(var(--max), calc(100% - 32px));
  margin: 16px auto 0;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 247, 0.78);
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 34px rgba(110, 72, 65, 0.08);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 760;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.brand__mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--rose), #ffb3a5);
  color: white;
  box-shadow: 0 10px 20px rgba(217, 106, 136, 0.28);
}

.navlinks {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.navlinks__item,
.link-button {
  border: 0;
  background: transparent;
  padding: 10px 13px;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
}

.navlinks__item:hover,
.link-button:hover { background: rgba(217, 106, 136, 0.10); color: var(--text); }

.logout-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.current-user {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 225, 234, 0.65);
  color: var(--rose-dark);
  font-weight: 650;
}

.page {
  width: min(var(--max), calc(100% - 32px));
  margin: 42px auto 0;
}

.narrow-page { width: min(780px, calc(100% - 32px)); }

.flash {
  margin: 0 0 18px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--card-solid);
  box-shadow: var(--shadow-soft);
}
.flash--success { border-color: rgba(65, 151, 111, 0.24); color: #28754e; background: #f1fff7; }
.flash--error { border-color: rgba(217, 84, 84, 0.28); color: #9f3434; background: #fff4f4; }

.hero {
  min-height: calc(100svh - 136px);
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(300px, 0.72fr);
  align-items: center;
  gap: clamp(28px, 6vw, 96px);
  padding: 28px 0 72px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--rose-dark);
  text-transform: uppercase;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 18px;
  font-size: clamp(2.75rem, 8vw, 6.8rem);
  line-height: 0.92;
  letter-spacing: -0.08em;
}
h2 { font-size: clamp(1.7rem, 3vw, 2.5rem); letter-spacing: -0.055em; }
h3 { letter-spacing: -0.035em; }

.hero__lead {
  max-width: 620px;
  color: var(--muted);
  font-size: clamp(1.08rem, 2vw, 1.35rem);
  line-height: 1.68;
}

.hero__actions,
.form-actions,
.card-actions,
.photo-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 740;
  box-shadow: 0 10px 24px rgba(86, 61, 56, 0.08);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.button:hover { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(86, 61, 56, 0.12); }
.button--primary { background: linear-gradient(135deg, var(--rose), #ff9c91); color: white; }
.button--ghost { background: rgba(255,255,255,0.58); border-color: var(--line); color: var(--muted); }
.button--small { min-height: 36px; padding: 0 14px; font-size: 0.9rem; }
.button--danger { background: #fff1f1; color: #b33636; border-color: rgba(179, 54, 54, 0.2); }
.text-link { color: var(--rose-dark); font-weight: 750; }
.text-button { border: 0; background: transparent; color: var(--rose-dark); cursor: pointer; padding: 0; font-weight: 750; }
.text-button--danger { color: #aa3030; }

.memory-stream {
  position: relative;
  min-height: 760px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px 0;
}

.memory-stream::before {
  content: "";
  position: absolute;
  inset: 4% auto 4% 50%;
  width: 2px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: linear-gradient(180deg, transparent, rgba(217, 106, 136, 0.16), transparent);
}

.memory-card {
  position: relative;
  width: clamp(160px, 32vw, 250px);
  aspect-ratio: 0.72;
  overflow: hidden;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.72);
  border: 7px solid #fff;
  box-shadow: var(--shadow);
  transition: transform .22s ease, box-shadow .22s ease, filter .22s ease;
}
.memory-card:hover { filter: saturate(1.05); box-shadow: 0 28px 82px rgba(104, 58, 56, 0.2); }
.memory-card img { width: 100%; height: 100%; object-fit: cover; }
.memory-card span {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  padding: 8px 10px;
  border-radius: 999px;
  color: white;
  font-size: 0.86rem;
  font-weight: 750;
  background: rgba(38, 27, 25, 0.38);
  backdrop-filter: blur(10px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.memory-card--1 { align-self: flex-start; transform: rotate(-12deg); }
.memory-card--2 { align-self: flex-end; transform: rotate(15deg); margin-top: -66px; }
.memory-card--3 { align-self: flex-start; transform: rotate(-15deg); margin-top: -38px; }
.memory-card--4 { align-self: flex-end; transform: rotate(14deg); margin-top: -72px; }
.memory-card--5 { align-self: flex-start; transform: rotate(-8deg); margin-top: -42px; }
.memory-card--6 { align-self: flex-end; transform: rotate(10deg); margin-top: -56px; }
.memory-card--1:hover { transform: rotate(-9deg) translateY(-5px); }
.memory-card--2:hover { transform: rotate(12deg) translateY(-5px); }
.memory-card--3:hover { transform: rotate(-12deg) translateY(-5px); }
.memory-card--4:hover { transform: rotate(11deg) translateY(-5px); }
.memory-card--5:hover { transform: rotate(-5deg) translateY(-5px); }
.memory-card--6:hover { transform: rotate(7deg) translateY(-5px); }
.memory-card--empty {
  display: grid;
  place-items: center;
  border: 5px solid rgba(48, 37, 35, 0.78);
  background: linear-gradient(145deg, rgba(255,255,255,0.88), rgba(255,225,234,0.58));
}
.memory-card--empty span { position: static; color: var(--muted); background: transparent; backdrop-filter: none; text-align: center; }

.section-block,
.form-card,
.story-card,
.upload-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}

.section-block,
.form-card,
.story-card,
.upload-card { padding: clamp(20px, 4vw, 36px); }
.empty-state { padding: clamp(28px, 6vw, 56px); text-align: center; }
.empty-state p { color: var(--muted); }

.section-heading,
.page-title-row,
.upload-card {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}
.page-title-row { margin-bottom: 24px; align-items: center; }
.page-title-row p { color: var(--muted); max-width: 720px; }

.event-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}
.event-grid--compact { margin-top: 20px; }
.event-card {
  display: block;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,0.76);
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(104, 58, 56, 0.10);
}
.event-card--article { display: flex; flex-direction: column; }
.event-card__media { display: block; }
.event-card__image {
  width: 100%;
  height: 250px;
  object-fit: cover;
  background: var(--rose-soft);
}
.event-card__image--placeholder {
  display: grid;
  place-items: center;
  color: var(--rose-dark);
  font-size: 3rem;
}
.event-card__body { padding: 18px; }
.event-card__date { margin-bottom: 8px; color: var(--rose-dark); font-weight: 760; }
.event-card h2, .event-card h3 { margin-bottom: 8px; }
.event-card p { color: var(--muted); line-height: 1.55; }
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.form.stack { display: grid; gap: 18px; }
.form label, .caption-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 720;
}
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 13px 15px;
  background: rgba(255,255,255,0.78);
  color: var(--text);
  outline: none;
}
textarea { line-height: 1.55; }
input:focus, textarea:focus { border-color: rgba(217, 106, 136, 0.55); box-shadow: 0 0 0 4px rgba(217, 106, 136, 0.12); }
.file-drop {
  padding: 16px;
  border: 1px dashed rgba(217, 106, 136, 0.42);
  border-radius: 22px;
  background: rgba(255, 241, 234, 0.62);
}
.file-drop small { color: var(--muted); font-weight: 500; }
.current-poster img { width: 140px; height: 160px; object-fit: cover; border-radius: 18px; border: 5px solid #fff; box-shadow: var(--shadow-soft); }
.danger-zone { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }

.auth-page {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  position: relative;
  width: min(480px, 100%);
  overflow: hidden;
  padding: clamp(26px, 6vw, 44px);
  border-radius: 36px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.76);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.auth-card h1 { font-size: clamp(2.1rem, 8vw, 4rem); }
.auth-card p { color: var(--muted); line-height: 1.6; }
.auth-card__decor {
  position: absolute;
  top: -22px;
  right: 28px;
  font-size: 8rem;
  color: rgba(217, 106, 136, 0.12);
  transform: rotate(12deg);
}

.event-hero {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(22px, 5vw, 56px);
  align-items: center;
  margin-bottom: 24px;
}
.event-hero__image,
.poster-placeholder {
  min-height: 420px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 9px solid #fff;
  background: var(--rose-soft);
}
.event-hero__image img { width: 100%; height: 100%; min-height: 420px; object-fit: cover; }
.poster-placeholder { display: grid; place-items: center; color: var(--rose-dark); font-size: 6rem; }
.event-hero h1 { font-size: clamp(2.6rem, 7vw, 5.8rem); }
.event-description, .story-text { color: var(--muted); line-height: 1.75; }
.meta-list { display: grid; gap: 7px; margin: 18px 0 22px; color: var(--muted); }
.story-card, .upload-card { margin-bottom: 24px; }
.story-text { white-space: pre-line; font-size: 1.05rem; }
.muted { color: var(--muted); }
.upload-form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.upload-form input { width: min(420px, 100%); background: white; }

.photo-gallery { display: grid; gap: 26px; }
.photo-card {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.78);
  box-shadow: var(--shadow-soft);
}
.photo-card__image { background: #f1e3dd; }
.photo-card__image img { width: 100%; height: 100%; max-height: 760px; min-height: 440px; object-fit: cover; }
.photo-card__content { padding: clamp(18px, 4vw, 30px); display: grid; gap: 18px; align-content: start; }
.caption-form, .replace-form { display: grid; gap: 10px; }
.photo-tools { padding: 14px; border: 1px solid var(--line); border-radius: 22px; background: rgba(255, 248, 244, 0.72); }
.replace-form { grid-template-columns: 1fr auto; align-items: center; flex: 1; min-width: min(100%, 360px); }
.comments { display: grid; gap: 14px; }
.comments h3 { margin: 0; }
.comment-list { display: grid; gap: 10px; }
.comment {
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 241, 234, 0.76);
  border: 1px solid var(--line);
}
.comment__top { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 0.9rem; margin-bottom: 8px; }
.comment-edit-form { display: grid; gap: 8px; }
.comment-delete-form { margin-top: 6px; }
.comment-form { display: grid; gap: 10px; }
.footer {
  width: min(var(--max), calc(100% - 32px));
  margin: 48px auto 22px;
  padding: 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 0.94rem;
}

@media (max-width: 940px) {
  .hero,
  .event-hero,
  .photo-card { grid-template-columns: 1fr; }
  .hero { min-height: auto; padding-top: 28px; }
  .memory-stream { min-height: 620px; width: min(440px, 100%); margin: 0 auto; }
  .event-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-heading,
  .page-title-row,
  .upload-card { align-items: flex-start; flex-direction: column; }
  .photo-card__image img { min-height: 360px; max-height: none; }
}

@media (max-width: 680px) {
  .topbar {
    position: static;
    width: calc(100% - 20px);
    border-radius: 26px;
    flex-wrap: wrap;
    justify-content: center;
  }
  .brand { width: 100%; justify-content: center; }
  .navlinks { margin-left: 0; order: 2; }
  .logout-form { order: 3; }
  .page { width: calc(100% - 20px); margin-top: 24px; }
  h1 { font-size: clamp(2.45rem, 16vw, 4rem); }
  .event-grid { grid-template-columns: 1fr; }
  .memory-stream { min-height: 560px; }
  .memory-card { width: clamp(150px, 55vw, 218px); border-width: 5px; border-radius: 20px; }
  .memory-card--2, .memory-card--4, .memory-card--6 { margin-top: -60px; }
  .event-hero__image, .poster-placeholder { min-height: 320px; border-width: 6px; }
  .event-hero__image img { min-height: 320px; }
  .photo-tools, .replace-form, .upload-form { display: grid; grid-template-columns: 1fr; width: 100%; }
  .footer { flex-direction: column; text-align: center; }
}

.backup-card {
  display: grid;
  gap: 20px;
  padding: clamp(22px, 5vw, 40px);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: rgba(255,255,255,0.78);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}

.backup-card__icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--rose), #ffb3a5);
  color: #fff;
  font-size: 2rem;
  box-shadow: 0 16px 34px rgba(217, 106, 136, 0.24);
}

.backup-card code,
.backup-help code {
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(217, 106, 136, 0.10);
  color: var(--rose-dark);
}

.backup-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding-top: 8px;
}

.backup-help {
  margin-top: 24px;
}
/* Mobile overflow fix: keeps the home page inside the phone viewport */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.home-page,
.hero,
.hero__text,
.memory-stream {
  min-width: 0;
}

@media (max-width: 680px) {
  .topbar {
    width: min(100% - 24px, 560px);
    margin-top: 14px;
    padding: 14px 12px;
    gap: 10px;
  }

  .brand {
    min-width: 0;
  }

  .brand__mark {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
  }

  .brand span:last-child {
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    text-align: center;
    font-size: clamp(1rem, 4.4vw, 1.18rem);
    line-height: 1.16;
  }

  .navlinks {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
  }

  .navlinks__item,
  .link-button {
    padding: 9px 11px;
  }

  .logout-form {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  .page,
  .footer {
    width: min(100% - 24px, 560px);
  }

  .home-page {
    overflow: hidden;
  }

  .hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    padding-top: 18px;
    padding-bottom: 54px;
    overflow: hidden;
  }

  .hero__text {
    width: 100%;
    max-width: 100%;
  }

  .eyebrow {
    font-size: 0.68rem;
    letter-spacing: 0.20em;
  }

  .hero h1 {
    max-width: 100%;
    font-size: clamp(2.25rem, 11.6vw, 3rem);
    line-height: 0.98;
    letter-spacing: -0.065em;
  }

  .hero__lead {
    max-width: 100%;
    font-size: 1.03rem;
    line-height: 1.58;
  }

  .hero__actions {
    width: 100%;
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
  }

  .hero__actions .button {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: 12px;
    white-space: nowrap;
    font-size: clamp(0.88rem, 3.65vw, 1rem);
  }

  .memory-stream {
    width: 100%;
    max-width: 340px;
    min-height: 520px;
    margin-inline: auto;
    padding-inline: 18px;
    overflow: hidden;
  }

  .memory-card {
    width: clamp(135px, 47vw, 190px);
    border-width: 5px;
    border-radius: 20px;
  }

  .memory-card--1,
  .memory-card--3,
  .memory-card--5 {
    margin-left: 8px;
  }

  .memory-card--2,
  .memory-card--4,
  .memory-card--6 {
    margin-right: 8px;
  }
}

@media (max-width: 380px) {
  .hero h1 {
    font-size: clamp(2.05rem, 11vw, 2.55rem);
  }

  .hero__actions {
    flex-direction: column;
    flex-wrap: nowrap;
  }

  .hero__actions .button {
    width: 100%;
  }
}
