:root {
  --bg: #08080a;
  --text: #f5f1ee;
  --muted: rgba(245, 241, 238, 0.55);
  --faint: rgba(245, 241, 238, 0.32);
  --glass: rgba(255, 255, 255, 0.07);
  --glass-edge: rgba(255, 255, 255, 0.1);
  --champagne: #f3d6bd;
  --rose: #e7a3a0;
  --warm: linear-gradient(135deg, #f7dfc9 0%, #eeb7a8 55%, #e19a9f 100%);
  --ring: conic-gradient(from 210deg, #f7dfc9, #e19a9f, #b98bd6, #f7dfc9);
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; background: var(--bg); color: var(--text); }

body { display: flex; justify-content: center; overflow: hidden; }

/* Her photo as a soft glow. The blur is baked in once (app.js shrinks it to 24px and the browser stretches it), so
   nothing is re-blurred while scrolling. No `filter` or `backdrop-filter` anywhere in the scrolling area: that was
   the phone lag. */
.bg {
  position: fixed;
  inset: 0;
  background: center / cover no-repeat;
  opacity: 0.55;
  z-index: 0;
  pointer-events: none;
}
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 70% at 50% 0%, transparent 0%, rgba(8, 8, 10, 0.75) 55%, var(--bg) 100%);
}

.chat {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Header */
.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
  position: relative;
  z-index: 1;
  background: rgba(10, 9, 11, 0.94);
  border-bottom: 1px solid var(--glass-edge);
}
.who { line-height: 1.2; }
.name { font-family: var(--serif); font-size: 18px; font-weight: 600; letter-spacing: 0.2px; }
.status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 2px; }
.dot { position: relative; width: 7px; height: 7px; border-radius: 50%; background: #5fe0a0; }
.dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: #5fe0a0; animation: ping 2s ease-out infinite; }

/* Avatar rings */
.ring { display: inline-grid; place-items: center; border-radius: 50%; background: var(--ring); flex: none; }
.ring.sm { padding: 2px; }
.ring.lg { padding: 3px; box-shadow: 0 18px 50px rgba(231, 163, 160, 0.25); }
.ring img { border-radius: 50%; object-fit: cover; border: 2px solid var(--bg); display: block; background: #1a1a1f; }
.avatar { width: 36px; height: 36px; }
.avatar-big { width: 112px; height: 112px; border-width: 3px; }

/* Thread */
.thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 26px 16px 18px;
  display: flex;
  flex-direction: column-reverse; /* browser keeps the newest message in view, no JS scrolling */
  scrollbar-width: none;
}
.log { display: flex; flex-direction: column; gap: 4px; }
.still { animation: none !important; }
.thread::-webkit-scrollbar { display: none; }

.intro { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 8px 0 18px; }
.name-big { font-family: var(--serif); font-size: 30px; font-weight: 600; margin-top: 14px; letter-spacing: 0.3px; }
.tagline { font-size: 14px; color: var(--muted); margin-top: 4px; }
.fine { font-size: 11px; color: var(--faint); margin-top: 10px; letter-spacing: 0.3px; }
.fine a { color: var(--faint); }

.day, .system {
  align-self: center;
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--faint);
  margin: 6px 0 10px;
}
.system { margin-top: 14px; text-transform: none; letter-spacing: 0.2px; font-size: 12px; animation: fade 300ms ease backwards; }

.row { display: flex; align-items: flex-end; gap: 8px; }
.row.me { justify-content: flex-end; margin-top: 8px; }
.mini { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex: none; }
.mini.hidden { visibility: hidden; }

.msg {
  max-width: 76%;
  padding: 11px 15px;
  border-radius: 22px;
  font-size: 16px;
  line-height: 1.38;
  overflow-wrap: anywhere;
}
.her-msg, .typing {
  background: rgba(255, 255, 255, 0.085);
  border: 1px solid var(--glass-edge);
  border-bottom-left-radius: 8px;
  transform-origin: bottom left;
}
.typing { animation: pop-in 240ms var(--ease) backwards; }
.her-msg { animation: settle 200ms var(--ease) backwards; }
.me-msg {
  background: var(--warm);
  color: #2a1715;
  font-weight: 500;
  border-bottom-right-radius: 8px;
  transform-origin: bottom right;
  animation: send 280ms var(--ease) backwards;
}

.receipt {
  align-self: flex-end;
  font-size: 11px;
  color: var(--faint);
  margin: 3px 6px 6px 0;
  animation: fade 200ms ease backwards;
}

.typing { display: flex; gap: 5px; padding: 15px 16px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text); animation: bounce 1.2s ease-in-out infinite; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

/* Quick replies */
.dock {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px calc(18px + env(safe-area-inset-bottom));
  min-height: 24px;
}
.reply {
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  width: 100%;
  min-height: 52px;
  padding: 14px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(243, 214, 189, 0.28);
  cursor: pointer;
  touch-action: manipulation;
  animation: rise 300ms var(--ease) backwards;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, opacity 140ms ease;
}
.reply:disabled { cursor: default; }
.dock.leaving .reply { opacity: 0; transform: translateY(6px); }
.reply:hover { border-color: rgba(243, 214, 189, 0.55); }
.reply:active { transform: scale(0.98); background: rgba(243, 214, 189, 0.12); }

/* Unlock card */
.unlock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 12px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(243, 214, 189, 0.25);
  animation: rise 360ms var(--ease) backwards;
}
.unlock-title { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.cta {
  position: relative;
  overflow: hidden;
  width: 100%;
  margin-top: 4px;
  text-align: center;
  font-weight: 700;
  font-size: 17px;
  color: #2a1715;
  text-decoration: none;
  background: var(--warm);
  border-radius: 16px;
  padding: 17px;
  box-shadow: 0 12px 34px rgba(231, 163, 160, 0.35);
  transition: transform 120ms ease;
}
.cta:active { transform: scale(0.98); }
.cta::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 40%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: translateX(-120%);
  animation: shine 2.8s ease-in-out 0.6s infinite;
}
.note { font-size: 12px; color: var(--muted); }

/* Static pages */
.page { position: relative; z-index: 1; max-width: 560px; padding: 56px 24px; line-height: 1.65; color: var(--muted); overflow-y: auto; }
.page h1 { font-family: var(--serif); color: var(--text); font-size: 26px; margin-bottom: 18px; }
.page p { margin-bottom: 12px; }
.page a { color: var(--champagne); }

/* Only transform/opacity animate (GPU). Anything that must be read (bubbles, buttons, card) animates transform only,
   so a paused animation can never leave it dim. Opacity is used only for the transient typing bubble and receipts. */
@keyframes pop-in { from { opacity: 0.3; transform: translateY(6px) scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes settle { from { transform: scale(0.97); } to { transform: none; } }
@keyframes send { from { transform: translateY(10px) scale(0.92); } to { transform: none; } }
@keyframes rise { from { transform: translateY(12px) scale(0.98); } to { transform: none; } }
@keyframes fade { from { opacity: 0.5; } to { opacity: 1; } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.35; } 30% { transform: translateY(-4px); opacity: 0.9; } }
@keyframes ping { 0% { transform: scale(1); opacity: 0.6; } 80%, 100% { transform: scale(2.6); opacity: 0; } }
@keyframes shine { 0% { transform: translateX(-120%); } 60%, 100% { transform: translateX(300%); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
