:root {
  --cream: #fff8f1;
  --cream-2: #fff1e3;
  --blush: #ffb7c5;
  --blush-deep: #f48aa6;
  --plum: #5b3a6b;
  --plum-soft: #7a5a8c;
  --sage: #9dbe8b;
  --gold: #e8b547;
  --ink: #2b1f33;
  --ink-soft: #5a4a64;
  --paper: #ffffff;
  --shadow: 0 18px 40px -22px rgba(91, 58, 107, 0.35);
  --shadow-soft: 0 6px 18px -10px rgba(91, 58, 107, 0.25);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  background: linear-gradient(180deg, var(--cream) 0%, var(--cream-2) 100%);
  color: var(--ink);
  font-family: 'Mulish', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100%;
}

body {
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

a {
  color: var(--plum);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

textarea {
  resize: vertical;
}

/* Compose / edit textareas: disable the resize grip so it doesn't compete
   with the absolutely positioned character counter in the bottom-right. */
.compose textarea {
  resize: none;
}

.visually-hidden {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

/* ---------- Floating petals (whimsy) ---------- */
.petals {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.petal {
  position: absolute;
  font-size: 28px;
  opacity: 0.55;
  filter: drop-shadow(0 4px 8px rgba(91, 58, 107, 0.12));
  animation: drift 18s linear infinite;
  will-change: transform;
}
/* Each petal gets a distinct negative animation-delay so on first paint
   they're spread across the cycle (and therefore the viewport) rather
   than all entering from above the fold together. They continue falling
   normally — the delay just shifts their starting phase. Combined with
   varied durations, they stay desynced indefinitely. */
.petal-1  { left: 6%;  top: -8%;  animation-duration: 22s; animation-delay: -1s;  }
.petal-2  { left: 22%; top: -12%; animation-duration: 28s; animation-delay: -4s;  font-size: 32px; }
.petal-3  { left: 40%; top: -5%;  animation-duration: 18s; animation-delay: -4s;  }
.petal-4  { left: 58%; top: -14%; animation-duration: 24s; animation-delay: -7s;  font-size: 36px; }
.petal-5  { left: 75%; top: -7%;  animation-duration: 30s; animation-delay: -11s; font-size: 22px; }
.petal-6  { left: 88%; top: -10%; animation-duration: 26s; animation-delay: -12s; }
.petal-7  { left: 14%; top: -3%;  animation-duration: 32s; animation-delay: -17s; font-size: 26px; }
/* Family emojis — Mom's yarn (8), Dad's cap (9), Pepper's rabbit (10),
   Marlo's carousel (11), Asher's plane (12). Same drift pattern but with
   alternating drift-back keyframes so consecutive elements sweep opposite
   horizontal directions. */
.petal-8  { left: 10%; top: -15%; animation-name: drift-back; animation-duration: 33s; animation-delay: -21s; font-size: 30px; }
.petal-9  { left: 32%; top:  -8%; animation-duration: 29s; animation-delay: -20s; font-size: 26px; }
.petal-10 { left: 54%; top: -20%; animation-name: drift-back; animation-duration: 37s; animation-delay: -29s; font-size: 32px; }
.petal-11 { left: 76%; top:  -5%; animation-duration: 24s; animation-delay: -21s; font-size: 32px; }
.petal-12 { left: 90%; top: -12%; animation-name: drift-back; animation-duration: 28s; animation-delay: -27s; font-size: 28px; }

@keyframes drift {
  0% {
    transform: translateY(-10vh) translateX(0) rotate(0deg);
  }
  50% {
    transform: translateY(50vh) translateX(40px) rotate(180deg);
  }
  100% {
    transform: translateY(115vh) translateX(-30px) rotate(360deg);
  }
}

@keyframes drift-back {
  0% {
    transform: translateY(-10vh) translateX(0) rotate(0deg);
  }
  50% {
    transform: translateY(50vh) translateX(-35px) rotate(-160deg);
  }
  100% {
    transform: translateY(115vh) translateX(25px) rotate(-300deg);
  }
}

/* When the user (or iOS Low Power Mode) prefers reduced motion, freeze the
   drift but scatter the petals across the viewport like a snapshot of the
   animation rather than piling them all at the bottom. */
@media (prefers-reduced-motion: reduce) {
  .petal {
    animation: none;
    opacity: 0.4;
  }
  .petal-1  { top:  8%; }
  .petal-2  { top: 24%; }
  .petal-3  { top: 42%; }
  .petal-4  { top: 14%; }
  .petal-5  { top: 66%; }
  .petal-6  { top: 82%; }
  .petal-7  { top: 50%; }
  .petal-8  { top: 32%; }
  .petal-9  { top: 60%; }
  .petal-10 { top: 18%; }
  .petal-11 { top: 76%; }
  .petal-12 { top: 46%; }
}

/* ---------- Page shell ---------- */
.page {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

/* ---------- Topbar ---------- */
.topbar {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  /* Add the iOS safe-area inset so the brand sits below the notch / status
     bar instead of underneath it (paired with black-translucent so the page
     bg extends into that area). */
  padding: calc(18px + env(safe-area-inset-top)) 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--plum);
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.topbar__brand:hover { text-decoration: none; }
.topbar__brand-emoji { font-size: 22px; }
.topbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar__hello {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--paper);
  border: 1px solid rgba(91, 58, 107, 0.08);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--ink-soft);
  box-shadow: var(--shadow-soft);
}
.topbar__logout-form { margin: 0; }
.topbar__logout {
  background: transparent;
  border: 1px solid rgba(91, 58, 107, 0.18);
  border-radius: 999px;
  padding: 6px 14px;
  color: var(--plum);
  cursor: pointer;
  font-size: 14px;
  transition: background 120ms ease, transform 120ms ease;
}
.topbar__logout:hover {
  background: var(--paper);
  transform: translateY(-1px);
}
.topbar__bell {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  background: var(--paper);
  border: 1px solid rgba(91, 58, 107, 0.08);
  border-radius: 999px;
  padding: 0;
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform 120ms ease, background 120ms ease;
}
.topbar__bell:hover {
  background: #fff;
  transform: translateY(-1px) rotate(-6deg);
}
.topbar__bell[aria-expanded="true"] {
  background: var(--blush);
  border-color: var(--blush-deep);
}

/* Notification settings popover (slides in below the topbar) */
.topbar-popover {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 8px auto 0;
  padding: 12px 18px;
  background: var(--paper);
  border: 1px solid rgba(91, 58, 107, 0.08);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: popover-in 160ms ease-out;
}
.topbar-popover[hidden] { display: none; }
.topbar-popover__text {
  margin: 0;
  font-size: 14px;
  color: var(--ink-soft);
}
@keyframes popover-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (max-width: 480px) {
  .topbar-popover {
    margin-left: 16px;
    margin-right: 16px;
  }
}

/* ---------- Hero ---------- */
.hero {
  margin: 24px 0 18px;
}
.hero__eyebrow {
  margin: 0 0 6px;
  color: var(--plum-soft);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.hero__title {
  margin: 0 0 8px;
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: clamp(28px, 6vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--plum);
}
.hero--mom .hero__title { color: var(--plum); }
.hero__subtitle {
  margin: 0;
  color: var(--ink-soft);
  font-size: 16px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px;
  border: 1px solid rgba(91, 58, 107, 0.06);
}
.card + .card { margin-top: 14px; }
.card--compose { margin-top: 8px; }
.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.card__time {
  color: var(--plum-soft);
  font-size: 13px;
  font-weight: 500;
}
.card__author {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--plum);
}
.card__author-emoji {
  display: inline-grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 999px;
  background: var(--cream);
  font-size: 18px;
}
.card__body {
  margin: 0;
  white-space: pre-wrap;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
}
.card__body--muted { color: var(--ink-soft); }
.card__actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.card__confirm {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
.card__delete-form { margin: 0; display: inline; }
.card--editing { outline: 2px solid var(--blush); outline-offset: 2px; }
.card--confirming { outline: 2px solid var(--gold); outline-offset: 2px; background: #fffaf0; }
.card--mom-note .card__body { font-size: 18px; }

/* ---------- Compose ---------- */
.compose textarea,
.field input[type='password'],
.field input[type='text'] {
  width: 100%;
  border: 1px solid rgba(91, 58, 107, 0.15);
  background: var(--cream);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 17px;
  color: var(--ink);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.compose textarea:focus,
.field input:focus {
  border-color: var(--blush-deep);
  background: var(--paper);
  box-shadow: 0 0 0 4px rgba(255, 183, 197, 0.35);
}
.compose__actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
/* Editing variant: Delete on the far left, Cancel + Save on the right. */
.compose__actions--editing {
  justify-content: space-between;
  align-items: center;
}
.compose__actions-right {
  display: inline-flex;
  gap: 8px;
}
.compose--inline { margin-top: 4px; }
.compose__count {
  position: absolute;
  bottom: 8px;
  right: 12px;
  margin: 0 0 4px 0;
  padding: 1px 6px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: rgba(91, 58, 107, 0.4);
  background: rgba(255, 248, 241, 0.85);
  border-radius: 4px;
  pointer-events: none;
  transition: color 120ms ease;
}
.compose__count[data-near] { color: var(--gold); }
.compose__count[data-at]   { color: #c44569; font-weight: 600; }

.field {
  display: block;
  margin-bottom: 14px;
  position: relative; /* anchor for absolute children like .compose__count */
}
.field__label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--plum-soft);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

/* ---------- Notes list ---------- */
.notes { margin-top: 28px; }
.notes__heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 22px;
  color: var(--plum);
  margin: 0 0 14px;
}
.notes__count {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--blush);
  color: var(--plum);
  font-family: 'Mulish', sans-serif;
  font-weight: 600;
  font-size: 13px;
}
.notes__empty {
  background: var(--paper);
  border: 1px dashed rgba(91, 58, 107, 0.2);
  border-radius: var(--radius-lg);
  padding: 22px;
  color: var(--ink-soft);
  text-align: center;
}
.notes__list {
  list-style: none;
  margin: 0; padding: 0;
}
.notes__list--timeline .card { padding: 22px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 600;
  font-size: 15px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease;
  white-space: nowrap;
}
.btn--primary {
  background: var(--plum);
  color: #fff;
  box-shadow: var(--shadow-soft);
}
.btn--primary:hover {
  background: #4a2f58;
  transform: translateY(-1px) rotate(-0.5deg);
  text-decoration: none;
}
.btn--primary:active { transform: translateY(0); }
.btn--quiet {
  background: transparent;
  color: var(--plum);
  border-color: rgba(91, 58, 107, 0.16);
}
.btn--quiet:hover {
  background: var(--cream);
  text-decoration: none;
}
.btn--danger {
  background: #c44569;
  color: #fff;
}
.btn--danger:hover {
  background: #a83553;
  text-decoration: none;
}
.btn--danger-quiet {
  color: #a83553;
  border-color: rgba(168, 53, 83, 0.18);
}
.btn--danger-quiet:hover {
  background: #fff0f3;
  text-decoration: none;
}

/* ---------- Login ---------- */
.login {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 80px);
}
.login__card {
  width: 100%;
  max-width: 480px;
  background: var(--paper);
  border-radius: 28px;
  padding: 32px 28px 28px;
  box-shadow: 0 30px 60px -30px rgba(91, 58, 107, 0.4);
  border: 1px solid rgba(91, 58, 107, 0.06);
  position: relative;
}
.login__card::before {
  content: '✨';
  position: absolute;
  top: -10px; right: 24px;
  font-size: 22px;
  filter: drop-shadow(0 4px 6px rgba(232, 181, 71, 0.4));
  animation: sparkle 3s ease-in-out infinite;
}
@keyframes sparkle {
  0%, 100% { transform: scale(1) rotate(0); opacity: 0.9; }
  50%      { transform: scale(1.15) rotate(15deg); opacity: 1; }
}
.login__title {
  margin: 0 0 8px;
  font-family: 'Fraunces', serif;
  font-weight: 500;
  text-align: center;
  letter-spacing: -0.02em;
  color: var(--plum);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.login__title-line--small {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--plum-soft);
  font-weight: 500;
  font-family: 'Mulish', sans-serif;
}
.login__title-line--large {
  font-size: 44px;
  line-height: 1.05;
}
.login__subtitle {
  text-align: center;
  color: var(--ink-soft);
  margin: 0 0 22px;
  font-size: 15px;
}
.login__form { display: block; }
.login__faces {
  border: 0;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.face {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border-radius: var(--radius-md);
  background: var(--cream);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}
.face:hover {
  transform: translateY(-2px) rotate(-1deg);
  background: #fff;
}
.face input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}
.face__emoji {
  font-size: 30px;
  line-height: 1;
}
.face__name {
  font-size: 12px;
  color: var(--plum-soft);
  font-weight: 500;
}
.face--selected,
.face:has(input:checked) {
  border-color: var(--blush-deep);
  background: #fff;
  box-shadow: 0 8px 18px -10px rgba(244, 138, 166, 0.6);
}
.login__error {
  margin: 0 0 12px;
  padding: 10px 14px;
  background: #fff0f3;
  border: 1px solid rgba(196, 69, 105, 0.2);
  border-radius: var(--radius-sm);
  color: #a83553;
  font-size: 14px;
}
.login__submit {
  width: 100%;
  padding: 14px;
  font-size: 16px;
}

/* ---------- Notify card (Mom view only) ---------- */
.notify {
  margin: 18px 0 8px;
}
.notify__inner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--paper);
  border: 1px solid rgba(91, 58, 107, 0.08);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 14px 18px;
}
.notify__bell {
  font-size: 28px;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 6px rgba(232, 181, 71, 0.4));
}
.notify__text { flex: 1; min-width: 0; }
.notify__title {
  margin: 0;
  font-weight: 600;
  color: var(--plum);
  font-size: 15px;
}
.notify__status {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
}
@media (max-width: 480px) {
  .notify__inner { flex-wrap: wrap; }
  .notify__inner .btn { width: 100%; }
}

/* ---------- Empty (Mom view) ---------- */
.empty {
  text-align: center;
  background: var(--paper);
  border-radius: var(--radius-lg);
  padding: 36px 24px;
  box-shadow: var(--shadow);
  margin-top: 12px;
  border: 1px solid rgba(91, 58, 107, 0.06);
}
.empty__art {
  font-size: 56px;
  margin-bottom: 8px;
  animation: gentlebob 4s ease-in-out infinite;
}
@keyframes gentlebob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-4px) rotate(2deg); }
}
.empty__title {
  margin: 0 0 6px;
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 22px;
  color: var(--plum);
}
.empty__body {
  margin: 0;
  color: var(--ink-soft);
}

/* ---------- Mobile tweaks ---------- */
@media (max-width: 480px) {
  .login__faces { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .face__emoji { font-size: 26px; }
  .face__name  { font-size: 11px; }
  .login__card { padding: 26px 20px; border-radius: 22px; }
  .login__title-line--large { font-size: 36px; }
  .topbar { padding-top: 14px; }
  .topbar__brand-text { display: none; }
  .card { padding: 18px; }
}
