/* =====================================================================
   Dez Chat Box — styles
   ===================================================================== */
:root {
  --bg: #eef2f4;
  --panel: #ffffff;
  --panel-2: #f5f7f8;
  --panel-3: #eaeef0;
  --line: #e3e8eb;
  --text: #111b21;
  --muted: #667781;
  --accent: #0f7b6c;
  --accent-2: #14a38f;
  --accent-ink: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 13%, #ffffff);
  --chat-bg: #efeae2;
  --chat-dots: rgba(17, 27, 33, .045);
  --bubble-me: color-mix(in srgb, var(--accent-2) 20%, #ffffff);
  --bubble-me-ink: #111b21;
  --bubble-them: #ffffff;
  --bubble-them-ink: #111b21;
  --quote-bg: rgba(17, 27, 33, .055);
  --tick: #8696a0;
  --tick-read: #34a8e8;
  --danger: #e04848;
  --success: #1fa855;
  --shadow: 0 8px 28px rgba(15, 30, 45, .10);
  --shadow-sm: 0 1px 1.5px rgba(11, 20, 26, .13);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1114; --panel: #111b21; --panel-2: #1a242b; --panel-3: #222e35; --line: #222d34;
    --text: #e9edef; --muted: #8696a0; --accent: #21b29c; --accent-2: #2fd0b8; --accent-ink: #04211c;
    --accent-soft: color-mix(in srgb, var(--accent) 22%, #111b21); --chat-bg: #0b141a; --chat-dots: rgba(255, 255, 255, .03);
    --bubble-me: color-mix(in srgb, var(--accent) 52%, #0b141a); --bubble-me-ink: #e9edef; --bubble-them: #202c33; --bubble-them-ink: #e9edef;
    --quote-bg: rgba(0, 0, 0, .22); --tick: #8fa3ad; --tick-read: #53bdeb;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45); --shadow-sm: 0 1px 1.5px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1114; --panel: #111b21; --panel-2: #1a242b; --panel-3: #222e35; --line: #222d34;
  --text: #e9edef; --muted: #8696a0; --accent: #21b29c; --accent-2: #2fd0b8; --accent-ink: #04211c;
  --accent-soft: color-mix(in srgb, var(--accent) 22%, #111b21); --chat-bg: #0b141a; --chat-dots: rgba(255, 255, 255, .03);
  --bubble-me: color-mix(in srgb, var(--accent) 52%, #0b141a); --bubble-me-ink: #e9edef; --bubble-them: #202c33; --bubble-them-ink: #e9edef;
  --quote-bg: rgba(0, 0, 0, .22); --tick: #8fa3ad; --tick-read: #53bdeb;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45); --shadow-sm: 0 1px 1.5px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
.theme-anim, .theme-anim * { transition: background-color .4s var(--ease), color .4s var(--ease), border-color .4s var(--ease) !important; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", "Noto Sans Tamil", "Noto Color Emoji", sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.clickable { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2;
      stroke-linecap: round; stroke-linejoin: round; flex: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 35%, transparent); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- buttons */
.btn { position: relative; overflow: hidden; border: 0; border-radius: 10px; padding: 11px 16px; font: inherit;
  font-weight: 600; cursor: pointer; transition: transform .15s var(--ease), filter .2s, background .2s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.soft { background: var(--accent-soft); color: var(--accent); text-decoration: none; display: inline-block; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); text-decoration: none; display: inline-block; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger-soft { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .6; cursor: default; }
.btn.loading { color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn { position: relative; overflow: hidden; display: inline-grid; place-items: center; width: 40px; height: 40px;
  border-radius: 50%; border: 0; background: transparent; color: var(--muted); cursor: pointer; text-decoration: none;
  transition: background .2s, color .2s, transform .15s var(--ease); flex: none; }
.icon-btn:hover { background: var(--panel-3); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.on { color: var(--accent); background: var(--accent-soft); }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.light { color: #fff; }
.icon-btn.light:hover { background: rgba(255,255,255,.15); color: #fff; }

.ripple { position: absolute; border-radius: 50%; pointer-events: none; background: currentColor; opacity: .18;
  transform: scale(0); animation: ripple .6s var(--ease) forwards; }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

.flash { padding: 10px 12px; border-radius: 10px; font-size: 13.5px; animation: shake .4s; }
.flash.error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.flash.ok { background: var(--accent-soft); color: var(--accent); animation: fadeDown .35s var(--ease); }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes fadeDown { from { opacity: 0; transform: translateY(-6px); } }

/* ---------------------------------------------------------------- avatar */
.avatar { position: relative; width: 44px; height: 44px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 700; color: #fff; background: #7a8794; font-size: 17px; user-select: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar.online::after { content: ""; position: absolute; right: 0; bottom: 1px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--success); border: 2.5px solid var(--panel); animation: dotIn .4s var(--spring); }
@keyframes dotIn { from { transform: scale(0); } }
.avatar.big { width: 96px; height: 96px; font-size: 36px; }
.avatar.huge { width: 112px; height: 112px; font-size: 42px; }
.avatar.sm { width: 34px; height: 34px; font-size: 14px; }

/* ---------------------------------------------------------------- layout */
.app { display: grid; grid-template-columns: 68px minmax(300px, 390px) 1fr; height: 100vh; height: 100dvh; overflow: hidden; position: relative; }
.app.offline::before { content: "Connecting…"; position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: #f0b429; color: #3b2a00; font-size: 13px; font-weight: 600; padding: 6px 14px; border-radius: 20px;
  box-shadow: var(--shadow); animation: fadeDown .3s var(--ease); }

.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 8px 12px; gap: 6px; }
button.me { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; color: inherit; font: inherit;
  text-align: left; cursor: pointer; padding: 4px 8px 4px 4px; border-radius: 14px; min-width: 0; transition: background .2s; }
button.me:hover { background: var(--panel-2); }
.me-text { min-width: 0; } .me-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-actions { display: flex; }
#themeBtn .i-sun { display: none; }
:root[data-theme="dark"] #themeBtn .i-sun { display: block; } :root[data-theme="dark"] #themeBtn .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #themeBtn .i-sun { display: block; }
  :root:not([data-theme="light"]) #themeBtn .i-moon { display: none; }
}

.search { position: relative; margin: 2px 12px 8px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); pointer-events: none; }
.search input { width: 100%; padding: 10px 12px 10px 40px; border-radius: 12px; border: 1px solid transparent;
  background: var(--panel-2); color: var(--text); font: inherit; transition: border-color .2s, background .2s, box-shadow .2s; }
.search input:focus { outline: none; border-color: var(--accent); background: var(--panel); box-shadow: 0 0 0 3px var(--accent-soft); }

.filters { display: flex; gap: 6px; padding: 0 12px 10px; }
.filter { position: relative; overflow: hidden; border: 0; background: var(--panel-2); color: var(--muted); padding: 6px 12px;
  border-radius: 16px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: background .2s, color .2s; display: inline-flex; gap: 6px; align-items: center; }
.filter:hover { background: var(--panel-3); }
.filter.active { background: var(--accent-soft); color: var(--accent); }
.fcount:empty { display: none; }
.fcount { font-size: 11.5px; background: var(--accent); color: #fff; border-radius: 9px; padding: 0 6px; min-width: 18px; text-align: center; }

.user-list { list-style: none; margin: 0; padding: 0 6px 12px; overflow-y: auto; flex: 1; }
.user-list li { position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px; padding: 10px 10px;
  cursor: pointer; border-radius: 12px; transition: background .18s; will-change: transform; }
.user-list li:hover { background: var(--panel-2); }
.user-list li.active { background: var(--accent-soft); }
.user-list li + li::before { content: ""; position: absolute; top: 0; left: 68px; right: 10px; border-top: 1px solid var(--line); }
.user-list li:hover::before, .user-list li.active::before, .user-list li:hover + li::before, .user-list li.active + li::before { opacity: 0; }
.u-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.u-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.u-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 16px; }
.u-time { font-size: 12px; color: var(--muted); flex: none; }
li.has-unread .u-time { color: var(--accent); font-weight: 600; }
li.has-unread .u-last { color: var(--text); }
.u-last { display: flex; align-items: center; gap: 3px; min-width: 0; color: var(--muted); font-size: 14px; }
.u-last > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-last .ticks { margin: 0 1px 0 0; }
.typing-text { color: var(--accent) !important; font-weight: 600; }
.typing-text i { font-style: normal; animation: blink 1.2s infinite; }
.typing-text i:nth-child(2) { animation-delay: .2s; } .typing-text i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .2; } 30% { opacity: 1; } }
.badge { background: var(--accent); color: #fff; border-radius: 11px; padding: 1px 7px; min-width: 21px; text-align: center;
  font-size: 12px; font-weight: 700; flex: none; animation: badgeIn .35s var(--spring); }
@keyframes badgeIn { from { transform: scale(0); } }
.list-empty { padding: 30px 16px !important; text-align: center; color: var(--muted); cursor: default !important; display: block !important; }
.list-empty:hover { background: none !important; }

/* skeleton shimmer */
.skel { cursor: default !important; }
.skel i { width: 44px; height: 44px; border-radius: 50%; display: block; flex: none; }
.skel div { flex: 1; display: grid; gap: 8px; }
.skel b { display: block; height: 11px; border-radius: 6px; width: 70%; } .skel b + b { width: 45%; }
.skel i, .skel b, .skel-msg, .img-wrap.loading {
  background: linear-gradient(90deg, var(--panel-2) 25%, var(--panel-3) 50%, var(--panel-2) 75%);
  background-size: 300% 100%; animation: shimmer 1.3s infinite linear; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }

/* ---------------------------------------------------------------- empty state */
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--chat-bg); position: relative; }
.empty { margin: auto; text-align: center; padding: 24px; max-width: 460px; animation: fadeUp .5s var(--ease); }
.empty h2 { margin: 18px 0 6px; font-size: 26px; }
.empty-art { position: relative; width: 150px; height: 120px; margin: 0 auto; }
.empty-art .bubble { position: absolute; border-radius: 18px; box-shadow: var(--shadow); animation: float 4s ease-in-out infinite; }
.empty-art .b1 { width: 92px; height: 50px; left: 0; top: 8px; background: var(--bubble-them); border-bottom-left-radius: 4px; }
.empty-art .b2 { width: 104px; height: 50px; right: 0; top: 54px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-bottom-right-radius: 4px; animation-delay: -1.3s; }
.empty-art .b3 { width: 30px; height: 30px; left: 22px; top: 76px; border-radius: 50%; background: var(--bubble-me); animation-delay: -2.4s; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } }
.empty-tips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }
.empty-tips span { background: var(--panel); padding: 6px 12px; border-radius: 16px; font-size: 13px; box-shadow: var(--shadow-sm); }

/* ---------------------------------------------------------------- conversation */
.conv { display: flex; flex-direction: column; height: 100%; min-height: 0; position: relative; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 9px 14px; background: var(--panel);
  border-bottom: 1px solid var(--line); z-index: 3; }
.chat-head .avatar { width: 42px; height: 42px; }
.peer-info { flex: 1; min-width: 0; }
.peer-name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peer-status { font-size: 13px; color: var(--muted); height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peer-status.swap { animation: fadeDown .3s var(--ease); }
.peer-status.is-typing, .peer-status.is-online { color: var(--accent); }
.back { display: none; }

.messages-wrap { position: relative; flex: 1; min-height: 0; display: flex; }
.messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 6% 18px; display: flex; flex-direction: column;
  background-color: var(--chat-bg);
  background-image: radial-gradient(var(--chat-dots) 1.2px, transparent 1.3px), radial-gradient(var(--chat-dots) 1.2px, transparent 1.3px);
  background-size: 26px 26px; background-position: 0 0, 13px 13px; overscroll-behavior: contain; }
#msgList { display: flex; flex-direction: column; margin-top: auto; }
#msgList > * { flex-shrink: 0; }
.skel-msg { height: 42px; width: 42%; border-radius: 12px; margin: 6px 0; opacity: .7; }
.skel-msg:nth-child(even) { align-self: flex-end; width: 34%; }
.skel-msg:nth-child(3n) { height: 70px; }
.load-more { align-self: center; font-size: 12px; color: var(--muted); padding: 6px; }

.day { position: sticky; top: 4px; z-index: 2; align-self: center; margin: 10px 0 6px; pointer-events: none; }
.day span { display: inline-block; font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--panel);
  padding: 5px 12px; border-radius: 8px; box-shadow: var(--shadow-sm); text-transform: uppercase; letter-spacing: .02em; font-size: 11.5px; }
.unread-divider { align-self: stretch; text-align: center; margin: 10px -6%; padding: 6px; font-size: 12.5px; font-weight: 600;
  color: var(--accent); background: color-mix(in srgb, var(--panel) 70%, transparent); animation: fadeUp .4s var(--ease); }

/* rows & bubbles */
.row { position: relative; display: flex; align-items: flex-start; margin-top: 2px; max-width: 100%; }
.row.first { margin-top: 10px; }
.row.me { justify-content: flex-end; }
.row.them { justify-content: flex-start; }
.row.center { justify-content: center; margin: 10px 0; }
.bubble { position: relative; max-width: min(72%, 620px); padding: 6px 9px 8px; border-radius: 10px; line-height: 1.38;
  box-shadow: var(--shadow-sm); word-wrap: break-word; overflow-wrap: anywhere; font-size: var(--msg-fs, 14.6px); }
.row.me .bubble { background: var(--bubble-me); color: var(--bubble-me-ink); }
.row.them .bubble { background: var(--bubble-them); color: var(--bubble-them-ink); }
/* tails on the first bubble of each group */
.row.me.first .bubble { border-top-right-radius: 2px; }
.row.them.first .bubble { border-top-left-radius: 2px; }
.row.first .bubble::before { content: ""; position: absolute; top: 0; width: 10px; height: 13px; }
.row.me.first .bubble::before { right: -8px; background: var(--bubble-me); clip-path: polygon(0 0, 100% 0, 0 100%); }
.row.them.first .bubble::before { left: -8px; background: var(--bubble-them); clip-path: polygon(0 0, 100% 0, 100% 100%); }
.bubble .text { white-space: pre-wrap; }
.bubble a { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); }
.row.me .bubble a { color: #027eb5; } :root[data-theme="dark"] .row.me .bubble a { color: #53bdeb; }

/* time + ticks sit at the bottom right; text wraps around them */
.meta { float: right; display: inline-flex; align-items: center; gap: 3px; margin: 8px -2px -5px 10px; font-size: 11px;
  color: color-mix(in srgb, currentColor 55%, transparent); white-space: nowrap; position: relative; top: 2px; user-select: none; }
.bubble.emoji-only { background: transparent !important; box-shadow: none; padding: 0 2px; }
.bubble.emoji-only::before { display: none; }
.bubble.emoji-only .text { font-size: 44px; line-height: 1.15; }
.bubble.emoji-only .meta { background: var(--panel); color: var(--muted); padding: 2px 6px; border-radius: 8px; margin-top: 4px; }

/* ticks */
.ticks { display: inline-grid; place-items: center; width: 18px; height: 12px; color: var(--tick); }
.ticks svg { width: 18px; height: 12px; stroke-width: 1.7; }
.ticks.s-pending svg, .ticks.s-failed svg { width: 13px; height: 13px; }
.ticks.s-pending svg path { transform-origin: 8px 8px; animation: spin 2s linear infinite; }
.ticks.s-read { color: var(--tick-read); }
.ticks.s-failed { color: var(--danger); cursor: pointer; }
.ticks.pop { animation: tickPop .45s var(--spring); }
.ticks.pop.s-read svg path { animation: tickDraw .4s var(--ease); stroke-dasharray: 20; }
@keyframes tickPop { 0% { transform: scale(.4); opacity: .3; } 100% { transform: scale(1); opacity: 1; } }
@keyframes tickDraw { from { stroke-dashoffset: 20; } to { stroke-dashoffset: 0; } }

/* reply quote */
.quote { display: grid; gap: 1px; margin: 0 -3px 5px; padding: 6px 10px; border-radius: 7px; background: var(--quote-bg);
  border-left: 4px solid var(--accent); cursor: pointer; font-size: 13px; min-width: 120px; transition: filter .2s; }
.quote:hover { filter: brightness(.96); }
.quote b { color: var(--accent); font-size: 12.5px; }
.quote span { color: color-mix(in srgb, currentColor 75%, transparent); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.bubble.deleted { font-style: italic; color: var(--muted) !important; }
.del-text { display: inline-flex; align-items: center; gap: 6px; }
.del-text svg { width: 15px; height: 15px; }

/* hover options + swipe-to-reply */
.msg-more { position: absolute; top: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--panel); color: var(--muted); box-shadow: var(--shadow-sm); cursor: pointer; opacity: 0;
  transform: scale(.7); transition: opacity .15s, transform .2s var(--spring); z-index: 2; }
.msg-more svg { width: 16px; height: 16px; }
.row.me .msg-more { right: calc(min(72%, 620px) + 6px); } .row.them .msg-more { left: calc(min(72%, 620px) + 6px); }
.row.me .msg-more { right: auto; left: auto; position: static; order: -1; margin: 4px 6px 0 0; align-self: flex-start; }
.row.them .msg-more { position: static; margin: 4px 0 0 6px; }
@media (hover: hover) { .row:hover .msg-more, .row.menu-on .msg-more { opacity: 1; transform: none; } }
@media (hover: none) { .msg-more { display: none; } }
.swipe-reply { position: absolute; left: -36px; top: 50%; margin-top: -15px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--panel); color: var(--accent); display: grid; place-items: center; box-shadow: var(--shadow-sm);
  opacity: 0; transform: scale(.5); transition: opacity .15s, transform .2s var(--spring); pointer-events: none; }
.swipe-reply svg { width: 16px; height: 16px; }
.row.swiping .swipe-reply { opacity: 1; transform: none; }
.row.menu-on .bubble { filter: brightness(.95); }

/* enter / leave / highlight animations */
.row.enter { animation: msgIn .36s var(--spring) both; }
.row.enter.from-right { transform-origin: bottom right; } .row.enter.from-left { transform-origin: bottom left; }
@keyframes msgIn { from { opacity: 0; transform: translateY(14px) scale(.92); } }
.row.center.enter { animation: fadeUp .35s var(--ease) both; }
.row.leave { animation: msgOut .22s var(--ease) forwards; }
@keyframes msgOut { to { opacity: 0; transform: scale(.9); height: 0; margin: 0; } }
.row.flash .bubble { animation: flashMsg 1.4s var(--ease); }
@keyframes flashMsg { 0%, 40% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 55%, transparent); } 100% { box-shadow: var(--shadow-sm); } }

/* call log pill */
.call-pill { display: inline-flex; align-items: center; gap: 8px; background: var(--panel); color: var(--text); font-size: 13px;
  padding: 7px 12px; border-radius: 10px; box-shadow: var(--shadow-sm); }
.call-pill svg { width: 16px; height: 16px; color: var(--accent); }
.call-pill.missed svg { color: var(--danger); }
.call-pill .time { color: var(--muted); font-size: 11px; }

/* file bubbles */
.bubble.file-bubble { padding: 4px; width: min(340px, 74vw); }
.bubble.file-bubble .meta { position: absolute; right: 10px; bottom: 5px; top: auto; float: none; margin: 0; }
.bubble.file-bubble:has(.media) .file-row { padding-bottom: 20px; }
.bubble.file-bubble .file-row.doc { padding-bottom: 22px; }
.bubble.file-bubble audio + .file-row { padding-bottom: 20px; }
.media { border-radius: 8px; overflow: hidden; background: rgba(0,0,0,.08); }
.media img, .media video { display: block; width: 100%; max-height: 380px; object-fit: contain; background: #000; }
.media img { cursor: zoom-in; object-fit: cover; min-height: 120px; transition: opacity .4s var(--ease), filter .4s; }
.img-wrap.loading img { opacity: 0; }
.file-bubble audio { width: 100%; margin: 4px 0; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 6px 6px 2px; }
.file-row.doc { padding: 8px 8px; background: var(--quote-bg); border-radius: 8px; }
.file-meta { flex: 1; min-width: 0; display: grid; font-size: 13px; }
.fname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fsub { opacity: .7; font-size: 12px; }
.doc-icon { --dc: var(--accent); width: 40px; height: 48px; border-radius: 6px; flex: none; display: grid; place-items: center;
  font-size: 10.5px; font-weight: 800; color: #fff; background: var(--dc); position: relative;
  clip-path: polygon(0 0, 72% 0, 100% 22%, 100% 100%, 0 100%); }
.doc-icon::after { content: ""; position: absolute; right: 0; top: 0; width: 28%; height: 22%; background: rgba(255,255,255,.35); }
.dl-btn { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; border: 0; cursor: pointer;
  background: color-mix(in srgb, currentColor 10%, transparent); color: inherit; text-decoration: none; transition: transform .15s var(--ease), background .2s; }
.dl-btn:hover { background: color-mix(in srgb, currentColor 18%, transparent); transform: translateY(-1px); }
.dl-btn svg { width: 18px; height: 18px; }

/* uploading bubble with progress ring */
.up-thumb img { filter: blur(1px) brightness(.85); }
.up-ring { width: 44px; height: 44px; border: 0; background: none; padding: 0; cursor: pointer; color: var(--accent); flex: none; }
.up-ring svg { width: 44px; height: 44px; transform: rotate(-90deg); }
.up-ring .bg { stroke: color-mix(in srgb, currentColor 18%, transparent); stroke-width: 3; }
.up-ring .fg { stroke: currentColor; stroke-width: 3; transition: stroke-dashoffset .25s var(--ease); }
.up-ring .x { transform: rotate(90deg); transform-origin: 22px 22px; stroke-width: 2.2; }
.row.uploading.failed .up-ring { color: var(--danger); }

/* typing bubble */
.typing-bubble { align-self: flex-start; display: inline-flex; gap: 4px; padding: 12px 14px; margin-top: 10px; background: var(--bubble-them);
  border-radius: 10px; border-top-left-radius: 2px; box-shadow: var(--shadow-sm); animation: msgIn .3s var(--spring); flex-shrink: 0; }
.typing-bubble span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; }
.typing-bubble span:nth-child(2) { animation-delay: .15s; } .typing-bubble span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-6px); opacity: 1; } }

/* jump to latest */
.jump-btn { position: absolute; right: 18px; bottom: 16px; width: 42px; height: 42px; border-radius: 50%; border: 0; z-index: 4;
  background: var(--panel); color: var(--muted); box-shadow: var(--shadow); cursor: pointer; display: grid; place-items: center;
  opacity: 0; transform: scale(.6) translateY(10px); transition: opacity .2s, transform .3s var(--spring); }
.jump-btn.show { opacity: 1; transform: none; }
.jump-count { position: absolute; top: -6px; right: -4px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 10px; padding: 1px 6px; animation: badgeIn .3s var(--spring); }

/* message menu */
.msg-menu { position: fixed; z-index: 40; min-width: 190px; background: var(--panel); border-radius: 12px; padding: 6px;
  box-shadow: 0 12px 40px rgba(0,0,0,.22); opacity: 0; transform: scale(.85); transition: opacity .14s, transform .2s var(--spring); }
.msg-menu.open { opacity: 1; transform: none; }
.msg-menu button { position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px; width: 100%; border: 0;
  background: none; color: var(--text); font: inherit; font-size: 14.5px; padding: 9px 12px; border-radius: 8px; cursor: pointer; text-align: left; }
.msg-menu button:hover { background: var(--panel-2); }
.msg-menu button svg { width: 18px; height: 18px; color: var(--muted); }
.msg-menu .danger, .msg-menu .danger svg { color: var(--danger); }

/* composer */
.composer-wrap { position: relative; background: var(--panel-2); border-top: 1px solid var(--line); z-index: 3; }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 0 12px; max-height: 0; opacity: 0; overflow: hidden;
  transition: max-height .25s var(--ease), opacity .2s, padding .25s var(--ease); }
.reply-bar.open { max-height: 90px; opacity: 1; padding: 8px 12px 0; }
.reply-quote { flex: 1; min-width: 0; display: grid; padding: 8px 12px; border-radius: 8px; background: var(--panel);
  border-left: 4px solid var(--accent); font-size: 13.5px; }
.reply-quote b { color: var(--accent); font-size: 13px; }
.reply-quote span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.emoji-panel { background: var(--panel); border-bottom: 1px solid var(--line); height: 0; opacity: 0; overflow: hidden;
  display: flex; flex-direction: column; transition: height .28s var(--ease), opacity .2s; }
.emoji-panel.open { height: 260px; opacity: 1; }
.emoji-tabs { display: flex; gap: 2px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.emoji-tabs button { border: 0; background: none; font-size: 20px; padding: 4px 10px; border-radius: 8px; cursor: pointer;
  opacity: .55; transition: opacity .2s, background .2s; }
.emoji-tabs button.active { opacity: 1; background: var(--accent-soft); }
.emoji-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); padding: 8px 10px; }
.emoji-grid button { border: 0; background: none; font-size: 26px; height: 42px; border-radius: 10px; cursor: pointer; transition: background .15s, transform .15s; }
.emoji-grid button:hover { background: var(--panel-2); transform: scale(1.15); }

.composer { display: flex; align-items: flex-end; gap: 4px; padding: 8px 10px; }
.composer textarea { flex: 1; resize: none; max-height: 140px; padding: 11px 16px; border-radius: 22px; border: 1px solid transparent;
  background: var(--panel); color: var(--text); font: inherit; font-size: 15px; line-height: 1.35; margin: 0 4px;
  transition: border-color .2s, box-shadow .2s; }
.composer textarea:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer .icon-btn { margin-bottom: 2px; }
.send { position: relative; overflow: hidden; width: 44px; height: 44px; border-radius: 50%; border: 0; flex: none; cursor: pointer;
  display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 40%, transparent); transition: transform .25s var(--spring), opacity .2s, box-shadow .2s; }
.send svg { width: 20px; height: 20px; margin-left: -2px; }
.send:disabled { opacity: .45; transform: scale(.88); box-shadow: none; cursor: default; }
.send:not(:disabled):hover { transform: scale(1.06); }

.drop-hint { position: absolute; inset: 66px 12px 12px; border: 2.5px dashed var(--accent); border-radius: 18px; z-index: 6;
  background: color-mix(in srgb, var(--accent-soft) 88%, transparent); display: grid; place-content: center; justify-items: center; gap: 10px;
  font-weight: 700; color: var(--accent); pointer-events: none; animation: fadeUp .2s var(--ease); backdrop-filter: blur(2px); }
.drop-hint svg { width: 40px; height: 40px; animation: float 1.6s ease-in-out infinite; }

/* ---------------------------------------------------------------- modals */
.modal { position: fixed; inset: 0; background: rgba(5, 10, 15, .55); display: grid; place-items: center; z-index: 30;
  opacity: 0; transition: opacity .2s var(--ease); backdrop-filter: blur(3px); padding: 12px; }
.modal.open { opacity: 1; }
.modal > * { transform: translateY(14px) scale(.96); transition: transform .3s var(--spring); }
.modal.open > * { transform: none; }
.profile-card { position: relative; background: var(--panel); border-radius: 20px; padding: 26px; width: min(440px, 94vw);
  max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow); display: grid; gap: 12px; }
.profile-card h2 { margin: 0; }
.profile-card .close { position: absolute; right: 10px; top: 10px; }
#profileForm { display: grid; gap: 12px; }
.profile-card label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.profile-card input, .profile-card select { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: inherit; width: 100%; transition: border-color .2s, box-shadow .2s; }
.profile-card input:focus, .profile-card select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.profile-card details summary { cursor: pointer; color: var(--accent); font-size: 14px; margin-bottom: 8px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo-edit { display: flex; align-items: center; gap: 18px; }
.photo-btns { display: grid; gap: 8px; }
.photo-btns .btn { text-align: center; cursor: pointer; }
#profileView { display: grid; justify-items: center; text-align: center; gap: 4px; }
#profileView.hidden { display: none; }
#pvAvatar { cursor: zoom-in; animation: badgeIn .5s var(--spring); }
#profileView h2 { margin-top: 10px; }
.about { margin: 6px 0; }
.pv-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; text-align: left; margin: 8px 0; width: 100%;
  background: var(--panel-2); padding: 12px 14px; border-radius: 12px; }
.pv-list dt { color: var(--muted); } .pv-list dd { margin: 0; overflow-wrap: anywhere; }
.pv-actions { display: flex; gap: 10px; justify-content: flex-end; width: 100%; }
#profileView .pv-actions { justify-content: center; }
.confirm-card { width: min(380px, 94vw); } .confirm-card p { margin: 0 0 8px; font-size: 15.5px; }
.info-card { width: min(380px, 94vw); }
.info-preview { background: var(--bubble-me); color: var(--bubble-me-ink); padding: 10px 12px; border-radius: 10px; margin-bottom: 6px; white-space: pre-wrap; }
.info-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.info-row:last-child { border-bottom: 0; }
.info-row span { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.info-row b { font-weight: 600; font-size: 14px; }

/* incoming call */
.incoming-card { background: var(--panel); border-radius: 24px; padding: 36px 44px; text-align: center; display: grid;
  justify-items: center; gap: 6px; box-shadow: var(--shadow); min-width: 290px; }
.rings { position: relative; margin-bottom: 8px; }
.rings::before, .rings::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--success); animation: ringOut 2s infinite var(--ease); }
.rings::after { animation-delay: 1s; }
@keyframes ringOut { from { transform: scale(1); opacity: .8; } to { transform: scale(1.9); opacity: 0; } }
.in-name { font-size: 22px; font-weight: 700; margin-top: 10px; }
.in-actions { display: flex; gap: 56px; margin-top: 20px; }
#acceptBtn { animation: wiggle 1.4s infinite; }
@keyframes wiggle { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(-14deg); } 80% { transform: rotate(12deg); } 90% { transform: rotate(-8deg); } }

/* viewer */
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.94); z-index: 35; display: flex; flex-direction: column;
  opacity: 0; transition: opacity .22s var(--ease); }
.viewer.open { opacity: 1; }
.viewer-bar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; color: #fff; }
.viewer-bar span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-body { flex: 1; display: grid; place-items: center; min-height: 0; padding: 10px; }
.viewer-body img, .viewer-body video { max-width: 100%; max-height: calc(100vh - 80px); object-fit: contain; transform: scale(.94);
  transition: transform .35s var(--spring); }
.viewer.open .viewer-body img, .viewer.open .viewer-body video { transform: none; }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px); opacity: 0; background: #1f2a30; color: #fff;
  padding: 11px 18px; border-radius: 12px; z-index: 70; font-size: 14px; max-width: 90vw; box-shadow: var(--shadow);
  transition: opacity .25s var(--ease), transform .35s var(--spring); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- call screen */
.round { position: relative; overflow: hidden; width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; background: rgba(255,255,255,.16); color: #fff; backdrop-filter: blur(6px);
  transition: transform .2s var(--spring), background .2s; }
.round:hover { transform: translateY(-2px); background: rgba(255,255,255,.24); }
.round:active { transform: scale(.92); }
.round svg { width: 24px; height: 24px; }
.round.off { background: #fff; color: #222; }
.round.on { background: var(--accent-2); color: #fff; }
.round.danger { background: var(--danger); color: #fff; }
.round.success { background: var(--success); color: #fff; }
.round:disabled { opacity: .4; }

#callScreen { position: fixed; inset: 0; background: #0b1013; z-index: 20; color: #fff; animation: callIn .35s var(--ease); }
@keyframes callIn { from { opacity: 0; transform: scale(1.03); } }
.call-audio-only { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 6px; z-index: 1;
  background: radial-gradient(circle at 50% 40%, #16323a, #0b1013 60%); }
.call-audio-only .avatar { animation: breathe 2.6s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { box-shadow: 0 0 0 0 rgba(33,178,156,.45); } 50% { box-shadow: 0 0 0 22px rgba(33,178,156,0); } }
.muted-light { color: rgba(255,255,255,.65); }
.remote-grid { position: absolute; inset: 0; display: grid; gap: 6px; padding: 64px 6px 96px; background: #0b1013; transition: padding .3s var(--ease); }
.remote-grid[data-count="2"] { grid-template-columns: 1fr 1fr; }
.remote-grid[data-count="3"], .remote-grid[data-count="4"] { grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; }
.remote-tile { position: relative; background: #000; border-radius: 14px; overflow: hidden; min-height: 0; animation: tileIn .45s var(--spring); }
@keyframes tileIn { from { opacity: 0; transform: scale(.9); } }
.remote-tile video { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile-label, .tile-res { position: absolute; bottom: 8px; font-size: 12.5px; padding: 3px 8px; border-radius: 6px; background: rgba(0,0,0,.55); }
.tile-label { left: 8px; } .tile-res { right: 8px; color: #9ff0d8; }
.tile-res:empty { display: none; }
.tile-off { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px; background: #11181d; }
.focus-layout .remote-grid { grid-template-columns: 1fr !important; }
.focus-layout .remote-tile:not(:first-child) { position: absolute; left: 16px; top: 76px; width: 220px; max-width: 34vw;
  aspect-ratio: 16/9; z-index: 2; border: 2px solid rgba(255,255,255,.3); cursor: pointer; }
.focus-layout .remote-tile:nth-child(3) { top: calc(76px + 140px); }
.local-strip { position: absolute; right: 16px; bottom: 104px; display: flex; gap: 8px; z-index: 3; transition: bottom .3s var(--ease); }
.local-tile { position: relative; width: 200px; max-width: 30vw; aspect-ratio: 16/9; border-radius: 12px; overflow: hidden;
  border: 2px solid rgba(255,255,255,.3); background: #222; box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: tileIn .45s var(--spring); }
.local-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.local-tile video.mirror { transform: scaleX(-1); }
.local-tile span { position: absolute; left: 6px; bottom: 4px; font-size: 11.5px; background: rgba(0,0,0,.5); padding: 1px 6px; border-radius: 5px; }
.call-top { position: absolute; top: 0; left: 0; right: 0; padding: 16px 18px; display: flex; gap: 12px; align-items: center;
  justify-content: space-between; flex-wrap: wrap; z-index: 4; background: linear-gradient(rgba(0,0,0,.55), transparent);
  transition: opacity .35s var(--ease), transform .35s var(--ease); }
.call-title { font-weight: 600; }
.peer-flags { display: flex; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.peer-flags span { background: rgba(255,255,255,.14); padding: 3px 8px; border-radius: 8px; animation: fadeDown .3s var(--ease); }
.call-top-right { display: flex; gap: 8px; align-items: center; }
#qualitySel { background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 8px; padding: 6px 8px; font: inherit; font-size: 13px; }
#qualitySel option { color: #111; }
.chip-btn { background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.chip-btn[data-net="Excellent"] { background: rgba(31,168,85,.35); }
.chip-btn[data-net="Good"] { background: rgba(43,179,159,.3); }
.chip-btn[data-net="Weak"] { background: rgba(217,59,59,.4); }
.stats-box { position: absolute; top: 64px; right: 16px; z-index: 5; background: rgba(0,0,0,.72); border-radius: 12px;
  padding: 10px 14px; font-size: 12.5px; line-height: 1.6; max-width: min(440px, 92vw); backdrop-filter: blur(6px); animation: fadeDown .25s var(--ease); }
.stats-box em { color: #ffcf70; font-style: normal; }
.call-controls { position: absolute; left: 0; right: 0; bottom: 0; padding: 20px; display: flex; justify-content: center; gap: 16px;
  flex-wrap: wrap; z-index: 4; background: linear-gradient(transparent, rgba(0,0,0,.65)); transition: opacity .35s var(--ease), transform .35s var(--ease); }
#callScreen.idle .call-controls { opacity: 0; transform: translateY(30px); pointer-events: none; }
#callScreen.idle .call-top { opacity: 0; transform: translateY(-20px); pointer-events: none; }
#callScreen.idle .local-strip { bottom: 20px; }
#callScreen.idle { cursor: none; }
#dualModal { z-index: 45; }

/* ---------------------------------------------------------------- login */
.auth-body { display: grid; place-items: center; padding: 16px; min-height: 100vh; overflow-x: hidden; position: relative; }
.blobs { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.blobs i { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .45; animation: blob 18s ease-in-out infinite; }
.blobs i:nth-child(1) { width: 420px; height: 420px; background: #14a38f; left: -120px; top: -100px; }
.blobs i:nth-child(2) { width: 380px; height: 380px; background: #3b6fd8; right: -120px; bottom: -120px; animation-delay: -6s; }
.blobs i:nth-child(3) { width: 260px; height: 260px; background: #7c4dbd; right: 20%; top: 10%; animation-delay: -12s; opacity: .25; }
@keyframes blob { 0%, 100% { transform: translate(0, 0) scale(1); } 33% { transform: translate(60px, 40px) scale(1.1); } 66% { transform: translate(-30px, 60px) scale(.92); } }
.auth-wrap { display: grid; grid-template-columns: 1fr 1fr; max-width: 880px; width: 100%; border-radius: 24px; overflow: hidden;
  box-shadow: 0 30px 80px rgba(10, 30, 40, .25); background: var(--panel); animation: cardIn .6s var(--spring); }
@keyframes cardIn { from { opacity: 0; transform: translateY(24px) scale(.97); } }
.auth-side { background: linear-gradient(150deg, #0f7b6c, #0b4f66); color: #fff; padding: 38px; display: flex; flex-direction: column;
  gap: 18px; position: relative; overflow: hidden; }
.auth-side::after { content: ""; position: absolute; width: 300px; height: 300px; border-radius: 50%; right: -110px; bottom: -110px;
  background: rgba(255,255,255,.07); }
.auth-side h2 { font-size: 27px; line-height: 1.25; margin: 22px 0 0; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--accent); font-size: 17px; }
.brand-dot { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; }
.brand-dot::before { content: ""; width: 13px; height: 10px; background: #fff; border-radius: 2px 2px 2px 0; clip-path: polygon(0 0, 100% 0, 100% 75%, 35% 75%, 10% 100%, 10% 75%, 0 75%); }
.brand.light { color: #fff; } .brand.light .brand-dot { background: rgba(255,255,255,.2); }
.feature-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; font-size: 15px; }
.feature-list li { display: flex; gap: 10px; align-items: center; opacity: 0; animation: fadeUp .5s var(--ease) forwards; }
.feature-list li:nth-child(1) { animation-delay: .25s; } .feature-list li:nth-child(2) { animation-delay: .35s; }
.feature-list li:nth-child(3) { animation-delay: .45s; } .feature-list li:nth-child(4) { animation-delay: .55s; }
.feature-list li:nth-child(5) { animation-delay: .65s; }
.feature-list li span { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.14); display: grid; place-items: center; flex: none; }
.chat-preview { margin-top: auto; display: grid; gap: 6px; position: relative; z-index: 1; }
.chat-preview div { max-width: 78%; padding: 7px 10px; border-radius: 10px; font-size: 13px; opacity: 0; animation: msgIn .5s var(--spring) forwards; }
.chat-preview .p1 { background: rgba(255,255,255,.95); color: #111; border-top-left-radius: 2px; animation-delay: .9s; }
.chat-preview .p2 { background: #d4f5e9; color: #111; justify-self: end; border-top-right-radius: 2px; animation-delay: 1.5s; display: flex; gap: 6px; align-items: center; }
.chat-preview .p2 svg { width: 16px; height: 11px; color: #34a8e8; stroke-width: 1.8; }
.auth-card { background: var(--panel); padding: 30px; display: grid; gap: 14px; align-content: start; }
.auth-card h1 { margin: 6px 0 0; font-size: 26px; }
.tab-panel { display: grid; gap: 14px; animation: panelIn .35s var(--ease); }
@keyframes panelIn { from { opacity: 0; transform: translateX(14px); } }
.auth-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.auth-card input { padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--panel-2);
  color: var(--text); font: inherit; transition: border-color .2s, box-shadow .2s, background .2s; }
.auth-card input:focus { outline: none; border-color: var(--accent); background: var(--panel); box-shadow: 0 0 0 4px var(--accent-soft); }
.tabs { position: relative; display: grid; grid-template-columns: 1fr 1fr; background: var(--panel-2); border-radius: 14px; padding: 4px; }
.tab-ind { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); background: var(--panel); border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08); transition: transform .35s var(--spring); }
.tabs[data-active="register"] .tab-ind { transform: translateX(100%); }
.tab { position: relative; overflow: hidden; z-index: 1; border: 0; background: transparent; color: var(--muted); padding: 10px;
  border-radius: 10px; font: inherit; font-weight: 700; cursor: pointer; transition: color .25s; }
.tab.active { color: var(--accent); }
.pw { position: relative; display: block; }
.pw input { width: 100%; padding-right: 64px; }
.show-pw { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--accent);
  font: inherit; font-size: 13px; cursor: pointer; padding: 6px; font-weight: 600; }
.pw-meter { height: 4px; border-radius: 3px; background: var(--panel-3); overflow: hidden; margin-top: -6px; }
.pw-meter i { display: block; height: 100%; width: 0; border-radius: 3px; transition: width .3s var(--ease), background .3s; }
.auth-card .btn.primary { padding: 13px; font-size: 15.5px; }

/* ---------------------------------------------------------------- admin */
.admin-body { min-height: 100vh; }
.admin-top { display: flex; align-items: center; gap: 18px; padding: 12px 22px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.tag { background: var(--accent); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 6px; }
.admin-nav { display: flex; gap: 4px; flex: 1; }
.nav-btn { position: relative; overflow: hidden; border: 0; background: transparent; color: var(--muted); padding: 9px 14px;
  border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; transition: background .2s, color .2s; }
.nav-btn.active { background: var(--accent-soft); color: var(--accent); }
.admin-actions { display: flex; gap: 8px; align-items: center; }
.admin-main { max-width: 1200px; margin: 0 auto; padding: 22px; }
.view { animation: fadeUp .35s var(--ease); }
.admin-main h1 { margin: 0 0 16px; font-size: 24px; }
.view-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.view-head h1 { margin: 0; flex: 1; }
.search-input { padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font: inherit; min-width: 220px; }
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--panel); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); animation: fadeUp .45s var(--ease) both; }
.stat:nth-child(2) { animation-delay: .05s; } .stat:nth-child(3) { animation-delay: .1s; } .stat:nth-child(4) { animation-delay: .15s; }
.stat:nth-child(5) { animation-delay: .2s; } .stat:nth-child(6) { animation-delay: .25s; }
.stat-v { font-size: 30px; font-weight: 800; color: var(--accent); }
.stat-l { font-weight: 600; margin-top: 2px; } .stat-s { font-size: 12.5px; color: var(--muted); }
.panel { background: var(--panel); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.panel h3 { margin: 0 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--accent-soft); padding: 5px 10px; border-radius: 20px; font-size: 13.5px; display: inline-flex; gap: 6px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); display: inline-block; animation: breathe 2s infinite; }
.table-wrap { background: var(--panel); border-radius: 16px; box-shadow: var(--shadow); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 12px 14px;
  border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background .15s; } .table tbody tr:hover { background: var(--panel-2); }
.table tr:last-child td { border-bottom: 0; }
.table tr.disabled td { opacity: .55; }
.table code { font-size: 12px; }
.nowrap { white-space: nowrap; }
td.actions { white-space: nowrap; }
td.actions .btn + .btn, td.actions .btn + a, td.actions a + .btn { margin-left: 6px; }
.u-cell { display: flex; align-items: center; gap: 10px; }
.pill { font-size: 12px; padding: 2px 9px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.pill.admin { background: var(--accent); color: #fff; border-color: transparent; }
.pill.on { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); border-color: transparent; }
.pill.off { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border-color: transparent; }

/* ---------------------------------------------------------------- mobile */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .app.in-chat .sidebar { display: none; }
  .app:not(.in-chat) .chat { display: none; }
  .back { display: inline-grid; margin-left: -6px; }
  .chat-head { padding: 7px 8px; gap: 6px; }
  .messages { padding: 10px 10px 14px; }
  .unread-divider { margin: 10px -10px; }
  .bubble { max-width: 84%; }
  .composer { padding: 6px; }
  .emoji-panel.open { height: 230px; }
  .remote-grid[data-count="2"] { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .local-tile { width: 104px; aspect-ratio: 3/4; }
  .local-strip { bottom: 150px; right: 10px; flex-direction: column; }
  .call-controls { gap: 10px; padding: 14px 8px; }
  .call-controls .round { width: 46px; height: 46px; }
  .remote-grid { padding: 96px 4px 140px; }
  .two { grid-template-columns: 1fr; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { padding: 22px 24px; } .auth-side h2 { font-size: 20px; margin-top: 4px; }
  .feature-list, .chat-preview { display: none; }
  .auth-card { padding: 22px; }
  .admin-top { padding: 10px 14px; gap: 10px; } .admin-nav { order: 3; width: 100%; }
  .admin-main { padding: 14px; } .search-input { min-width: 0; flex: 1; }
  .jump-btn { right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* =====================================================================
   v3 — rail, panels, drawer, settings, reactions, voice, attach preview
   ===================================================================== */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg.filled, .star-ic { fill: currentColor; }
.tiny { width: 13px; height: 13px; vertical-align: -2px; }

/* accent colours (teal is the default from the theme) */
:root[data-accent="blue"]   { --accent: #2f74e0; --accent-2: #5a97f5; }
:root[data-accent="purple"] { --accent: #7c4dbd; --accent-2: #a07ae0; }
:root[data-accent="orange"] { --accent: #e0662a; --accent-2: #f59a52; }
:root[data-accent="rose"]   { --accent: #d6336c; --accent-2: #f06595; }
:root[data-accent="green"]  { --accent: #2f9e44; --accent-2: #51cf66; }
:root[data-font="small"] { --msg-fs: 13.6px; }
:root[data-font="large"] { --msg-fs: 16.8px; }

/* wallpapers */
:root[data-wall="plain"] .messages { background-image: none; }
:root[data-wall="mint"] .messages { background-color: color-mix(in srgb, #2fbf8f 16%, var(--bg)); background-image: radial-gradient(color-mix(in srgb, #2fbf8f 20%, transparent) 1.2px, transparent 1.3px); }
:root[data-wall="sky"] .messages { background-color: color-mix(in srgb, #3b82f6 14%, var(--bg)); background-image: linear-gradient(180deg, transparent, color-mix(in srgb, #3b82f6 10%, transparent)); background-size: auto; }
:root[data-wall="sunset"] .messages { background-image: linear-gradient(160deg, color-mix(in srgb, #f97316 16%, var(--bg)), color-mix(in srgb, #e11d63 14%, var(--bg))); background-size: auto; }
:root[data-wall="night"] .messages { background-color: #0d1424; background-image: radial-gradient(rgba(255,255,255,.18) 1px, transparent 1.2px), radial-gradient(rgba(255,255,255,.1) 1px, transparent 1.2px); background-size: 60px 60px, 34px 34px; background-position: 0 0, 17px 23px; }
:root[data-wall="night"] .day span, :root[data-wall="night"] .call-pill, :root[data-wall="night"] .chat-start { background: #1b2436; color: #c8d3e6; }

/* ---------------------------------------------------------------- icon rail */
.rail { background: var(--panel-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center;
  padding: 12px 0 14px; gap: 6px; z-index: 6; }
.rail-logo { margin-bottom: 10px; }
.rail-logo .brand-dot { width: 36px; height: 36px; border-radius: 11px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 40%, transparent); }
.rail-logo .brand-dot::before { width: 17px; height: 13px; }
.rail-btn { position: relative; overflow: hidden; width: 46px; height: 46px; border-radius: 14px; border: 0; background: transparent; color: var(--muted);
  display: grid; place-items: center; cursor: pointer; transition: background .2s, color .2s, transform .15s var(--ease); text-decoration: none; }
.rail-btn:hover { background: var(--panel-3); color: var(--text); }
.rail-btn:active { transform: scale(.92); }
.rail-btn.active { background: var(--accent-soft); color: var(--accent); }
.rail-btn.active::before { content: ""; position: absolute; left: -11px; top: 12px; bottom: 12px; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent); animation: fadeDown .3s var(--ease); }
.rail-btn svg { width: 22px; height: 22px; }
.rail-btn em { display: none; }
.rail-badge { position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent);
  color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; animation: badgeIn .35s var(--spring); }
#railMissed { background: var(--danger); }
.rail-spacer { flex: 1; }
.rail-me { border: 0; background: none; padding: 0; margin-top: 6px; cursor: pointer; border-radius: 50%; transition: transform .2s var(--spring); }
.rail-me:hover { transform: scale(1.08); }
.rail-me .avatar { width: 38px; height: 38px; font-size: 15px; }
.rail-me .avatar.online::after { width: 10px; height: 10px; border-color: var(--panel-2); }

/* ---------------------------------------------------------------- sidebar panels */
.sidebar { overflow: hidden; }
.panel { display: flex; flex-direction: column; min-height: 0; height: 100%; animation: panelIn .3s var(--ease); }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 8px 18px; }
.panel-head h1 { margin: 0; font-size: 23px; font-weight: 800; letter-spacing: -.01em; }
.panel-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.search input { padding-right: 36px; }
.search-clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); cursor: pointer; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; }
.search-clear svg { position: static; transform: none; width: 15px; height: 15px; }
.search-clear:hover { background: var(--panel-3); }
.list-label { padding: 10px 12px 4px !important; font-size: 12.5px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; cursor: default !important; display: block !important; }
.list-label:hover { background: none !important; } .list-label::before { display: none; }
.user-list li + li.list-label::before, .list-label + li::before { display: none; }
mark { background: color-mix(in srgb, #f0b429 45%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
mark.hl { background: #f0b429; color: #111; }
.u-icons { display: inline-flex; align-items: center; gap: 4px; flex: none; color: var(--muted); }
.ui-ic { width: 15px; height: 15px; }
.draft-label { color: var(--danger); font-weight: 600; margin-right: 2px; flex: none; }
li.muted-chat .badge { background: var(--muted); }
.msg-results { padding: 0 6px 16px; }
.msg-results .res { display: grid; gap: 2px; width: 100%; text-align: left; border: 0; background: none; color: inherit; font: inherit; padding: 9px 12px;
  border-radius: 12px; cursor: pointer; transition: background .15s; }
.msg-results .res:hover { background: var(--panel-2); }
.res-text { font-size: 13.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.filters { overflow-x: auto; scrollbar-width: none; } .filters::-webkit-scrollbar { display: none; }
.filter { flex: none; }

/* calls */
.call-list, .star-list { list-style: none; margin: 0; padding: 0 6px 16px; }
.call-list li { position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; cursor: pointer; transition: background .15s; animation: fadeUp .35s var(--ease) both; }
.call-list li:hover { background: var(--panel-2); }
.call-meta { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.call-meta svg { width: 15px; height: 15px; }
.call-meta.out svg, .call-meta.in svg { color: var(--success); }
.call-meta.missed, .call-meta.missed svg { color: var(--danger); }
.call-back { color: var(--accent); }

/* starred */
.star-item { position: relative; margin: 4px 6px 10px; padding: 10px 12px; border-radius: 14px; background: var(--panel-2); cursor: pointer;
  transition: transform .2s var(--ease), background .2s; animation: fadeUp .35s var(--ease) both; }
.star-item:hover { background: var(--panel-3); transform: translateY(-1px); }
.star-item.leave { animation: msgOut .22s var(--ease) forwards; }
.star-bubble { margin-top: 6px; padding: 8px 10px; border-radius: 10px; background: var(--bubble-them); font-size: 14px; box-shadow: var(--shadow-sm);
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 120px; overflow: hidden; margin-right: 30px; }
.star-bubble.me { background: var(--bubble-me); }
.unstar { position: absolute; right: 8px; bottom: 10px; color: #f0b429; }
.big-ic { width: 42px; height: 42px; color: #f0b429; fill: color-mix(in srgb, #f0b429 30%, transparent); margin-bottom: 8px; }

/* settings */
.settings { padding: 4px 16px 24px; }
.settings h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); margin: 22px 4px 8px; }
.set-profile { display: flex; align-items: center; gap: 14px; width: 100%; border: 0; background: var(--panel-2); color: inherit; font: inherit; text-align: left;
  padding: 14px; border-radius: 16px; cursor: pointer; transition: background .2s, transform .2s var(--ease); }
.set-profile:hover { background: var(--panel-3); transform: translateY(-1px); }
.set-profile .avatar.big { width: 64px; height: 64px; font-size: 26px; }
.set-profile > div { display: grid; gap: 1px; min-width: 0; }
.set-profile b { font-size: 17px; } .set-profile .link { color: var(--accent); font-size: 13px; margin-top: 3px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.set-row.col { flex-direction: column; align-items: stretch; }
.set-row > span { display: grid; gap: 2px; font-size: 14.5px; }
.set-row small { color: var(--muted); font-size: 12px; font-weight: 400; }
.set-row > span svg { width: 17px; height: 17px; vertical-align: -3px; margin-right: 8px; color: var(--muted); }
.seg { display: inline-flex; background: var(--panel-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { position: relative; overflow: hidden; border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 11px; border-radius: 8px; cursor: pointer; transition: background .2s, color .2s; }
.seg button.active { background: var(--panel); color: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.swatches, .walls { display: flex; gap: 10px; flex-wrap: wrap; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--c); cursor: pointer; position: relative;
  transition: transform .2s var(--spring); box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); }
.swatches button:hover { transform: scale(1.12); }
.swatches button.active { box-shadow: 0 0 0 3px var(--panel), 0 0 0 5px var(--c); }
.swatches button.active::after { content: ""; position: absolute; inset: 0; margin: auto; width: 12px; height: 7px; border: solid #fff; border-width: 0 0 2.5px 2.5px; transform: translateY(-2px) rotate(-45deg); }
.walls button { width: 52px; height: 52px; border-radius: 12px; border: 2px solid var(--line); cursor: pointer; transition: transform .2s var(--spring), border-color .2s; }
.walls button:hover { transform: scale(1.06); }
.walls button.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.w-doodle { background: #efeae2 radial-gradient(rgba(17,27,33,.15) 1.2px, transparent 1.3px) 0 0 / 10px 10px; }
.w-plain { background: #efeae2; } .w-mint { background: #d6f1e5; } .w-sky { background: linear-gradient(#e3edfc, #cfe0fb); }
.w-sunset { background: linear-gradient(160deg, #fde2cf, #f9d3e0); } .w-night { background: #0d1424 radial-gradient(rgba(255,255,255,.5) 1px, transparent 1.2px) 0 0 / 12px 12px; }
.toggle { cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle i { position: relative; width: 42px; height: 24px; border-radius: 12px; background: var(--panel-3); flex: none; transition: background .25s; }
.toggle i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3);
  transition: transform .3s var(--spring); }
.toggle input:checked + i { background: var(--accent); }
.toggle input:checked + i::after { transform: translateX(18px); }
.toggle input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.shortcuts { display: grid; gap: 8px; padding: 6px 4px; font-size: 13.5px; }
.shortcuts div { display: flex; align-items: center; gap: 4px; }
.shortcuts div span:last-child { margin-left: auto; color: var(--muted); }
kbd { background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 1px 7px; font: 12px ui-monospace, monospace; }
.kbd-text { font-size: 13px; }

/* ---------------------------------------------------------------- chat header extras */
.head-ic { width: 15px; height: 15px; color: var(--muted); margin-left: 6px; vertical-align: -2px; }
.chat-search { display: flex; align-items: center; gap: 6px; padding: 0 14px; max-height: 0; overflow: hidden; opacity: 0; background: var(--panel);
  border-bottom: 1px solid transparent; transition: max-height .25s var(--ease), opacity .2s, padding .25s var(--ease), border-color .2s; z-index: 2; }
.chat-search.open { max-height: 60px; opacity: 1; padding: 8px 14px; border-bottom-color: var(--line); }
.chat-search > svg { width: 17px; height: 17px; color: var(--muted); }
.chat-search input { flex: 1; border: 0; background: var(--panel-2); color: var(--text); font: inherit; padding: 8px 12px; border-radius: 10px; }
.chat-search input:focus { outline: 2px solid var(--accent-soft); }
.cs-count { font-size: 12.5px; color: var(--muted); white-space: nowrap; min-width: 54px; text-align: right; }
.dropdown { position: absolute; right: 14px; top: 58px; z-index: 12; min-width: 220px; background: var(--panel); border-radius: 12px; padding: 6px;
  box-shadow: 0 12px 40px rgba(0,0,0,.22); opacity: 0; transform: scale(.9); transform-origin: top right; transition: opacity .14s, transform .2s var(--spring); }
.dropdown.open { opacity: 1; transform: none; }
.dropdown button { position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; color: var(--text);
  font: inherit; font-size: 14.5px; padding: 10px 12px; border-radius: 8px; cursor: pointer; text-align: left; }
.dropdown button:hover { background: var(--panel-2); }
.dropdown svg { width: 18px; height: 18px; color: var(--muted); }
.chat-start { align-self: center; max-width: 440px; text-align: center; font-size: 12.5px; color: #8a6d00; background: #fff6d8; padding: 7px 14px;
  border-radius: 10px; margin: 8px 0 4px; box-shadow: var(--shadow-sm); }
:root[data-theme="dark"] .chat-start { background: #2a2614; color: #e3cf86; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chat-start { background: #2a2614; color: #e3cf86; } }

/* ---------------------------------------------------------------- bubble extras */
.fwd-label { display: flex; align-items: center; gap: 4px; font-size: 12.5px; font-style: italic; color: color-mix(in srgb, currentColor 60%, transparent); margin: 0 0 3px; }
.fwd-label svg { width: 14px; height: 14px; }
.edited { font-style: italic; margin-right: 2px; }
.star-ic { width: 11px; height: 11px; color: color-mix(in srgb, currentColor 70%, transparent); }
.row.has-reacts { margin-bottom: 16px; }
.reacts { position: absolute; bottom: -17px; display: flex; gap: 3px; z-index: 1; }
.row.me .reacts { right: 8px; } .row.them .reacts { left: 8px; }
.react-chip { display: inline-flex; align-items: center; gap: 3px; border: 1px solid var(--line); background: var(--panel); border-radius: 12px;
  padding: 1px 6px; font-size: 14px; cursor: pointer; box-shadow: var(--shadow-sm); transition: transform .2s var(--spring); color: var(--text); line-height: 1.4; }
.react-chip:hover { transform: scale(1.12); }
.react-chip.mine { border-color: var(--accent); background: var(--accent-soft); }
.react-chip b { font-size: 11.5px; color: var(--muted); }
.burst { position: fixed; z-index: 80; pointer-events: none; font-size: 34px; transform: translate(-50%, -50%); animation: burst .9s var(--ease) forwards; }
@keyframes burst { 0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; } 25% { transform: translate(-50%, -70%) scale(1.4); opacity: 1; } 100% { transform: translate(-50%, -160%) scale(.9); opacity: 0; } }

/* message menu: quick reactions */
.react-row { display: flex; gap: 2px; padding: 4px 4px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.react-row button, .react-more button { border: 0; background: none; font-size: 22px; width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; transition: transform .2s var(--spring), background .15s; padding: 0; }
.react-row button:hover, .react-more button:hover { transform: scale(1.25); background: var(--panel-2); }
.react-row button.chosen, .react-more button.chosen { background: var(--accent-soft); }
.react-plus { color: var(--muted); } .react-plus svg { width: 18px; height: 18px; }
.react-more { display: grid; grid-template-columns: repeat(6, 1fr); padding: 2px 4px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; animation: fadeDown .2s var(--ease); }
.msg-menu { min-width: 250px; }

/* ---------------------------------------------------------------- voice / audio player */
.bubble.audio-bubble { width: min(320px, 76vw); padding: 6px 8px 8px; }
.audio-bubble .meta { position: absolute; right: 10px; bottom: 5px; top: auto; float: none; margin: 0; }
.vplayer { display: flex; align-items: center; gap: 8px; padding-bottom: 12px; }
.vp-avatar { position: relative; width: 44px; height: 44px; border-radius: 50%; flex: none; background: var(--accent); color: #fff; display: grid; place-items: center; }
.vp-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.vp-avatar.music { background: color-mix(in srgb, var(--accent) 80%, #000); }
.vp-mic { position: absolute; right: -4px; bottom: -2px; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; border: 2px solid var(--bubble-them); }
.row.me .vp-mic { border-color: var(--bubble-me); }
.vp-mic svg { width: 11px; height: 11px; }
.vp-avatar:not(:has(img)) .vp-mic { position: static; border: 0; width: 26px; height: 26px; }
.vp-avatar:not(:has(img)) .vp-mic svg { width: 18px; height: 18px; }
.vp-play { width: 34px; height: 34px; border: 0; background: none; color: color-mix(in srgb, currentColor 75%, transparent); cursor: pointer; padding: 0; flex: none; display: grid; place-items: center; }
.vp-play svg { width: 26px; height: 26px; }
.vp-play .ic-pause, .vplayer.playing .ic-play { display: none; } .vplayer.playing .ic-pause { display: block; }
.vp-body { flex: 1; min-width: 0; display: grid; gap: 3px; }
.vp-wave { display: flex; align-items: center; gap: 2px; height: 30px; cursor: pointer; }
.vp-wave i { flex: 1; min-width: 2px; border-radius: 2px; background: color-mix(in srgb, currentColor 28%, transparent); transition: background .15s; }
.vp-wave i.on { background: var(--accent); }
.vplayer.playing .vp-wave i.on:last-of-type { animation: none; }
.vp-info { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: color-mix(in srgb, currentColor 60%, transparent); gap: 6px; }
.vp-time { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vp-right { display: inline-flex; align-items: center; gap: 4px; }
.vp-speed { border: 0; background: color-mix(in srgb, currentColor 12%, transparent); color: inherit; font: inherit; font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: 9px; cursor: pointer; }
.vp-dl { color: inherit; display: grid; } .vp-dl svg { width: 15px; height: 15px; }
.row.uploading .vp-avatar { width: 40px; height: 40px; }

/* reply / edit bar + recorder */
.rb-icon { width: 20px; height: 20px; color: var(--accent); flex: none; }
.reply-bar.editing .reply-quote { border-left-color: #f0b429; } .reply-bar.editing .reply-quote b, .reply-bar.editing .rb-icon { color: #c98a00; }
.send.mic { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.send.hidden { display: none !important; }
#sendBtn { animation: popIn .25s var(--spring); } #micBtn { animation: popIn .25s var(--spring); }
@keyframes popIn { from { transform: scale(.5) rotate(-30deg); opacity: 0; } }
.recorder { display: flex; align-items: center; gap: 10px; padding: 8px 10px; animation: fadeUp .25s var(--ease); }
.recorder .icon-btn { color: var(--danger); }
.rec-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--danger); animation: recPulse 1s infinite; flex: none; }
@keyframes recPulse { 50% { opacity: .25; transform: scale(.8); } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 42px; }
#recWave { flex: 1; height: 36px; min-width: 0; }

/* ---------------------------------------------------------------- forward modal */
.fwd-card { width: min(420px, 94vw); padding: 22px 18px 16px; }
.fwd-search { margin: 0; }
.fwd-list { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow-y: auto; }
.fwd-list li { display: flex; align-items: center; gap: 12px; padding: 8px 8px; border-radius: 12px; cursor: pointer; transition: background .15s; }
.fwd-list li:hover { background: var(--panel-2); }
.fwd-list li > span { flex: 1; display: grid; } .fwd-list small { font-size: 12px; }
.fwd-list .check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; color: transparent; transition: all .2s var(--spring); }
.fwd-list .check svg { width: 14px; height: 14px; stroke-width: 3; }
.fwd-list li.sel .check { background: var(--accent); border-color: var(--accent); color: #fff; transform: scale(1.1); }
.fwd-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.fwd-foot span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; }

/* ---------------------------------------------------------------- attachment preview */
.attach-card { width: min(760px, 96vw); height: min(640px, 90vh); background: var(--panel); border-radius: 20px; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow); }
.attach-card header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.attach-card header b { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 16px; background: var(--panel-2); }
.attach-stage img, .attach-stage video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 10px; box-shadow: var(--shadow); animation: tileIn .35s var(--spring); }
.attach-doc { display: grid; justify-items: center; gap: 8px; text-align: center; animation: tileIn .35s var(--spring); }
.doc-icon.big { width: 86px; height: 104px; font-size: 18px; }
.attach-strip { display: flex; gap: 8px; padding: 10px 14px; overflow-x: auto; border-top: 1px solid var(--line); }
.at-thumb { position: relative; width: 58px; height: 58px; border-radius: 10px; flex: none; overflow: hidden; background: var(--panel-3); cursor: pointer;
  display: grid; place-items: center; font-size: 11px; font-weight: 800; color: var(--muted); border: 2px solid transparent; transition: border-color .2s, transform .2s var(--spring); }
.at-thumb.sel { border-color: var(--accent); transform: scale(1.05); }
.at-thumb img { width: 100%; height: 100%; object-fit: cover; }
.at-x { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; padding: 0; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity .15s; }
.at-thumb:hover .at-x { opacity: 1; } .at-x svg { width: 12px; height: 12px; }
.at-add { width: 58px; height: 58px; border-radius: 10px; flex: none; border: 2px dashed var(--line); background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.at-add:hover { border-color: var(--accent); color: var(--accent); }
.attach-foot { display: flex; gap: 10px; align-items: center; padding: 10px 14px 14px; }
.attach-foot input { flex: 1; padding: 12px 16px; border-radius: 22px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; }
.attach-foot input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.attach-n { position: absolute; top: -4px; right: -4px; background: var(--panel); color: var(--accent); font-size: 11px; font-weight: 800; border-radius: 9px; padding: 0 5px; box-shadow: var(--shadow-sm); }
.attach-n:empty { display: none; }
#attachSend { overflow: visible; }

/* ---------------------------------------------------------------- contact info drawer */
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(380px, 100%); background: var(--panel); border-left: 1px solid var(--line); z-index: 15;
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .35s var(--ease), box-shadow .35s; visibility: hidden; }
.drawer.open { transform: none; visibility: visible; box-shadow: -12px 0 40px rgba(0,0,0,.12); }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 17px; }
.drawer-body { flex: 1; overflow-y: auto; background: var(--panel-2); }
.di-top { display: grid; justify-items: center; text-align: center; gap: 2px; padding: 26px 16px 18px; background: var(--panel); }
.di-top .avatar { animation: badgeIn .5s var(--spring); }
.di-top h3 { margin: 12px 0 0; font-size: 21px; }
.di-actions { display: flex; gap: 10px; margin-top: 14px; }
.di-actions button { position: relative; overflow: hidden; display: grid; justify-items: center; gap: 4px; width: 82px; padding: 10px 6px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel); color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; transition: background .2s, transform .2s var(--spring); }
.di-actions button:hover { background: var(--accent-soft); transform: translateY(-2px); }
.di-card { background: var(--panel); margin-top: 8px; padding: 14px 18px; }
.di-card .set-row:last-child { border-bottom: 0; }
.di-label { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
#diAbout { font-size: 15px; margin-bottom: 12px; }
.di-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.di-grid span:nth-child(even) { overflow-wrap: anywhere; }
.di-tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.di-tabs button { flex: 1; border: 0; background: var(--panel-2); color: var(--muted); font: inherit; font-weight: 600; font-size: 13.5px; padding: 8px; border-radius: 10px; cursor: pointer; transition: background .2s, color .2s; }
.di-tabs button.active { background: var(--accent-soft); color: var(--accent); }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.mg-item { position: relative; aspect-ratio: 1; border: 0; padding: 0; border-radius: 8px; overflow: hidden; background: var(--panel-3); cursor: pointer; animation: tileIn .35s var(--spring) both; }
.mg-item img, .mg-item video { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s var(--ease); }
.mg-item:hover img, .mg-item:hover video { transform: scale(1.06); }
.mg-play { position: absolute; inset: 0; margin: auto; width: 34px; height: 34px; border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; display: grid; place-items: center; }
.mg-play svg { width: 16px; height: 16px; }
.doc-line, .link-line { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.doc-line:hover { background: var(--panel-2); }
.doc-line .doc-icon { width: 34px; height: 40px; font-size: 9.5px; }
.dl-main { flex: 1; min-width: 0; display: grid; font-size: 14px; }
.dl-main b, .dl-main a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.dl-main small { font-size: 12px; }
.doc-line > svg { color: var(--muted); width: 18px; height: 18px; }
.link-ic { width: 34px; height: 34px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.link-ic svg { width: 17px; height: 17px; }
@media (min-width: 1280px) {
  .app.drawer-open { grid-template-columns: 68px minmax(300px, 390px) 1fr 380px; }
  .app.drawer-open .drawer { position: static; transform: none; box-shadow: none; visibility: visible; animation: drawerIn .35s var(--ease); }
}
@keyframes drawerIn { from { opacity: 0; transform: translateX(30px); } }

/* ---------------------------------------------------------------- mobile */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .rail { grid-row: 2; flex-direction: row; justify-content: space-around; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); gap: 0;
    border-right: 0; border-top: 1px solid var(--line); background: var(--panel); }
  .rail-logo, .rail-spacer, .rail-me { display: none; }
  .rail-btn { width: auto; flex: 1; height: 54px; border-radius: 12px; grid-template-rows: auto auto; gap: 2px; align-content: center; }
  .rail-btn em { display: block; font-style: normal; font-size: 11px; font-weight: 600; }
  .rail-btn.active { background: none; } .rail-btn.active svg { background: var(--accent-soft); border-radius: 14px; padding: 3px 14px; width: 52px; height: 28px; }
  .rail-btn.active::before { display: none; }
  .rail-badge { right: calc(50% - 26px); top: 2px; }
  .app.in-chat .rail { display: none; }
  .app.in-chat { grid-template-rows: 1fr; }
  .sidebar { grid-row: 1; }
  .drawer { position: fixed; width: 100%; z-index: 25; }
  .dropdown { right: 8px; top: 54px; }
  .panel-head { padding-top: 12px; }
  .attach-card { height: 92vh; border-radius: 16px; }
  .reacts { bottom: -16px; }
}
@media (max-width: 760px) { .chat { grid-row: 1; } }
/* the closed drawer sits off-screen; "clip" stops the page from ever scrolling sideways to it */
.app { overflow: hidden; overflow: clip; }
.di-card .set-row > span, .set-row > span:has(> svg) { display: flex; align-items: center; }
.attach-stage { position: relative; display: block; overflow: hidden; }
.attach-stage img, .attach-stage video { position: absolute; inset: 0; margin: auto; max-width: calc(100% - 32px); max-height: calc(100% - 32px); }
.attach-stage .attach-doc { position: absolute; inset: 0; margin: auto; height: max-content; }
