:root {
  --rose: #ff7ead;
  --rose-soft: #3a1527;
  --plum: #b384ff;
  --wine: #ff5f8f;
  --cream: #170d16;
  --white: #fff7fb;
  --ink: #ffeaf3;
  --muted: #d8aec1;
  --panel: rgba(39, 20, 36, 0.78);
  --panel-strong: rgba(55, 25, 50, 0.9);
  --line: rgba(255, 126, 173, 0.22);
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 95, 143, 0.22), transparent 28%),
    radial-gradient(circle at 85% 12%, rgba(179, 132, 255, 0.2), transparent 28%),
    radial-gradient(circle at 50% 105%, rgba(255, 126, 173, 0.16), transparent 36%),
    linear-gradient(135deg, #100912 0%, #1b0d1b 45%, #2a1024 100%);
}

a {
  color: var(--wine);
  text-decoration: none;
  font-weight: 700;
}

button,
.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--rose), var(--plum));
  color: var(--white);
  cursor: pointer;
  font-weight: 800;
  padding: 0.75rem 1rem;
  box-shadow: 0 10px 22px rgba(179, 54, 91, 0.2);
  min-height: 2.65rem;
  text-align: center;
  transition: transform 0.18s ease, filter 0.18s ease, border-color 0.18s ease;
}

button:hover,
.small-button:hover {
  transform: translateY(-1px);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(18, 9, 17, 0.72);
  color: var(--ink);
  font: inherit;
  padding: 0.8rem 0.9rem;
  outline-color: var(--rose);
}

textarea {
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: rgba(216, 174, 193, 0.68);
}

.sparkles::before,
.sparkles::after {
  content: "\2665  \2726  \2661  \2727  \2665";
  position: fixed;
  z-index: -1;
  color: rgba(255, 126, 173, 0.22);
  font-size: 2rem;
  letter-spacing: 1rem;
}

.sparkles::before {
  top: 7rem;
  right: 4vw;
}

.sparkles::after {
  bottom: 3rem;
  left: 3vw;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem clamp(1rem, 4vw, 3rem);
  background: rgba(18, 9, 17, 0.86);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  white-space: nowrap;
}

.brand-heart {
  display: grid;
  place-items: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 50%;
  color: var(--white);
  background: linear-gradient(135deg, var(--wine), var(--rose));
}

.nav {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav a {
  border-radius: 999px;
  color: var(--muted);
  padding: 0.55rem 0.75rem;
  white-space: nowrap;
}

.nav a:hover {
  background: rgba(255, 126, 173, 0.14);
  color: var(--white);
}

.ghost-button,
.danger-button,
.secondary-button,
.secondary-link {
  background: rgba(255, 255, 255, 0.06);
  color: var(--rose);
  border: 1px solid var(--line);
  box-shadow: none;
}

.danger-button {
  color: #ff9aae;
}

.active-soft {
  background: rgba(255, 126, 173, 0.16);
  border-color: rgba(255, 126, 173, 0.42);
}

.container {
  width: min(1040px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.narrow {
  width: min(860px, calc(100% - 2rem));
}

.hero {
  display: grid;
  min-height: 380px;
  align-items: center;
  border-radius: 30px;
  padding: clamp(2rem, 6vw, 4rem);
  background:
    linear-gradient(135deg, rgba(58, 21, 39, 0.82), rgba(35, 16, 43, 0.86)),
    url("data:image/svg+xml,%3Csvg width='180' height='180' xmlns='http://www.w3.org/2000/svg'%3E%3Ctext x='22' y='95' font-size='72' fill='%23ff7ead' fill-opacity='.22'%3E%E2%99%A5%3C/text%3E%3Ctext x='105' y='130' font-size='42' fill='%23b384ff' fill-opacity='.2'%3E%E2%9C%A6%3C/text%3E%3C/svg%3E");
  box-shadow: var(--shadow);
}

.hero h1,
.page-title h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2.2rem, 8vw, 4.8rem);
  line-height: 1;
}

.hero-copy,
.page-title p {
  max-width: 720px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.65;
}

.eyebrow {
  color: var(--wine);
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.counter,
.quote {
  color: var(--wine);
  font-size: 1.25rem;
  font-weight: 900;
}

.soft-panel,
.media-card,
.letter-card,
.date-card,
.category-row,
.stats-grid article {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.soft-panel {
  margin: 1.4rem 0;
  padding: clamp(1rem, 3vw, 1.5rem);
}

.form-panel {
  margin: 1.4rem 0 1.6rem;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.form-panel > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 3.25rem;
  padding: 0.9rem 1.2rem;
  color: var(--white);
  font-weight: 900;
  cursor: pointer;
  list-style: none;
  background: linear-gradient(135deg, rgba(255, 95, 143, 0.88), rgba(179, 132, 255, 0.88));
}

.form-panel > summary::-webkit-details-marker,
.mini-details > summary::-webkit-details-marker {
  display: none;
}

.form-panel > summary::before {
  content: "\2665";
}

.form-panel[open] > summary {
  border-bottom: 1px solid var(--line);
}

.form-panel > form {
  padding: clamp(1rem, 3vw, 1.4rem);
}

.center {
  text-align: center;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
}

.grid,
.letters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 240px));
  justify-content: start;
  align-items: start;
  gap: 1rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.media-card {
  position: relative;
  overflow: hidden;
}

.preview {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 3 / 2;
  background: linear-gradient(135deg, #361225, #23102b);
}

.preview-link {
  position: relative;
  color: inherit;
  overflow: hidden;
}

.preview-link:hover img,
.preview-link:hover video {
  filter: brightness(0.82);
}

.open-badge {
  position: absolute;
  right: 0.8rem;
  bottom: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  background: rgba(18, 9, 17, 0.78);
  color: var(--white);
  font-size: 0.85rem;
  font-weight: 900;
  padding: 0.35rem 0.7rem;
  backdrop-filter: blur(10px);
}

.preview img,
.preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview audio {
  width: 90%;
}

.file-icon {
  font-size: 4rem;
  color: var(--wine);
}

.card-body,
.letter-card,
.date-card {
  padding: 0.85rem;
}

.card-body h3,
.letter-card h3,
.date-card h3 {
  margin: 0 0 0.5rem;
  overflow-wrap: anywhere;
}

.card-body p,
.letter-card p,
.date-card p,
.timeline-item p {
  color: var(--muted);
  line-height: 1.5;
  white-space: pre-wrap;
}

.letter-card p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.favorite-form {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  z-index: 2;
}

.heart-button {
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  background: rgba(18, 9, 17, 0.82);
  color: var(--rose);
  border: 1px solid var(--line);
  box-shadow: none;
}

.heart-button.active {
  background: var(--wine);
  color: var(--white);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.75rem;
}

.inline-form,
.upload-form,
.filter-bar {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  margin-top: 0.75rem;
}

.inline-form > *,
.upload-form > * {
  min-width: 0;
}

.wide input {
  flex: 1;
}

.stack-form {
  display: grid;
  gap: 0.9rem;
}

.pretty-check {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
  width: fit-content;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  user-select: none;
}

.pretty-check input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pretty-check span {
  position: relative;
  width: 2.7rem;
  height: 1.45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  transition: background 0.18s ease, border-color 0.18s ease;
}

.pretty-check span::after {
  content: "";
  position: absolute;
  top: 0.19rem;
  left: 0.22rem;
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.18s ease, background 0.18s ease;
}

.pretty-check input:checked + span {
  background: linear-gradient(135deg, var(--wine), var(--plum));
  border-color: rgba(255, 126, 173, 0.48);
}

.pretty-check input:checked + span::after {
  transform: translateX(1.16rem);
  background: var(--white);
}

.category-list,
.date-list,
.timeline {
  display: grid;
  gap: 1rem;
}

.category-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.8rem;
  align-items: center;
  padding: 1rem;
}

.category-row a {
  display: grid;
  color: var(--ink);
}

.category-row span,
.heart-pill,
small {
  color: var(--muted);
}

.heart-pill {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  background: rgba(255, 126, 173, 0.14);
  padding: 0.35rem 0.65rem;
  font-weight: 800;
}

.mini-details {
  margin-top: 0.8rem;
}

.mini-details > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--rose);
  cursor: pointer;
  font-weight: 900;
  list-style: none;
  padding: 0.55rem 0.85rem;
  background: rgba(255, 255, 255, 0.05);
}

.mini-details[open] > summary {
  background: rgba(255, 126, 173, 0.13);
}

.paper {
  position: relative;
  background:
    linear-gradient(90deg, rgba(255, 126, 173, 0.1) 1px, transparent 1px) 0 0 / 26px 26px,
    rgba(42, 21, 34, 0.92);
}

.timeline {
  position: relative;
  margin-left: 1rem;
  border-left: 3px solid rgba(239, 111, 159, 0.24);
}

.timeline-item {
  position: relative;
  padding: 1rem 1rem 1rem 1.6rem;
}

.dot {
  position: absolute;
  left: -0.62rem;
  top: 1.4rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--rose);
  border: 3px solid #170d16;
}

.date-strip {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
}

.date-strip article {
  min-width: 180px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 0.9rem;
}

.top-dates-head {
  margin-top: 1.2rem;
}

.top-date-strip {
  margin-bottom: 1.2rem;
}

.date-strip span,
.date-card strong {
  display: block;
  color: var(--wine);
  margin-top: 0.35rem;
}

.date-card.today {
  background: linear-gradient(135deg, rgba(67, 25, 50, 0.96), rgba(84, 31, 63, 0.96));
  border-color: rgba(255, 126, 173, 0.45);
}

.date-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.compact-title h1 {
  font-size: clamp(2rem, 6vw, 3.6rem);
}

.back-link {
  display: inline-flex;
  margin-bottom: 1rem;
}

.viewer-panel {
  display: grid;
  place-items: center;
  width: min(860px, 100%);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(12, 7, 14, 0.58);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 280px;
}

.full-media {
  display: block;
  width: 100%;
  max-height: 56vh;
  object-fit: contain;
  background: #09050a;
}

.full-audio {
  width: min(720px, calc(100% - 2rem));
  margin: 4rem 1rem;
}

.document-view {
  text-align: center;
  padding: 3rem 1rem;
}

.letter-reader {
  max-width: 760px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: clamp(1.3rem, 4vw, 2.4rem);
}

.letter-reader p {
  color: var(--ink);
  font-size: 1.08rem;
  line-height: 1.8;
  white-space: pre-wrap;
}

.action-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
}

.stats-grid article {
  padding: 1.1rem;
}

.stats-grid strong {
  display: block;
  color: var(--wine);
  font-size: 1.9rem;
}

.table-like {
  display: grid;
  gap: 0.4rem;
}

.table-like div {
  display: grid;
  grid-template-columns: 1fr 0.7fr 0.8fr;
  gap: 0.8rem;
  border-bottom: 1px solid var(--line);
  padding: 0.65rem 0;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  padding: clamp(1.4rem, 7vw, 2.2rem);
  text-align: center;
}

.login-mark {
  display: grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  margin: 0 auto 1rem;
  border-radius: 50%;
  color: var(--white);
  background: linear-gradient(135deg, var(--wine), var(--plum));
  font-size: 2rem;
}

.alert {
  border-radius: 14px;
  background: rgba(255, 95, 143, 0.16);
  color: #ffc3d4;
  margin: 1rem 0;
  padding: 0.8rem;
}

.toast-area {
  position: fixed;
  right: 1rem;
  top: 5.2rem;
  z-index: 50;
  display: grid;
  gap: 0.75rem;
  width: min(360px, calc(100vw - 2rem));
  pointer-events: none;
}

.love-toast {
  display: grid;
  gap: 0.25rem;
  border: 1px solid rgba(255, 126, 173, 0.42);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 95, 143, 0.16), rgba(179, 132, 255, 0.14)),
    rgba(25, 11, 23, 0.94);
  color: var(--ink);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.45);
  padding: 0.9rem 1rem;
  pointer-events: auto;
  animation: toastIn 0.24s ease-out;
}

.love-toast::before {
  content: "\2665";
  color: var(--rose);
  font-size: 1.15rem;
  line-height: 1;
}

.love-toast strong {
  color: var(--white);
}

.love-toast span {
  color: var(--muted);
  line-height: 1.35;
}

.love-toast.leaving {
  animation: toastOut 0.28s ease-in forwards;
}

.tutorial-running {
  overflow-x: hidden;
}

.tutorial-focus {
  position: relative;
  z-index: 72;
  border-radius: 22px;
  outline: 2px solid rgba(255, 126, 173, 0.78);
  outline-offset: 7px;
  box-shadow:
    0 0 0 9999px rgba(4, 2, 5, 0.42),
    0 0 0 8px rgba(255, 126, 173, 0.11),
    0 0 38px rgba(255, 126, 173, 0.28);
}

.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: transparent;
  pointer-events: none;
}

.tutorial-card {
  position: fixed;
  width: min(520px, calc(100vw - 2rem));
  border: 1px solid rgba(255, 126, 173, 0.34);
  border-radius: 30px;
  background:
    radial-gradient(circle at top left, rgba(255, 126, 173, 0.2), transparent 38%),
    linear-gradient(135deg, rgba(255, 95, 143, 0.12), rgba(179, 132, 255, 0.1)),
    rgba(25, 11, 23, 0.97);
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  padding: 1.15rem 1.2rem;
  pointer-events: auto;
  backdrop-filter: blur(18px);
  animation: tutorialPop 0.2s ease-out;
}

.tutorial-progress {
  color: var(--rose);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.tutorial-card h2 {
  margin: 0.35rem 0;
}

.tutorial-card p {
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 1rem;
}

.tutorial-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.55rem;
}

.tutorial-actions button {
  box-shadow: none;
}

.tutorial-actions button:disabled {
  cursor: not-allowed;
  filter: grayscale(1);
  opacity: 0.45;
  transform: none;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-0.5rem) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(-0.35rem) scale(0.98);
  }
}

@keyframes tutorialPop {
  from {
    opacity: 0;
    transform: translateY(0.35rem) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .nav {
    order: 3;
    width: 100%;
  }

  .hero {
    min-height: 330px;
    border-radius: 22px;
  }

  .category-row,
  .table-like div,
  .inline-form,
  .upload-form,
  .filter-bar,
  .user-form,
  .date-card-head,
  .action-panel {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .category-row {
    display: grid;
  }

  .toast-area {
    top: auto;
    right: 0.75rem;
    bottom: 0.75rem;
    width: calc(100vw - 1.5rem);
  }

  .tutorial-overlay {
    background: transparent;
  }

  .tutorial-card {
    left: 0.75rem !important;
    right: 0.75rem;
    bottom: 0.75rem;
    top: auto !important;
    width: auto;
    border-radius: 24px;
  }

  .tutorial-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .tutorial-actions button[data-tutorial-action="next"] {
    grid-column: 1 / -1;
  }
}

/* Premium redesign */
body {
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 126, 173, 0.14), transparent 32%),
    radial-gradient(circle at 88% 18%, rgba(179, 132, 255, 0.18), transparent 30%),
    linear-gradient(150deg, #08050b 0%, #160b19 44%, #241022 100%);
}

.app-nav {
  width: min(1180px, calc(100% - 1.2rem));
  margin: 0.7rem auto 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(18, 11, 22, 0.62);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
}

.app-nav .brand-heart {
  width: 1.9rem;
  height: 1.9rem;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.settings-link {
  min-height: 2.65rem;
}

.premium-home,
.premium-page,
.viewer-shell,
.letter-reading-page {
  width: min(1180px, calc(100% - 1.3rem));
  margin: 0 auto;
  padding: 1.2rem 0 5rem;
  animation: pageFade 0.34s ease-out;
}

.memory-hero {
  position: relative;
  display: grid;
  align-items: end;
  min-height: min(760px, calc(100vh - 2rem));
  border-radius: 38px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(41, 16, 38, 0.72), rgba(8, 5, 11, 0.86)),
    var(--hero-image, radial-gradient(circle at 40% 25%, rgba(255, 126, 173, 0.35), transparent 35%)),
    linear-gradient(135deg, #2a1328, #0d0710);
  background-size: cover;
  background-position: center;
  box-shadow: 0 35px 90px rgba(0, 0, 0, 0.48);
  transform: translateZ(0);
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.72));
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 760px;
  padding: clamp(1.4rem, 6vw, 4rem);
}

.hero-content h1 {
  margin: 0;
  font-size: clamp(3rem, 12vw, 7rem);
  line-height: 0.92;
}

.hero-days {
  width: fit-content;
  margin: 1rem 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
  padding: 0.55rem 0.85rem;
  backdrop-filter: blur(14px);
  font-weight: 900;
}

.hero-content p {
  max-width: 590px;
  color: rgba(255, 247, 251, 0.84);
  font-size: 1.08rem;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.2rem;
}

.premium-section,
.premium-split,
.page-hero {
  margin-top: clamp(1.4rem, 4vw, 3rem);
}

.page-hero {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 34px;
  background: linear-gradient(135deg, rgba(255, 126, 173, 0.11), rgba(179, 132, 255, 0.08)), rgba(255, 255, 255, 0.04);
  padding: clamp(1.4rem, 5vw, 3rem);
}

.page-hero h1,
.premium-section h2,
.premium-split h2 {
  margin: 0;
}

.page-hero h1 {
  font-size: clamp(2.3rem, 7vw, 5rem);
  line-height: 0.95;
}

.premium-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.memory-grid,
.collection-grid,
.special-date-grid,
.envelope-grid,
.favorite-wall {
  display: grid;
  gap: 1rem;
}

.memory-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.memory-tile,
.album-item a,
.favorite-memory {
  position: relative;
  display: block;
  min-height: 260px;
  border-radius: 30px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 22px 65px rgba(0, 0, 0, 0.26);
  transition: transform 0.22s ease, filter 0.22s ease;
}

.memory-tile:hover,
.album-item a:hover,
.collection-card:hover,
.envelope-card:hover,
.favorite-memory:hover,
.memory-post:hover {
  transform: translateY(-5px);
}

.memory-tile img,
.memory-tile video,
.album-item img,
.album-item video,
.favorite-memory img,
.favorite-memory video,
.post-media img,
.post-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.memory-tile span,
.favorite-memory span,
.album-caption {
  position: absolute;
  left: 0.9rem;
  right: 0.9rem;
  bottom: 0.9rem;
  border-radius: 18px;
  background: rgba(8, 5, 11, 0.58);
  color: var(--white);
  padding: 0.7rem 0.8rem;
  backdrop-filter: blur(14px);
}

.next-date-card,
.featured-letter,
.premium-date-card,
.envelope-card,
.memory-post,
.comments-panel,
.viewer-side,
.collection-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 32px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.035));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(16px);
}

.next-date-card,
.featured-letter,
.premium-date-card {
  padding: clamp(1.2rem, 4vw, 2rem);
}

.countdown-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
  margin: 1.2rem 0;
}

.countdown-row div,
.date-number {
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.07);
  padding: 1rem;
  text-align: center;
}

.countdown-row strong,
.date-number strong {
  display: block;
  color: var(--white);
  font-size: clamp(1.8rem, 5vw, 3.4rem);
  line-height: 1;
}

.mini-timeline,
.social-feed {
  display: grid;
  gap: 1rem;
}

.mini-timeline a {
  position: relative;
  display: grid;
  gap: 0.25rem;
  border-left: 1px solid rgba(255, 126, 173, 0.35);
  color: var(--ink);
  margin-left: 0.6rem;
  padding: 0.2rem 0 1rem 1.3rem;
}

.event-dot {
  position: absolute;
  left: -0.42rem;
  top: 0.35rem;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: var(--rose);
}

.collection-grid {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.collection-card {
  overflow: hidden;
  min-height: 260px;
}

.collection-card > a,
.collection-card.static-card {
  display: grid;
  align-items: end;
  min-height: 260px;
  color: var(--white);
  padding: 1.2rem;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.72)),
    var(--cover, linear-gradient(135deg, rgba(255, 126, 173, 0.18), rgba(179, 132, 255, 0.16)));
  background-size: cover;
  background-position: center;
}

.collection-card h2,
.envelope-card h2,
.memory-post h2,
.premium-date-card h2 {
  margin: 0.35rem 0;
}

.collection-icon,
.media-chip,
.letter-stamp {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
  font-size: 0.82rem;
  font-weight: 900;
  padding: 0.35rem 0.65rem;
}

.album-masonry,
.favorite-wall {
  columns: 4 220px;
  column-gap: 1rem;
}

.album-item,
.favorite-memory,
.favorite-letter {
  display: inline-block;
  width: 100%;
  break-inside: avoid;
  margin: 0 0 1rem;
}

.album-item a {
  min-height: 280px;
}

.album-item.tall a {
  min-height: 430px;
}

.album-item.wide a {
  min-height: 330px;
}

.audio-tile {
  display: grid;
  min-height: 260px;
  place-items: center;
  color: var(--white);
  font-weight: 900;
  background: linear-gradient(135deg, rgba(255, 126, 173, 0.24), rgba(179, 132, 255, 0.2));
}

.envelope-grid {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.envelope-card {
  position: relative;
  padding: 1rem;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.035)),
    rgba(36, 16, 31, 0.78);
}

.envelope-card > a {
  display: grid;
  min-height: 270px;
  align-content: end;
  color: var(--ink);
  padding: 1rem;
}

.envelope-card::before {
  content: "";
  position: absolute;
  inset: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  pointer-events: none;
}

.social-feed {
  max-width: 760px;
  margin: 0 auto;
}

.memory-post {
  padding: 1rem;
}

.memory-post header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
}

.post-media {
  display: block;
  height: min(520px, 60vh);
  border-radius: 26px;
  overflow: hidden;
  margin: 1rem 0;
}

.special-date-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.premium-date-card.today {
  border-color: rgba(255, 126, 173, 0.45);
  background: linear-gradient(135deg, rgba(255, 126, 173, 0.14), rgba(179, 132, 255, 0.1));
}

.viewer-shell {
  width: min(1280px, calc(100% - 1.2rem));
}

.premium-viewer {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 1rem;
  align-items: stretch;
}

.viewer-side {
  padding: 1.2rem;
}

.viewer-media {
  display: grid;
  min-height: min(760px, 72vh);
  place-items: center;
  border-radius: 34px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
}

.viewer-media img,
.viewer-media video {
  width: 100%;
  height: 100%;
  max-height: 78vh;
  object-fit: contain;
}

.viewer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0;
}

.comments-panel {
  max-width: 860px;
  margin: 1rem auto 0;
  padding: 1rem;
}

.comment-form {
  display: grid;
  gap: 0.7rem;
}

.comment-list {
  display: grid;
  gap: 0.7rem;
  margin-top: 1rem;
}

.comment-list article {
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.055);
  padding: 0.85rem;
}

.letter-reading-page {
  width: min(900px, calc(100% - 1.2rem));
}

.letter-reader-premium {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 36px;
  padding: clamp(1.4rem, 6vw, 4rem);
  box-shadow: 0 35px 90px rgba(0, 0, 0, 0.28);
}

.letter-reader-premium h1 {
  margin: 0.5rem 0;
  font-size: clamp(2.4rem, 7vw, 5rem);
  line-height: 0.95;
}

.letter-body {
  margin: 2rem 0;
  color: var(--ink);
  font-size: 1.12rem;
  line-height: 1.9;
  white-space: pre-wrap;
}

@keyframes pageFade {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 860px) {
  .app-nav {
    border-radius: 28px;
    align-items: flex-start;
  }

  .nav-actions {
    width: 100%;
    justify-content: space-between;
  }

  .premium-split,
  .premium-viewer {
    grid-template-columns: 1fr;
  }

  .memory-hero {
    min-height: 76vh;
    border-radius: 28px;
  }

  .album-masonry,
  .favorite-wall {
    columns: 2 150px;
  }

  .viewer-media {
    min-height: 420px;
  }
}

/* Total experience pass: memory-first, not system-first */
:root {
  --app-max: 1440px;
  --surface: rgba(255, 255, 255, 0.055);
  --surface-strong: rgba(255, 255, 255, 0.09);
  --soft-border: rgba(255, 255, 255, 0.09);
}

body {
  background:
    radial-gradient(circle at 12% -10%, rgba(240, 138, 172, 0.16), transparent 34%),
    radial-gradient(circle at 92% 8%, rgba(157, 122, 245, 0.18), transparent 36%),
    linear-gradient(140deg, #06040a 0%, #100918 46%, #1d0d1d 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background: linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(circle at center, black, transparent 78%);
}

.sparkles {
  display: none;
}

.app-nav {
  width: min(var(--app-max), calc(100% - 2rem));
  margin-top: 1rem;
  padding: 0.55rem 0.7rem;
  border-radius: 24px;
  background: rgba(9, 6, 14, 0.58);
  border-color: rgba(255, 255, 255, 0.07);
}

.brand {
  font-weight: 900;
}

.brand-heart {
  background: rgba(255, 255, 255, 0.1);
  color: var(--rose);
}

.nav {
  flex: 1;
  justify-content: center;
}

.nav a {
  color: rgba(255, 241, 247, 0.72);
  font-weight: 780;
}

.nav a:hover {
  color: var(--white);
  background: rgba(255, 255, 255, 0.08);
}

button,
.small-button {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #fff2f7, #d9ccff);
  color: #17101a;
  box-shadow: 0 18px 36px rgba(157, 122, 245, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  font-weight: 900;
}

.secondary-link,
.secondary-button,
.ghost-button {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.11);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.premium-home,
.premium-page,
.viewer-shell,
.letter-reading-page {
  width: min(var(--app-max), calc(100% - 2rem));
  padding-top: 1rem;
}

.memory-hero {
  min-height: min(790px, calc(100vh - 7rem));
  align-items: center;
  justify-items: center;
  border-radius: 38px;
  background-position: center;
  box-shadow: 0 45px 110px rgba(0, 0, 0, 0.46);
}

.memory-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.05), transparent 30%);
  pointer-events: none;
}

.hero-overlay {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.54)),
    linear-gradient(90deg, rgba(0, 0, 0, 0.32), rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.32));
}

.hero-content {
  display: grid;
  justify-items: center;
  max-width: 820px;
  text-align: center;
  padding: clamp(1.5rem, 7vw, 5rem);
}

.hero-content h1 {
  font-size: clamp(3.6rem, 11vw, 8.5rem);
  line-height: 0.88;
  text-shadow: 0 24px 64px rgba(0, 0, 0, 0.46);
}

.hero-content p {
  max-width: 680px;
  font-size: clamp(1.02rem, 2vw, 1.3rem);
}

.hero-days {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  font-size: 1rem;
}

.hero-actions {
  justify-content: center;
}

.hero-actions .small-button {
  min-height: 3.15rem;
  padding: 0.85rem 1.25rem;
}

.premium-section,
.premium-split {
  margin-top: clamp(2rem, 5vw, 4rem);
}

.section-head {
  margin-bottom: 1rem;
}

.section-head h2 {
  font-size: clamp(1.8rem, 4vw, 3.1rem);
}

.memory-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(0.7rem, 1.8vw, 1.25rem);
}

.memory-tile {
  min-height: clamp(250px, 28vw, 430px);
  border-radius: 30px;
  background: #140b18;
}

.memory-tile:nth-child(2),
.memory-tile:nth-child(5) {
  transform: translateY(34px);
}

.memory-tile img,
.memory-tile video,
.album-item img,
.album-item video,
.favorite-memory img,
.favorite-memory video {
  transition: transform 0.45s ease, filter 0.35s ease;
}

.memory-tile:hover img,
.memory-tile:hover video,
.album-item:hover img,
.album-item:hover video,
.favorite-memory:hover img,
.favorite-memory:hover video {
  transform: scale(1.045);
  filter: saturate(1.08) contrast(1.04);
}

.memory-tile span,
.album-caption,
.favorite-memory span {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.memory-tile:hover span,
.album-item:hover .album-caption,
.favorite-memory:hover span {
  opacity: 1;
  transform: translateY(0);
}

.premium-split {
  grid-template-columns: 1.1fr 0.9fr;
}

.next-date-card,
.featured-letter {
  min-height: 360px;
  display: grid;
  align-content: center;
}

.next-date-card,
.featured-letter,
.premium-date-card,
.envelope-card,
.memory-post,
.comments-panel,
.viewer-side,
.collection-card {
  border: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.035));
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.24);
}

.album-masonry,
.favorite-wall {
  columns: 4 260px;
  column-gap: 1.05rem;
}

.album-item,
.favorite-memory,
.favorite-letter {
  margin-bottom: 1.05rem;
}

.album-item a,
.favorite-memory {
  min-height: 300px;
  border-radius: 30px;
}

.album-item.tall a {
  min-height: 460px;
}

.album-item.wide a {
  min-height: 360px;
}

.collection-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.collection-card,
.collection-card > a,
.collection-card.static-card {
  min-height: 300px;
  border-radius: 32px;
}

.envelope-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.envelope-card {
  border-radius: 30px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04)),
    rgba(37, 19, 34, 0.78);
}

.envelope-card > a {
  min-height: 300px;
}

.social-feed {
  max-width: 980px;
}

.memory-post {
  padding: clamp(1rem, 3vw, 1.5rem);
}

.post-media {
  height: min(620px, 68vh);
  border-radius: 30px;
}

.special-date-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.premium-date-card {
  min-height: 330px;
}

.viewer-shell {
  width: min(1500px, calc(100% - 2rem));
}

.premium-viewer {
  grid-template-columns: 360px 1fr;
}

.viewer-media {
  min-height: min(820px, 78vh);
}

@media (max-width: 1050px) {
  .memory-grid,
  .collection-grid,
  .envelope-grid,
  .special-date-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .memory-tile:nth-child(2),
  .memory-tile:nth-child(5) {
    transform: none;
  }
}

@media (max-width: 760px) {
  .app-nav {
    width: min(100% - 0.7rem, var(--app-max));
  }

  .premium-home,
  .premium-page,
  .viewer-shell,
  .letter-reading-page {
    width: min(100% - 0.7rem, var(--app-max));
  }

  .memory-hero {
    min-height: 78vh;
    border-radius: 30px;
  }

  .hero-content h1 {
    font-size: clamp(3.3rem, 17vw, 5.4rem);
  }

  .memory-grid {
    grid-template-columns: 1fr;
  }

  .memory-tile {
    min-height: 360px;
  }

  .premium-split,
  .premium-viewer,
  .collection-grid,
  .envelope-grid,
  .special-date-grid {
    grid-template-columns: 1fr;
  }

  .album-masonry,
  .favorite-wall {
    columns: 1;
  }

  .album-item a,
  .album-item.tall a,
  .album-item.wide a,
  .favorite-memory {
    min-height: 380px;
  }

  .memory-tile span,
  .album-caption,
  .favorite-memory span {
    opacity: 1;
    transform: none;
  }
}

/* Softer dark letters: no harsh white paper */
.love-letter-card {
  border-color: rgba(255, 154, 197, 0.14);
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 122, 180, 0.18), transparent 36%),
    linear-gradient(145deg, rgba(51, 25, 46, 0.94), rgba(28, 18, 38, 0.96));
  color: #fff4f8;
}

.love-letter-card::before {
  background:
    linear-gradient(145deg, transparent 49%, rgba(255, 139, 190, 0.12) 50%, transparent 51%),
    linear-gradient(215deg, transparent 49%, rgba(179, 132, 255, 0.11) 50%, transparent 51%);
}

.love-letter-card > a,
.love-letter-card h2 {
  color: #fff4f8;
}

.love-letter-card p {
  color: rgba(255, 244, 248, 0.72);
}

.love-letter-card small {
  color: rgba(255, 244, 248, 0.56);
}

.love-letter-card .letter-stamp {
  border-color: rgba(255, 255, 255, 0.12);
  color: #ffd6e6;
  background: rgba(255, 255, 255, 0.08);
}

.love-letter-card .heart-button {
  color: #ffd6e6;
  background: rgba(255, 255, 255, 0.1);
}

.letter-reader-premium.paper {
  border-color: rgba(255, 154, 197, 0.13);
  color: #fff4f8;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 18% 10%, rgba(255, 122, 180, 0.14), transparent 38%),
    linear-gradient(145deg, rgba(48, 25, 44, 0.98), rgba(22, 15, 31, 0.98));
  background-size: 100% 2.15rem, auto, auto;
}

.letter-reader-premium.paper::before {
  background: rgba(255, 154, 197, 0.16);
}

.letter-reader-premium .back-link,
.letter-reader-premium .eyebrow,
.letter-reader-premium small {
  color: rgba(255, 244, 248, 0.6);
}

.letter-reader-premium h1 {
  color: #fff4f8;
}

.letter-body {
  color: rgba(255, 244, 248, 0.84);
}

.letter-reader-premium .secondary-button,
.letter-reader-premium .secondary-link,
.letter-reader-premium .small-button {
  border-color: rgba(255, 255, 255, 0.12);
  color: #fff4f8;
  background: rgba(255, 255, 255, 0.08);
}

.favorite-letter.paper,
.album-masonry .favorite-letter,
.album-masonry .fav-letter-card {
  min-height: 145px;
  display: grid;
  align-content: end;
  gap: 0.28rem;
  break-inside: avoid;
  margin-bottom: 0.55rem;
  padding: 0.85rem;
  border: 1px solid rgba(255, 154, 197, 0.13);
  border-radius: 18px;
  color: #fff4f8;
  text-decoration: none;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 122, 180, 0.18), transparent 34%),
    linear-gradient(145deg, rgba(50, 25, 46, 0.95), rgba(25, 17, 36, 0.96));
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
}

.favorite-letter.paper::before,
.album-masonry .favorite-letter::before,
.album-masonry .fav-letter-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(145deg, transparent 49%, rgba(255, 139, 190, 0.1) 50%, transparent 51%),
    linear-gradient(215deg, transparent 49%, rgba(179, 132, 255, 0.1) 50%, transparent 51%);
}

.favorite-letter.paper,
.album-masonry .favorite-letter,
.album-masonry .fav-letter-card {
  position: relative;
}

.favorite-letter.paper small,
.favorite-letter.paper h2,
.favorite-letter.paper p,
.album-masonry .fav-letter-card small,
.album-masonry .fav-letter-card h2,
.album-masonry .fav-letter-card p {
  position: relative;
  z-index: 1;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.favorite-letter.paper small,
.album-masonry .fav-letter-card small {
  width: fit-content;
  max-width: 100%;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  color: #ffd6e6;
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.08);
}

.favorite-letter.paper h2,
.album-masonry .fav-letter-card h2 {
  margin: 0;
  color: #fff4f8;
  font-size: 1.05rem;
  line-height: 1.08;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.favorite-letter.paper p,
.album-masonry .fav-letter-card p {
  margin: 0;
  color: rgba(255, 244, 248, 0.68);
  font-size: 0.86rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.fav-letter-card {
  border-color: rgba(255, 154, 197, 0.13);
  color: #fff4f8;
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 122, 180, 0.15), transparent 34%),
    linear-gradient(145deg, rgba(50, 25, 46, 0.92), rgba(26, 17, 37, 0.94));
}

.fav-letter-card h2 {
  color: #fff4f8;
}

.fav-letter-card p,
.fav-letter-card small {
  color: rgba(255, 244, 248, 0.66);
}

/* New memory tools */
.memory-caption {
  color: var(--muted);
  line-height: 1.55;
  margin: 0.8rem 0;
  overflow-wrap: anywhere;
}

.reaction-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.85rem 0;
}

.reaction-row form {
  display: flex;
}

.reaction-row button {
  min-height: 2.25rem;
  padding: 0.48rem 0.72rem;
  font-size: 0.84rem;
}

.extras-grid,
.song-list,
.places-grid {
  display: grid;
  gap: 1rem;
}

.extras-grid {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.extra-card,
.song-card,
.place-card {
  display: grid;
  gap: 0.55rem;
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.032));
  color: var(--ink);
  padding: 1.1rem;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.22);
  transition: transform 0.2s ease, background 0.2s ease;
}

.extra-card:hover,
.song-card:hover,
.place-card:hover {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, 0.08);
}

.extra-card span,
.song-card small,
.place-card small {
  color: var(--rose);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.backup-card {
  border: 0;
  text-align: left;
}

.search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.7rem;
  margin-top: 1rem;
}

.song-list {
  max-width: 900px;
}

.song-card {
  grid-template-columns: 1fr;
}

.places-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.place-card h2,
.song-card strong {
  margin: 0;
}

.place-card p,
.song-card p,
.extra-card p {
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
}

@media (max-width: 650px) {
  .search-form {
    grid-template-columns: 1fr;
  }
}

.home-song-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.85rem;
}

.home-song-card {
  display: grid;
  gap: 0.35rem;
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(243, 160, 191, 0.12), rgba(157, 122, 245, 0.1)),
    rgba(255, 255, 255, 0.05);
  color: var(--ink);
  min-height: 150px;
  padding: 1rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease, background 0.2s ease;
}

.home-song-card:hover {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, 0.08);
}

.home-song-card span {
  width: fit-content;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--rose);
  font-size: 0.78rem;
  font-weight: 900;
  padding: 0.32rem 0.58rem;
}

.home-song-card strong,
.home-song-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-song-card p {
  color: var(--muted);
  line-height: 1.45;
  margin: 0;
}

/* Viewer overflow hardening */
.premium-viewer {
  min-width: 0;
}

.viewer-side,
.viewer-media {
  min-width: 0;
}

.viewer-side {
  overflow: hidden;
}

.viewer-title {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.05;
}

.viewer-meta,
.viewer-side .eyebrow,
.viewer-side .back-link {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-actions {
  max-width: 100%;
  overflow: hidden;
}

.viewer-actions a,
.viewer-actions button {
  max-width: 100%;
}

.viewer-side input,
.viewer-side select {
  min-width: 0;
}

.viewer-media img,
.viewer-media video {
  min-width: 0;
}

@media (max-width: 760px) {
  .viewer-title {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
}

/* Favorites polish */
.settings-link,
.nav-actions .ghost-button,
.nav-actions form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.45rem;
  height: 2.45rem;
  border-radius: 999px;
  padding: 0.55rem 0.82rem;
  line-height: 1;
  white-space: nowrap;
}

.nav-actions form {
  display: flex;
  margin: 0;
}

.favorites-page {
  width: min(1320px, calc(100% - 1.2rem));
}

.favorites-hero {
  margin-bottom: 1rem;
}

.favorites-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-flow: dense;
  gap: 1rem;
}

.fav-photo-card,
.fav-letter-card {
  display: grid;
  overflow: hidden;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.24);
  transition: transform 0.22s ease, background 0.22s ease;
}

.fav-photo-card:hover,
.fav-letter-card:hover {
  transform: translateY(-4px);
  background: rgba(255, 255, 255, 0.08);
}

.fav-photo-card.feature {
  grid-column: span 2;
  grid-row: span 2;
}

.fav-media {
  position: relative;
  min-height: 230px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
}

.fav-photo-card.feature .fav-media {
  min-height: 500px;
}

.fav-media img,
.fav-media video {
  display: block;
  width: 100%;
  height: 100%;
  min-height: inherit;
  object-fit: cover;
  transition: transform 0.4s ease, filter 0.3s ease;
}

.fav-photo-card:hover .fav-media img,
.fav-photo-card:hover .fav-media video {
  transform: scale(1.035);
  filter: saturate(1.08);
}

.fav-info {
  display: grid;
  gap: 0.18rem;
  padding: 0.8rem 0.9rem;
}

.fav-info strong,
.fav-info small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fav-badge {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  border-radius: 999px;
  background: rgba(10, 6, 14, 0.72);
  color: var(--white);
  font-size: 0.78rem;
  font-weight: 900;
  padding: 0.32rem 0.6rem;
  backdrop-filter: blur(12px);
}

.fav-letter-card {
  align-content: end;
  min-height: 260px;
  padding: 1rem;
  background:
    linear-gradient(145deg, rgba(255, 242, 247, 0.12), rgba(157, 122, 245, 0.08)),
    rgba(38, 20, 35, 0.72);
}

.fav-letter-card h2 {
  margin: 0.35rem 0;
}

.fav-letter-card p {
  color: var(--muted);
  line-height: 1.55;
}

.fav-letter-card span {
  width: fit-content;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
  font-size: 0.84rem;
  font-weight: 900;
  padding: 0.45rem 0.7rem;
}

@media (max-width: 1050px) {
  .favorites-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 650px) {
  .favorites-board {
    grid-template-columns: 1fr;
  }

  .fav-photo-card.feature {
    grid-column: auto;
    grid-row: auto;
  }

  .fav-photo-card.feature .fav-media,
  .fav-media {
    min-height: 330px;
  }
}

/* Memory card overflow hardening */
.large-thumbs.memory-grid {
  align-items: start;
}

.large-thumbs .memory-tile {
  position: relative;
  display: block;
  height: clamp(260px, 28vw, 420px);
  min-height: 0;
  overflow: hidden;
  border-radius: 30px;
}

.large-thumbs .memory-tile:nth-child(2),
.large-thumbs .memory-tile:nth-child(5) {
  transform: none;
}

.large-thumbs .memory-tile img,
.large-thumbs .memory-tile video {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
}

.large-thumbs .memory-tile span {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 2;
  display: block;
  max-width: calc(100% - 1.5rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 16px;
  background: rgba(8, 5, 11, 0.68);
  color: var(--white);
  padding: 0.62rem 0.75rem;
  backdrop-filter: blur(14px);
}

.memory-tile span,
.album-caption strong,
.album-caption small,
.fav-info strong,
.fav-info small,
.card-body h3,
.card-body p {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-grid,
.album-masonry,
.favorites-board {
  overflow: visible;
}

@media (max-width: 760px) {
  .large-thumbs .memory-tile {
    height: 330px;
  }
}

/* Overlap cleanup: keep photos clean and metadata below the image */
.memory-tile,
.album-item a,
.favorite-memory {
  display: grid;
  grid-template-rows: 1fr auto;
  background: rgba(255, 255, 255, 0.055);
  overflow: hidden;
}

.memory-tile img,
.memory-tile video,
.album-item img,
.album-item video,
.favorite-memory img,
.favorite-memory video {
  display: block;
  min-height: 0;
}

.memory-tile span,
.album-caption,
.favorite-memory span {
  position: static;
  left: auto;
  right: auto;
  bottom: auto;
  opacity: 1;
  transform: none;
  border-radius: 0;
  background: rgba(12, 8, 17, 0.9);
  color: var(--ink);
  padding: 0.7rem 0.8rem;
  backdrop-filter: none;
}

.album-caption {
  display: grid;
  gap: 0.18rem;
}

.album-caption strong,
.memory-tile span,
.favorite-memory span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.album-caption small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-tile:hover span,
.album-item:hover .album-caption,
.favorite-memory:hover span {
  opacity: 1;
  transform: none;
}

.album-item a,
.favorite-memory {
  min-height: 0;
}

.album-item a > img,
.album-item a > video,
.favorite-memory > img,
.favorite-memory > video {
  height: 250px;
}

.album-item.tall a > img,
.album-item.tall a > video {
  height: 360px;
}

.album-item.wide a > img,
.album-item.wide a > video {
  height: 300px;
}

.memory-tile > img,
.memory-tile > video {
  height: clamp(230px, 25vw, 380px);
}

.media-chip {
  position: absolute;
  top: 0.7rem;
  left: 0.7rem;
  z-index: 2;
  background: rgba(12, 8, 17, 0.72);
  backdrop-filter: blur(12px);
}

.favorite-form {
  z-index: 4;
}

.heart-button {
  backdrop-filter: blur(12px);
}

.post-media {
  position: relative;
  overflow: hidden;
}

.memory-post header {
  align-items: flex-start;
}

.memory-post header span {
  flex-shrink: 0;
  max-width: 44%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .memory-tile > img,
  .memory-tile > video,
  .album-item a > img,
  .album-item a > video,
  .album-item.tall a > img,
  .album-item.tall a > video,
  .album-item.wide a > img,
  .album-item.wide a > video,
  .favorite-memory > img,
  .favorite-memory > video {
    height: 310px;
  }

  .memory-post header {
    display: grid;
  }

  .memory-post header span {
    max-width: 100%;
  }
}

/* Visual refinement: calmer, smaller, more premium */
:root {
  --rose: #f3a0bf;
  --plum: #9d7af5;
  --wine: #f08aac;
  --ink: #fff1f7;
  --muted: #cbb1c1;
  --line: rgba(255, 255, 255, 0.11);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

body {
  background:
    radial-gradient(circle at 22% -10%, rgba(157, 122, 245, 0.16), transparent 35%),
    radial-gradient(circle at 82% 8%, rgba(243, 160, 191, 0.12), transparent 34%),
    linear-gradient(150deg, #08060d 0%, #120b18 48%, #1b0f1d 100%);
}

button,
.small-button {
  min-height: 2.45rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(135deg, rgba(243, 160, 191, 0.95), rgba(157, 122, 245, 0.9));
  color: #170c17;
  font-size: 0.92rem;
  font-weight: 850;
  padding: 0.65rem 0.95rem;
  box-shadow: 0 10px 24px rgba(157, 122, 245, 0.16);
}

.ghost-button,
.danger-button,
.secondary-button,
.secondary-link {
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.13);
  box-shadow: none;
}

.secondary-link:hover,
.ghost-button:hover,
.secondary-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.app-nav {
  width: min(1060px, calc(100% - 1rem));
  margin-top: 0.55rem;
  padding: 0.55rem 0.7rem;
  background: rgba(12, 8, 17, 0.72);
}

.nav {
  gap: 0.18rem;
}

.nav a {
  font-size: 0.92rem;
  padding: 0.48rem 0.65rem;
}

.nav-actions {
  gap: 0.35rem;
}

.premium-home,
.premium-page,
.viewer-shell,
.letter-reading-page {
  width: min(1060px, calc(100% - 1rem));
  padding-top: 0.85rem;
}

.memory-hero {
  min-height: min(560px, 68vh);
  border-radius: 30px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.36);
}

.hero-content {
  max-width: 620px;
  padding: clamp(1.35rem, 5vw, 3rem);
}

.hero-content h1 {
  font-size: clamp(2.55rem, 8vw, 5.2rem);
  letter-spacing: 0;
}

.hero-days {
  font-size: 0.92rem;
  margin: 0.8rem 0;
}

.hero-content p {
  max-width: 520px;
  font-size: 1rem;
}

.page-hero {
  border-radius: 26px;
  padding: clamp(1.15rem, 4vw, 2.2rem);
}

.page-hero h1 {
  font-size: clamp(2rem, 5.8vw, 3.9rem);
}

.premium-section,
.premium-split,
.page-hero {
  margin-top: 1.15rem;
}

.premium-split {
  gap: 0.8rem;
}

.memory-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.memory-tile,
.album-item a,
.favorite-memory {
  min-height: 170px;
  border-radius: 22px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
}

.memory-tile:hover,
.album-item a:hover,
.collection-card:hover,
.envelope-card:hover,
.favorite-memory:hover,
.memory-post:hover {
  transform: translateY(-3px);
}

.memory-tile span,
.favorite-memory span,
.album-caption {
  left: 0.55rem;
  right: 0.55rem;
  bottom: 0.55rem;
  border-radius: 14px;
  font-size: 0.82rem;
  padding: 0.48rem 0.58rem;
}

.album-masonry,
.favorite-wall {
  columns: 5 150px;
  column-gap: 0.75rem;
}

.album-item,
.favorite-memory,
.favorite-letter {
  margin-bottom: 0.75rem;
}

.album-item a {
  min-height: 185px;
}

.album-item.tall a {
  min-height: 250px;
}

.album-item.wide a {
  min-height: 215px;
}

.favorite-memory.large {
  min-height: 230px;
}

.collection-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.8rem;
}

.collection-card,
.collection-card > a,
.collection-card.static-card {
  min-height: 190px;
  border-radius: 24px;
}

.collection-card > a,
.collection-card.static-card {
  padding: 1rem;
}

.next-date-card,
.featured-letter,
.premium-date-card,
.envelope-card,
.memory-post,
.comments-panel,
.viewer-side,
.collection-card {
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.028));
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.23);
}

.next-date-card,
.featured-letter,
.premium-date-card {
  padding: 1.15rem;
}

.countdown-row {
  gap: 0.5rem;
}

.countdown-row div,
.date-number {
  border-radius: 18px;
  padding: 0.75rem;
}

.countdown-row strong,
.date-number strong {
  font-size: clamp(1.45rem, 4vw, 2.45rem);
}

.envelope-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.8rem;
}

.envelope-card {
  padding: 0.75rem;
}

.envelope-card > a {
  min-height: 205px;
  padding: 0.85rem;
}

.special-date-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.8rem;
}

.post-media {
  height: min(360px, 46vh);
  border-radius: 20px;
}

.viewer-media {
  min-height: min(620px, 66vh);
  border-radius: 26px;
}

.viewer-side {
  padding: 1rem;
}

.letter-reader-premium {
  border-radius: 28px;
  padding: clamp(1.2rem, 5vw, 3rem);
}

.letter-reader-premium h1 {
  font-size: clamp(2rem, 5.8vw, 3.9rem);
}

@media (max-width: 860px) {
  .app-nav {
    border-radius: 22px;
  }

  .nav-actions {
    gap: 0.45rem;
  }

  .memory-hero {
    min-height: 62vh;
    border-radius: 24px;
  }

  .premium-split {
    grid-template-columns: 1fr;
  }

  .album-masonry,
  .favorite-wall {
    columns: 2 135px;
  }

  .memory-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Compact pass: keep memories visual without oversized cards */
.premium-home,
.premium-page,
.viewer-shell,
.letter-reading-page {
  width: min(1180px, calc(100% - 1rem));
}

.premium-section,
.premium-split,
.page-hero {
  margin-top: 0.85rem;
}

.section-head {
  margin-bottom: 0.65rem;
}

.memory-hero {
  min-height: min(440px, 56vh);
  border-radius: 24px;
}

.hero-content {
  padding: clamp(1.05rem, 4vw, 2.25rem);
}

.hero-content h1 {
  font-size: clamp(2.1rem, 6.5vw, 4.25rem);
}

.page-hero.compact {
  padding: clamp(0.95rem, 3vw, 1.55rem);
}

.page-hero.compact h1 {
  font-size: clamp(1.7rem, 4.5vw, 3rem);
}

.memory-grid,
.large-thumbs.memory-grid {
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 0.55rem;
}

.memory-tile,
.large-thumbs .memory-tile {
  min-height: 136px;
  max-height: 180px;
  border-radius: 18px;
}

.large-thumbs .memory-tile:nth-child(2),
.large-thumbs .memory-tile:nth-child(5) {
  min-height: 150px;
  grid-row: auto;
}

.memory-tile > img,
.memory-tile > video,
.large-thumbs .memory-tile img,
.large-thumbs .memory-tile video {
  height: 100%;
  object-fit: cover;
}

.memory-tile span,
.large-thumbs .memory-tile span,
.favorite-memory span,
.album-caption,
.fav-info {
  max-width: calc(100% - 0.7rem);
  left: 0.35rem;
  right: 0.35rem;
  bottom: 0.35rem;
  padding: 0.38rem 0.48rem;
  border-radius: 12px;
  font-size: 0.75rem;
  line-height: 1.2;
}

.memory-tile span,
.album-caption strong,
.album-caption small,
.fav-info strong,
.fav-info small,
.favorite-memory span,
.home-song-card strong,
.home-song-card small,
.song-card strong,
.song-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.album-masonry,
.favorite-wall {
  columns: 6 130px;
  column-gap: 0.55rem;
}

.album-item,
.favorite-memory,
.favorite-letter {
  margin-bottom: 0.55rem;
}

.album-item a,
.favorite-memory {
  min-height: 145px;
  border-radius: 18px;
}

.album-item.tall a,
.album-item.wide a,
.favorite-memory.large {
  min-height: 170px;
}

.album-item a > img,
.album-item a > video,
.favorite-memory > img,
.favorite-memory > video {
  height: 100%;
  object-fit: cover;
}

.collection-grid,
.envelope-grid,
.special-date-grid,
.extras-grid,
.places-grid,
.home-song-row {
  gap: 0.65rem;
}

.collection-grid {
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
}

.collection-card,
.collection-card > a,
.collection-card.static-card {
  min-height: 150px;
  border-radius: 18px;
}

.collection-card > a,
.collection-card.static-card,
.extra-card,
.song-card,
.place-card {
  padding: 0.85rem;
}

.envelope-grid {
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
}

.envelope-card {
  border-radius: 18px;
  padding: 0.58rem;
}

.envelope-card > a {
  min-height: 155px;
  padding: 0.75rem;
}

.envelope-card h2,
.fav-letter-card h2,
.premium-date-card h2,
.memory-post h2,
.memory-post h3,
.collection-card h2 {
  font-size: clamp(1rem, 2.3vw, 1.35rem);
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.envelope-card p,
.fav-letter-card p,
.featured-letter p,
.memory-post p {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.next-date-card,
.featured-letter,
.premium-date-card,
.memory-post,
.comments-panel,
.viewer-side,
.collection-card,
.extra-card,
.song-card,
.place-card,
.home-song-card {
  border-radius: 18px;
  padding: 0.9rem;
}

.premium-split {
  gap: 0.65rem;
}

.countdown-row {
  gap: 0.35rem;
}

.countdown-row div,
.date-number {
  padding: 0.55rem;
  border-radius: 14px;
}

.countdown-row strong,
.date-number strong {
  font-size: clamp(1.2rem, 3vw, 1.9rem);
}

.home-song-row {
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
}

.home-song-card {
  min-height: 112px;
}

.favorites-board {
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 0.6rem;
}

.fav-photo-card,
.fav-letter-card {
  border-radius: 18px;
  min-height: 0;
}

.fav-photo-card.feature {
  grid-column: auto;
  grid-row: auto;
}

.fav-media,
.fav-photo-card.feature .fav-media {
  height: 145px;
}

.fav-letter-card {
  padding: 0.9rem;
  min-height: 155px;
}

.social-feed {
  display: grid;
  gap: 0.75rem;
}

.memory-post {
  padding: 0.9rem;
}

.post-media {
  height: min(260px, 36vh);
  border-radius: 16px;
}

.special-date-grid {
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
}

.premium-date-card {
  min-height: 0;
}

@media (max-width: 860px) {
  .premium-home,
  .premium-page,
  .viewer-shell,
  .letter-reading-page {
    width: min(100% - 0.75rem, 1180px);
    padding-top: 0.55rem;
  }

  .memory-hero {
    min-height: 360px;
    border-radius: 20px;
  }

  .memory-grid,
  .large-thumbs.memory-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .memory-tile,
  .large-thumbs .memory-tile,
  .large-thumbs .memory-tile:nth-child(2),
  .large-thumbs .memory-tile:nth-child(5) {
    min-height: 126px;
    max-height: 150px;
  }

  .album-masonry,
  .favorite-wall {
    columns: 2 118px;
    column-gap: 0.5rem;
  }

  .album-item a,
  .album-item.tall a,
  .album-item.wide a,
  .favorite-memory,
  .favorite-memory.large {
    min-height: 132px;
  }

  .collection-grid,
  .envelope-grid,
  .special-date-grid,
  .home-song-row,
  .extras-grid,
  .places-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .collection-card,
  .collection-card > a,
  .collection-card.static-card {
    min-height: 130px;
  }

  .envelope-card > a {
    min-height: 142px;
  }

  .favorites-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .fav-media,
  .fav-photo-card.feature .fav-media {
    height: 132px;
  }

  .fav-letter-card {
    min-height: 140px;
  }

  .post-media {
    height: 210px;
  }

  .premium-split {
    gap: 0.55rem;
  }
}

@media (max-width: 420px) {
  .memory-tile,
  .large-thumbs .memory-tile,
  .large-thumbs .memory-tile:nth-child(2),
  .large-thumbs .memory-tile:nth-child(5) {
    min-height: 112px;
  }

  .album-item a,
  .album-item.tall a,
  .album-item.wide a,
  .favorite-memory,
  .favorite-memory.large {
    min-height: 118px;
  }

  .collection-card,
  .collection-card > a,
  .collection-card.static-card,
  .envelope-card > a,
  .home-song-card,
  .extra-card,
  .song-card,
  .place-card {
    min-height: 118px;
  }

  .fav-media,
  .fav-photo-card.feature .fav-media {
    height: 118px;
  }

  .next-date-card,
  .featured-letter,
  .premium-date-card,
  .memory-post,
  .home-song-card,
  .fav-letter-card {
    padding: 0.75rem;
  }
}

/* Final organization pass: cleaner app-like rhythm */
body {
  overflow-x: hidden;
}

.app-nav {
  position: sticky;
  top: 0.5rem;
  z-index: 40;
  align-items: center;
  gap: 0.65rem;
}

.brand,
.nav a,
.ghost-button,
.small-button,
.secondary-button,
.secondary-link,
.danger-button,
button {
  white-space: nowrap;
}

.nav {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar {
  display: none;
}

.nav-actions {
  flex: 0 0 auto;
}

.premium-home,
.premium-page {
  display: grid;
  gap: 0.85rem;
}

.premium-section,
.premium-split,
.form-panel,
.all-memories-panel,
.page-hero {
  margin-top: 0;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 0.8rem;
}

.section-head h2,
.page-hero h1,
.viewer-title,
.letter-reader-premium h1 {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.section-head a {
  flex: 0 0 auto;
}

.page-hero.compact {
  min-height: 0;
  display: grid;
  gap: 0.35rem;
}

.page-hero.compact p {
  max-width: 760px;
}

.form-panel,
.premium-create,
.mini-details,
.all-memories-panel {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.form-panel > summary,
.mini-details > summary,
.all-memories-panel > summary {
  user-select: none;
}

.form-panel > form,
.upload-form,
.stack-form,
.inline-form.wide,
.comment-form {
  gap: 0.65rem;
}

.form-panel input,
.form-panel select,
.form-panel textarea,
.comment-form textarea,
.viewer-side input,
.viewer-side select,
.viewer-side textarea {
  min-width: 0;
  border-radius: 14px;
}

.upload-form {
  grid-template-columns: minmax(160px, 0.8fr) minmax(180px, 1fr) minmax(220px, 1.2fr) auto;
  align-items: end;
}

.upload-form button {
  min-height: 44px;
}

.collection-grid,
.envelope-grid,
.special-date-grid,
.extras-grid,
.places-grid,
.home-song-row,
.favorites-board {
  align-items: stretch;
}

.collection-card,
.memory-collection-card,
.envelope-card,
.premium-date-card,
.extra-card,
.song-card,
.place-card,
.home-song-card,
.fav-photo-card,
.fav-letter-card,
.memory-post,
.next-date-card,
.featured-letter {
  min-width: 0;
  overflow: hidden;
}

.collection-card h2,
.envelope-card h2,
.premium-date-card h2,
.fav-letter-card h2,
.memory-post h2,
.memory-post h3,
.home-song-card strong,
.song-card strong,
.place-card h2,
.extra-card h2 {
  margin: 0;
}

.collection-card p,
.envelope-card p,
.premium-date-card p,
.fav-letter-card p,
.memory-post p,
.home-song-card p,
.song-card p,
.place-card p,
.extra-card p {
  margin-block: 0.25rem;
}

.premium-viewer {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 0.75rem;
  align-items: stretch;
}

.viewer-media {
  order: 1;
  min-height: min(560px, 68vh);
  max-height: 72vh;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.28);
}

.viewer-side {
  order: 2;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-width: 0;
  max-height: 72vh;
  overflow-y: auto;
}

.viewer-title {
  font-size: clamp(1.35rem, 3vw, 2.1rem);
  line-height: 1.05;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.viewer-meta {
  margin: 0;
}

.viewer-actions,
.reaction-row,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.viewer-actions form,
.reaction-row form,
.actions form,
.nav-actions form {
  margin: 0;
}

.reaction-row button,
.viewer-actions a,
.viewer-actions button {
  min-height: 38px;
}

.comments-panel {
  margin-top: 0;
}

.comment-list {
  display: grid;
  gap: 0.55rem;
}

.comment-list article {
  border-radius: 16px;
  padding: 0.8rem;
  background: rgba(255, 255, 255, 0.045);
}

.mini-details .stack-form {
  margin-top: 0.55rem;
}

@media (max-width: 980px) {
  .premium-viewer {
    grid-template-columns: 1fr;
  }

  .viewer-media,
  .viewer-side {
    max-height: none;
  }

  .viewer-media {
    min-height: 360px;
    max-height: none;
  }

  .upload-form {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 680px) {
  .app-nav {
    top: 0.35rem;
    width: min(100% - 0.5rem, 1180px);
    padding: 0.45rem;
    border-radius: 18px;
  }

  .brand span:last-child {
    display: none;
  }

  .nav a,
  .ghost-button {
    font-size: 0.82rem;
    padding: 0.42rem 0.56rem;
  }

  .nav-actions {
    gap: 0.25rem;
  }

  .tutorial-start {
    display: none;
  }

  .section-head {
    align-items: start;
  }

  .section-head a {
    font-size: 0.84rem;
  }

  .upload-form,
  .inline-form.wide {
    grid-template-columns: 1fr;
  }

  .viewer-media {
    min-height: 280px;
    border-radius: 18px;
  }

  .viewer-side {
    border-radius: 18px;
  }

  .viewer-actions a,
  .viewer-actions button,
  .reaction-row button {
    flex: 1 1 auto;
    justify-content: center;
  }

  .comments-panel .section-head {
    display: block;
  }
}

/* Letters redesign */
.letter-composer {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 22px;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 126, 177, 0.18), transparent 34%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.035));
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.24);
}

.letter-composer > summary {
  min-height: 68px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.8rem;
  cursor: pointer;
  list-style: none;
  padding: 0.95rem 1.1rem;
}

.letter-composer > summary::-webkit-details-marker {
  display: none;
}

.letter-composer > summary::after {
  content: "Abrir";
  padding: 0.48rem 0.78rem;
  border-radius: 999px;
  color: #fff;
  font-weight: 800;
  font-size: 0.82rem;
  background: linear-gradient(135deg, rgba(255, 102, 169, 0.92), rgba(139, 92, 246, 0.86));
  box-shadow: 0 10px 24px rgba(255, 86, 154, 0.22);
}

.letter-composer[open] > summary::after {
  content: "Fechar";
}

.letter-composer > summary span,
.letter-composer > summary small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.letter-composer > summary span {
  font-size: 1.1rem;
  font-weight: 900;
}

.letter-composer > summary small {
  grid-column: 1;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.86rem;
}

.letter-form {
  display: grid;
  gap: 0.75rem;
  padding: 0 1.1rem 1.1rem;
}

.letter-form-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(145px, 0.7fr) minmax(150px, 0.85fr);
  gap: 0.65rem;
}

.letter-form label {
  min-width: 0;
  display: grid;
  gap: 0.35rem;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.86rem;
}

.letter-form input,
.letter-form select,
.letter-form textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  background: rgba(11, 8, 18, 0.48);
}

.letter-form textarea {
  min-height: 210px;
  line-height: 1.65;
  resize: vertical;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    rgba(11, 8, 18, 0.48);
  background-size: 100% 2.05rem;
}

.letter-form button {
  justify-self: start;
  min-height: 44px;
  border-radius: 999px;
  padding-inline: 1rem;
}

.envelope-grid {
  align-items: stretch;
}

.love-letter-card {
  position: relative;
  min-height: 188px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background:
    linear-gradient(145deg, rgba(255, 247, 251, 0.98), rgba(255, 223, 237, 0.94));
  color: #2b1622;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.26);
}

.love-letter-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(145deg, transparent 49%, rgba(222, 99, 145, 0.18) 50%, transparent 51%),
    linear-gradient(215deg, transparent 49%, rgba(140, 81, 180, 0.14) 50%, transparent 51%);
  opacity: 0.9;
}

.love-letter-card > a {
  position: relative;
  min-height: 168px;
  display: grid;
  align-content: start;
  gap: 0.45rem;
  padding: 1rem;
  color: #2b1622;
  text-decoration: none;
}

.love-letter-card .letter-stamp {
  width: fit-content;
  max-width: 100%;
  border: 1px solid rgba(151, 72, 109, 0.18);
  color: #8b3159;
  background: rgba(255, 255, 255, 0.68);
}

.love-letter-card h2 {
  color: #2b1622;
  font-size: clamp(1.05rem, 2.3vw, 1.45rem);
  line-height: 1.05;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.love-letter-card p {
  color: rgba(43, 22, 34, 0.78);
  line-height: 1.5;
  -webkit-line-clamp: 3;
}

.love-letter-card small {
  align-self: end;
  color: rgba(43, 22, 34, 0.55);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.love-letter-card .favorite-form {
  top: 0.55rem;
  right: 0.55rem;
  z-index: 2;
}

.love-letter-card .heart-button {
  background: rgba(255, 255, 255, 0.72);
  color: #9b315e;
  box-shadow: 0 8px 18px rgba(103, 36, 70, 0.18);
}

.love-letter-card .actions {
  position: relative;
  z-index: 2;
  padding: 0 0.75rem 0.75rem;
}

.love-letter-card .actions .small-button,
.love-letter-card .actions .danger-button {
  min-height: 34px;
  font-size: 0.78rem;
}

.empty-letter-state {
  min-height: 188px;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 0.35rem;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 20px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.035);
}

.empty-letter-state span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 103, 166, 0.22);
}

.letter-reading-page {
  width: min(920px, calc(100% - 1rem));
  gap: 0.85rem;
}

.letter-reader-premium.paper {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(110, 51, 83, 0.16);
  color: #2b1622;
  background:
    linear-gradient(rgba(117, 67, 91, 0.045) 1px, transparent 1px),
    linear-gradient(145deg, #fff8fb, #ffe7f0 52%, #fff9fc);
  background-size: 100% 2.15rem, auto;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.34);
}

.letter-reader-premium.paper::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: clamp(1.25rem, 4vw, 3rem);
  width: 1px;
  background: rgba(207, 91, 132, 0.2);
}

.letter-reader-premium .back-link,
.letter-reader-premium .eyebrow,
.letter-reader-premium small {
  position: relative;
  color: rgba(43, 22, 34, 0.58);
}

.letter-reader-premium h1 {
  position: relative;
  max-width: 760px;
  color: #2b1622;
  font-size: clamp(2rem, 6vw, 4rem);
  line-height: 0.98;
}

.letter-body {
  position: relative;
  max-width: 760px;
  margin-top: 1.15rem;
  color: rgba(43, 22, 34, 0.88);
  font-size: clamp(1.03rem, 2vw, 1.22rem);
  line-height: 1.9;
  white-space: pre-wrap;
}

.letter-reader-premium .reaction-row,
.letter-reader-premium .viewer-actions {
  position: relative;
}

.letter-reader-premium .secondary-button,
.letter-reader-premium .secondary-link,
.letter-reader-premium .small-button {
  border-color: rgba(110, 51, 83, 0.14);
  color: #53243a;
  background: rgba(255, 255, 255, 0.58);
}

.letter-reader-premium .danger-button {
  color: #fff;
}

@media (max-width: 760px) {
  .letter-composer > summary {
    min-height: 60px;
    padding: 0.85rem;
  }

  .letter-composer > summary small {
    display: none;
  }

  .letter-form {
    padding: 0 0.85rem 0.85rem;
  }

  .letter-form-row {
    grid-template-columns: 1fr;
  }

  .letter-form textarea {
    min-height: 180px;
  }

  .love-letter-card,
  .love-letter-card > a {
    min-height: 154px;
  }

  .letter-reader-premium.paper {
    border-radius: 22px;
    padding: 1.35rem 1rem;
  }

  .letter-reader-premium.paper::before {
    display: none;
  }

  .letter-body {
    line-height: 1.75;
  }
}

.all-memories-panel {
  margin-top: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.035);
  overflow: hidden;
}

.all-memories-panel > summary {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  cursor: pointer;
  list-style: none;
  padding: 0.85rem 1rem;
  color: #fff;
}

.all-memories-panel > summary::-webkit-details-marker {
  display: none;
}

.all-memories-panel > summary::after {
  content: "Abrir";
  flex: 0 0 auto;
  padding: 0.42rem 0.7rem;
  border-radius: 999px;
  color: #fff;
  font-size: 0.8rem;
  background: linear-gradient(135deg, rgba(255, 111, 174, 0.85), rgba(126, 88, 255, 0.78));
}

.all-memories-panel[open] > summary::after {
  content: "Fechar";
}

.all-memories-panel > summary span,
.all-memories-panel > summary small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.all-memories-panel > summary span {
  font-weight: 800;
}

.all-memories-panel > summary small {
  margin-left: auto;
  color: rgba(255, 255, 255, 0.62);
}

.all-memories-panel .album-masonry {
  padding: 0 0.75rem 0.75rem;
}

@media (max-width: 520px) {
  .all-memories-panel > summary {
    min-height: 52px;
    padding: 0.75rem;
  }

  .all-memories-panel > summary small {
    display: none;
  }
}

/* Chat and profile photos */
.chat-page {
  width: min(920px, calc(100% - 2rem));
}

.chat-panel {
  display: grid;
  grid-template-rows: minmax(360px, 62vh) auto;
  overflow: hidden;
  border: 1px solid rgba(255, 126, 173, 0.22);
  border-radius: 24px;
  background:
    radial-gradient(circle at top left, rgba(255, 126, 173, 0.1), transparent 34%),
    rgba(24, 12, 25, 0.82);
  box-shadow: var(--shadow);
}

.chat-messages {
  display: grid;
  align-content: start;
  gap: 0.75rem;
  overflow-y: auto;
  padding: clamp(0.85rem, 3vw, 1.2rem);
  scroll-behavior: smooth;
}

.chat-message {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.65rem;
  max-width: min(680px, 92%);
  justify-self: start;
}

.chat-message.mine {
  grid-template-columns: minmax(0, 1fr) auto;
  justify-self: end;
}

.chat-message.mine .profile-avatar {
  order: 2;
}

.chat-message > div:last-child {
  display: grid;
  gap: 0.35rem;
  border: 1px solid rgba(255, 126, 173, 0.18);
  border-radius: 18px 18px 18px 6px;
  background: rgba(255, 255, 255, 0.07);
  padding: 0.72rem 0.82rem;
}

.chat-message.mine > div:last-child {
  border-radius: 18px 18px 6px 18px;
  background: linear-gradient(135deg, rgba(255, 95, 143, 0.28), rgba(157, 124, 255, 0.22));
}

.chat-message header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  align-items: baseline;
  justify-content: space-between;
}

.chat-message p {
  margin: 0;
  color: var(--ink);
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: end;
  border-top: 1px solid rgba(255, 126, 173, 0.18);
  background: rgba(10, 6, 13, 0.45);
  padding: 0.85rem;
}

.chat-form textarea {
  min-height: 54px;
  max-height: 140px;
}

.profile-editor {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.85rem;
  align-items: center;
  padding: 0.9rem;
  border-bottom: 1px solid rgba(255, 126, 173, 0.16);
}

.profile-editor.compact {
  margin: 0.75rem 0 0;
  border: 1px solid rgba(255, 126, 173, 0.16);
  border-radius: 18px 18px 0 0;
  border-bottom: 0;
  background: rgba(255, 255, 255, 0.035);
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  overflow: hidden;
  border: 1px solid rgba(255, 126, 173, 0.28);
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255, 95, 143, 0.28), rgba(157, 124, 255, 0.24));
  color: #fff;
  font-weight: 900;
}

.profile-avatar.large {
  width: 82px;
  height: 82px;
  font-size: 1.8rem;
}

.profile-avatar.small {
  width: 38px;
  height: 38px;
  font-size: 0.92rem;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: center;
}

.avatar-form input[type="file"] {
  min-height: 42px;
  padding: 0.55rem;
}

@media (max-width: 620px) {
  .chat-page {
    width: 100%;
    padding-inline: 0.55rem;
  }

  .chat-panel {
    grid-template-rows: minmax(330px, calc(100vh - 260px)) auto;
    border-radius: 18px;
  }

  .chat-message {
    max-width: 100%;
  }

  .chat-form,
  .profile-editor,
  .avatar-form {
    grid-template-columns: 1fr;
  }
}

.collection-manage {
  position: relative;
  z-index: 2;
  margin: 0 0.65rem 0.65rem;
}

.collection-manage > summary {
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.075);
}

.collection-manage form {
  margin-top: 0.5rem;
}

.danger-zone {
  border-color: rgba(255, 95, 135, 0.16);
}

.category-manage-panel {
  display: grid;
  gap: 0.65rem;
  padding: 0 1rem 1rem;
}

.category-manage-panel form {
  margin: 0;
}

.category-manage-panel .danger-button {
  width: fit-content;
}

@media (max-width: 520px) {
  .category-manage-panel {
    padding: 0 0.75rem 0.75rem;
  }

  .category-manage-panel .danger-button {
    width: 100%;
  }
}

.category-composer {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 122, 180, 0.13), transparent 34%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025));
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.2);
}

.category-composer > summary {
  min-height: 58px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.7rem;
  cursor: pointer;
  list-style: none;
  padding: 0.85rem 1rem;
}

.category-composer > summary::-webkit-details-marker {
  display: none;
}

.category-composer > summary::after {
  content: "Criar";
  padding: 0.42rem 0.7rem;
  border-radius: 999px;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, rgba(255, 111, 174, 0.85), rgba(126, 88, 255, 0.78));
}

.category-composer[open] > summary::after {
  content: "Fechar";
}

.category-composer span,
.category-composer small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-composer span {
  font-weight: 900;
}

.category-composer small {
  grid-column: 1;
  color: rgba(255, 255, 255, 0.62);
}

.category-composer form {
  padding: 0 1rem 1rem;
}

@media (max-width: 520px) {
  .category-composer > summary {
    min-height: 52px;
    padding: 0.75rem;
  }

  .category-composer small {
    display: none;
  }

  .category-composer form {
    padding: 0 0.75rem 0.75rem;
  }
}

/* Collections as memory folders */
.memory-collection-card {
  overflow: hidden;
  min-height: 235px;
  padding: 0;
}

.memory-collection-card .collection-cover {
  min-height: 235px;
  padding: 0;
  grid-template-rows: 1fr auto;
  gap: 0;
  overflow: hidden;
}

.collection-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 0.18rem;
  height: 142px;
  padding: 0.35rem;
}

.collection-preview-grid div,
.collection-preview-grid.empty {
  min-width: 0;
  overflow: hidden;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.08);
}

.collection-preview-grid img,
.collection-preview-grid video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.collection-preview-grid.empty {
  display: grid;
  place-items: center;
  grid-column: 1 / -1;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.82rem;
}

.memory-collection-card .collection-cover > div:last-child {
  padding: 0.85rem;
  background: linear-gradient(180deg, rgba(18, 12, 28, 0.7), rgba(18, 12, 28, 0.94));
}

.memory-collection-card h2,
.memory-collection-card p,
.memory-collection-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.album-collections {
  margin-top: 0.8rem;
}

.album-category-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(165px, 210px);
  gap: 0.6rem;
  overflow-x: auto;
  padding: 0.1rem 0 0.45rem;
  scrollbar-width: thin;
}

.album-category-card {
  min-height: 132px;
  display: grid;
  align-content: end;
  gap: 0.18rem;
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  padding: 0.8rem;
  color: #fff;
  text-decoration: none;
  background:
    linear-gradient(180deg, rgba(12, 8, 18, 0.12), rgba(12, 8, 18, 0.9)),
    var(--cover),
    linear-gradient(135deg, rgba(255, 143, 190, 0.23), rgba(124, 74, 255, 0.2));
  background-size: cover;
  background-position: center;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.album-category-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.3);
}

.album-category-card span,
.album-category-card strong,
.album-category-card small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  position: relative;
  z-index: 1;
}

.album-category-card span {
  width: fit-content;
  max-width: 100%;
  padding: 0.24rem 0.48rem;
  border-radius: 999px;
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
}

.album-category-card strong {
  font-size: 1.02rem;
}

.album-category-card small {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.76rem;
}

@media (max-width: 860px) {
  .memory-collection-card,
  .memory-collection-card .collection-cover {
    min-height: 202px;
  }

  .collection-preview-grid {
    height: 118px;
  }

  .album-category-strip {
    grid-auto-columns: minmax(140px, 165px);
    gap: 0.5rem;
  }

  .album-category-card {
    min-height: 116px;
    border-radius: 16px;
    padding: 0.7rem;
  }
}

@media (max-width: 420px) {
  .memory-collection-card,
  .memory-collection-card .collection-cover {
    min-height: 190px;
  }

  .collection-preview-grid {
    height: 108px;
    padding: 0.3rem;
  }
}

/* Mobile app layout pass */
@media (max-width: 720px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    font-size: 15px;
  }

  .sparkles {
    opacity: 0.45;
  }

  .app-nav {
    position: sticky;
    top: 0;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0.45rem 0.5rem;
    border-radius: 0 0 18px 18px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.45rem;
    background: rgba(12, 8, 18, 0.92);
    backdrop-filter: blur(18px);
  }

  .brand {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    padding: 0;
    border-radius: 999px;
  }

  .brand span:last-child {
    display: none;
  }

  .brand-heart {
    margin: 0;
  }

  .nav {
    min-width: 0;
    display: flex;
    gap: 0.32rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    padding: 0.1rem 0.05rem;
  }

  .nav a {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-height: 36px;
    padding: 0.48rem 0.62rem;
    border-radius: 999px;
    font-size: 0.82rem;
  }

  .nav-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
  }

  .tutorial-start {
    display: none;
  }

  .settings-link,
  .nav-actions form button {
    min-height: 36px;
    padding: 0.45rem 0.58rem;
    border-radius: 999px;
    font-size: 0.78rem;
  }

  .premium-home,
  .premium-page,
  .viewer-shell,
  .letter-reading-page {
    width: 100%;
    max-width: 100%;
    padding: 0.55rem 0.55rem 1.2rem;
    gap: 0.7rem;
  }

  .page-hero,
  .page-hero.compact,
  .memory-hero,
  .premium-section,
  .premium-split,
  .form-panel,
  .premium-create,
  .category-composer,
  .letter-composer,
  .all-memories-panel,
  .comments-panel,
  .viewer-side,
  .letter-reader-premium,
  .next-date-card,
  .featured-letter {
    border-radius: 18px;
  }

  .page-hero.compact,
  .page-hero {
    padding: 0.95rem;
  }

  .page-hero h1,
  .page-hero.compact h1 {
    font-size: clamp(1.75rem, 9vw, 2.7rem);
    line-height: 0.98;
  }

  .page-hero p,
  .hero-content p {
    font-size: 0.92rem;
    line-height: 1.45;
  }

  .memory-hero {
    min-height: 360px;
    overflow: hidden;
  }

  .hero-content {
    padding: 1rem;
    justify-content: end;
  }

  .hero-content h1 {
    font-size: clamp(2.4rem, 15vw, 4.2rem);
    line-height: 0.9;
  }

  .hero-days {
    width: fit-content;
    max-width: 100%;
    font-size: 0.82rem;
    padding: 0.45rem 0.62rem;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
    width: 100%;
  }

  .hero-actions .small-button,
  .hero-actions .secondary-link {
    width: 100%;
    justify-content: center;
    min-height: 42px;
    padding: 0.55rem 0.5rem;
    font-size: 0.86rem;
  }

  .section-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
  }

  .section-head h2 {
    font-size: clamp(1.25rem, 6vw, 1.8rem);
    line-height: 1;
  }

  .section-head a {
    font-size: 0.8rem;
    padding: 0.42rem 0.58rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
  }

  .memory-grid,
  .large-thumbs.memory-grid,
  .collection-grid,
  .envelope-grid,
  .special-date-grid,
  .favorites-board,
  .extras-grid,
  .places-grid,
  .home-song-row,
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .memory-tile,
  .large-thumbs .memory-tile,
  .large-thumbs .memory-tile:nth-child(2),
  .large-thumbs .memory-tile:nth-child(5) {
    min-height: 118px;
    max-height: 142px;
    border-radius: 16px;
  }

  .album-masonry,
  .favorite-wall {
    columns: 2 118px;
    column-gap: 0.5rem;
  }

  .album-item,
  .favorite-memory,
  .favorite-letter,
  .album-masonry .fav-letter-card {
    margin-bottom: 0.5rem;
  }

  .album-item a,
  .album-item.tall a,
  .album-item.wide a,
  .favorite-memory,
  .favorite-memory.large {
    min-height: 118px;
    border-radius: 16px;
  }

  .album-caption,
  .memory-tile span,
  .favorite-memory span,
  .fav-info {
    left: 0.32rem;
    right: 0.32rem;
    bottom: 0.32rem;
    max-width: calc(100% - 0.64rem);
    padding: 0.34rem 0.42rem;
    border-radius: 11px;
    font-size: 0.7rem;
  }

  .album-caption small {
    display: none;
  }

  .album-category-strip {
    grid-auto-columns: minmax(132px, 155px);
    gap: 0.45rem;
    padding-bottom: 0.35rem;
  }

  .album-category-card {
    min-height: 108px;
    border-radius: 15px;
    padding: 0.65rem;
  }

  .album-category-card strong {
    font-size: 0.96rem;
  }

  .memory-collection-card,
  .memory-collection-card .collection-cover {
    min-height: 176px;
    border-radius: 17px;
  }

  .collection-preview-grid {
    height: 98px;
  }

  .memory-collection-card .collection-cover > div:last-child {
    padding: 0.68rem;
  }

  .collection-card,
  .collection-card > a,
  .collection-card.static-card,
  .extra-card,
  .song-card,
  .place-card,
  .home-song-card,
  .premium-date-card,
  .fav-letter-card,
  .love-letter-card {
    border-radius: 17px;
  }

  .collection-card,
  .collection-card > a,
  .collection-card.static-card {
    min-height: 124px;
  }

  .home-song-card,
  .song-card,
  .place-card,
  .extra-card {
    min-height: 112px;
    padding: 0.72rem;
  }

  .premium-split {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .next-date-card,
  .featured-letter,
  .premium-date-card,
  .memory-post,
  .comments-panel {
    padding: 0.82rem;
  }

  .countdown-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .countdown-row div,
  .date-number {
    padding: 0.52rem 0.35rem;
    border-radius: 13px;
  }

  .countdown-row strong,
  .date-number strong {
    font-size: clamp(1.1rem, 7vw, 1.7rem);
  }

  .mini-timeline {
    gap: 0.45rem;
  }

  .mini-timeline a {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.35rem 0.55rem;
    padding: 0.68rem;
    border-radius: 15px;
  }

  .mini-timeline p,
  .mini-timeline small {
    grid-column: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .form-panel > summary,
  .category-composer > summary,
  .letter-composer > summary,
  .all-memories-panel > summary,
  .mini-details > summary {
    min-height: 50px;
    padding: 0.72rem;
    border-radius: 16px;
  }

  .form-panel > summary::before {
    display: none;
  }

  .form-panel > form,
  .category-composer form,
  .letter-form,
  .category-manage-panel {
    padding: 0 0.72rem 0.72rem;
  }

  .upload-form,
  .stack-form,
  .inline-form,
  .inline-form.wide,
  .letter-form-row,
  .comment-form,
  .search-form,
  .filter-bar,
  .pretty-filter,
  .premium-filter {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  input,
  select,
  textarea,
  button,
  .small-button,
  .secondary-button,
  .secondary-link,
  .danger-button,
  .ghost-button {
    max-width: 100%;
  }

  input,
  select,
  textarea {
    min-height: 42px;
    font-size: 16px;
  }

  textarea {
    min-height: 112px;
  }

  button,
  .small-button,
  .secondary-button,
  .secondary-link,
  .danger-button {
    min-height: 40px;
    justify-content: center;
  }

  .viewer-shell {
    padding-inline: 0.4rem;
  }

  .premium-viewer {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .viewer-media {
    order: 1;
    min-height: 285px;
    max-height: 62vh;
    border-radius: 18px;
  }

  .viewer-side {
    order: 2;
    padding: 0.82rem;
    max-height: none;
    overflow: visible;
  }

  .viewer-title {
    font-size: clamp(1.28rem, 7vw, 2rem);
    -webkit-line-clamp: 2;
  }

  .viewer-actions,
  .reaction-row,
  .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.42rem;
  }

  .viewer-actions form,
  .reaction-row form,
  .actions form {
    width: 100%;
  }

  .viewer-actions a,
  .viewer-actions button,
  .reaction-row button,
  .actions a,
  .actions button {
    width: 100%;
    min-height: 38px;
    font-size: 0.82rem;
  }

  .comments-panel .section-head {
    display: block;
  }

  .comment-list article {
    padding: 0.72rem;
  }

  .letter-composer > summary,
  .category-composer > summary {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .letter-composer > summary small,
  .category-composer small {
    display: none;
  }

  .letter-form textarea {
    min-height: 172px;
  }

  .love-letter-card,
  .love-letter-card > a {
    min-height: 145px;
  }

  .love-letter-card > a {
    padding: 0.82rem;
  }

  .love-letter-card h2,
  .fav-letter-card h2,
  .favorite-letter.paper h2 {
    font-size: 1rem;
  }

  .love-letter-card p,
  .fav-letter-card p,
  .favorite-letter.paper p {
    font-size: 0.82rem;
    -webkit-line-clamp: 3;
  }

  .letter-reading-page {
    width: 100%;
    padding: 0.55rem;
  }

  .letter-reader-premium.paper {
    padding: 1rem;
    border-radius: 18px;
  }

  .letter-reader-premium h1 {
    font-size: clamp(1.9rem, 10vw, 3.1rem);
  }

  .letter-body {
    font-size: 1rem;
    line-height: 1.7;
  }

  .favorites-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fav-media,
  .fav-photo-card.feature .fav-media {
    height: 126px;
  }

  .fav-letter-card {
    min-height: 140px;
    padding: 0.75rem;
  }

  .social-feed {
    gap: 0.6rem;
  }

  .memory-post header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.35rem;
  }

  .memory-post header span {
    justify-self: start;
    max-width: 100%;
  }

  .post-media {
    height: 210px;
    border-radius: 16px;
  }

  .premium-date-card h2,
  .memory-post h2,
  .memory-post h3 {
    overflow-wrap: anywhere;
  }

  .premium-date-card p {
    -webkit-line-clamp: 3;
  }

  .login-page {
    padding: 0.7rem;
  }

  .login-card {
    width: 100%;
    max-width: 420px;
    border-radius: 22px;
    padding: 1rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .user-form,
  .admin-list article,
  .category-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 390px) {
  .premium-home,
  .premium-page,
  .viewer-shell,
  .letter-reading-page {
    padding-inline: 0.42rem;
  }

  .nav a {
    font-size: 0.78rem;
    padding-inline: 0.52rem;
  }

  .settings-link,
  .nav-actions form button {
    font-size: 0.74rem;
    padding-inline: 0.48rem;
  }

  .memory-grid,
  .large-thumbs.memory-grid,
  .collection-grid,
  .envelope-grid,
  .special-date-grid,
  .favorites-board,
  .extras-grid,
  .places-grid,
  .home-song-row {
    gap: 0.42rem;
  }

  .memory-tile,
  .large-thumbs .memory-tile,
  .album-item a,
  .album-item.tall a,
  .album-item.wide a,
  .favorite-memory,
  .favorite-memory.large {
    min-height: 108px;
  }

  .album-masonry,
  .favorite-wall {
    column-gap: 0.42rem;
  }

  .viewer-actions,
  .reaction-row,
  .actions {
    grid-template-columns: 1fr;
  }
}

/* Mobile comfort override: prioritize breathing room over density */
@media (max-width: 720px) {
  .app-nav {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "brand actions"
      "nav nav";
    row-gap: 0.38rem;
  }

  .brand {
    grid-area: brand;
  }

  .nav {
    grid-area: nav;
    width: 100%;
    padding-bottom: 0.05rem;
  }

  .nav-actions {
    grid-area: actions;
    justify-self: end;
  }

  .nav a {
    min-height: 34px;
  }

  .premium-home,
  .premium-page,
  .viewer-shell,
  .letter-reading-page {
    padding-inline: 0.7rem;
    gap: 0.85rem;
  }

  .memory-hero {
    min-height: 320px;
  }

  .hero-content h1 {
    font-size: clamp(2.15rem, 13vw, 3.7rem);
  }

  .hero-actions,
  .countdown-row {
    grid-template-columns: 1fr;
  }

  .section-head {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .section-head a {
    justify-self: start;
  }

  .memory-grid,
  .large-thumbs.memory-grid,
  .collection-grid,
  .envelope-grid,
  .special-date-grid,
  .favorites-board,
  .extras-grid,
  .places-grid,
  .home-song-row,
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 0.7rem;
  }

  .memory-tile,
  .large-thumbs .memory-tile,
  .large-thumbs .memory-tile:nth-child(2),
  .large-thumbs .memory-tile:nth-child(5) {
    min-height: 210px;
    max-height: 260px;
  }

  .album-masonry,
  .favorite-wall,
  .all-memories-panel .album-masonry {
    columns: 1;
    column-gap: 0;
  }

  .album-item,
  .favorite-memory,
  .favorite-letter,
  .album-masonry .fav-letter-card {
    margin-bottom: 0.7rem;
  }

  .album-item a,
  .album-item.tall a,
  .album-item.wide a,
  .favorite-memory,
  .favorite-memory.large {
    min-height: 235px;
  }

  .album-caption small {
    display: block;
  }

  .album-category-strip {
    grid-auto-columns: minmax(74vw, 84vw);
  }

  .album-category-card {
    min-height: 145px;
  }

  .memory-collection-card,
  .memory-collection-card .collection-cover {
    min-height: 240px;
  }

  .collection-preview-grid {
    height: 145px;
  }

  .collection-card,
  .collection-card > a,
  .collection-card.static-card {
    min-height: 170px;
  }

  .home-song-card,
  .song-card,
  .place-card,
  .extra-card,
  .premium-date-card,
  .next-date-card,
  .featured-letter,
  .memory-post,
  .fav-letter-card,
  .love-letter-card {
    padding: 0.95rem;
  }

  .love-letter-card,
  .love-letter-card > a,
  .fav-letter-card {
    min-height: 180px;
  }

  .fav-media,
  .fav-photo-card.feature .fav-media {
    height: 235px;
  }

  .post-media {
    height: 255px;
  }

  .viewer-media {
    min-height: 330px;
    max-height: none;
  }

  .viewer-actions,
  .reaction-row,
  .actions {
    grid-template-columns: 1fr;
  }

  .form-panel > summary,
  .category-composer > summary,
  .letter-composer > summary,
  .all-memories-panel > summary,
  .mini-details > summary {
    min-height: 56px;
  }

  .all-memories-panel > summary,
  .category-composer > summary,
  .letter-composer > summary {
    grid-template-columns: 1fr;
  }

  .all-memories-panel > summary::after,
  .category-composer > summary::after,
  .letter-composer > summary::after {
    justify-self: start;
  }

  .all-memories-panel > summary {
    display: grid;
    align-items: start;
  }

  .all-memories-panel > summary small {
    display: block;
    margin-left: 0;
  }

  .letter-reader-premium.paper {
    padding: 1.15rem;
  }

  .comment-form button,
  .upload-form button,
  .stack-form button,
  .inline-form button,
  .letter-form button,
  .search-form button,
  .filter-bar button {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .premium-home,
  .premium-page,
  .viewer-shell,
  .letter-reading-page {
    padding-inline: 0.55rem;
  }

  .memory-tile,
  .large-thumbs .memory-tile,
  .large-thumbs .memory-tile:nth-child(2),
  .large-thumbs .memory-tile:nth-child(5) {
    min-height: 185px;
  }

  .album-item a,
  .album-item.tall a,
  .album-item.wide a,
  .favorite-memory,
  .favorite-memory.large {
    min-height: 205px;
  }

  .fav-media,
  .fav-photo-card.feature .fav-media {
    height: 205px;
  }

  .post-media {
    height: 225px;
  }

  .viewer-media {
    min-height: 285px;
  }

  .memory-collection-card,
  .memory-collection-card .collection-cover {
    min-height: 220px;
  }

  .collection-preview-grid {
    height: 130px;
  }
}

/* Mobile no-clipping fix: collections must show fully */
@media (max-width: 720px) {
  .premium-home,
  .premium-page,
  .viewer-shell,
  .letter-reading-page,
  .premium-section,
  .album-collections,
  .collection-grid,
  .favorites-board,
  .envelope-grid,
  .special-date-grid,
  .extras-grid,
  .places-grid,
  .home-song-row {
    overflow: visible;
  }

  .album-category-strip {
    display: grid;
    grid-auto-flow: row;
    grid-auto-columns: initial;
    grid-template-columns: 1fr;
    overflow: visible;
    padding: 0;
  }

  .album-category-card {
    width: 100%;
    min-width: 0;
    min-height: 150px;
  }

  .memory-collection-card,
  .memory-collection-card .collection-cover,
  .collection-card,
  .collection-card > a,
  .collection-card.static-card {
    width: 100%;
    min-width: 0;
    height: auto;
  }

  .memory-collection-card,
  .memory-collection-card .collection-cover {
    min-height: 0;
  }

  .memory-collection-card .collection-cover {
    display: grid;
    grid-template-rows: auto auto;
  }

  .collection-preview-grid {
    height: auto;
    min-height: 150px;
    aspect-ratio: 16 / 9;
  }

  .memory-collection-card .collection-cover > div:last-child {
    min-height: 92px;
  }

  .memory-collection-card h2,
  .memory-collection-card p,
  .memory-collection-card small,
  .album-category-card span,
  .album-category-card strong,
  .album-category-card small {
    max-width: 100%;
  }
}

@media (max-width: 430px) {
  .album-category-card {
    min-height: 138px;
  }

  .collection-preview-grid {
    min-height: 130px;
  }
}

/* Control polish: consistent buttons, action groups and forms */
button,
.small-button,
.secondary-button,
.secondary-link,
.danger-button,
.ghost-button,
.mini-details > summary,
.section-head a,
.back-link {
  min-height: 42px;
  border-radius: 14px;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
}

button,
.small-button {
  position: relative;
  isolation: isolate;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(135deg, #ff6f9f, #9d7cff);
  color: #fff;
  box-shadow: 0 12px 28px rgba(255, 95, 143, 0.18);
}

button:hover,
.small-button:hover,
.secondary-button:hover,
.secondary-link:hover,
.danger-button:hover,
.ghost-button:hover,
.mini-details > summary:hover,
.section-head a:hover,
.back-link:hover {
  filter: brightness(1.07);
  transform: translateY(-1px);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.82);
  outline-offset: 3px;
}

.secondary-button,
.secondary-link,
.ghost-button,
.mini-details > summary,
.section-head a,
.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  border: 1px solid rgba(255, 126, 173, 0.26);
  background: rgba(255, 255, 255, 0.075);
  color: #ffd7e6;
  box-shadow: none;
  padding: 0.7rem 0.9rem;
}

.danger-button {
  border-color: rgba(255, 115, 137, 0.38);
  background: rgba(255, 81, 111, 0.12);
  color: #ffb7c6;
  box-shadow: none;
}

.active-soft,
.heart-button.active {
  border-color: rgba(255, 255, 255, 0.2);
  background: linear-gradient(135deg, #ff5f8f, #ff8db6);
  color: #fff;
}

.heart-button {
  width: 42px;
  height: 42px;
  min-height: 42px;
  border-radius: 50%;
  padding: 0;
  font-size: 1.05rem;
}

.actions,
.viewer-actions,
.reaction-row,
.action-panel,
.tutorial-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 0.55rem;
  align-items: stretch;
}

.actions form,
.viewer-actions form,
.reaction-row form,
.action-panel form,
.nav-actions form {
  display: contents;
}

.actions a,
.actions button,
.viewer-actions a,
.viewer-actions button,
.reaction-row button,
.action-panel a,
.action-panel button {
  width: 100%;
  min-width: 0;
  padding-inline: 0.75rem;
}

.reaction-row {
  grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
  margin-top: 0.8rem;
}

.reaction-row button {
  min-height: 38px;
  border-radius: 999px;
  padding: 0.55rem 0.65rem;
}

.viewer-actions {
  margin-top: 1rem;
}

.inline-form,
.upload-form,
.filter-bar,
.search-form,
.comment-form {
  align-items: stretch;
}

.inline-form button,
.upload-form button,
.filter-bar button,
.search-form button,
.comment-form button,
.stack-form button,
.letter-form button {
  min-width: 132px;
}

.user-form {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(160px, 1.2fr) minmax(170px, 1fr) auto;
  gap: 0.65rem;
  align-items: stretch;
  padding: 0.72rem;
  border: 1px solid rgba(255, 126, 173, 0.16);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
}

.form-panel > form,
.form-panel .user-form,
.mini-details form {
  margin-top: 0;
}

.mini-details {
  display: grid;
  gap: 0.65rem;
}

.mini-details[open] {
  padding-top: 0.3rem;
}

.mini-details > summary {
  width: fit-content;
}

.mini-details .stack-form,
.mini-details .inline-form {
  padding: 0.72rem;
  border: 1px solid rgba(255, 126, 173, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
}

.mini-details .danger-button {
  width: fit-content;
}

.nav-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-actions .ghost-button,
.nav-actions form button {
  min-height: 38px;
  border-radius: 999px;
  padding: 0.55rem 0.72rem;
}

.nav a,
.notification-button {
  position: relative;
}

.notification-badge {
  display: inline-grid;
  place-items: center;
  min-width: 1.25rem;
  height: 1.25rem;
  margin-left: 0.35rem;
  border: 2px solid rgba(18, 9, 17, 0.88);
  border-radius: 999px;
  background: linear-gradient(135deg, #ff4f86, #ff9abc);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 950;
  line-height: 1;
  padding: 0 0.32rem;
  box-shadow: 0 8px 18px rgba(255, 79, 134, 0.34);
}

.notification-badge[hidden] {
  display: none;
}

.section-badge {
  position: absolute;
  top: -0.34rem;
  right: -0.28rem;
  margin: 0;
  min-width: 1.12rem;
  height: 1.12rem;
  font-size: 0.66rem;
}

.nav a.has-notification {
  color: #fff;
  background: rgba(255, 126, 173, 0.16);
}

.notification-button:not(:has(.notification-badge[hidden])) {
  color: #fff;
  border-color: rgba(255, 126, 173, 0.42);
  background: rgba(255, 126, 173, 0.14);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.hero-actions .small-button {
  min-width: 150px;
}

.section-head a,
.back-link {
  min-height: 36px;
  border-radius: 999px;
  font-size: 0.9rem;
}

.card-body .actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card-body .actions .small-button {
  min-height: 38px;
  padding: 0.6rem 0.7rem;
}

@media (max-width: 860px) {
  .user-form {
    grid-template-columns: 1fr;
  }

  .inline-form,
  .upload-form,
  .filter-bar,
  .search-form,
  .comment-form {
    display: grid;
    grid-template-columns: 1fr;
  }

  .inline-form button,
  .upload-form button,
  .filter-bar button,
  .search-form button,
  .comment-form button,
  .stack-form button,
  .letter-form button,
  .mini-details .danger-button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  button,
  .small-button,
  .secondary-button,
  .secondary-link,
  .danger-button,
  .ghost-button {
    min-height: 44px;
    padding: 0.68rem 0.76rem;
    font-size: 0.9rem;
  }

  .actions,
  .viewer-actions,
  .action-panel,
  .tutorial-actions,
  .card-body .actions,
  .hero-actions {
    grid-template-columns: 1fr;
    display: grid;
  }

  .reaction-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-actions {
    gap: 0.32rem;
  }

  .nav-actions .ghost-button,
  .nav-actions form button {
    min-height: 34px;
    padding: 0.42rem 0.56rem;
    font-size: 0.78rem;
  }

  .notification-button {
    padding-right: 0.44rem;
  }

  .notification-badge {
    min-width: 1.08rem;
    height: 1.08rem;
    font-size: 0.62rem;
  }
}

/* Layout safety pass: prevent text, badges and buttons from overlapping */
main,
section,
article,
div,
form,
label,
header,
nav,
.container,
.premium-home,
.premium-page,
.viewer-shell,
.letter-reading-page,
.form-panel,
.soft-panel,
.card-body,
.viewer-side,
.chat-panel,
.chat-message,
.profile-editor,
.nav-actions {
  min-width: 0;
}

p,
h1,
h2,
h3,
h4,
span,
small,
strong,
a,
button,
summary,
label {
  overflow-wrap: anywhere;
}

button,
.small-button,
.secondary-button,
.secondary-link,
.danger-button,
.ghost-button,
.mini-details > summary,
.section-head a,
.back-link {
  max-width: 100%;
  height: auto;
  line-height: 1.18;
  white-space: normal;
}

.nav a,
.brand,
.heart-pill,
.notification-badge {
  overflow-wrap: normal;
  white-space: nowrap;
}

input,
select,
textarea {
  min-width: 0;
}

.nav {
  align-items: center;
  overflow-y: visible;
  padding-block: 0.2rem;
}

.nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: max-content;
  overflow: visible;
}

.nav a.has-notification {
  padding-right: 1.25rem;
}

.section-badge {
  top: -0.22rem;
  right: -0.12rem;
}

.nav-actions {
  min-width: 0;
  max-width: 100%;
}

.notification-button {
  gap: 0.35rem;
}

.notification-button .notification-badge {
  flex: 0 0 auto;
  margin-left: 0.2rem;
}

.inline-form,
.upload-form,
.filter-bar,
.search-form,
.comment-form,
.avatar-form,
.chat-form,
.user-form {
  max-width: 100%;
}

.actions,
.viewer-actions,
.reaction-row,
.action-panel,
.card-body .actions,
.hero-actions {
  max-width: 100%;
}

.actions form,
.viewer-actions form,
.reaction-row form,
.action-panel form {
  min-width: 0;
}

.chat-message > div:last-child,
.love-toast,
.tutorial-card,
.memory-post,
.premium-date-card,
.collection-card,
.love-letter-card,
.fav-letter-card,
.home-song-card,
.extra-card,
.song-card,
.place-card {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 720px) {
  .nav {
    overflow-x: auto;
    overflow-y: visible;
  }

  .nav a {
    min-width: max-content;
    padding-block: 0.55rem;
  }

  .nav a.has-notification {
    padding-right: 1.35rem;
  }

  .nav-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .notification-button {
    max-width: 8.8rem;
  }
}

@media (max-width: 430px) {
  .notification-button {
    max-width: 7.4rem;
  }

  .notification-button .notification-badge {
    margin-left: 0.1rem;
  }
}

/* Navigation repair: keep menu items, badges and action buttons separated */
.app-nav {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  overflow: visible;
}

.app-nav .brand {
  min-width: max-content;
}

.app-nav .nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.15rem;
  scrollbar-width: none;
}

.app-nav .nav::-webkit-scrollbar {
  display: none;
}

.app-nav .nav a {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  min-width: max-content;
  min-height: 38px;
  padding: 0.52rem 0.72rem;
  border-radius: 999px;
  line-height: 1;
  white-space: nowrap;
  overflow: visible;
}

.app-nav .nav a.has-notification {
  padding-right: 0.72rem;
}

.app-nav .nav .section-badge {
  position: static;
  flex: 0 0 auto;
  min-width: 1.08rem;
  height: 1.08rem;
  margin: 0 0 0 0.1rem;
  border-width: 1px;
  font-size: 0.62rem;
  transform: none;
}

.app-nav .nav-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  min-width: max-content;
  max-width: none;
}

.app-nav .nav-actions form {
  display: block;
  margin: 0;
}

.app-nav .nav-actions .ghost-button,
.app-nav .nav-actions form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: max-content;
  min-height: 38px;
  padding: 0.5rem 0.7rem;
  border-radius: 999px;
  line-height: 1;
  white-space: nowrap;
}

.app-nav .notification-button {
  max-width: none;
}

.app-nav .notification-button .notification-badge {
  position: static;
  flex: 0 0 auto;
  margin-left: 0.2rem;
}

@media (max-width: 820px) {
  .app-nav {
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-radius: 0 0 18px 18px;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "brand actions"
      "nav nav";
    gap: 0.42rem;
    padding: 0.5rem 0.58rem;
  }

  .app-nav .brand {
    grid-area: brand;
  }

  .app-nav .nav {
    grid-area: nav;
    width: 100%;
    padding: 0.12rem 0 0.05rem;
  }

  .app-nav .nav-actions {
    grid-area: actions;
    justify-self: end;
    min-width: 0;
    max-width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .app-nav .nav-actions::-webkit-scrollbar {
    display: none;
  }

  .app-nav .nav-actions .ghost-button,
  .app-nav .nav-actions form button {
    min-height: 34px;
    padding: 0.42rem 0.56rem;
    font-size: 0.78rem;
  }
}

@media (max-width: 430px) {
  .app-nav {
    padding-inline: 0.48rem;
  }

  .app-nav .nav a {
    min-height: 34px;
    padding: 0.45rem 0.58rem;
    font-size: 0.8rem;
  }

  .app-nav .nav-actions .ghost-button,
  .app-nav .nav-actions form button {
    padding-inline: 0.46rem;
    font-size: 0.74rem;
  }
}
