/* ===========================================================================
   First Rec — bold editorial / warm-sunset keepsake.
   Mobile-first. Palette is fixed; everything else bends around it.
   =========================================================================== */

:root {
  /* palette */
  --brunswick: #014944;
  --myrtle:    #347A73;
  --vista:     #7C93CE;
  --thistle:   #C7B6DC;
  --tea:       #FCCCC9;

  /* tints derived from the palette */
  --tea-soft:  #FDE2E0;
  --ink:       #013430;          /* deepest text */
  --ink-soft:  #2c615b;          /* softened body text on light */
  --line:      rgba(1, 73, 68, .14);

  --font-display: "Bricolage Grotesque", sans-serif;
  --font-note:    "Fraunces", Georgia, serif;

  --shadow-card: 0 18px 40px -22px rgba(1, 52, 48, .55), 0 4px 10px -6px rgba(1, 52, 48, .3);
  --radius: 22px;
  --maxw: 560px;
}

* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: hidden; }

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100dvh;
  font-family: var(--font-display);
  color: #fff;
  background:
    radial-gradient(150% 85% at 50% -22%,
      var(--tea) 0%,
      rgba(252, 204, 201, .28) 26%,
      rgba(124, 147, 206, .12) 48%,
      transparent 66%),
    linear-gradient(180deg, #02564f 0%, #014944 42%, #013f3b 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* faint film grain for a printed-keepsake feel */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: .05;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- shared atoms --------------------------------------------------- */
.btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  border: 0;
  border-radius: 999px;
  padding: 15px 22px;
  min-height: 52px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease, opacity .2s;
  letter-spacing: .01em;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .55; cursor: default; }
.btn--block { width: 100%; }

.btn--primary { background: var(--brunswick); color: var(--tea); box-shadow: 0 10px 22px -12px rgba(1,73,68,.8); }
.btn--primary:hover { background: #013f3b; }

.btn--warm { background: var(--tea); color: var(--brunswick); box-shadow: 0 12px 26px -12px rgba(252,204,201,.7); }
.btn--warm:hover { background: #ffdbd8; }

.btn--ghost {
  background: transparent;
  color: var(--brunswick);
  border: 1.5px solid var(--line);
}
.btn--ghost:hover { border-color: var(--myrtle); }

.field { display: block; margin-bottom: 16px; }
.field-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--myrtle);
  margin-bottom: 7px;
}
.field-label .req,
.field-label .opt { font-style: normal; font-weight: 600; letter-spacing: .08em; font-size: .62rem; }
.field-label .req { color: #b06a66; }
.field-label .opt { color: #9bb0ad; }

input, textarea {
  width: 100%;
  font-family: var(--font-display);
  font-size: 16px;                       /* keeps iOS from zooming on focus */
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 14px 15px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
input:focus, textarea:focus {
  outline: none;
  border-color: var(--myrtle);
  box-shadow: 0 0 0 4px rgba(52, 122, 115, .15);
}

/* person tag */
.tag {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--tag, var(--vista));
  color: var(--brunswick);
  font-weight: 800;
  font-size: .78rem;
  letter-spacing: .03em;
  text-transform: lowercase;
}
.tag--sm { min-width: 24px; height: 24px; font-size: .68rem; padding: 0 7px; }

/* ===========================================================================
   LOGIN
   =========================================================================== */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 22px calc(32px + env(safe-area-inset-bottom));
}
.login-inner { width: 100%; max-width: 400px; text-align: center; }
.brand-kicker {
  text-transform: uppercase;
  letter-spacing: .34em;
  font-size: .72rem;
  font-weight: 700;
  color: var(--tea);
  margin: 0 0 10px;
}
.brand {
  font-size: clamp(3.4rem, 18vw, 4.6rem);
  line-height: .92;
  font-weight: 800;
  letter-spacing: -.02em;
  margin: 0;
  color: #fff;
  text-wrap: balance;
}
.brand-sub {
  font-family: var(--font-note);
  font-style: italic;
  font-size: 1.12rem;
  color: var(--tea);
  margin: 12px 0 26px;
}
.login-form { text-align: left; }
.login-form .field-label { color: var(--tea); }
.login-error { color: #ffd5d2; font-size: .9rem; min-height: 1.2em; margin: 2px 0 14px; font-weight: 600; }
.login-foot {
  margin-top: 22px;
  font-size: .78rem;
  letter-spacing: .04em;
  color: rgba(255,255,255,.55);
}
.setup-banner {
  background: rgba(252, 204, 201, .14);
  border: 1px solid rgba(252, 204, 201, .4);
  color: var(--tea-soft);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: .86rem;
  line-height: 1.5;
  text-align: left;
  margin-bottom: 22px;
}
.setup-banner code { background: rgba(0,0,0,.25); padding: 1px 6px; border-radius: 6px; }

/* ===========================================================================
   APP shell + topbar
   =========================================================================== */
#app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-bottom: calc(112px + env(safe-area-inset-bottom));   /* clear the add bar */
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 6px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  letter-spacing: -.01em;
  font-size: 1.18rem;
}
.topbar-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--tea);
  box-shadow: 0 0 0 4px rgba(252,204,201,.25);
}
.topbar-user { display: flex; align-items: center; gap: 9px; }
.topbar-email { font-size: .74rem; color: rgba(255,255,255,.6); max-width: 36vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iconbtn {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 0;
  background: rgba(255,255,255,.1);
  color: #fff;
  cursor: pointer;
  transition: background .2s;
}
.iconbtn:hover { background: rgba(255,255,255,.2); }
.iconbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ===========================================================================
   ON THIS DAY  — stacked, hand-placed white banners on the deep green
   =========================================================================== */
.onthisday { padding: 14px 20px 30px; }
.otd-head { margin: 6px 2px 20px; }
.otd-kicker {
  text-transform: uppercase;
  letter-spacing: .26em;
  font-size: .8rem;
  font-weight: 700;
  color: var(--tea);
  margin: 0;
}
.otd-today {
  font-size: clamp(2.6rem, 13vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1;
  margin: 4px 0 0;
  color: #fff;
}

.otd-stack { display: flex; flex-direction: column; gap: 18px; padding: 6px 4px 4px; }

.otd-card {
  background: #fff;
  color: var(--ink);
  border-radius: 18px;
  padding: 18px 18px 20px;
  box-shadow: var(--shadow-card);
  rotate: var(--rot, 0deg);
  translate: 0 0;
  transform-origin: 50% 50%;
  transition: rotate .35s ease, translate .35s ease, box-shadow .35s ease;
  animation: otd-in .55s cubic-bezier(.2, .75, .25, 1) backwards;
  animation-delay: calc(var(--i, 0) * 75ms + 120ms);
}
@keyframes otd-in {
  from { opacity: 0; translate: 0 18px; }
  to   { opacity: 1; translate: 0 0; }
}
.otd-card:hover { rotate: 0deg; translate: 0 -4px; box-shadow: 0 26px 48px -22px rgba(1,52,48,.6); }

.otd-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.otd-date {
  font-size: 1.06rem; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: var(--brunswick); margin: 0;
}
.otd-ago {
  font-size: .72rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--myrtle); margin: 3px 0 0; font-weight: 600;
}
.otd-title {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 14px 0 0;
  font-size: 1.34rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: .01em;
  text-transform: uppercase;
  color: var(--brunswick);
  word-break: break-word;
}
.otd-title .i-spark { flex: none; width: 19px; height: 19px; margin-top: 3px; fill: var(--vista); }
.otd-title span {
  background: linear-gradient(transparent 62%, var(--tea) 62%);   /* tea-rose headline highlight */
  padding: 0 2px;
}
.otd-note {
  font-family: var(--font-note);
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 12px 0 0;
}

.otd-empty {
  background: rgba(255,255,255,.07);
  border: 1px dashed rgba(252,204,201,.45);
  border-radius: 18px;
  padding: 24px 22px;
  color: var(--tea-soft);
}
.otd-empty p { margin: 0; font-family: var(--font-note); font-size: 1.16rem; }
.otd-empty em { color: #fff; }
.otd-empty-sub { margin-top: 8px !important; font-size: .96rem !important; color: rgba(255,255,255,.65); }

/* ===========================================================================
   TIMELINE  — on a warm Tea Rose panel
   =========================================================================== */
.timeline-panel {
  background: var(--tea);
  border-radius: 30px 30px 0 0;
  margin-top: 8px;
  padding: 26px 20px 40px;
  min-height: 50vh;
  box-shadow: 0 -20px 40px -28px rgba(1,52,48,.5);
}
.timeline-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}
.tl-kicker {
  text-transform: uppercase; letter-spacing: .2em; font-size: .68rem;
  font-weight: 700; color: var(--myrtle); margin: 0 0 4px;
}
.tl-heading {
  font-size: 1.7rem; font-weight: 800; letter-spacing: -.01em;
  color: var(--brunswick); margin: 0;
}
.sort-btn {
  display: inline-flex; align-items: center; gap: 7px;
  flex: none;
  font-family: var(--font-display); font-weight: 700; font-size: .8rem;
  letter-spacing: .02em;
  color: var(--brunswick);
  background: #fff;
  border: 1.5px solid rgba(1,73,68,.12);
  border-radius: 999px;
  padding: 9px 14px;
  min-height: 40px;
  cursor: pointer;
  transition: transform .15s, box-shadow .2s;
  box-shadow: 0 6px 14px -10px rgba(1,52,48,.5);
}
.sort-btn:active { transform: translateY(1px); }
.sort-arrow { font-size: 1rem; color: var(--myrtle); }

.year-group { margin-bottom: 10px; }
.year {
  font-size: clamp(2.6rem, 14vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--brunswick);
  margin: 18px 0 6px;
  line-height: 1;
}
.year::after {
  content: "";
  display: block;
  width: 46px; height: 4px;
  margin-top: 8px;
  border-radius: 4px;
  background: var(--vista);
}

.entries { list-style: none; margin: 0; padding: 0; position: relative; }
.entries::before {
  content: "";
  position: absolute;
  left: 20px; top: 8px; bottom: 8px;
  border-left: 2px dashed var(--myrtle);
  opacity: .65;
}
.entry { position: relative; padding: 0 0 22px 52px; }
.node {
  position: absolute;
  left: 5px; top: 2px;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  box-shadow: 0 0 0 4px var(--tea);             /* masks the dashed line cleanly */
  z-index: 1;
}
.node svg { width: 15px; height: 15px; fill: #fff; }
.node--vista   { background: var(--vista); }
.node--thistle { background: var(--thistle); }

.entry-card { padding-top: 1px; }
.entry-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: .72rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--myrtle);
  margin: 0 0 5px;
}
.entry-meta .dot { color: rgba(52,122,115,.5); }
.entry-title {
  font-size: 1.28rem; font-weight: 800; line-height: 1.14;
  letter-spacing: -.005em; color: var(--brunswick);
  margin: 0; word-break: break-word;
}
.entry-note {
  font-family: var(--font-note);
  font-size: 1.04rem; line-height: 1.55; color: var(--ink-soft);
  margin: 8px 0 0;
}
.entry-photo { margin-top: 12px; }
.entry-photo img {
  display: block; width: 100%; height: auto;
  border-radius: 16px;
  border: 4px solid #fff;
  box-shadow: var(--shadow-card);
}
.entry-actions { display: flex; gap: 18px; margin-top: 12px; }
.linkbtn {
  background: none; border: 0; padding: 8px 0; cursor: pointer;
  font-family: var(--font-display); font-weight: 700;
  font-size: .72rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--myrtle);
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.linkbtn:hover { color: var(--brunswick); border-color: var(--brunswick); }
.linkbtn--danger { color: #b06a66; }
.linkbtn--danger:hover { color: #8f4c48; border-color: #8f4c48; }

.tl-empty { text-align: center; padding: 40px 16px 30px; color: var(--ink-soft); }
.tl-empty-big {
  font-family: var(--font-note); font-style: italic;
  font-size: 1.8rem; color: var(--brunswick); margin: 0 0 8px;
}
.tl-empty p:not(.tl-empty-big) { font-family: var(--font-note); font-size: 1.06rem; margin: 0; }

/* ===========================================================================
   ADD BAR  (pinned)
   =========================================================================== */
.addbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: min(calc(100% - 32px), calc(var(--maxw) - 32px));
  z-index: 40;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 58px;
  border: 0; border-radius: 999px;
  background: var(--brunswick);
  color: var(--tea);
  font-family: var(--font-display); font-weight: 800; font-size: 1.05rem;
  letter-spacing: .01em;
  cursor: pointer;
  box-shadow: 0 16px 34px -12px rgba(1,52,48,.75), 0 2px 0 rgba(255,255,255,.04) inset;
  transition: transform .15s, box-shadow .2s, background .2s;
}
.addbar:hover { background: #013f3b; }
.addbar:active { transform: translateX(-50%) translateY(1px) scale(.995); }
.addbar-plus {
  display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--tea); color: var(--brunswick);
  font-size: 1.3rem; line-height: 1; font-weight: 700;
}

/* ===========================================================================
   SHEET (add / edit)
   =========================================================================== */
.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(1, 52, 48, .55);
  backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .22s ease;
}
.sheet.open .sheet-backdrop { opacity: 1; }
.sheet-panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-width: var(--maxw);
  margin: 0 auto;
  background: #fff;
  color: var(--ink);
  border-radius: 28px 28px 0 0;
  padding: 12px 22px calc(24px + env(safe-area-inset-bottom));
  max-height: 92dvh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform .26s cubic-bezier(.2, .8, .2, 1);
  box-shadow: 0 -20px 50px -20px rgba(1,52,48,.6);
}
.sheet.open .sheet-panel { transform: translateY(0); }
.sheet-grip {
  width: 42px; height: 5px; border-radius: 999px;
  background: var(--line); margin: 4px auto 14px;
}
.sheet-title {
  font-size: 1.5rem; font-weight: 800; letter-spacing: -.01em;
  color: var(--brunswick); margin: 0 0 18px;
}
.sheet-row { display: flex; gap: 12px; }
.field--date { flex: 1; }

.photo-row { display: flex; }
.photo-pick {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 50px; width: 100%;
  border-style: dashed; border-width: 1.5px;
  border-color: var(--myrtle);
  color: var(--brunswick);
}
.photo-preview { margin: 14px 0 0; position: relative; }
.photo-preview img {
  display: block; width: 100%; height: auto; max-height: 320px; object-fit: cover;
  border-radius: 16px; border: 4px solid #fff; box-shadow: var(--shadow-card);
}
.photo-remove {
  position: absolute; top: 12px; right: 12px;
  background: rgba(1,52,48,.78); color: #fff;
  border: 0; border-radius: 999px;
  padding: 8px 14px; font-family: var(--font-display); font-weight: 700;
  font-size: .72rem; letter-spacing: .1em; text-transform: uppercase;
  cursor: pointer;
}
.sheet-actions { display: flex; gap: 12px; margin-top: 22px; }
.sheet-actions .btn--ghost { flex: 1; }
.sheet-actions .btn--primary { flex: 2; }

/* ===========================================================================
   TOAST
   =========================================================================== */
.toast {
  position: fixed;
  left: 50%; transform: translateX(-50%) translateY(12px);
  bottom: calc(86px + env(safe-area-inset-bottom));
  z-index: 80;
  background: var(--ink);
  color: #fff;
  font-weight: 600; font-size: .92rem;
  padding: 13px 20px;
  border-radius: 999px;
  box-shadow: var(--shadow-card);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  max-width: calc(100% - 36px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===========================================================================
   Misc
   =========================================================================== */
body.locked { overflow: hidden; }

@media (min-width: 600px) {
  .onthisday { padding-left: 28px; padding-right: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-delay: 0ms !important; transition-duration: .001ms !important; }
  .otd-card { translate: 0 0; opacity: 1; }
}
