*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --jacob-color: #7c6bf0;
  --jacob-dark: #5b4ed4;
  --jenn-color: #e8579e;
  --jenn-dark: #d4408a;
  --accent: #9d7bf7;
  --green: #34c77b;
  --gray-50: #faf8fc;
  --gray-100: #f4f1f8;
  --gray-200: #e8e3ef;
  --gray-300: #d4cede;
  --gray-500: #8a8198;
  --gray-700: #4a3f5c;
  --gray-900: #1e1533;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* ── Shadow scale ── */
  --shadow-xs: 0 1px 3px rgba(0,0,0,.06);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.12);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.16);
  --shadow-focus: 0 0 0 3px var(--input-focus-shadow);

  /* ── Radius scale ── */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* ── Type scale ── */
  --text-xs: 10px;
  --text-sm: 12px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 20px;
  --sent-color: var(--jacob-color);
  --sent-dark: var(--jacob-dark);
  --received-bg: #fff;
  --received-border: rgba(200, 170, 230, .35);

  /* ── Semantic surface tokens ── */
  --page-bg: #fdf7f2;
  --chat-bg-gradient-a: rgba(253, 200, 215, .16);
  --chat-bg-gradient-b: rgba(200, 170, 240, .12);
  --chat-bg-stripe: rgba(216, 180, 254, .025);
  --header-bg: rgba(245, 238, 255, .9);
  --header-grad-from: rgba(240, 235, 255, .92);
  --header-grad-to: rgba(255, 240, 248, .92);
  --header-border: rgba(200, 170, 230, .15);
  --card-bg: #fff;
  --input-bg: #fff;
  --input-border: rgba(200, 170, 230, .22);
  --input-focus-border: rgba(200, 170, 230, .5);
  --input-focus-shadow: rgba(200, 170, 230, .1);
  --input-bar-bg: rgba(253, 248, 243, .85);
  --input-bar-border: rgba(200, 170, 230, .12);
  --frosted-bg: rgba(255, 255, 255, .8);
  --frosted-border: rgba(255, 255, 255, .5);
  --frosted-bg-strong: rgba(255, 255, 255, .95);
  --received-msg-bg: #fff;
  --received-msg-border: rgba(200, 160, 230, .35);
  --date-divider-line: rgba(200, 170, 230, .25);
  --date-divider-bg: rgba(245, 235, 255, .5);
  --date-divider-border: rgba(200, 170, 230, .15);
  --date-divider-text: #b07cc1;
  --reaction-bg: rgba(255, 255, 255, .65);
  --reaction-bg-hover: rgba(255, 255, 255, .85);
  --reaction-bg-mine: rgba(157, 123, 247, .1);
  --reaction-picker-bg: rgba(255, 255, 255, .95);
  --reaction-picker-border: rgba(0, 0, 0, .06);
  --image-preview-bg: rgba(255, 255, 255, .65);
  --image-preview-border: rgba(255, 255, 255, .5);
  --heart-pill-bg: rgba(255, 240, 245, .85);
  --heart-pill-hover: rgba(255, 230, 240, .9);
  --heart-pill-border: rgba(255, 240, 245, .9);
  --heart-notif-bg: rgba(255, 240, 245, .95);
  --incoming-call-bg: rgba(255, 255, 255, .95);
  --login-card-bg: rgba(255, 255, 255, .96);
  --hover-overlay: rgba(0, 0, 0, .04);
  --label-purple: #b07cc1;
  --reply-preview-bg: rgba(253, 248, 243, .92);
  --cal-sheet-bg: #fff;
  --cal-input-bg: var(--gray-50);
  --cal-input-focus-bg: #fff;
}

[data-theme="dark"] {
  --gray-50: #1a1625;
  --gray-100: #201c2e;
  --gray-200: #2d2841;
  --gray-300: #3d3654;
  --gray-500: #8a8198;
  --gray-700: #c4bdd4;
  --gray-900: #ede8f5;
  --accent: #a98bfa;
  --received-bg: #241f35;
  --received-border: rgba(157, 123, 247, .2);

  --page-bg: #13101e;
  --chat-bg-gradient-a: rgba(232, 87, 158, .06);
  --chat-bg-gradient-b: rgba(157, 123, 247, .06);
  --chat-bg-stripe: rgba(157, 123, 247, .02);
  --header-bg: rgba(26, 20, 40, .92);
  --header-grad-from: rgba(30, 22, 50, .94);
  --header-grad-to: rgba(40, 20, 42, .94);
  --header-border: rgba(157, 123, 247, .12);
  --card-bg: #1e1a2e;
  --input-bg: #1e1a2e;
  --input-border: rgba(157, 123, 247, .15);
  --input-focus-border: rgba(157, 123, 247, .35);
  --input-focus-shadow: rgba(157, 123, 247, .08);
  --input-bar-bg: rgba(22, 19, 35, .9);
  --input-bar-border: rgba(157, 123, 247, .08);
  --frosted-bg: rgba(30, 26, 46, .85);
  --frosted-border: rgba(157, 123, 247, .08);
  --frosted-bg-strong: rgba(30, 26, 46, .95);
  --received-msg-bg: #1e1a2e;
  --received-msg-border: rgba(157, 123, 247, .2);
  --date-divider-line: rgba(157, 123, 247, .15);
  --date-divider-bg: rgba(30, 26, 46, .6);
  --date-divider-border: rgba(157, 123, 247, .1);
  --date-divider-text: #b499d6;
  --reaction-bg: rgba(30, 26, 46, .7);
  --reaction-bg-hover: rgba(40, 35, 60, .85);
  --reaction-bg-mine: rgba(157, 123, 247, .15);
  --reaction-picker-bg: rgba(30, 26, 46, .95);
  --reaction-picker-border: rgba(157, 123, 247, .1);
  --image-preview-bg: rgba(30, 26, 46, .7);
  --image-preview-border: rgba(157, 123, 247, .08);
  --heart-pill-bg: rgba(232, 87, 158, .12);
  --heart-pill-hover: rgba(232, 87, 158, .18);
  --heart-pill-border: rgba(232, 87, 158, .15);
  --heart-notif-bg: rgba(232, 87, 158, .15);
  --incoming-call-bg: rgba(30, 26, 46, .95);
  --login-card-bg: rgba(30, 26, 46, .96);
  --hover-overlay: rgba(255, 255, 255, .04);
  --label-purple: #b499d6;
  --reply-preview-bg: rgba(22, 19, 35, .92);
  --cal-sheet-bg: #1e1a2e;
  --cal-input-bg: #1a1625;
  --cal-input-focus-bg: #241f35;
}

/* Dark mode toggle icon swap */
[data-theme="dark"] #theme-toggle-btn .icon-sun { display: none; }
[data-theme="dark"] #theme-toggle-btn .icon-moon { display: block !important; }

/* Smooth theme transition */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
  transition: background-color .3s ease, color .2s ease, border-color .3s ease, box-shadow .3s ease !important;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: "DM Sans", "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.screen {
  height: 100%;
}

/* ── Login ── */

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(157, 123, 247, .3) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(232, 87, 158, .25) 0%, transparent 50%),
    linear-gradient(160deg, #1a1440 0%, #2d1f6b 30%, #4a1d7a 60%, #6e1d5a 100%);
  padding: 24px;
}

.login-container {
  width: 100%;
  max-width: 360px;
  background: var(--login-card-bg);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border-radius: 28px;
  padding: 44px 32px;
  box-shadow:
    0 25px 60px rgba(0,0,0,.25),
    0 0 0 1px rgba(255,255,255,.15),
    inset 0 1px 0 rgba(255,255,255,.5);
  animation: cardGlow 5s ease-in-out infinite;
  color: var(--gray-900);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.app-icon {
  font-size: 48px;
  margin-bottom: 8px;
  opacity: 0;
  animation:
    loginFadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both,
    iconFloat 3s ease-in-out 0.5s infinite,
    iconGlow 4s ease-in-out 0.5s infinite;
  will-change: transform, filter;
}

.login-header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.3px;
  background: linear-gradient(135deg, #7c6bf0, #b47af7, #e8579e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  opacity: 0;
  animation: loginFadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.08s both;
}

.login-subtitle {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
  font-style: italic;
  opacity: 0;
  animation: loginFadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.16s both;
}

.login-day-counter {
  font-size: var(--text-sm);
  margin-top: 10px;
  color: rgba(157, 123, 247, .7);
  font-weight: 500;
  letter-spacing: .3px;
  opacity: 0;
  animation: loginFadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.24s both;
}

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

@keyframes iconFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

@keyframes iconGlow {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(157, 123, 247, 0.3)); }
  50%      { filter: drop-shadow(0 0 16px rgba(232, 87, 158, 0.45)); }
}

@keyframes cardGlow {
  0%, 100% {
    box-shadow:
      0 25px 60px rgba(0,0,0,.25),
      0 0 0 1px rgba(255,255,255,.15),
      inset 0 1px 0 rgba(255,255,255,.5),
      0 0 30px rgba(124, 107, 240, 0.08);
  }
  50% {
    box-shadow:
      0 25px 60px rgba(0,0,0,.25),
      0 0 0 1px rgba(255,255,255,.15),
      inset 0 1px 0 rgba(255,255,255,.5),
      0 0 40px rgba(232, 87, 158, 0.12);
  }
}

#login-form input {
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: var(--text-lg);
  outline: none;
  transition: border-color .25s ease, background .25s ease, box-shadow .25s ease;
  background: var(--gray-50);
  color: var(--gray-900);
}

#login-form input:first-of-type {
  opacity: 0;
  animation: loginFadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.32s both;
}

#login-form input:nth-of-type(2) {
  opacity: 0;
  animation: loginFadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.40s both;
}

#login-form input:focus {
  border-color: var(--accent);
  background: var(--cal-input-focus-bg);
  box-shadow: var(--shadow-focus);
}

#login-btn {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, var(--jacob-color), #b47af7, var(--jenn-color));
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  font-size: var(--text-lg);
  font-weight: 600;
  cursor: pointer;
  transition: transform .2s cubic-bezier(.21,1.02,.55,1), box-shadow .2s;
  box-shadow: 0 4px 15px rgba(124, 107, 240, .3);
  letter-spacing: .2px;
  opacity: 0;
  animation: loginFadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.48s both;
}

#login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(124, 107, 240, .35);
}

#login-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(124, 107, 240, .3);
}

.error {
  color: #ef4444;
  text-align: center;
  margin-top: 12px;
  font-size: var(--text-base);
}

/* ── Chat ── */

#chat-screen[hidden] {
  display: none;
}

#chat-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background:
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 18px,
      var(--chat-bg-stripe) 18px,
      var(--chat-bg-stripe) 19px
    ),
    radial-gradient(circle at 20% 85%, var(--chat-bg-gradient-a) 0%, transparent 50%),
    radial-gradient(circle at 80% 15%, var(--chat-bg-gradient-b) 0%, transparent 50%),
    var(--page-bg);
  background-attachment: fixed;
}

/* Header */

#chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  background: var(--header-bg);
  background-image: linear-gradient(135deg, var(--header-grad-from), var(--header-grad-to));
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border-bottom: 1px solid var(--header-border);
  box-shadow: 0 2px 12px rgba(124, 107, 240, .06);
  flex-shrink: 0;
  padding-top: max(14px, env(safe-area-inset-top, 0px));
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  overflow: hidden;
  padding-left: 4px;
}


.header-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.partner-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.partner-name {
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -.4px;
  color: var(--partner-color, var(--gray-900));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Partner Status Line ── */

.status-line {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--gray-500);
  white-space: nowrap;
  overflow: visible;
  line-height: 1;
  margin-top: 2px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gray-300);
  flex-shrink: 0;
  transition: background .3s ease;
}

.status-dot.online {
  background: #10b981;
  animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, .4);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0);
    transform: scale(1.15);
  }
}

.status-label {
  font-weight: 600;
  transition: color .3s ease;
}

.status-label.online {
  color: #10b981;
}

.status-sep {
  opacity: .3;
  font-size: 10px;
}

.status-weather {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.status-weather span {
  font-size: inherit;
}

#status-weather-temp {
  font-weight: 600;
}

/* ── Header Tray ── */

.header-tray {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  max-height: 0;
  overflow: hidden;
  padding: 0 18px;
  background-image: linear-gradient(135deg, var(--header-grad-from), var(--header-grad-to));
  border-bottom: 1px solid var(--header-border);
  transition: max-height 0.25s ease, padding 0.25s ease;
}

.header-tray.open {
  max-height: 90px;
  padding: 12px 18px;
}

.tray-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-500);
  padding: 0;
  transition: transform 0.15s;
}

.tray-btn:hover {
  transform: scale(1.05);
}

.tray-btn:active {
  transform: scale(0.92);
}

.tray-btn .tray-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1.5px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.tray-btn svg {
  width: 22px;
  height: 22px;
}

.tray-btn > span:last-child:not(.tray-icon-wrap) {
  display: none;
}

/* ── Tray button individual colors ── */
#photo-album-btn .tray-icon-wrap {
  color: rgba(180, 122, 247, .55);
  background: rgba(180, 122, 247, .06);
  border-color: rgba(180, 122, 247, .12);
}
#photo-album-btn:hover .tray-icon-wrap {
  color: #b47af7;
  background: rgba(180, 122, 247, .14);
  border-color: rgba(180, 122, 247, .25);
}

#spotify-btn .tray-icon-wrap {
  color: rgba(29, 185, 84, .55);
  background: rgba(29, 185, 84, .06);
  border-color: rgba(29, 185, 84, .12);
}
#spotify-btn:hover .tray-icon-wrap {
  color: #1DB954;
  background: rgba(29, 185, 84, .14);
  border-color: rgba(29, 185, 84, .25);
}

#lang-toggle-btn .tray-icon-wrap {
  color: rgba(59, 130, 246, .55);
  background: rgba(59, 130, 246, .06);
  border-color: rgba(59, 130, 246, .12);
}
#lang-toggle-btn:hover .tray-icon-wrap {
  color: #3b82f6;
  background: rgba(59, 130, 246, .14);
  border-color: rgba(59, 130, 246, .25);
}

#sound-toggle-btn .tray-icon-wrap {
  color: rgba(245, 158, 11, .55);
  background: rgba(245, 158, 11, .06);
  border-color: rgba(245, 158, 11, .12);
}
#sound-toggle-btn:hover .tray-icon-wrap {
  color: #f59e0b;
  background: rgba(245, 158, 11, .14);
  border-color: rgba(245, 158, 11, .25);
}

#header-tray-toggle {
  color: rgba(99, 102, 241, 1);
  border-color: rgba(99, 102, 241, .25);
  background: rgba(99, 102, 241, .12);
  animation: gentlePulse 2.5s ease-in-out 3;
}

#header-tray-toggle:hover {
  color: #4f46e5;
  border-color: rgba(99, 102, 241, .4);
  background: rgba(99, 102, 241, .2);
  animation: none;
}

#header-tray-toggle.open {
  animation: none;
}

@keyframes gentlePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, .0); }
  50% { box-shadow: 0 0 0 5px rgba(99, 102, 241, .2); }
}

@keyframes spotifyPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(29, 185, 84, .0); }
  50% { box-shadow: 0 0 0 5px rgba(29, 185, 84, .2); }
}

#spotify-btn .tray-icon-wrap.spotify-glow {
  animation: spotifyPulse 2.5s ease-in-out 3;
}

#spotify-btn:hover .tray-icon-wrap.spotify-glow {
  animation: none;
}

.chevron-icon {
  transition: transform 0.25s ease;
}

.chevron-icon.open {
  transform: rotate(180deg);
}

/* Floating event pill */

/* Sticky pills row */
.floating-event-pill {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  width: fit-content;
  max-width: 85%;
  margin: 8px auto 4px;
  padding: 6px 16px;
  border-radius: var(--radius-xl);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  box-shadow: 0 2px 12px rgba(0,0,0,.08), 0 0 0 1px rgba(255,255,255,.3) inset;
  animation: eventPillIn .45s cubic-bezier(.34,1.56,.64,1) both;
  transition: opacity .3s ease, transform .3s ease;
}

.floating-event-pill[hidden] { display: none !important; }

.floating-event-pill:hover { transform: scale(1.03); }
.floating-event-pill:active { transform: scale(0.97); opacity: .8; }

.floating-event-pill.type-event  { background: rgba(139,92,246,.15); color: var(--cal-event); }
.floating-event-pill.type-trip   { background: rgba(59,130,246,.15); color: var(--cal-trip); }
.floating-event-pill.type-date   { background: rgba(236,72,153,.15); color: var(--cal-date); }
.floating-event-pill.type-memory { background: rgba(245,158,11,.15); color: var(--cal-memory); }

@keyframes eventPillIn {
  0% { opacity: 0; transform: translateY(-12px) scale(0.85); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Language toggle */

#lang-toggle-btn.swapping {
  animation: langSwap .3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes langSwap {
  0%   { transform: scale(1) rotateY(0deg); opacity: 1; }
  40%  { transform: scale(.7) rotateY(90deg); opacity: 0; }
  60%  { transform: scale(.7) rotateY(-90deg); opacity: 0; }
  100% { transform: scale(1) rotateY(0deg); opacity: 1; }
}

#logout-btn {
  cursor: pointer;
}

#logout-btn .tray-icon-wrap {
  color: rgba(239, 68, 68, .55);
  background: rgba(239, 68, 68, .06);
  border-color: rgba(239, 68, 68, .12);
}

#logout-btn:hover .tray-icon-wrap {
  color: #ef4444;
  background: rgba(239, 68, 68, .14);
  border-color: rgba(239, 68, 68, .25);
}

/* Messages */

#messages-container {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 18px;
}

/* Custom scrollbar */
#messages-container::-webkit-scrollbar {
  width: 4px;
}
#messages-container::-webkit-scrollbar-track {
  background: transparent;
}
#messages-container::-webkit-scrollbar-thumb {
  background: rgba(139,92,246,.15);
  border-radius: 10px;
}

/* ── Scroll-to-bottom button ── */

.scroll-to-bottom-btn {
  position: absolute;
  bottom: var(--input-area-height, 70px);
  right: 16px;
  z-index: 6;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--jacob-color), var(--jacob-dark));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 4px 14px rgba(124, 107, 240, .35),
    0 2px 6px rgba(0, 0, 0, .1);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, bottom 0.25s ease;
}

.scroll-to-bottom-btn.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.scroll-to-bottom-btn.visible.first-show {
  animation: scrollBtnEntrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scrollBtnEntrance {
  0%   { opacity: 0; transform: translateY(20px) scale(0.6); }
  60%  { opacity: 1; transform: translateY(-6px) scale(1.08); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.scroll-to-bottom-btn:hover {
  transform: translateY(-2px);
  box-shadow:
    0 6px 20px rgba(124, 107, 240, .45),
    0 2px 8px rgba(0, 0, 0, .12);
}

.scroll-to-bottom-btn:active {
  transform: scale(0.93);
}

.scroll-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--jenn-color);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(232, 87, 158, .4);
  animation: badgePop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.scroll-unread-badge[hidden] {
  display: none;
}

@keyframes badgePop {
  0%   { transform: scale(0); }
  100% { transform: scale(1); }
}

#messages {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 100%;
  justify-content: flex-end;
}

/* ── Message groups ── */

.msg-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 20px;
}

.msg-group:first-child {
  margin-top: 0;
}

.msg-group-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .4px;
  text-transform: uppercase;
  padding: 0 4px;
  margin-bottom: 4px;
}

.msg-group.sent-group {
  align-items: flex-end;
}

.msg-group.sent-group .msg-group-label {
  text-align: right;
  color: color-mix(in srgb, var(--sent-color) 70%, #fff);
}

.msg-group.received-group {
  align-items: flex-start;
}

.msg-group.received-group .msg-group-label {
  color: var(--label-purple);
}


/* ── Message bubbles ── */

.msg {
  max-width: 72%;
  padding: 11px 16px;
  border-radius: var(--radius-xl);
  font-size: 14.5px;
  line-height: 1.5;
  word-wrap: break-word;
  position: relative;
  transition: transform .2s ease, opacity .2s ease;
}

.msg.long-pressing {
  transform: scale(0.97);
  opacity: 0.8;
}

@keyframes msgSlideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes msgSlideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.msg.sent {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--sent-color), var(--sent-dark));
  color: #fff;
  border-radius: 20px 20px 6px 20px;
  box-shadow:
    0 3px 12px color-mix(in srgb, var(--sent-color) 22%, transparent),
    0 1px 3px rgba(0,0,0,.05);
  animation: msgSlideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.msg.received {
  align-self: flex-start;
  background: var(--received-msg-bg);
  color: var(--gray-900);
  border-radius: 20px 20px 20px 6px;
  border-left: 3px solid var(--received-msg-border);
  box-shadow:
    0 1px 3px rgba(0,0,0,.02),
    0 4px 12px rgba(0,0,0,.03);
  animation: msgSlideInLeft 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Consecutive sent — soften the top-right corner */
.msg-group.sent-group .msg.sent + .msg.sent {
  border-top-right-radius: 10px;
}

/* Consecutive received — soften the top-left corner */
.msg-group.received-group .msg.received + .msg.received {
  border-top-left-radius: 10px;
}

.msg-time {
  font-size: var(--text-xs);
  color: var(--gray-500);
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  overflow: hidden;
  transition: max-height .25s ease, opacity .2s ease, margin-top .25s ease;
}

/* Show timestamp on hover (desktop) */
.msg:hover .msg-time {
  max-height: 24px;
  opacity: .55;
  margin-top: 5px;
}

/* Show timestamp when gap-triggered or tapped */
.msg.show-time .msg-time {
  max-height: 24px;
  opacity: .55;
  margin-top: 5px;
}

.msg.sent .msg-time {
  text-align: right;
}

.msg:hover.sent .msg-time,
.msg.sent.show-time .msg-time {
  opacity: 1;
  color: rgba(255, 255, 255, 0.4);
}

/* Always show time on last sent message (read-check visibility) */
.msg-group.sent-group .msg.sent:last-child .msg-time {
  max-height: 24px;
  opacity: 1;
  margin-top: 5px;
  color: rgba(255, 255, 255, 0.4);
}

/* On touch devices, disable hover reveal — rely on .show-time class */
@media (hover: none) {
  .msg:hover .msg-time {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
  }
  .msg:hover.sent .msg-time {
    opacity: 0;
  }
}

.msg-read-check {
  display: inline-flex;
  align-items: center;
  margin-left: 3px;
  vertical-align: text-bottom;
  position: relative;
  top: 0.5px;
}

.msg-read-check svg {
  width: 12px;
  height: 12px;
  transition: color 0.3s ease, filter 0.3s ease;
}

.msg-read-check svg circle {
  stroke: rgba(255, 255, 255, 0.2);
  fill: transparent;
  transition: stroke 0.3s ease, fill 0.3s ease;
}

.msg-read-check svg path {
  stroke: rgba(255, 255, 255, 0.2);
  transition: stroke 0.3s ease;
}

.msg-read-check.read svg circle {
  stroke: #fff;
  fill: rgba(255, 255, 255, .25);
}

.msg-read-check.read svg path {
  stroke: #fff;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, .6));
}

.date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 26px 0 14px;
}

.date-divider::before,
.date-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to var(--dir, right), transparent, var(--date-divider-line));
}

.date-divider::after {
  --dir: left;
}

.date-divider-text {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--date-divider-text);
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 4px 18px;
  background: var(--date-divider-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--date-divider-border);
  border-radius: var(--radius-xl);
  white-space: nowrap;
}

.unread-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 18px 0 10px;
}

.unread-divider::before,
.unread-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--accent);
  opacity: .5;
}

.unread-divider-text {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 3px 14px;
}

/* Typing indicator */

#typing-indicator[hidden] {
  display: none;
}

#typing-indicator {
  padding: 6px 18px 8px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

#typing-text {
  font-size: 11px;
  color: var(--gray-500);
  padding-left: 4px;
  font-weight: 500;
  letter-spacing: .2px;
}

.typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 16px;
  background: var(--received-bg);
  border-radius: 20px 20px 20px 6px;
  border-left: 3px solid var(--received-border);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, .02),
    0 4px 12px rgba(0, 0, 0, .03);
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sent-color);
  animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: .15s;
}

.typing-dot:nth-child(3) {
  animation-delay: .3s;
}

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0) scale(1);
    opacity: .3;
  }
  30% {
    transform: translateY(-5px) scale(1.15);
    opacity: .9;
  }
}

/* Input bar */

#input-bar {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 10px 12px;
  padding-bottom: max(10px, var(--safe-bottom));
  background: var(--input-bar-bg);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border-top: 1px solid var(--input-bar-border);
  flex-shrink: 0;
}

#message-input {
  flex: 1;
  min-width: 0;
  padding: 7px 16px;
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-2xl);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 120px;
  line-height: 1.4;
  background: var(--input-bg);
  color: var(--gray-900);
  transition: border-color .25s, background .25s, box-shadow .25s, height .15s ease;
}

#message-input:focus {
  border-color: var(--input-focus-border);
  background: var(--input-bg);
  box-shadow: var(--shadow-focus);
}

#send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--sent-color), var(--sent-dark));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform .2s cubic-bezier(.21,1.02,.55,1), box-shadow .2s, opacity .25s, background .3s ease;
  box-shadow:
    0 2px 6px rgba(124, 107, 240, .25),
    0 0 0 0 rgba(124, 107, 240, 0);
}

#send-btn:disabled {
  opacity: .3;
  cursor: default;
  box-shadow: none;
  transform: none;
  background: var(--gray-300);
}

#send-btn:not(:disabled):hover {
  transform: scale(1.08);
  box-shadow:
    0 3px 10px rgba(124, 107, 240, .3),
    0 0 0 3px rgba(124, 107, 240, .08);
}

#send-btn:not(:disabled):active {
  transform: scale(.92);
}

/* Image button */

#image-btn,
#video-btn,
#screenshot-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--gray-500);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color .2s, transform .15s ease;
}

#image-btn:hover,
#video-btn:hover,
#screenshot-btn:hover {
  color: var(--gray-700);
  transform: scale(1.1);
}

#image-btn:active,
#video-btn:active,
#screenshot-btn:active {
  color: var(--accent);
  transform: scale(0.92);
}

#screenshot-btn {
  animation: screenshotPulse 2.5s ease-in-out 3;
}

#screenshot-btn:hover {
  animation: none;
}

@keyframes screenshotPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, .0); }
  50% { box-shadow: 0 0 0 5px rgba(99, 102, 241, .2); }
}

/* Drop zone strip */

.drop-zone-strip[hidden] {
  display: none;
}

.drop-zone-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(99, 102, 241, .06);
  border-top: 2px dashed rgba(99, 102, 241, .3);
  color: rgba(99, 102, 241, .65);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

[data-theme="dark"] .drop-zone-strip {
  background: rgba(99, 102, 241, .08);
  border-color: rgba(99, 102, 241, .25);
  color: rgba(129, 132, 255, .6);
}

/* Image preview */

#image-preview {
  position: relative;
  padding: 8px 14px;
  background: var(--image-preview-bg);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--image-preview-border);
  flex-shrink: 0;
}

#image-preview img {
  max-width: 240px;
  max-height: 200px;
  border-radius: 10px;
  display: block;
}

#remove-preview {
  position: absolute;
  top: 4px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: var(--text-lg);
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Message images */

.msg-image {
  max-width: 240px;
  border-radius: 10px;
  display: block;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .1), 0 1px 3px rgba(0, 0, 0, .06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.msg-image:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .14), 0 2px 6px rgba(0, 0, 0, .08);
}

/* Shimmer loading placeholder for images */
.msg-image-wrap {
  position: relative;
  display: inline-block;
  max-width: 240px;
  border-radius: 10px;
  overflow: hidden;
}

.msg-image-wrap.loading {
  min-width: 180px;
  min-height: 120px;
  background: var(--gray-200);
}

.msg-image-wrap.loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.5) 50%, transparent 100%);
  animation: shimmer 1.5s ease-in-out infinite;
}

.msg-image-wrap.loading .msg-image {
  opacity: 0;
}

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

.msg-image-wrap + .msg-text,
.msg-image + .msg-text {
  margin-top: 6px;
}

.msg:has(.msg-image) {
  padding: 4px;
}

.msg:has(.msg-image) .msg-text {
  padding: 4px 10px 0;
}

.msg:has(.msg-image) .msg-time {
  padding: 0 10px 4px;
}

/* Border-radius consistency: inner radius = bubble radius - padding */
.msg.sent:has(.msg-image) .msg-image,
.msg.sent:has(.msg-image) .msg-image-wrap {
  border-radius: 16px 16px 2px 16px;
}

.msg.received:has(.msg-image) .msg-image,
.msg.received:has(.msg-image) .msg-image-wrap {
  border-radius: 16px 16px 16px 2px;
}

/* ── Video preview ── */

#video-preview {
  position: relative;
  padding: 8px 14px;
  background: var(--image-preview-bg);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--image-preview-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

#video-preview[hidden] { display: none; }

#video-preview-thumb {
  width: 60px;
  height: 44px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--gray-200);
}

.video-preview-name {
  flex: 1;
  min-width: 0;
  font-size: var(--text-sm);
  color: var(--gray-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#remove-video-preview {
  position: absolute;
  top: 4px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: var(--text-lg);
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gray-200);
  overflow: hidden;
}

.video-progress-bar[hidden] { display: none; }

.video-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width .15s linear;
}

/* ── Video in chat bubble ── */

.msg-video-wrap {
  position: relative;
  max-width: 280px;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: #000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12), 0 1px 3px rgba(0, 0, 0, .06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.msg-video-wrap:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .18), 0 2px 6px rgba(0, 0, 0, .08);
}

.msg-video-wrap video {
  width: 100%;
  display: block;
  border-radius: 10px;
}

.msg-video-wrap .video-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .25);
  transition: background 0.2s ease;
  pointer-events: none;
}

.msg-video-wrap:hover .video-play-overlay {
  background: rgba(0, 0, 0, .35);
}

.msg-video-wrap .video-play-overlay svg {
  width: 48px;
  height: 48px;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .35));
  opacity: .9;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.msg-video-wrap:hover .video-play-overlay svg {
  transform: scale(1.08);
  opacity: 1;
}

.msg-video-wrap.playing .video-play-overlay {
  opacity: 0;
}

.msg-video-wrap + .msg-text {
  margin-top: 6px;
}

.msg:has(.msg-video-wrap) {
  padding: 4px;
}

.msg:has(.msg-video-wrap) .msg-text {
  padding: 4px 10px 0;
}

.msg:has(.msg-video-wrap) .msg-time {
  padding: 0 10px 4px;
}

.msg.sent:has(.msg-video-wrap) .msg-video-wrap,
.msg.sent:has(.msg-video-wrap) .msg-video-wrap video {
  border-radius: 16px 16px 2px 16px;
}

.msg.received:has(.msg-video-wrap) .msg-video-wrap,
.msg.received:has(.msg-video-wrap) .msg-video-wrap video {
  border-radius: 16px 16px 16px 2px;
}

/* ── Fullscreen video overlay ── */

.video-overlay[hidden] { display: none; }

.video-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1300;
}

.video-overlay video {
  max-width: 95%;
  max-height: 90%;
  border-radius: var(--radius-sm);
  outline: none;
}

.video-overlay-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  z-index: 1;
}

.video-overlay-close:hover {
  background: rgba(255,255,255,.3);
}

/* ── Album play icon overlay (for video thumbnails) ── */

.photo-album-item .album-play-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.photo-album-item .album-play-icon svg {
  width: 32px;
  height: 32px;
  filter: drop-shadow(0 1px 4px rgba(0,0,0,.4));
  opacity: .85;
}

/* Fullscreen image overlay */

.image-overlay[hidden] {
  display: none;
}

.image-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: pointer;
}

.image-overlay img {
  max-width: 95%;
  max-height: 85%;
  object-fit: contain;
  border-radius: 4px;
}

.overlay-action-btn {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}

.overlay-action-btn:hover {
  background: rgba(255,255,255,.3);
}

/* Empty state */

.empty-state {
  text-align: center;
  color: var(--gray-500);
  padding: 60px 24px;
  font-size: 15px;
  line-height: 1.6;
}

.empty-state .emoji {
  font-size: 64px;
  margin-bottom: 16px;
  animation: emptyFloat 3s ease-in-out infinite;
}

@keyframes emptyFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ── Call UI ── */

/* Header call buttons */

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}


/* Heart pill next to partner name */
.heart-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px 4px 8px;
  border-radius: 14px;
  border: 1px solid rgba(232, 87, 158, .2);
  background: var(--heart-pill-bg);
  color: var(--jenn-color);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(232, 87, 158, .08);
  transition: transform .15s cubic-bezier(.21,1.02,.55,1), box-shadow .2s, background .2s;
  flex-shrink: 0;
  position: relative;
}

.heart-pill svg {
  width: 14px;
  height: 14px;
}

.heart-pill span {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -.2px;
  line-height: 1;
}

.heart-pill:hover {
  background: var(--heart-pill-hover);
  box-shadow: 0 4px 14px rgba(232, 87, 158, .18);
  transform: scale(1.04);
}

.heart-pill:active {
  transform: scale(0.96);
}

.heart-pill.tapped {
  animation: heartPulse 1.5s ease-in-out infinite;
  background: rgba(255, 220, 235, .9);
  border-color: rgba(232, 87, 158, .4);
}

.heart-pill.partner-tapped {
  animation: heartGlow 1s ease-in-out infinite;
  background: var(--heart-pill-hover);
  border-color: rgba(232, 87, 158, .4);
}

.heart-pill.partner-tapped::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e8579e;
  border: 2px solid var(--heart-pill-border);
  animation: heartDot 1s ease-in-out infinite;
}

@keyframes heartPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

@keyframes heartGlow {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 2px rgba(232, 87, 158, .3)); }
  50% { transform: scale(1.1); filter: drop-shadow(0 0 8px rgba(232, 87, 158, .6)); }
}

@keyframes heartDot {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* Love burst overlay */
.love-burst-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.love-burst-overlay .love-heart {
  position: absolute;
  font-size: 24px;
  animation: loveFloat linear forwards;
  opacity: 0;
  pointer-events: none;
}

@keyframes loveFloat {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.3) rotate(0deg);
  }
  10% {
    opacity: 1;
  }
  80% {
    opacity: .8;
  }
  100% {
    opacity: 0;
    transform: translateY(-100vh) scale(1.2) rotate(var(--rot, 30deg));
  }
}

.love-burst-overlay .love-center-heart {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 100px;
  animation: loveCenterPop .8s cubic-bezier(.17,.67,.35,1.5) forwards;
  pointer-events: none;
  filter: drop-shadow(0 0 24px rgba(232, 87, 158, .5));
}

@keyframes loveCenterPop {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  40% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  60% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
}

.love-burst-overlay .love-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  border: 3px solid rgba(232, 87, 158, .4);
  transform: translate(-50%, -50%);
  animation: loveRing 1.2s ease-out forwards;
  pointer-events: none;
}

@keyframes loveRing {
  0% { width: 0; height: 0; opacity: 1; border-width: 4px; }
  100% { width: 380px; height: 380px; opacity: 0; border-width: 1px; }
}

/* Heart notification toast */
.heart-notification {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  opacity: 0;
  background: var(--heart-notif-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(232, 87, 158, .2);
  border-radius: var(--radius-xl);
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 500;
  color: #c2185b;
  box-shadow: 0 4px 16px rgba(232, 87, 158, .15);
  z-index: 100;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity .35s ease, transform .35s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.heart-notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.heart-notification-icon {
  font-size: 15px;
  animation: heartNotifBeat .6s ease-in-out 2;
}

@keyframes heartNotifBeat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

/* ── Toast Notification System ── */

.toast-container {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 360px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-xl);
  font-size: 13px;
  font-weight: 500;
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .12), 0 0 0 1px rgba(255, 255, 255, .15) inset;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-16px);
  transition: opacity .3s ease, transform .3s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-icon {
  font-size: 15px;
  flex-shrink: 0;
}

.toast-success {
  background: rgba(34, 197, 94, .15);
  border: 1px solid rgba(34, 197, 94, .25);
  color: #15803d;
}

[data-theme="dark"] .toast-success {
  color: #4ade80;
}

.toast-error {
  background: rgba(239, 68, 68, .15);
  border: 1px solid rgba(239, 68, 68, .25);
  color: #dc2626;
}

[data-theme="dark"] .toast-error {
  color: #f87171;
}

.toast-info {
  background: rgba(124, 107, 240, .12);
  border: 1px solid rgba(124, 107, 240, .2);
  color: #6d28d9;
}

[data-theme="dark"] .toast-info {
  color: #a78bfa;
}

.toast-love {
  background: var(--heart-notif-bg);
  border: 1px solid rgba(232, 87, 158, .2);
  color: #c2185b;
}

[data-theme="dark"] .toast-love {
  color: #f472b6;
}

.toast-love .toast-icon {
  animation: heartNotifBeat .6s ease-in-out 2;
}

/* ── Search Bar ── */

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  background: var(--header-bg);
  background-image: linear-gradient(135deg, var(--header-grad-from), var(--header-grad-to));
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border-bottom: 1px solid var(--header-border);
  flex-shrink: 0;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height .3s cubic-bezier(.4, 0, .2, 1), opacity .25s ease, padding .3s ease;
}

.search-bar.open {
  max-height: 52px;
  opacity: 1;
  padding: 8px 14px;
}

.search-input {
  flex: 1;
  min-width: 0;
  padding: 7px 16px;
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-full);
  font-size: var(--text-base);
  font-family: inherit;
  outline: none;
  background: var(--input-bg);
  color: var(--gray-900);
  transition: border-color .25s, box-shadow .25s;
}

.search-input:focus {
  border-color: var(--input-focus-border);
  box-shadow: var(--shadow-focus);
}

.search-match-count {
  font-size: var(--text-sm);
  color: var(--gray-500);
  white-space: nowrap;
  min-width: 50px;
  text-align: center;
}

.search-close-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, .06);
  color: var(--gray-500);
  font-size: var(--text-lg);
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}

.search-close-btn:hover {
  background: rgba(0, 0, 0, .1);
}

#search-toggle-btn {
  color: rgba(124, 107, 240, .5);
  border-color: rgba(124, 107, 240, .12);
  background: rgba(124, 107, 240, .04);
}

#search-toggle-btn:hover {
  color: var(--jacob-color);
  border-color: rgba(124, 107, 240, .25);
  background: rgba(124, 107, 240, .1);
}

/* ── Reconnect Banner ── */

.reconnect-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
  font-size: 13px;
  color: var(--gray-600);
  flex-shrink: 0;
}

.reconnect-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--gray-300);
  border-top-color: var(--jacob-color);
  border-radius: 50%;
  animation: reconnectSpin .8s linear infinite;
}

@keyframes reconnectSpin {
  to { transform: rotate(360deg); }
}

/* Dim action buttons when disconnected — input stays usable for queue */
.chat-disconnected .call-btn,
.chat-disconnected .tray-btn {
  opacity: .4;
  pointer-events: none;
}

/* ── Sound Toggle ── */

#sound-toggle-btn.muted .icon-sound-on { display: none; }
#sound-toggle-btn.muted .icon-sound-off { display: block !important; }
#sound-toggle-btn.muted { color: var(--jenn-color); opacity: 0.8; }

/* ── Spotify ── */

.spotify-btn {
  color: rgba(29, 185, 84, .5);
  border-color: rgba(29, 185, 84, .12);
  background: rgba(29, 185, 84, .04);
}

.spotify-btn:hover {
  color: #1DB954;
  border-color: rgba(29, 185, 84, .25);
  background: rgba(29, 185, 84, .1);
}

.spotify-btn.connected {
  color: #1DB954;
}

.status-spotify-line {
  font-size: 10.5px;
  opacity: .85;
  gap: 5px;
  padding-top: 0;
  margin-top: 2px;
  font-family: 'DM Sans', 'Noto Sans KR', sans-serif;
}

.status-spotify-icon {
  flex-shrink: 0;
  overflow: visible;
}

.eq-bar {
  transform-origin: bottom;
  animation: eqBounce 0.8s ease-in-out infinite alternate;
}
.eq-bar-1 { animation-duration: 0.7s; }
.eq-bar-2 { animation-duration: 0.9s; animation-delay: 0.15s; }
.eq-bar-3 { animation-duration: 0.75s; animation-delay: 0.3s; }
.eq-bar-4 { animation-duration: 0.85s; animation-delay: 0.05s; }

@keyframes eqBounce {
  0%   { transform: scaleY(.35); }
  100% { transform: scaleY(1); }
}

.status-spotify-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
  color: var(--gray-500);
  font-weight: 500;
  letter-spacing: .02em;
}

.msg.search-hidden { display: none !important; }
.msg-group.search-hidden { display: none !important; }
.date-divider.search-hidden { display: none !important; }

.msg.search-match {
  animation: replyHighlight 1.5s ease-out;
}

.search-nav-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, .06);
  color: var(--gray-600);
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}

.search-nav-btn:hover {
  background: rgba(0, 0, 0, .1);
}

.msg-text mark,
.msg-reply-text mark {
  background: rgba(255, 213, 79, .45);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.msg-text mark.current {
  background: rgba(255, 165, 0, .6);
}

.call-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1.5px solid transparent;
  background: none;
  color: var(--gray-500);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color .2s, background .2s, border-color .2s, transform .15s;
}

.call-btn svg {
  width: 23px;
  height: 23px;
}

.call-btn:hover {
  transform: scale(1.05);
}

.call-btn:active {
  transform: scale(.92);
}

/* Individual header button tints */
#calendar-btn {
  color: rgba(232, 87, 158, .5);
  border-color: rgba(232, 87, 158, .12);
  background: rgba(232, 87, 158, .04);
}
#calendar-btn:hover {
  color: var(--jenn-color);
  border-color: rgba(232, 87, 158, .25);
  background: rgba(232, 87, 158, .1);
}

#theme-toggle-btn {
  color: rgba(245, 158, 11, .55);
  border-color: rgba(245, 158, 11, .12);
  background: rgba(245, 158, 11, .04);
}
#theme-toggle-btn:hover {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, .25);
  background: rgba(245, 158, 11, .1);
}

/* Incoming call banner */

.incoming-call[hidden] {
  display: none;
}

.incoming-call {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2500;
  background: var(--incoming-call-bg);
  backdrop-filter: blur(20px);
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 30px rgba(0,0,0,.12);
  animation: slideDown .3s ease-out;
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

.incoming-call-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.incoming-call-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulseRing 1.5s ease-out infinite;
  position: relative;
}

@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .5); }
  70% { box-shadow: 0 0 0 12px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.incoming-call-name {
  font-weight: 600;
  font-size: var(--text-lg);
  color: var(--gray-900);
}

.incoming-call-type {
  font-size: 13px;
  color: var(--gray-500);
}

.incoming-call-actions {
  display: flex;
  gap: 12px;
}

.call-action-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .2s;
}

.call-action-btn:active {
  opacity: .8;
}

.call-action-btn.accept {
  background: var(--green);
}

.call-action-btn.decline {
  background: #ef4444;
}

/* Call overlay */

.call-overlay[hidden] {
  display: none;
}

.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--gray-900);
  display: flex;
  flex-direction: column;
  color: #fff;
}

.call-status-bar {
  text-align: center;
  padding: 20px 16px 12px;
  padding-top: max(20px, calc(env(safe-area-inset-top, 0px) + 12px));
  flex-shrink: 0;
}

.call-partner-name {
  font-size: var(--text-2xl);
  font-weight: 600;
}

.call-status-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

.call-timer {
  font-size: var(--text-base);
  color: rgba(255,255,255,.6);
}

/* Call quality indicator */

.call-quality {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
}

.call-quality-bar {
  width: 4px;
  border-radius: 1px;
  background: rgba(255,255,255,.25);
  transition: background .4s ease, height .4s ease;
}

.call-quality-bar:nth-child(1) { height: 6px; }
.call-quality-bar:nth-child(2) { height: 10px; }
.call-quality-bar:nth-child(3) { height: 16px; }

.call-quality.good .call-quality-bar { background: #22c55e; }

.call-quality.fair .call-quality-bar:nth-child(1),
.call-quality.fair .call-quality-bar:nth-child(2) { background: #eab308; }

.call-quality.poor .call-quality-bar:nth-child(1) { background: #ef4444; }

.call-quality-text {
  font-size: 11px;
  color: rgba(255,255,255,.5);
  margin-left: 4px;
  transition: color .4s ease;
}

.call-quality.good .call-quality-text { color: #22c55e; }
.call-quality.fair .call-quality-text { color: #eab308; }
.call-quality.poor .call-quality-text { color: #ef4444; }

/* Video area */

.call-video-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}

#local-video {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 120px;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 2px solid rgba(255,255,255,.3);
  z-index: 1;
}

.call-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 0;
}

.call-avatar-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  font-weight: 700;
  color: #fff;
}

/* Call controls */

.call-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 20px 16px;
  padding-bottom: max(20px, calc(var(--safe-bottom) + 12px));
  flex-shrink: 0;
}

.call-control-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.15);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, color .2s;
}

.call-control-btn:active {
  background: rgba(255,255,255,.25);
}

.call-control-btn.active {
  background: var(--card-bg);
  color: var(--gray-900);
}

.call-control-btn.end-call {
  width: 64px;
  height: 64px;
  background: #ef4444;
}

.call-control-btn.end-call:active {
  background: #dc2626;
}

/* ── Emoji Button ── */

#emoji-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--gray-500);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color .2s;
}

#emoji-btn:active {
  color: var(--accent);
}

/* ── Emoji Picker Panel ── */

.emoji-picker {
  background: var(--frosted-bg);
  backdrop-filter: blur(20px) saturate(1.4);
  border-top: 1px solid var(--frosted-border);
  border-top-color: var(--frosted-border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  max-height: 260px;
  overflow: hidden;
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
  transition:
    max-height .3s cubic-bezier(.4, 0, .2, 1),
    opacity .25s cubic-bezier(.4, 0, .2, 1),
    transform .3s cubic-bezier(.4, 0, .2, 1),
    visibility .3s,
    border-top-color .3s;
  will-change: max-height, opacity, transform;
}

.emoji-picker:not(.open) {
  max-height: 0;
  opacity: 0;
  transform: translateY(8px);
  visibility: hidden;
  border-top-color: transparent;
}

.emoji-tabs {
  display: flex;
  border-bottom: 1px solid var(--gray-200);
  overflow-x: auto;
  flex-shrink: 0;
}

.emoji-tab {
  flex: 1;
  min-width: 0;
  padding: 8px 4px;
  border: none;
  background: none;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  border-bottom: 2px solid transparent;
  transition: color .2s, border-color .2s;
}

.emoji-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.emoji-tab:hover {
  color: var(--gray-700);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
}

.emoji-grid button {
  border: none;
  background: none;
  font-size: 22px;
  padding: 6px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: background .15s, transform .1s ease;
}

.emoji-grid button:hover {
  background: var(--gray-100);
  transform: scale(1.15);
}

.emoji-grid button:active {
  transform: scale(0.9);
}

/* ── Message Reactions ── */

.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 10px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
  border: 1px solid rgba(157, 123, 247, .12);
  background: var(--reaction-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--gray-700);
  transition: border-color .2s, background .2s, transform .15s cubic-bezier(.21,1.02,.55,1);
}

.reaction-pill:hover {
  background: var(--reaction-bg-hover);
  transform: scale(1.08);
}

.reaction-pill.mine {
  border-color: rgba(157, 123, 247, .4);
  background: var(--reaction-bg-mine);
}

.reaction-pill .reaction-emoji {
  font-size: var(--text-base);
}

.reaction-pill .reaction-count {
  font-size: 11px;
  font-weight: 600;
}

/* ── Reaction Trigger (hover smiley) ── */

.msg-reaction-trigger {
  position: absolute;
  top: -8px;
  opacity: 0;
  pointer-events: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--gray-200);
  background: var(--card-bg);
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
  transition: opacity .15s;
  z-index: 5;
}

.msg.sent .msg-reaction-trigger {
  left: -12px;
}

.msg.received .msg-reaction-trigger {
  right: -12px;
}

.msg:hover .msg-reaction-trigger {
  opacity: 1;
  pointer-events: auto;
}

/* ── Reaction Picker Popup ── */

.reaction-picker[hidden] {
  display: none;
}

.reaction-picker {
  position: fixed;
  z-index: 100;
  background: var(--reaction-picker-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--reaction-picker-border);
  border-radius: 28px;
  padding: 6px 10px;
  display: flex;
  gap: 2px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12), 0 0 0 1px rgba(0,0,0,.03);
}

.reaction-picker button {
  border: none;
  background: none;
  font-size: 22px;
  padding: 6px;
  cursor: pointer;
  border-radius: 50%;
  line-height: 1;
  transition: background .15s, transform .15s;
}

.reaction-picker button:hover {
  background: var(--gray-100);
  transform: scale(1.2);
}

/* Touch: long-press visual */
@media (hover: none) {
  .msg-reaction-trigger {
    opacity: 0 !important;
    pointer-events: none !important;
  }
}

/* ── Calendar Full-Screen View ── */

:root {
  --cal-event: #8b5cf6;
  --cal-trip: #3b82f6;
  --cal-date: #ec4899;
  --cal-memory: #f59e0b;
}

.calendar-view[hidden] {
  display: none;
}

.calendar-view {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background:
    radial-gradient(circle at 20% 85%, var(--chat-bg-gradient-a) 0%, transparent 50%),
    radial-gradient(circle at 80% 15%, var(--chat-bg-gradient-b) 0%, transparent 50%),
    var(--page-bg);
  display: flex;
  flex-direction: column;
  animation: calViewSlideUp .3s ease-out;
}

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

.calendar-view.closing {
  animation: calViewSlideDown .2s ease-in forwards;
}

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

/* Header bar */
.cal-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top, 0px));
  background: var(--header-bg);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border-bottom: 1px solid var(--header-border);
  flex-shrink: 0;
}

.cal-view-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -.3px;
  background: linear-gradient(135deg, #7c6bf0, #b47af7, #e8579e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.cal-view-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cal-today-pill {
  padding: 5px 14px;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--accent);
  background: rgba(157, 123, 247, .08);
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
}

.cal-today-pill:hover {
  background: rgba(157, 123, 247, .15);
}

.cal-today-pill:active {
  transform: scale(.95);
}

.cal-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--gray-100);
  color: var(--gray-700);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}

.cal-close-btn:hover {
  background: var(--gray-200);
}

/* Month navigation */
.cal-month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 6px;
  flex-shrink: 0;
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
}

.cal-month-year {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--gray-900);
  transition: opacity .2s;
}

.cal-month-year.fading {
  opacity: 0;
}

.cal-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--gray-700);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}

.cal-nav-btn:hover {
  background: var(--gray-100);
}

.cal-nav-btn:active {
  background: var(--gray-200);
}

/* Weekday headers */
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 6px 16px;
  text-align: center;
  flex-shrink: 0;
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
}

.cal-weekdays span {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-500);
  padding: 4px 0;
}

/* Grid */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0 12px 8px;
  gap: 2px;
  flex-shrink: 0;
  transition: opacity .15s;
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
}

.cal-grid.fading {
  opacity: .3;
}

.cal-day {
  width: 100%;
  height: 40px;
  border: none;
  background: none;
  border-radius: 50%;
  font-size: var(--text-base);
  color: var(--gray-700);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background .15s, color .15s;
}

.cal-day:hover {
  background: var(--gray-100);
}

.cal-day.today {
  font-weight: 700;
  color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.cal-day.selected {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: none;
}

.cal-day.selected:hover {
  background: var(--accent);
}

.cal-day.other-month {
  color: var(--gray-300);
}

/* Event type color dots */
.cal-dots {
  display: flex;
  gap: 2px;
  position: absolute;
  bottom: 3px;
}

.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.cal-dot.type-event  { background: var(--cal-event); }
.cal-dot.type-trip   { background: var(--cal-trip); }
.cal-dot.type-date   { background: var(--cal-date); }
.cal-dot.type-memory { background: var(--cal-memory); }

.cal-day.selected .cal-dot { background: rgba(255,255,255,.8); }

/* Trip range highlighting */
.cal-day.in-range {
  background: rgba(59, 130, 246, .12);
  border-radius: 0;
}

.cal-day.range-start {
  background: rgba(59, 130, 246, .12);
  border-radius: 50% 0 0 50%;
}

.cal-day.range-end {
  background: rgba(59, 130, 246, .12);
  border-radius: 0 50% 50% 0;
}

.cal-day.range-single {
  border-radius: 50%;
}

.cal-day.in-range:hover,
.cal-day.range-start:hover,
.cal-day.range-end:hover {
  background: rgba(59, 130, 246, .22);
}

.cal-day.selected.in-range,
.cal-day.selected.range-start,
.cal-day.selected.range-end {
  background: var(--accent);
  border-radius: 50%;
}

/* ── Lower scrollable section ── */

.cal-lower-section {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: max(12px, var(--safe-bottom));
}

.cal-lower-section::-webkit-scrollbar {
  width: 4px;
}
.cal-lower-section::-webkit-scrollbar-track {
  background: transparent;
}
.cal-lower-section::-webkit-scrollbar-thumb {
  background: rgba(139,92,246,.15);
  border-radius: 10px;
}

/* ── Upcoming Events ── */

.cal-upcoming {
  padding: 12px 20px 10px;
}

.cal-upcoming:empty {
  display: none;
}

.cal-upcoming-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-500);
  margin-bottom: 8px;
}

.cal-upcoming-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 6px;
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
}

.cal-upcoming-item:hover {
  box-shadow: var(--shadow-sm);
}

.cal-upcoming-item:active {
  transform: scale(0.98);
}

.cal-upcoming-icon {
  font-size: var(--text-xl);
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}

.cal-upcoming-badge {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cal-upcoming-badge.type-event  { background: var(--cal-event); }
.cal-upcoming-badge.type-trip   { background: var(--cal-trip); }
.cal-upcoming-badge.type-date   { background: var(--cal-date); }
.cal-upcoming-badge.type-memory { background: var(--cal-memory); }

.cal-upcoming-text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-upcoming-when {
  font-size: 11px;
  color: var(--gray-500);
  flex-shrink: 0;
}

/* Empty state */
.cal-empty-state {
  text-align: center;
  padding: 32px 24px;
  color: var(--gray-500);
}

.cal-empty-state .cal-empty-icon {
  font-size: 40px;
  margin-bottom: 8px;
}

.cal-empty-state .cal-empty-text {
  font-size: var(--text-base);
  font-weight: 500;
}

.cal-empty-state .cal-empty-hint {
  font-size: var(--text-sm);
  margin-top: 4px;
  opacity: .7;
}

/* ── Day section ── */

.cal-day-section[hidden] {
  display: none;
}

.cal-day-section {
  padding: 14px 20px 12px;
  animation: calDayAppear .25s ease-out;
}

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

.cal-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cal-day-header span {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-700);
}

.cal-add-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: var(--text-2xl);
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .15s, transform .1s;
  box-shadow: 0 2px 8px rgba(157, 123, 247, .3);
}

.cal-add-btn:hover {
  opacity: .85;
}

.cal-add-btn:active {
  transform: scale(.9);
}

/* Event cards */
.cal-events-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cal-event-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--card-bg);
  border-radius: 14px;
  border-left: 3px solid var(--cal-event);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: transform .1s, box-shadow .15s;
}

.cal-event-item:active {
  transform: scale(0.98);
}

.cal-event-item:hover {
  box-shadow: var(--shadow-sm);
}

.cal-event-item.type-event  { border-left-color: var(--cal-event); }
.cal-event-item.type-trip   { border-left-color: var(--cal-trip); }
.cal-event-item.type-date   { border-left-color: var(--cal-date); }
.cal-event-item.type-memory { border-left-color: var(--cal-memory); }

.cal-event-icon {
  font-size: var(--text-xl);
  flex-shrink: 0;
  margin-top: 1px;
}

.cal-event-info {
  flex: 1;
  min-width: 0;
}

.cal-event-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cal-event-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--gray-900);
  word-break: break-word;
}

.cal-event-type-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
  padding: 1px 5px;
  border-radius: 4px;
  flex-shrink: 0;
}

.cal-event-type-badge.type-event  { background: rgba(139,92,246,.12); color: var(--cal-event); }
.cal-event-type-badge.type-trip   { background: rgba(59,130,246,.12); color: var(--cal-trip); }
.cal-event-type-badge.type-date   { background: rgba(236,72,153,.12); color: var(--cal-date); }
.cal-event-type-badge.type-memory { background: rgba(245,158,11,.12); color: var(--cal-memory); }

.cal-event-desc {
  font-size: var(--text-sm);
  color: var(--gray-500);
  margin-top: 2px;
  word-break: break-word;
}

.cal-event-meta {
  font-size: var(--text-xs);
  color: var(--gray-500);
  margin-top: 3px;
  opacity: .7;
}

.cal-no-events {
  text-align: center;
  padding: 20px 0;
}

.cal-no-events .cal-empty-icon {
  font-size: 32px;
  margin-bottom: 6px;
}

.cal-no-events .cal-empty-text {
  font-size: 13px;
  color: var(--gray-500);
}

.cal-no-events .cal-empty-hint {
  font-size: 11px;
  color: var(--gray-500);
  opacity: .7;
  margin-top: 2px;
}

/* ── Bottom-sheet form overlay ── */

.cal-form-overlay[hidden] {
  display: none;
}

.cal-form-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.cal-form-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.35);
  animation: calBackdropIn .2s ease-out;
}

@keyframes calBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.cal-form-sheet {
  position: relative;
  background: var(--cal-sheet-bg);
  border-radius: 20px 20px 0 0;
  padding: 12px 20px 20px;
  padding-bottom: max(20px, calc(var(--safe-bottom) + 12px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: calSheetUp .3s cubic-bezier(.21,1.02,.55,1);
  box-shadow: 0 -4px 24px rgba(0,0,0,.1);
}

@keyframes calSheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.cal-form-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--gray-300);
  margin: 0 auto 4px;
}

.cal-form-heading {
  font-size: 17px;
  font-weight: 700;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.cal-form-heading::before {
  content: "";
  width: 4px;
  height: 20px;
  border-radius: 2px;
  background: var(--cal-event);
  flex-shrink: 0;
  transition: background .2s;
}

.cal-form-sheet[data-cal-type="event"] .cal-form-heading::before { background: var(--cal-event); }
.cal-form-sheet[data-cal-type="trip"] .cal-form-heading::before { background: var(--cal-trip); }
.cal-form-sheet[data-cal-type="date"] .cal-form-heading::before { background: var(--cal-date); }
.cal-form-sheet[data-cal-type="memory"] .cal-form-heading::before { background: var(--cal-memory); }

/* Type picker */
.cal-type-picker {
  display: flex;
  gap: 6px;
}

.cal-type-btn {
  flex: 1;
  padding: 10px 6px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: var(--gray-50);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  text-align: center;
  transition: all .2s cubic-bezier(.4, 0, .2, 1);
}

.cal-type-btn:hover {
  border-color: var(--gray-300);
  color: var(--gray-700);
}

.cal-type-btn.active[data-type="event"] {
  border-color: var(--cal-event);
  background: rgba(139,92,246,.12);
  color: var(--cal-event);
  transform: scale(1.03);
  box-shadow: 0 2px 8px rgba(139,92,246,.15);
}
.cal-type-btn.active[data-type="trip"] {
  border-color: var(--cal-trip);
  background: rgba(59,130,246,.12);
  color: var(--cal-trip);
  transform: scale(1.03);
  box-shadow: 0 2px 8px rgba(59,130,246,.15);
}
.cal-type-btn.active[data-type="date"] {
  border-color: var(--cal-date);
  background: rgba(236,72,153,.12);
  color: var(--cal-date);
  transform: scale(1.03);
  box-shadow: 0 2px 8px rgba(236,72,153,.15);
}
.cal-type-btn.active[data-type="memory"] {
  border-color: var(--cal-memory);
  background: rgba(245,158,11,.12);
  color: var(--cal-memory);
  transform: scale(1.03);
  box-shadow: 0 2px 8px rgba(245,158,11,.15);
}

/* Form inputs — unified */
.cal-form-sheet input[type="text"],
.cal-form-sheet textarea,
.cal-end-date-row input[type="date"] {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-family: inherit;
  outline: none;
  background: var(--cal-input-bg);
  color: var(--gray-900);
  transition: border-color .2s, background .2s, box-shadow .2s;
  resize: none;
}

.cal-form-sheet input[type="text"]:focus,
.cal-form-sheet textarea:focus,
.cal-end-date-row input[type="date"]:focus {
  border-color: var(--accent);
  background: var(--cal-input-focus-bg);
  box-shadow: var(--shadow-focus);
}

/* Validation error state */
.cal-form-sheet input.cal-input-error {
  border-color: #ef4444 !important;
  animation: calShake .4s ease-in-out;
}

@keyframes calShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px); }
  30% { transform: translateX(5px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
  90% { transform: translateX(1px); }
}

/* End date row */
.cal-end-date-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cal-end-date-row label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-500);
  white-space: nowrap;
}

.cal-end-date-row input[type="date"] {
  flex: 1;
}

/* Form actions */
.cal-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.cal-form-btn {
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .15s cubic-bezier(.21,1.02,.55,1), background .2s, box-shadow .2s;
}

.cal-form-btn:active {
  transform: scale(.96);
}

.cal-cancel-btn {
  background: var(--gray-100);
  color: var(--gray-700);
}

.cal-cancel-btn:hover {
  background: var(--gray-200);
}

.cal-save-btn {
  background: linear-gradient(135deg, var(--jacob-color), var(--jacob-dark));
  color: #fff;
  box-shadow: 0 2px 8px rgba(124, 107, 240, .25);
}

.cal-save-btn:hover {
  box-shadow: 0 4px 14px rgba(124, 107, 240, .3);
  transform: translateY(-1px);
}

.cal-delete-btn {
  background: rgba(239, 68, 68, .1);
  color: #ef4444;
  margin-right: auto;
}

.cal-delete-btn:hover {
  background: rgba(239, 68, 68, .18);
}

/* ── Sticker Button ── */

#sticker-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--gray-500);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color .2s, transform .15s ease;
}

#sticker-btn:hover {
  color: var(--gray-700);
  transform: scale(1.1);
}

#sticker-btn:active {
  color: var(--accent);
  transform: scale(0.92);
}

/* ── Sticker Picker Panel ── */

.sticker-picker {
  background: var(--frosted-bg);
  backdrop-filter: blur(20px) saturate(1.4);
  border-top: 1px solid var(--frosted-border);
  border-top-color: var(--frosted-border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  max-height: 320px;
  overflow: hidden;
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
  transition:
    max-height .3s cubic-bezier(.4, 0, .2, 1),
    opacity .25s cubic-bezier(.4, 0, .2, 1),
    transform .3s cubic-bezier(.4, 0, .2, 1),
    visibility .3s,
    border-top-color .3s;
  will-change: max-height, opacity, transform;
}

.sticker-picker:not(.open) {
  max-height: 0;
  opacity: 0;
  transform: translateY(8px);
  visibility: hidden;
  border-top-color: transparent;
}

.sticker-main-tabs {
  display: flex;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.sticker-main-tab {
  flex: 1;
  padding: 10px 4px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  text-align: center;
  border-bottom: 2.5px solid transparent;
  transition: color .2s, border-color .2s;
}

.sticker-main-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.sticker-main-tab:hover {
  color: var(--gray-700);
}

.sticker-category-tabs {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  overflow-x: auto;
  flex-shrink: 0;
  border-bottom: 1px solid var(--gray-100);
}

.sticker-category-tab {
  padding: 4px 12px;
  border-radius: 14px;
  border: 1.5px solid var(--gray-200);
  background: var(--gray-50);
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}

.sticker-category-tab.active {
  border-color: var(--accent);
  background: rgba(139, 92, 246, .08);
  color: var(--accent);
}

.sticker-category-tab:hover {
  border-color: var(--gray-300);
  color: var(--gray-700);
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
}

.sticker-grid button {
  border: none;
  background: none;
  font-size: 36px;
  padding: 8px;
  cursor: pointer;
  border-radius: 10px;
  line-height: 1;
  transition: background .15s, transform .1s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
}

.sticker-grid button:hover {
  background: rgba(139, 92, 246, .08);
  transform: scale(1.1);
}

.sticker-grid button:active {
  transform: scale(.95);
}

/* Kaomoji items are text-based, smaller font */
.sticker-grid button.kaomoji-item {
  font-size: var(--text-base);
  padding: 6px 4px;
  word-break: keep-all;
  white-space: nowrap;
  color: var(--gray-900);
}

/* Animated sticker preview on hover */
.sticker-grid button.animated-item:hover {
  animation: stickerBounce .5s ease 2;
}

/* ── GIPHY Search & Grid ── */

.sticker-search-wrap[hidden] {
  display: none;
}

.sticker-search-wrap {
  padding: 6px 8px;
  flex-shrink: 0;
}

.sticker-search {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-xl);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: var(--gray-50);
  color: var(--gray-900);
  transition: border-color .2s, background .2s;
}

.sticker-search:focus {
  border-color: var(--accent);
  background: var(--cal-input-focus-bg);
  box-shadow: var(--shadow-focus);
}

/* GIPHY image items in sticker grid */
.sticker-grid .giphy-item {
  padding: 2px;
  font-size: 0;
  overflow: hidden;
  aspect-ratio: 1;
}

.sticker-grid .giphy-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.sticker-grid .giphy-item:hover {
  background: rgba(139, 92, 246, .08);
  transform: scale(1.05);
}

/* GIPHY loading state */
.sticker-grid .giphy-loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 24px;
  color: var(--gray-500);
  font-size: 13px;
}

/* GIPHY attribution */
.giphy-attribution[hidden] {
  display: none;
}

.giphy-attribution {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--gray-500);
  padding: 4px 8px 6px;
  border-top: 1px solid var(--gray-100);
  opacity: .7;
}

/* ── Character Sub-Tabs ── */

.character-sub-tabs {
  display: flex;
  gap: 6px;
  padding: 6px 8px;
  overflow-x: auto;
  flex-shrink: 0;
  border-bottom: 1px solid var(--gray-100);
  justify-content: center;
}

.character-sub-tab {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--gray-200);
  background: var(--gray-50);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color .2s, transform .15s;
}

.character-sub-tab svg {
  width: 28px;
  height: 28px;
  pointer-events: none;
}

.character-sub-tab.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, .2);
}

.character-sub-tab:hover {
  border-color: var(--gray-400);
  transform: scale(1.08);
}

.character-sub-tab.active:hover {
  border-color: var(--accent);
}

/* ── Sticker Messages ── */

.msg.sticker-msg {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding: 4px 8px;
}

.sticker-content {
  display: flex;
  flex-direction: column;
}

.msg.sent.sticker-msg {
  align-self: flex-end;
}

.msg.received.sticker-msg {
  align-self: flex-start;
}

.sticker-display {
  line-height: 1;
}

/* Emoji stickers — large display */
.sticker-type-emoji .sticker-display {
  font-size: 80px;
}

/* Kaomoji stickers — styled pill */
.sticker-type-kaomoji .sticker-display {
  display: inline-block;
  background: rgba(139, 92, 246, .08);
  border: 1.5px solid rgba(139, 92, 246, .15);
  border-radius: var(--radius-xl);
  padding: 10px 18px;
  font-size: 22px;
  color: var(--gray-900);
}

/* Animated stickers — large with animation */
.sticker-type-animated .sticker-display {
  font-size: 80px;
  display: inline-block;
}

/* GIPHY stickers — rendered as images */
.sticker-type-giphy .sticker-display {
  line-height: 0;
}

.sticker-type-giphy .sticker-display img {
  max-width: 180px;
  max-height: 180px;
  border-radius: var(--radius-md);
  object-fit: contain;
}

/* Custom (Mochi) stickers — SVG display */
.sticker-type-custom .sticker-display {
  line-height: 0;
}

.sticker-type-custom .sticker-display svg {
  width: 120px;
  height: 120px;
}

/* Custom sticker grid items */
.sticker-grid .custom-sticker-item {
  padding: 4px;
  font-size: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sticker-grid .custom-sticker-item svg {
  width: 60px;
  height: 60px;
  pointer-events: none;
}

.sticker-grid .custom-sticker-item:hover {
  background: rgba(139, 92, 246, .08);
  transform: scale(1.08);
}

.msg.sticker-msg .msg-time {
  color: rgba(138, 129, 152, .6);
}

.msg:hover.sticker-msg .msg-time,
.msg.sticker-msg.show-time .msg-time {
  opacity: .6;
}

.msg.sent.sticker-msg .msg-time {
  text-align: right;
  color: rgba(138, 129, 152, .6);
}

.msg.sent.sticker-msg .msg-read-check svg circle,
.msg.sent.sticker-msg .msg-read-check svg path {
  stroke: var(--gray-300);
}

.msg.sent.sticker-msg .msg-read-check.read svg circle {
  stroke: var(--accent);
  fill: rgba(157, 123, 247, .1);
}

.msg.sent.sticker-msg .msg-read-check.read svg path {
  stroke: var(--accent);
  filter: drop-shadow(0 0 3px rgba(157, 123, 247, .3));
}

/* ── Sticker CSS Animations (finite iterations) ── */

@keyframes stickerBounce {
  0%, 100% { transform: translateY(0); }
  25% { transform: translateY(-16px); }
  50% { transform: translateY(0); }
  75% { transform: translateY(-8px); }
}

@keyframes stickerWiggle {
  0%, 100% { transform: rotate(0deg); }
  15% { transform: rotate(-12deg); }
  30% { transform: rotate(10deg); }
  45% { transform: rotate(-8deg); }
  60% { transform: rotate(6deg); }
  75% { transform: rotate(-3deg); }
}

@keyframes stickerPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}

@keyframes stickerSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes stickerShake {
  0%, 100% { transform: translateX(0); }
  10% { transform: translateX(-6px); }
  20% { transform: translateX(6px); }
  30% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  50% { transform: translateX(-3px); }
  60% { transform: translateX(3px); }
  70% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

.sticker-anim-bounce { animation: stickerBounce .6s ease 3; }
.sticker-anim-wiggle { animation: stickerWiggle .6s ease 3; }
.sticker-anim-pulse  { animation: stickerPulse .8s ease 2; }
.sticker-anim-spin   { animation: stickerSpin .7s linear 2; }
.sticker-anim-shake  { animation: stickerShake .5s ease 3; }

/* ── Photo Album ── */

.photo-album[hidden] {
  display: none;
}

.photo-album {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background:
    radial-gradient(circle at 20% 85%, var(--chat-bg-gradient-a) 0%, transparent 50%),
    radial-gradient(circle at 80% 15%, var(--chat-bg-gradient-b) 0%, transparent 50%),
    var(--page-bg);
  display: flex;
  flex-direction: column;
  animation: albumSlideUp .25s ease-out;
}

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

.photo-album-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top, 0px));
  background: var(--header-bg);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border-bottom: 1px solid var(--header-border);
  flex-shrink: 0;
}

.photo-album-title-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.photo-album-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -.3px;
  background: linear-gradient(135deg, #7c6bf0, #b47af7, #e8579e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.photo-album-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-400);
}

.photo-album-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--gray-100);
  color: var(--gray-700);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}

.photo-album-close:hover {
  background: var(--gray-200);
}

.photo-album-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  flex-shrink: 0;
}

.photo-album-tab {
  padding: 6px 18px;
  border-radius: var(--radius-xl);
  border: 1.5px solid var(--gray-200);
  background: var(--gray-50);
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  transition: all .15s;
}

.photo-album-tab:hover {
  border-color: var(--gray-300);
  color: var(--gray-700);
}

.photo-album-tab.active {
  border-color: var(--sent-color);
  background: var(--sent-color);
  color: #fff;
}

.photo-album-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 20px;
  -webkit-overflow-scrolling: touch;
}

.photo-album-content::-webkit-scrollbar {
  width: 4px;
}
.photo-album-content::-webkit-scrollbar-track {
  background: transparent;
}
.photo-album-content::-webkit-scrollbar-thumb {
  background: rgba(139,92,246,.15);
  border-radius: 10px;
}

.photo-album-month {
  margin-top: 20px;
}

.photo-album-month:first-child {
  margin-top: 8px;
}

.photo-album-month-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--label-purple);
  padding: 8px 0;
}

.photo-album-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.photo-album-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: transform .15s ease, box-shadow .15s ease;
}

.photo-album-item:hover {
  transform: scale(1.03);
  box-shadow: var(--shadow-md);
}

.photo-album-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-album-sender {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

.photo-album-date {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px 6px 5px;
  background: linear-gradient(transparent, rgba(0,0,0,.6));
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  text-align: right;
  opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
}

.photo-album-item:hover .photo-album-date {
  opacity: 1;
}

.photo-album-sender.sender-jacob {
  background: linear-gradient(135deg, #7c6bf0, #9d8cf8);
}

.photo-album-sender.sender-jenn {
  background: linear-gradient(135deg, #e8579e, #f08cbd);
}

.photo-album-empty {
  text-align: center;
  color: var(--gray-500);
  padding: 60px 24px;
  font-size: var(--text-base);
}

.photo-album-empty .emoji {
  font-size: 48px;
  margin-bottom: 12px;
}

/* Mobile responsive */
@media (max-width: 480px) {
  #chat-header {
    padding: 10px 12px;
    padding-top: max(10px, env(safe-area-inset-top, 0px));
  }
  .header-actions {
    gap: 6px;
  }
  .call-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }
  .call-btn svg {
    width: 21px;
    height: 21px;
  }
  .header-left {
    gap: 8px;
    min-width: 0;
  }
  .partner-name {
    font-size: var(--text-lg);
  }
  .status-line {
    font-size: 10px;
    gap: 3px;
  }
  .status-dot {
    width: 6px;
    height: 6px;
  }
  .heart-pill {
    padding: 3px 8px 3px 6px;
    gap: 4px;
  }
  .heart-pill svg {
    width: 12px;
    height: 12px;
  }
  .heart-pill span {
    font-size: 11px;
  }
  .header-tray.open { gap: 16px; padding: 10px 12px; }
  .tray-btn .tray-icon-wrap { width: 38px; height: 38px; border-radius: 10px; }
  .tray-btn svg { width: 20px; height: 20px; }
  .tray-btn > span:last-child:not(.tray-icon-wrap) { display: none; }
  .floating-event-pill { font-size: 11px; padding: 5px 12px; }
  #messages-container {
    padding: 12px 14px;
  }
  .msg {
    max-width: 85%;
  }
  /* Sticker mobile adjustments */
  .character-sub-tab {
    width: 30px;
    height: 30px;
  }
  .character-sub-tab svg {
    width: 22px;
    height: 22px;
  }
  .sticker-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .sticker-type-emoji .sticker-display {
    font-size: 64px;
  }
  .sticker-type-animated .sticker-display {
    font-size: 64px;
  }
  .sticker-type-giphy .sticker-display img {
    max-width: 140px;
    max-height: 140px;
  }
  .sticker-type-custom .sticker-display svg {
    width: 100px;
    height: 100px;
  }
  .sticker-grid .custom-sticker-item svg {
    width: 50px;
    height: 50px;
    pointer-events: none;
  }
  /* Photo album mobile */
  .photo-album-content {
    padding: 0 14px 14px;
  }
  .photo-album-tabs {
    padding: 10px 14px;
    gap: 6px;
  }
  .photo-album-tab {
    padding: 5px 14px;
    font-size: var(--text-sm);
  }
  .photo-album-grid {
    gap: 4px;
  }
  .photo-album-item {
    border-radius: var(--radius-sm);
  }
  .photo-album-sender {
    width: 18px;
    height: 18px;
    font-size: 8px;
    top: 3px;
    left: 3px;
  }
}

/* ── Reply Preview Bar ── */

.reply-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--reply-preview-bg);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--input-bar-border);
  border-left: 3px solid var(--accent);
  flex-shrink: 0;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height .25s cubic-bezier(.4, 0, .2, 1), opacity .2s ease, padding .25s ease;
}

.reply-preview[hidden] { display: flex; max-height: 0; opacity: 0; padding: 0 14px; overflow: hidden; }

.reply-preview.visible {
  max-height: 80px;
  opacity: 1;
  padding: 8px 14px;
}

.reply-preview-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.reply-preview-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
}

.reply-preview-name::before {
  content: "\21A9 ";
}

.reply-preview-name.jacob {
  color: var(--jacob-color);
}

.reply-preview-name.jenn {
  color: var(--jenn-color);
}

.reply-preview-text {
  font-size: var(--text-sm);
  color: var(--gray-500);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.reply-cancel {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.06);
  color: var(--gray-500);
  font-size: var(--text-lg);
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}

.reply-cancel:hover {
  background: rgba(0,0,0,.1);
}

/* ── Reply Block Inside Message Bubble ── */

.msg-reply-block {
  padding: 6px 10px;
  margin-bottom: 6px;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  background: rgba(157, 123, 247, .08);
  cursor: pointer;
  transition: background .15s;
}

.msg-reply-block:hover {
  background: rgba(157, 123, 247, .15);
}

.msg.sent .msg-reply-block {
  background: rgba(255,255,255,.12);
  border-left-color: rgba(255,255,255,.5);
}

.msg.sent .msg-reply-block:hover {
  background: rgba(255,255,255,.2);
}

.msg-reply-block-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 1px;
}

.msg.sent .msg-reply-block-name {
  color: rgba(255,255,255,.75);
}

.msg-reply-block-text {
  font-size: var(--text-sm);
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.msg.sent .msg-reply-block-text {
  color: rgba(255,255,255,.55);
}

/* ── Deleted Message Placeholder ── */

.msg.deleted {
  background: none !important;
  border: 1.5px dashed var(--gray-200) !important;
  box-shadow: none !important;
}

[data-theme="dark"] .msg.deleted {
  border-color: var(--gray-300) !important;
}

.msg.deleted .msg-deleted-text {
  font-style: italic;
  color: var(--gray-500);
  font-size: 13px;
}

.msg.sent.deleted {
  color: var(--gray-500) !important;
}

/* ── Message Edit Mode ── */

.msg-edit-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.msg-edit-textarea {
  width: 100%;
  min-height: 36px;
  max-height: 120px;
  padding: 6px 10px;
  border: 1.5px solid rgba(255, 255, 255, .25);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-family: inherit;
  line-height: 1.5;
  outline: none;
  resize: none;
  color: inherit;
  background: rgba(255, 255, 255, .12);
  transition: border-color .2s;
}

.msg-edit-textarea:focus {
  border-color: rgba(255, 255, 255, .45);
}

.msg.received .msg-edit-textarea {
  background: var(--input-bg);
  border-color: var(--input-border);
  color: var(--gray-900);
}

.msg.received .msg-edit-textarea:focus {
  border-color: var(--input-focus-border);
}

.msg-edit-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.msg-edit-actions button {
  padding: 4px 14px;
  border: none;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}

.msg-edit-actions button:active {
  transform: scale(0.95);
}

.msg-edit-cancel {
  background: rgba(255, 255, 255, .15);
  color: rgba(255, 255, 255, .8);
}

.msg.received .msg-edit-cancel {
  background: var(--gray-100);
  color: var(--gray-700);
}

.msg-edit-save {
  background: rgba(255, 255, 255, .9);
  color: var(--jacob-color);
}

.msg.received .msg-edit-save {
  background: var(--jacob-color);
  color: #fff;
}

/* ── Edited Indicator ── */

.msg-edited-indicator {
  font-style: italic;
  opacity: .6;
  font-size: var(--text-xs);
  margin-right: 4px;
}

/* ── Reply / Delete Action Buttons in Reaction Picker ── */

.reaction-picker-divider {
  width: 1px;
  align-self: stretch;
  margin: 4px 4px;
  background: rgba(0,0,0,.08);
}

.reaction-picker-action {
  border: none;
  background: none;
  font-size: 12px !important;
  padding: 6px 8px !important;
  cursor: pointer;
  border-radius: 8px !important;
  line-height: 1.2;
  color: var(--gray-700);
  white-space: nowrap;
  transition: background .15s, color .15s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.reaction-picker-action:hover {
  background: var(--gray-100) !important;
  transform: none !important;
}

.reaction-picker-action.delete-action {
  color: #ef4444;
}

.reaction-picker-action.delete-action:hover {
  background: rgba(239,68,68,.08) !important;
}

/* ── Highlight effect for scrolling to replied message ── */

@keyframes replyHighlight {
  0% { box-shadow: 0 0 0 3px var(--accent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.msg.reply-highlight {
  animation: replyHighlight 1.5s ease-out;
}

/* ── Desktop centered layout ── */

@media (min-width: 768px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    background:
      radial-gradient(ellipse at 30% 20%, var(--chat-bg-gradient-a) 0%, transparent 50%),
      radial-gradient(ellipse at 70% 80%, var(--chat-bg-gradient-b) 0%, transparent 50%),
      radial-gradient(ellipse at 50% 50%, var(--chat-bg-gradient-b) 0%, transparent 70%),
      linear-gradient(160deg, var(--gray-100) 0%, var(--gray-50) 40%, var(--page-bg) 100%);
  }

  #login-screen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    border-radius: 0;
    box-shadow: none;
  }

  #chat-screen {
    max-width: 480px;
    width: 100%;
    height: min(100vh, 900px);
    max-height: 100vh;
    border-radius: var(--radius-2xl);
    box-shadow:
      0 25px 60px rgba(0, 0, 0, .12),
      0 8px 24px rgba(0, 0, 0, .08),
      0 0 0 1px rgba(200, 170, 230, .2);
    position: relative;
    overflow: hidden;
    background-attachment: scroll;
  }

  #chat-header {
    border-radius: 24px 24px 0 0;
  }

  #input-bar {
    border-radius: 0 0 24px 24px;
  }

  /* Overlays constrained to chat card */
  .calendar-view {
    position: absolute;
  }

  .photo-album {
    position: absolute;
  }

  .call-overlay {
    position: absolute;
  }

  .incoming-call {
    position: absolute;
  }
}

/* ── Inline links ── */

.msg-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, .4);
  text-underline-offset: 2px;
  word-break: break-all;
}

.msg-link:hover {
  text-decoration-color: rgba(255, 255, 255, .7);
}

.msg.received .msg-link {
  text-decoration-color: var(--accent);
}

.msg.received .msg-link:hover {
  text-decoration-color: var(--gray-700);
}

/* ── Pin Indicator ── */

.msg-pin-indicator {
  font-size: 10px;
  opacity: .6;
  margin-bottom: 2px;
}

/* ── Pinned Messages Panel ── */

.pinned-panel {
  position: absolute;
  inset: 0;
  z-index: 60;
  background: var(--page-bg);
  flex-direction: column;
  animation: slideUp .25s ease;
}

.pinned-panel[hidden] {
  display: none;
}

.pinned-panel:not([hidden]) {
  display: flex;
}

.pinned-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: var(--text-base);
}

.pinned-panel-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-primary);
  padding: 4px 8px;
}

.pinned-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.pinned-msg {
  padding: 10px 14px;
  margin-bottom: 8px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}

.pinned-msg:hover {
  background: var(--gray-100);
}

.pinned-msg-sender {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 2px;
}

.pinned-msg-text {
  font-size: var(--text-sm);
  line-height: 1.4;
}

.pinned-msg-time {
  font-size: var(--text-xs);
  opacity: .5;
  margin-top: 4px;
}

.pinned-empty {
  text-align: center;
  padding: 40px 20px;
  opacity: .5;
  font-size: var(--text-sm);
}

.msg.highlight-flash {
  animation: highlightFlash 1.5s ease;
}

@keyframes highlightFlash {
  0%, 100% { box-shadow: none; }
  25%, 75% { box-shadow: 0 0 0 3px var(--accent); }
}

/* ── Link Preview Card ── */

.link-preview-card {
  display: block;
  margin-top: 8px;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, .08);
  text-decoration: none;
  color: inherit;
  transition: background .15s;
}

.link-preview-card:hover {
  background: rgba(0, 0, 0, .12);
}

.msg.received .link-preview-card {
  background: var(--gray-100);
}

.msg.received .link-preview-card:hover {
  background: var(--gray-200);
}

.link-preview-image {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  display: block;
}

.link-preview-info {
  padding: 8px 10px;
}

.link-preview-domain {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .3px;
  opacity: .6;
  margin-bottom: 2px;
}

.link-preview-title {
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.3;
}

.link-preview-desc {
  font-size: var(--text-xs);
  opacity: .7;
  margin-top: 2px;
  line-height: 1.4;
}

[data-theme="dark"] .link-preview-card {
  background: rgba(255, 255, 255, .06);
}

[data-theme="dark"] .link-preview-card:hover {
  background: rgba(255, 255, 255, .1);
}

[data-theme="dark"] .msg.received .link-preview-card {
  background: rgba(255, 255, 255, .04);
}

[data-theme="dark"] .msg.received .link-preview-card:hover {
  background: rgba(255, 255, 255, .08);
}
