/* ==========================================================================
   Glint web — Direct messages (inbox, thread, composer, voice notes, details,
   new message). Scoped under .page-direct / .dm*. Cyanotype tokens only.
   ========================================================================== */

/* --- Page frame ------------------------------------------------------------ */

.page-direct { --dm-inbox-w: 397px; --dm-own-bg: var(--brand-500); --dm-own-fg: var(--on-brand); }

/* Like the reference apps, Messages uses the icon sidebar on desktop. */
@media (min-width: 768px) {
  body.page-direct { --sidebar-w: var(--layout-web-sidebar-icons); }
  .page-direct .sidebar { width: var(--layout-web-sidebar-icons); padding-inline: 12px; }
  .page-direct .sidebar .nav-label, .page-direct .sidebar .wordmark { display: none; }
  .page-direct .sidebar .brand-mark { display: block; }
  .page-direct .sidebar .sidebar-brand { padding-inline: 10px; }
  .page-direct .main { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
}

.dm { display: flex; min-height: 0; flex: 1; }
@media (min-width: 768px) { .dm { height: 100vh; height: 100dvh; } }

/* --- Inbox pane -------------------------------------------------------------- */

.dm-inbox { width: var(--dm-inbox-w); flex: none; display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border-subtle); background: var(--bg-base); }
.dm-inbox-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 36px 24px 12px; flex: none; }
.dm-inbox-title { font-size: var(--type-title-lg-size); line-height: var(--type-title-lg-line); font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-inbox-head .icon-btn { margin: -8px -8px -8px 0; }
.dm-inbox-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.dm-mobile-head { display: none; }

/* Notes row: 60-char status bubbles above avatars. */
.dm-notes { display: flex; gap: 4px; padding: 30px 16px 8px; overflow-x: auto; scrollbar-width: none; }
.dm-notes::-webkit-scrollbar { display: none; }
.dm-note { flex: none; }
.dm-note-btn { position: relative; display: grid; justify-items: center; gap: 4px; width: 72px; padding: 0 2px; }
.dm-note-btn .avatar { --size: 48px; }
.dm-note-bubble {
  position: absolute; left: 50%; bottom: calc(100% - 10px); transform: translateX(-50%); z-index: 1;
  width: max-content; max-width: 92px; min-width: 40px; padding: 4px 9px; border-radius: 12px;
  background: var(--bg-raised); color: var(--text-primary); border: 1px solid var(--border-subtle);
  font-size: 12px; line-height: 1.25; text-align: center; overflow-wrap: anywhere;
}
.dm-note-bubble > span { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.dm-note-bubble::after { content: ""; position: absolute; left: 14px; bottom: -6px; width: 8px; height: 8px; border-radius: 50%; background: var(--bg-raised); border: 1px solid var(--border-subtle); }
.dm-note-bubble.is-empty { color: var(--text-secondary); }
.dm-note-name { max-width: 68px; font-size: var(--type-micro-size); color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-note-btn:hover .dm-note-bubble { border-color: var(--text-tertiary); }

/* Note dialog. */
.dm-note-dialog { width: min(420px, 100%); }
.dm-note-dialog .head-action:disabled { opacity: 0.45; }
.dm-note-compose { position: relative; display: grid; justify-items: center; gap: 12px; padding: 88px 24px 24px; }
.dm-note-compose .dm-note-bubble.is-input { position: absolute; top: 20px; bottom: auto; max-width: 240px; width: 240px; padding: 10px 12px; }
.dm-note-compose textarea { width: 100%; border: 0; background: transparent; resize: none; text-align: center; font-size: var(--type-body-size); line-height: 1.35; color: var(--text-primary); padding: 0; }
.dm-note-compose textarea::placeholder { color: var(--text-secondary); }
.dm-note-compose .avatar { --size: 86px; margin-top: 12px; }
.dm-note-count { font-size: var(--type-meta-size); color: var(--text-tertiary); }
.dm-note-hint { font-size: var(--type-meta-size); color: var(--text-secondary); text-align: center; }

/* Search + tabs. */
.dm-search { padding: 4px 16px 8px; }
.dm-tabs { padding: 0 24px; gap: 32px; }
.dm-tabs .tab-btn { display: inline-flex; align-items: center; gap: 6px; }
.dm-tab-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--brand-500); color: var(--on-brand); font-size: var(--type-micro-size); font-weight: 600; }
.dm-requests-note { padding: 12px 24px 4px; font-size: var(--type-meta-size); color: var(--text-secondary); }

/* Rows. */
.dm-list { display: grid; padding: 8px 0 16px; }
.dm-row { position: relative; display: flex; align-items: center; gap: 12px; min-width: 0; padding: 8px 24px; transition: background-color 120ms; }
.dm-row:hover { background: color-mix(in srgb, var(--bg-raised) 60%, transparent); }
.dm-row.is-active { background: var(--bg-raised); }
.dm-row-av { position: relative; flex: none; display: grid; }
.dm-row-av .avatar { --size: 56px; }
.dm-row-avdot { display: none; position: absolute; right: 0; top: 2px; box-shadow: 0 0 0 2px var(--bg-base); }
.dm-row-text { display: grid; min-width: 0; flex: 1; gap: 2px; line-height: 1.3; }
.dm-row-title { font-size: var(--type-body-size); color: var(--text-primary); font-weight: 400; }
.dm-row-sub { display: flex; align-items: center; gap: 4px; min-width: 0; font-size: var(--type-meta-size); color: var(--text-secondary); }
.dm-row-preview { flex: 0 1 auto; }
.dm-row-preview.is-typing { color: var(--brand-400); }
.dm-row-time { flex: none; }
.dm-row-muted { color: var(--text-secondary); flex: none; }
.dm-row.is-unread .dm-row-title, .dm-row.is-unread .dm-row-preview:not(.is-typing) { font-weight: 600; color: var(--text-primary); }
.dm-row-dot { flex: none; }

/* Stacked group avatars. */
.dm-stack { position: relative; display: block; width: var(--dm-stack); height: var(--dm-stack); flex: none; }
.dm-stack .avatar { position: absolute; width: var(--dm-stack-small); height: var(--dm-stack-small); }
.dm-stack .avatar:first-child { left: 0; top: 0; }
.dm-stack .avatar:last-child { right: 0; bottom: 0; border-radius: 50%; box-shadow: 0 0 0 2px var(--bg-base); }
.dm-row.is-active .dm-stack .avatar:last-child, .dm-row:hover .dm-stack .avatar:last-child { box-shadow: 0 0 0 2px var(--bg-raised); }

.dm-empty { padding-top: 64px; }

/* --- Thread pane ------------------------------------------------------------- */

.dm-main { position: relative; flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.dm-welcome { flex: 1; display: grid; place-items: center; padding: 24px; }
.dm-welcome .empty h2 { font-size: var(--type-title-lg-size); font-weight: 400; }

.dm-thread { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--dm-tint, var(--bg-base)); }
.dm-missing { justify-content: center; }

/* Chat themes → own-bubble color, plus a faint background tint and accent so a theme is visible even
   before you've sent anything (the only-gradient rule still holds: tints are flat). */
.dm-thread[data-chat-theme="cyanotype"] { --dm-tint: color-mix(in srgb, var(--brand-500) 9%, var(--bg-base)); --dm-accent: var(--brand-400); }
.dm-thread[data-chat-theme="selenium"] { --dm-tint: color-mix(in srgb, var(--accent-selenium) 7%, var(--bg-base)); --dm-accent: var(--accent-selenium); }
.dm-thread[data-chat-theme="flash"] { --dm-tint: color-mix(in srgb, var(--accent-flash) 6%, var(--bg-base)); --dm-accent: var(--accent-flash); }
.dm-thread[data-chat-theme="mono"] { --dm-accent: var(--text-primary); }
.dm-thread[data-chat-theme="selenium"] { --dm-own-bg: var(--accent-selenium); --dm-own-fg: var(--bg-base); }
[data-theme="light"] .dm-thread[data-chat-theme="selenium"] { --dm-own-fg: var(--text-primary); }
/* Cyanotype: the pale print tone. Flash: a tint (white on flash is below 4.5:1, so never body text on solid flash). */
.dm-thread[data-chat-theme="cyanotype"] { --dm-own-bg: var(--brand-100); --dm-own-fg: var(--text-primary); }
.dm-thread[data-chat-theme="flash"] { --dm-own-bg: color-mix(in srgb, var(--accent-flash) 24%, var(--bg-base)); --dm-own-fg: var(--text-primary); }
.dm-thread[data-chat-theme="mono"] { --dm-own-bg: var(--text-primary); --dm-own-fg: var(--bg-base); }

.dm-head { display: flex; align-items: center; gap: 12px; height: 75px; padding: 0 16px; border-bottom: 1px solid var(--border-subtle); flex: none; background: var(--dm-tint, var(--bg-base)); }
.dm-back { display: none; }
.dm-head-who { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; text-align: left; }
.dm-head-who .avatar, .dm-head-who .dm-stack { --size: 44px; }
.dm-head-text { display: grid; min-width: 0; line-height: 1.3; }
.dm-head-title { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: var(--type-title-md-size); }
.dm-head-sub { font-size: var(--type-meta-size); color: var(--text-secondary); }
.dm-info { margin: -8px -4px -8px 0; }

.dm-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column-reverse; scrollbar-width: thin; }
.dm-log { display: flex; flex-direction: column; padding: 16px 16px 12px; }

.dm-older { display: grid; place-items: center; min-height: 48px; }
.dm-intro { display: grid; justify-items: center; gap: 6px; padding: 24px 16px 32px; text-align: center; }
.dm-intro .avatar, .dm-intro .dm-stack { --size: 96px; margin-bottom: 8px; }
.dm-intro-title { font-size: var(--type-title-lg-size); font-weight: 600; }
.dm-intro-sub { font-size: var(--type-meta-size); color: var(--text-secondary); margin-bottom: 8px; }

.dm-divider { align-self: center; margin: 20px 0 10px; font-size: var(--type-meta-size); font-weight: 500; color: var(--text-secondary); }
.dm-system { align-self: center; max-width: 80%; margin: 8px 0; text-align: center; font-size: var(--type-meta-size); color: var(--text-secondary); }

/* Messages. */
.dm-msg { display: flex; flex-direction: column; align-items: flex-start; margin-top: 2px; border-radius: 12px; transition: background-color 300ms; }
.dm-msg.is-own { align-items: flex-end; }
.dm-msg.pos-single, .dm-msg.pos-first { margin-top: 8px; }
.dm-msg.has-reacts { margin-bottom: 16px; }
.dm-msg.is-flash { background: color-mix(in srgb, var(--brand-500) 14%, transparent); }
.dm-sender { margin: 0 0 3px 48px; font-size: var(--type-micro-size); color: var(--text-secondary); }

.dm-line { display: flex; align-items: flex-end; gap: 8px; width: 100%; }
.is-own > .dm-line { flex-direction: row-reverse; }
.dm-av { width: 28px; flex: none; display: grid; align-self: flex-end; }
.dm-av .avatar { --size: 28px; }
.dm-content { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; max-width: min(72%, 480px); -webkit-touch-callout: none; }
.is-own .dm-content { align-items: flex-end; }

.dm-bubble {
  padding: 8px 12px; border-radius: var(--radius-bubble); background: var(--bg-raised); color: var(--text-primary);
  font-size: var(--type-body-size); line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%;
}
.is-own .dm-bubble { background: var(--dm-own-bg); color: var(--dm-own-fg); }
.is-own .dm-bubble .mention, .is-own .dm-bubble .hashtag { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.dm-bubble.is-jumbo { background: none !important; padding: 0 2px; font-size: 40px; line-height: 1.15; }
.dm-bubble.is-unsent { background: transparent !important; color: var(--text-secondary) !important; border: 1px solid var(--border-subtle); font-style: italic; }

/* Bubble shape: 18 all round, the corner nearest the sender 6 (runs: first → bottom, middle/last → both). */
.is-theirs.pos-single .dm-shape, .is-theirs.pos-first .dm-shape { border-bottom-left-radius: var(--radius-bubble-tail); }
.is-theirs.pos-middle .dm-shape, .is-theirs.pos-last .dm-shape { border-top-left-radius: var(--radius-bubble-tail); border-bottom-left-radius: var(--radius-bubble-tail); }
.is-own.pos-single .dm-shape, .is-own.pos-first .dm-shape { border-bottom-right-radius: var(--radius-bubble-tail); }
.is-own.pos-middle .dm-shape, .is-own.pos-last .dm-shape { border-top-right-radius: var(--radius-bubble-tail); border-bottom-right-radius: var(--radius-bubble-tail); }
.dm-shape.is-jumbo { border-radius: 0 !important; }

/* Media. */
.dm-media { position: relative; display: block; width: 260px; max-width: 100%; max-height: 360px; overflow: hidden; border-radius: var(--radius-bubble); background: var(--bg-raised); }
.dm-media img, .dm-media video { width: 100%; height: 100%; max-height: 360px; object-fit: cover; }
.dm-media.is-video video { object-fit: contain; background: #000; max-height: 420px; }
.dm-media:focus-visible { outline-offset: 2px; }
.dm-media.is-uploading img, .dm-media.is-uploading video { opacity: 0.6; }
.dm-progress { position: absolute; inset: 0; display: grid; place-items: center; }
.dm-progress svg { width: 40px; height: 40px; transform: rotate(-90deg); }
.dm-progress circle { fill: none; stroke: rgba(255, 255, 255, 0.35); stroke-width: 3; }
.dm-progress circle.bar { stroke: #fff; stroke-dasharray: 100.5; transition: stroke-dashoffset 120ms linear; stroke-linecap: round; }

/* Shared post card. */
.dm-card { display: block; width: 240px; max-width: 100%; overflow: hidden; border-radius: var(--radius-bubble); background: var(--bg-raised); color: var(--text-primary); }
.dm-card-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; min-width: 0; }
.dm-card-head .avatar { --size: 24px; }
.dm-card-media { position: relative; display: block; aspect-ratio: 4 / 5; background: var(--bg-surface); }
.dm-card-media img { width: 100%; height: 100%; object-fit: cover; }
.dm-card-type { position: absolute; top: 8px; right: 8px; color: #fff; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4)); }
.dm-card-caption { padding: 0 12px; margin: 8px 0 10px; font-size: var(--type-meta-size); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dm-card-caption .username { margin-right: 2px; }
.dm-card:hover .dm-card-media img { opacity: 0.92; }
.dm-card.is-missing { display: flex; flex-direction: row; align-items: flex-start; gap: 10px; padding: 12px; background: transparent; border: 1px solid var(--border-subtle); color: var(--text-secondary); }
.dm-card.is-missing strong { display: block; color: var(--text-primary); font-weight: 600; font-size: var(--type-body-size); }
.dm-card.is-missing span span { font-size: var(--type-meta-size); }

/* Story reply. */
.dm-story-label { font-size: var(--type-meta-size); color: var(--text-secondary); margin: 0 4px 2px; }
.dm-story { display: block; width: 112px; aspect-ratio: 9 / 16; overflow: hidden; border-radius: var(--radius-control); background: var(--bg-raised); }
.dm-story img { width: 100%; height: 100%; object-fit: cover; }
.dm-story.is-expired { display: grid; place-items: center; align-content: center; gap: 6px; padding: 8px; text-align: center; font-size: var(--type-meta-size); color: var(--text-secondary); border: 1px solid var(--border-subtle); background: transparent; }

/* Reply quote. */
.dm-quote { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; max-width: min(72%, 480px); margin: 10px 0 2px 36px; text-align: left; }
.is-own > .dm-quote { align-items: flex-end; margin-left: 0; text-align: right; }
.dm-quote-label { display: inline-flex; align-items: center; gap: 4px; font-size: var(--type-micro-size); color: var(--text-secondary); padding: 0 4px; }
.dm-quote-text {
  padding: 7px 12px 14px; margin-bottom: -10px; border-radius: var(--radius-bubble); background: var(--bg-surface); border: 1px solid var(--border-subtle);
  color: var(--text-secondary); font-size: var(--type-meta-size); line-height: 1.35; max-width: 100%; display: block; overflow-wrap: anywhere;
}
.dm-quote-text > span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dm-quote + .dm-line { position: relative; z-index: 1; }

/* Reactions float at the bottom corner of the bubble. */
.dm-reacts { position: absolute; bottom: -16px; z-index: 2; display: flex; gap: 2px; }
.is-theirs .dm-reacts { left: 8px; }
.is-own .dm-reacts { right: 8px; }
.dm-react { display: inline-flex; align-items: center; gap: 3px; height: 24px; padding: 0 7px; border-radius: 999px; background: var(--bg-raised); border: 2px solid var(--bg-base); font-size: 13px; line-height: 1; color: var(--text-primary); }
.dm-react .tnum { font-size: var(--type-micro-size); font-weight: 600; color: var(--text-secondary); }
.dm-react.is-mine { background: var(--brand-100); }
.dm-react:hover { filter: brightness(1.08); }

/* Hover toolbar (desktop). */
.dm-tools { display: flex; align-items: center; gap: 0; align-self: center; opacity: 0; transition: opacity 120ms; flex: none; }
.is-own .dm-tools { flex-direction: row-reverse; }
.dm-line:hover .dm-tools, .dm-tools:focus-within { opacity: 1; }
.dm-tool { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: var(--text-secondary); }
.dm-tool:hover { color: var(--text-primary); background: var(--bg-raised); }
@media (hover: none) { .dm-tools { display: none; } }

/* Pending (optimistic) sends. */
.dm-msg.is-pending .dm-bubble { opacity: 0.72; }
.dm-msg.is-failed .dm-bubble, .dm-msg.is-failed .dm-media { opacity: 0.5; }
.dm-pending-state { display: flex; gap: 12px; margin: 3px 4px 0; font-size: var(--type-micro-size); color: var(--text-secondary); }
.dm-pending-state button { display: inline-flex; align-items: center; gap: 4px; color: var(--status-danger); font-weight: 600; }
.dm-pending-state .dm-pending-remove { color: var(--text-secondary); }

/* Typing indicator. */
.dm-typing { display: inline-flex; align-items: center; gap: 4px; padding: 13px 14px; }
.dm-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-secondary); animation: dm-typing 1.2s infinite ease-in-out; }
.dm-typing i:nth-child(2) { animation-delay: 0.15s; }
.dm-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dm-typing { 0%, 60%, 100% { opacity: 0.35; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
.dm-typing-row .avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

/* Time + receipt inside the bubble (WhatsApp style). */
.dm-bubble { white-space: normal; }
.dm-text { white-space: pre-wrap; }
/* The meta sits in the bubble's bottom-right corner; an invisible spacer after the text reserves its room on the last line. */
.dm-bubble:has(> .dm-meta) { position: relative; }
.dm-bubble > .dm-text::after { content: ''; display: inline-block; width: 40px; height: 1px; }
.is-own .dm-bubble > .dm-text::after { width: 62px; }
.dm-meta { position: absolute; right: 10px; bottom: 5px; display: inline-flex; align-items: center; gap: 3px; font-size: 11px; line-height: 14px; white-space: nowrap; color: var(--text-secondary); font-variant-numeric: tabular-nums; pointer-events: none; }
.is-own .dm-bubble .dm-meta { color: color-mix(in srgb, var(--dm-own-fg) 80%, transparent); }
.dm-bubble.is-jumbo .dm-meta { position: static; justify-content: flex-end; display: flex; color: var(--text-secondary); }
.dm-bubble.is-jumbo > .dm-text::after { display: none; }
.dm-meta.is-overlay { right: 8px; bottom: 8px; padding: 2px 6px; border-radius: 999px; background: rgba(0, 0, 0, 0.45); color: #fff !important; }
.dm-media.is-video .dm-meta.is-overlay { bottom: auto; top: 8px; }
.dm-meta.is-under { position: static; margin: 2px 4px 0; align-self: flex-end; }
.is-theirs .dm-meta.is-under { align-self: flex-start; }
.dm-ticks { flex: none; width: 18px; height: 12px; display: block; }
.dm-ticks.is-sent, .dm-ticks.is-delivered, .dm-ticks.is-sending { opacity: 0.9; }
.dm-ticks.is-seen { color: var(--dm-seen, #53BDEB); opacity: 1; }
/* Light own bubbles (Selenium, Flash, light Cyanotype) need a deeper blue for "seen". */
.dm-thread[data-chat-theme="selenium"] .is-own, [data-theme="light"] .dm-thread[data-chat-theme="flash"] .is-own, [data-theme="light"] .dm-thread[data-chat-theme="cyanotype"] .is-own { --dm-seen: #0A6FA6; }
.dm-msg.is-failed .dm-meta { visibility: hidden; }
.dm-media { position: relative; }

/* Voice note: avatar (speed while playing) · play · waveform; time under it; time + receipt bottom-right. */
.dm-voice { position: relative; display: block; width: 340px; max-width: 100%; padding: 8px 12px 6px 8px; }
.dm-voice-main { display: grid; grid-template-columns: 44px 36px minmax(0, 1fr); align-items: center; column-gap: 8px; --wave-off: color-mix(in srgb, var(--text-primary) 32%, transparent); --wave-on: var(--text-primary); --wave-dot: var(--brand-400); }
.is-own .dm-voice-main { --wave-off: color-mix(in srgb, var(--dm-own-fg) 45%, transparent); --wave-on: var(--dm-own-fg); --wave-dot: var(--dm-own-fg); }
.dm-voice-main.is-unplayed { --wave-off: color-mix(in srgb, var(--dm-accent, var(--accent-selenium)) 55%, transparent); --wave-dot: var(--dm-accent, var(--accent-selenium)); }
.dm-voice-lead { position: relative; width: 44px; height: 44px; display: grid; place-items: center; }
.dm-voice-av { position: relative; display: block; width: 44px; height: 44px; }
.dm-voice-av .avatar { --size: 44px; width: 44px; height: 44px; }
.dm-voice-av .avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.dm-voice-av-empty { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: color-mix(in srgb, currentColor 16%, transparent); }
.dm-voice-mic { position: absolute; right: -4px; bottom: -2px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--bg-raised); color: var(--text-secondary); box-shadow: 0 0 0 2px var(--bg-raised); }
.is-own .dm-voice-mic { background: var(--dm-own-bg); color: var(--dm-own-fg); box-shadow: 0 0 0 2px var(--dm-own-bg); }
.dm-voice-main.is-unplayed .dm-voice-mic { color: var(--dm-accent, var(--accent-selenium)); }
.dm-voice-speed { min-width: 40px; height: 26px; padding: 0 8px; border-radius: 999px; background: color-mix(in srgb, currentColor 18%, transparent); color: inherit; font-size: 13px; font-weight: 600; }
.dm-voice-play { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: inherit; }
.dm-voice-play:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
.dm-voice-body { display: grid; gap: 2px; min-width: 0; padding-top: 6px; }
.dm-wave { position: relative; height: 28px; cursor: pointer; touch-action: none; --p: 0; }
.dm-wave:focus-visible { outline-offset: 4px; }
.dm-wave-bars { position: absolute; inset: 0 6px 0 0; display: flex; align-items: center; justify-content: space-between; }
.dm-wave-bars i { display: block; width: 3px; min-height: 3px; border-radius: 2px; background: var(--wave-off); flex: none; }
.dm-wave-bars.is-played { clip-path: inset(0 calc((1 - var(--p)) * 100%) 0 0); }
.dm-wave-bars.is-played i { background: var(--wave-on); }
.dm-wave-dot { position: absolute; top: 50%; left: calc(var(--p) * (100% - 6px)); width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--wave-dot); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); pointer-events: none; }
.dm-voice-time { font-size: 12px; line-height: 16px; opacity: 0.8; }
.dm-voice > .dm-meta { right: 12px; bottom: 6px; }
.is-pending-voice .dm-wave { cursor: default; }

/* --- Composer: raised card, text on top, tools below (ChatGPT-like) ---------------- */

.dm-compose-wrap { flex: none; padding: 4px 16px 12px; background: transparent; }
.dm-replying { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; margin-bottom: 8px; border-radius: var(--radius-control); background: var(--bg-surface); }
.dm-replying .grow { display: grid; gap: 1px; }
.dm-replying-to { font-size: var(--type-meta-size); color: var(--text-secondary); }
.dm-replying-to strong { color: var(--text-primary); font-weight: 600; }
.dm-replying-text { font-size: var(--type-meta-size); color: var(--text-secondary); }
.dm-replying .icon-btn { margin: -4px 0; }

.dm-composer { display: flex; flex-direction: column; gap: 2px; padding: 10px 10px 8px; border: 1px solid var(--border-subtle); border-radius: 24px; background: var(--bg-raised); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.06); transition: border-color 120ms; }
.dm-composer:focus-within { border-color: color-mix(in srgb, var(--text-tertiary) 70%, transparent); }
.dm-composer textarea {
  width: 100%; min-height: 26px; max-height: 128px; padding: 2px 6px; border: 0; background: transparent; resize: none; outline: none;
  font-size: 17px; font-weight: 400; line-height: 24px; color: var(--text-primary); overflow-y: auto;
}
.dm-composer textarea::placeholder { color: var(--text-secondary); }
.dm-compose-bar { display: flex; align-items: center; gap: 12px; min-height: 40px; }
.dm-compose-bar .grow { flex: 1; }
.dm-cbtn { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%; color: var(--text-primary); }
.dm-cbtn:hover { background: color-mix(in srgb, var(--text-primary) 8%, transparent); }
.dm-cbtn .icon { width: 24px; height: 24px; }
.dm-plus { border: 1px solid var(--border-subtle); }
.dm-go { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%; background: var(--brand-500); color: var(--on-brand); transition: transform 120ms, opacity 120ms; }
.dm-go:hover { transform: scale(1.05); }
.dm-go:disabled { opacity: 0.45; transform: none; }
.dm-go .icon { width: 22px; height: 22px; }
.dm-emoji { position: relative; }
.dm-emoji .emoji-grid { left: -6px; right: auto; bottom: 44px; }
.dm-attach { position: relative; }
.dm-attach-menu { position: absolute; left: 0; bottom: 46px; z-index: 30; min-width: 220px; padding: 6px; border-radius: 16px; background: var(--bg-surface); border: 1px solid var(--border-subtle); box-shadow: var(--shadow-sheet); }
.dm-attach-menu button { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; padding: 10px 12px; border-radius: 10px; font-size: 17px; font-weight: 400; color: var(--text-primary); text-decoration: none; }
.dm-attach-menu button:hover { background: var(--bg-raised); }
.dm-attach-menu .icon { width: 24px; height: 24px; }
@media (hover: hover) and (pointer: fine) { .dm-attach-camera { display: none !important; } }

/* Voice recorder (tap to record). */
.dm-rec { display: grid; gap: 10px; padding: 12px 12px 10px; border: 1px solid var(--border-subtle); border-radius: 24px; background: var(--bg-raised); }
.dm-rec-top { display: flex; align-items: center; gap: 12px; min-width: 0; height: 32px; padding: 0 4px; }
.dm-rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--status-danger); flex: none; animation: dm-pulse 1s infinite ease-in-out; }
@keyframes dm-pulse { 50% { opacity: 0.3; } }
.dm-rec-play { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 50%; color: var(--text-primary); }
.dm-rec-time { font-size: 20px; line-height: 1; min-width: 52px; font-variant-numeric: tabular-nums; }
.dm-rec-meter { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: flex-end; gap: 3px; height: 28px; overflow: hidden; }
.dm-rec-meter i { width: 3px; flex: none; border-radius: 2px; background: var(--text-secondary); transition: height 80ms linear; }
.dm-rec-meter.is-paused { justify-content: space-between; }
.dm-rec-meter i.on { background: var(--brand-400); }
.dm-rec-actions { display: flex; align-items: center; gap: 12px; }
.dm-rec-trash { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%; background: color-mix(in srgb, var(--status-danger) 14%, transparent); color: var(--status-danger); }
.dm-rec-trash:hover { background: color-mix(in srgb, var(--status-danger) 22%, transparent); }
.dm-rec-pause { flex: 1; height: 44px; border-radius: 999px; background: color-mix(in srgb, var(--text-primary) 8%, transparent); color: var(--text-primary); font-size: 17px; font-weight: 500; }
.dm-rec-pause .row { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.dm-rec-pause:hover { background: color-mix(in srgb, var(--text-primary) 12%, transparent); }
.dm-rec-pause:disabled, .dm-rec-send:disabled { opacity: 0.5; }
.dm-rec-send { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%; background: var(--brand-500); color: var(--on-brand); }
.dm-rec-send .icon { width: 22px; height: 22px; }

/* Message request banner. */
.dm-request { flex: none; display: grid; gap: 6px; padding: 16px 24px 20px; border-top: 1px solid var(--border-subtle); text-align: center; background: var(--bg-base); }
.dm-request-title { font-size: var(--type-body-size); }
.dm-request-title strong { font-weight: 600; }
.dm-request-sub { font-size: var(--type-meta-size); color: var(--text-secondary); max-width: 440px; justify-self: center; }
.dm-request-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.dm-request-actions .t-danger { color: var(--status-danger); }

/* --- Floating reaction picker, touch sheet, lightbox ----------------------- */

.dm-picker { position: fixed; z-index: 80; display: flex; gap: 2px; padding: 6px 8px; border-radius: 999px; background: var(--bg-surface); border: 1px solid var(--border-subtle); box-shadow: var(--shadow-sheet); }
.dm-picker button, .dm-focus-reacts button { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; font-size: 32px; line-height: 1; transition: transform 120ms var(--ease-sheet); }
.dm-picker button:hover, .dm-focus-reacts button:hover { transform: scale(1.18); }
.dm-picker button.is-mine, .dm-focus-reacts button.is-mine { background: var(--brand-100); }

/* Message menu: the message lifted over a dimmed, blurred thread (iOS style). */
.dm-msg.is-focused { visibility: hidden; }
.dm-focus { position: fixed; inset: 0; z-index: 95; background: rgba(0, 0, 0, 0.42); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); animation: dm-fade 140ms ease-out; }
@keyframes dm-fade { from { opacity: 0; } }
.dm-focus-stack { position: fixed; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 24px)); }
.dm-focus-stack.is-own { align-items: flex-end; }
.dm-focus-stack.is-theirs { align-items: flex-start; }
.dm-focus-reacts { display: flex; gap: 2px; padding: 6px 8px; border-radius: 999px; background: var(--bg-surface); box-shadow: var(--shadow-sheet); }
.dm-focus-msg { max-height: 40vh; overflow: hidden; border-radius: var(--radius-bubble); pointer-events: none; }
.dm-focus-msg .dm-content, .dm-info-msg .dm-content { max-width: 100%; }
.dm-focus-msg.is-own .dm-bubble, .dm-info-msg.is-own .dm-bubble { background: var(--dm-own-bg); color: var(--dm-own-fg); }
.dm-focus-msg.is-own .dm-meta, .dm-info-msg.is-own .dm-meta { color: color-mix(in srgb, var(--dm-own-fg) 72%, transparent); }
.dm-focus-msg.is-own .dm-voice-main, .dm-info-msg.is-own .dm-voice-main { --wave-off: color-mix(in srgb, var(--dm-own-fg) 45%, transparent); --wave-on: var(--dm-own-fg); --wave-dot: var(--dm-own-fg); }
.dm-focus-menu { min-width: 240px; padding: 4px 0; border-radius: 14px; background: var(--bg-surface); box-shadow: var(--shadow-sheet); overflow: hidden; }
.dm-focus-menu button { display: flex; align-items: center; justify-content: space-between; gap: 24px; width: 100%; padding: 11px 16px; font-size: 17px; font-weight: 400; line-height: 22px; color: var(--text-primary); text-decoration: none; text-align: left; }
.dm-focus-menu button + button { border-top: 0.5px solid var(--border-subtle); }
.dm-focus-menu button:hover, .dm-focus-menu button:focus-visible { background: var(--bg-raised); text-decoration: none; }
.dm-focus-menu button.danger { color: var(--status-danger); }
.dm-focus-menu .icon { width: 22px; height: 22px; flex: none; }

/* Message info. */
.dm-info-wrap { position: fixed; inset: 0; z-index: 96; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, 0.42); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); animation: dm-fade 140ms ease-out; }
.dm-info-card { width: min(400px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; border-radius: 18px; background: var(--bg-surface); box-shadow: var(--shadow-sheet); overflow: hidden; }
.dm-info-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 8px 8px 20px; }
.dm-info-head h2 { font-size: 17px; font-weight: 600; }
.dm-info-body { overflow-y: auto; padding: 0 20px 16px; }
.dm-info-msg { display: flex; justify-content: flex-end; padding: 12px; margin-bottom: 8px; border-radius: 14px; background: var(--dm-tint, var(--bg-base)); pointer-events: none; }
.dm-info-sub { display: flex; align-items: center; gap: 8px; margin: 14px 0 4px; font-size: 13px; font-weight: 600; color: var(--text-secondary); text-transform: none; }
.dm-info-list { display: grid; }
.dm-info-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; border-bottom: 0.5px solid var(--border-subtle); font-size: 17px; }
.dm-info-row:last-child { border-bottom: 0; }
.dm-info-label, .dm-info-who { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.dm-info-who .avatar { --size: 32px; width: 32px; height: 32px; flex: none; }
.dm-info-who .avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.dm-info-time { font-size: 15px; color: var(--text-secondary); white-space: nowrap; }
.dm-info-empty { padding: 10px 0; font-size: 15px; color: var(--text-secondary); }
.dm-ticks-wrap { display: inline-flex; color: var(--text-secondary); }

.dm-box { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 48px 24px; background: rgba(0, 0, 0, 0.9); animation: fade-in 200ms both; }
.dm-box img { max-width: 100%; max-height: calc(100dvh - 96px); object-fit: contain; border-radius: var(--radius-photo-feed); cursor: zoom-out; }

/* --- Chat details drawer ------------------------------------------------------ */

.dm-details {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 20; width: min(100%, 360px); display: flex; flex-direction: column;
  background: var(--bg-base); border-left: 1px solid var(--border-subtle); box-shadow: var(--shadow-sheet);
  animation: dm-drawer var(--motion-sheet) both;
}
@keyframes dm-drawer { from { transform: translateX(100%); } }
/* ≥1024 the drawer is a column: the conversation stays usable beside it. */
@media (min-width: 1024px) {
  .dm-thread.has-details { padding-right: 360px; }
  .dm-thread.has-details .dm-details { box-shadow: none; animation: none; }
}
.dm-details-head { position: relative; display: flex; align-items: center; justify-content: center; height: 75px; padding: 0 48px; border-bottom: 1px solid var(--border-subtle); flex: none; }
.dm-details-head h2 { font-size: var(--type-title-md-size); font-weight: 600; }
.dm-details-head .icon-btn { position: absolute; top: 50%; transform: translateY(-50%); margin: 0; }
.dm-details-back { left: 8px; display: none !important; }
.dm-details-close { right: 8px; }
.dm-details-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.dm-d-sec { padding: 12px 20px; border-bottom: 1px solid var(--border-subtle); }
.dm-d-sec.is-flush { padding-inline: 0; }
.dm-d-sec.is-flush .dm-d-title, .dm-d-sec.is-flush .dm-d-empty { padding-inline: 20px; }
.dm-d-row { display: flex; align-items: center; gap: 12px; min-height: 48px; cursor: default; }
label.dm-d-row { cursor: pointer; }
.dm-d-row.is-stacked { display: grid; gap: 10px; padding: 8px 0; }
.dm-d-row .icon-duotone { color: var(--text-primary); }
.dm-d-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.dm-d-title h3 { font-size: var(--type-title-md-size); font-weight: 600; }
.dm-d-name { display: flex; gap: 8px; align-items: center; }
.dm-d-name .input { min-height: 36px; height: 36px; padding: 6px 10px; }
.dm-members { margin: 0 -20px; }
.dm-members .user-row { padding: 8px 20px; }
.dm-themes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.dm-theme { display: grid; justify-items: center; gap: 6px; padding: 8px 2px; border-radius: var(--radius-control); font-size: var(--type-micro-size); color: var(--text-secondary); border: 1px solid transparent; }
.dm-theme:hover { background: var(--bg-raised); }
.dm-theme[aria-checked="true"] { color: var(--text-primary); border-color: var(--border-subtle); background: var(--bg-surface); }
.dm-theme-dot { width: 28px; height: 28px; border-radius: 50%; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text-primary) 12%, transparent); }
.dm-theme[aria-checked="true"] .dm-theme-dot { box-shadow: 0 0 0 2px var(--bg-base), 0 0 0 4px var(--text-primary); }
.dm-theme[data-swatch="default"] .dm-theme-dot { background: var(--brand-500); }
.dm-theme[data-swatch="cyanotype"] .dm-theme-dot { background: var(--brand-100); border: 2px solid var(--brand-500); }
.dm-theme[data-swatch="selenium"] .dm-theme-dot { background: var(--accent-selenium); }
.dm-theme[data-swatch="flash"] .dm-theme-dot { background: color-mix(in srgb, var(--accent-flash) 24%, var(--bg-base)); border: 2px solid var(--accent-flash); }
.dm-theme[data-swatch="mono"] .dm-theme-dot { background: var(--text-primary); }
.dm-d-media { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; }
.dm-d-media > * { position: relative; display: block; aspect-ratio: 1; overflow: hidden; background: var(--bg-raised); border-radius: 0; }
.dm-d-media img { width: 100%; height: 100%; object-fit: cover; }
.dm-d-media .is-video { display: grid; place-items: center; color: var(--text-primary); }
.dm-d-empty { padding: 4px 0 16px; font-size: var(--type-meta-size); color: var(--text-secondary); }
.dm-d-actions { display: grid; padding: 8px 0 24px; border-bottom: 0; }
.dm-d-actions button { min-height: 44px; padding: 0 20px; text-align: left; color: var(--status-danger); font-weight: 600; }
.dm-d-actions button:hover { background: var(--bg-surface); }

/* --- New message dialog -------------------------------------------------------- */

.dm-new { max-height: 92dvh; }
@media (min-width: 768px) { .dm-new.sheet-dialog { width: 548px; height: min(640px, 80vh); max-height: none; } }
.dm-new-to { display: flex; align-items: flex-start; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border-subtle); flex: none; }
.dm-new-label { font-weight: 600; line-height: 28px; flex: none; }
.dm-new-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.dm-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; background: var(--brand-100); color: var(--brand-400); font-size: var(--type-meta-size); font-weight: 600; }
[data-theme="light"] .dm-chip { color: var(--brand-500); }
.dm-new-input { flex: 1; min-width: 120px; height: 28px; border: 0; background: transparent; color: var(--text-primary); font-size: var(--type-body-size); padding: 0; }
.dm-new-input:focus { outline: none; }
.dm-new-input::placeholder { color: var(--text-secondary); }
.dm-new-input::-webkit-search-cancel-button { display: none; }
.dm-new-group { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border-subtle); flex: none; color: var(--text-secondary); }
.dm-new-group .input { min-height: 36px; height: 36px; padding: 6px 10px; }
.dm-new-list { flex: 1; min-height: 160px; overflow-y: auto; overscroll-behavior: contain; padding: 4px 0 8px; }
.dm-new-section { padding: 12px 16px 6px; font-weight: 600; font-size: var(--type-body-size); }
.dm-new-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 16px; text-align: left; }
.dm-new-row:hover { background: color-mix(in srgb, var(--bg-raised) 60%, transparent); }
.dm-new-name { font-size: var(--type-body-size); }
.dm-new-check { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 50%; border: 1.5px solid var(--text-tertiary); color: var(--on-brand); }
.dm-new-check.is-on { background: var(--brand-500); border-color: var(--brand-500); }
.dm-new-foot { padding: 12px 16px 16px; border-top: 1px solid var(--border-subtle); flex: none; }

/* --- Breakpoints ------------------------------------------------------------ */

/* 1024–1263: slightly narrower inbox. */
@media (min-width: 1024px) and (max-width: 1263px) { .page-direct { --dm-inbox-w: 360px; } }

/* 768–1023: the inbox collapses to avatars only. */
@media (min-width: 768px) and (max-width: 1023px) {
  .page-direct { --dm-inbox-w: 108px; }
  .dm-inbox-head { justify-content: center; padding: 32px 0 16px; }
  .dm-inbox-title, .dm-notes, .dm-search, .dm-tabs, .dm-requests-note { display: none; }
  .dm-inbox-head .icon-btn { margin: 0; }
  .dm-row { justify-content: center; padding: 8px 0; }
  .dm-row-text, .dm-row-dot { display: none; }
  .dm-row-avdot { display: block; }
  .dm-inbox .dm-empty { padding: 24px 8px; }
  .dm-inbox .dm-empty p, .dm-inbox .dm-empty .btn { display: none; }
  .dm-empty-desk { display: none; }
  .dm-details { width: min(100%, 340px); }
}

/* <768: inbox and thread are separate pages. */
@media (max-width: 767px) {
  .page-direct { --dm-inbox-w: 100%; }
  .dm-mobile-head { display: flex; }
  .dm-inbox-head { display: none; }
  .dm-inbox { border-right: 0; }
  .dm-inbox-scroll { overflow: visible; }
  .dm.has-thread .dm-inbox { display: none; }
  .dm.no-thread .dm-main { display: none; }
  .dm-row { padding: 8px 16px; }
  .dm-tabs { padding: 0 16px; }
  .dm-notes { padding-inline: 8px; }

  /* Thread page: full height, no tab bar. */
  .page-direct.dm-has-thread .tabbar { display: none; }
  .page-direct.dm-has-thread .main { padding-bottom: 0; height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
  .page-direct.dm-has-thread .dm { height: 100%; }
  .dm-head { height: 56px; padding: 0 12px 0 16px; gap: 10px; }
  .dm-back { display: inline-grid; }
  .dm-head-who .avatar, .dm-head-who .dm-stack { --size: 32px; }
  .dm-head-who .dm-stack { --dm-stack: 32px !important; --dm-stack-small: 23px !important; }
  .dm-head-title { font-size: var(--type-body-strong-size); }
  .dm-log { padding: 12px 12px 8px; }
  .dm-content { max-width: 78%; }
  .dm-compose-wrap { padding: 4px 12px calc(12px + env(safe-area-inset-bottom)); }
  .dm-request { padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); }

  .dm-details { position: fixed; inset: 0; z-index: 60; width: 100%; border-left: 0; box-shadow: none; }
  .dm-details-head { height: var(--topbar-h); }
  .dm-details-back { display: inline-grid !important; }
  .dm-details-close { display: none !important; }
}

/* --- Reduced motion -------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .dm-typing i { animation: none !important; opacity: 0.6; }
  .dm-rec-dot { animation: none !important; }
  .dm-details { animation: fade-in 200ms both !important; }
  .dm-picker button:hover, .dm-focus-reacts button:hover { transform: none; }
  .dm-focus, .dm-info-wrap { animation: none; }
  .dm-msg { transition: none; }
}

/* ==========================================================================
   Batch 3 (items 4, 5, 7, 9): compact composer, one-row recorder, voice note
   alignment + readable meta, drafts, location cards / sheet.
   ========================================================================== */

/* Composer: + · 😊 | text | one round button. 24px icons, one compact row (grows to 5 lines). */
.dm-composer { flex-direction: row; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 8px; border-radius: 24px; }
.dm-compose-tools { display: flex; align-items: center; gap: 8px; flex: none; height: 40px; }
.dm-compose-tools .dm-cbtn { width: 32px; height: 32px; }
.dm-compose-tools .dm-cbtn .icon { width: 24px; height: 24px; }
.dm-composer textarea { flex: 1; min-width: 0; min-height: 40px; padding: 8px 4px; line-height: 24px; }
.dm-composer .dm-go { width: 40px; height: 40px; }
.dm-compose-bar { display: none; }
.dm-attach-menu { bottom: 48px; }
.dm-emoji .emoji-grid { display: none; }

/* Recorder: a single row no taller than the composer, so it can't be cut off. */
.dm-rec { display: flex; align-items: center; gap: 8px; min-height: 54px; padding: 6px 6px 6px 8px; border-radius: 24px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.06); }
.dm-rec-trash { width: 40px; height: 40px; }
.dm-rec-dot { margin-left: 4px; }
.dm-rec-play { width: 32px; height: 32px; background: color-mix(in srgb, var(--text-primary) 8%, transparent); }
.dm-rec-time { font-size: 17px; min-width: 44px; }
.dm-rec-meter { height: 28px; }
.dm-rec-pause { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; font-size: 0; }
.dm-rec-pause > span { display: grid; place-items: center; }
.dm-rec-send { width: 40px; height: 40px; }
@media (max-width: 420px) { .dm-rec-meter i:nth-child(2n) { display: none; } }

/* Voice note: avatar · play · waveform + seek dot on one centre line; duration under the waveform start. */
.dm-voice { padding: 8px 12px 6px 8px; }
.dm-voice-main { grid-template-columns: 44px 36px minmax(0, 1fr); grid-template-rows: 44px auto; row-gap: 0; align-items: center; }
.dm-voice-lead, .dm-voice-play { grid-row: 1; align-self: center; }
.dm-voice-body { display: contents; }
.dm-voice-body .dm-wave { grid-column: 3; grid-row: 1; align-self: center; height: 32px; }
.dm-voice-body .dm-voice-time { grid-column: 3; grid-row: 2; justify-self: start; margin-top: -4px; }
.dm-voice-main .dm-voice-time { font-size: 12px; font-weight: 500; line-height: 16px; opacity: 1; color: color-mix(in srgb, currentColor 75%, transparent); }
.dm-voice > .dm-meta { right: 12px; bottom: 6px; }

/* Time + ticks: 12px medium; on own (brand) bubbles white 75% with solid white ticks, seen = #9FE2FF. */
.dm-meta { font-size: 12px; font-weight: 500; line-height: 16px; }
/* Audit WM-08: follow the bubble's own foreground so light chat themes (Flash, Cyanotype, light Selenium) stay readable. */
.is-own .dm-bubble .dm-meta, .is-own .dm-loc .dm-meta { color: color-mix(in srgb, var(--dm-own-fg, #fff) 75%, transparent); }
.is-own .dm-bubble .dm-meta .dm-ticks, .is-own .dm-loc .dm-meta .dm-ticks { color: var(--dm-own-fg, #fff); opacity: 1; }
.is-own .dm-bubble .dm-meta .dm-ticks.is-seen, .is-own .dm-loc .dm-meta .dm-ticks.is-seen { color: var(--dm-own-seen, #9FE2FF); }
/* QA web 4: responsive.css colours every <time> secondary grey, which made own-bubble times unreadable on
   the brand fill. Times inherit the bubble meta colour (white 75% on own bubbles, 12px medium) everywhere. */
.dm-meta time, .dm-divider time, .dm-loc-sub time { color: inherit; font: inherit; }
.is-own .dm-meta, .is-own .dm-meta.is-under, .is-own .dm-voice .dm-meta, .is-own .dm-loc .dm-meta { font-size: 12px; font-weight: 500; }
.is-own :is(.dm-bubble, .dm-voice, .dm-loc) > .dm-meta:not(.is-overlay):not(.is-under) { color: color-mix(in srgb, var(--dm-own-fg, #fff) 75%, transparent); }
.is-own :is(.dm-bubble, .dm-voice, .dm-loc) > .dm-meta:not(.is-overlay):not(.is-under) .dm-ticks { color: var(--dm-own-fg, #fff); opacity: 1; }
.is-own :is(.dm-bubble, .dm-voice, .dm-loc) > .dm-meta:not(.is-overlay):not(.is-under) .dm-ticks.is-seen { color: var(--dm-own-seen, #9FE2FF); }
.dm-thread[data-chat-theme="selenium"], [data-theme="light"] .dm-thread[data-chat-theme="flash"], [data-theme="light"] .dm-thread[data-chat-theme="cyanotype"] { --dm-own-seen: #0A6FA6; }
.is-own .dm-bubble.is-unsent > .dm-meta, .is-own .dm-bubble.is-jumbo > .dm-meta { color: var(--text-secondary); }
.is-own .dm-bubble.is-unsent .dm-meta, .is-own .dm-bubble.is-jumbo .dm-meta { color: var(--text-secondary); }

/* Voice still processing / failed (never an empty row). */
.dm-voice-wait { display: inline-flex; align-items: center; gap: 8px; padding: 10px 64px 10px 12px; font-size: 15px; }
.dm-voice-wait.is-failed { opacity: 0.8; }

/* Drafts in the inbox. */
.dm-row-preview.is-draft { color: var(--status-danger); font-weight: 500; }

/* Location card. */
.dm-loc { position: relative; display: block; width: 280px; max-width: 100%; overflow: hidden; border-radius: 18px; background: var(--bg-raised); color: var(--text-primary); border: 1px solid var(--border-subtle); }
.is-own .dm-loc { background: var(--dm-own-bg); color: var(--dm-own-fg); border-color: transparent; }
.dm-loc-map { position: relative; display: block; height: 150px; overflow: hidden; background: #E8E4DA; }
.dm-loc-tiles { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.dm-loc-tiles img { position: absolute; width: 256px; height: 256px; max-width: none; }
.dm-loc-pin { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -100%); color: var(--status-danger); filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35)); line-height: 0; }
.dm-loc.is-live .dm-loc-pin { transform: translate(-50%, -50%); padding: 3px; border-radius: 50%; background: #fff; }
.dm-loc-pin.is-pulsing::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--brand-500); animation: dm-pulse 1.6s infinite ease-out; }
.dm-loc.is-ended .dm-loc-map { filter: grayscale(1); opacity: 0.75; }
.dm-loc-attrib { position: absolute; right: 4px; bottom: 2px; font-size: 9px; color: #333; background: rgba(255, 255, 255, 0.7); padding: 0 3px; border-radius: 3px; }
.dm-loc-body { padding: 8px 12px 24px; display: grid; gap: 2px; }
.dm-loc-title { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 700; line-height: 20px; }
.dm-loc-sub { font-size: 13px; line-height: 18px; opacity: 0.85; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.dm-loc-actions { display: flex; gap: 8px; margin-top: 6px; }
.dm-loc-btn { flex: 1; display: grid; place-items: center; height: 32px; padding: 0 8px; border-radius: 10px; font-size: 13px; font-weight: 600; color: inherit; text-decoration: none; background: color-mix(in srgb, currentColor 12%, transparent); white-space: nowrap; }
.dm-loc-btn:hover { background: color-mix(in srgb, currentColor 18%, transparent); }
.dm-loc-btn.is-danger { color: #fff; background: var(--status-danger); }
.dm-loc > .dm-meta { position: absolute; right: 10px; bottom: 5px; }

/* Location sheet. */
.dm-loc-dialog { width: min(520px, 100%); max-height: calc(100dvh - 48px); display: flex; flex-direction: column; }
.dm-loc-preview { position: relative; flex: none; height: 200px; overflow: hidden; background: #E8E4DA; }
.dm-loc-preview .dm-loc-tiles { left: 0; top: 0; transform: none; width: 100%; height: 100%; }
.dm-loc-preview .dm-loc-tiles img { position: absolute; width: 256px; height: 256px; max-width: none; }
.dm-loc-status { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center; color: #333; font-size: 15px; }
.dm-loc-list { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; }
.dm-loc-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 8px; border-radius: 12px; text-align: left; color: var(--text-primary); }
.dm-loc-row:hover:not(:disabled) { background: var(--bg-raised); }
.dm-loc-row:disabled { opacity: 0.5; }
.dm-loc-row .grow { display: grid; min-width: 0; }
.dm-loc-row strong { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-loc-row small { font-size: 13px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-loc-ico { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%; background: var(--bg-raised); color: var(--text-primary); }
.dm-loc-ico.is-brand { background: var(--brand-500); color: var(--on-brand); }
.dm-loc-ico.is-live { background: #12B76A; color: #fff; }
.dm-loc-durations { display: flex; gap: 8px; padding: 4px 8px 8px 60px; }
.dm-loc-durations .btn { flex: 1; }
.dm-loc-head { padding: 12px 8px 4px; font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.dm-loc-empty { padding: 8px; font-size: 14px; color: var(--text-secondary); }
@media (prefers-reduced-motion: reduce) { .dm-loc-pin.is-pulsing::after { animation: none; } }
