/* Cookies and Thorra: sữa dâu + bánh quy */
:root {
  --milk: #FFF1F5;       /* nền sữa dâu */
  --petal: #FFC2D4;      /* hồng cánh hoa */
  --blush: #FFE4EC;
  --rose: #F7799A;       /* nút chính */
  --rose-deep: #E25C80;
  --cocoa: #6B3F3A;      /* chữ: nâu socola thay cho đen */
  --cocoa-soft: #9C716B;
  --cookie: #E8B57E;
  --cream: #FFFAF6;      /* mặt thẻ */
  --mint: #C9EDE0;
  --line: #F3C9D5;
  --tint: #FFE9F0;       /* đổi theo mùa */
  --radius-lg: 30px;
  --radius-md: 18px;
  --shadow: 0 6px 0 #F2BACB;   /* bóng "bánh quy" đặc, không mờ */
  --safe-b: env(safe-area-inset-bottom, 0px);
  --display: 'Baloo 2', 'Nunito', system-ui, sans-serif;
  --body: 'Nunito', system-ui, sans-serif;
}
:root[data-season="spring"] { --tint: #FFE3EE; }
:root[data-season="summer"] { --tint: #FFF3D6; }
:root[data-season="autumn"] { --tint: #FFE6D5; }
:root[data-season="winter"] { --tint: #ECE6FF; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--body);
  font-weight: 600;
  color: var(--cocoa);
  background:
    radial-gradient(120% 60% at 50% -10%, var(--tint), transparent 70%),
    var(--milk);
  background-attachment: fixed;
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--rose); outline-offset: 2px; border-radius: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  padding: 14px 16px calc(96px + var(--safe-b));
}

/* ---------- Hiệu ứng mùa ---------- */
.season-layer { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.particle {
  position: absolute; top: -40px;
  animation: fall linear forwards;
  opacity: .9;
}
.particle svg { width: 100%; height: 100%; display: block; }
.p-summer { animation-name: rise; top: auto; bottom: -40px; }
@keyframes fall {
  0%   { transform: translate(0, 0) rotate(0); }
  50%  { transform: translate(calc(var(--drift) * -.5), 55vh) rotate(calc(var(--spin) * .5)); }
  100% { transform: translate(var(--drift), 112vh) rotate(var(--spin)); opacity: .2; }
}
@keyframes rise {
  0%   { transform: translate(0, 0) scale(.6); opacity: 0; }
  15%  { opacity: .9; }
  100% { transform: translate(var(--drift), -110vh) scale(1.1); opacity: 0; }
}
.hopper {
  position: fixed; left: -60px; bottom: calc(78px + var(--safe-b)); z-index: 5; pointer-events: none;
  animation: hop-across 8.5s linear forwards;
}
.hopper svg { animation: hop .55s ease-in-out infinite; display: block; }
@keyframes hop-across { to { transform: translateX(calc(100vw + 120px)); } }
@keyframes hop { 0%,100% { transform: translateY(0); } 45% { transform: translateY(-22px) rotate(-6deg); } }

/* ---------- Đầu trang ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.brand { font-family: var(--display); font-weight: 800; font-size: 1.35rem; line-height: 1; letter-spacing: -.01em; }
.brand small { display: block; font-family: var(--body); font-size: .74rem; font-weight: 700; color: var(--cocoa-soft); margin-top: 3px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--cream); border: 2px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-weight: 800; font-size: .85rem; white-space: nowrap;
}

/* ---------- Trạng thái hai đứa ---------- */
.moods-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.mood-bubble {
  display: flex; align-items: center; gap: 8px; text-align: left;
  background: var(--cream); border: 2px solid var(--line); border-radius: 22px;
  padding: 8px 10px 8px 6px; min-height: 76px; position: relative;
}
.mood-bubble.mine { border-style: dashed; }
.mood-bubble .bunny-sticker { flex: none; }
.mood-bubble .who { font-size: .74rem; color: var(--cocoa-soft); font-weight: 800; }
.mood-bubble .what { font-family: var(--display); font-weight: 700; font-size: 1.02rem; line-height: 1.1; }
.mood-bubble .note { font-size: .78rem; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mood-bubble .when { font-size: .7rem; color: var(--cocoa-soft); }
.mood-bubble.empty .what { color: var(--cocoa-soft); }

/* ---------- Khung chụp (thẻ bánh quy) ---------- */
.camera {
  position: relative; aspect-ratio: 1; width: 100%;
  border-radius: 42px; overflow: hidden;
  background: #F9D6DF;
  box-shadow: 0 0 0 6px var(--cream), 0 0 0 8px var(--line), 0 14px 0 2px #F2BACB;
  margin: 8px 0 26px;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.camera::after {           /* đường may viền bánh */
  content: ''; position: absolute; inset: 10px; border-radius: 34px;
  border: 2.5px dashed rgba(255,255,255,.75); pointer-events: none;
}
/* absolute + width/height rõ ràng: Safari không tính height:100% theo aspect-ratio của khung */
.camera video, .camera img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
/* display:grid của .camera-empty ghi đè thuộc tính hidden -> lớp hướng dẫn đè lên hình camera */
.camera video.mirror { transform: scaleX(-1); }
.camera-empty[hidden], .camera video[hidden], .cam-tap[hidden] { display: none; }
.cam-tap {
  position: absolute; inset: 0; z-index: 3; border: none; background: rgba(107,63,58,.35);
  color: #fff; font-weight: 800; font-size: 1.05rem;
}
.camera-empty {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  padding: 24px; gap: 8px; align-content: center;
}
.camera-empty p { margin: 0; max-width: 24ch; font-size: .95rem; }
.rec-badge {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  background: rgba(226,92,128,.92); color: #fff; border-radius: 999px; padding: 3px 12px;
  font-weight: 800; font-size: .85rem; display: none;
}
.recording .rec-badge { display: block; }
.caption-input {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%);
  width: calc(100% - 48px); max-width: 320px; text-align: center;
  background: rgba(255,250,246,.88); border: none; border-radius: 999px;
  padding: 10px 16px; font-weight: 800; backdrop-filter: blur(6px);
}
.caption-input::placeholder { color: var(--cocoa-soft); }
.camera .sticker-on {
  position: absolute; top: 14px; left: 14px; z-index: 2;
  filter: drop-shadow(0 3px 0 rgba(107,63,58,.15));
}

.controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin: 0 6px 6px; }
.icon-btn {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--cream); border: 2px solid var(--line);
  display: grid; place-items: center; justify-self: center;
}
.icon-btn svg { width: 24px; height: 24px; }

/* Nút chụp = bánh quy chip socola */
.shutter {
  width: 86px; height: 86px; border-radius: 50%; border: none; padding: 0; position: relative;
  background: none; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-appearance: none; appearance: none; display: block; justify-self: center;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
/* Safari không kéo giãn SVG theo inset -> phải ghi rõ width/height, nếu không bánh quy lệch khỏi vòng */
.shutter svg { pointer-events: none; }
.shutter .ring { position: absolute; top: 0; left: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.shutter .ring circle { fill: none; stroke-width: 6; }
.shutter .ring .track { stroke: var(--petal); }
.shutter .ring .prog { stroke: var(--rose-deep); stroke-linecap: round; stroke-dasharray: 251.3; stroke-dashoffset: 251.3; }
.shutter .cookie { position: absolute; top: 9px; left: 9px; width: calc(100% - 18px); height: calc(100% - 18px); transition: transform .15s ease; }
.shutter:active .cookie, .recording .shutter .cookie { transform: scale(.9); }
.hint { text-align: center; font-size: .8rem; color: var(--cocoa-soft); margin: 2px 0 18px; }

.mood-picker { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; margin: -6px -16px 10px; padding-inline: 16px; }
.mood-picker::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--cream); border: 2px solid var(--line); border-radius: 20px;
  padding: 6px 8px 6px; width: 78px; font-size: .74rem; font-weight: 800;
}
.chip[aria-pressed="true"] { border-color: var(--rose); background: var(--blush); box-shadow: 0 3px 0 var(--rose); }

.send-row { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }

/* ---------- Nút ---------- */
.btn {
  border: none; border-radius: 999px; padding: 13px 20px;
  font-family: var(--display); font-weight: 700; font-size: 1.08rem; line-height: 1.1;
  background: var(--rose); color: #fff; box-shadow: 0 5px 0 var(--rose-deep);
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--rose-deep); }
.btn[disabled] { opacity: .6; pointer-events: none; }
.btn.soft { background: var(--cream); color: var(--cocoa); border: 2px solid var(--line); box-shadow: 0 5px 0 var(--line); }
.btn.block { width: 100%; }
.link-btn { background: none; border: none; color: var(--rose-deep); font-weight: 800; padding: 6px; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Dòng thời gian ---------- */
.section-title { font-family: var(--display); font-weight: 800; font-size: 1.3rem; margin: 26px 0 10px; display: flex; justify-content: space-between; align-items: baseline; }
.section-title span { font-family: var(--body); font-size: .82rem; color: var(--cocoa-soft); font-weight: 700; }
.moment { margin-bottom: 26px; }
.moment .media {
  position: relative; aspect-ratio: 1; border-radius: var(--radius-lg); overflow: hidden;
  background: var(--petal); border: 3px solid var(--cream); box-shadow: var(--shadow);
}
.moment .media img, .moment .media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.moment .cap {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); max-width: calc(100% - 32px);
  background: rgba(255,250,246,.9); border-radius: 999px; padding: 6px 14px; font-weight: 800;
  text-align: center; font-size: .92rem; backdrop-filter: blur(6px);
}
.moment .mood-tag {
  position: absolute; top: 10px; left: 10px; display: flex; align-items: center; gap: 2px;
  background: rgba(255,250,246,.9); border-radius: 999px; padding: 2px 12px 2px 2px; font-weight: 800; font-size: .8rem;
}
.moment .vid-badge {
  position: absolute; top: 12px; right: 12px; background: rgba(107,63,58,.6); color: #fff;
  border-radius: 999px; padding: 2px 10px; font-size: .75rem; font-weight: 800;
}
.moment .meta { display: flex; align-items: center; gap: 10px; padding: 10px 4px 0; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--cookie); color: var(--cocoa); font-family: var(--display); font-weight: 800; border: 2px solid var(--cocoa);
}
.avatar.partner { background: var(--mint); }
.meta .name { font-weight: 800; line-height: 1.1; }
.meta .time { font-size: .76rem; color: var(--cocoa-soft); }
.meta .grow { flex: 1; min-width: 0; }
.reacts { display: flex; gap: 4px; }
.react-btn { border: 2px solid var(--line); background: var(--cream); border-radius: 999px; padding: 3px 8px; font-size: .95rem; line-height: 1.2; }
.react-btn.on { background: var(--blush); border-color: var(--rose); }
.more-btn { background: none; border: none; font-size: 1.2rem; padding: 4px 6px; color: var(--cocoa-soft); }

.empty-state { text-align: center; padding: 26px 18px; background: var(--cream); border: 2px dashed var(--line); border-radius: var(--radius-lg); }
.empty-state p { margin: 6px 0 0; }

/* ---------- Lịch kỷ niệm ---------- */
.month-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 12px; }
.month-head h2 { font-family: var(--display); font-weight: 800; font-size: 1.5rem; margin: 0; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .dow { text-align: center; font-size: .72rem; color: var(--cocoa-soft); font-weight: 800; }
.cal .cell {
  aspect-ratio: 1; border-radius: 14px; position: relative; overflow: hidden;
  background: var(--cream); border: 2px solid transparent; display: grid; place-items: center;
  font-weight: 800; font-size: .85rem; color: var(--cocoa-soft); padding: 0;
}
.cal .cell.has { border-color: var(--cream); box-shadow: 0 3px 0 #F2BACB; }
.cal .cell img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cal .cell .n { position: relative; z-index: 1; }
.cal .cell.has .n { position: absolute; bottom: 2px; right: 4px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.45); font-size: .72rem; }
.cal .cell.today { border-color: var(--rose); }
.cal .cell.blank { background: transparent; }

.day-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.day-head h2 { font-family: var(--display); font-weight: 800; font-size: 1.3rem; margin: 0; text-align: center; line-height: 1.15; }
.day-head h2 small { display: block; font-family: var(--body); font-size: .8rem; color: var(--cocoa-soft); font-weight: 700; }
.status-log { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 18px; padding: 2px 16px 6px; scrollbar-width: none; }
.status-log .item { flex: none; display: flex; align-items: center; gap: 6px; background: var(--cream); border: 2px solid var(--line); border-radius: 999px; padding: 2px 12px 2px 2px; font-size: .8rem; font-weight: 800; }

/* ---------- Tụi mình ---------- */
.card { background: var(--cream); border: 2px solid var(--line); border-radius: var(--radius-lg); padding: 18px; margin-bottom: 16px; }
.card h3 { font-family: var(--display); font-weight: 800; font-size: 1.15rem; margin: 0 0 8px; }
.couple-hero { text-align: center; padding: 22px 18px; }
.couple-hero .pair { display: flex; justify-content: center; align-items: center; gap: 4px; }
.couple-hero .days { font-family: var(--display); font-weight: 800; font-size: 2.6rem; line-height: 1; margin: 8px 0 2px; color: var(--rose-deep); }
.code-box {
  font-family: var(--display); font-weight: 800; font-size: 2rem; letter-spacing: .12em;
  background: var(--blush); border: 2px dashed var(--rose); border-radius: 18px; text-align: center; padding: 8px; margin: 8px 0 12px;
}
.seg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.seg button { border: 2px solid var(--line); background: #fff; border-radius: 14px; padding: 8px 2px; font-size: .78rem; font-weight: 800; display: grid; gap: 2px; justify-items: center; }
.seg button[aria-pressed="true"] { border-color: var(--rose); background: var(--blush); }

/* ---------- Form ---------- */
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-weight: 800; font-size: .88rem; margin: 0 0 5px 6px; }
.field input {
  width: 100%; padding: 13px 16px; border-radius: 16px; border: 2px solid var(--line); background: #fff;
  font-weight: 700; outline: none;
}
.field input:focus { border-color: var(--rose); }
.field em { display: block; font-style: normal; font-size: .76rem; color: var(--cocoa-soft); margin: 4px 0 0 6px; }
.form-error { color: #C53B5C; font-weight: 800; font-size: .88rem; min-height: 1.2em; margin: 2px 6px 10px; }

.auth { min-height: calc(100vh - 40px); display: flex; flex-direction: column; justify-content: center; padding-bottom: 20px; }
.auth-hero { text-align: center; margin-bottom: 18px; }
.auth-hero h1 { font-family: var(--display); font-weight: 800; font-size: 2.2rem; line-height: 1; margin: 6px 0 4px; }
.auth-hero p { margin: 0; color: var(--cocoa-soft); }
.auth-hero .duo { display: inline-flex; align-items: flex-end; }
.auth-hero .duo .bunny-sticker:last-child { margin-left: -14px; transform: scaleX(-1); }
.auth .switch { text-align: center; margin-top: 16px; }

/* ---------- Thanh điều hướng ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(10px + var(--safe-b)); z-index: 10;
  width: min(440px, calc(100% - 24px));
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: rgba(255,250,246,.94); backdrop-filter: blur(10px);
  border: 2px solid var(--line); border-radius: 26px; padding: 6px; box-shadow: 0 6px 0 #F2BACB;
}
.tabbar a {
  text-decoration: none; color: var(--cocoa-soft); display: grid; justify-items: center; gap: 1px;
  font-size: .74rem; font-weight: 800; padding: 6px 0; border-radius: 20px;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--cocoa); background: var(--blush); }

/* ---------- Bottom sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(107,63,58,.28); z-index: 40; animation: fade .2s; }
.sheet {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 41;
  width: min(480px, 100%); max-height: 86vh; overflow-y: auto;
  background: var(--milk); border-radius: 30px 30px 0 0; padding: 10px 16px calc(20px + var(--safe-b));
  animation: up .25s cubic-bezier(.2,.9,.3,1.2);
}
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.sheet h3 { font-family: var(--display); font-weight: 800; font-size: 1.3rem; margin: 0 0 10px; text-align: center; }
.mood-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.mood-grid .chip { width: auto; }
@keyframes up { from { transform: translate(-50%, 100%); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Xem toàn màn hình ---------- */
.viewer { position: fixed; inset: 0; z-index: 50; background: #2A1A18; display: grid; place-items: center; animation: fade .15s; }
.viewer img, .viewer video { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer .close { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; z-index: 2; }

/* ---------- Toast + tải lên ---------- */
.toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top, 0px)); z-index: 60;
  transform: translate(-50%, -150%); transition: transform .3s cubic-bezier(.2,.9,.3,1.2);
  background: var(--cocoa); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 800; font-size: .9rem;
  max-width: calc(100% - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); }
.uploading {
  position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255,241,245,.7); z-index: 3;
  font-family: var(--display); font-weight: 800; font-size: 1.1rem;
}
.bounce { animation: bounce 1s ease-in-out infinite; }
@keyframes bounce { 50% { transform: translateY(-10px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* Lời mời bật thông báo ở trang chủ */
.push-banner[hidden] { display: none; }
.push-banner-text { font-weight: 800; margin-bottom: 12px; }
.push-banner-actions { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }

/* Ảnh đang gửi ngầm */
.moment video.mirror { transform: scaleX(-1); }
.moment.pending .media { opacity: .92; }
.pending-badge {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  background: rgba(107,63,58,.78); color: #fff; border-radius: 999px; padding: 4px 12px;
  font-weight: 800; font-size: .8rem;
}
.moment.failed .pending-badge { background: rgba(226,92,128,.95); }
.btn.small { padding: 8px 14px; font-size: .85rem; box-shadow: 0 3px 0 var(--line); }

/* Nút ▶ khi iPhone không cho tự phát video (Chế độ nguồn điện thấp) */
.moment .play-hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2;
  width: 64px; height: 64px; border-radius: 50%; display: none; place-items: center;
  background: rgba(107,63,58,.55); color: #fff; font-size: 1.6rem; pointer-events: none;
}
.moment .needs-tap .play-hint { display: grid; }
