/* ==========================================================================
   Chat: messages, composer, wallpaper, voice notes, calls and extras.
   ========================================================================== */

/* ==========================================================================
   Chat
   ========================================================================== */

.chat-view {
  position: relative;
  display: flex; flex-direction: column;
  height: calc(100vh - var(--nav-height));
  height: calc(100dvh - var(--nav-height) - env(safe-area-inset-bottom));
}

.chat-header {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.8rem var(--gutter);
  padding-top: calc(max(0.8rem, env(safe-area-inset-top)) + var(--island-room));
  border-bottom: 1px solid var(--ink);
  background: var(--paper);
  z-index: 5;
}
.chat-header__name { font-size: 1.85rem; line-height: 1; }
.chat-header__status { font-family: var(--mono); font-size: 0.72rem; color: var(--ink-faint); margin-top: 0.2rem; }

.chat-messages {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 0.5rem 0.9rem 0.9rem;
  display: flex; flex-direction: column;
}
.chat-messages > :first-child { margin-top: auto; }

.day-divider {
  display: flex; align-items: center; gap: 0.75rem;
  margin: 1.4rem 0 0.6rem;
  font-family: var(--mono); font-size: 0.7rem; color: var(--ink-faint); letter-spacing: 0.06em;
}
.day-divider::before, .day-divider::after { content: ""; flex: 1; height: 1px; background: var(--rule); }

.msg { display: flex; margin-top: 3px; }
.msg--group-start { margin-top: 12px; }
.msg--hearted { margin-bottom: 12px; }
.msg--mine { justify-content: flex-end; }

.msg__bubble {
  position: relative;
  max-width: min(78%, 520px);
  padding: 0.5rem 0.8rem 0.35rem;
  border-radius: 14px;
}
.msg--mine .msg__bubble { background: var(--ink); color: var(--paper); }
.msg--theirs .msg__bubble { background: var(--card); border: 1px solid var(--rule); box-shadow: var(--shadow-paper); }
.msg--mine.msg--group-start .msg__bubble { border-top-right-radius: 4px; }
.msg--theirs.msg--group-start .msg__bubble { border-top-left-radius: 4px; }
.msg__bubble--pulse { animation: thump 420ms var(--ease); }

.msg__bubble--image { padding: 4px 4px 0.35rem; }
.msg__bubble--image .msg__text { padding: 0.3rem 0.5rem 0; }
.msg__bubble--image .msg__meta { padding: 0 0.5rem; }
.msg__image { display: block; border-radius: 11px; overflow: hidden; }
.msg__image img { display: block; width: 100%; max-width: 280px; max-height: 340px; object-fit: cover; }

.msg__text { font-size: 0.97rem; line-height: 1.42; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg__meta {
  display: flex; justify-content: flex-end; align-items: center; gap: 0.3rem;
  margin-top: 0.15rem;
  font-family: var(--mono); font-size: 0.64rem; opacity: 0.6;
}
.msg-status { letter-spacing: -0.2em; margin-right: 0.2em; }

.msg__heart {
  position: absolute; bottom: -11px;
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0; color: transparent;
  background: var(--paper); border: 1px solid var(--rule);
  animation: pop var(--fast) var(--ease);
}
.msg__heart::after {
  content: ""; width: 11px; height: 11px;
  background: var(--wax);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21s-8.5-5.2-8.5-11.4A4.8 4.8 0 0 1 12 6.6a4.8 4.8 0 0 1 8.5 3c0 6.2-8.5 11.4-8.5 11.4Z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21s-8.5-5.2-8.5-11.4A4.8 4.8 0 0 1 12 6.6a4.8 4.8 0 0 1 8.5 3c0 6.2-8.5 11.4-8.5 11.4Z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.msg--mine .msg__heart { left: -6px; }
.msg--theirs .msg__heart { right: -6px; }

.chat-composer { position: relative; }
.chat-input {
  display: flex; align-items: flex-end; gap: 0.2rem;
  padding: 0.55rem 0.6rem;
  border-top: 1px solid var(--rule);
  background: var(--paper);
}
.chat-input__field {
  flex: 1; min-width: 0; resize: none;
  min-height: 44px; max-height: 120px;
  padding: 0.6rem 0.95rem;
  border: 1px solid var(--rule-strong); border-radius: 22px;
  background: var(--card); line-height: 1.4;
  transition: border-color var(--fast) var(--ease);
}
.chat-input__field:focus { outline: none; border-color: var(--ink); }

.send-btn {
  width: 44px; height: 44px; margin-left: 0.15rem; flex-shrink: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--wax); color: var(--on-wax);
  transition: transform var(--fast) var(--ease), opacity var(--fast) var(--ease), background var(--fast) var(--ease);
}
.send-btn .icon { width: 19px; height: 19px; margin-left: -2px; }
.send-btn:active:not(:disabled) { transform: scale(0.92); }
.send-btn:disabled { background: var(--rule); color: var(--ink-faint); }

.popover {
  position: absolute; bottom: calc(100% + 8px); z-index: 30;
  background: var(--card); border: 1px solid var(--rule);
  border-radius: var(--r-md); box-shadow: var(--shadow-lift);
  padding: 0.35rem;
  animation: rise var(--fast) var(--ease);
}
.popover[hidden] { display: none; }

/* Emoji keyboard, in the spirit of the one on iPhone */
.ep {
  --ep-fill: color-mix(in srgb, var(--ink) 7%, transparent);
  left: 0.6rem; width: min(372px, calc(100% - 1.2rem)); height: 352px;
  display: flex; flex-direction: column; padding: 0; overflow: hidden;
  border-radius: 22px;
  background: color-mix(in srgb, var(--card) 96%, transparent);
  -webkit-backdrop-filter: blur(28px) saturate(1.6); backdrop-filter: blur(28px) saturate(1.6);
  box-shadow: 0 18px 50px rgba(40, 20, 10, 0.22), 0 0 0 0.5px color-mix(in srgb, var(--ink) 14%, transparent);
  border: 0;
  animation: ep-in 240ms var(--ease);
}
@keyframes ep-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.ep__search {
  display: flex; align-items: center; gap: 0.45rem; margin: 0.7rem 0.7rem 0.3rem;
  height: 36px; padding: 0 0.7rem; border-radius: 11px; background: var(--ep-fill); color: var(--ink-faint);
}
.ep__search .ep__icon { width: 17px; height: 17px; flex: none; }
.ep__query {
  flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--ink);
  font: inherit; font-size: 16px; /* 16px keeps iPhone from zooming in */
}
.ep__query::placeholder { color: var(--ink-faint); }
.ep__query::-webkit-search-cancel-button { opacity: 0.5; }
.ep__body { position: relative; flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 0.45rem 0.4rem; scrollbar-width: thin; }
.ep__title {
  position: sticky; top: 0; z-index: 1; margin: 0; padding: 0.55rem 0.35rem 0.3rem;
  font-family: var(--sans); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-faint);
  background: linear-gradient(color-mix(in srgb, var(--card) 96%, transparent) 70%, transparent);
}
.ep__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); }
.ep__e, .ep__tone {
  display: flex; align-items: center; justify-content: center; aspect-ratio: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: 29px; line-height: 1; border-radius: 11px;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform 140ms var(--ease), background 140ms var(--ease);
}
@media (hover: hover) { .ep__e:hover, .ep__tone:hover { background: var(--ep-fill); } }
.ep__e:active { transform: scale(0.84); }
.ep__e--pop { animation: ep-pop 300ms var(--ease); }
@keyframes ep-pop { 35% { transform: scale(1.32); } }
.ep__e:focus-visible, .ep__tab:focus-visible, .ep__tone:focus-visible { outline: 2px solid var(--wax-text); outline-offset: -2px; }
.ep--searching .ep__section[data-cat] { display: none; }
.ep__empty { margin: 0; padding: 2.4rem 1rem; text-align: center; color: var(--ink-faint); font-size: 0.9rem; }
.ep__loading { height: 100%; min-height: 200px; background: linear-gradient(100deg, transparent 30%, var(--ep-fill) 50%, transparent 70%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: 14px; margin-top: 0.4rem; }
.ep__tabs {
  display: flex; gap: 2px; padding: 0.3rem 0.45rem 0.4rem;
  border-top: 0.5px solid color-mix(in srgb, var(--ink) 12%, transparent);
}
.ep__tab {
  flex: 1; height: 34px; display: flex; align-items: center; justify-content: center;
  border-radius: 9px; color: var(--ink-faint);
  transition: background 160ms var(--ease), color 160ms var(--ease);
}
.ep__tab .ep__icon { width: 19px; height: 19px; }
.ep__tab.is-active { color: var(--ink); background: var(--ep-fill); }
.ep__tones {
  position: absolute; z-index: 6; display: flex; gap: 2px; padding: 5px;
  border-radius: 16px; background: var(--card);
  box-shadow: 0 12px 34px rgba(40, 20, 10, 0.28), 0 0 0 0.5px color-mix(in srgb, var(--ink) 16%, transparent);
  animation: ep-in 180ms var(--ease);
}
.ep__tones[hidden] { display: none; }
.ep__tone { width: 44px; font-size: 30px; }
@media (max-width: 640px) {
  .ep { left: 0.4rem; right: 0.4rem; width: auto; height: min(48vh, 340px); }
  .ep__grid { grid-template-columns: repeat(8, 1fr); }
}

.attach-menu { right: 0.6rem; width: 220px; }
.attach-menu__item {
  width: 100%; display: flex; align-items: center; gap: 0.7rem;
  padding: 0.7rem 0.75rem; border-radius: var(--r-sm); text-align: left; font-weight: 500;
}
.attach-menu__item .icon { color: var(--ink-soft); width: 20px; height: 20px; }
.attach-menu__item:hover { background: var(--paper-deep); }
.attach-menu__item em { margin-left: auto; font-style: normal; font-family: var(--mono); font-size: 0.68rem; color: var(--ink-faint); }

/* ==========================================================================
   Chat: reply, swipe, heartbeat, countdown strip
   ========================================================================== */

.msg { position: relative; align-items: center; gap: 0.3rem; }
.msg__bubble { transition: transform 220ms var(--ease); }
.msg--swiping .msg__bubble { transform: translateX(var(--swipe, 0)); transition: none; }
.msg__swipe-icon {
  position: absolute; left: 0.2rem; top: 50%; margin-top: -14px;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-faint); background: var(--paper-deep);
  opacity: 0; transform: scale(0.6);
  transition: opacity var(--fast) var(--ease), transform var(--fast) var(--ease), background var(--fast) var(--ease), color var(--fast) var(--ease);
  pointer-events: none;
}
.msg__swipe-icon .icon { width: 15px; height: 15px; }
.msg--swiping .msg__swipe-icon { opacity: 0.8; transform: scale(0.85); }
.msg--swipe-ready .msg__swipe-icon { opacity: 1; transform: scale(1); background: var(--wax); color: var(--on-wax); }

.msg__reply-btn {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-faint); opacity: 0;
  transition: opacity var(--fast) var(--ease), background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.msg__reply-btn .icon { width: 16px; height: 16px; }
.msg--mine .msg__reply-btn { order: -1; }
.msg:hover .msg__reply-btn, .msg__reply-btn:focus-visible { opacity: 1; }
.msg__reply-btn:hover { background: var(--paper-deep); color: var(--ink); }
@media (hover: none) { .msg__reply-btn { display: none; } }

.msg__quote {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.05rem;
  width: 100%; text-align: left;
  margin: 0.1rem 0 0.4rem; padding: 0.35rem 0.6rem;
  border-left: 2px solid var(--wax-text);
  border-radius: 4px 8px 8px 4px;
  background: rgba(127, 110, 95, 0.1);
  font-size: 0.82rem;
}
.msg--mine .msg__quote { background: rgba(255, 248, 239, 0.12); border-left-color: rgba(255, 248, 239, 0.6); }
[data-theme="dark"] .msg--mine .msg__quote { background: rgba(0, 0, 0, 0.08); border-left-color: var(--wax-deep); }
.msg__quote-who { font-family: var(--mono); font-size: 0.66rem; opacity: 0.75; letter-spacing: 0.02em; }
.msg__quote-text { opacity: 0.85; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.msg__bubble--image .msg__quote { margin: 0.25rem 0.25rem 0.4rem; width: calc(100% - 0.5rem); }

.msg--flash .msg__bubble { animation: flash 1.2s var(--ease); }
@keyframes flash { 0%, 100% { box-shadow: 0 0 0 0 transparent; } 20% { box-shadow: 0 0 0 4px var(--wax-tint), 0 0 0 1px var(--wax); } }

.reply-bar {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.55rem 0.6rem 0.55rem 0.95rem;
  border-top: 1px solid var(--rule);
  background: var(--card);
  animation: rise 200ms var(--ease);
}
.reply-bar[hidden] { display: none; }
.edit-bar .reply-bar__who { text-transform: none; }
.send-btn__check { display: none; }
.chat-input--editing .send-btn > .icon { display: none; }
.chat-input--editing .send-btn__check { display: contents; }
.chat-input--editing #attach-btn { display: none; }

/* Editing: the message being changed lifts gently. */
.msg--editing .msg__bubble { box-shadow: 0 0 0 2px var(--wax), 0 10px 26px rgba(40, 20, 10, 0.18); transform: translateY(-1px); transition: box-shadow 200ms var(--ease), transform 200ms var(--ease); }
.msg__edited { margin-right: 0.35em; font-family: var(--sans); font-style: italic; letter-spacing: 0; }

/* One to three emoji on their own: big, no bubble (like Messages). */
.msg--jumbo .msg__bubble { background: none !important; border: 0 !important; box-shadow: none !important; padding: 0 0.1rem !important; }
.msg--jumbo .msg__text { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; font-size: 3rem; line-height: 1.12; letter-spacing: 0.02em; }
.msg--jumbo-2 .msg__text { font-size: 2.6rem; }
.msg--jumbo-3 .msg__text { font-size: 2.25rem; }
.msg--jumbo .msg__meta { color: var(--ink-faint); opacity: 1; }
.chat-view--deep .msg--jumbo .msg__meta { color: #fff8ef; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45); }
.msg-row--new .msg.msg--jumbo .msg__bubble { animation: jumbo-in 520ms var(--ease) both; }
@keyframes jumbo-in { 0% { transform: scale(0.4); opacity: 0; } 60% { transform: scale(1.12); opacity: 1; } }
.reply-bar__icon { color: var(--wax-text); }
.reply-bar__icon .icon { width: 18px; height: 18px; }
.reply-bar__body { flex: 1; min-width: 0; display: flex; flex-direction: column; border-left: 2px solid var(--wax-text); padding-left: 0.6rem; }
.reply-bar__who { font-family: var(--mono); font-size: 0.68rem; color: var(--wax-text); }
.reply-bar__text { font-size: 0.88rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-header__info { flex: 1; min-width: 0; }
.nudge-btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  height: 38px; padding: 0 0.85rem 0 0.7rem;
  border: 1px solid var(--rule-strong); border-radius: var(--r-full);
  font-size: 0.8rem; font-weight: 500; color: var(--ink);
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease), opacity var(--fast) var(--ease);
}
.nudge-btn .icon { width: 17px; height: 17px; fill: var(--wax-text); stroke: var(--wax-text); }
.nudge-btn:hover:not(:disabled) { border-color: var(--wax-text); }
.nudge-btn:active:not(:disabled) .icon { animation: thump 380ms var(--ease); }
.nudge-btn:disabled { opacity: 0.5; }
@media (max-width: 380px) {
  .nudge-btn span { display: none; }
  .nudge-btn { width: 40px; padding: 0; justify-content: center; }
}

.nudge-line {
  display: flex; align-items: center; justify-content: center; gap: 0.45rem;
  margin: 14px auto 4px; padding: 0.35rem 0.9rem;
  font-family: var(--serif); font-style: italic; font-size: 1.05rem; color: var(--ink-soft);
}
.nudge-line__heart { color: var(--wax-text); display: inline-flex; }
.nudge-line__heart .icon { width: 15px; height: 15px; fill: currentColor; animation: heartbeat 2.4s ease-in-out infinite; }
.nudge-line__time { font-family: var(--mono); font-style: normal; font-size: 0.64rem; color: var(--ink-faint); }

.heart-burst {
  position: fixed; z-index: 400; pointer-events: none;
  width: 18px; height: 18px; margin: -9px 0 0 -9px;
  color: var(--wax-text);
  animation: burst 1.1s var(--ease) forwards;
}
.heart-burst .icon { width: 100%; height: 100%; fill: currentColor; stroke: none; }
@keyframes burst {
  0% { opacity: 0; transform: translate(0, 0) scale(0.4); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--r)) scale(1.15); }
}

.heartbeat {
  position: fixed; inset: 0; z-index: 240;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.4rem;
  padding: 2rem; text-align: center;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  animation: fade 360ms var(--ease);
  cursor: pointer;
}
.heartbeat--leaving { animation: fade-out 400ms var(--ease) forwards; }
.heartbeat__seal { width: 120px; height: 120px; animation: heartbeat 1.2s ease-in-out infinite; }
.heartbeat__seal .icon { width: 46%; height: 46%; }
.heartbeat__text { font-family: var(--serif); font-size: 2.3rem; line-height: 1.1; max-width: 16ch; }
.heartbeat__text em { color: var(--wax-text); }
.heartbeat__hint { font-family: var(--mono); font-size: 0.72rem; color: var(--ink-faint); }

.countdown-strip {
  display: flex; align-items: baseline; justify-content: center; gap: 0.4rem;
  padding: 0.45rem var(--gutter);
  border-bottom: 1px solid var(--rule);
  background: var(--card);
  font-size: 0.82rem; color: var(--ink-soft);
  white-space: nowrap; overflow: hidden;
}
.countdown-strip__when { font-family: var(--serif); font-style: italic; font-size: 1.1rem; color: var(--wax-text); }
.countdown-strip__what { overflow: hidden; text-overflow: ellipsis; }

/* ==========================================================================
   Chat wallpaper
   ========================================================================== */

.chat-view { isolation: isolate; }
.chat-wallpaper {
  position: absolute; inset: 0; z-index: -1;
  overflow: hidden; pointer-events: none;
  background-position: center;
}
.chat-wallpaper__photo {
  position: absolute; inset: calc(var(--wp-blur, 0px) * -2);
  background-size: cover; background-position: center;
  filter: blur(var(--wp-blur, 0px)) saturate(1.05);
}
.chat-wallpaper::after {
  content: ""; position: absolute; inset: 0;
  background: rgba(14, 10, 8, var(--wp-dim, 0));
}

/* Dark wallpapers and photos: lighter text around the bubbles, wax-red
   bubbles for you in light mode, frosted bubbles over photos. */
.chat-view--deep .chat-messages {
  --ink-soft: rgba(255, 248, 239, 0.86);
  --ink-faint: rgba(255, 248, 239, 0.66);
  --rule: rgba(255, 248, 239, 0.22);
}
.chat-view--deep .day-divider, .chat-view--deep .nudge-line { text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); }
/* On photo and dark wallpapers the burgundy heart would vanish: use the soft rose that missed calls use there. */
.chat-view--deep .nudge-line__heart { color: #ffb3a3; }
:root:not([data-theme="dark"]) .chat-view--deep .msg--mine .msg__bubble { background: var(--wax); color: #fff8ef; }
.chat-view--deep .msg--theirs .msg__bubble { border-color: transparent; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18); }
.chat-view--photo .msg--theirs .msg__bubble {
  /* Solid enough to read without a live blur (blur on every bubble makes scrolling stutter). */
  background: color-mix(in srgb, var(--card) 92%, transparent);
}
.chat-view--photo .msg--mine .msg__bubble { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18); }
.chat-view--deep .msg__swipe-icon, .chat-view--deep .msg__reply-btn { color: rgba(255, 248, 239, 0.8); }

/* Picker */
.modal__panel--wallpaper { max-width: 560px; }
.wp-preview {
  position: relative; height: 230px !important;
  margin: 0 0 1.25rem;
  border: 1px solid var(--rule); border-radius: var(--r-md);
  overflow: hidden; background: var(--paper);
}
.wp-preview__msgs { position: absolute; inset: 0; padding: 0.6rem 0.8rem 0.9rem; overflow: hidden; justify-content: flex-end; }
.wp-preview .msg__bubble { animation: none; }

.wp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.85rem 0.7rem; }
.wp-swatch { display: flex; flex-direction: column; gap: 0.35rem; text-align: left; cursor: pointer; }
.wp-swatch__art {
  position: relative; display: block; height: auto !important; aspect-ratio: 3 / 4;
  border-radius: var(--r-sm); overflow: hidden;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--rule);
  transition: box-shadow var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.wp-swatch__art .chat-wallpaper { z-index: 0; }
.wp-swatch:hover .wp-swatch__art { transform: translateY(-2px); }
.wp-swatch--active .wp-swatch__art { box-shadow: inset 0 0 0 2px var(--wax), 0 0 0 3px var(--wax-tint); }
.wp-swatch__name { font-family: var(--mono); font-size: 0.7rem; color: var(--ink-soft); }
.wp-swatch--active .wp-swatch__name { color: var(--wax-text); }
.wp-swatch__add {
  position: absolute; inset: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  color: var(--wax-text);
  background: repeating-linear-gradient(-45deg, transparent 0 8px, var(--rule) 8px 9px);
}
.wp-swatch__add .icon { width: 26px; height: 26px; }
.wp-swatch--has-photo .wp-swatch__add { background: none; color: #fff8ef; opacity: 0; transition: opacity var(--fast) var(--ease); }
.wp-swatch--has-photo:hover .wp-swatch__add { opacity: 0.9; }
.wp-swatch input:focus-visible + .wp-swatch__art { outline: 2px solid var(--wax-text); outline-offset: 2px; }

.wp-adjust { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.2rem; }
.wp-adjust[hidden] { display: none; }
.wp-slider { display: flex; flex-direction: column; gap: 0.4rem; }
.wp-slider input[type="range"] { width: 100%; accent-color: var(--wax); }

.wp-share {
  display: flex; align-items: flex-start; gap: 0.75rem;
  margin-top: 1.25rem; padding: 0.85rem 0.9rem;
  border: 1px solid var(--rule); border-radius: var(--r-sm);
  cursor: pointer; font-size: 0.92rem; line-height: 1.35;
}
.wp-share input { position: absolute; opacity: 0; pointer-events: none; }
.wp-share__box {
  flex-shrink: 0; width: 22px; height: 22px; margin-top: 1px;
  border: 1.5px solid var(--rule-strong); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.wp-share input:checked + .wp-share__box { background: var(--wax); border-color: var(--wax); }
.wp-share input:checked + .wp-share__box::after {
  content: ""; width: 6px; height: 11px; margin-top: -2px;
  border: solid var(--on-wax); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.wp-share input:focus-visible + .wp-share__box { outline: 2px solid var(--wax-text); outline-offset: 2px; }
.wp-share strong { font-weight: 600; }
.modal__panel--wallpaper .modal__actions { margin-top: 1.4rem; }

.settings-row--link { width: 100%; text-align: left; }
.settings-row--link .settings-row__label, .settings-row--link .settings-row__hint { display: block; }
.settings-row__chevron { color: var(--ink-faint); }
.settings-row__chevron .icon { width: 18px; height: 18px; }
.settings-row--link:hover .settings-row__chevron { color: var(--wax-text); }
/* Swatches: draw the pattern at double size, then shrink, so a small
   thumbnail shows the whole design rather than one corner of it. */
.wp-swatch__art .chat-wallpaper { inset: auto; top: 0; left: 0; width: 200%; height: 200%; transform: scale(0.5); transform-origin: 0 0; }

/* ==========================================================================
   Voice notes
   ========================================================================== */

.msg__bubble--voice { min-width: min(268px, 72vw); padding: 0.5rem 0.7rem 0.35rem 0.5rem; }
.voice { display: flex; align-items: center; gap: 0.55rem; }
.voice__play {
  position: relative; flex-shrink: 0;
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--wax); color: var(--on-wax);
  transition: transform var(--fast) var(--ease);
}
.voice__play:active { transform: scale(0.92); }
.voice__play .icon { width: 18px; height: 18px; position: absolute; transition: opacity var(--fast) var(--ease), transform var(--fast) var(--ease); }
.voice__play .icon:first-child { margin-left: 2px; }
.voice__play .icon:last-child { opacity: 0; transform: scale(0.6); }
.voice--playing .voice__play .icon:first-child { opacity: 0; transform: scale(0.6); }
.voice--playing .voice__play .icon:last-child { opacity: 1; transform: none; }
.msg--mine .voice__play { background: var(--paper); color: var(--ink); }
:root:not([data-theme="dark"]) .chat-view--deep .msg--mine .voice__play { background: #fff8ef; color: var(--wax-text); }

.voice__wave {
  flex: 1; min-width: 0; height: 30px;
  display: flex; align-items: center; gap: 1.5px; overflow: hidden;
  --bar-min: 0.18;
  cursor: pointer; touch-action: manipulation;
}
.voice__wave:focus-visible { outline-offset: 4px; }
.voice__wave span {
  flex: 1 1 0; min-width: 1px; max-width: 4px;
  height: calc(max(var(--h), var(--bar-min)) * 100%);
  border-radius: 2px;
  background: currentColor;
  opacity: clamp(0.32, calc((var(--progress) - var(--i)) * 200 + 0.32), 1);
  transition: opacity 120ms linear;
}
.msg--theirs .voice__wave span { color: var(--wax-text); }
.voice__time { font-family: var(--mono); font-size: 0.7rem; opacity: 0.75; min-width: 2.4em; text-align: right; font-variant-numeric: tabular-nums; }
.voice__speed {
  font-family: var(--mono); font-size: 0.66rem; line-height: 1;
  padding: 0.3rem 0.4rem; border-radius: 999px;
  border: 1px solid currentColor; opacity: 0.55;
  transition: opacity var(--fast) var(--ease);
}
.voice__speed:hover { opacity: 1; }
.voice--playing .voice__speed { opacity: 0.9; }

/* Mic and recorder */
.mic-btn { background: var(--wax); color: var(--on-wax); }
.mic-btn .icon { margin-left: 0; width: 20px; height: 20px; }
.mic-btn:hover { background: var(--wax-deep); color: var(--on-wax); }
.send-btn[hidden], .mic-btn[hidden] { display: none; }
.chat-composer--recording .chat-input { visibility: hidden; }
.chat-composer--recording .reply-bar { display: none; }
.recorder {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.55rem 0.6rem;
  background: var(--paper); border-top: 1px solid var(--rule);
  animation: rise 200ms var(--ease);
}
.recorder[hidden] { display: none; }
.recorder__cancel { color: var(--ink-soft); }
.recorder__cancel:hover { color: var(--danger); }
.recorder__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--wax); animation: rec-blink 1.1s ease-in-out infinite; flex-shrink: 0; }
.recorder__time { font-family: var(--mono); font-size: 0.86rem; min-width: 2.8em; font-variant-numeric: tabular-nums; }
.recorder__hint { flex: 1; min-width: 0; font-family: var(--serif); font-style: italic; font-size: 1.05rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) { .recorder__hint { display: none; } }
.recorder__meter { flex: 1; min-width: 0; max-width: 260px; margin-left: auto; height: 30px; display: flex; align-items: center; justify-content: flex-end; gap: 2px; overflow: hidden; }
.recorder__meter span {
  flex: 0 0 3px; height: calc(var(--h, 0.08) * 100%); min-height: 3px;
  border-radius: 2px; background: var(--wax);
  transition: height 60ms linear;
}
.recorder .send-btn { background: var(--wax); color: var(--on-wax); }
@keyframes rec-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ==========================================================================
   In-app camera (laptops)
   ========================================================================== */

.modal__panel--camera { padding: 0; max-width: 720px; background: #0d0a08; color: #fff8ef; overflow: hidden; }
.modal__panel--camera::before { display: none; }
.modal__panel--camera .modal__close { background: rgba(0, 0, 0, 0.45); color: #fff; }
.camera__stage { position: relative; aspect-ratio: 4 / 3; background: #000; display: flex; align-items: center; justify-content: center; }
.camera__video, .camera__still { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera__video[hidden], .camera__still[hidden] { display: none; }
.camera__video--mirror { transform: scaleX(-1); }
.camera__status { position: absolute; inset: auto 1.5rem; text-align: center; font-family: var(--serif); font-style: italic; font-size: 1.3rem; color: rgba(255, 248, 239, 0.8); }
.camera__status[hidden] { display: none; }
.camera__stage::after { content: ""; position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.camera__stage--flash::after { animation: shutter-flash 300ms ease-out; }
@keyframes shutter-flash { 0% { opacity: 0.85; } 100% { opacity: 0; } }
.camera__bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 1rem 1.25rem calc(1rem + env(safe-area-inset-bottom)); }
.camera__bar[hidden] { display: none; }
.camera__bar--review { display: flex; justify-content: center; gap: 0.75rem; }
.camera__btn.btn--ghost { color: #fff8ef; border-color: rgba(255, 248, 239, 0.4); }
.camera__btn.btn--primary { background: var(--wax); color: #fff8ef; }
.camera__shutter {
  width: 68px; height: 68px; border-radius: 50%;
  border: 3px solid #fff8ef; padding: 4px;
  display: flex; align-items: center; justify-content: center;
}
.camera__shutter span { width: 100%; height: 100%; border-radius: 50%; background: #fff8ef; transition: transform 120ms var(--ease), background 120ms var(--ease); }
.camera__shutter:hover span { background: var(--wax); }
.camera__shutter:active span { transform: scale(0.88); }
.camera__shutter:disabled { opacity: 0.4; }
.camera__side { justify-self: start; width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff8ef; background: rgba(255, 248, 239, 0.12); }
.camera__side[hidden] { visibility: hidden; display: flex; }
.camera__side--spacer { background: none; }
.camera__side .icon { width: 22px; height: 22px; }

/* ==========================================================================
   Chat rows: only genuinely new messages animate in
   ========================================================================== */

.msg-row { display: contents; }
.msg-row--new .msg__bubble, .msg-row--new .nudge-line, .msg-row--new .day-divider { animation: msg-in 360ms cubic-bezier(0.2, 0.9, 0.3, 1.15) both; }
.msg-row--new .msg--mine .msg__bubble { transform-origin: 100% 100%; }
.msg-row--new .msg--theirs .msg__bubble { transform-origin: 0 100%; }
@keyframes msg-in { from { opacity: 0; transform: translateY(10px) scale(0.92); } }

/* Ticks: grey sent/delivered, blue read */
.msg-status { color: inherit; opacity: 0.7; transition: color 300ms var(--ease); }
.msg-status--read, .msg--mine .msg-status--read { color: #4fb6f5; opacity: 1; }
[data-theme="dark"] .msg--mine .msg-status--read { color: #1478c8; }
:root:not([data-theme="dark"]) .chat-view--deep .msg--mine .msg-status--read { color: #d6efff; }
.msg__seen {
  align-self: flex-end; margin: 3px 4px 0 0;
  font-family: var(--mono); font-size: 0.64rem; color: var(--ink-faint);
  animation: fade 300ms var(--ease);
}

/* ==========================================================================
   Thinking of you: hold-to-charge heart, 3D heartbeat, hearts in sync
   ========================================================================== */

.love-btn {
  --p: 0;
  position: relative; display: inline-flex; align-items: center; gap: 0.55rem;
  height: 48px; padding: 0 0.95rem 0 0.2rem;
  border-radius: var(--r-full);
  border: 1px solid var(--rule-strong);
  font-size: 0.8rem; font-weight: 500; color: var(--ink);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: manipulation;
  transition: border-color var(--fast) var(--ease), opacity var(--fast) var(--ease);
}
.love-btn:hover:not(:disabled) { border-color: var(--wax-text); }
.love-btn:disabled { opacity: 0.55; }
.love-btn__charge { position: relative; width: 44px; height: 44px; display: grid; place-items: center; flex-shrink: 0; }
.love-btn__charge svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.love-btn__track { fill: none; stroke: var(--rule); stroke-width: 2.5; opacity: 0; transition: opacity var(--fast) var(--ease); }
.love-btn__ring {
  fill: none; stroke: var(--wax-text); stroke-width: 2.8; stroke-linecap: round;
  stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--p) * 100);
}
.love-btn__seal {
  width: 26px; height: 26px;
  transform: scale(calc(1 + var(--p) * 0.3));
  transition: transform 120ms ease-out;
}
.love-btn--charging .love-btn__track { opacity: 1; }
.love-btn--charging .love-btn__seal { animation: charge-beat calc(0.9s - var(--p) * 0.45s) ease-in-out infinite; }
.love-btn--charging[data-level="3"] { border-color: var(--wax-text); box-shadow: 0 0 0 4px var(--wax-tint); }
.love-btn--sent .love-btn__seal { animation: thump 600ms var(--ease); }
@keyframes charge-beat {
  0%, 100% { transform: scale(calc(1 + var(--p) * 0.3)); }
  20% { transform: scale(calc(1.1 + var(--p) * 0.32)); }
  40% { transform: scale(calc(1 + var(--p) * 0.3)); }
  55% { transform: scale(calc(1.05 + var(--p) * 0.31)); }
}
@media (max-width: 380px) {
  .love-btn__label { display: none; }
  .love-btn { padding: 0 0.3rem; }
}

.love-wave {
  position: fixed; z-index: 400; pointer-events: none;
  width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%;
  border: 2px solid var(--wax-text);
  animation: love-wave 1.1s ease-out forwards;
}
.love-wave--l2 { animation-duration: 1.2s; border-width: 3px; }
.love-wave--l3 { animation-duration: 1.3s; border-width: 4px; box-shadow: 0 0 24px var(--wax); }
@keyframes love-wave { to { transform: scale(var(--s, 5)); opacity: 0; } }
.love-wave--l2 { --s: 7; }
.love-wave--l3 { --s: 10; }

/* The moment */
.beat {
  position: fixed; inset: 0; z-index: 245;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.6rem;
  padding: 2rem; text-align: center; cursor: pointer;
  background:
    radial-gradient(60% 45% at 50% 40%, color-mix(in srgb, var(--wax) 18%, transparent), transparent 70%),
    color-mix(in srgb, var(--paper) 90%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  animation: fade 380ms var(--ease);
}
.beat--leaving { animation: fade-out 450ms var(--ease) forwards; }
.beat__stage { position: relative; width: 220px; height: 220px; display: grid; place-items: center; perspective: 700px; margin-bottom: 1rem; }
.beat__glow { position: absolute; inset: 10%; border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--wax) 45%, transparent), transparent); animation: glow-beat var(--period) ease-in-out infinite; }
.beat__face { position: absolute; right: 6px; bottom: 6px; z-index: 3; }
.beat__face .avatar { box-shadow: 0 0 0 4px var(--paper), var(--shadow-lift); }
.beat__text { font-family: var(--serif); font-size: 2.4rem; line-height: 1.05; max-width: 15ch; }
.beat__text em { color: var(--wax-text); }
.beat__level { font-family: var(--serif); font-style: italic; font-size: 1.35rem; color: var(--ink-soft); }
.beat__hint { margin-top: 1.4rem; font-family: var(--mono); font-size: 0.72rem; color: var(--ink-faint); }

.heart3d {
  --hs: 150px;
  position: relative; display: block; width: var(--hs); height: var(--hs);
  transform-style: preserve-3d;
  animation: heart-swing 5s ease-in-out infinite, heart-beat var(--period, 1s) ease-in-out infinite;
}
.heart3d__layer {
  position: absolute; inset: 0;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21.2s-9-5.6-9-12.1A5 5 0 0 1 12 6.2a5 5 0 0 1 9 2.9c0 6.5-9 12.1-9 12.1Z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21.2s-9-5.6-9-12.1A5 5 0 0 1 12 6.2a5 5 0 0 1 9 2.9c0 6.5-9 12.1-9 12.1Z'/%3E%3C/svg%3E") center / contain no-repeat;
  background: color-mix(in srgb, #8e2a2e calc(100% - var(--z) * 4%), #4f1418);
  transform: translateZ(calc((var(--z) - var(--n) / 2) * 1.7px));
}
.heart3d__layer:last-child {
  background:
    radial-gradient(40% 32% at 34% 30%, rgba(255, 230, 220, 0.75), transparent 70%),
    radial-gradient(70% 60% at 50% 60%, #c0474a, #a3363a 60%, #6f1d22);
}
.heart3d--alt .heart3d__layer { background: color-mix(in srgb, #2f4a6b calc(100% - var(--z) * 4%), #16263a); }
.heart3d--alt .heart3d__layer:last-child { background: radial-gradient(40% 32% at 34% 30%, rgba(225, 240, 255, 0.7), transparent 70%), radial-gradient(70% 60% at 50% 60%, #6f93bd, #3e5f86 60%, #233a57); }
.beat--l3 .heart3d { --hs: 175px; }
.beat--l1 .heart3d { --hs: 130px; }
@keyframes heart-swing { 0%, 100% { rotate: y -22deg; } 50% { rotate: y 22deg; } }
@keyframes heart-beat { 0%, 60%, 100% { scale: 1; } 14% { scale: 1.16; } 28% { scale: 1; } 42% { scale: 1.09; } }
@keyframes glow-beat { 0%, 60%, 100% { opacity: 0.55; transform: scale(1); } 14% { opacity: 1; transform: scale(1.18); } }

/* Hearts in sync: two hearts meet in the middle */
.beat__stage--sync { width: 280px; }
.beat__half { position: absolute; top: 50%; margin-top: -60px; }
.beat__half .heart3d { --hs: 120px; animation-duration: 5s, 0.7s; }
.beat__half--left { left: 50%; margin-left: -120px; animation: meet-left 1.6s cubic-bezier(0.3, 0.9, 0.3, 1.1) both; }
.beat__half--right { right: 50%; margin-right: -120px; animation: meet-right 1.6s cubic-bezier(0.3, 0.9, 0.3, 1.1) both; }
.beat__faces { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); display: flex; z-index: 3; }
.beat__faces .avatar { box-shadow: 0 0 0 4px var(--paper); }
.beat__faces .avatar + .avatar { margin-left: -12px; }
@keyframes meet-left { from { transform: translateX(-90px) rotate(-12deg); opacity: 0; } to { transform: translateX(26px) rotate(-6deg); } }
@keyframes meet-right { from { transform: translateX(90px) rotate(12deg); opacity: 0; } to { transform: translateX(-26px) rotate(6deg); } }

.nudge-line__heart { gap: 1px; }
.nudge-line__heart .icon { width: 14px; height: 14px; }

/* ==========================================================================
   Calls
   ========================================================================== */

.chat-header__calls { display: flex; gap: 0.1rem; margin-left: auto; }
.chat-header__calls .icon-btn { width: 40px; height: 40px; color: var(--ink); }
.chat-header__calls .icon-btn:hover { color: var(--wax-text); }
.chat-header__info + .chat-header__calls + .love-btn { margin-left: 0.2rem; }
@media (max-width: 420px) {
  .chat-header { gap: 0.55rem; }
  .love-btn__label { display: none; }
  .love-btn { padding: 0 0.2rem; }
  .chat-header__name { font-size: 1.6rem; }
}

.call-line {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  margin: 12px auto 4px; padding: 0.5rem 1rem;
  border: 1px solid var(--rule); border-radius: var(--r-full);
  background: var(--card); color: var(--ink-soft);
  font-size: 0.88rem;
  transition: border-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.call-line:hover { border-color: var(--ink-soft); color: var(--ink); }
.call-line__icon { display: inline-flex; color: var(--ink-soft); }
.call-line__icon .icon { width: 16px; height: 16px; }
.call-line--missed, .call-line--missed .call-line__icon { color: var(--danger); }
.call-line__time { font-family: var(--mono); font-size: 0.64rem; color: var(--ink-faint); }
.chat-view--deep .call-line { background: color-mix(in srgb, var(--card) 85%, transparent); }

body.in-call { overflow: hidden; }
.call-screen {
  position: fixed; inset: 0; z-index: 255;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: max(2.2rem, env(safe-area-inset-top)) 1.5rem max(2rem, env(safe-area-inset-bottom));
  background: #120d0b; color: #fff8ef;
  animation: fade 300ms var(--ease);
  overflow: hidden;
}
.call-screen--leaving { animation: fade-out 380ms var(--ease) forwards; }
.call-screen__backdrop {
  position: absolute; inset: -40px; z-index: 0;
  background: radial-gradient(70% 50% at 50% 30%, rgba(142, 42, 46, 0.5), transparent 70%), #120d0b;
  background-size: cover; background-position: center;
  filter: blur(36px) saturate(1.2) brightness(0.55);
  transform: scale(1.1);
}
.call-screen__remote {
  position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%;
  object-fit: cover; background: #000; opacity: 0;
  /* Rounded corners keep Windows from handing a full-window video to the
     graphics card's overlay path, which shows black on some drivers. */
  border-radius: 2px;
  transition: opacity 600ms var(--ease);
}
.call-screen--video.call-screen--live .call-screen__remote { opacity: 1; }
.call-screen__canvas {
  position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%;
  display: none; opacity: 0; transition: opacity 600ms var(--ease); pointer-events: none;
}
.call-screen__canvas--on { display: block; }
.call-screen--video.call-screen--live .call-screen__canvas--on { opacity: 1; }
.call-screen__local {
  position: absolute; z-index: 3; right: 1rem; top: max(1rem, env(safe-area-inset-top));
  width: 104px; aspect-ratio: 3 / 4; border-radius: 16px; object-fit: cover;
  background: #000; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 0 1.5px rgba(255, 248, 239, 0.25);
  opacity: 0; transition: opacity 400ms var(--ease);
}
.call-screen--video .call-screen__local--ready { opacity: 1; }
.call-screen__local--mirror { transform: scaleX(-1); }
.call-screen__local--off { opacity: 0.25 !important; }
.call-screen--audio .call-screen__remote, .call-screen--audio .call-screen__local { display: block; width: 1px; height: 1px; opacity: 0; }

.call-screen__top { position: relative; z-index: 2; display: flex; justify-content: center; padding-top: 7vh; }
.call-screen__who { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; text-align: center; transition: transform 500ms var(--ease), opacity 500ms var(--ease); }
.call-screen__face { position: relative; display: inline-flex; margin-bottom: 0.6rem; }
.call-screen__face .avatar--hero { width: 128px; height: 128px; font-size: 3.4rem; box-shadow: 0 0 0 5px rgba(255, 248, 239, 0.12), 0 20px 50px rgba(0, 0, 0, 0.5); }
.call-screen__waves { position: absolute; inset: 0; pointer-events: none; }
.call-screen__waves i {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(255, 248, 239, 0.35);
  animation: call-wave 2.4s ease-out infinite;
}
.call-screen__waves i:nth-child(2) { animation-delay: 0.8s; }
.call-screen__waves i:nth-child(3) { animation-delay: 1.6s; }
.call-screen--live .call-screen__waves i { border-color: rgba(239, 106, 79, 0.45); animation-duration: 1.6s; }
@keyframes call-wave { from { transform: scale(1); opacity: 0.9; } to { transform: scale(1.9); opacity: 0; } }
.call-screen__name { font-family: var(--serif); font-size: 2.8rem; line-height: 1; color: #fff8ef; }
.call-screen__status { font-family: var(--mono); font-size: 0.82rem; letter-spacing: 0.06em; color: rgba(255, 248, 239, 0.75); font-variant-numeric: tabular-nums; }
.call-screen--video.call-screen--live .call-screen__who { transform: translateY(-4vh) scale(0.6); }
.call-screen--video.call-screen--live .call-screen__face { display: none; }
/* Like FaceTime: soft shade at the top and bottom so the name, timer and
   buttons stay readable over any picture. */
.call-screen--video.call-screen--live::before,
.call-screen--video.call-screen--live::after {
  content: ""; position: absolute; left: 0; right: 0; z-index: 2; pointer-events: none;
  animation: fade 600ms var(--ease);
}
.call-screen--video.call-screen--live::before { top: 0; height: 34%; background: linear-gradient(rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.22) 55%, transparent); }
.call-screen--video.call-screen--live::after { bottom: 0; height: 30%; background: linear-gradient(transparent, rgba(0, 0, 0, 0.2) 40%, rgba(0, 0, 0, 0.6)); }
.call-screen--video.call-screen--live .call-screen__name,
.call-screen--video.call-screen--live .call-screen__status { text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55), 0 0 18px rgba(0, 0, 0, 0.35); }
.call-screen--video.call-screen--live .call-btn span { text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
.call-screen--ending .call-screen__status { color: #ffb3a3; }
.call-screen__sound { display: none; }
.call-screen--live .call-screen__status { cursor: pointer; }
.call-screen__info {
  max-width: 34ch; padding: 0.35rem 0.8rem; border-radius: var(--r-full);
  background: rgba(0, 0, 0, 0.45); color: #fff8ef; font-size: 0.72rem; line-height: 1.4; text-align: center;
  white-space: pre-line;
}
.call-screen__info[hidden] { display: none; }
.call-screen--video.call-screen--live .call-screen__info { font-size: 1.15rem; }

.call-screen__unmute {
  position: relative; z-index: 3; align-self: center;
  padding: 0.7rem 1.2rem; border-radius: var(--r-full);
  background: rgba(255, 248, 239, 0.16); color: #fff8ef; font-weight: 600;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.call-screen__unmute[hidden] { display: none; }

.call-screen__controls {
  position: relative; z-index: 3;
  display: flex; justify-content: center; align-items: flex-start; gap: 1.1rem;
  padding: 1rem 0.5rem 0;
}
.call-btn {
  display: flex; flex-direction: column; align-items: center; gap: 0.45rem;
  color: #fff8ef; font-size: 0.74rem; font-weight: 500;
}
.call-btn .icon {
  width: 64px; height: 64px; padding: 19px; border-radius: 50%;
  background: rgba(255, 248, 239, 0.16);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  stroke-width: 1.8;
  transition: background var(--fast) var(--ease), transform 120ms var(--ease), color var(--fast) var(--ease);
}
.call-btn:active .icon { transform: scale(0.92); }
.call-btn--on .icon { background: #fff8ef; color: #120d0b; }
.call-btn--end .icon, .call-btn--decline .icon { background: #d8422f; transform: rotate(135deg); }
.call-btn--end:active .icon, .call-btn--decline:active .icon { transform: rotate(135deg) scale(0.92); }
.call-btn--accept .icon { background: #3fa36b; animation: accept-pulse 1.6s ease-in-out infinite; }
.call-screen--incoming .call-screen__controls { gap: 4.5rem; padding-bottom: 1rem; }
.call-screen--incoming .call-btn .icon { width: 72px; height: 72px; padding: 22px; }
@keyframes accept-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(63, 163, 107, 0.55); } 50% { box-shadow: 0 0 0 16px rgba(63, 163, 107, 0); } }

@media (min-width: 900px) {
  .call-screen__local { width: 180px; right: 1.5rem; top: 1.5rem; }
}

/* ==========================================================================
   Chat extras: info, search, photos, check-ins, send later
   ========================================================================== */

/* Header: her name opens chat info */
.chat-header__who {
  display: flex; align-items: center; gap: 0.8rem; flex: 1; min-width: 0;
  padding: 0; margin: 0; background: none; border: 0; color: inherit; text-align: left; cursor: pointer;
  border-radius: 14px; -webkit-tap-highlight-color: transparent;
}
.chat-header__who:active { opacity: 0.7; }
.chat-header__who .chat-header__name, .chat-header__who .chat-header__status { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header__who:focus-visible { outline: 2px solid var(--wax-text); outline-offset: 4px; }

/* Shared bottom-sheet modal */
.modal__panel--sheet { max-width: 480px; padding-top: 1.7rem; }
.sheet-title { font-size: 2rem; margin-bottom: 0.2rem; }
.sheet-sub { color: var(--ink-faint); font-size: 0.92rem; margin-bottom: 1.2rem; }
.btn--block { width: 100%; justify-content: center; }
.btn--danger-text { color: var(--danger); }

/* Chat info */
.chat-info { text-align: center; }
.chat-info__head { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; margin-bottom: 1.4rem; }
.chat-info__head .avatar { width: 96px; height: 96px; font-size: 2.6rem; }
.chat-info__name { font-size: 2.2rem; margin-top: 0.4rem; }
.chat-info__status { color: var(--ink-faint); font-size: 0.9rem; }
.chat-info__actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.chat-info__action {
  display: flex; flex-direction: column; align-items: center; gap: 0.45rem;
  padding: 0.95rem 0.4rem; border-radius: 16px; background: var(--paper-deep); color: var(--wax-text);
  font-size: 0.8rem; font-weight: 600; transition: transform 140ms var(--ease), background 140ms var(--ease);
}
.chat-info__action span { color: var(--ink); }
.chat-info__action .icon { width: 24px; height: 24px; }
.chat-info__action:active { transform: scale(0.95); }

/* Search */
.chat-search { position: absolute; inset: 0; z-index: 40; display: flex; flex-direction: column; background: var(--paper); animation: fade 180ms var(--ease); }
.chat-search--leaving { animation: fade-out 200ms var(--ease) forwards; }
.chat-search__bar {
  display: flex; align-items: center; gap: 0.6rem;
  padding: calc(max(0.7rem, env(safe-area-inset-top)) + var(--island-room)) var(--gutter) 0.7rem;
  background: var(--glass); border-bottom: 0.5px solid var(--hairline);
  -webkit-backdrop-filter: saturate(1.5) blur(20px); backdrop-filter: saturate(1.5) blur(20px);
}
.chat-search__field {
  flex: 1; display: flex; align-items: center; gap: 0.45rem; height: 40px; padding: 0 0.75rem;
  border-radius: 12px; background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink-faint);
}
.chat-search__field .icon { width: 18px; height: 18px; flex: none; }
.chat-search__input { flex: 1; min-width: 0; border: 0; outline: none; background: none; color: var(--ink); font: inherit; font-size: 16px; }
.chat-search__cancel { color: var(--wax-text); font-weight: 600; padding: 0.4rem 0.2rem; }
.chat-search__results { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0.4rem var(--gutter) 1.5rem; }
.chat-search__hint { padding: 2.5rem 1rem; text-align: center; color: var(--ink-faint); }
.chat-search__hit {
  width: 100%; display: flex; gap: 0.75rem; align-items: flex-start; text-align: left;
  padding: 0.85rem 0.2rem; border-bottom: 0.5px solid var(--hairline);
}
.chat-search__hit:active { background: var(--paper-deep); }
.chat-search__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.chat-search__meta { font-size: 0.78rem; color: var(--ink-faint); }
.chat-search__meta b { color: var(--ink); font-weight: 600; }
.chat-search__text { font-size: 0.95rem; line-height: 1.4; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chat-search__text mark { background: color-mix(in srgb, var(--wax) 22%, transparent); color: var(--ink); border-radius: 3px; padding: 0 1px; }
.chat-search__older { display: block; margin: 1.2rem auto 0; color: var(--wax-text); font-weight: 600; padding: 0.6rem 1rem; border-radius: var(--r-full); background: var(--wax-tint); }
.msg--flash .msg__bubble { animation: flash-bubble 1.6s var(--ease); }
@keyframes flash-bubble { 0%, 60% { box-shadow: 0 0 0 3px var(--wax), 0 10px 26px rgba(40, 20, 10, 0.2); transform: scale(1.02); } }

/* Photos */
.gallery { max-width: 640px; }
.gallery__scroll { max-height: 64vh; max-height: 64dvh; overflow-y: auto; margin: 0 -0.25rem; }
.gallery__month { font-family: var(--sans); font-size: 0.78rem; font-weight: 600; color: var(--ink-faint); margin: 0.9rem 0.25rem 0.45rem; }
.gallery__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 3px; }
.gallery__item { aspect-ratio: 1; overflow: hidden; border-radius: 6px; background: var(--paper-deep); }
.gallery__item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 200ms var(--ease); }
.gallery__item:active img { transform: scale(0.96); }
.photo-viewer__bar { display: flex; justify-content: center; gap: 0.6rem; padding: 0.8rem; }
.photo-viewer__btn {
  display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.6rem 1.1rem; border-radius: var(--r-full);
  background: rgba(255, 248, 239, 0.14); color: #fff8ef; font-weight: 600; font-size: 0.9rem;
}
.photo-viewer__btn .icon { width: 18px; height: 18px; }

/* Check-ins */
.checkin-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
.checkin-choice {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.95rem 0.9rem; border-radius: 16px;
  background: var(--paper-deep); font-weight: 600; text-align: left; transition: transform 140ms var(--ease);
}
.checkin-choice:active { transform: scale(0.96); }
.checkin-choice__emoji { font-size: 1.6rem; line-height: 1; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.checkin { display: flex; align-items: center; gap: 0.7rem; padding: 0.15rem 0.1rem 0.1rem; }
.checkin__emoji {
  width: 44px; height: 44px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; background: rgba(255, 255, 255, 0.22); font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.msg--theirs .checkin__emoji { background: var(--paper-deep); }
.checkin__body { display: flex; flex-direction: column; }
.checkin__label { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.75; }
.checkin__text { font-size: 1.05rem; font-weight: 600; }

/* Send later */
.scheduled-bar {
  display: flex; align-items: center; gap: 0.5rem; width: 100%;
  padding: 0.55rem var(--gutter); font-size: 0.82rem; color: var(--ink-soft); text-align: left;
  background: var(--glass); border-top: 0.5px solid var(--hairline);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
.scheduled-bar[hidden] { display: none; }
.scheduled-bar .icon { width: 16px; height: 16px; color: var(--wax-text); flex: none; }
.scheduled-bar span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scheduled-bar b { color: var(--ink); font-weight: 600; }
.schedule-form { display: flex; flex-direction: column; gap: 0.9rem; }
.schedule-form__chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.schedule-form__chips .chip--on { background: var(--wax); border-color: var(--wax); color: #fff; }
.schedule-form__when { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.8rem; font-weight: 600; color: var(--ink-soft); }
.schedule-form__error { color: var(--danger); font-size: 0.86rem; }
.schedule-form__error[hidden] { display: none; }
.scheduled-list { display: flex; flex-direction: column; gap: 0.6rem; }
.scheduled-item { padding: 0.9rem 1rem; border-radius: 16px; background: var(--paper-deep); }
.scheduled-item__when { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; font-weight: 600; color: var(--wax-text); }
.scheduled-item__when .icon { width: 14px; height: 14px; }
.scheduled-item__text { margin: 0.35rem 0 0.6rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.scheduled-item__actions { display: flex; gap: 0.4rem; justify-content: flex-end; }

/* "New messages" */
.unread-divider { display: flex; align-items: center; gap: 0.7rem; margin: 1rem 0 0.6rem; color: var(--wax-text); }
.unread-divider::before, .unread-divider::after { content: ""; flex: 1; height: 1px; background: color-mix(in srgb, var(--wax) 45%, transparent); }
.unread-divider span { font-size: 0.74rem; font-weight: 700; letter-spacing: 0.02em; }
.chat-view--deep .unread-divider { color: #ffd2c8; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
.msg__bubble.msg__bubble--image { padding: 3px 3px 0.35rem; }
.msg__bubble--image .msg__image { border-radius: 17px; }
.chat-header__name { font-family: var(--serif); font-weight: 400; }
.chat-search__field { min-width: 0; }
.chat-search__cancel { flex: none; }

/* Waiting to send (offline) */
.msg-status--pending { display: inline-flex; align-items: center; opacity: 0.85; letter-spacing: 0; margin-left: 1px; animation: pending-pulse 2s ease-in-out infinite; }
@keyframes pending-pulse { 50% { opacity: 0.45; } }

/* ==========================================================================
   A cleaner chat top on phones (iPhone Pro Max included)
   ========================================================================== */
@media (max-width: 899px) {
  /* The heart on its own, like an app icon: no words, no outline. */
  .love-btn { padding: 0; width: 46px; height: 46px; justify-content: center; border: 0; background: transparent; flex: none; }
  .love-btn__label { display: none; }
  .chat-header { gap: 0.6rem; padding-top: calc(max(0.55rem, env(safe-area-inset-top)) + var(--island-room)); padding-bottom: 0.55rem; }
  .chat-header__who { gap: 0.65rem; }
  .chat-header__name { font-size: 1.65rem; }
  .chat-header__status { font-size: 0.74rem; margin-top: 0.1rem; }
  .chat-header__calls { gap: 0; }
  .chat-header__calls .icon-btn { width: 42px; height: 42px; }
}

/* Countdown: a small frosted pill under the header, not a white band. */
.countdown-strip {
  align-self: center; width: fit-content; max-width: calc(100% - 2 * var(--gutter));
  margin: 0.5rem auto 0.1rem; padding: 0.28rem 0.9rem;
  border: 0; border-radius: var(--r-full);
  background: var(--glass);
  -webkit-backdrop-filter: saturate(1.4) blur(18px); backdrop-filter: saturate(1.4) blur(18px);
  box-shadow: 0 2px 10px rgba(40, 20, 10, 0.12), 0 0 0 0.5px var(--hairline);
  font-size: 0.8rem; position: relative; z-index: 4;
  transition: transform 160ms var(--ease);
}
.countdown-strip:active { transform: scale(0.97); }
.countdown-strip__when { font-size: 1.02rem; }

/* ==========================================================================
   Chat refinements (moved unchanged from refined.css in Phase 2)
   ========================================================================== */

.msg__meta, .msg__seen, .chat-header__status, .call-screen__status, time { font-variant-numeric: tabular-nums; letter-spacing: 0; }
/* Frosted bars, like iOS */
.chat-header {
  background: var(--glass);
  -webkit-backdrop-filter: saturate(1.5) blur(20px); backdrop-filter: saturate(1.5) blur(20px);
  border-bottom: 0.5px solid var(--hairline);
}

/* Chat bubbles */
.msg__bubble { border-radius: 20px; padding: 0.5rem 0.85rem 0.4rem; }
.msg--mine.msg--group-start .msg__bubble { border-top-right-radius: 7px; }
.msg--theirs.msg--group-start .msg__bubble { border-top-left-radius: 7px; }
.msg--mine .msg__bubble { background: var(--bubble-mine); color: var(--on-bubble-mine); box-shadow: none; }
.msg--theirs .msg__bubble { background: var(--bubble-theirs); border: 0; box-shadow: var(--shadow-paper); color: var(--ink); }
[data-theme="dark"] .msg--theirs .msg__bubble { box-shadow: none; }
.msg__meta { font-family: var(--sans); font-size: 0.68rem; opacity: 1; color: var(--ink-faint); }
.msg--mine .msg__meta { color: rgba(255, 255, 255, 0.88); }
.msg-status { opacity: 0.9; }
.msg-status--read, .msg--mine .msg-status--read,
[data-theme="dark"] .msg--mine .msg-status--read,
:root:not([data-theme="dark"]) .chat-view--deep .msg--mine .msg-status--read { color: var(--tick-read); opacity: 1; font-weight: 700; }
.msg__seen { font-family: var(--sans); font-size: 0.68rem; font-weight: 500; }
.msg--editing .msg__bubble { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--wax), 0 10px 26px rgba(40, 20, 10, 0.18); }

/* Day labels: small, quiet, rounded */
.day-divider { margin: 1.2rem 0 0.5rem; }
.day-divider::before, .day-divider::after { background: var(--hairline); }
.day-divider span {
  font-family: var(--sans); font-size: 0.72rem; font-weight: 600; letter-spacing: 0; text-transform: none;
  color: var(--ink-faint);
}

/* Composer */
.chat-input__field {
  background: var(--card); border: 0.5px solid var(--rule-strong); border-radius: 22px;
  box-shadow: 0 1px 2px rgba(60, 35, 20, 0.04);
}
.chat-input__field:focus { border-color: color-mix(in srgb, var(--wax) 55%, var(--rule-strong)); }
.send-btn:not(.mic-btn) { background: var(--wax); color: var(--on-wax); box-shadow: 0 2px 8px color-mix(in srgb, var(--wax) 30%, transparent); }
.send-btn:not(.mic-btn):disabled { background: var(--rule); color: var(--ink-faint); box-shadow: none; }
.reply-bar, .chat-composer .reply-bar { background: var(--glass); border-top: 0.5px solid var(--hairline); }
.reply-bar__who { font-family: var(--sans); font-weight: 600; font-size: 0.74rem; }
/* Over photo and dark wallpapers: call lines become dark frosted glass,
   and the white bubbles keep their normal grey text. */
.chat-view--deep .call-line {
  background: rgba(24, 16, 13, 0.46); color: #fff8ef; border-color: rgba(255, 248, 239, 0.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.chat-view--deep .call-line__icon, .chat-view--deep .call-line__time { color: rgba(255, 248, 239, 0.8); }
.chat-view--deep .call-line--missed, .chat-view--deep .call-line--missed .call-line__icon { color: #ffb3a3; }
:root:not([data-theme="dark"]) .chat-view--deep .msg--theirs .msg__bubble { --ink-soft: #6b5a52; --ink-faint: #806e63; --rule: #ece3d8; }

/* A slim, quiet scrollbar on the laptop */
.chat-messages { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--ink) 22%, transparent) transparent; }
.chat-view--deep .chat-messages { scrollbar-color: rgba(255, 248, 239, 0.35) transparent; }

/* Quick reactions: small badges on the bubble's corner, one per person */
.msg__reacts {
  position: absolute; bottom: -13px; display: flex; gap: 0;
  padding: 2px 4px; border-radius: var(--r-full);
  background: var(--card); box-shadow: 0 1px 4px rgba(40, 20, 10, 0.16), 0 0 0 0.5px var(--hairline);
  animation: pop var(--fast) var(--ease);
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.msg--mine .msg__reacts { left: -6px; }
.msg--theirs .msg__reacts { right: -6px; }
.msg__react { font-size: 0.95rem; line-height: 1.2; padding: 0 1px; }
.msg__react + .msg__react { margin-left: -2px; }
.msg--hearted { margin-bottom: 14px; }
.sheet-reacts {
  display: flex; justify-content: space-between; gap: 0.25rem;
  margin: -0.4rem 0 1rem; padding: 0.45rem; border-radius: var(--r-full);
  background: var(--paper-deep);
}
.sheet-react {
  flex: 1; aspect-ratio: 1; max-width: 52px; border-radius: 50%;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; font-size: 1.65rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: transform 160ms var(--ease), background 160ms var(--ease);
}
.sheet-react:active { transform: scale(0.86); }
@media (hover: hover) { .sheet-react:hover { transform: scale(1.12); } }
.sheet-react.is-on { background: var(--wax-tint); box-shadow: 0 0 0 2px var(--wax); }

/* Typing */
.chat-header__status--typing { color: var(--wax-text); font-style: italic; }
.typing-row { display: flex; padding: 6px 0 2px; animation: rise 220ms var(--ease); }
.typing-bubble {
  display: inline-flex; gap: 4px; align-items: center;
  padding: 0.7rem 0.9rem; border-radius: 20px; border-top-left-radius: 7px;
  background: var(--bubble-theirs); box-shadow: var(--shadow-paper);
}
.typing-bubble i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); animation: typing-dot 1.2s ease-in-out infinite; }
.typing-bubble i:nth-child(2) { animation-delay: 0.15s; }
.typing-bubble i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-dot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.45; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ==========================================================================
   Phase 2: Chat
   Runs of messages sit close together and only the last one carries the
   time and the tail. One quiet receipt sits under your latest message.
   Photos fill their bubble. The composer is one pill with a single round
   button that turns from mic into send.
   ========================================================================== */

/* Rhythm: 2px inside a run, a breath between runs */
.msg { margin-top: 2px; }
.msg--group-start { margin-top: 10px; }

/* Shape: corners where a run joins tighten; the last bubble gets the tail */
.msg__bubble { border-radius: var(--r-bubble); padding: 0.5rem 0.85rem 0.45rem; }
.msg--mine.msg--group-start .msg__bubble { border-top-right-radius: var(--r-bubble); }
.msg--theirs.msg--group-start .msg__bubble { border-top-left-radius: var(--r-bubble); }
.msg--mine:not(.msg--group-start) .msg__bubble { border-top-right-radius: 8px; }
.msg--mine:not(.msg--group-end) .msg__bubble { border-bottom-right-radius: 8px; }
.msg--mine.msg--group-end .msg__bubble { border-bottom-right-radius: 4px; }
.msg--theirs:not(.msg--group-start) .msg__bubble { border-top-left-radius: 8px; }
.msg--theirs:not(.msg--group-end) .msg__bubble { border-bottom-left-radius: 8px; }
.msg--theirs.msg--group-end .msg__bubble { border-bottom-left-radius: 4px; }

/* Time: small, once per run */
.msg__meta { font-size: var(--text-cap); gap: 0.25rem; margin-top: 0.1rem; }

/* Receipt under your latest message: "Seen 1:41 PM", "Delivered", "Sent" */
.msg__seen {
  align-self: flex-end; margin: 4px 6px 0 0;
  font-family: var(--sans); font-size: var(--text-cap); font-weight: 500; letter-spacing: 0.01em;
  color: var(--ink-faint);
}
.chat-view--deep .msg__seen { color: rgba(255, 248, 239, 0.88); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45); }

/* Photos fill the bubble; the time sits on the photo */
.msg__bubble.msg__bubble--photo-only { padding: 3px; }
.msg__bubble--photo-only .msg__image { border-radius: 17px; }
.msg--mine.msg--group-end .msg__bubble--photo-only .msg__image { border-bottom-right-radius: 3px; }
.msg--theirs.msg--group-end .msg__bubble--photo-only .msg__image { border-bottom-left-radius: 3px; }
.msg .msg__bubble--photo-only .msg__meta {
  position: absolute; right: 10px; bottom: 9px; margin: 0;
  padding: 2px 7px; border-radius: var(--r-full);
  background: rgba(20, 12, 10, 0.42); color: #fff;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}

/* Reactions: a small chip on the bubble's lower edge, ringed in the page colour */
.msg .msg__reacts {
  left: 10px; right: auto; bottom: -12px;
  box-shadow: 0 0 0 2px var(--paper), 0 2px 6px rgba(40, 20, 10, 0.16);
}
.chat-view--deep .msg .msg__reacts { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); }

/* Typing dots match the bubble they stand in for */
.typing-bubble { border-radius: var(--r-bubble); border-bottom-left-radius: 4px; }

/* Header: the name in the interface face, calm and legible */
.chat-header__name { font-family: var(--sans); font-weight: 600; font-size: var(--text-headline); letter-spacing: -0.01em; line-height: 1.2; }
.chat-header__status { font-family: var(--sans); font-size: 0.75rem; color: var(--ink-soft); margin-top: 1px; }

/* Composer: one pill (emoji, text, attach) and one round button */
.chat-input {
  align-items: flex-end; gap: var(--space-2);
  padding: var(--space-2) max(var(--space-3), env(safe-area-inset-right)) var(--space-2) max(var(--space-3), env(safe-area-inset-left));
  border-top: 0.5px solid var(--hairline);
}
.chat-input__pill {
  flex: 1; min-width: 0;
  display: flex; align-items: flex-end; gap: 0;
  min-height: 44px; padding: 0 2px;
  background: var(--card);
  border: 0.5px solid var(--rule-strong); border-radius: 22px;
  box-shadow: 0 1px 2px rgba(60, 35, 20, 0.04);
  transition: border-color var(--fast) var(--ease);
}
.chat-input__pill:focus-within { border-color: color-mix(in srgb, var(--wax-text) 55%, var(--rule-strong)); }
.chat-input__pill .chat-input__field,
.chat-input__pill .chat-input__field:focus {
  min-height: 42px; padding: 10px 4px;
  border: 0; border-radius: 0; background: transparent; box-shadow: none;
  font-size: var(--text-body);
}
.chat-input__pill .icon-btn { width: 38px; height: 42px; border-radius: 21px; color: var(--ink-faint); }
.chat-input__pill .icon-btn:hover, .chat-input__pill .icon-btn[aria-expanded="true"] { background: transparent; color: var(--ink); }
.chat-input .send-btn { width: 44px; height: 44px; flex: none; }
.chat-input .send-btn:not([hidden]) { animation: pop 180ms var(--ease); }

/* ==========================================================================
   Popovers (moved unchanged from refined.css in Phase 6)
   ========================================================================== */

.popover { border: 0.5px solid var(--hairline); border-radius: 18px; }

/* ==========================================================================
   Photo albums: photos sent together, as one grid
   2: side by side · 3: one tall + two stacked · 4+: two by two, "+N" on the last
   ========================================================================== */

.msg__bubble--album { width: min(256px, 68vw); }
.msg__album {
  display: grid; gap: 2px; width: 100%; overflow: hidden;
  border-radius: 17px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  aspect-ratio: 1;
}
.msg__album--2 { aspect-ratio: 8 / 5; }
.msg__album--3 { grid-template-rows: repeat(2, minmax(0, 1fr)); }
.msg__album--3 .msg__tile:first-child { grid-row: span 2; }
.msg__album--4 { grid-template-rows: repeat(2, minmax(0, 1fr)); }
.msg__tile {
  position: relative; display: block; min-width: 0; min-height: 0; overflow: hidden;
  background: var(--paper-deep);
}
.msg__tile img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform var(--press) var(--ease); }
.msg__tile:active img { transform: scale(0.97); }
.msg__tile img:not(.media--ready) {
  background-image: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.35) 50%, transparent 70%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
}
.msg__tile-more {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(20, 12, 10, 0.45); color: #fff;
  font-size: 1.6rem; font-weight: 600; letter-spacing: -0.01em;
}
/* The tail corner matches a single photo's */
.msg--mine.msg--group-end .msg__bubble--photo-only .msg__album { border-bottom-right-radius: 3px; }
.msg--theirs.msg--group-end .msg__bubble--photo-only .msg__album { border-bottom-left-radius: 3px; }
/* With a caption, the grid sits at the top of the bubble */
.msg__bubble--album:not(.msg__bubble--photo-only) .msg__album { border-radius: 17px 17px 6px 6px; }
.msg-album-anchor { display: block; height: 0; }

/* Photo viewer: a set you can swipe through */
.photo-viewer__count { position: absolute; top: 0.9rem; left: 0; right: 0; z-index: 2; margin: 0; text-align: center; font-size: var(--text-foot); color: rgba(255, 255, 255, 0.8); font-variant-numeric: tabular-nums; pointer-events: none; }
.photo-viewer__stage { position: relative; }
.photo-viewer__nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(20, 12, 10, 0.5); color: #fff;
}
.photo-viewer__nav .icon { width: 20px; height: 20px; }
.photo-viewer__nav--prev { left: 0.75rem; }
.photo-viewer__nav--next { right: 0.75rem; }
@media (hover: none) { .photo-viewer__nav { display: none; } }
.photo-viewer--in-right { animation: viewer-in-right 280ms var(--ease-sheet); }
.photo-viewer--in-left { animation: viewer-in-left 280ms var(--ease-sheet); }

/* ==========================================================================
   Chat: their photo beside the bubbles, 3D emoji, softer corners
   ========================================================================== */

/* Their photo sits beside the last bubble of each run; the bubbles above
   it keep the same space so a run stays in one straight line. */
.msg__avatar { flex: none; display: flex; align-self: flex-end; width: 28px; margin-right: 8px; }
.msg__avatar .avatar { box-shadow: 0 0 0 2px var(--paper); }
.msg--checkin .msg__avatar { display: none; }

/* Emoji drawn as 3D pictures (js/emoji3d.js). They scale with the text. */
.emoji3d {
  display: inline-block; width: 1.32em; height: 1.32em; margin: 0 0.03em;
  vertical-align: -0.32em; object-fit: contain;
  pointer-events: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.msg--jumbo .emoji3d { width: 1.12em; height: 1.12em; margin: 0 0.05em; vertical-align: -0.2em; filter: drop-shadow(0 5px 7px rgba(60, 30, 20, 0.22)); }
.msg__quote-text .emoji3d { width: 1.2em; height: 1.2em; vertical-align: -0.25em; }
.msg__react .emoji3d { width: 1.25em; height: 1.25em; margin: 0; vertical-align: -0.28em; }
.sheet-react .emoji3d { width: 1.15em; height: 1.15em; margin: 0; vertical-align: middle; }
.ep__e .emoji3d, .ep__tone .emoji3d { width: 1.12em; height: 1.12em; margin: 0; vertical-align: middle; }

/* Rounder, for the most part */
.msg__bubble { border-radius: var(--r-bubble); }
.msg--mine:not(.msg--group-start) .msg__bubble { border-top-right-radius: 10px; }
.msg--mine:not(.msg--group-end) .msg__bubble { border-bottom-right-radius: 10px; }
.msg--mine.msg--group-end .msg__bubble { border-bottom-right-radius: 6px; }
.msg--theirs:not(.msg--group-start) .msg__bubble { border-top-left-radius: 10px; }
.msg--theirs:not(.msg--group-end) .msg__bubble { border-bottom-left-radius: 10px; }
.msg--theirs.msg--group-end .msg__bubble { border-bottom-left-radius: 6px; }
.typing-bubble { border-bottom-left-radius: 6px; }
.msg__quote { border-radius: 6px 12px 12px 6px; }
.msg__image { border-radius: 16px; }
.gallery__item { border-radius: 12px; }

/* The day sits in a small rounded label instead of between two lines. */
.day-divider { justify-content: center; margin: 1.2rem 0 0.6rem; }
.day-divider::before, .day-divider::after { display: none; }
.day-divider span { padding: 0.28rem 0.85rem; border-radius: var(--r-full); background: var(--paper-deep); color: var(--ink-soft); }
.chat-view--deep .day-divider span { background: rgba(20, 12, 10, 0.38); color: #fff8ef; text-shadow: none; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }

/* The time under a big emoji was white on cream in light mode. */
.msg--mine.msg--jumbo .msg__meta { color: var(--ink-faint); }
.chat-view--deep .msg--mine.msg--jumbo .msg__meta { color: #fff8ef; }

/* ==========================================================================
   Chat header and composer, set to the mockup
   ========================================================================== */

/* A small green dot and a capital letter in front of the status, instead of
   a dot on the photo. */
.chat-header .avatar__presence { display: none; }
.chat-header__status--online::before {
  content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px;
  border-radius: 50%; background: #4c9a6a; vertical-align: 0.05em;
}

/* The "more" button closes the row, like the three dots in iMessage. */
.chat-header__more { width: 40px; height: 40px; margin-left: -0.15rem; color: var(--ink); }
.chat-header__more .icon { width: 22px; height: 22px; }
.chat-header__more:hover { color: var(--wax-text); }
@media (max-width: 359px) { .chat-header__more { display: none; } }

/* Composer: a little taller and lifted, with the round button to match. */
.chat-input__pill { min-height: 48px; border-radius: 24px; box-shadow: 0 2px 10px rgba(60, 35, 20, 0.07); }
.chat-input__pill .chat-input__field, .chat-input__pill .chat-input__field:focus { min-height: 46px; padding: 12px 4px; }
.chat-input__pill .icon-btn { width: 42px; height: 46px; border-radius: 23px; color: var(--ink-soft); }
.chat-input__pill .icon-btn .icon { width: 23px; height: 23px; }
.chat-input .send-btn { width: 48px; height: 48px; box-shadow: 0 4px 14px color-mix(in srgb, var(--wax) 32%, transparent); }
.chat-input .send-btn .icon { width: 21px; height: 21px; }
.chat-input .send-btn:disabled { box-shadow: none; }
[data-theme="dark"] .chat-input__pill { box-shadow: none; }

/* Their bubbles: flat warm grey, no shadow or outline. The time inside them
   uses the darker secondary ink, so it stays readable on grey. */
.msg--theirs .msg__bubble { box-shadow: none; }
.msg--theirs .msg__meta { color: var(--ink-soft); }
.typing-bubble { box-shadow: none; }
