/* ===================== Banana — Telegram-style UI ===================== */
:root {
  --tg-blue: #5288c1;
  --tg-blue-bright: #3390ec;
  --accent: #50a8eb;
  --send: #6cc04a;
  --online: #4dcd5e;
  --radius: 12px;
  --sidebar-w: 380px;
}

/* ---- Dark theme (default, classic Telegram) ---- */
.theme-dark {
  --bg: #0e1621;
  --bg-chat: #0e1621;
  --panel: #17212b;
  --panel-2: #232e3c;
  --hover: #202b36;
  --active: #2b5278;
  --in-bubble: #182533;
  --out-bubble: #2b5278;
  --divider: #101921;
  --text: #ffffff;
  --text-2: #8a9bad;
  --text-3: #6d7f8f;
  --icon: #6d7f8f;
  --search-bg: #242f3d;
  --shadow: rgba(0, 0, 0, .35);
  --tick: #5fb0e8;
  --pattern-opacity: .14;
}

/* ---- Light theme ---- */
.theme-light {
  --bg: #ffffff;
  --bg-chat: #d6e2ec;
  --panel: #ffffff;
  --panel-2: #f1f1f1;
  --hover: #f4f4f5;
  --active: #419fd9;
  --in-bubble: #ffffff;
  --out-bubble: #effdde;
  --divider: #e6ecf0;
  --text: #000000;
  --text-2: #707991;
  --text-3: #a0acb6;
  --icon: #707991;
  --search-bg: #f4f4f5;
  --shadow: rgba(0, 0, 0, .12);
  --tick: #4fae4e;
  --pattern-opacity: .5;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Roboto', -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
#app { height: 100vh; width: 100vw; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; outline: none; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(120,140,160,.25); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(120,140,160,.45); }
.hidden { display: none !important; }

/* ===================== Auth screen ===================== */
.auth-wrap {
  height: 100%; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.auth-card {
  width: 360px; max-width: 92vw; text-align: center; padding: 24px;
  animation: pop .25s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px);} to {opacity:1; transform:none;} }
.auth-logo {
  width: 160px; height: 160px; margin: 0 auto 20px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #6fb1ff, var(--tg-blue));
  display: flex; align-items: center; justify-content: center; font-size: 90px;
  box-shadow: 0 6px 24px rgba(40,110,180,.5);
}
.auth-card h1 { font-size: 26px; font-weight: 500; margin-bottom: 8px; }
.auth-card p.sub { color: var(--text-2); font-size: 15px; margin-bottom: 26px; line-height: 1.5; }
.field { position: relative; margin-bottom: 16px; text-align: left; }
.field input {
  width: 100%; padding: 15px 16px; font-size: 16px; color: var(--text);
  background: transparent; border: 1px solid var(--panel-2); border-radius: var(--radius);
  transition: border-color .15s;
}
.theme-light .field input { border-color: #cdd6dd; }
.field input:focus { border-color: var(--tg-blue-bright); }
.field label {
  position: absolute; left: 12px; top: 15px; color: var(--text-3); font-size: 16px;
  pointer-events: none; transition: all .15s; padding: 0 4px; background: var(--bg);
}
.field input:focus + label,
.field input:not(:placeholder-shown) + label {
  top: -8px; font-size: 12px; color: var(--tg-blue-bright);
}
.btn-primary {
  width: 100%; padding: 14px; font-size: 15px; font-weight: 500; letter-spacing: .4px;
  text-transform: uppercase; color: #fff; background: var(--tg-blue-bright);
  border-radius: var(--radius); transition: background .15s, opacity .15s;
}
.btn-primary:hover { background: #2b82e0; }
.btn-primary:disabled { opacity: .5; cursor: default; }
.auth-switch { margin-top: 18px; color: var(--text-2); font-size: 14px; }
.auth-switch a { color: var(--tg-blue-bright); cursor: pointer; text-decoration: none; }
.auth-error {
  color: #ec5252; font-size: 13px; min-height: 18px; margin: -4px 0 10px; text-align: left;
}

/* ===================== Layout ===================== */
.layout { display: flex; height: 100%; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--panel);
  border-right: 1px solid var(--divider); display: flex; flex-direction: column;
}
.chat-pane { flex: 1; display: flex; flex-direction: column; background: var(--wallpaper, var(--bg-chat)); position: relative; min-width: 0; }

/* ---- Sidebar header ---- */
.sb-header {
  height: 56px; flex-shrink: 0; display: flex; align-items: center; gap: 8px;
  padding: 0 14px;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; color: var(--icon); transition: background .15s; flex-shrink: 0;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn svg { width: 24px; height: 24px; }
.search-box {
  flex: 1; height: 42px; background: var(--search-bg); border-radius: 21px;
  display: flex; align-items: center; padding: 0 12px; gap: 8px; transition: box-shadow .15s;
}
.search-box.focus { box-shadow: inset 0 0 0 2px var(--tg-blue-bright); background: var(--panel); }
.search-box svg { width: 20px; height: 20px; color: var(--icon); flex-shrink: 0; }
.search-box input { flex: 1; background: none; border: none; color: var(--text); font-size: 15px; }
.search-box input::placeholder { color: var(--text-3); }

/* ---- Chat list ---- */
.chat-list { flex: 1; overflow-y: auto; overflow-x: hidden; }
.chat-item {
  display: flex; align-items: center; gap: 11px; padding: 8px 12px; cursor: pointer;
  position: relative; transition: background .12s;
}
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--active); }
.chat-item.active .ci-time, .chat-item.active .ci-preview,
.chat-item.active .ci-name { color: #fff; }
.chat-item.active .ci-preview b { color: #eaf2fb; }
.avatar {
  width: 54px; height: 54px; border-radius: 50%; flex-shrink: 0; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 21px; font-weight: 500;
  background-size: cover; background-position: center; position: relative; user-select: none;
}
.avatar.sm { width: 40px; height: 40px; font-size: 16px; }
.avatar.lg { width: 120px; height: 120px; font-size: 44px; }
.ci-body { flex: 1; min-width: 0; }
.ci-top, .ci-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ci-name { font-size: 16px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-time { font-size: 12px; color: var(--text-3); flex-shrink: 0; }
.ci-preview { font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.ci-preview b { color: var(--text-2); font-weight: 400; }
.badge {
  min-width: 22px; height: 22px; border-radius: 11px; background: var(--tg-blue);
  color: #fff; font-size: 12px; font-weight: 500; display: flex; align-items: center;
  justify-content: center; padding: 0 7px; flex-shrink: 0;
}
.badge.muted { background: var(--text-3); }
.ci-status-dot {
  position: absolute; bottom: 1px; right: 1px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--online); border: 2.5px solid var(--panel);
}
.chat-item.active .ci-status-dot { border-color: var(--active); }

/* ---- Empty / placeholder ---- */
.empty-pane {
  flex: 1; display: flex; align-items: center; justify-content: center; flex-direction: column;
}
.empty-pill {
  background: var(--panel); color: var(--text-2); padding: 8px 16px; border-radius: 18px;
  font-size: 14px; box-shadow: 0 1px 2px var(--shadow);
}

/* empty-chat greeting card (centered "Say hi!") */
.empty-chat { margin: auto; display: flex; align-items: center; justify-content: center; padding: 20px; }
.empty-card {
  background: var(--panel); border-radius: 16px; padding: 24px 28px; text-align: center;
  max-width: 330px; box-shadow: 0 2px 16px var(--shadow); animation: pop .25s ease;
}
.empty-emoji { font-size: 64px; line-height: 1; margin-bottom: 12px; }
.empty-emoji.greet { cursor: pointer; display: inline-block; transform-origin: 70% 70%; animation: wave 2.6s ease-in-out infinite; }
.empty-emoji.greet:hover { animation: none; transform: scale(1.2); }
.empty-emoji.greet:active { transform: scale(.9); }
@keyframes wave {
  0%, 65%, 100% { transform: rotate(0); }
  10% { transform: rotate(16deg); } 20% { transform: rotate(-8deg); }
  30% { transform: rotate(16deg); } 40% { transform: rotate(-4deg); } 50% { transform: rotate(12deg); }
}
.empty-title { font-size: 18px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.empty-sub { font-size: 14px; color: var(--text-2); line-height: 1.5; }

/* ===================== Chat header ===================== */
.chat-header {
  height: 56px; flex-shrink: 0; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--divider); z-index: 5;
  cursor: pointer;
}
.ch-info { flex: 1; min-width: 0; }
.ch-name { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-status { font-size: 13px; color: var(--text-2); }
.ch-status.online { color: var(--accent); }
.ch-actions { display: flex; gap: 4px; }

/* ===================== Messages ===================== */
.messages {
  flex: 1; overflow-y: auto; padding: 12px 6%; display: flex; flex-direction: column;
  gap: 2px; position: relative;
}
.chat-pane::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22270%22%20height%3D%22270%22%20viewBox%3D%220%200%20270%20270%22%3E%3Cg%20font-size%3D%2246%22%20font-family%3D%22Apple%20Color%20Emoji%2C%20Segoe%20UI%20Emoji%2C%20Noto%20Color%20Emoji%2C%20sans-serif%22%3E%3Ctext%20x%3D%2222%22%20y%3D%2252%22%20transform%3D%22rotate%2812%2022%2040%29%22%3E%F0%9F%8D%8C%3C%2Ftext%3E%3Ctext%20x%3D%22160%22%20y%3D%2244%22%20transform%3D%22rotate%28-32%20160%2032%29%22%3E%F0%9F%8D%8C%3C%2Ftext%3E%3Ctext%20x%3D%2290%22%20y%3D%22140%22%20transform%3D%22rotate%2860%2090%20128%29%22%3E%F0%9F%8D%8C%3C%2Ftext%3E%3Ctext%20x%3D%22200%22%20y%3D%22150%22%20transform%3D%22rotate%28-10%20200%20138%29%22%3E%F0%9F%8D%8C%3C%2Ftext%3E%3Ctext%20x%3D%2234%22%20y%3D%22228%22%20transform%3D%22rotate%28104%2034%20216%29%22%3E%F0%9F%8D%8C%3C%2Ftext%3E%3Ctext%20x%3D%22150%22%20y%3D%22236%22%20transform%3D%22rotate%28-52%20150%20224%29%22%3E%F0%9F%8D%8C%3C%2Ftext%3E%3Ctext%20x%3D%22235%22%20y%3D%22120%22%20transform%3D%22rotate%2828%20235%20108%29%22%3E%F0%9F%8D%8C%3C%2Ftext%3E%3C%2Fg%3E%3C%2Fsvg%3E");
  opacity: var(--pattern-opacity);
}
.messages > * { position: relative; z-index: 1; }
/* anchor messages to the bottom (Telegram-style): with few messages they sit at
   the bottom; when content overflows, the auto margin collapses and scroll works */
.messages > *:first-child { margin-top: auto; }
.date-sep { align-self: center; margin: 10px 0; }
.date-sep span {
  background: rgba(0,0,0,.28); color: #fff; padding: 4px 12px; border-radius: 14px;
  font-size: 13px; font-weight: 500;
}
.theme-light .date-sep span { background: rgba(110,125,140,.55); }

/* secret-chat encryption notice */
.sys-note {
  align-self: center; max-width: 88%; text-align: center; background: rgba(0,0,0,.3);
  color: #e7eef5; font-size: 13px; padding: 8px 16px; border-radius: 12px; margin: 8px 0; line-height: 1.45;
}
.theme-light .sys-note { background: rgba(110,125,140,.5); color: #fff; }
.sys-note.warn { background: rgba(224,83,61,.28); color: #ffd9d2; }

.msg-row { display: flex; max-width: 72%; }
.msg-row.out { align-self: flex-end; flex-direction: row-reverse; }
.msg-row.in { align-self: flex-start; }
.msg-row .row-avatar { width: 33px; flex-shrink: 0; align-self: flex-end; margin-right: 7px; }
.msg-row.out .row-avatar { display: none; }

.bubble {
  position: relative; padding: 6px 11px 7px; border-radius: 12px; font-size: 15px;
  line-height: 1.32; word-wrap: break-word; overflow-wrap: anywhere; max-width: 100%;
  box-shadow: 0 1px 1px var(--shadow); min-width: 56px;
}
.msg-row.in .bubble { background: var(--in-bubble); border-bottom-left-radius: 4px; }
.msg-row.out .bubble { background: var(--out-bubble); border-bottom-right-radius: 4px; }
.theme-light .msg-row.in .bubble { color: #000; }
/* grouped (consecutive same-sender) bubbles share rounding */
.msg-row.grouped { margin-top: 1px; }
.msg-row.grouped.in .bubble { border-top-left-radius: 6px; }
.msg-row.grouped.out .bubble { border-top-right-radius: 6px; }

.bubble .sender { font-size: 14px; font-weight: 500; margin-bottom: 2px; }
.bubble .reply-quote {
  border-left: 2px solid var(--accent); padding: 2px 8px; margin-bottom: 4px;
  background: rgba(255,255,255,.06); border-radius: 4px; font-size: 14px; cursor: pointer;
}
.theme-light .bubble .reply-quote { background: rgba(0,0,0,.04); }
.bubble .reply-quote .rq-name { color: var(--accent); font-weight: 500; }
.bubble .reply-quote .rq-text { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-row.out .reply-quote .rq-text { color: #cfe2f5; }

.bubble .text { white-space: pre-wrap; }
.bubble img.media {
  max-width: 320px; max-height: 320px; width: 100%; border-radius: 8px; display: block;
  margin: -2px -5px 2px; cursor: pointer;
}
.bubble .file-att {
  display: flex; align-items: center; gap: 10px; padding: 4px 0;
}
.bubble .file-att .fi {
  width: 44px; height: 44px; border-radius: 50%; background: var(--accent); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.bubble .file-att .fi svg { width: 24px; height: 24px; color: #fff; }
.bubble .file-att .fmeta { min-width: 0; }
.bubble .file-att .fname { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bubble .file-att .fsize { font-size: 12px; color: var(--text-2); }

.meta {
  float: right; margin: 6px 0 -2px 8px; font-size: 11px; color: var(--text-3);
  display: inline-flex; align-items: center; gap: 3px; user-select: none; line-height: 1;
}
.msg-row.out .meta { color: #93c0e8; }
.theme-light .msg-row.out .meta { color: #5aa86a; }
.meta .edited { font-style: italic; }
.tick { display: inline-flex; }
.tick svg { width: 16px; height: 16px; }
.tick.read { color: var(--tick); }
.tick.sending { color: var(--text-3); }
.tick.sending svg, .tick.failed svg { width: 14px; height: 14px; }
.tick.failed { color: #ec5252; }
.msg-row.failed .bubble { cursor: pointer; }
.bubble .fail-hint { color: #ec5252; font-size: 11px; margin-top: 3px; }

/* mobile back button — driven by the same breakpoint as single-pane mode, not JS */
.mobile-back { display: none; }
@media (max-width: 720px) { .app-mobile-chat .mobile-back { display: flex; } }

/* context menu */
.ctx-menu {
  position: fixed; z-index: 100; background: var(--panel); border-radius: 10px;
  box-shadow: 0 4px 20px var(--shadow); padding: 6px; min-width: 180px;
  animation: pop .12s ease;
}
.ctx-menu button {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px;
  border-radius: 6px; font-size: 15px; color: var(--text); text-align: left;
}
.ctx-menu button:hover { background: var(--hover); }
.ctx-menu button.danger { color: #ec5252; }
.ctx-menu button svg { width: 20px; height: 20px; opacity: .8; }

/* typing indicator */
.typing-dots { display: inline-flex; gap: 3px; align-items: center; }
.typing-dots i {
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
  animation: blink 1.2s infinite both;
}
.typing-dots i:nth-child(2) { animation-delay: .2s; }
.typing-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

/* ===================== Composer ===================== */
.composer {
  flex-shrink: 0; padding: 8px 16px 14px; display: flex; align-items: flex-end; gap: 10px;
  z-index: 5;
}
.composer-inner {
  flex: 1; background: var(--panel); border-radius: 18px; display: flex; align-items: flex-end;
  padding: 4px 6px 4px 8px; box-shadow: 0 1px 2px var(--shadow); min-height: 50px;
}
.composer-inner .icon-btn { width: 38px; height: 38px; }
.composer textarea {
  flex: 1; background: none; border: none; color: var(--text); font-size: 16px;
  resize: none; max-height: 140px; padding: 12px 4px; line-height: 1.3;
}
.composer textarea::placeholder { color: var(--text-3); }
.send-btn {
  width: 50px; height: 50px; border-radius: 50%; background: var(--tg-blue);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: transform .12s, background .15s; color: #fff;
}
.send-btn:hover { background: #4a7fb5; }
.send-btn:active { transform: scale(.92); }
.send-btn svg { width: 26px; height: 26px; }

/* reply / edit bar above composer */
.compose-context {
  flex-shrink: 0; padding: 6px 16px 0;
}
.cc-inner {
  background: var(--panel); border-radius: 8px; padding: 6px 10px; display: flex;
  align-items: center; gap: 10px; border-left: 3px solid var(--accent);
}
.cc-inner .cc-body { flex: 1; min-width: 0; }
.cc-inner .cc-title { color: var(--accent); font-size: 14px; font-weight: 500; }
.cc-inner .cc-text { color: var(--text-2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* emoji picker */
.emoji-pop {
  position: absolute; bottom: 70px; left: 16px; width: 340px; height: 300px; overflow-y: auto;
  background: var(--panel); border-radius: 12px; box-shadow: 0 4px 20px var(--shadow);
  padding: 10px; display: flex; flex-direction: column; z-index: 20; animation: pop .12s ease;
}
.emoji-pop > span { font-size: 26px; cursor: pointer; padding: 4px; border-radius: 8px; line-height: 1; }
.emoji-pop > span:hover { background: var(--hover); }
.ep-pack-name { font-size: 13px; color: var(--text-2); font-weight: 500; padding: 8px 4px 4px; position: sticky; left: 0; }

/* ===================== Modal ===================== */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center;
  justify-content: center; z-index: 200; animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 420px; max-width: 94vw; max-height: 86vh; background: var(--panel);
  border-radius: 12px; box-shadow: 0 8px 40px rgba(0,0,0,.5); display: flex; flex-direction: column;
  animation: pop .18s ease;
}
.modal-head { display: flex; align-items: center; gap: 16px; padding: 16px 20px; }
.modal-head h2 { font-size: 20px; font-weight: 500; flex: 1; }
.modal-body { padding: 4px 20px 20px; overflow-y: auto; }
.modal .search-box { margin-bottom: 8px; }
.modal-input {
  width: 100%; padding: 12px 14px; font-size: 16px; color: var(--text); background: transparent;
  border: 1px solid var(--panel-2); border-radius: 10px; margin-bottom: 14px;
}
.theme-light .modal-input { border-color: #cdd6dd; }
.modal-input:focus { border-color: var(--tg-blue-bright); }
.user-row {
  display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-radius: 8px; cursor: pointer;
}
.user-row:hover { background: var(--hover); }
.user-row .ur-body { flex: 1; min-width: 0; }
.user-row .ur-name { font-size: 16px; }
.user-row .ur-sub { font-size: 13px; color: var(--text-2); }
.user-row .check {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--text-3); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.user-row.selected .check { background: var(--tg-blue-bright); border-color: var(--tg-blue-bright); }
.user-row .check svg { width: 14px; height: 14px; color: #fff; }
.fab-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }

/* drawer menu */
.drawer-bg { position: fixed; inset: 0; z-index: 150; animation: fade .15s ease; }
.drawer {
  position: absolute; top: 0; left: 0; bottom: 0; width: 300px; background: var(--panel);
  box-shadow: 2px 0 16px var(--shadow); animation: slidein .2s ease; padding-bottom: 12px;
}
@keyframes slidein { from { transform: translateX(-100%);} to { transform: none; } }
.drawer-top { padding: 18px 18px 14px; background: linear-gradient(135deg, #2b5278, #1a3a55); }
.theme-light .drawer-top { background: linear-gradient(135deg, #4a9fe0, #3585d4); }
.drawer-top .dn { color: #fff; font-size: 17px; font-weight: 500; margin-top: 10px; }
.drawer-top .du { color: rgba(255,255,255,.8); font-size: 14px; }
.drawer-item {
  display: flex; align-items: center; gap: 22px; padding: 13px 18px; font-size: 15px;
  transition: background .12s; width: 100%; text-align: left;
}
.drawer-item:hover { background: var(--hover); }
.drawer-item svg { width: 22px; height: 22px; color: var(--icon); }
.toggle {
  margin-left: auto; width: 38px; height: 22px; border-radius: 11px; background: var(--panel-2);
  position: relative; transition: background .15s; flex-shrink: 0;
}
.toggle.on { background: var(--tg-blue); }
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform .15s;
}
.toggle.on::after { transform: translateX(16px); }

/* lightbox */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 300; display: flex;
  align-items: center; justify-content: center; animation: fade .15s ease; cursor: zoom-out;
}
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 6px; }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 400;
  background: var(--panel-2); color: var(--text); padding: 11px 18px; border-radius: 10px;
  font-size: 14px; box-shadow: 0 4px 20px var(--shadow); animation: pop .15s ease;
}

/* profile view rows */
.profile-head { display: flex; flex-direction: column; align-items: center; padding: 10px 0 18px; gap: 12px; }
.profile-head .pn { font-size: 20px; font-weight: 500; }
.profile-head .pu { font-size: 14px; color: var(--text-2); }
.info-row { display: flex; gap: 18px; padding: 12px 6px; align-items: flex-start; }
.info-row svg { width: 22px; height: 22px; color: var(--icon); flex-shrink: 0; margin-top: 2px; }
.info-row .ir-label { font-size: 13px; color: var(--accent); }
.info-row .ir-value { font-size: 15px; }

/* ===================== Banana feature styles ===================== */
.avatar { background-size: cover; background-position: center; }

/* floating compose (pencil) button */
.sidebar { position: relative; }
.fab {
  position: absolute; right: 18px; bottom: 18px; width: 56px; height: 56px; border-radius: 50%;
  background: var(--tg-blue); color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,.35); z-index: 8; transition: transform .12s, background .15s;
}
.fab:hover { background: #4a7fb5; }
.fab:active { transform: scale(.9); }
.fab svg { width: 26px; height: 26px; }
.compose-menu { min-width: 222px; }

/* chat folder tabs */
.folder-tabs { display: flex; gap: 2px; padding: 0 8px; overflow-x: auto; border-bottom: 1px solid var(--divider); flex-shrink: 0; }
.folder-tabs::-webkit-scrollbar { height: 0; }
.folder-tab { padding: 9px 12px; font-size: 14px; color: var(--text-2); cursor: pointer; white-space: nowrap; border-bottom: 2px solid transparent; transition: color .12s; }
.folder-tab:hover { color: var(--text); }
.folder-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.folder-tab i { font-style: normal; background: var(--tg-blue); color: #fff; font-size: 11px; padding: 0 5px; border-radius: 9px; margin-left: 3px; vertical-align: 1px; }

/* online dot on the chat-header avatar */
.ch-avatar { position: relative; flex-shrink: 0; }

/* message text formatting */
.bubble .inline-code { font-family: 'Roboto Mono', monospace; background: rgba(0,0,0,.25); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.theme-light .bubble .inline-code { background: rgba(0,0,0,.08); }
.bubble .code-block { font-family: 'Roboto Mono', monospace; background: rgba(0,0,0,.25); padding: 8px 10px; border-radius: 8px; font-size: 13px; white-space: pre-wrap; overflow-x: auto; margin: 3px 0; }
.theme-light .bubble .code-block { background: rgba(0,0,0,.06); }
.bubble .spoiler { background: var(--text-2); color: transparent; border-radius: 4px; cursor: pointer; transition: color .2s; user-select: none; }
.bubble .spoiler.revealed { background: transparent; color: inherit; user-select: text; }
.bubble .mention { color: var(--accent); font-weight: 500; cursor: pointer; }
.msg-row.out .bubble .mention { color: #cfe2f5; }
.bubble.jumbo { background: transparent !important; box-shadow: none !important; padding: 2px 4px; }
.bubble.jumbo .text { font-size: 46px; line-height: 1.1; }
.bubble.jumbo .meta { color: var(--text-2); }

/* forwarded / deleted */
.bubble .fwd { font-size: 13px; color: var(--accent); margin-bottom: 3px; font-style: italic; }
.bubble .fwd b { font-weight: 500; font-style: normal; }
.msg-row.out .bubble .fwd { color: #cfe2f5; }
.bubble.deleted { background: var(--in-bubble); font-style: italic; color: var(--text-2); }
.msg-row.out .bubble.deleted { background: var(--out-bubble); }
.bubble.deleted .del-text { font-size: 14px; }

/* reactions */
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction { display: inline-flex; align-items: center; gap: 3px; background: rgba(0,0,0,.22); border-radius: 12px; padding: 2px 8px; font-size: 14px; cursor: pointer; user-select: none; transition: background .12s; }
.theme-light .reaction { background: rgba(0,0,0,.06); }
.reaction i { font-style: normal; font-size: 12px; color: var(--text-2); }
.reaction.mine { background: var(--tg-blue); }
.reaction.mine i { color: #fff; }
.msg-row.out .reaction { background: rgba(255,255,255,.14); }
.msg-row.out .reaction.mine { background: var(--accent); }

/* react picker row in context menu */
.react-row { display: flex; gap: 2px; padding: 4px 6px 8px; border-bottom: 1px solid var(--divider); margin-bottom: 4px; }
.react-pick { font-size: 22px; cursor: pointer; padding: 4px; border-radius: 8px; line-height: 1; transition: transform .1s; }
.react-pick:hover { transform: scale(1.25); }

/* voice messages */
.voice { display: flex; align-items: center; gap: 10px; min-width: 180px; padding: 2px 0; }
.voice-play { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.msg-row.out .voice-play { background: #fff; color: var(--out-bubble); }
.voice-play svg { width: 22px; height: 22px; }
.voice-wave { flex: 1; height: 4px; background: rgba(255,255,255,.25); border-radius: 2px; position: relative; }
.theme-light .msg-row.in .voice-wave { background: rgba(0,0,0,.15); }
.voice-prog { position: absolute; left: 0; top: 0; bottom: 0; width: 0%; background: var(--accent); border-radius: 2px; }
.msg-row.out .voice-prog { background: #fff; }
.voice-dur { font-size: 12px; color: var(--text-2); }
.msg-row.out .voice-dur { color: #cfe2f5; }

/* polls */
.poll { min-width: 230px; padding: 2px 0; }
.poll-q { font-size: 15px; font-weight: 500; margin-bottom: 2px; }
.poll-sub { font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.msg-row.out .poll-sub { color: #cfe2f5; }
.poll-opt { padding: 5px 0; cursor: pointer; border-bottom: 1px solid rgba(127,127,127,.12); }
.poll-opt-top { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.poll-check { width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--accent); font-size: 13px; flex-shrink: 0; }
.poll-opt.mine .poll-check { background: var(--accent); color: #fff; }
.poll-label { flex: 1; }
.poll-pct { color: var(--text-2); font-size: 13px; }
.poll-bar { height: 4px; background: rgba(127,127,127,.18); border-radius: 2px; margin-top: 4px; }
.poll-bar div { height: 100%; background: var(--accent); border-radius: 2px; transition: width .3s; }
.poll-total { font-size: 12px; color: var(--text-2); margin-top: 8px; text-align: center; }
.poll-chk { display: flex; align-items: center; gap: 10px; margin: 8px 2px; color: var(--text-2); font-size: 15px; }
.poll-opt.correct .poll-bar div { background: var(--send); }
.poll-opt.wrong .poll-bar div { background: #e0533d; }
/* quiz creator correct-answer picker */
.poll-opt-row { display: flex; align-items: center; gap: 8px; }
.poll-opt-row .poll-opt-in { flex: 1; margin-bottom: 8px; }
.poll-correct { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--text-3); flex-shrink: 0; cursor: pointer; margin-bottom: 8px; transition: all .12s; }
.poll-correct.hidden { display: none; }
.poll-correct.on { background: var(--send); border-color: var(--send); box-shadow: inset 0 0 0 3px var(--panel); }
.member-badge { margin-left: auto; font-size: 14px; }

/* pinned bar */
.pinned-bar { display: flex; align-items: center; gap: 10px; padding: 6px 14px; background: var(--panel); border-bottom: 1px solid var(--divider); cursor: pointer; z-index: 4; }
.pin-icn svg { width: 20px; height: 20px; color: var(--accent); }
.pin-body { flex: 1; min-width: 0; border-left: 2px solid var(--accent); padding-left: 8px; }
.pin-title { font-size: 13px; color: var(--accent); font-weight: 500; }
.pin-text { font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* composer extras */
.send-btn.mic-btn { background: var(--tg-blue); }
.composer-inner.readonly { justify-content: center; color: var(--text-2); }
.composer-inner.readonly svg { width: 20px; height: 20px; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #e0533d; animation: pulse 1s infinite; flex-shrink: 0; margin-left: 6px; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
.rec-time { font-size: 15px; color: var(--text); margin-left: 8px; }

/* mention autocomplete */
.mention-pop { position: absolute; bottom: 74px; left: 16px; right: 16px; max-width: 360px; max-height: 220px; overflow-y: auto;
  background: var(--panel); border-radius: 12px; box-shadow: 0 4px 20px var(--shadow); z-index: 20; padding: 6px; animation: pop .12s ease; }
.mention-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.mention-item.active, .mention-item:hover { background: var(--hover); }
.mention-item .mi-name { font-size: 15px; }
.mention-item .mi-user { font-size: 13px; color: var(--text-2); }

/* selection mode */
.msg-row.selected .bubble { box-shadow: 0 0 0 2px var(--accent); }
.sel-box { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--text-3); align-self: center; margin: 0 8px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: #fff; }
.msg-row.selected .sel-box { background: var(--tg-blue); border-color: var(--tg-blue); }
.sel-box svg { width: 14px; height: 14px; }
.select-header { background: var(--panel); }

/* chat list extras */
.ci-mute svg, .mini-mute svg { width: 15px; height: 15px; color: var(--text-3); vertical-align: -2px; }
.mini-mute svg { width: 16px; height: 16px; }
.ci-badges { display: flex; align-items: center; gap: 6px; }
.ci-pin svg { width: 16px; height: 16px; color: var(--text-3); transform: rotate(45deg); }
.archived-row { display: flex; align-items: center; gap: 16px; padding: 12px 16px; cursor: pointer; color: var(--text-2); font-size: 15px; border-bottom: 1px solid var(--divider); }
.archived-row:hover { background: var(--hover); }
.archived-row svg { width: 22px; height: 22px; }
.saved-av { background: linear-gradient(135deg, #5eb5f7, var(--tg-blue)) !important; }

/* settings */
.set-label { color: var(--accent); font-size: 14px; margin: 14px 2px 10px; }
.accent-row { display: flex; gap: 12px; flex-wrap: wrap; }
.accent-dot { width: 34px; height: 34px; border-radius: 50%; cursor: pointer; box-shadow: inset 0 0 0 0 #fff; transition: transform .1s; }
.accent-dot:hover { transform: scale(1.1); }
.accent-dot.sel { box-shadow: 0 0 0 3px var(--panel), 0 0 0 5px currentColor; }
.wp-row { display: flex; gap: 10px; flex-wrap: wrap; }
.wp-opt { padding: 14px 16px; border-radius: 10px; cursor: pointer; font-size: 14px; background: var(--panel-2); border: 2px solid transparent; }
.wp-opt:hover { border-color: var(--accent); }

/* avatar edit */
.avatar-edit { position: relative; cursor: pointer; }
.avatar-cam { position: absolute; right: -2px; bottom: -2px; width: 38px; height: 38px; border-radius: 50%; background: var(--tg-blue); display: flex; align-items: center; justify-content: center; border: 3px solid var(--panel); }
.avatar-cam svg { width: 18px; height: 18px; color: #fff; }

/* stickers + jumbo */
.bubble.sticker-bubble { background: transparent !important; box-shadow: none !important; padding: 0; position: relative; }
.bubble .sticker { font-size: 96px; line-height: 1.05; user-select: none; }
.sticker-meta { position: absolute; right: 6px; bottom: 4px; font-size: 11px; color: var(--text-2); background: rgba(0,0,0,.3); border-radius: 8px; padding: 1px 6px; display: inline-flex; align-items: center; gap: 3px; }
.sticker-reactions { padding: 2px 0; }
.ep-tabs { display: flex; gap: 6px; padding: 0 4px 8px; border-bottom: 1px solid var(--divider); margin-bottom: 6px; position: sticky; top: 0; background: var(--panel); }
.ep-tab { font-size: 14px; padding: 4px 10px; border-radius: 8px; cursor: pointer; color: var(--text-2); }
.ep-tab.active { background: var(--hover); color: var(--text); }
.ep-grid { display: flex; flex-wrap: wrap; gap: 2px; }
.ep-grid span { font-size: 26px; cursor: pointer; padding: 4px; border-radius: 8px; line-height: 1; }
.ep-grid.stickers span { font-size: 40px; }
.ep-grid span:hover { background: var(--hover); }

/* link previews */
.link-preview { display: flex; gap: 10px; margin-top: 6px; padding: 8px 10px; background: rgba(0,0,0,.18); border-radius: 8px; border-left: 3px solid var(--accent); text-decoration: none; color: inherit; }
.theme-light .link-preview { background: rgba(0,0,0,.04); }
.msg-row.out .link-preview { background: rgba(255,255,255,.12); }
.lp-img { width: 56px; height: 56px; border-radius: 6px; background-size: cover; background-position: center; flex-shrink: 0; }
.lp-domain { font-size: 12px; color: var(--accent); font-weight: 500; }
.lp-title { font-size: 14px; font-weight: 500; }
.lp-desc { font-size: 13px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* self-destruct */
.ttl-badge { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; }
.ttl-badge svg { width: 13px; height: 13px; }
.ttl-btn.on { color: var(--send); }

/* stories bar */
.stories-bar { display: flex; gap: 4px; padding: 10px 8px; overflow-x: auto; border-bottom: 1px solid var(--divider); flex-shrink: 0; }
.stories-bar::-webkit-scrollbar { height: 0; }
.story-item { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; width: 64px; flex-shrink: 0; }
.story-ring { width: 56px; height: 56px; border-radius: 50%; padding: 2px; position: relative; }
.story-ring.unseen { background: linear-gradient(135deg, #f5a623, #e8527f, #8774e1); }
.story-ring.seen { background: var(--panel-2); }
.story-ring.add { background: var(--panel-2); }
.story-ring .avatar { width: 100%; height: 100%; border: 2px solid var(--panel); }
.story-add { position: absolute; right: -2px; bottom: -2px; width: 20px; height: 20px; border-radius: 50%; background: var(--tg-blue); border: 2px solid var(--panel); display: flex; align-items: center; justify-content: center; }
.story-add svg { width: 12px; height: 12px; color: #fff; }
.story-name { font-size: 12px; color: var(--text-2); max-width: 62px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* story viewer */
.story-viewer { position: fixed; inset: 0; background: #000; z-index: 350; display: flex; align-items: center; justify-content: center; animation: fade .15s ease; }
.story-viewer .sv-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sv-bars { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; gap: 4px; z-index: 2; }
.sv-bar { flex: 1; height: 3px; background: rgba(255,255,255,.3); border-radius: 2px; overflow: hidden; }
.sv-fill { height: 100%; width: 0; background: #fff; }
.sv-fill.done { width: 100%; }
.sv-fill.active { animation: svgrow 5s linear forwards; }
@keyframes svgrow { from { width: 0; } to { width: 100%; } }
.sv-head { position: absolute; top: 20px; left: 12px; right: 12px; display: flex; align-items: center; gap: 10px; z-index: 2; color: #fff; }
.sv-name { font-weight: 500; }
.sv-time { font-size: 13px; color: rgba(255,255,255,.7); }
.sv-close { margin-left: auto; color: #fff; }
.sv-caption { position: absolute; bottom: 60px; left: 0; right: 0; text-align: center; color: #fff; padding: 0 20px; }
.sv-viewers { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); color: #fff; display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; z-index: 3; }
.sv-viewers svg { width: 18px; height: 18px; }
.sv-nav { position: absolute; top: 0; bottom: 0; width: 40%; z-index: 1; cursor: pointer; }
.sv-prev { left: 0; } .sv-next { right: 0; }

/* call overlay */
.call-overlay { position: fixed; inset: 0; background: rgba(10,20,30,.97); z-index: 360; display: flex; align-items: center; justify-content: center; animation: fade .15s ease; }
.call-box { width: 100%; height: 100%; position: relative; display: flex; align-items: center; justify-content: center; }
.call-remote { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.call-local { position: absolute; right: 18px; top: 18px; width: 140px; height: 190px; object-fit: cover; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,.5); z-index: 2; }
.call-info { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 12px; color: #fff; }
.call-name { font-size: 24px; font-weight: 500; }
.call-status { font-size: 15px; color: rgba(255,255,255,.7); }
.call-actions { position: absolute; bottom: 50px; left: 0; right: 0; display: flex; gap: 28px; justify-content: center; z-index: 3; }
.call-btn { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; }
.call-btn svg { width: 28px; height: 28px; }
.call-btn.accept { background: var(--send); }
.call-btn.hangup { background: #e0533d; }

/* profile action buttons */
.profile-actions { display: flex; gap: 10px; margin: 14px 0; }
.pa-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px; background: var(--panel-2); border-radius: 10px; color: var(--accent); font-size: 13px; }
.pa-btn svg { width: 22px; height: 22px; }
.pa-btn:hover { background: var(--hover); }

/* responsive */
@media (max-width: 720px) {
  :root { --sidebar-w: 100vw; }
  .sidebar { position: absolute; inset: 0; z-index: 10; }
  .chat-pane { position: absolute; inset: 0; z-index: 11; }
  .app-mobile-chat .sidebar { display: none; }
  .app-mobile-list .chat-pane { display: none; }
  .msg-row { max-width: 86%; }
  .mention-pop { left: 8px; right: 8px; }
}
