@font-face {
  font-family: 'VazirmatnWeb';
  src: url('/fonts/Vazirmatn-Regular.ttf') format('truetype');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  unicode-range:
    U+0600-06FF,
    U+0750-077F,
    U+08A0-08FF,
    U+FB50-FDFF,
    U+FE70-FEFF;
}

/* ================================================================
   Chats — app.css
================================================================ */

/* ── Variables ─────────────────────────────────────────────────── */
:root {
  color-scheme: dark;
  --bg:          #0e1621;
  --bg2:         #17212b;
  --bg3:         #233140;
  --card:        #18232d;
  --sidebar-bg:  #17212b;
  --accent:      #67b2f8;
  --accent2:     #4f9de6;
  --accent-dim:  rgba(103,178,248,.16);
  --accent-line: rgba(103,178,248,.30);
  --accent-strong: rgba(103,178,248,.22);
  --accent-bright: #b8ddff;
  --accent-contrast: #ffffff;
  --bubble-sent: #2b5278;
  --bubble-recv: #182533;
  --text:        #edf3f8;
  --text2:       #8ea4b7;
  --text3:       #657b90;
  --border:      rgba(255,255,255,.08);
  --border2:     rgba(255,255,255,.12);
  --danger:      #ff6b6b;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bot:    env(safe-area-inset-bottom, 0px);
  --nav-h:       72px;
  --hdr-h:       60px;
  --sidebar-w:   320px;
  --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --app-pattern-url: url('/background/pattern-22.svg');
  --app-pattern-opacity: .15;
  --chat-surface-grad-start: #17293d;
  --chat-surface-grad-mid: #112032;
  --chat-surface-grad-end: #0d1723;
  --chat-surface-glow: rgba(103,178,248,.16);
  --bubble-reply-sent-bg: rgba(0,0,0,.14);
  --bubble-reply-sent-line: var(--accent);
  --bubble-reply-sent-accent: var(--accent);
  --bubble-reply-sent-text: rgba(237,243,248,.74);
  --bubble-reply-recv-bg: color-mix(in srgb, var(--bg3) 88%, transparent);
  --bubble-reply-recv-line: var(--accent);
  --bubble-reply-recv-accent: var(--accent);
  --bubble-reply-recv-text: var(--text2);
  --file-box-sent-bg: var(--accent-dim);
  --file-box-sent-fg: var(--accent);
  --file-box-recv-bg: color-mix(in srgb, var(--bg3) 84%, transparent);
  --file-box-recv-fg: var(--accent-bright);
  --reaction-pill-bg: color-mix(in srgb, var(--accent-dim) 72%, var(--bg2) 28%);
  --reaction-pill-border: color-mix(in srgb, var(--accent) 22%, transparent);
  --reaction-pill-fg: var(--accent-bright);
  --reaction-pill-avatar-ring: rgba(14,22,33,.92);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg:          #e9edf2;
  --bg2:         #ffffff;
  --bg3:         #f4f7fb;
  --card:        #ffffff;
  --sidebar-bg:  #ffffff;
  --accent:      #3390ec;
  --accent2:     #2b7cd3;
  --accent-dim:  rgba(51,144,236,.12);
  --accent-line: rgba(51,144,236,.24);
  --accent-strong: rgba(51,144,236,.18);
  --accent-bright: #5ba9f6;
  --accent-contrast: #ffffff;
  --bubble-sent: #effdde;
  --bubble-recv: #ffffff;
  --text:        #182533;
  --text2:       #708499;
  --text3:       #99a9b7;
  --border:      rgba(24,37,51,.08);
  --border2:     rgba(24,37,51,.14);
  --danger:      #d55a5a;
  --app-pattern-opacity: .05;
  --chat-surface-grad-start: #fefefe;
  --chat-surface-grad-mid: #eff5fb;
  --chat-surface-grad-end: #e7eff8;
  --chat-surface-glow: rgba(51,144,236,.12);
  --bubble-reply-sent-bg: #def5ce;
  --bubble-reply-sent-line: #6cbf62;
  --bubble-reply-sent-accent: #6cbf62;
  --bubble-reply-sent-text: #6cbf62;
  --bubble-reply-recv-bg: #e4f2f9;
  --bubble-reply-recv-line: #82bfd8;
  --bubble-reply-recv-accent: #3390ec;
  --bubble-reply-recv-text: #4e7389;
  --file-box-sent-bg: #def5ce;
  --file-box-sent-fg: #6cbf62;
  --file-box-recv-bg: #e4f2f9;
  --file-box-recv-fg: #3390ec;
  --reaction-pill-bg: #e6f2fd;
  --reaction-pill-border: rgba(51,144,236,.14);
  --reaction-pill-fg: #2f7fd0;
  --reaction-pill-avatar-ring: rgba(230,242,253,.96);
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box; margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
}
html {
  height: 100%;
  overscroll-behavior: none;
  background: var(--bg);
  transition: background .2s ease;
}
body {
  font-family: 'VazirmatnWeb', var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  transition: background .2s ease, color .2s ease;
}
input, textarea, button { font-family: inherit; }
input.is-rtl, textarea.is-rtl {
  direction: rtl;
  text-align: right;
}
input.is-ltr, textarea.is-ltr {
  direction: ltr;
  text-align: left;
}
a { color: inherit; }
button:disabled {
  cursor: not-allowed;
  opacity: .65;
}
:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}
.hidden { display: none !important; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

/* ════════════════════════════════════════════════════════════════
   SHARED ATOMS
════════════════════════════════════════════════════════════════ */

/* Avatars */
.ava {
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0; color: #fff; position: relative;
}
.ava.group { border-radius: 14px; }
.ava.has-photo {
  background: var(--bg3);
  color: transparent;
  overflow: visible;
}
.ava img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
}
.ava.c-teal   { background: #4ea4d9; }
.ava.c-blue   { background: #5f8cff; }
.ava.c-purple { background: #8774e1; }
.ava.c-pink   { background: #de6aa6; }
.ava.c-orange { background: #e69a4a; }
.ava.c-red    { background: #d86a6a; }
.ava.c-green  { background: #68b56d; }
.ava.saved {
  background: #e6f2fd;
  color: var(--accent);
}
.ava.saved svg {
  width: 54%;
  height: 54%;
}
.ava-previewable {
  cursor: pointer;
}
.ava-online {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--ava-ring-color, var(--sidebar-bg));
}

/* Icon button */
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: transparent; border: none;
  color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg3); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.accent-btn { background: var(--accent); color: var(--accent-contrast); }
.icon-btn.accent-btn:hover { background: var(--accent2); }
.icon-btn.selection-active {
  background: var(--accent-dim);
  color: var(--accent);
}

/* Badge */
.badge {
  min-width: 20px; height: 20px; border-radius: 10px;
  background: var(--accent); color: var(--accent-contrast);
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

/* Search bar */
.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 0 12px; height: 40px;
  transition: border-color .2s;
}
.search-bar:focus-within { border-color: var(--accent); }
.search-bar input {
  flex: 1; background: none; border: none; outline: none;
  font-size: 13px; color: var(--text);
  min-width: 0;
}
.search-bar input::placeholder { color: var(--text3); }
.search-bar svg { width: 15px; height: 15px; color: var(--text3); flex-shrink: 0; }

/* Chat items (shared between sidebar and mobile list) */
.chat-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px;
  cursor: pointer; transition: background .15s;
  --ava-ring-color: var(--sidebar-bg);
  touch-action: manipulation;
  -webkit-touch-callout: none;
}
.chat-item:hover,
.chat-item.active {
  background: var(--bg3);
  --ava-ring-color: var(--bg3);
}
.chat-item.select-mode {
  padding-right: 14px;
}
.chat-item.selected {
  background: var(--accent-dim);
  border-color: var(--accent-line);
  --ava-ring-color: var(--accent-dim);
}
.chat-item-body { flex: 1; min-width: 0; }
.chat-item-name { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.chat-item-preview {
  font-size: 12px; color: var(--text2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-item-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.chat-item-time { font-size: 11px; color: var(--text3); display: flex; align-items: center; gap: 3px; }
.chat-item-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  flex-shrink: 0;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.chat-item-check.selected {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-contrast);
}

/* Messages */
.msgs-area {
  flex: 1 1 auto; overflow-y: auto;
  min-height: 0;
  padding: 16px 16px 12px;
  display: flex; flex-direction: column; gap: 10px;
  position: relative;
  isolation: isolate;
  background: transparent;
  overflow-anchor: none;
}
.msgs-area > * {
  transition: opacity .18s ease, transform .18s ease;
}
#m-screen-chat,
#d-chat-view {
  position: relative;
  min-height: 0;
  overflow: hidden;
  --msgs-overlay-top: 0px;
  --msgs-overlay-right: 0px;
  --msgs-overlay-bottom: 0px;
  --msgs-overlay-left: 0px;
}
#m-screen-chat > *:not(.chat-surface-pattern):not(.chat-drop-overlay),
#d-chat-view > *:not(.chat-surface-pattern):not(.chat-drop-overlay) {
  position: relative;
  z-index: 1;
}
.chat-surface-pattern,
.chat-drop-overlay {
  position: absolute;
  top: var(--msgs-overlay-top);
  right: var(--msgs-overlay-right);
  bottom: var(--msgs-overlay-bottom);
  left: var(--msgs-overlay-left);
  pointer-events: none;
}
.chat-surface-pattern {
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 14% 0%, var(--chat-surface-glow) 0, transparent 34%),
    radial-gradient(circle at 100% 10%, color-mix(in srgb, var(--accent) 8%, transparent) 0, transparent 28%),
    linear-gradient(180deg, var(--chat-surface-grad-start) 0%, var(--chat-surface-grad-mid) 48%, var(--chat-surface-grad-end) 100%);
  transform: translateZ(0);
}
.chat-surface-pattern::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--app-pattern-url);
  background-repeat: repeat-x;
  background-position: top center;
  background-size: auto calc(100% + 96px);
  opacity: var(--app-pattern-opacity);
  pointer-events: none;
}
.chat-drop-overlay {
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .18s ease;
}
.chat-drop-overlay-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  max-width: calc(100% - 32px);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 74%, var(--accent-dim) 26%);
  border: 1px solid color-mix(in srgb, var(--accent) 36%, var(--border) 64%);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
  box-shadow: 0 16px 36px rgba(0,0,0,.18);
  transform: scale(.96);
  transition: transform .18s ease, box-shadow .18s ease;
}
#m-screen-chat.is-drop-target .chat-surface-pattern,
#d-chat-view.is-drop-target .chat-surface-pattern {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 48%, transparent);
}
#m-screen-chat.is-drop-target .chat-drop-overlay,
#d-chat-view.is-drop-target .chat-drop-overlay {
  opacity: 1;
}
#m-screen-chat.is-drop-target .chat-drop-overlay-pill,
#d-chat-view.is-drop-target .chat-drop-overlay-pill {
  transform: scale(1);
}
#m-screen-chat.is-drop-target .msgs-area > *,
#d-chat-view.is-drop-target .msgs-area > *,
#m-screen-chat.is-drop-target .chat-input-bar,
#d-chat-view.is-drop-target .d-input-area {
  opacity: .28;
}
.scroll-bottom-btn {
  position: absolute !important;
  right: 18px;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg2) 88%, transparent);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 14px 32px rgba(0,0,0,.18);
  backdrop-filter: blur(14px);
  cursor: pointer;
  z-index: 6;
  transition: transform .18s ease, background .18s ease, opacity .18s ease;
}
.scroll-bottom-btn:hover {
  transform: translateY(-1px);
  background: color-mix(in srgb, var(--bg3) 76%, transparent);
}
.scroll-bottom-btn svg {
  width: 18px;
  height: 18px;
}
.scroll-bottom-btn.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}
.day-chip-row {
  display: flex;
  justify-content: center;
  padding: 0;
  margin: 8px 0;
  pointer-events: none;
}
.day-chip {
  background: color-mix(in srgb, var(--bg2) 82%, transparent); border: 1px solid var(--border);
  border-radius: 99px; padding: 4px 14px;
  font-size: 11px; font-weight: 500; color: var(--text2);
  width: fit-content;
  backdrop-filter: blur(12px);
  box-shadow: none;
}
:root[data-theme="light"] .day-chip {
  background: color-mix(in srgb, var(--bg2) 88%, transparent);
  border-color: var(--border2);
  color: var(--text2);
  box-shadow: none;
}
.msg-row { display: flex; align-items: flex-end; gap: 6px; }
.msg-row.sent  { justify-content: flex-end; }
.msg-row.recv  { justify-content: flex-start; }
.msg-row.selection-mode {
  margin: 0 -8px 3px;
  padding: 4px 8px;
  border-radius: 18px;
  transition: background .16s ease;
}
.msg-row.selection-mode.selectable {
  cursor: pointer;
}
.msg-row.selection-mode.selectable:hover {
  background: var(--accent-dim);
}
.msg-row.selection-mode.selected {
  background: transparent;
}
.msg-row.selection-mode .bubble a,
.msg-row.selection-mode .bubble button,
.msg-row.selection-mode .bubble video,
.msg-row.selection-mode .bubble .audio-wave-shell,
.msg-row.selection-mode .bubble .audio-play-btn {
  pointer-events: none;
}
.msg-row.msg-highlight { animation: msg-highlight 1.8s ease; }
.msg-row.msg-highlight .bubble { box-shadow: 0 0 0 1px var(--accent-line); }
.msg-stack {
  display: flex;
  flex-direction: column;
  max-width: min(420px, 100%);
}
.msg-stack.has-corner-reactions {
  padding-bottom: 14px;
}
.msg-bubble-wrap {
  position: relative;
  z-index: 0;
}
.msg-bubble-wrap.selection-mode.selectable {
  cursor: pointer;
  padding-right: 32px;
}
.msg-bubble-wrap.selection-mode.selectable .bubble > * {
  pointer-events: none;
}
.msg-bubble-wrap.selection-mode.selectable .bubble {
  box-shadow: inset 0 0 0 1px var(--border2);
  transition: box-shadow .16s ease, transform .16s ease;
}
.msg-bubble-wrap.selection-mode.selectable:hover .bubble {
  transform: translateY(-1px);
}
.msg-bubble-wrap.selection-mode.selected .bubble {
  box-shadow: inset 0 0 0 1px var(--accent-line);
  background: var(--bubble-sent);
}
.msg-bubble-wrap.recv.selection-mode.selected .bubble {
  background: var(--bubble-recv);
}
.msg-ava {
  width: 26px; height: 26px; border-radius: 50%;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: #fff;
}
.msg-select-indicator {
  position: absolute;
  top: 50%;
  right: 0;
  width: 22px;
  height: 22px;
  border: 1px solid var(--border2);
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg2) 88%, transparent);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px rgba(0,0,0,.16);
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transform: translateY(-50%) scale(.82);
  transition: background .16s ease, color .16s ease, border-color .16s ease, transform .16s ease, opacity .16s ease;
}
.msg-bubble-wrap.selection-mode.selectable .msg-select-indicator {
  opacity: .8;
}
.msg-select-indicator.selected {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: transparent;
  opacity: 1;
  transform: translateY(-50%) scale(1);
}
.msg-select-indicator svg {
  width: 13px;
  height: 13px;
}
.bubble {
  max-width: min(420px, 100%);
  padding: 9px 13px 7px;
  border-radius: 18px;
  word-break: break-word; line-height: 1.45;
  position: relative;
  z-index: 1;
}
.bubble.sent {
  background: var(--bubble-sent);
  border-bottom-right-radius: 4px; color: var(--text);
}
.bubble.recv {
  background: var(--bubble-recv);
  border-bottom-left-radius: 4px; color: var(--text);
}
.bubble-text {
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bubble-text.is-rtl {
  direction: rtl;
  text-align: right;
}
.bubble-text.is-ltr {
  direction: ltr;
  text-align: left;
}
.bubble-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.bubble-link:hover {
  text-decoration: underline;
}
.bubble-mention {
  display: inline;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  color: color-mix(in srgb, var(--accent) 84%, #6bc8ff 16%);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.bubble-mention:hover {
  text-decoration: underline;
}
.bubble-reply {
  margin-bottom: 8px;
  padding: 4px 6px;
  border-radius: 3px;
  border-inline-start: 2px solid var(--bubble-reply-sent-line)!important;
  background: var(--bubble-reply-sent-bg);
}
.bubble-reply-link {
  width: 100%;
  border: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.bubble-reply-link:hover {
  transform: translateY(-1px);
}
.bubble-reply-static {
  cursor: default;
}
.bubble.recv .bubble-reply {
  background: var(--bubble-reply-recv-bg);
  border-inline-start-color: var(--bubble-reply-recv-line)!important;
}
.bubble-reply-sender {
  font-size: 11px;
  font-weight: 700;
  color: var(--bubble-reply-sent-accent);
  margin-bottom: 0px;
}
.bubble-reply-text {
  font-size: 12px;
  color: var(--bubble-reply-sent-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bubble.recv .bubble-reply-sender {
  color: var(--bubble-reply-recv-accent);
}
.bubble.recv .bubble-reply-text {
  color: var(--bubble-reply-recv-text);
}
.bubble-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  margin-top: 0px;
}
.bubble-foot-meta {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-inline-start: auto;
  min-width: fit-content;
}
.bubble-edited {
  font-size: 10px;
  color: rgba(255,255,255,.38);
}
.bubble-forwarded {
  font-size: 10px;
  color: rgba(255,255,255,.38);
}
.msg-reactions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  margin-top: 0;
  padding: 0;
  min-width: 0;
}
.msg-reaction-list {
  display: flex;
  align-items: center;
  justify-content: inherit;
  flex-wrap: nowrap;
  gap: 6px;
}
.msg-reaction,
.msg-reaction-add {
  min-height: 28px;
  border-radius: 999px;
  border: 1px solid var(--reaction-pill-border);
  background: var(--reaction-pill-bg);
  color: var(--reaction-pill-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 4px 8px 4px 10px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.msg-reaction:hover,
.msg-reaction-add:hover {
  background: color-mix(in srgb, var(--reaction-pill-bg) 88%, #ffffff 12%);
  color: var(--reaction-pill-fg);
}
.msg-reaction.active {
  background: color-mix(in srgb, var(--reaction-pill-bg) 82%, #ffffff 18%);
  border-color: color-mix(in srgb, var(--reaction-pill-border) 62%, transparent);
  color: var(--reaction-pill-fg);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 14%, transparent);
}
.msg-reaction-emoji {
  font-size: 14px;
  line-height: 1;
}
.msg-reaction-users {
  display: inline-flex;
  align-items: center;
  margin-inline-start: 1px;
}
.msg-reaction-user {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  overflow: hidden;
  border: 1.5px solid var(--reaction-pill-avatar-ring);
  margin-inline-start: -4px;
  background: var(--bg2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--reaction-pill-fg);
  font-size: 7px;
  font-weight: 700;
}
.msg-reaction-user:first-child {
  margin-inline-start: 0;
}
.msg-reaction-user img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.msg-reaction-count {
  font-size: 10px;
  font-weight: 700;
  color: inherit;
}
.bubble-time { font-size: 10px; color: rgba(255,255,255,.38); }
.tick { width: 15px; height: 15px; color: rgba(255,255,255,.38); }
.tick.read { color: var(--accent); }
:root[data-theme="light"] .bubble-time,
:root[data-theme="light"] .tick,
:root[data-theme="light"] .bubble-edited { color: rgba(23,38,58,.45); }
.bubble-image {
  display: block;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg3);
}
.bubble-image img {
  display: block;
  width: 100%;
  max-width: min(320px, 100%);
  max-height: 320px;
  object-fit: cover;
}
.bubble-image-button {
  display: block;
  padding: 0;
  border: none;
  background: transparent;
  cursor: zoom-in;
}
.bubble-image-button:hover .bubble-image img {
  transform: scale(1.015);
}
.bubble-image img {
  transition: transform .18s ease;
}
.bubble-video,
.bubble-audio {
  display: block;
  width: 100%;
}
.bubble-video {
  max-width: min(360px, 100%);
  max-height: 320px;
  border-radius: 12px;
  background: #000;
}
.bubble-audio {
  min-width: min(280px, 100%);
  height: 40px;
}
.bubble-audio-player {
  min-width: min(292px, 100%);
  display: flex;
  align-items: center;
  gap: 12px;
}
.audio-play-btn {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .15s ease, background .15s ease;
}
.audio-play-btn:hover {
  transform: scale(1.03);
}
.audio-play-btn svg {
  width: 17px;
  height: 17px;
}
.bubble.recv .audio-play-btn {
  background: var(--accent-dim);
  color: var(--accent);
}
.bubble-audio-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.audio-wave-shell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 30px;
  gap: 3px;
  cursor: pointer;
  overflow: hidden;
}
.audio-wave-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
  overflow: hidden;
  pointer-events: none;
}
.audio-wave-layer.fill {
  width: 0;
}
.audio-wave-bar {
  flex: 0 0 4px;
  width: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,.22);
  transition: background .14s ease, opacity .14s ease;
}
.audio-wave-bar.is-active {
  background: var(--accent);
}
.bubble.recv .audio-wave-bar {
  background: rgba(23,38,58,.15);
}
.bubble.recv .audio-wave-bar.is-active {
  background: var(--accent);
}
.audio-time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  color: rgba(255,255,255,.58);
}
.bubble.recv .audio-time-row {
  color: var(--text2);
}
.audio-meta-line {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bubble.recv .audio-meta-line {
  color: var(--text);
}
.audio-play-btn.is-loading {
  opacity: .7;
}
.audio-play-btn.is-loading svg {
  animation: spin 1s linear infinite;
}
.bubble-media-meta {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-top: 8px;
}
.bubble-media-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bubble-media-download {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}
.bubble-file {
  display: flex; align-items: center; gap: 10px; padding: 2px 0;
}
.bubble-file-link {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  text-decoration: none;
  color: inherit;
  border-radius: 12px;
  transition: background .15s ease;
  text-align: left;
  cursor: pointer;
}
.bubble-file-link:hover { background: color-mix(in srgb, var(--accent-dim) 28%, transparent); }
.file-icon-box {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--file-box-sent-bg);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: var(--file-box-sent-fg);
}
.bubble.recv .file-icon-box {
  background: var(--file-box-recv-bg);
  color: var(--file-box-recv-fg);
}
.file-icon-box svg { width: 17px; height: 17px; }
.file-meta { flex: 1; min-width: 0; }
.file-name { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 11px; color: var(--text2); }

/* Typing */
.typing-row {
  display: flex;
  justify-content: flex-start;
  padding: 2px 0 0;
}
.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--bubble-recv) 94%, transparent);
  color: var(--text2);
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
}
.typing-copy {
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
}
.typing-dots { display: flex; gap: 4px; align-items: center; }
.tdot { width: 6px; height: 6px; border-radius: 50%; background: var(--text3); animation: tdot .9s infinite; }
.tdot:nth-child(2) { animation-delay: .18s; }
.tdot:nth-child(3) { animation-delay: .36s; }
@keyframes tdot { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-4px)} }
@keyframes msg-highlight {
  0% { transform: scale(1); }
  20% { transform: scale(1.01); }
  35% { background: var(--accent-strong); }
  100% { transform: scale(1); background: transparent; }
}
@keyframes message-menu-slide {
  0% { opacity: 0; transform: translateY(-8px) scale(.98); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Loading / Empty */
.loading-state { flex: 1; display: flex; align-items: center; justify-content: center; }
.spin {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--border2); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-chats {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; color: var(--text2); padding: 32px; text-align: center;
}
.empty-chats svg { width: 48px; height: 48px; color: var(--text3); }
.empty-chats strong { font-size: 15px; color: var(--text); }
.empty-chats p { font-size: 13px; line-height: 1.6; color: var(--text3); }
.empty-action {
  min-width: 144px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.empty-action:hover {
  background: var(--accent-strong);
  border-color: var(--accent-line);
  color: var(--accent-bright);
}
.settings-ghost-btn {
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.settings-ghost-btn:hover {
  background: var(--bg3);
  color: var(--text);
}
.group-manage-photo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0 2px;
}
.group-manage-photo .d-action-btn {
  width: auto;
  min-width: 90px;
  margin-bottom: 0;
  padding: 0 14px;
}
.group-manage-search {
  margin-bottom: 10px;
}
.group-manage-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.group-manage-empty {
  padding: 6px 2px 2px;
  color: var(--text3);
  font-size: 12px;
  line-height: 1.5;
}
.group-manage-user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg2);
}
.group-member-action {
  height: 30px;
  padding: 0 12px;
  border: none;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.group-member-action:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}
.group-member-action.danger {
  background: rgba(229,92,92,.14);
  color: var(--danger);
}
.group-member-action.danger:hover {
  background: rgba(229,92,92,.2);
}
.theme-toggle {
  height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.theme-toggle:hover {
  background: var(--bg3);
  color: var(--text);
}
.theme-toggle svg {
  width: 15px;
  height: 15px;
}
.chat-search-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.chat-search-strip .search-bar {
  flex: 1;
}
.conn-banner { display: none !important; }
.conn-banner::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.conn-banner.connected {
  color: var(--accent);
  background: var(--accent-dim);
}
.conn-banner.connecting,
.conn-banner.reconnecting {
  color: #d3a341;
  background: rgba(211,163,65,.12);
}
.conn-banner.offline {
  color: var(--danger);
  background: rgba(229,92,92,.12);
}
.emoji-popover {
  position: absolute;
  right: 14px;
  bottom: 70px;
  width: min(320px, calc(100vw - 32px));
  padding: 10px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--bg2);
  display: flex;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 6px;
  box-shadow: 0 18px 40px rgba(0,0,0,.18);
  z-index: 5;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}
.emoji-popover.mobile {
  right: 12px;
  bottom: calc(100% + 8px);
  width: min(330px, calc(100vw - 24px));
}
.emoji-popover button {
  flex: 0 0 auto;
  width: 38px;
  height: 32px;
  border: none;
  border-radius: 10px;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
}
.emoji-popover button:hover { background: var(--bg3); }
.emoji-popover::-webkit-scrollbar {
  height: 4px;
}
.emoji-popover::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 999px;
}
.upload-queue {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 12px 10px;
}
.upload-item {
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg2);
  box-shadow: 0 12px 28px rgba(0,0,0,.08);
}
.upload-item.done {
  border-color: var(--accent-line);
}
.upload-item.failed {
  border-color: rgba(229,92,92,.25);
}
.upload-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.upload-name {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.upload-state {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
}
.upload-item.done .upload-state {
  color: var(--accent);
}
.upload-item.failed .upload-state {
  color: var(--danger);
}
.upload-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg3);
  overflow: hidden;
}
.upload-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width .18s ease;
}
.upload-item.failed .upload-bar {
  background: linear-gradient(90deg, #e55c5c, #ff9b9b);
}
.upload-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text2);
}
.message-menu {
  position: fixed;
  min-width: 178px;
  max-width: min(284px, calc(100vw - 24px));
  padding: 5px;
  border-radius: 14px;
  border: none;
  background: var(--bubble-recv);
  box-shadow: 0 18px 42px rgba(0,0,0,.18);
  backdrop-filter: blur(14px);
  z-index: 140;
  animation: message-menu-slide .18s cubic-bezier(.22,.9,.24,1) both;
}
.chat-menu {
  position: fixed;
  min-width: 188px;
  max-width: min(260px, calc(100vw - 24px));
  padding: 4px;
  border-radius: 14px;
  border: none;
  background: var(--card);
  box-shadow: 0 18px 42px rgba(0,0,0,.18);
  backdrop-filter: blur(14px);
  z-index: 142;
  animation: message-menu-slide .18s cubic-bezier(.22,.9,.24,1) both;
}
.chat-menu-btn {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}
.chat-menu-btn:hover {
  background: color-mix(in srgb, var(--card) 82%, var(--bg3) 18%);
}
.chat-menu-btn.delete {
  color: #ff6b6b;
}
.chat-menu-btn svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}
.message-menu.sent {
  background: var(--bubble-sent);
  min-width: 178px;
  padding: 4px;
  border-radius: 13px;
  transform-origin: top right;
  box-shadow: 0 14px 30px rgba(0,0,0,.14);
}
.message-menu.recv {
  background: var(--bubble-recv);
  transform-origin: top center;
}
.message-menu-reactions {
  display: flex;
  margin: -1px -1px 5px;
  padding: 4px 4px 6px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
}
.message-menu-reactions-scroll {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  padding: 2px 1px 2px 0;
  width: 100%;
}
.message-menu-reactions-scroll::-webkit-scrollbar {
  height: 4px;
}
.message-menu-reactions-scroll::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 999px;
}
.message-menu-reaction-btn {
  min-width: 34px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 11px;
  background: color-mix(in srgb, var(--bg2) 94%, transparent);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  scroll-snap-align: start;
  transition: background .16s ease, color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.message-menu-reaction-btn:hover {
  background: var(--bg3);
  transform: translateY(-1px);
}
.message-menu-reaction-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}
.message-menu-btn {
  width: 100%;
  min-height: 32px;
  padding: 0 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 400;
  cursor: pointer;
  text-align: left;
  transition: background .16s ease, color .16s ease;
}
.message-menu.sent .message-menu-btn:hover {
  background: color-mix(in srgb, var(--bubble-sent) 88%, white 12%);
}
.message-menu.recv .message-menu-btn:hover {
  background: color-mix(in srgb, var(--bubble-recv) 82%, var(--bg3) 18%);
}
:root[data-theme="light"] .message-menu.sent {
  background: #ffffff;
  box-shadow: 0 18px 42px rgba(23,38,58,.12);
}
:root[data-theme="light"] .message-menu.sent .message-menu-btn {
  color: var(--text);
}
:root[data-theme="light"] .message-menu.sent .message-menu-btn:hover {
  background: #f1f1f1;
  transform: none;
}
:root[data-theme="light"] .chat-menu {
  background: #ffffff;
  box-shadow: 0 18px 42px rgba(23,38,58,.12);
}
:root[data-theme="light"] .chat-menu-btn:hover {
  background: #f1f1f1;
}
.reaction-popover {
  position: fixed;
  z-index: 130;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg2) 96%, transparent);
  box-shadow: 0 18px 40px rgba(0,0,0,.18);
  backdrop-filter: blur(12px);
}
.reaction-popover button {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 12px;
  background: transparent;
  font-size: 19px;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.reaction-popover button:hover {
  background: var(--bg3);
  transform: translateY(-1px);
}
.message-menu-btn.delete {
  color: var(--danger);
}
.message-menu-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.message-selection-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg2) 92%, transparent);
  backdrop-filter: blur(14px);
}
.message-selection-meta {
  flex: 1;
  min-width: 0;
}
.message-selection-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.message-selection-hint {
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.message-selection-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border: none;
  border-radius: 12px;
  background: var(--bg3);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.message-selection-btn svg {
  width: 15px;
  height: 15px;
}
.message-selection-btn.danger {
  background: rgba(229,92,92,.12);
  color: var(--danger);
}
.message-selection-btn:disabled {
  opacity: .45;
}
.composer-reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: none;
}
.composer-reply-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.composer-reply-icon svg {
  width: 16px;
  height: 16px;
}
.composer-reply-meta {
  flex: 1;
  min-width: 0;
}
.composer-reply-kicker {
  font-size: 11px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 3px;
}
.composer-reply-text {
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.composer-reply-close {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: var(--bg3);
  color: var(--text2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.composer-reply-close svg {
  width: 14px;
  height: 14px;
}
.voice-recorder {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: color-mix(in srgb, var(--bg2) 92%, var(--bg3) 8%);
  direction: ltr;
}
.voice-recorder.is-paused {
  border-color: color-mix(in srgb, var(--danger) 28%, var(--border) 72%);
}
.voice-recorder-status {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.voice-recording-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--danger) 18%, transparent);
  animation: voice-record-pulse 1.15s ease-in-out infinite;
  flex-shrink: 0;
}
.voice-recorder.is-paused .voice-recording-dot {
  animation: none;
  box-shadow: none;
  background: var(--text3);
}
.voice-timer {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
  white-space: nowrap;
}
.voice-btn,
.voice-preview-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .16s ease, color .16s ease, transform .16s ease, box-shadow .16s ease;
  padding: 0;
}
.voice-btn:active,
.voice-preview-btn:active {
  transform: scale(.96);
}
.voice-btn svg,
.voice-preview-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.voice-cancel-btn {
  background: transparent;
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 22%, var(--border) 78%);
}
.voice-cancel-btn:hover {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}
.voice-preview-btn {
  background: color-mix(in srgb, var(--bg3) 88%, transparent);
  color: var(--text2);
}
.voice-preview-btn:hover {
  background: var(--bg3);
  color: var(--text);
}
.voice-preview-btn.is-playing {
  background: var(--accent);
  color: var(--accent-contrast);
}
.voice-pause-btn {
  background: var(--accent-dim);
  color: var(--accent);
}
.voice-pause-btn:hover {
  background: color-mix(in srgb, var(--accent-dim) 70%, var(--bg3) 30%);
}
.voice-pause-btn.is-paused {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 18%, transparent);
}

@keyframes voice-record-pulse {
  0%, 100% { transform: scale(.84); opacity: .72; }
  50% { transform: scale(1); opacity: 1; }
}
.forward-modal-caption {
  font-size: 12px;
  color: var(--text2);
  text-align: center;
  margin-top: -2px;
}
.forward-result-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 46vh;
  overflow-y: auto;
}
.forward-chat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.forward-chat-row:hover {
  background: var(--bg3);
  border-color: var(--border2);
  transform: translateY(-1px);
}
.forward-chat-meta {
  flex: 1;
  min-width: 0;
}
.forward-chat-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.forward-chat-preview {
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.forward-chat-arrow {
  color: var(--text3);
  flex-shrink: 0;
}
.forward-chat-arrow svg {
  width: 16px;
  height: 16px;
}
.forward-empty {
  padding: 20px 6px;
  text-align: center;
  font-size: 13px;
  color: var(--text3);
}
.media-preview-modal {
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 150;
}
.media-lightbox {
  position: relative;
  width: min(920px, 100%);
  max-height: min(90vh, 860px);
  padding: 18px;
  border-radius: 26px;
  background: color-mix(in srgb, var(--bg2) 92%, transparent);
  border: 1px solid var(--border2);
  box-shadow: 0 26px 90px rgba(0,0,0,.35);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.media-lightbox-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: color-mix(in srgb, var(--bg3) 84%, transparent);
  color: var(--text);
  z-index: 2;
}
.media-lightbox-stage {
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 18px;
}
.media-lightbox-stage img {
  max-width: 100%;
  max-height: calc(90vh - 72px);
  object-fit: contain;
  display: block;
}
.avatar-preview-btn {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  display: inline-flex;
  cursor: pointer;
}
.media-lightbox-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.media-lightbox-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.audio-dock {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(calc(100vw - 28px), 640px);
  padding: 12px 14px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg2) 92%, transparent);
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 46px rgba(0,0,0,.18);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 120;
}
.audio-dock-btn,
.audio-dock-close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.audio-dock-close {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
}
.audio-dock-btn svg,
.audio-dock-close svg {
  width: 17px;
  height: 17px;
}
.audio-dock-btn.is-loading svg {
  animation: spin 1s linear infinite;
}
.audio-dock-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.audio-dock-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.audio-dock-wave {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 30px;
  gap: 3px;
  cursor: pointer;
  overflow: hidden;
}
.audio-dock-wave .audio-wave-bar {
  background: color-mix(in srgb, var(--text3) 30%, transparent);
}
.audio-dock-wave .audio-wave-bar.is-active {
  background: var(--accent);
}
.audio-dock-times {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  color: var(--text2);
}
.attach-btn.selection-active {
  color: var(--accent);
}

/* Toast */
#toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 99px; padding: 9px 20px;
  font-size: 13px; color: var(--text);
  max-width: min(calc(100vw - 32px), 360px);
  white-space: normal; text-align: center; z-index: 999;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Modal overlay */
.modal-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgb(0 0 0 / 90%);
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(3px);
}
.modal-sheet {
  width: 100%; max-width: 480px;
  background: var(--bg2);
  border-radius: 22px 22px 0 0;
  padding: 12px 16px calc(20px + var(--safe-bot));
  display: flex; flex-direction: column; gap: 12px;
  max-height: 80vh; overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.sheet-handle { width: 36px; height: 4px; background: var(--border2); border-radius: 99px; margin: 0 auto 4px; }
.sheet-title { font-size: 16px; font-weight: 700; text-align: center; }
.compose-mode-switch {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.compose-mode-btn {
  flex: 1;
  height: 38px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.compose-mode-btn.active {
  background: var(--accent);
  color: var(--accent-contrast);
}
.selected-users {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.selected-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--accent-dim);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}
.selected-user-chip button {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
}
.selected-user-chip button:hover {
  background: var(--bg3);
  color: var(--text);
}
.user-result {
  display: flex; align-items: center; gap: 12px;
  padding: 10px; border-radius: 12px;
  cursor: pointer; transition: background .15s;
}
.user-result:hover { background: var(--bg3); }
.user-result.active {
  background: var(--accent-dim);
  border: 1px solid var(--accent-line);
}
.user-result .name  { font-size: 14px; font-weight: 600; }
.user-result .uname { font-size: 12px; color: var(--text2); }
.user-result-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}
.sheet-actions {
  display: flex;
}
.sheet-actions .btn-login {
  margin-top: 0;
}
.modal-sheet-compact {
  max-width: 420px;
  border-radius: 18px;
  padding: 18px;
}
.confirm-sheet {
  max-width: 380px;
}
.confirm-copy {
  margin-top: 8px;
  color: var(--text2);
  font-size: 13px;
  line-height: 1.7;
}
.modal-inline-actions {
  display: flex;
  gap: 10px;
}
.confirm-actions {
  margin-top: 18px;
  justify-content: flex-end;
}
.modal-inline-actions .settings-ghost-btn,
.modal-inline-actions .btn-login {
  flex: 1;
  margin-top: 0;
}
.confirm-submit {
  min-width: 110px;
}
.confirm-submit.danger {
  background: #ff6b6b;
  color: #fff;
}
.confirm-submit.danger:hover {
  background: #ff5b5b;
}
.inp-textarea {
  min-height: 120px;
  height: auto;
  padding: 12px 14px;
  resize: vertical;
}

/* ════════════════════════════════════════════════════════════════
   LOGIN SCREEN (shared mobile + desktop)
════════════════════════════════════════════════════════════════ */
#screen-login {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  position: relative;
  padding: 32px 28px; gap: 32px;
  background:
    radial-gradient(circle at 14% 0%, color-mix(in srgb, var(--accent) 14%, transparent) 0, transparent 28%),
    radial-gradient(circle at 100% 8%, color-mix(in srgb, var(--accent) 10%, transparent) 0, transparent 24%),
    linear-gradient(180deg, color-mix(in srgb, var(--sidebar-bg) 88%, var(--bg) 12%) 0%, var(--bg) 100%);
  overflow-y: auto;
}
.login-logo,
.login-form {
  position: relative;
  z-index: 1;
}
.login-logo { display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 320px; text-align: center; }
.login-icon-wrap {
  width: 78px; height: 78px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 22%, transparent), color-mix(in srgb, var(--accent) 8%, transparent));
  border-radius: 24px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 18px 44px rgba(0,0,0,.14);
}
.login-icon-wrap svg { width: 34px; height: 34px; color: var(--accent); }
.login-title { font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.login-sub   { font-size: 13px; color: var(--text2); line-height: 1.5; }
.login-form  {
  width: 100%;
  max-width: 390px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  border-radius: 28px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg2) 92%, transparent);
  backdrop-filter: blur(18px);
  box-shadow: 0 22px 60px rgba(0,0,0,.16);
}
.login-form-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.form-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
.form-copy {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text2);
}
.inp-wrap    { display: flex; flex-direction: column; gap: 6px; }
.inp-label   { font-size: 11px; font-weight: 600; color: var(--text2); letter-spacing: .4px; text-transform: uppercase; }
.inp-control-wrap {
  position: relative;
}
.inp {
  width: 100%; height: 48px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text);
  font-size: 15px; padding: 0 16px; outline: none; transition: border-color .2s;
}
.inp-with-action {
  padding-right: 50px;
}
.inp:focus { border-color: var(--accent); }
.inp::placeholder { color: var(--text3); }
.inp-action-btn {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color .16s ease, background .16s ease;
}
.inp-action-btn:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--bg3) 72%, transparent);
}
.inp-action-btn svg {
  width: 18px;
  height: 18px;
}
.btn-login {
  width: 100%; height: 50px;
  background: linear-gradient(180deg, var(--accent), var(--accent2)); border: none; border-radius: 16px;
  color: var(--accent-contrast); font-size: 15px; font-weight: 700;
  cursor: pointer; margin-top: 4px;
  transition: background .15s, transform .1s, box-shadow .15s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 16px 30px color-mix(in srgb, var(--accent) 26%, transparent);
}
.btn-login:hover  { background: var(--accent2); }
.btn-login:active { transform: scale(.98); }
.login-err { display: none; }
.auth-switch {
  height: 44px;
  border: 1px solid var(--accent-line);
  background: color-mix(in srgb, var(--accent-dim) 84%, transparent);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 16px;
  text-align: center;
  border-radius: 16px;
  transition: background .16s ease, color .16s ease, border-color .16s ease, transform .16s ease;
}
.auth-switch:hover {
  color: var(--accent-bright);
  background: color-mix(in srgb, var(--accent-dim) 94%, transparent);
  border-color: var(--accent-line);
  transform: translateY(-1px);
}

/* ════════════════════════════════════════════════════════════════
   MOBILE LAYOUT  (< 768px)
════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  .inp,
  .inp-textarea,
  .msg-inp,
  .search-bar input {
    font-size: 16px;
  }

  #desktop-layout { display: none !important; }

  #mobile-layout {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    position: relative;
    overflow: hidden;
    min-height: 0;
  }

  .screen {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    background: var(--sidebar-bg);
    transition: transform .28s cubic-bezier(.4,0,.2,1), opacity .28s ease;
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }
  .screen.hidden      { display: none; }
  .screen.slide-right { transform: translateX(100%); }

  /* Top bar */
  .top-bar {
    height: var(--hdr-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 14px; flex-shrink: 0;
    padding-top: var(--safe-top); position: relative;
  }
  .top-bar-title {
    font-size: 18px; font-weight: 700;
    position: absolute; left: 50%; transform: translateX(-50%);
  }

  /* Mobile icon btn override */
  .icon-btn {
    width: 38px; height: 38px;
    background: var(--bg2); color: var(--text);
  }
  .icon-btn:active { background: var(--bg3); }

  /* Chat list screen */
  #m-screen-chats { padding-bottom: calc(var(--nav-h) + var(--safe-bot)); }
  #m-screen-chats .search-bar { margin: 4px 12px 10px; height: 44px; border-radius: 14px; }
  #m-screen-chats .search-bar input { font-size: 16px; }
  .mob-chat-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0 10px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .mob-chat-list .chat-item {
    background: var(--card);
    border-radius: 16px;
    padding: 12px 10px;
    --ava-ring-color: var(--card);
  }
  .mob-chat-list .chat-item:active { background: var(--bg3); }
  .mob-chat-list .ava { width: 48px; height: 48px; font-size: 17px; }
  .audio-dock {
    bottom: calc(var(--nav-h) + var(--safe-bot) + 10px);
    width: calc(100vw - 22px);
    padding: 10px 12px;
  }
  .media-preview-modal {
    padding: 10px;
  }
  .media-lightbox {
    padding: 14px;
    border-radius: 22px;
  }
  .media-lightbox-meta {
    flex-direction: column;
    align-items: stretch;
  }

  /* Bottom nav */
  .bottom-nav {
    position: absolute; bottom: 0; left: 0; right: 0;
    height: calc(var(--nav-h) + var(--safe-bot));
    padding-bottom: var(--safe-bot);
    display: flex; align-items: flex-start; justify-content: center;
    padding-top: 8px; background: transparent;
  }
  .nav-pill {
    display: flex; align-items: center;
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 99px; padding: 5px; gap: 4px;
    width: calc(100% - 32px); max-width: 340px;
  }
  .nav-item {
    flex: 1; height: 50px; border-radius: 99px;
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 3px; cursor: pointer;
    transition: background .2s, color .2s;
    color: var(--text2); font-size: 12px; font-weight: 600;
    border: none; background: transparent;
  }
  .nav-item svg { width: 21px; height: 21px; }
  .nav-item.active { background: var(--accent); color: var(--accent-contrast); }

  /* Chat view screen */
  .chat-top-bar {
    height: var(--hdr-h);
    display: flex; align-items: center;
    padding: 0 12px; gap: 10px; flex-shrink: 0;
    padding-top: var(--safe-top);
    background-color: var(--bg2);
    border-bottom: 1px solid var(--border);
  }
  #m-screen-chat {
    min-height: 0;
    overflow: hidden;
  }
  .chat-top-info { flex: 1; text-align: center; }
  .chat-top-name { font-size: 16px; font-weight: 700; }
  .chat-top-status {
    font-size: 12px; color: var(--text2);
    display: flex; align-items: center; justify-content: center; gap: 4px;
  }
  .status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text3); }
  .status-dot.online { background: var(--accent); }

  /* Mobile input bar */
  .chat-input-bar {
    display: flex; align-items: flex-end; gap: 0px;
    position: relative;
    padding: 8px 12px calc(8px + var(--safe-bot));
    border-top: 1px solid var(--border);
    background-color: var(--bg2);
    flex-shrink: 0;
    margin-top: auto;
  }
  #m-scroll-bottom-btn {
    bottom: calc(70px + var(--safe-bot));
  }
  #m-reply-bar {
    margin: 0 12px 10px;
    flex-shrink: 0;
  }
  #m-upload-queue {
    padding: 0 12px 10px;
    flex-shrink: 0;
  }
  #m-msgs-area {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .attach-btn {
    width: 32px; height: 32px; background: none; border: none;
    color: var(--text2); cursor: pointer;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  }
  .attach-btn svg { width: 22px; height: 22px; }
  .msg-inp {
    flex: 1;
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 22px; color: var(--text); font-size: 14px;
    padding: 10px 16px; outline: none; transition: border-color .2s;
    min-height: 42px;
    max-height: 132px;
    line-height: 1.45;
    resize: none;
    overflow-y: auto;
  }
  .msg-inp:focus { border-color: var(--accent); }
  .msg-inp::placeholder { color: var(--text3); }
  .m-composer-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-inline-start: 6px;
    flex-shrink: 0;
  }
  .send-btn {
    width: 0; height: 32px; border-radius: 50%;
    background: var(--accent); border: none; color: var(--accent-contrast);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background .15s, opacity .18s ease, transform .18s ease, width .18s ease, margin .18s ease;
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px) scale(.82);
    overflow: hidden;
    padding: 0;
  }
  .send-btn.is-ready { width: 32px; opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }
  .send-btn:active { background: var(--accent2); }
  .send-btn svg { width: 22px; height: 22px; transform: none; fill: currentColor; flex-shrink: 0; }
  .m-emoji-btn {
    background: var(--accent-contrast);
    color: var(--accent);
  }
  .m-emoji-btn svg {
    transform: none;
    fill: none;
  }
  .chat-input-bar.recording-mode {
    align-items: center;
    gap: 8px;
  }

  /* Settings screen */
  #m-screen-settings {
    padding-bottom: 0;
    overflow: hidden;
    min-height: 0;
  }
  .settings-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 16px calc(16px + var(--safe-bot));
    display: flex;
    flex-direction: column;
    gap: 16px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .settings-body > * {
    flex-shrink: 0;
  }
  #m-screen-settings .bottom-nav {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    height: auto;
    padding: 8px 0 calc(12px + var(--safe-bot));
    margin-top: auto;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border);
    z-index: 2;
  }
  #m-screen-settings .nav-pill {
    margin: 0 auto;
  }
  .settings-profile {
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    padding: 24px 16px;
    background: var(--card); border-radius: 20px; border: 1px solid var(--border);
    flex-shrink: 0;
  }
  .ava-lg { width: 72px; height: 72px; font-size: 24px; font-weight: 700; }
  .settings-name   { font-size: 18px; font-weight: 700; }
  .settings-handle { font-size: 14px; color: var(--text2); }
  .settings-photo-btn { min-width: 0; }
  .settings-section { background: var(--card); border-radius: 18px; border: 1px solid var(--border); overflow: hidden; flex-shrink: 0; }
  .settings-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 15px 16px; border-bottom: 1px solid var(--border);
    cursor: pointer; transition: background .15s;
  }
  .settings-row:last-child { border-bottom: none; }
  .settings-row:active { background: var(--bg3); }
  .settings-row-label { font-size: 15px; }
  .settings-row-val   { font-size: 13px; color: var(--text2); }
  .settings-row svg   { width: 17px; height: 17px; color: var(--text3); }
  .settings-form {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .settings-inline-actions {
    display: flex;
    gap: 10px;
  }
  .settings-inline-actions .empty-action,
  .settings-inline-actions .settings-ghost-btn {
    flex: 1;
  }
  .settings-ghost-btn {
    height: 40px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg2);
    color: var(--text2);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
  }

  /* Toast on mobile sits above nav */
  #toast { bottom: calc(var(--nav-h) + 12px); }
}

/* ════════════════════════════════════════════════════════════════
   DESKTOP LAYOUT  (≥ 768px)
════════════════════════════════════════════════════════════════ */
@media (min-width: 768px) {
  #mobile-layout  { display: none !important; }
  #screen-login   { max-width: 100%; }

  #desktop-layout {
    height: 100%;
    display: flex;
  }

  /* ── Sidebar ── */
  #d-sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    height: 100%;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
  }
  .d-sidebar-header {
    height: var(--hdr-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 14px; flex-shrink: 0;
    border-bottom: 1px solid var(--border);
  }
  .d-brand {
    display: flex; align-items: center; gap: 10px; cursor: default;
  }
  .d-brand-icon {
    width: 30px; height: 30px; border-radius: 9px;
    background: var(--accent-dim);
    display: flex; align-items: center; justify-content: center;
  }
  .d-brand-icon svg { width: 15px; height: 15px; color: var(--accent); }
  .d-brand-name { font-size: 15px; font-weight: 700; }
  .d-sidebar-actions { display: flex; gap: 2px; }

  .d-search-wrap { padding: 10px 10px 8px; flex-shrink: 0; }

  .d-tabs {
    display: flex; padding: 0 10px 8px; gap: 4px; flex-shrink: 0;
  }
  .d-tab {
    flex: 1; height: 28px; border-radius: 8px; border: none;
    background: transparent; color: var(--text3);
    font-size: 12px; font-weight: 600; cursor: pointer; transition: all .15s;
    letter-spacing: .3px;
  }
  .d-tab:hover { background: var(--bg3); color: var(--text2); }
  .d-tab.active { background: var(--bg3); color: var(--accent); }

  .d-chat-list { flex: 1; overflow-y: auto; padding: 0; }
  .d-section-label {
    font-size: 10px; font-weight: 700; letter-spacing: .8px;
    color: var(--text3); text-transform: uppercase;
    padding: 8px 6px 4px;
  }
  .d-chat-list .ava { width: 45px; height: 45px; font-size: 18px; }
  .d-chat-list .chat-item { padding: 8px 12px; }

  .d-sidebar-footer {
    border-top: 1px solid var(--border); padding: 10px; flex-shrink: 0;
  }
  .audio-dock {
    left: 10px;
    bottom: 86px;
    transform: none;
    width: calc(var(--sidebar-w) - 20px);
    padding: 8px 10px;
    border-radius: 16px;
    gap: 8px;
    background: color-mix(in srgb, var(--sidebar-bg) 94%, transparent);
    box-shadow: 0 14px 28px rgba(0,0,0,.16);
  }
  .audio-dock-btn,
  .audio-dock-close {
    width: 30px;
    height: 30px;
  }
  .audio-dock-btn svg,
  .audio-dock-close svg {
    width: 13px;
    height: 13px;
  }
  .audio-dock-main {
    gap: 4px;
  }
  .audio-dock-name {
    font-size: 11px;
    font-weight: 600;
  }
  .audio-dock-wave {
    height: 16px;
  }
  .audio-dock-times {
    font-size: 10px;
    gap: 8px;
  }
  .d-user-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px; border-radius: 10px; cursor: pointer; transition: background .15s;
    --ava-ring-color: var(--sidebar-bg);
  }
  .d-user-row:hover {
    background: var(--bg3);
    --ava-ring-color: var(--bg3);
  }
  .d-user-info { flex: 1; min-width: 0; }
  .d-user-name   { font-size: 13px; font-weight: 600; }
  .d-user-handle { font-size: 11px; color: var(--text3); }

  /* ── Main pane ── */
  #d-main {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column;
    height: 100%;
  }

  /* Empty state */
  #d-empty {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 14px; color: var(--text2);
    padding: 32px;
  }
  #d-empty svg { width: 56px; height: 56px; color: var(--text3); }
  #d-empty h3 { font-size: 18px; font-weight: 600; color: var(--text2); }
  #d-empty p  { font-size: 13px; color: var(--text3); }
  #d-empty .empty-action { margin-top: 4px; }

  /* Chat header */
  .d-chat-header {
    height: var(--hdr-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px; flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    background-color: var(--bg2);
  }
  .d-chat-header-left { display: flex; align-items: center; gap: 12px; }
  .d-chat-header-name   { font-size: 15px; font-weight: 700; }
  .d-chat-header-status { font-size: 12px; color: var(--text3); display: flex; align-items: center; gap: 0; }
  .d-chat-header-status .status-dot { display: none; }
  .status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text3); display: inline-block; }
  .status-dot.online { background: var(--accent); }
  .d-chat-header-actions { display: flex; gap: 2px; }

  /* Desktop input */
  .d-input-area {
    padding: 6px 14px 6px;
    border-top: 1px solid var(--border); flex-shrink: 0;
    position: relative;
    background-color: var(--bg2);
  }
  #d-scroll-bottom-btn {
    bottom: 88px;
  }
  #d-upload-queue {
    padding: 0 0 10px;
  }
  .d-input-wrap {
    display: flex; align-items: center; gap: 8px;
    background: transparent; border: none;
    border-radius: 0; padding: 0;
    transition: border-color .2s;
  }
  .d-input-wrap textarea {
    flex: 1; background: none; border: none; outline: none;
    resize: none; font-size: 14px; color: var(--text);
    max-height: 132px; min-height: 22px; overflow-y: auto;
  }
  .d-input-wrap textarea::placeholder { color: var(--text3); }
  .d-input-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
  .d-input-wrap svg { width: 22px; height: 22px; }
  .d-input-wrap.recording-mode {
    align-items: center;
  }
  .d-input-wrap .voice-recorder {
    min-height: 44px;
    background: color-mix(in srgb, var(--bg3) 92%, transparent);
  }
  .d-input-actions .voice-btn,
  .d-input-actions .voice-preview-btn {
    width: 34px;
    height: 34px;
  }
  .d-send-btn {
    width: 0; height: 34px; border-radius: 50%;
    background: var(--accent-contrast); border: none; color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: opacity .18s ease, transform .18s ease, width .18s ease, color .15s ease, background .15s ease;
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px) scale(.82);
    overflow: hidden;
    padding: 0;
  }
  .d-send-btn.is-ready { width: 34px; opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }
  .d-send-btn:hover { color: var(--accent2); background: var(--accent-contrast); }
  .d-send-btn svg { width: 22px; height: 22px; transform: none; fill: currentColor; flex-shrink: 0; }

  /* Desktop modal — centered */
  .modal-overlay { align-items: center; }
  .modal-sheet {
    max-width: 440px; border-radius: 18px;
    padding: 20px; max-height: 70vh;
  }
  .sheet-title { margin-bottom: 4px; }

  /* Settings in desktop — right panel */
  #d-settings-panel {
    width: 280px; flex-shrink: 0;
    border-left: 1px solid var(--border);
    background: var(--sidebar-bg);
    height: 100%; overflow-y: auto;
    display: flex; flex-direction: column;
    opacity: 0;
    transform: translateX(20px) scale(.985);
    transition: opacity .24s ease, transform .28s cubic-bezier(.22,.9,.24,1);
    will-change: opacity, transform;
  }
  #d-settings-panel.is-open {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  .d-panel-header {
    height: var(--hdr-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
  }
  .d-panel-title { font-size: 14px; font-weight: 700; }
  .d-panel-body  { padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; }
  .d-panel-profile {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    padding-bottom: 16px; border-bottom: 1px solid var(--border);
  }
  .d-panel-name   { font-size: 16px; font-weight: 700; }
  .d-panel-handle { font-size: 12px; color: var(--text2); }
  .d-panel-presence {
    font-size: 12px;
    color: var(--text2);
  }
  .d-panel-presence.is-online {
    color: var(--accent);
  }
  .saved-panel-profile .d-panel-handle {
    text-align: center;
    max-width: 220px;
    line-height: 1.55;
  }
  .saved-panel-copy {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .d-section-title {
    font-size: 10px; font-weight: 700; letter-spacing: .8px;
    color: var(--text3); text-transform: uppercase; margin-bottom: 6px;
  }
  .d-member-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
  .d-member-row .ava { width: 32px; height: 32px; font-size: 11px; }
  .d-member-name   { font-size: 13px; font-weight: 500; }
  .d-member-handle { font-size: 11px; color: var(--text3); }
  .d-admin-badge {
    font-size: 10px; font-weight: 700; color: var(--accent);
    background: var(--accent-dim); padding: 2px 7px; border-radius: 99px; letter-spacing: .3px;
  }
  .d-admin-badge.owner {
    background: var(--accent-dim);
    color: var(--accent-bright);
  }
  .d-action-btn {
    width: 100%; height: 36px; border-radius: 10px;
    background: var(--bg3); border: 1px solid var(--border);
    color: var(--text2); font-size: 13px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: all .15s; margin-bottom: 6px;
  }
  .d-action-btn:hover { background: var(--bg2); color: var(--text); }
  .d-action-btn.danger { color: var(--danger); border-color: rgba(229,92,92,.2); }
  .d-action-btn.danger:hover { background: rgba(229,92,92,.1); }
  .d-action-btn svg { width: 15px; height: 15px; }
  .d-inline-actions {
    display: flex;
    gap: 8px;
  }
  .d-inline-actions .d-action-btn {
    flex: 1;
    margin-bottom: 0;
  }
  .d-pref-actions {
    display: flex;
    gap: 8px;
  }
  .d-pref-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg2);
    color: var(--text2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .16s ease, color .16s ease, border-color .16s ease;
  }
  .d-pref-icon-btn:hover {
    background: var(--bg3);
    color: var(--text);
  }
  .d-pref-icon-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
  }
  .d-pref-icon-btn svg {
    width: 18px;
    height: 18px;
  }
  .d-pref-signout {
    margin-top: 10px;
  }
}
.starred-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}
.starred-item:hover { background: var(--bg2); }
.starred-item-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.starred-item-sender {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  flex: 1;
}
.starred-item-time {
  font-size: 11px;
  color: var(--text3);
}
.starred-item-text {
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}