:root {
  --paper: #fffaf4;
  --cream: #f8eee7;
  --ink: #211a18;
  --muted: #746761;
  --rose: #d84a67;
  --mint: #4f967f;
  --gold: #c99131;
  --blue: #426b9c;
  --line: rgba(33, 26, 24, 0.13);
  --shadow: 0 22px 70px rgba(73, 43, 31, 0.2);
}

* { box-sizing: border-box; }

html { background: var(--cream); }

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(216, 74, 103, 0.12), transparent 32%),
    linear-gradient(225deg, rgba(79, 150, 127, 0.14), transparent 35%),
    var(--cream);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 0 42%, rgba(255, 255, 255, 0.46) 49%, transparent 56%),
    transparent;
  transform: translateX(-120%);
  animation: shimmer 7s ease-in-out infinite;
  z-index: 1;
}

button, input { font: inherit; }
button { border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }

.phone-shell {
  position: relative;
  z-index: 2;
  width: min(100%, 480px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.auth-shell {
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 244, 0.94);
  backdrop-filter: blur(14px);
}

.topbar.simple { position: static; }

.top-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.back-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
  transition: transform 180ms ease, background 180ms ease;
}

.back-button::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.back-button:active {
  transform: scale(0.96);
}

.back-button.disabled {
  visibility: hidden;
  pointer-events: none;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: 8px;
  background: var(--ink);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: block;
  object-fit: contain;
}

.brand-lockup:hover {
  transform: translateY(-1px) rotate(-2deg);
  box-shadow: 0 10px 24px rgba(33, 26, 24, 0.18);
}

.ghost-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: #fff;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 850;
}

.page-nav {
  position: sticky;
  top: 69px;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 244, 0.94);
  backdrop-filter: blur(14px);
}

.progress-dots {
  position: sticky;
  top: 69px;
  z-index: 8;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 244, 0.94);
  backdrop-filter: blur(14px);
}

.progress-dots span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(33, 26, 24, 0.18);
  transition: width 220ms ease, background 220ms ease;
}

.progress-dots span.active {
  width: 28px;
  background: var(--ink);
}

.page-nav a {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 5px;
  background: #fff;
  font-size: 0.76rem;
  font-weight: 900;
  text-align: center;
}

.page-nav a.active {
  background: var(--ink);
  color: #fff;
}

.lock-card,
.media-panel,
.photo-panel,
.letter-panel,
.creative-panel,
.promise-panel,
.forgive-panel,
.happy-panel,
.final-note,
.love-reasons article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
}

.lock-card {
  align-self: center;
  margin: 22px;
  padding: 26px 20px;
}

.tiny-label {
  margin: 0 0 8px;
  color: var(--rose);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, h3, p { overflow-wrap: anywhere; }

h1 {
  margin: 0;
  font-size: clamp(2.35rem, 14vw, 4.05rem);
  line-height: 0.92;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 12px;
  font-size: 1.42rem;
  line-height: 1.05;
  letter-spacing: 0;
}

p {
  line-height: 1.55;
}

.lock-copy,
.hero p,
.letter-panel p,
.love-reasons p,
.promise-result,
.final-note p {
  color: var(--muted);
}

.password-form { margin-top: 26px; }

.password-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.password-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.password-row input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 12px;
  background: #fff;
  color: var(--ink);
}

.password-row button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 13px 16px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.error-text {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: var(--rose);
  font-weight: 800;
}

.hero {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  padding: 30px 18px 18px;
  animation: pageRise 520ms ease both;
}

.apology-hero {
  background:
    linear-gradient(180deg, rgba(255, 250, 244, 0) 0%, var(--paper) 94%),
    repeating-linear-gradient(90deg, rgba(201, 145, 49, 0.18) 0 1px, transparent 1px 28px),
    linear-gradient(140deg, rgba(66, 107, 156, 0.14), rgba(216, 74, 103, 0.12));
}

.love-hero {
  background:
    radial-gradient(circle at 80% 10%, rgba(216, 74, 103, 0.18), transparent 34%),
    linear-gradient(145deg, rgba(79, 150, 127, 0.18), transparent 58%);
}

.promise-hero {
  background:
    linear-gradient(135deg, rgba(201, 145, 49, 0.2), transparent 42%),
    linear-gradient(225deg, rgba(66, 107, 156, 0.16), transparent 48%);
}

.finale-hero {
  min-height: 58vh;
  background:
    linear-gradient(180deg, rgba(255, 250, 244, 0) 0%, var(--paper) 95%),
    linear-gradient(145deg, rgba(79, 150, 127, 0.18), rgba(216, 74, 103, 0.1));
}

.media-panel,
.photo-panel,
.letter-panel,
.creative-panel,
.promise-panel,
.forgive-panel,
.happy-panel,
.final-note,
.love-reasons {
  margin: 16px;
}

.media-panel,
.photo-panel,
.letter-panel,
.creative-panel,
.promise-panel,
.forgive-panel,
.happy-panel,
.final-note {
  padding: 16px;
  opacity: 0;
  transform: translateY(24px) scale(0.985);
  transition: opacity 520ms ease, transform 520ms ease;
}

.media-panel.visible,
.photo-panel.visible,
.letter-panel.visible,
.creative-panel.visible,
.promise-panel.visible,
.forgive-panel.visible,
.happy-panel.visible,
.final-note.visible,
.love-reasons article.visible,
.photo-card.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.reel-player {
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 620px;
  border-radius: 8px;
  background: #191413;
  object-fit: cover;
}

.photo-stack {
  display: grid;
  gap: 16px;
}

.photo-card {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  opacity: 0;
  transition: opacity 520ms ease, transform 520ms ease, box-shadow 240ms ease;
}

.photo-card img {
  width: 100%;
  aspect-ratio: 4 / 5;
  display: block;
  object-fit: cover;
  background: #f1e4dd;
}

.happy-card img {
  aspect-ratio: 3 / 4;
}

.photo-card:hover {
  box-shadow: 0 16px 34px rgba(73, 43, 31, 0.16);
}

.tilt-left.visible { transform: rotate(-1.2deg); }
.tilt-right.visible { transform: rotate(1.2deg); }

figcaption {
  padding: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
  line-height: 1.38;
}

.mood-pill,
.counter {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 8px 10px;
  background: rgba(79, 150, 127, 0.14);
  color: #24584b;
  font-size: 0.74rem;
  font-weight: 900;
}

.love-reasons {
  display: grid;
  gap: 12px;
}

.love-reasons article {
  padding: 16px;
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 520ms ease, transform 520ms ease;
}

.love-reasons span {
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 950;
}

.heart-button {
  position: relative;
  width: 180px;
  height: 180px;
  display: grid;
  place-items: center;
  margin: 22px auto 16px;
  border-radius: 50%;
  background: rgba(216, 74, 103, 0.12);
  color: var(--ink);
  overflow: hidden;
  animation: heartbeat 1.7s ease-in-out infinite;
}

.heart-button::before,
.heart-button::after {
  content: "";
  position: absolute;
  width: 72px;
  height: 112px;
  top: 44px;
  border-radius: 72px 72px 0 0;
  background: var(--rose);
}

.heart-button::before {
  left: 52px;
  transform: rotate(-45deg);
  transform-origin: 0 100%;
}

.heart-button::after {
  left: 56px;
  transform: rotate(45deg);
  transform-origin: 100% 100%;
}

.heart-button strong {
  position: relative;
  z-index: 2;
  color: #fff;
  font-weight: 950;
}

#heartFill {
  position: absolute;
  inset: auto 0 0;
  height: 0%;
  background: rgba(33, 26, 24, 0.22);
  transition: height 80ms linear;
  z-index: 1;
}

.promise-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.promise-card {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  padding: 10px;
  transition: transform 180ms ease, background 180ms ease, color 180ms ease;
}

.promise-card:active {
  transform: scale(0.96);
}

.promise-card.open {
  background: var(--ink);
  color: #fff;
}

.promise-result {
  min-height: 3.1em;
  margin: 12px 0 0;
  font-weight: 800;
}

.anger-button {
  width: 100%;
  min-height: 170px;
  display: grid;
  place-items: center;
  gap: 8px;
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(216, 74, 103, 0.18), rgba(201, 145, 49, 0.2)),
    #fff;
  color: var(--ink);
  font-weight: 950;
  transition: transform 180ms ease, filter 180ms ease;
}

.anger-button:active {
  transform: scale(0.98);
  filter: saturate(1.22);
}

.anger-face {
  font-size: 4.2rem;
  line-height: 1;
}

.meter {
  height: 12px;
  margin-top: 12px;
  border-radius: 999px;
  background: rgba(33, 26, 24, 0.1);
  overflow: hidden;
}

.meter span {
  width: 0%;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--rose), var(--gold), var(--mint));
  transition: width 220ms ease;
}

.final-note {
  background: var(--ink);
  color: #fff;
}

.final-note .tiny-label,
.final-note p {
  color: rgba(255, 255, 255, 0.76);
}

.final-note .primary-button {
  width: 100%;
  background: #fff;
  color: var(--ink);
}

.wide { width: 100%; }

.scroll-cue,
.auto-next {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.scroll-cue::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-left: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  animation: bounceDown 1.1s ease-in-out infinite;
}

.auto-next {
  margin: 22px 16px 34px;
  border: 1px dashed var(--line);
  background: rgba(255, 255, 255, 0.64);
  opacity: 0.55;
  transition: opacity 240ms ease, transform 240ms ease;
}

.auto-next.armed {
  opacity: 1;
  transform: scale(1.02);
}

#confettiCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 30;
}

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

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.035); }
  58% { transform: scale(0.99); }
}

@keyframes bounceDown {
  0%, 100% { transform: translateY(-2px) rotate(45deg); }
  50% { transform: translateY(4px) rotate(45deg); }
}

@keyframes shimmer {
  0%, 62% { transform: translateX(-120%); }
  100% { transform: translateX(120%); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (min-width: 481px) {
  body { padding: 22px 0; }
  .phone-shell {
    min-height: calc(100vh - 44px);
    border-radius: 22px;
  }
}
