:root {
  /* Light palette */
  --bg: #f6f5f1;
  --panel: #ffffff;
  --panel-2: #faf9f6;
  --ink: #15171a;
  --ink-2: #3a3d44;
  --muted: #7b7f88;
  --muted-2: #a9adb5;
  --line: #ebe9e3;
  --line-2: #f1efe9;
  --hover: #f0ede5;
  --active: #e9e5da;

  /* Brand: warm amber + deep ink */
  --brand: #e07a3c;
  --brand-ink: #c5591a;
  --brand-soft: #fdece0;
  --accent: #3b7a63;
  --accent-soft: #e2efe9;
  --danger: #c7453a;
  --warn: #d69e2e;
  --info: #3a6ea5;

  /* Message bubbles */
  --bubble-in: #ffffff;
  --bubble-in-ink: #15171a;
  --bubble-out: #15171a;
  --bubble-out-ink: #f6f5f1;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 2px rgba(20, 22, 26, 0.04), 0 1px 1px rgba(20, 22, 26, 0.03);
  --shadow: 0 4px 12px rgba(20, 22, 26, 0.06), 0 1px 2px rgba(20, 22, 26, 0.04);
  --shadow-lg: 0 16px 40px rgba(20, 22, 26, 0.12), 0 2px 6px rgba(20, 22, 26, 0.06);

  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

.dark {
  --bg: #0e0f12;
  --panel: #16181c;
  --panel-2: #121418;
  --ink: #ecedef;
  --ink-2: #c6c8cd;
  --muted: #8a8e97;
  --muted-2: #5e626b;
  --line: #23262c;
  --line-2: #1b1e23;
  --hover: #1d2026;
  --active: #23272e;

  --brand: #f28a4c;
  --brand-ink: #ffa66b;
  --brand-soft: #3a2416;
  --accent: #6bb395;
  --accent-soft: #1e2b26;
  --danger: #e56a5f;

  --bubble-in: #1c1f24;
  --bubble-in-ink: #ecedef;
  --bubble-out: #e07a3c;
  --bubble-out-ink: #1a1208;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.45;
}

#root {
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

input,
textarea {
  font-family: inherit;
  color: inherit;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted-2);
  background-clip: padding-box;
  border: 3px solid transparent;
}

/* ============== App shell ============== */
.app {
  display: grid;
  grid-template-columns: 72px 340px 1fr 340px;
  height: 100%;
  background: var(--bg);
}
.app.no-info {
  grid-template-columns: 72px 340px 1fr;
}

/* ============== Rail (leftmost nav) ============== */
.rail {
  background: var(--panel-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  gap: 4px;
}
.rail .logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.5px;
  margin-bottom: 14px;
}
.rail .logo .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  margin-left: 2px;
}
.rail-item {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  position: relative;
  transition: all 0.15s ease;
}
.rail-item:hover {
  background: var(--hover);
  color: var(--ink);
}
.rail-item.active {
  background: var(--ink);
  color: var(--bg);
}
.rail-item .badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--panel-2);
}
.rail .spacer {
  flex: 1;
}
.rail .me {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}
.rail .me:hover {
  border-color: var(--brand);
}
.rail .me img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.rail .me .dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #3b9a5e;
  border: 2px solid var(--panel-2);
}

/* ============== Sidebar (chat list) ============== */
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.sidebar-header {
  padding: 16px 18px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
}
.sidebar-actions {
  display: flex;
  gap: 2px;
}
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all 0.15s ease;
}
.icon-btn:hover {
  background: var(--hover);
  color: var(--ink);
}
.icon-btn.primary {
  background: var(--ink);
  color: var(--bg);
}
.icon-btn.primary:hover {
  background: var(--ink-2);
  color: var(--bg);
}

.search {
  position: relative;
}
.search input {
  width: 100%;
  height: 38px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 0 12px 0 36px;
  font-size: 13px;
  outline: none;
  transition: all 0.15s ease;
}
.search input:focus {
  border-color: var(--ink-2);
  background: var(--panel);
}
.search input::placeholder {
  color: var(--muted);
}
.search .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}
.search kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 2px 5px;
  border-radius: 4px;
}

.tabs {
  display: flex;
  padding: 0 14px;
  gap: 2px;
  border-bottom: 1px solid var(--line);
}
.tab {
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
}
.tab:hover {
  color: var(--ink);
}
.tab.active {
  color: var(--ink);
  border-bottom-color: var(--brand);
}
.tab .count {
  font-size: 11px;
  background: var(--line);
  color: var(--ink-2);
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}
.tab.active .count {
  background: var(--brand-soft);
  color: var(--brand-ink);
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
}
.chat-item {
  padding: 10px 10px;
  border-radius: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}
.chat-item:hover {
  background: var(--hover);
}
.chat-item.active {
  background: var(--active);
}
.chat-item.pinned::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 50%;
  width: 3px;
  height: 18px;
  background: var(--brand);
  border-radius: 3px;
  transform: translateY(-50%);
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  background: var(--line);
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar.group {
  background: var(--brand-soft);
  color: var(--brand-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
}
.avatar.group.a { background: #e9ddfc; color: #6d3ec2; }
.avatar.group.b { background: #dbeff2; color: #2a7a8c; }
.avatar.group.c { background: #fde5d8; color: #c5591a; }
.avatar.group.d { background: #e4f0da; color: #4a7a2a; }
.avatar.group.e { background: #fce1e3; color: #b83344; }
.avatar .presence {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--panel);
}
.presence.online { background: #3b9a5e; }
.presence.away { background: #e0b04a; }
.presence.offline { background: #a9adb5; }
.avatar.sm { width: 32px; height: 32px; }
.avatar.sm .presence { width: 9px; height: 9px; border-width: 1.5px; }
.avatar.lg { width: 84px; height: 84px; }
.avatar.xl { width: 110px; height: 110px; }

.chat-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chat-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}
.chat-name .verified {
  color: var(--brand);
}
.chat-time {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.chat-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chat-preview {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-preview .you {
  color: var(--ink-2);
  font-weight: 500;
}
.chat-preview .sender {
  color: var(--ink-2);
  font-weight: 500;
}
.chat-preview .status-icon {
  color: var(--info);
  flex-shrink: 0;
}
.chat-preview .typing {
  color: var(--brand);
  font-weight: 500;
  font-style: italic;
}
.chat-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.unread-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--brand);
  color: white;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.unread-badge.muted {
  background: var(--muted-2);
}
.mute-icon {
  color: var(--muted-2);
}

/* ============== Conversation ============== */
.conversation {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
  position: relative;
}
.convo-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel);
  min-height: 64px;
}
.convo-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 10px;
  margin: -4px -6px;
  transition: background 0.15s;
}
.convo-header-left:hover {
  background: var(--hover);
}
.convo-header-info {
  min-width: 0;
}
.convo-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.convo-subtitle {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.convo-subtitle .live-dot {
  width: 6px;
  height: 6px;
  background: #3b9a5e;
  border-radius: 50%;
  display: inline-block;
}
.convo-subtitle.typing {
  color: var(--brand);
  font-style: italic;
}
.convo-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.messages-inner {
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 18px 0 10px;
  position: relative;
}
.date-divider span {
  background: var(--bg);
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border: 1px solid var(--line);
  border-radius: 20px;
}

.system-msg {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.msg-group {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  align-items: flex-end;
}
.msg-group.out {
  flex-direction: row-reverse;
}
.msg-group .avatar-slot {
  width: 32px;
  flex-shrink: 0;
}
.msg-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 70%;
  min-width: 0;
}
.msg-group.out .msg-stack {
  align-items: flex-end;
}
.msg-sender {
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-ink);
  padding: 0 12px 2px;
}
.msg-sender.color-b { color: #2a7a8c; }
.msg-sender.color-c { color: #6d3ec2; }
.msg-sender.color-d { color: #4a7a2a; }
.msg-sender.color-e { color: #b83344; }

.bubble {
  background: var(--bubble-in);
  color: var(--bubble-in-ink);
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  box-shadow: var(--shadow-sm);
  max-width: 100%;
  word-wrap: break-word;
  position: relative;
  border: 1px solid var(--line-2);
}
.msg-group.out .bubble {
  background: var(--bubble-out);
  color: var(--bubble-out-ink);
  border-color: transparent;
}
.bubble.first {
  border-top-left-radius: 16px;
}
.msg-group.out .bubble.first {
  border-top-right-radius: 16px;
}
.bubble.last {
  border-bottom-left-radius: 4px;
}
.msg-group.out .bubble.last {
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 4px;
}
.bubble.single {
  border-bottom-left-radius: 4px;
}
.msg-group.out .bubble.single {
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 4px;
}

.bubble-wrap {
  position: relative;
}
.bubble-wrap:hover .msg-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.msg-actions {
  position: absolute;
  top: -14px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 1px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: all 0.15s ease;
  z-index: 5;
}
.msg-group.out .msg-actions {
  right: auto;
  left: 8px;
}
.msg-actions .icon-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
}
.msg-actions .icon-btn:hover {
  background: var(--hover);
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
  padding: 0 6px;
  font-variant-numeric: tabular-nums;
}
.msg-group.out .msg-meta {
  color: var(--muted);
}
.msg-meta .edited {
  font-style: italic;
}
.msg-meta .status.read {
  color: var(--info);
}

.reply-quote {
  border-left: 3px solid var(--brand);
  background: rgba(224, 122, 60, 0.08);
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 12px;
}
.msg-group.out .reply-quote {
  background: rgba(246, 245, 241, 0.12);
  border-left-color: var(--brand-soft);
}
.reply-quote .reply-to {
  font-size: 11px;
  font-weight: 600;
  color: var(--brand-ink);
  margin-bottom: 2px;
}
.msg-group.out .reply-quote .reply-to {
  color: var(--brand-soft);
}
.reply-quote .reply-text {
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-group.out .reply-quote .reply-text {
  color: var(--bubble-out-ink);
  opacity: 0.8;
}

.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  padding: 0 6px;
}
.reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 2px 8px 2px 6px;
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.15s ease;
  font-variant-numeric: tabular-nums;
}
.reaction:hover {
  border-color: var(--ink-2);
}
.reaction.mine {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-ink);
  font-weight: 600;
}

/* Media in bubbles */
.bubble.has-media {
  padding: 4px;
}
.bubble.has-media .caption {
  padding: 6px 9px 4px;
  font-size: 14px;
}
.media-grid {
  display: grid;
  gap: 2px;
  border-radius: 12px;
  overflow: hidden;
  max-width: 340px;
}
.media-grid.cols-1 { grid-template-columns: 1fr; }
.media-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.media-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.media-item {
  aspect-ratio: 1 / 1;
  background-size: cover;
  background-position: center;
  position: relative;
  cursor: pointer;
  overflow: hidden;
}
.media-item.wide {
  aspect-ratio: 16 / 10;
  grid-column: span 2;
}
.media-item .play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.15);
}
.media-item .play-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.media-item .duration {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 11px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}
.media-item .more-count {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 600;
}

/* File attachment */
.file-attach {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-width: 240px;
  max-width: 320px;
}
.msg-group.out .file-attach {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}
.file-attach .file-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.5px;
}
.file-attach .file-icon.pdf { background: #fdeceb; color: #c7453a; }
.file-attach .file-icon.doc { background: #e7f0fa; color: #3a6ea5; }
.file-attach .file-icon.zip { background: #f2ebdb; color: #8a6a1e; }
.file-attach .file-icon.fig { background: #fce0e0; color: #c7453a; }
.file-attach .file-info { min-width: 0; flex: 1; }
.file-attach .file-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-attach .file-meta {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.msg-group.out .file-attach .file-meta {
  color: rgba(246, 245, 241, 0.7);
}
.file-attach .dl-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--ink-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.file-attach .dl-btn:hover {
  background: var(--brand);
  color: white;
}

/* Voice message */
.voice-msg {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 2px;
  min-width: 220px;
}
.voice-msg .play {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.msg-group.out .voice-msg .play {
  background: white;
  color: var(--ink);
}
.voice-waveform {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 28px;
}
.voice-waveform .bar {
  flex: 1;
  background: var(--muted-2);
  border-radius: 2px;
  min-height: 4px;
}
.voice-waveform .bar.played {
  background: var(--brand);
}
.msg-group.out .voice-waveform .bar {
  background: rgba(246, 245, 241, 0.4);
}
.msg-group.out .voice-waveform .bar.played {
  background: var(--bg);
}
.voice-time {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.msg-group.out .voice-time {
  color: rgba(246, 245, 241, 0.7);
}

/* Typing indicator */
.typing-bubble {
  display: inline-flex;
  gap: 3px;
  padding: 12px 14px;
  background: var(--bubble-in);
  border: 1px solid var(--line-2);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}
.typing-bubble .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-bounce 1.2s infinite;
}
.typing-bubble .dot:nth-child(2) { animation-delay: 0.15s; }
.typing-bubble .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Composer */
.composer-wrap {
  padding: 10px 20px 14px;
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.composer-wrap .inner {
  max-width: 780px;
  margin: 0 auto;
}
.reply-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  font-size: 12px;
}
.reply-banner .bar {
  width: 3px;
  align-self: stretch;
  background: var(--brand);
  border-radius: 3px;
}
.reply-banner .rinfo { flex: 1; min-width: 0; }
.reply-banner .rname {
  font-weight: 600;
  color: var(--brand-ink);
  font-size: 11px;
}
.reply-banner .rtext {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 6px 6px 6px 10px;
  transition: border-color 0.15s;
}
.composer:focus-within {
  border-color: var(--ink-2);
}
.composer.has-reply {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}
.composer textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  padding: 9px 6px;
  font-size: 14px;
  line-height: 1.4;
  max-height: 160px;
  background: transparent;
  min-height: 20px;
}
.composer textarea::placeholder {
  color: var(--muted);
}
.composer .send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.composer .send-btn:hover {
  background: var(--brand);
}
.composer .send-btn.mic {
  background: var(--panel-2);
  color: var(--ink);
}
.composer .send-btn.mic:hover {
  background: var(--brand);
  color: white;
}
.composer-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-bottom: 4px;
}

/* Attachment preview strip */
.attach-strip {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  overflow-x: auto;
}
.attach-chip {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  overflow: hidden;
}
.attach-chip .x {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}
.attach-chip.file {
  background: var(--panel-2);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex-direction: column;
  font-size: 9px;
  font-weight: 600;
  padding: 4px;
  text-align: center;
  line-height: 1.1;
}

/* Voice recording state */
.recording-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  width: 100%;
}
.recording-bar .rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  animation: rec-pulse 1.2s infinite;
}
@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.recording-bar .rec-time {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.recording-bar .rec-wave {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 24px;
}
.recording-bar .rec-wave .bar {
  flex: 1;
  background: var(--brand);
  border-radius: 2px;
  animation: rec-wave 1s infinite;
}
@keyframes rec-wave {
  0%, 100% { height: 30%; }
  50% { height: 80%; }
}

/* ============== Info Panel ============== */
.info-panel {
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
}
.info-header {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.info-header-title {
  font-size: 14px;
  font-weight: 600;
}
.info-hero {
  padding: 24px 20px 18px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
.info-hero .avatar {
  margin: 0 auto 12px;
}
.info-hero h3 {
  margin: 0 0 2px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.3px;
}
.info-hero .sub {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
}
.info-hero .actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  transition: all 0.15s;
  min-width: 64px;
  font-size: 11px;
  font-weight: 500;
}
.quick-btn:hover {
  background: var(--hover);
  border-color: var(--muted-2);
  color: var(--ink);
}
.quick-btn.danger:hover {
  background: #fdeceb;
  border-color: var(--danger);
  color: var(--danger);
}

.info-section {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.info-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.info-section-title .link {
  color: var(--brand-ink);
  font-size: 11px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
}
.info-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
}
.info-row .k {
  color: var(--muted);
  width: 80px;
  flex-shrink: 0;
  font-size: 12px;
}
.info-row .v {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.info-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 13px;
  cursor: pointer;
}
.info-toggle-row .left {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-2);
}

.toggle {
  width: 32px;
  height: 18px;
  background: var(--line);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.toggle.on {
  background: var(--brand);
}
.toggle.on::after {
  transform: translateX(14px);
}

.media-thumbs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
}
.media-thumb {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.media-thumb .video-icon {
  position: absolute;
  bottom: 4px;
  left: 4px;
  color: white;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  cursor: pointer;
  border-radius: 8px;
  padding: 6px 4px;
  margin: 0 -4px;
}
.member-row:hover {
  background: var(--hover);
}
.member-row .mi {
  flex: 1;
  min-width: 0;
}
.member-row .mn {
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}
.member-row .mr {
  font-size: 11px;
  color: var(--muted);
}
.role-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.role-tag.mod {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ============== Emoji picker ============== */
.popover {
  position: absolute;
  bottom: 100%;
  margin-bottom: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 30;
  overflow: hidden;
}
.emoji-picker {
  width: 340px;
  height: 380px;
  left: 0;
  display: flex;
  flex-direction: column;
}
.emoji-picker .search-row {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--line);
}
.emoji-picker .search-row input {
  width: 100%;
  height: 32px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 12px;
  outline: none;
}
.emoji-cats {
  display: flex;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  gap: 2px;
}
.emoji-cat {
  padding: 8px 10px;
  font-size: 16px;
  opacity: 0.5;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: opacity 0.15s;
}
.emoji-cat:hover { opacity: 0.8; }
.emoji-cat.active {
  opacity: 1;
  border-bottom-color: var(--brand);
}
.emoji-grid {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
}
.emoji-group-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 8px 4px 4px;
}
.emoji-cells {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}
.emoji-cell {
  aspect-ratio: 1;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.1s;
}
.emoji-cell:hover { background: var(--hover); }

.attach-menu {
  bottom: 100%;
  left: 0;
  width: 220px;
  padding: 6px;
  margin-bottom: 8px;
}
.attach-menu .item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
  text-align: left;
}
.attach-menu .item:hover { background: var(--hover); color: var(--ink); }
.attach-menu .item .i {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.attach-menu .item .i.a { background: #e2efe9; color: #3b7a63; }
.attach-menu .item .i.b { background: #fdece0; color: var(--brand-ink); }
.attach-menu .item .i.c { background: #e7f0fa; color: #3a6ea5; }
.attach-menu .item .i.d { background: #f0e4fb; color: #6d3ec2; }
.attach-menu .item .i.e { background: #fce1e3; color: #b83344; }
.attach-menu .divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

.reaction-picker {
  bottom: auto;
  top: -42px;
  display: flex;
  gap: 2px;
  padding: 4px;
  margin-bottom: 0;
}
.reaction-picker .emoji-cell {
  width: 30px;
  height: 30px;
  font-size: 18px;
}
.reaction-picker .emoji-cell:hover {
  transform: scale(1.25);
  transition: transform 0.1s;
}

/* Context menu */
.context-menu {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 50;
  min-width: 200px;
}
.context-menu .item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.context-menu .item:hover { background: var(--hover); color: var(--ink); }
.context-menu .item.danger { color: var(--danger); }
.context-menu .item.danger:hover { background: #fdeceb; color: var(--danger); }
.context-menu .divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}
.context-menu .shortcut {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
}

/* Gallery overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 16, 18, 0.88);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}
.overlay .close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}
.overlay .close:hover { background: rgba(255, 255, 255, 0.2); }
.overlay img {
  max-width: 85vw;
  max-height: 85vh;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

/* Modal */
.modal-scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 16, 18, 0.4);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  width: 460px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.field {
  margin-bottom: 14px;
}
.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 5px;
}
.field input,
.field textarea {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 13px;
  outline: none;
  background: var(--panel);
  transition: border-color 0.15s;
}
.field textarea {
  height: auto;
  padding: 8px 10px;
  min-height: 60px;
  resize: vertical;
}
.field input:focus, .field textarea:focus {
  border-color: var(--ink-2);
}

.btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.btn.primary {
  background: var(--ink);
  color: var(--bg);
}
.btn.primary:hover { background: var(--brand); }
.btn.ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--line);
}
.btn.ghost:hover { background: var(--hover); }
.btn.brand {
  background: var(--brand);
  color: white;
}
.btn.brand:hover { background: var(--brand-ink); }
.btn.danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--line);
}
.btn.danger:hover { background: #fdeceb; border-color: var(--danger); }

/* Empty state for pages */
.empty-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  color: var(--muted);
}
.empty-panel .ic {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  margin-bottom: 16px;
}
.empty-panel h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 4px;
}
.empty-panel p {
  font-size: 13px;
  margin: 0 0 16px;
  max-width: 280px;
}

/* Requests, Contacts, Blocked lists (alt sidebar views) */
.request-item {
  padding: 12px 10px;
  border-radius: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.request-item:hover { background: var(--hover); }
.request-item .main { flex: 1; min-width: 0; }
.request-item .nm { font-size: 13px; font-weight: 600; }
.request-item .hn { font-size: 12px; color: var(--muted); }
.request-item .actions { display: flex; gap: 4px; }
.request-item .btn { height: 28px; padding: 0 10px; font-size: 12px; }

/* Settings page */
.settings-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}
.settings-inner {
  max-width: 640px;
  margin: 0 auto;
}
.settings-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}
.settings-sub {
  color: var(--muted);
  margin-bottom: 28px;
  font-size: 13px;
}
.settings-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px 18px;
  margin-bottom: 18px;
}
.settings-card h4 {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 14px 0 6px;
  margin: 0;
  border-bottom: 1px solid var(--line);
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  gap: 16px;
}
.settings-row:last-child { border-bottom: none; }
.settings-row .sl { flex: 1; min-width: 0; }
.settings-row .sl .t { font-size: 13px; font-weight: 500; }
.settings-row .sl .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.settings-row select {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 0 10px;
  font-size: 12px;
  outline: none;
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
}

.theme-picker {
  display: flex;
  gap: 8px;
}
.theme-opt {
  padding: 6px;
  border: 2px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  min-width: 72px;
}
.theme-opt.active { border-color: var(--brand); color: var(--ink); }
.theme-opt .sw {
  width: 56px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid var(--line);
  overflow: hidden;
  display: flex;
}
.theme-opt .sw.light { background: #f6f5f1; }
.theme-opt .sw.light::after {
  content: "";
  width: 50%;
  background: #fff;
  border-left: 1px solid #ebe9e3;
  margin-left: auto;
}
.theme-opt .sw.dark { background: #0e0f12; }
.theme-opt .sw.dark::after {
  content: "";
  width: 50%;
  background: #16181c;
  border-left: 1px solid #23262c;
  margin-left: auto;
}
.theme-opt .sw.auto {
  background: linear-gradient(to right, #f6f5f1 50%, #0e0f12 50%);
}

/* Tweaks panel */
.tweaks-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 280px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  padding: 14px;
  display: none;
}
.tweaks-panel.open { display: block; }
.tweaks-panel h4 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tweaks-row {
  margin-bottom: 12px;
}
.tweaks-row label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 6px;
}
.tweaks-swatches {
  display: flex;
  gap: 6px;
}
.tweaks-sw {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}
.tweaks-sw.active {
  border-color: var(--ink);
  outline: 2px solid var(--panel);
}
.seg {
  display: flex;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
}
.seg button {
  flex: 1;
  height: 26px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  border-radius: 6px;
}
.seg button.active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* Utility */
.inline-ico {
  display: inline-flex;
  vertical-align: middle;
}
.hidden { display: none !important; }
.scrollable { overflow-y: auto; }
