.message-context {
  position: fixed;
  margin: 0;
  padding: 0;
  width: min(228px, calc(100vw - 24px));
  max-width: none;
  color: #f8f8f7;
  background: linear-gradient(135deg, rgba(44,45,44,.94), rgba(24,30,27,.94));
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 15px;
  box-shadow: 0 15px 50px #0005, inset 0 1px 1px #ffffff14;
  backdrop-filter: blur(28px) saturate(1.5);
  -webkit-backdrop-filter: blur(28px) saturate(1.5);
  overflow: hidden;
  animation: message-menu-pop .22s cubic-bezier(.2,1.2,.4,1) both;
}
.message-context:focus { outline: none; }
.message-context::backdrop { background: #151a1726; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.message-context--4 { width: min(208px, calc(100vw - 24px)); }
.message-context--2 { width: min(176px, calc(100vw - 24px)); }
.message-context--1 { width: min(102px, calc(100vw - 24px)); }
.message-action-grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.message-context--4 .message-action-grid,
.message-context--2 .message-action-grid { grid-template-columns: repeat(2, 1fr); }
.message-context--1 .message-action-grid { grid-template-columns: 1fr; }
.message-action-grid button {
  min-width: 0;
  min-height: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 3px;
  border: 0;
  border-right: 1px solid #ffffff0b;
  border-bottom: 1px solid #ffffff0b;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: 11px;
  font-weight: 500;
}
.message-context--3 .message-action-grid button:nth-child(3n),
.message-context--4 .message-action-grid button:nth-child(2n),
.message-context--2 .message-action-grid button:nth-child(2n),
.message-context--1 .message-action-grid button { border-right: 0; }
.message-context--3 .message-action-grid button,
.message-context--4 .message-action-grid button:nth-last-child(-n+2),
.message-context--2 .message-action-grid button,
.message-context--1 .message-action-grid button { border-bottom: 0; }
.message-action-grid button svg { width: 21px; height: 21px; }
.message-action-grid button:hover, .message-action-grid button:active { background: #ffffff12; }
.message-action-grid button:focus-visible { outline: 2px solid var(--action-primary); outline-offset: -5px; }
.context-active { box-shadow: 0 0 0 3px var(--focus-ring); }
.message-actionable { touch-action: pan-y; }
.copy-text-preview { max-height: 240px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.9; font-size: 15px; padding: 17px; background: #f7f4ef; border-radius: 14px; }
.copy-text-preview mark { background: var(--surface-accent); color: inherit; border-radius: 3px; }
.copy-range-controls { margin-top: 19px; }
.copy-range-controls input { width: 100%; accent-color: #d8755b; min-height: 30px; }
.reply-composer { display: flex; align-items: center; gap: 12px; padding: 12px 17px; border-top: 1px solid #eee6de; background: #fcf6ef; }
.reply-composer > div { flex: 1; min-width: 0; border-left: 3px solid #de896b; padding-left: 10px; }
.reply-composer strong, .reply-composer small { display: block; }
.reply-composer strong { font-size: 12px; color: #ba705b; margin-bottom: 3px; }
.reply-composer small { font-size: 12px; color: #8d8884; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-composer button { border: 0; background: transparent; color: #9b8d84; padding: 8px; font-size: 22px; }
.message-quote { display: block; width: 100%; text-align: left; margin: 0 0 8px; padding: 8px 10px; border: 0; border-left: 3px solid #d19a7d; border-radius: 6px; background: #00000008; color: inherit; }
.message-quote strong { display: block; font-size: 11px; margin-bottom: 3px; opacity: .9; }
.message-quote span { display: block; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; opacity: .8; }
.mine .message-quote { background: #ffffff26; border-left-color: #fff9; }
.message-jump { animation: message-jump 1.2s ease; }
@keyframes message-menu-pop { from { opacity: 0; transform: translateY(8px) scale(.94); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes message-jump { 0%, 45% { box-shadow: 0 0 0 4px var(--focus-ring); } 100% { box-shadow: none; } }
@media(prefers-reduced-motion: reduce) { .message-context, .message-jump { animation: none; } }

.message-location { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 14px; background: var(--surface-accent); color: var(--action-primary); font-size: 11px; border-bottom: 1px solid var(--line-strong); }
.message-location button { border: 0; border-radius: 8px; background: #fff; color: var(--action-primary); font: inherit; padding: 7px 9px; }

/* Hearts under chat bubbles, the read label and its reader list. */
.message-hearts { display: inline-flex; align-items: center; gap: var(--space-1, 4px); width: fit-content; min-height: var(--touch-small, 28px); margin: var(--space-1, 4px) 2px 0; padding: 2px 10px 2px 7px; border: 1px solid var(--line-soft); border-radius: var(--radius-pill); background: var(--surface-card); color: var(--ink-secondary); font-size: var(--text-micro, 11px); font-weight: 700; line-height: 1.2; }
.message-hearts svg { width: 14px; height: 14px; flex: none; fill: #d6405f; }
.message-hearts.hearted { border-color: #f1c4cd; background: #fdf0f2; color: #9c2440; }
.message.mine .message-hearts { display: flex; margin-left: auto; }
#messages .bubble[data-message-id] { touch-action: manipulation; }
.heart-burst { position: fixed; z-index: 30; width: 72px; height: 72px; margin: -36px 0 0 -36px; pointer-events: none; animation: heart-burst 760ms var(--ease-standard, ease-out) forwards; }
.heart-burst svg { width: 100%; height: 100%; fill: #e0486a; filter: drop-shadow(0 6px 14px rgb(0 0 0 / 18%)); }
@keyframes heart-burst {
  0% { opacity: 0; transform: scale(.3); }
  25% { opacity: 1; transform: scale(1.15); }
  45% { transform: scale(.95); }
  70% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: translateY(-24px) scale(.9); }
}
.bubble-row { display: flex; align-items: flex-end; justify-content: flex-end; gap: 6px; min-width: 0; }
.bubble-row > .bubble { min-width: 0; }
.message-side { display: flex; flex: none; flex-direction: column; align-items: flex-end; margin-bottom: 2px; color: var(--ink-secondary); font-size: var(--text-micro, 11px); line-height: 1.35; white-space: nowrap; }
button.message-read-count { min-height: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.readers-popup { position: fixed; inset: auto; margin: 0; width: max-content; min-width: 116px; max-width: min(240px, calc(100vw - 24px)); max-height: min(260px, 50vh); padding: 0; overflow: auto; border: 1px solid rgba(255,255,255,.12); border-radius: 12px; background: rgba(42,42,42,.94); color: #f8f8f7; box-shadow: var(--shadow-float); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
.readers-popup::backdrop { background: #151a1726; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.readers-title { margin: 0; padding: 6px 12px; border-bottom: 1px solid rgba(255,255,255,.12); font-size: var(--text-micro, 11px); font-weight: 700; text-align: center; color: rgba(248,248,247,.82); }
.readers-popup ul { margin: 0; padding: 3px 0; list-style: none; }
.readers-popup li { display: flex; align-items: center; gap: 8px; padding: 4px 12px; font-size: 13px; }
.readers-popup .avatar { flex: none; width: 22px; height: 22px; border-radius: 50%; font-size: 10px; }
.readers-popup .reader-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.readers-popup time { margin-left: 10px; color: #f8f8f7a6; font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Date pill before the first message of each day. */
.day-divider { display: flex; justify-content: center; align-self: stretch; margin: var(--space-2, 8px) 0 var(--space-1, 4px); }
.day-divider span { padding: 4px 12px; border-radius: var(--radius-pill); background: var(--surface-soft); color: var(--ink-secondary); font-size: var(--text-micro, 11px); font-weight: 700; }

/* Reply hint that appears while swiping a message to the left. */
#messages .message { touch-action: pan-y; }
.swipe-reply-icon { position: fixed; z-index: 20; display: grid; place-items: center; width: 32px; height: 32px; margin-top: -16px; border-radius: 50%; background: var(--surface-soft); color: var(--ink-secondary); opacity: 0; pointer-events: none; transition: background var(--motion-fast, 120ms), color var(--motion-fast, 120ms), transform var(--motion-fast, 120ms); }
.swipe-reply-icon svg { width: 18px; height: 18px; }
.swipe-reply-icon.ready { background: var(--action-primary); color: var(--ink-on-accent); transform: scale(1.1); }
/* "設為封面" stands out in the photo menu with the account's accent colour. */
.message-action-grid button[data-parent-cover], .message-action-grid button[data-own-cover] { background: var(--action-primary); color: var(--ink-on-accent, #fff); font-weight: 700; }
.message-action-grid button[data-own-cover] + button[data-parent-cover] { box-shadow: inset 1px 0 0 #ffffff59; }
