/* ============================================================
   Whatsgram — "WhatsGram" purple design.
   Deep indigo canvas, violet accent (#7c5cff), Manrope type,
   glassmorphism header, gradient bubbles, doodle wallpaper.
   ============================================================ */

:root[data-theme="dark"] {
  --bg:            #100e15;   /* chat canvas */
  --sidebar-bg:    #16131c;   /* sidebar / cards / modals */
  --header-bg:     rgba(22,19,28,.82);
  --panel-bg:      #100e15;
  --surface:       #241e30;   /* incoming bubble */
  --surface-2:     #1c1925;   /* inputs */
  --surface-hover: #221d2c;
  --surface-3:     #26222f;   /* elevated hover */
  --active:        rgba(124,92,255,.18);
  --in-bubble:     #241e30;
  --out-bubble:    linear-gradient(135deg, #5b3df0 0%, #8b5cf6 100%);
  --out-bubble-hi: #6d4ff2;
  --out-text:      #ffffff;
  --out-meta:      rgba(255,255,255,.74);
  --text:          #f2efff;
  --text-2:        #b8b3c7;
  --text-3:        #7d7790;
  --divider:       rgba(255,255,255,.06);
  --divider-2:     rgba(255,255,255,.10);
  --accent:        #7c5cff;
  --accent-2:      #a78bfa;
  --accent-hi:     #6a4af0;
  --accent-soft:   rgba(124,92,255,.18);
  --link:          #a78bfa;
  --tick:          #7d7790;
  --tick-read:     #a78bfa;
  --badge:         #7c5cff;
  --badge-muted:   #564f68;
  --danger:        #ff5a6b;
  --shadow:        rgba(0,0,0,.7);
  --elev:          0 24px 60px rgba(0,0,0,.6);
  --prem-grad:     linear-gradient(135deg, #ffc24b, #ff8a3c);
  --premium:       #ffb547;
  --wp-op:         1;
}

:root[data-theme="light"] {
  --bg:            #f3f1fb;
  --sidebar-bg:    #ffffff;
  --header-bg:     rgba(255,255,255,.85);
  --panel-bg:      #f3f1fb;
  --surface:       #ffffff;
  --surface-2:     #ece8f7;
  --surface-hover: #efeaf9;
  --surface-3:     #e6e0f5;
  --active:        rgba(124,92,255,.12);
  --in-bubble:     #ffffff;
  --out-bubble:    linear-gradient(135deg, #6d4ff2 0%, #8b5cf6 100%);
  --out-bubble-hi: #7c5cff;
  --out-text:      #ffffff;
  --out-meta:      rgba(255,255,255,.82);
  --text:          #1c1726;
  --text-2:        #6b6480;
  --text-3:        #9d97ad;
  --divider:       rgba(20,10,40,.07);
  --divider-2:     rgba(20,10,40,.12);
  --accent:        #7c5cff;
  --accent-2:      #8b5cf6;
  --accent-hi:     #6a4af0;
  --accent-soft:   rgba(124,92,255,.14);
  --link:          #6d4ff2;
  --tick:          #9d97ad;
  --tick-read:     #7c5cff;
  --badge:         #7c5cff;
  --badge-muted:   #b9b2cc;
  --danger:        #e0322c;
  --shadow:        rgba(60,40,110,.18);
  --elev:          0 20px 50px rgba(60,40,110,.2);
  --prem-grad:     linear-gradient(135deg, #ffc24b, #ff8a3c);
  --premium:       #f59e0b;
  --wp-op:         .6;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01";
}
svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
input, textarea, button { font-family: inherit; }

/* ============ Auth (split hero) ============ */
.auth-screen { height: 100%; display: flex; }
.auth-hero {
  flex: 1.1; position: relative; overflow: hidden; color: #fff;
  background: linear-gradient(150deg, #2a1d52 0%, #3a2570 46%, #5b3df0 130%);
  padding: 56px 60px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-hero::before {
  content: ""; position: absolute; width: 560px; height: 560px;
  right: -180px; top: -140px; border-radius: 50%;
  background: radial-gradient(circle, rgba(167,139,250,.55), transparent 68%);
}
.auth-hero::after {
  content: ""; position: absolute; width: 420px; height: 420px;
  left: -160px; bottom: -160px; border-radius: 50%;
  background: radial-gradient(circle, rgba(124,92,255,.45), transparent 68%);
}
.hero-content { position: relative; z-index: 1; max-width: 470px; }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 46px; }
.brand-mark { width: 46px; height: 46px; }
.brand-name { font-weight: 800; font-size: 24px; letter-spacing: -.5px; }
.hero-title { font-size: 42px; line-height: 1.1; font-weight: 800; letter-spacing: -1px; margin-bottom: 18px; }
.hero-sub { font-size: 17px; line-height: 1.5; color: rgba(255,255,255,.8); max-width: 410px; }
.hero-feats { list-style: none; margin-top: 36px; display: flex; flex-direction: column; gap: 15px; }
.hero-feats li { display: flex; align-items: center; gap: 14px; font-size: 15.5px; color: rgba(255,255,255,.92); }
.hf-ic { width: 36px; height: 36px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.14); border-radius: 11px; font-size: 16px; font-weight: 700; }
.hero-deco { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 9px; max-width: 360px; }
.deco-bubble { padding: 10px 14px; border-radius: 16px; font-size: 14.5px; animation: floatUp .55s ease both; }
.deco-bubble.in { align-self: flex-start; background: rgba(255,255,255,.16); border-bottom-left-radius: 5px; }
.deco-bubble.out { align-self: flex-end; background: rgba(124,92,255,.92); border-bottom-right-radius: 5px; }
.deco-bubble:nth-child(2) { animation-delay: .14s; }
.deco-bubble:nth-child(3) { animation-delay: .28s; }
.db-tick { margin-left: 8px; font-size: 12px; color: #e3dbff; }
@keyframes floatUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.auth-panel { width: 480px; flex-shrink: 0; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; }
.auth-box { width: 340px; max-width: 100%; }
.auth-mark-sm { display: none; width: 58px; height: 58px; margin: 0 auto 18px; }
.auth-h1 { font-size: 27px; font-weight: 800; letter-spacing: -.5px; }
.auth-p { color: var(--text-2); font-size: 14.5px; margin: 6px 0 24px; }
.seg { position: relative; display: flex; background: var(--surface-2); border-radius: 13px; padding: 4px; margin-bottom: 22px; }
.seg button { flex: 1; position: relative; z-index: 1; padding: 10px; border: none; background: none;
  color: var(--text-2); font-size: 14.5px; font-weight: 700; cursor: pointer; border-radius: 10px; transition: color .2s; }
.seg button.active { color: #fff; }
.seg-pill { position: absolute; top: 4px; left: 4px; width: calc(50% - 4px); height: calc(100% - 8px);
  background: var(--accent); border-radius: 10px; z-index: 0; box-shadow: 0 8px 18px -8px rgba(124,92,255,.8);
  transition: transform .25s cubic-bezier(.4,0,.2,1); }
.seg.reg .seg-pill { transform: translateX(100%); }
.field2 { display: flex; align-items: center; gap: 10px; padding: 0 14px;
  background: var(--surface-2); border: 1.5px solid transparent; border-radius: 13px; margin-bottom: 12px; transition: border-color .15s, background .15s; }
.field2:focus-within { border-color: var(--accent); background: var(--surface-3); }
.field2-ic { color: var(--text-3); font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.field2 input { flex: 1; padding: 14px 0; background: none; border: none; outline: none; color: var(--text); font-size: 15px; }
.field2 input::placeholder { color: var(--text-3); }
.auth-foot { margin-top: 28px; color: var(--text-3); font-size: 12.5px; }
.auth-form { display: flex; flex-direction: column; }
.field { position: relative; }
.field input { width: 100%; padding: 14px 16px; background: var(--surface-2); color: var(--text);
  border: 1.5px solid transparent; border-radius: 12px; font-size: 15px; outline: none; transition: border-color .15s; }
.field input:focus { border-color: var(--accent); }
.field input::placeholder { color: var(--text-3); }
.btn-primary { width: 100%; padding: 14px; margin-top: 4px; border: none; border-radius: 12px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); font-size: 15px; font-weight: 700; cursor: pointer;
  box-shadow: 0 12px 26px -10px rgba(124,92,255,.7); transition: filter .15s, transform .1s, box-shadow .2s; }
.btn-primary:hover { filter: brightness(1.06); box-shadow: 0 16px 32px -10px rgba(124,92,255,.85); }
.btn-primary:active { transform: scale(.985); }
.btn-primary:disabled { opacity: .5; cursor: default; box-shadow: none; }
.btn-secondary { width: 100%; padding: 13px; margin-top: 10px; background: var(--surface-2); color: var(--text);
  border: none; border-radius: 12px; font-size: 14.5px; font-weight: 700; cursor: pointer; transition: background .15s; }
.btn-secondary:hover { background: var(--surface-hover); }
.auth-error { color: var(--danger); font-size: 13px; min-height: 16px; text-align: center; margin: 2px 0 10px; }

/* ============ App layout ============ */
.app { height: 100%; display: flex; }

.sidebar {
  width: 360px; min-width: 280px; position: relative;
  display: flex; flex-direction: column;
  background: var(--sidebar-bg); border-right: 1px solid var(--divider);
}
.sidebar-header { padding: 14px 14px 8px; flex-shrink: 0; display: flex; align-items: center; gap: 10px; }
.ham-btn { flex-shrink: 0; border-radius: 12px !important; }

.icon-btn { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 12px; color: var(--text-2); cursor: pointer; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }

/* search pill */
.search-wrap { position: relative; flex: 1; }
.search-wrap.inset { padding: 8px 14px 0; flex: none; }
.search-wrap .search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--text-3); pointer-events: none; }
.search-wrap.inset .search-icon { left: 26px; }
.search-wrap input { width: 100%; padding: 10px 16px 10px 40px; background: var(--surface-2); color: var(--text);
  border: 1.5px solid transparent; border-radius: 12px; outline: none; font-size: 14.5px; font-weight: 500; transition: border-color .15s, background .15s; }
.search-wrap input:focus { border-color: var(--accent-soft); background: var(--surface-3); }
.search-wrap input::placeholder { color: var(--text-3); }
.search-clear { position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-3); font-size: 20px; cursor: pointer; }

/* ============ Chat list ============ */
.chat-list { flex: 1; overflow-y: auto; padding: 4px 8px 84px; }
.chat-item { position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 14px; cursor: pointer; transition: background .12s; }
.chat-item:hover { background: var(--surface-hover); }
.chat-item.active { background: linear-gradient(180deg, rgba(124,92,255,.22), rgba(124,92,255,.13)); }
.chat-item.active::before { content: ""; position: absolute; left: 1px; top: 13px; bottom: 13px; width: 3px; border-radius: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2)); }
.chat-item.active .chat-name { color: var(--text); }
.chat-item.active .chat-time { color: var(--text-2); }

.avatar { width: 54px; height: 54px; flex-shrink: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 19px; position: relative;
  background: var(--accent); overflow: visible;
  box-shadow: 0 6px 18px -10px rgba(0,0,0,.7), inset 0 0 0 1px rgba(255,255,255,.09); }
.avatar.sm { width: 42px; height: 42px; font-size: 15px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar.prem::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; padding: 2px;
  background: var(--prem-grad); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; }
.avatar .online-dot { position: absolute; right: 0; bottom: 0; width: 14px; height: 14px; border-radius: 50%;
  background: #22c55e; border: 3px solid var(--sidebar-bg); }

/* archive row */
.archive-row { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 14px; cursor: pointer; transition: background .12s; }
.archive-row:hover { background: var(--surface-hover); }
.archive-ic { width: 54px; height: 54px; flex-shrink: 0; border-radius: 50%; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; color: var(--text-2); }
.archive-ic svg { width: 24px; height: 24px; }

.chat-main { flex: 1; min-width: 0; }
.chat-top, .chat-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-name { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; }
.chat-time { font-size: 11.5px; font-weight: 600; color: var(--text-3); flex-shrink: 0; }
.chat-snippet { font-size: 13.5px; color: var(--text-3); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.chat-snippet .snip-tick { display: inline-flex; vertical-align: -3px; margin-right: 3px; }
.badge { flex-shrink: 0; min-width: 20px; height: 20px; padding: 0 6px; background: var(--badge); color: #fff; border-radius: 11px;
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin-top: 3px;
  box-shadow: 0 6px 14px -6px rgba(124,92,255,.8); }
.badge.muted { background: var(--badge-muted); box-shadow: none; }

/* compose FAB */
.fab { position: absolute; right: 18px; bottom: 18px; width: 54px; height: 54px; border: none; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 14px 36px -8px rgba(124,92,255,.6), inset 0 0 0 1px rgba(255,255,255,.14); transition: transform .15s, box-shadow .2s; z-index: 5; }
.fab:hover { transform: translateY(-1px); box-shadow: 0 18px 40px -8px rgba(124,92,255,.75), inset 0 0 0 1px rgba(255,255,255,.2); }
.fab:active { transform: scale(.94); }
.fab svg { width: 24px; height: 24px; }

/* ============ Drawer ============ */
.drawer-overlay { position: fixed; inset: 0; z-index: 49; background: rgba(8,6,12,.55); backdrop-filter: blur(4px); animation: fade .15s ease; }
.drawer { position: fixed; top: 0; left: 0; bottom: 0; width: 300px; z-index: 50; background: var(--sidebar-bg);
  display: flex; flex-direction: column; box-shadow: 8px 0 40px rgba(0,0,0,.5); animation: slideIn .22s cubic-bezier(.3,.7,.2,1); }
@keyframes slideIn { from { transform: translateX(-100%); } to { transform: none; } }
.drawer-acc { display: flex; align-items: center; gap: 12px; padding: 20px 16px 18px;
  background: linear-gradient(135deg, #5b3df0, #8b5cf6); color: #fff; cursor: pointer; }
.drawer-acc-av { width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; background: rgba(255,255,255,.2);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.drawer-acc-av img { width: 100%; height: 100%; object-fit: cover; }
.drawer-acc-info { flex: 1; min-width: 0; }
.drawer-acc-name { font-size: 16px; font-weight: 800; display: flex; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-acc-sub { font-size: 13px; color: rgba(255,255,255,.78); margin-top: 2px; }
.drawer-acc #drawer-theme { color: rgba(255,255,255,.9); }
.drawer-acc #drawer-theme:hover { background: rgba(255,255,255,.16); color: #fff; }
.drawer-menu { flex: 1; overflow-y: auto; padding: 8px; }
.drawer-menu button { width: 100%; display: flex; align-items: center; gap: 16px; padding: 12px;
  background: none; border: none; border-radius: 12px; color: var(--text); font-size: 14.5px; font-weight: 600; cursor: pointer; text-align: left; }
.drawer-menu button svg { width: 22px; height: 22px; color: var(--text-2); }
.drawer-menu button:hover { background: var(--surface-hover); }
.drawer-menu button.prem-item svg { color: var(--premium); }
.drawer-menu button.danger, .drawer-menu button.danger svg { color: var(--danger); }
.drawer-foot { padding: 14px 16px; color: var(--text-3); font-size: 12px; border-top: 1px solid var(--divider); }

/* ============ Chat pane ============ */
.chat-pane { flex: 1; display: flex; flex-direction: column; position: relative;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(124,92,255,.10), transparent 60%),
    radial-gradient(80% 60% at 100% 100%, rgba(167,139,250,.06), transparent 70%),
    linear-gradient(180deg, #181425, #241a3a); }
:root[data-theme="light"] .chat-pane { background:
    radial-gradient(120% 90% at 50% 0%, rgba(124,92,255,.10), transparent 60%),
    linear-gradient(180deg, #efeafb, #e7def7); }
.chat-pane::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: var(--wp-op);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cg fill='none' stroke='rgba(167,139,250,0.13)' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 30c0-5 8-7 10-1 2-6 10-4 10 1 0 6-10 12-10 12S16 36 16 30Z'/%3E%3Ccircle cx='80' cy='28' r='8'/%3E%3Cpath d='M68 32c8 3 18 3 24 0'/%3E%3Cpath d='M128 22v12M122 28h12M132 18l-8 8M124 18l8 8'/%3E%3Cpath d='M20 70c0-4 3-7 7-7h14c4 0 7 3 7 7v8c0 4-3 7-7 7H30l-6 5v-5c-2-1-4-3-4-6v-9Z'/%3E%3Cpath d='M80 64l8 10-8 14-8-14 8-10Z'/%3E%3Cpath d='M124 60l8 8-4 12-12 4-8-8 4-12 12-4Zm-4 8a2 2 0 1 0 4 0 2 2 0 0 0-4 0Z'/%3E%3Cpath d='M28 116a8 8 0 1 0 6-14 6 6 0 0 1-6 14Z'/%3E%3Ccircle cx='80' cy='112' r='10'/%3E%3Cpath d='M76 116l3-8 7-4-3 8-7 4Z'/%3E%3Cpath d='M120 100v18M120 100l10-2v18'/%3E%3Ccircle cx='117' cy='118' r='3'/%3E%3Ccircle cx='127' cy='116' r='3'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 150px 150px;
  -webkit-mask-image: linear-gradient(180deg,#000 0%, #000 96%, transparent 100%);
  mask-image: linear-gradient(180deg,#000 0%, #000 96%, transparent 100%);
}
:root[data-theme="light"] .chat-pane::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cg fill='none' stroke='rgba(124,92,255,0.12)' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 30c0-5 8-7 10-1 2-6 10-4 10 1 0 6-10 12-10 12S16 36 16 30Z'/%3E%3Ccircle cx='80' cy='28' r='8'/%3E%3Cpath d='M68 32c8 3 18 3 24 0'/%3E%3Cpath d='M128 22v12M122 28h12M132 18l-8 8M124 18l8 8'/%3E%3Cpath d='M20 70c0-4 3-7 7-7h14c4 0 7 3 7 7v8c0 4-3 7-7 7H30l-6 5v-5c-2-1-4-3-4-6v-9Z'/%3E%3Cpath d='M80 64l8 10-8 14-8-14 8-10Z'/%3E%3Cpath d='M124 60l8 8-4 12-12 4-8-8 4-12 12-4Z'/%3E%3Cpath d='M28 116a8 8 0 1 0 6-14 6 6 0 0 1-6 14Z'/%3E%3Ccircle cx='80' cy='112' r='10'/%3E%3Cpath d='M120 100v18M120 100l10-2v18'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 150px 150px;
}

.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; z-index: 1; }
.empty-pill { font-size: 13px; font-weight: 600; color: #e5dffb; background: rgba(20,15,30,.55); backdrop-filter: blur(10px);
  padding: 8px 18px; border-radius: 18px; }
:root[data-theme="light"] .empty-pill { background: rgba(255,255,255,.85); color: var(--text-2); }

.chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; z-index: 1; }
.chat-header { height: 62px; flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 0 14px 0 16px;
  background: var(--header-bg); backdrop-filter: blur(20px) saturate(140%); -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid var(--divider); }
.chat-header .hdr-click { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center;
  cursor: pointer; border-radius: 10px; padding: 5px 8px; margin-left: -8px; transition: background .12s; height: 48px; }
.chat-header .hdr-click:hover { background: var(--surface-hover); }
.chat-header .hdr-name { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; }
.chat-header .hdr-status { font-size: 12.5px; font-weight: 500; color: var(--text-3); margin-top: 2px; }
.chat-header .hdr-status.online, .chat-header .hdr-status.typing { color: var(--accent-2); }
.chat-header .hdr-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.chat-header .hdr-actions .icon-btn { width: 38px; height: 38px; border-radius: 10px; }
.chat-header #back-btn { display: none; }

/* translate bar */
.translate-bar { flex-shrink: 0; margin: 10px 14px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; position: relative;
  height: 38px; padding: 0 8px 0 14px; border-radius: 12px;
  background: rgba(124,92,255,.10); border: 1px solid rgba(124,92,255,.16); }
.tb-main { display: inline-flex; align-items: center; gap: 8px; color: var(--accent-2); font-size: 13px; font-weight: 600; cursor: pointer; }
.tb-main svg { width: 17px; height: 17px; }
.tb-set { width: 30px; height: 30px; border-radius: 9px; color: var(--accent-2); }
.tb-set svg { width: 18px; height: 18px; }
.translate-bar.on { background: rgba(124,92,255,.18); }

/* messages */
.messages { flex: 1; overflow-y: auto; padding: 16px max(6%, 20px) 12px; display: flex; flex-direction: column; gap: 3px; position: relative; z-index: 1; }
.msg-day { align-self: center; margin: 14px 0 6px; padding: 5px 12px; background: rgba(20,15,30,.55); color: #e5dffb;
  border-radius: 12px; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; backdrop-filter: blur(10px); }
:root[data-theme="light"] .msg-day { background: rgba(255,255,255,.85); color: var(--text-2); }

.msg { max-width: 70%; padding: 7px 12px 7px; border-radius: 16px; position: relative; font-size: 14.5px; line-height: 1.4;
  word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.enter { animation: bubble .2s cubic-bezier(.2,.7,.3,1); }
@keyframes bubble { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg.in  { align-self: flex-start; background: var(--in-bubble); border: 1px solid var(--divider); border-bottom-left-radius: 6px; }
.msg.out { align-self: flex-end; background: var(--out-bubble); color: var(--out-text); border-bottom-right-radius: 6px;
  box-shadow: 0 8px 22px -12px rgba(91,61,240,.7), inset 0 0 0 1px rgba(255,255,255,.05); }
.msg.first-in, .msg.first-out { margin-top: 7px; }
.msg .sender { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 2px; }
.msg .meta { float: right; margin: 6px 0 -2px 8px; font-size: 10.5px; font-weight: 600; color: var(--text-3); display: inline-flex; align-items: center; gap: 4px; }
.msg.out .meta { color: var(--out-meta); }
.msg .meta .tick { display: inline-flex; }
.msg.out .meta .tick { color: var(--out-meta); }
.msg .meta .tick.read { color: var(--tick-read); }
.msg.out .meta .tick.read { color: #e3dbff; }
.tick svg, .snip-tick svg { width: 16px; height: 12px; stroke-width: 1.8; }
.tick.sending svg { width: 13px; height: 13px; opacity: .8; }
.typing-row { align-self: flex-start; }

/* ============ Composer ============ */
.composer { flex-shrink: 0; display: flex; align-items: flex-end; gap: 4px; margin: 8px 14px 14px; padding: 5px 6px 5px 8px;
  background: var(--surface-2); border: 1px solid var(--divider); border-radius: 24px; position: relative; transition: border-color .15s, background .15s; }
.composer:focus-within { border-color: var(--accent-soft); background: var(--surface-3); }
.composer textarea { flex: 1; resize: none; max-height: 130px; padding: 9px 6px; background: none; color: var(--text);
  border: none; outline: none; font-size: 14.5px; font-weight: 500; line-height: 1.4; }
.composer textarea::placeholder { color: var(--text-3); }
.send-btn { width: 44px; height: 44px; flex-shrink: 0; border: none; border-radius: 50%; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  display: flex; align-items: center; justify-content: center; transition: transform .12s, filter .15s;
  box-shadow: 0 10px 24px -10px rgba(124,92,255,.7), inset 0 0 0 1px rgba(255,255,255,.14); }
.send-btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.send-btn:active { transform: scale(.92); }
.send-btn svg { width: 22px; height: 22px; }
.comp-btn { width: 42px; height: 42px; flex-shrink: 0; border-radius: 50%; }
.comp-btn svg { width: 23px; height: 23px; }
#mic-btn { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 10px 24px -10px rgba(124,92,255,.7), inset 0 0 0 1px rgba(255,255,255,.14); }
#mic-btn:hover { transform: translateY(-1px); }

.rec-bar { position: absolute; inset: 0; display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-radius: 24px; background: var(--surface-3); }
.rec-cancel { color: var(--danger); }
.rec-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--danger); animation: blink 1.1s infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.rec-time { font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 700; }
.rec-hint { color: var(--text-2); font-size: 14px; flex: 1; }
.rec-bar .send-btn { color: #fff; }

/* ============ Attachments ============ */
.msg.media { padding: 4px; position: relative; }
.msg.media .meta { float: none; position: absolute; right: 10px; bottom: 9px; margin: 0;
  background: rgba(0,0,0,.45); color: #fff !important; padding: 2px 7px; border-radius: 10px; z-index: 2; backdrop-filter: blur(4px); }
.msg.media .meta .tick { color: #fff !important; }
.msg-image { display: block; max-width: 280px; max-height: 340px; width: 100%; border-radius: 12px; cursor: pointer; object-fit: cover; }
.msg.media .caption { padding: 5px 7px 2px; }
.msg-file { display: flex; align-items: center; gap: 12px; padding: 5px 6px; min-width: 200px; }
.file-ic { width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center; color: #fff; }
.file-ic svg { width: 22px; height: 22px; }
.msg.out .file-ic { background: rgba(255,255,255,.2); }
.file-meta { min-width: 0; }
.file-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.file-size { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.msg.out .file-size { color: var(--out-meta); }
.msg a.file-dl { color: inherit; text-decoration: none; }
.msg-voice { display: flex; align-items: center; gap: 11px; padding: 4px; min-width: 210px; }
.voice-play { width: 42px; height: 42px; flex-shrink: 0; border: none; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center; }
.msg.out .voice-play { background: rgba(255,255,255,.25); color: #fff; }
.voice-play svg { width: 20px; height: 20px; fill: currentColor; stroke: none; }
.voice-body { flex: 1; }
.voice-track { height: 4px; border-radius: 2px; background: rgba(127,127,127,.35); position: relative; cursor: pointer; }
.msg.out .voice-track { background: rgba(255,255,255,.3); }
.voice-fill { position: absolute; left: 0; top: 0; height: 100%; width: 0; border-radius: 2px; background: var(--accent-2); }
.msg.out .voice-fill { background: #fff; }
.voice-dur { font-size: 12px; color: var(--text-2); margin-top: 5px; font-variant-numeric: tabular-nums; }
.msg.out .voice-dur { color: var(--out-meta); }

/* ============ Rich profile view (info-card style) ============ */
.profile-modal-rich { width: 400px; }
.profile-view { padding: 0; }
.pv-hero { position: relative; padding: 30px 20px 20px; text-align: center; }
.pv-actions-top { position: absolute; top: 14px; right: 14px; display: flex; gap: 4px; }
.pv-actions-top .icon-btn { color: var(--text-2); border-radius: 10px; }
.pv-avatar { width: 104px; height: 104px; margin: 0 auto 14px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 40px; font-weight: 700; overflow: hidden; position: relative;
  box-shadow: 0 18px 40px -16px rgba(0,0,0,.6), inset 0 0 0 1px rgba(255,255,255,.08); }
.pv-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pv-name { font-size: 22px; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 6px; }
.pv-status { font-size: 13px; color: var(--text-3); margin-top: 4px; display: inline-flex; align-items: center; gap: 6px; }
.pv-status.online { color: var(--accent-2); }
.pv-status .warn { color: var(--premium); display: inline-flex; }
.pv-status .warn svg { width: 15px; height: 15px; }
.pv-quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 4px 16px 16px; }
.pv-quick button { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 12px 4px;
  background: var(--surface-2); border: 1px solid var(--divider); border-radius: 14px; color: var(--text-2); font-size: 11.5px; font-weight: 600; cursor: pointer; transition: background .12s, color .12s; }
.pv-quick button:hover { background: var(--surface-hover); color: var(--text); }
.pv-quick button svg { width: 22px; height: 22px; color: var(--accent-2); }
.pv-section { border-top: 8px solid var(--bg); padding: 8px 0; }
.pv-row { display: flex; align-items: flex-start; gap: 14px; padding: 10px 18px; cursor: default; }
.pv-row.tap { cursor: pointer; }
.pv-row.tap:hover { background: var(--surface-hover); }
.pv-row .pv-ic { width: 22px; flex-shrink: 0; color: var(--text-3); display: flex; justify-content: center; padding-top: 2px; }
.pv-row .pv-body { flex: 1; min-width: 0; }
.pv-row .pv-value { font-size: 14.5px; font-weight: 600; color: var(--text); word-break: break-word; }
.pv-row .pv-value.link { color: var(--accent-2); }
.pv-row .pv-label { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.pv-row .pv-trail { color: var(--text-3); flex-shrink: 0; align-self: center; }
.pv-row .pv-count { color: var(--text-2); font-size: 14px; font-weight: 600; align-self: center; }
.pv-row.danger .pv-value, .pv-row.danger .pv-ic { color: var(--danger); }
.pv-stories { border-top: 8px solid var(--bg); padding: 26px 18px; text-align: center; color: var(--text-3); font-size: 13.5px; }
.group-count { padding: 4px 18px 8px; color: var(--text-2); font-size: 13px; }

/* ============ Settings ============ */
.settings-modal-box { width: 420px; }
.settings-head { border-bottom: none; }
.settings-head .head-actions { display: flex; align-items: center; gap: 2px; }
.settings-scroll { overflow-y: auto; }
.settings-card { display: flex; align-items: center; gap: 14px; padding: 6px 18px 18px; }
.settings-card .sc-av { width: 60px; height: 60px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 24px; font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.settings-card .sc-av img { width: 100%; height: 100%; object-fit: cover; }
.settings-card .sc-info { flex: 1; min-width: 0; }
.settings-card .sc-name { font-size: 18px; font-weight: 800; display: flex; align-items: center; }
.settings-card .sc-sub { font-size: 13.5px; color: var(--text-2); margin-top: 2px; }
.settings-card .sc-sub b { color: var(--text); font-weight: 600; }
.settings-group { border-top: 8px solid var(--bg); padding: 6px 0; }
.set-item { width: 100%; display: flex; align-items: center; gap: 16px; padding: 11px 18px; background: none; border: none;
  color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer; text-align: left; }
.set-item:hover { background: var(--surface-hover); }
.set-item .si-ic { width: 28px; height: 28px; flex-shrink: 0; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--text-2); }
.set-item .si-ic svg { width: 19px; height: 19px; }
.set-item .si-ic.accent { background: var(--accent-soft); color: var(--accent-2); }
.set-item .si-ic.gold { background: rgba(255,181,71,.16); color: var(--premium); }
.set-item .si-ic.danger { background: rgba(255,90,107,.14); color: var(--danger); }
.set-item .si-val { margin-left: auto; color: var(--accent-2); font-size: 14px; font-weight: 600; }
.set-item .si-chevron { margin-left: auto; color: var(--text-3); display: inline-flex; }
.set-item .si-val + .si-chevron { margin-left: 8px; }
.set-item .si-chevron svg { width: 19px; height: 19px; }
.settings-head #settings-title { flex: 1; }
.settings-back svg { width: 22px; height: 22px; }

/* ============ Image viewer ============ */
.img-viewer { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; animation: fade .15s ease; }
.img-viewer img { max-width: 92vw; max-height: 90vh; border-radius: 10px; }
.iv-close { position: absolute; top: 18px; right: 22px; color: #fff; font-size: 30px; }

/* ============ Modals ============ */
.modal-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(8,6,12,.55); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { width: 420px; max-width: 94vw; max-height: 88vh; background: var(--sidebar-bg); border-radius: 20px;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--elev), 0 0 0 1px var(--divider-2); animation: pop .18s cubic-bezier(.2,.8,.2,1); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98);} to {opacity:1;transform:none;} }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 14px; }
.modal-header h3 { font-size: 18px; font-weight: 800; }
.modal-close { border-radius: 10px !important; font-size: 26px; line-height: 1; font-weight: 400; }
.modal-close, .pv-actions-top .modal-close, .search-clear, .iv-close { font-weight: 400; }
.search-clear { font-size: 24px; }
.modal-field { padding: 12px 18px 0; }
.modal-field label { display: block; font-size: 12px; font-weight: 700; color: var(--text-3); margin-bottom: 6px; padding-left: 2px; letter-spacing: .04em; text-transform: uppercase; }
.modal-action { width: calc(100% - 36px); margin: 16px 18px; }

.user-list { overflow-y: auto; padding: 6px; flex: 1; min-height: 80px; }
.user-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px; cursor: pointer; transition: background .12s; }
.user-item:hover { background: var(--surface-hover); }
.user-item .ui-main { flex: 1; min-width: 0; }
.user-item .ui-name { font-size: 15px; font-weight: 600; display: flex; align-items: center; }
.user-item .ui-sub { font-size: 13px; color: var(--text-2); }
.user-item .check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--text-3);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.user-item.selected .check { background: var(--accent); border-color: var(--accent); }
.user-item .check svg { width: 13px; height: 13px; color: #fff; opacity: 0; }
.user-item.selected .check svg { opacity: 1; }
.empty-hint { text-align: center; color: var(--text-3); padding: 24px; font-size: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 8px 18px 0; }
.chip { display: flex; align-items: center; gap: 6px; padding: 5px 8px 5px 5px; background: var(--surface-2); border-radius: 16px; font-size: 13px; font-weight: 600; }
.chip .avatar { width: 24px; height: 24px; font-size: 11px; box-shadow: none; }
.chip .x { cursor: pointer; color: var(--text-3); font-size: 16px; line-height: 1; }

.create-avatar { text-align: center; padding: 18px 0 8px; }
.create-avatar-circle { width: 100px; height: 100px; margin: 0 auto; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center; overflow: hidden; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 40px; font-weight: 700; position: relative; }
.create-avatar-circle img { width: 100%; height: 100%; object-fit: cover; }
.create-avatar-circle svg { width: 34px; height: 34px; opacity: .9; }
.create-avatar-hint { color: var(--accent-2); font-size: 13px; font-weight: 600; margin-top: 8px; cursor: pointer; }
#profile-avatar { width: 96px; height: 96px; margin: 0 auto; }
.profile-username { text-align: center; color: var(--text-2); font-size: 14px; padding: 6px 0 2px; }

/* ============ Scrollbars ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.16); }
:root[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(20,10,40,.12); }
.chat-list::-webkit-scrollbar-thumb, .messages::-webkit-scrollbar-thumb { background: transparent; }
.chat-list:hover::-webkit-scrollbar-thumb, .messages:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); }

/* ============ Badges & emoji status ============ */
.prem-badge { display: inline-flex; vertical-align: -3px; margin-left: 4px; width: 18px; height: 18px;
  align-items: center; justify-content: center; color: var(--premium); flex-shrink: 0;
  filter: drop-shadow(0 1px 3px rgba(255,138,60,.45)); }
.prem-badge svg { width: 16px; height: 16px; }
.prem-badge.has-emoji { width: auto; height: auto; font-size: .95em; filter: none; }
.prem-badge.self { cursor: pointer; transition: transform .12s, filter .12s; }
.prem-badge.self:hover { transform: scale(1.12); filter: brightness(1.12) drop-shadow(0 1px 4px rgba(255,138,60,.6)); }
.prem-badge.has-emoji img.emoji { width: 1.05em; height: 1.05em; vertical-align: -.18em; }
.emoji-st { margin-left: 4px; font-size: .92em; }

/* emoji-status picker popover */
.status-picker { width: 290px; padding: 8px; }
.status-picker .sp-head { font-size: 11px; font-weight: 700; color: var(--text-3); padding: 4px 6px 8px; text-transform: uppercase; letter-spacing: .06em; }
.status-picker .emoji-grid { grid-template-columns: repeat(6, 1fr); }
.status-picker .emoji-grid button { font-size: 24px; padding: 6px 0; border-radius: 10px; background: none; border: none; cursor: pointer; }
.status-picker .emoji-grid button:hover { background: var(--surface-hover); }
.status-picker .sp-clear { width: 100%; margin-top: 6px; padding: 9px; border: none; border-radius: 10px; background: var(--surface-2); color: var(--text-2); font-weight: 600; cursor: pointer; }
.status-picker .sp-clear:hover { background: var(--surface-hover); }

/* ============ Emoji / sticker panel ============ */
.emoji-panel { position: absolute; bottom: 60px; right: 6px; width: 344px; max-width: calc(100vw - 28px); height: 320px;
  background: var(--sidebar-bg); border: 1px solid var(--divider-2); border-radius: 18px; box-shadow: var(--elev);
  display: flex; flex-direction: column; overflow: hidden; z-index: 30; animation: pop .14s ease; }
.ep-tabs { display: flex; border-bottom: 1px solid var(--divider); flex-shrink: 0; padding: 0 6px; }
.ep-tabs button { flex: 1; padding: 13px; background: none; border: none; color: var(--text-3); font-size: 13.5px; font-weight: 700; cursor: pointer; border-bottom: 2px solid transparent; transition: color .12s; }
.ep-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.ep-body { flex: 1; overflow-y: auto; padding: 8px; }
.emoji-cat-title { font-size: 11px; font-weight: 700; color: var(--text-3); padding: 8px 4px 4px; text-transform: uppercase; letter-spacing: .06em; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); }
.emoji-grid button { background: none; border: none; font-size: 23px; padding: 5px 0; cursor: pointer; border-radius: 9px; line-height: 1.2; }
.emoji-grid button:hover { background: var(--surface-hover); }
.sticker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.sticker-grid button { background: none; border: none; font-size: 46px; padding: 8px 0; cursor: pointer; border-radius: 14px; transition: background .12s, transform .1s; }
.sticker-grid button:hover { background: var(--surface-hover); transform: scale(1.05); }
.sticker-pack-title { font-size: 12px; font-weight: 700; color: var(--text-3); padding: 10px 4px 4px; display: flex; align-items: center; gap: 6px; }
.sticker-locked { opacity: .45; }
.sticker-lock-note { text-align: center; color: var(--text-2); font-size: 13px; padding: 8px; }

.msg.sticker { background: transparent !important; box-shadow: none; border: 0 !important; padding: 0; max-width: 50%; }
.sticker-emoji { font-size: 84px; line-height: 1; display: block; filter: drop-shadow(0 14px 24px rgba(0,0,0,.35)); }
.msg.sticker .meta { float: none; display: inline-flex; color: #fff !important; margin: 6px 0 0; align-self: flex-end;
  background: rgba(20,15,30,.55); backdrop-filter: blur(8px); padding: 4px 8px; border-radius: 10px; }

.prem-chip { display: inline-block; font-size: 10.5px; font-weight: 800; color: #fff; background: var(--prem-grad);
  padding: 2px 7px; border-radius: 8px; margin-left: 6px; vertical-align: 1px; }
.status-pick { width: 100%; text-align: left; padding: 13px 14px; background: var(--surface-2); border: 1.5px solid transparent;
  border-radius: 12px; color: var(--text); font-size: 15px; cursor: pointer; }
.status-pick:hover { border-color: var(--accent); }

/* ============ Premium modal ============ */
.premium-modal { width: 420px; }
.premium-hero { text-align: center; padding: 30px 20px 18px; background: linear-gradient(150deg, #ffc24b, #ff8a3c); color: #fff; position: relative; overflow: hidden; }
.premium-hero::after { content: ""; position: absolute; inset: 0; background: radial-gradient(80% 120% at 50% -10%, rgba(255,255,255,.35), transparent 60%); }
.premium-star { font-size: 54px; line-height: 1; filter: drop-shadow(0 6px 14px rgba(0,0,0,.25)); position: relative; }
.premium-star svg { width: 58px; height: 58px; }
.premium-title { font-size: 24px; font-weight: 800; margin-top: 8px; position: relative; }
.premium-sub { font-size: 14px; opacity: .95; margin-top: 4px; position: relative; }
.premium-feats { padding: 16px 18px 4px; display: flex; flex-direction: column; gap: 4px; }
.pf { display: flex; align-items: center; gap: 14px; padding: 10px; border-radius: 12px; }
.pf:hover { background: var(--surface-hover); }
.pf-ic { width: 42px; height: 42px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--surface-2); border-radius: 12px; font-size: 19px; }
.pf b { display: block; font-size: 14.5px; font-weight: 700; }
.pf span { display: block; font-size: 12.5px; color: var(--text-2); margin-top: 1px; }

/* ============ Channel locked composer ============ */
.locked-note { flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 18px;
  color: var(--text-2); font-size: 14px; }
.locked-note svg { width: 17px; height: 17px; }

/* ============ Message actions ============ */
.msg-menu-btn { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border: none; border-radius: 50%; cursor: pointer; padding: 0;
  background: rgba(10,8,16,.45); color: #fff; opacity: 0; display: flex; align-items: center; justify-content: center; transition: opacity .12s, background .12s; z-index: 3; backdrop-filter: blur(4px); }
.msg:hover .msg-menu-btn { opacity: .9; }
.msg-menu-btn:hover { background: rgba(10,8,16,.7); }
.msg-menu-btn svg { width: 15px; height: 15px; }
.msg.sticker .msg-menu-btn { background: rgba(10,8,16,.55); }

.reply-quote { display: block; border-left: 3px solid var(--accent-2); cursor: pointer; padding: 5px 10px; margin: 0 0 6px; border-radius: 8px;
  background: rgba(124,92,255,.12); max-width: 280px; }
.rq-name { display: block; font-size: 12px; font-weight: 700; color: var(--accent-2); }
.rq-text { display: block; font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg.out .reply-quote { background: rgba(255,255,255,.14); border-left-color: rgba(255,255,255,.75); }
.msg.out .rq-name { color: #fff; }
.msg.out .rq-text { color: rgba(255,255,255,.85); }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.reaction { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; padding: 2px 8px; border: none; border-radius: 13px; font-size: 14px;
  background: rgba(127,127,127,.2); color: var(--text); transition: transform .1s, filter .12s; }
.reaction span { font-size: 12px; font-weight: 700; }
.reaction.mine { background: var(--accent); color: #fff; }
.msg.out .reaction { background: rgba(255,255,255,.18); color: #fff; }
.msg.out .reaction.mine { background: rgba(255,255,255,.34); color: #fff; }
.reaction:hover { filter: brightness(1.08); }
.reaction:active { transform: scale(.92); }
.meta .edited { opacity: .8; font-style: italic; }

.msg.flash { animation: flashring 1.25s ease; }
@keyframes flashring { 0%, 100% { box-shadow: 0 1px 1px rgba(0,0,0,.18); } 25% { box-shadow: 0 0 0 3px var(--accent); } }

/* context menu */
.ctx-menu { position: fixed; z-index: 300; min-width: 200px; background: var(--sidebar-bg); border: 1px solid var(--divider-2); border-radius: 16px; padding: 6px; box-shadow: var(--elev); animation: pop .12s ease; }
.ctx-react { display: flex; gap: 2px; padding: 3px 2px 7px; margin-bottom: 5px; border-bottom: 1px solid var(--divider); }
.ctx-react button { flex: 1; background: none; border: none; font-size: 21px; cursor: pointer; padding: 5px 0; border-radius: 9px; transition: transform .1s, background .12s; }
.ctx-react button:hover { background: var(--surface-hover); transform: scale(1.25); }
.ctx-item { width: 100%; display: flex; align-items: center; gap: 13px; cursor: pointer; padding: 10px 12px; background: none; border: none; border-radius: 11px; color: var(--text); font-size: 14px; font-weight: 600; text-align: left; }
.ctx-item svg { width: 18px; height: 18px; color: var(--text-2); }
.ctx-item:hover { background: var(--surface-hover); }
.ctx-item.danger, .ctx-item.danger svg { color: var(--danger); }

/* composer reply/edit context */
.composer-context { display: flex; align-items: center; gap: 8px; margin: 0 14px; padding: 9px 14px; background: var(--surface-2); border-radius: 14px 14px 0 0; }
.cc-bar { flex: 1; min-width: 0; border-left: 3px solid var(--accent-2); padding: 1px 10px; }
.cc-title { font-size: 13px; font-weight: 700; color: var(--accent-2); }
.cc-text { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-context + .composer { margin-top: 4px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); z-index: 400;
  background: #2a2440; color: #fff; padding: 12px 22px; border-radius: 14px; font-size: 14px; font-weight: 600; box-shadow: var(--elev); animation: toastIn .2s ease; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translateX(-50%); } }

/* ============ Folder tabs ============ */
.folder-tabs { display: flex; gap: 4px; padding: 2px 10px 6px; overflow-x: auto; flex-shrink: 0; scrollbar-width: none; }
.folder-tabs::-webkit-scrollbar { display: none; }
.folder-tab { flex-shrink: 0; padding: 7px 13px; background: none; border: none; border-radius: 10px;
  color: var(--text-3); font-size: 12.5px; font-weight: 700; cursor: pointer; white-space: nowrap; transition: background .12s, color .12s; }
.folder-tab:hover { background: var(--surface-hover); color: var(--text); }
.folder-tab.active { color: var(--text); background: var(--surface-2); }

/* mute icon in chat row */
.mute-ic { display: inline-flex; vertical-align: -3px; margin-right: 3px; color: var(--text-3); }
.mute-ic svg { width: 15px; height: 15px; }

/* ============ In-chat search ============ */
.chat-search { flex-shrink: 0; display: flex; align-items: center; gap: 6px; padding: 8px 12px;
  background: var(--header-bg); backdrop-filter: blur(20px); border-bottom: 1px solid var(--divider); }
.chat-search .search-wrap { flex: 1; }
.cs-count { font-size: 13px; color: var(--text-2); flex-shrink: 0; min-width: 18px; text-align: center; }
.chat-search-results { flex-shrink: 0; max-height: 40%; overflow-y: auto; background: var(--sidebar-bg);
  border-bottom: 1px solid var(--divider); z-index: 2; }
.cs-row { padding: 10px 16px; cursor: pointer; border-bottom: 1px solid var(--divider); }
.cs-row:hover { background: var(--surface-hover); }
.cs-who { font-size: 12.5px; font-weight: 600; color: var(--accent-2); }
.cs-text { font-size: 14px; color: var(--text); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============ Gift message (Telegram-style, centered) ============ */
.msg.gift-msg { align-self: center !important; background: transparent !important; box-shadow: none; border: 0 !important; padding: 0; max-width: 340px; width: 100%; }
.gift-card { position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 7px;
  padding: 26px 26px 20px; border-radius: 22px;
  background: linear-gradient(165deg, #2e2552 0%, #1d1730 100%); border: 1px solid rgba(167,139,250,.22); box-shadow: 0 22px 50px -20px rgba(91,61,240,.7); }
.gift-shine { position: absolute; top: -40%; left: -30%; width: 160%; height: 120%; pointer-events: none;
  background: radial-gradient(50% 50% at 50% 50%, rgba(167,139,250,.28), transparent 70%); }
.gift-visual { width: 116px; height: 116px; display: flex; align-items: center; justify-content: center; position: relative;
  filter: drop-shadow(0 12px 22px rgba(0,0,0,.4)); animation: giftPop .4s cubic-bezier(.2,.9,.3,1.3); }
@keyframes giftPop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.gift-visual img { width: 104px; height: 104px; }
.gift-visual .raw { font-size: 88px; line-height: 1; }
.gift-title { font-size: 16px; font-weight: 800; color: var(--text); position: relative; }
.gift-from { font-size: 13px; color: var(--text-2); position: relative; }
.gift-note { font-size: 13px; font-weight: 700; color: var(--premium); position: relative; }
.gift-sub { font-size: 13px; font-weight: 600; color: var(--accent-2); position: relative; margin-top: 4px; }
.gift-actions { display: flex; gap: 8px; margin-top: 10px; position: relative; width: 100%; }
.gift-act { flex: 1; padding: 10px 12px; border: none; border-radius: 14px; font-size: 13px; font-weight: 700; cursor: pointer; transition: filter .12s, background .12s; }
.gift-act.profile { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 8px 20px -10px rgba(124,92,255,.8); }
.gift-act.sell { background: rgba(255,255,255,.1); color: var(--text); }
.gift-act:hover { filter: brightness(1.08); }
.gift-act:disabled, .gift-act.done { opacity: .85; cursor: default; filter: none; }
.msg.gift-msg .meta { display: block; text-align: center; color: var(--text-3) !important; margin: 6px 0 0; float: none; }

/* profile gifts grid */
.pv-section-head { display: flex; align-items: center; gap: 8px; padding: 4px 18px 8px; color: var(--text-3); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.pv-section-head svg { width: 18px; height: 18px; }
.pv-section-count { background: var(--surface-2); color: var(--text-2); border-radius: 8px; padding: 1px 7px; font-size: 11px; }
.pv-gifts { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 6px; }
.pv-gift { width: 56px; height: 56px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--divider);
  display: flex; align-items: center; justify-content: center; }
.pv-gift .raw { font-size: 32px; line-height: 1; }
.pv-gift img.emoji { width: 34px; height: 34px; }

/* ============ Gift picker modal ============ */
.gift-bal { padding: 6px 18px 0; color: var(--text-2); font-size: 13.5px; }
.gift-bal b { color: var(--text); }
.gift-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 12px 16px 18px; }
.gift-grid button { background: var(--surface-2); border: 1px solid var(--divider); border-radius: 16px; font-size: 38px; padding: 10px 0; cursor: pointer; transition: transform .1s, background .12s; }
.gift-grid button:hover { background: var(--surface-hover); transform: scale(1.06); }

/* ============ Stars modal ============ */
.stars-hero { text-align: center; padding: 28px 20px 8px; }
.stars-big { font-size: 62px; line-height: 1; color: var(--premium); filter: drop-shadow(0 6px 16px rgba(255,181,71,.45)); }
.stars-big svg { width: 64px; height: 64px; }
.stars-count { font-size: 34px; font-weight: 800; margin-top: 6px; }
.stars-sub { color: var(--text-2); font-size: 14px; margin-top: 4px; }
.stars-packs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 14px 18px 18px; }
.star-pack { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 14px; background: var(--surface-2);
  border: 1px solid var(--divider); border-radius: 16px; cursor: pointer; transition: background .12s, transform .1s; }
.star-pack:hover { background: var(--surface-hover); transform: translateY(-1px); }
.sp-amt { font-size: 16px; font-weight: 800; color: var(--premium); }
.sp-price { font-size: 13px; color: var(--text-2); font-weight: 600; }

/* ============ Settings switch ============ */
.set-item .si-label { flex: 1; }
.switch { width: 40px; height: 23px; border-radius: 12px; background: var(--surface-3); position: relative; flex-shrink: 0; transition: background .18s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%; background: #fff; transition: transform .18s; box-shadow: 0 2px 4px rgba(0,0,0,.3); }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(17px); }

/* ============ Folders management ============ */
.folders-list { padding: 6px; max-height: 50vh; overflow-y: auto; }
.folder-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; }
.folder-row:hover { background: var(--surface-hover); }
.folder-row-name { font-size: 15px; font-weight: 600; flex: 1; }
.folder-row-count { font-size: 13px; color: var(--text-2); }
.fr-edit svg, .fr-del svg { width: 18px; height: 18px; }
.fr-del { color: var(--danger); }

/* ============ @mentions ============ */
.mention { color: var(--accent-2); font-weight: 700; cursor: pointer; }
.mention:hover { text-decoration: underline; }
.msg.out .mention { color: #fff; text-decoration: underline; text-underline-offset: 2px; }

/* ============ Translation line ============ */
.tr-line { display: block; margin-top: 5px; padding-top: 5px; border-top: 1px dashed currentColor;
  font-size: 14px; opacity: .85; }
.msg.in .tr-line { border-color: rgba(255,255,255,.18); }
.translate-bar.on .tb-main { color: var(--accent-2); font-weight: 700; }

/* ============ Call overlay ============ */
.call-overlay { position: fixed; inset: 0; z-index: 350; display: flex; align-items: center; justify-content: center;
  background: rgba(8,6,16,.72); backdrop-filter: blur(10px); animation: fade .15s ease; }
.call-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--sidebar-bg); padding: 40px 46px 32px; border-radius: 26px; box-shadow: var(--elev), 0 0 0 1px var(--divider-2); min-width: 300px; }
.call-min { position: absolute; top: 14px; left: 14px; color: var(--text-2); }
.call-mini { position: fixed; right: 18px; bottom: 18px; z-index: 360; display: flex; align-items: center; gap: 10px;
  padding: 8px; background: var(--sidebar-bg); border: 1px solid var(--divider-2); border-radius: 18px; box-shadow: var(--elev); cursor: pointer; animation: pop .15s ease; }
.call-mini-av { width: 42px; height: 42px; border-radius: 50%; overflow: hidden; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; background: var(--accent); flex-shrink: 0; }
.call-mini-av img { width: 100%; height: 100%; object-fit: cover; }
.call-mini-info { min-width: 0; padding-right: 6px; }
.call-mini-name { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.call-mini-timer { font-size: 12px; font-weight: 600; color: var(--accent-2); font-variant-numeric: tabular-nums; }
.call-mini-btn { width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer; color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.call-mini-btn.hang { background: var(--danger); }
.call-mini-btn.hang svg { width: 20px; height: 20px; transform: rotate(135deg); }
.call-avatar { width: 110px; height: 110px; border-radius: 50%; overflow: hidden; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 44px; font-weight: 700; background: var(--accent); box-shadow: 0 0 0 0 rgba(124,92,255,.5); animation: callpulse 1.8s infinite; }
.call-avatar img { width: 100%; height: 100%; object-fit: cover; }
@keyframes callpulse { 0% { box-shadow: 0 0 0 0 rgba(124,92,255,.5); } 70% { box-shadow: 0 0 0 22px rgba(124,92,255,0); } 100% { box-shadow: 0 0 0 0 rgba(124,92,255,0); } }
.call-name { font-size: 22px; font-weight: 800; margin-top: 6px; }
.call-status { font-size: 14px; color: var(--text-2); }
.call-timer { font-size: 15px; color: var(--accent-2); font-variant-numeric: tabular-nums; font-weight: 700; }
.call-actions { display: flex; gap: 20px; margin-top: 24px; }
.call-btn { width: 60px; height: 60px; border-radius: 50%; border: none; cursor: pointer; color: #fff;
  display: flex; align-items: center; justify-content: center; transition: transform .12s, filter .12s; }
.call-btn:hover { filter: brightness(1.1); }
.call-btn:active { transform: scale(.92); }
.call-btn svg { width: 26px; height: 26px; }
.call-btn.accept { background: #22c55e; }
.call-btn.decline { background: var(--danger); }
.call-btn.decline svg { transform: rotate(135deg); }
.call-btn.mute { background: var(--surface-3); color: var(--text); }
.call-btn.mute.off { background: var(--danger); color: #fff; }

/* ============ Apple emoji images ============ */
img.emoji { width: 1.3em; height: 1.3em; vertical-align: -0.28em; margin: 0 .02em; object-fit: contain; }
.sticker-emoji img.emoji, .msg.sticker img.emoji { width: 96px; height: 96px; vertical-align: middle; margin: 0; }
.emoji-grid img.emoji { width: 27px; height: 27px; vertical-align: middle; }
.sticker-grid img.emoji { width: 58px; height: 58px; vertical-align: middle; }
.gift-grid img.emoji { width: 40px; height: 40px; vertical-align: middle; }
.gift-visual img.emoji { width: 76px; height: 76px; }
.emoji-st img.emoji, .prem-chip img.emoji { width: 1em; height: 1em; vertical-align: -.15em; }
.chat-name img.emoji, .hdr-name img.emoji, .pv-name img.emoji, .drawer-acc-name img.emoji, .sc-name img.emoji, .ui-name img.emoji { width: 1.1em; height: 1.1em; vertical-align: -.2em; }
.hf-ic img.emoji, .field2-ic img.emoji, .pf-ic img.emoji { width: 1em; height: 1em; vertical-align: -.15em; }

/* ============ Settings card (clickable) + prompt modal ============ */
.settings-card { cursor: pointer; border-radius: 14px; margin: 0 8px 8px; padding: 12px 14px; transition: background .15s var(--ease); }
.settings-card:hover { background: var(--surface-hover); }
.settings-card .sc-chevron { margin-left: auto; color: var(--text-3); display: inline-flex; align-self: center; }
.settings-card .sc-chevron svg { width: 20px; height: 20px; }
.prompt-modal { width: 380px; }
.prompt-input { width: 100%; padding: 13px 14px; background: var(--surface-2); color: var(--text);
  border: 1.5px solid transparent; border-radius: 12px; font-size: 15px; font-weight: 500; outline: none; transition: border-color .15s; }
.prompt-input:focus { border-color: var(--accent); }
.prompt-input::placeholder { color: var(--text-3); }

/* ============ Smooth motion (high-refresh feel) ============ */
:root { --ease: cubic-bezier(.22,.61,.36,1); --ease-out: cubic-bezier(.16,1,.3,1); }
/* GPU-friendly: animate transform/opacity, hint the compositor on movers. */
.modal, .ctx-menu, .drawer, .call-card, .call-mini, .emoji-panel, .status-picker, .toast { will-change: transform, opacity; }
.send-btn, #mic-btn, .fab, .avatar, .gift-visual { will-change: transform; }
/* Consistent snappy easing + press feedback on tappables. */
.chat-item, .user-item, .set-item, .folder-tab, .pv-row.tap, .pv-quick button,
.gift-act, .star-pack, .reaction, .drawer-menu button, .ctx-item, .folder-row {
  transition: background .14s var(--ease), color .14s var(--ease), transform .12s var(--ease), filter .15s var(--ease), box-shadow .2s var(--ease);
}
.chat-item:active, .user-item:active, .set-item:active, .drawer-menu button:active, .ctx-item:active { transform: scale(.985); }
.icon-btn:active, .comp-btn:active { transform: scale(.86); }
.btn-primary { transition: filter .15s var(--ease), transform .12s var(--ease), box-shadow .2s var(--ease); }
.btn-primary:active, .gift-act:active, .pv-quick button:active, .star-pack:active { transform: scale(.96); }
.fab:active { transform: scale(.9); }
.seg-pill { transition: transform .28s var(--ease-out); }
.wg-info, .switch, .switch::after { transition: all .2s var(--ease); }

/* ============ Reduce animations ============ */
:root[data-noanim] *, :root[data-noanim] *::before, :root[data-noanim] *::after {
  animation-duration: .001s !important; transition-duration: .001s !important;
}

/* ============ Responsive ============ */
@media (max-width: 1100px) { .sidebar { width: 320px; } }
@media (max-width: 920px) {
  .auth-hero { display: none; }
  .auth-panel { width: 100%; flex: 1; }
  .auth-mark-sm { display: block; }
}
@media (max-width: 720px) {
  .sidebar { width: 100%; position: absolute; inset: 0; z-index: 20; }
  .app.chat-open .sidebar { display: none; }
  .chat-pane { width: 100%; }
  .chat-header #back-btn { display: flex; }
  .drawer { width: 86%; max-width: 320px; }
}
