  /* Telegram Desktop Dark Theme */
  :root, .theme-dark {
    --bg-chat: #0e1621;
    --bg-primary: #17212b;
    --bg-secondary: #242f3d;
    --bg-hover: #202b36;
    --bg-input: #17212b;
    --bubble-in: #182533;
    --bubble-out: #2b5278;
    --text-primary: #ffffff;
    --text-secondary: #708499;
    --text-link: #6ab3f3;
    --accent: #6ab3f3;
    --accent-dark: #4a9eeb;
    --check-read: #6ab3f3;
    --border: #0e1621;
    --date-bg: #263040;
    --sidebar-width: 340px;
    --drawer-width: 280px;
    --header-height: 56px;
    --green: #4dcd5e;
    --chat-pattern: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  }

  .theme-light {
    --bg-chat: #8e9aa8;
    --bg-primary: #ffffff;
    --bg-secondary: #f0f2f5;
    --bg-hover: #f4f4f5;
    --bg-input: #f0f2f5;
    --bubble-in: #ffffff;
    --bubble-out: #effdde;
    --text-primary: #000000;
    --text-secondary: #707579;
    --text-link: #3390ec;
    --accent: #3390ec;
    --border: #e6e6e6;
    --date-bg: rgba(0,0,0,.25);
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  html, body, #app {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
  }

  body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
  }

  .hidden { display: none !important; }
  .muted { color: var(--text-secondary); font-size: 13px; }
  .link-text { color: var(--text-link); }
  .status-text { color: var(--text-link); font-size: 13px; }

  /* AUTH */
  .auth-screen {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-chat);
    padding: 20px;
  }

  .auth-card {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 32px 28px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0,0,0,.4);
  }

  .auth-logo { text-align: center; margin-bottom: 24px; }
  .auth-logo-img {
    width: 96px;
    height: 96px;
    border-radius: 22px;
    object-fit: cover;
    display: inline-block;
    box-shadow: 0 8px 28px rgba(176, 38, 255, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.06);
  }
  .auth-logo h1 { font-size: 26px; margin-top: 14px; font-weight: 500; }
  .auth-logo p { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

  .auth-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 20px;
  }

  .auth-tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
  }
  .auth-tab.active { background: var(--bg-hover); color: var(--accent); }

  .auth-form label { display: block; font-size: 13px; color: var(--text-secondary); margin: 12px 0 4px; }
  .auth-form label:first-child { margin-top: 0; }
  .auth-form input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--bg-secondary);
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
  }
  .auth-form input:focus { border-color: var(--accent); }
  .auth-form small { display: block; font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

  .btn-primary {
    width: 100%;
    margin-top: 20px;
    padding: 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
  }
  .btn-primary:hover { background: var(--accent-dark); }

  .btn-link {
    width: 100%;
    margin-top: 8px;
    padding: 8px;
    border: none;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font-size: 14px;
  }
  .auth-forgot-link { margin-top: 12px; text-align: center; }

  .verify-hint { font-size: 14px; color: var(--text-secondary); margin-bottom: 12px; text-align: center; }
  .auth-error { margin-top: 12px; padding: 10px; background: #3d2020; color: #ff8a80; border-radius: 8px; font-size: 13px; text-align: center; }

  /* MESSENGER */
  .messenger {
    display: flex;
    height: 100dvh;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    background: var(--bg-chat);
    position: relative;
  }

  /* Drawer — выезжает поверх списка чатов как в TG */
  .drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 80;
    transition: opacity .25s;
  }
  .drawer-overlay.hidden { opacity: 0; pointer-events: none; }

  .drawer {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--drawer-width);
    background: var(--bg-primary);
    z-index: 90;
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    box-shadow: 4px 0 24px rgba(0,0,0,.45);
  }
  .messenger:not(.drawer-open) .drawer { transform: translateX(-100%); pointer-events: none; }
  .messenger.drawer-open .sidebar { pointer-events: none; }

  .drawer-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 14px 14px;
    cursor: pointer;
    background: var(--bg-primary);
    position: relative;
    flex-shrink: 0;
  }
  .drawer-profile:hover { background: var(--bg-hover); }

  .drawer-user { flex: 1; min-width: 0; }
  .drawer-user strong {
    display: block;
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .drawer-status-link {
    font-size: 13px;
    color: var(--text-link);
    text-decoration: none;
    display: block;
    margin-top: 2px;
  }
  .drawer-gear {
    position: absolute;
    top: 14px;
    right: 8px;
    color: var(--text-secondary);
  }

  .drawer-divider {
    height: 1px;
    background: rgba(255,255,255,.06);
    margin: 4px 0;
  }

  .drawer-nav { flex: 1; overflow-y: auto; }

  .drawer-item {
    display: flex;
    align-items: center;
    gap: 18px;
    width: 100%;
    padding: 11px 20px;
    border: none;
    background: transparent;
    font-size: 15px;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
  }
  .drawer-item:hover { background: var(--bg-hover); }
  .drawer-item .di { width: 24px; height: 24px; color: var(--text-secondary); flex-shrink: 0; }

  .drawer-toggle { justify-content: flex-start; }
  .drawer-toggle .toggle { margin-left: auto; }

  .drawer-footer {
    padding: 12px 20px 20px;
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .drawer-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }
  .drawer-brand img {
    border-radius: 6px;
    object-fit: cover;
  }
  .version-tag {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 400;
    opacity: 0.85;
  }
  .drawer-link {
    border: none;
    background: none;
    color: var(--text-link);
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    padding: 0;
  }

  /* Toggle */
  .toggle { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
  .toggle input { opacity: 0; width: 0; height: 0; }
  .toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-secondary);
    border-radius: 12px;
    cursor: pointer;
    transition: .2s;
  }
  .toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    left: 3px; top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: .2s;
  }
  .toggle input:checked + .toggle-slider { background: var(--accent); }
  .toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

  /* Sidebar */
  .sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    z-index: 2;
  }

  .sidebar-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    height: var(--header-height);
    background: var(--bg-primary);
    flex-shrink: 0;
  }

  .search-wrap { flex: 1; position: relative; }
  .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
  }
  .search-wrap input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: none;
    border-radius: 20px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
  }
  .search-wrap input::placeholder { color: var(--text-secondary); }

  .icon-btn {
    width: 40px; height: 40px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s, color .15s;
  }
  .icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
  .send-icon { color: var(--accent) !important; }

  .chat-list { flex: 1; overflow-y: auto; }
  .chat-list-empty { padding: 40px 20px; text-align: center; }

  .chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    cursor: pointer;
    transition: background .12s;
    border-left: 3px solid transparent;
  }
  .chat-item:hover { background: var(--bg-hover); }
  .chat-item.active {
    background: var(--bg-hover);
    border-left-color: var(--accent);
  }
  .chat-item.active strong { color: var(--accent); }
  .chat-item.has-unread .chat-preview.unread,
  .chat-item.has-unread .chat-time.unread {
    color: var(--text-primary);
    font-weight: 500;
  }

  .chat-item-info { flex: 1; min-width: 0; }
  .chat-item-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
  .chat-item-top strong { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chat-item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 2px;
  }
  .chat-time { font-size: 12px; color: var(--text-secondary); flex-shrink: 0; }
  .chat-preview {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
  }
  .chat-unread {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .search-results {
    border-bottom: 1px solid var(--border);
    max-height: 260px;
    overflow-y: auto;
    background: var(--bg-primary);
  }
  .search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
  }
  .search-item:hover { background: var(--bg-hover); }

  /* Avatar */
  .avatar {
    width: 54px; height: 54px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 500;
    font-size: 20px;
    flex-shrink: 0;
    position: relative;
    user-select: none;
  }
  .avatar.medium { width: 48px; height: 48px; font-size: 18px; }
  .avatar.small { width: 42px; height: 42px; font-size: 16px; }
  .avatar.xlarge { width: 120px; height: 120px; font-size: 44px; }
  .avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    background: transparent;
  }

  .avatar.online::after {
    content: '';
    position: absolute;
    bottom: 1px; right: 1px;
    width: 12px; height: 12px;
    background: var(--green);
    border: 2px solid var(--bg-primary);
    border-radius: 50%;
  }

  /* Chat area */
  .chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-chat);
  }

  .empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-chat);
    background-image: var(--chat-pattern);
  }
  .empty-state-inner {
    text-align: center;
    max-width: 320px;
    padding: 24px;
  }
  .empty-state-icon { color: var(--accent); margin-bottom: 16px; }
  .empty-state-title {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 8px;
  }
  .empty-state-hint {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.45;
  }

  .active-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .chat-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px 0 4px;
    height: var(--header-height);
    background: var(--bg-primary);
    flex-shrink: 0;
  }

  .chat-header-main {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    text-align: left;
    min-width: 0;
    color: var(--text-primary);
  }
  .chat-header-main:hover { background: var(--bg-hover); }

  .chat-header-info strong {
    display: block;
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .chat-header-normal {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
  }

  .chat-header-actions { display: flex; align-items: center; gap: 2px; }
  #call-btn { color: var(--text-primary); display: flex !important; }

  .chat-menu-wrap { position: relative; }

  .chat-menu-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 200px;
    background: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    padding: 6px 0;
    z-index: 30;
  }

  .chat-menu-item {
    display: block;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
  }

  .chat-menu-item:hover { background: var(--bg-hover); }
  .chat-menu-item.danger { color: #e53935; }

  .chat-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    padding: 0 8px;
  }

  .chat-search-bar input {
    flex: 1;
    min-width: 0;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 18px;
    padding: 8px 14px;
    font-size: 15px;
    outline: none;
  }

  .chat-search-bar input::placeholder { color: var(--text-muted); }

  .chat-search-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
  }

  .chat-search-count {
    font-size: 13px;
    color: var(--text-muted);
    min-width: 48px;
    text-align: center;
  }

  .message .search-hit {
    background: rgba(255, 213, 79, 0.35);
    border-radius: 2px;
    padding: 0 1px;
  }

  .msg-row.search-active .message {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  .messages-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    background-color: var(--bg-chat);
    background-image: var(--chat-bg-image, var(--chat-pattern));
    background-size: cover;
    background-position: center;
    background-repeat: repeat;
  }

  .messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    -webkit-overflow-scrolling: touch;
  }

  /* Message rows */
  .msg-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 85%;
  }
  .msg-row.incoming { align-self: flex-start; }
  .msg-row.outgoing { align-self: flex-end; flex-direction: row-reverse; }

  .msg-row .avatar.tiny {
    width: 34px; height: 34px;
    font-size: 13px;
    margin-bottom: 2px;
  }

  .message {
    padding: 6px 10px 5px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.35;
    word-wrap: break-word;
    position: relative;
    max-width: 100%;
  }

  .message.incoming {
    background: var(--bubble-in);
    border-bottom-left-radius: 4px;
  }
  .message.outgoing {
    background: var(--bubble-out);
    border-bottom-right-radius: 4px;
  }

  html.has-chat-bg .message.incoming {
    background: rgba(24, 37, 51, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
  html.has-chat-bg .message.outgoing {
    background: rgba(43, 82, 120, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
  html.theme-light.has-chat-bg .message.incoming {
    background: rgba(255, 255, 255, 0.75);
  }
  html.theme-light.has-chat-bg .message.outgoing {
    background: rgba(239, 253, 222, 0.75);
  }

  .message-body { display: inline; }

  .message-footer {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    float: right;
    margin-left: 8px;
    margin-top: 4px;
    position: relative;
    top: 4px;
  }

  .message-time {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
  }

  .msg-checks {
    display: inline-flex;
    color: var(--check-read);
    line-height: 0;
  }
  .msg-checks.sent-only {
    color: rgba(255, 255, 255, 0.45);
  }
  .theme-light .message.outgoing .msg-checks.sent-only {
    color: rgba(0, 0, 0, 0.35);
  }
  .message.incoming .msg-checks { display: none; }
  .msg-checks svg { width: 16px; height: 11px; }

  .msg-status {
    display: inline-flex;
    align-items: center;
    line-height: 0;
  }

  .msg-spinner {
    width: 12px;
    height: 12px;
    border: 1.5px solid var(--text-secondary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: msg-spin .65s linear infinite;
    display: inline-block;
    opacity: 0.75;
  }

  .message.outgoing .msg-spinner {
    border-color: rgba(255, 255, 255, 0.45);
    border-top-color: transparent;
  }

  .msg-failed {
    font-size: 12px;
    font-weight: 700;
    color: #e17076;
    width: 12px;
    height: 12px;
    justify-content: center;
  }

  @keyframes msg-spin {
    to { transform: rotate(360deg); }
  }

  .message-image,
  .message-image-btn {
    max-width: 280px;
    max-height: 360px;
    border-radius: 8px;
    display: block;
    cursor: pointer;
    margin-bottom: 2px;
  }

  /* Call log message */
  .message-call-inner {
    text-align: center;
    min-width: 200px;
  }
  .message-call {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 6px 0;
  }

  /* Voice message — Telegram style */
  .message-voice .message-body,
  .message-voice-inner {
    display: block;
    min-width: 220px;
  }

  .message-voice.message,
  .message:has(.voice-player) {
    min-width: 240px;
    max-width: 320px;
    padding: 7px 10px 5px;
  }

  .voice-player {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .voice-play-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    width: 42px;
  }

  .voice-play {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    transition: background .15s, transform .1s;
  }
  .voice-play:active { transform: scale(0.94); }
  .voice-play svg { width: 20px; height: 20px; margin-left: 2px; display: block; }

  .message.outgoing .voice-play {
    background: #6ab3f3;
  }
  .message.outgoing .voice-play:hover {
    background: #7bbef5;
  }

  .message.incoming .voice-play {
    background: #5288c1;
  }
  .message.incoming .voice-play:hover {
    background: #5e95cf;
  }

  .voice-dur {
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1;
    white-space: nowrap;
    width: 100%;
  }

  .message.outgoing .voice-dur { color: rgba(255, 255, 255, 0.9); }
  .message.incoming .voice-dur { color: #6ab3f3; }

  .voice-unread-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #6ab3f3;
    display: inline-block;
    flex-shrink: 0;
  }

  .voice-wave-col {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    min-height: 42px;
  }

  .voice-wave {
    display: flex;
    align-items: center;
    gap: 1.5px;
    height: 28px;
    width: 100%;
  }

  .voice-wave span {
    display: block;
    width: 2px;
    min-height: 4px;
    border-radius: 1px;
    flex-shrink: 0;
    transform-origin: center center;
    transition: background .1s ease;
  }

  .message.outgoing .voice-wave span {
    background: rgba(255, 255, 255, 0.35);
  }
  .message.outgoing .voice-wave span.played {
    background: rgba(255, 255, 255, 0.95);
  }
  .message.incoming .voice-wave span {
    background: rgba(106, 179, 243, 0.3);
  }
  .message.incoming .voice-wave span.played {
    background: rgba(106, 179, 243, 0.9);
  }

  .voice-player.is-playing .voice-wave span:not(.played) {
    animation: voiceBarPulse 0.9s ease-in-out infinite;
  }
  .voice-player.is-playing .voice-wave span.active {
    animation: voiceBarActive 0.28s ease-in-out infinite alternate;
  }

  .voice-wave span:nth-child(4n+1) { animation-delay: 0s; }
  .voice-wave span:nth-child(4n+2) { animation-delay: .07s; }
  .voice-wave span:nth-child(4n+3) { animation-delay: .14s; }
  .voice-wave span:nth-child(4n+4) { animation-delay: .21s; }

  @keyframes voiceBarPulse {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.45); }
  }

  @keyframes voiceBarActive {
    0% { transform: scaleY(0.85); }
    100% { transform: scaleY(1.25); }
  }

  .message-voice .message-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    float: none;
    clear: both;
    margin-top: 2px;
    margin-left: 0;
    top: 0;
    gap: 3px;
  }

  .message.outgoing.message-voice .message-time {
    color: rgba(255, 255, 255, 0.5);
  }
  .message.outgoing.message-voice .msg-checks {
    color: rgba(255, 255, 255, 0.55);
  }
  .message.outgoing.message-voice .msg-checks.sent-only {
    color: rgba(255, 255, 255, 0.45);
  }
  .message.outgoing.message-voice .msg-status .msg-spinner {
    border-color: rgba(255, 255, 255, 0.45);
    border-top-color: transparent;
  }
  .message.incoming.message-voice .message-time {
    color: rgba(112, 132, 153, 0.9);
  }

  .hidden-audio { display: none; }

  .message-actions {
    display: none;
    position: absolute;
    top: 2px; right: 2px;
  }
  .message.outgoing:hover .message-actions { display: block; }
  @media (hover: none) { .message.outgoing .message-actions { display: block; opacity: .5; } }

  .msg-delete-btn {
    border: none;
    background: rgba(0,0,0,.3);
    color: #fff;
    width: 20px; height: 20px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
  }

  .date-divider {
    align-self: center;
    background: var(--date-bg);
    color: var(--text-primary);
    font-size: 13px;
    padding: 4px 12px;
    border-radius: 14px;
    margin: 10px 0 6px;
    opacity: .9;
  }

  .typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 16px 8px;
    font-size: 13px;
    color: var(--text-link);
  }
  .typing-dots { display: flex; gap: 3px; }
  .typing-dots i {
    display: block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: typingBounce 1.2s infinite;
  }
  .typing-dots i:nth-child(2) { animation-delay: .2s; }
  .typing-dots i:nth-child(3) { animation-delay: .4s; }
  @keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30% { transform: translateY(-4px); opacity: 1; }
  }

  /* Composer */
  .composer {
    flex-shrink: 0;
    background: var(--bg-input);
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    position: sticky;
    bottom: 0;
    z-index: 2;
    transform: translateY(calc(-1 * var(--keyboard-offset, 0px)));
  }

  .composer-inner {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    background: var(--bg-secondary);
    border-radius: 24px;
    padding: 4px 6px 4px 4px;
  }

  .composer-field {
    flex: 1;
    min-height: 44px;
    display: flex;
    align-items: flex-end;
    background: transparent;
    border-radius: 20px;
    padding: 0 4px;
  }

  .composer-field textarea {
    width: 100%;
    padding: 11px 4px;
    border: none;
    background: transparent;
    resize: none;
    font-family: inherit;
    font-size: 15px;
    max-height: 120px;
    outline: none;
    line-height: 1.4;
    color: var(--text-primary);
  }
  .composer-field textarea::placeholder { color: var(--text-secondary); }

  /* Emoji picker */
  .emoji-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    max-height: 320px;
    display: flex;
    flex-direction: column;
    z-index: 20;
    box-shadow: 0 -4px 16px rgba(0,0,0,.25);
  }

  .emoji-tabs {
    display: flex;
    gap: 2px;
    padding: 6px 8px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .emoji-tab {
    border: none;
    background: transparent;
    font-size: 20px;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
  }
  .emoji-tab:hover { background: var(--bg-hover); }
  .emoji-tab.active { background: var(--bg-secondary); }

  .emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 8px;
    overflow-y: auto;
    flex: 1;
  }

  .emoji-item {
    border: none;
    background: transparent;
    font-size: 26px;
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
    line-height: 1;
  }
  .emoji-item:hover { background: var(--bg-hover); }

  .composer { position: relative; }

  .composer.emoji-picker-visible {
    z-index: 50;
  }

  .composer.emoji-picker-visible .emoji-picker {
    z-index: 100;
  }

  .composer.is-recording .composer-inner #attach-btn,
  .composer.is-recording .composer-inner #emoji-btn,
  .composer.is-recording .composer-inner #voice-btn,
  .composer.is-recording .composer-inner #send-btn {
    visibility: hidden;
    width: 0;
    min-width: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
    pointer-events: none;
  }

  .composer.is-recording .voice-recording {
    display: flex;
  }

  .voice-recording {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 4px 0 0;
    color: var(--accent);
    font-size: 14px;
  }

  .voice-btn.recording {
    color: #e53935 !important;
    background: rgba(229,57,53,.15);
  }

  .voice-btn .media-icon { display: flex; align-items: center; justify-content: center; }
  .voice-btn .media-icon-camera { display: none; }
  .voice-btn.camera-mode .media-icon-mic { display: none; }
  .voice-btn.camera-mode .media-icon-camera { display: flex; }
  .voice-btn.camera-mode:not(.recording) { color: var(--accent); }

  .video-record-preview {
    position: fixed;
    inset: 0;
    z-index: 150;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(14, 22, 33, 0.78);
    pointer-events: none;
  }

  .video-record-preview.hidden { display: none; }

  .video-record-wrap {
    position: relative;
    width: 348px;
    height: 348px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .video-record-ring-pulse {
    position: absolute;
    width: 348px;
    height: 348px;
    border-radius: 50%;
    border: 3px solid var(--accent);
    animation: videoRingPulse 1.4s ease-out infinite;
    pointer-events: none;
  }

  .video-record-circle {
    width: 336px;
    height: 336px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid rgba(106, 179, 243, 0.9);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    animation: videoNotePopIn 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .video-record-circle video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    background: #000;
  }

  .video-record-timer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 18px;
    color: #fff;
    font-size: 17px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
  }

  .video-record-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e53935;
    animation: recordDotPulse 1s ease-in-out infinite;
  }

  @keyframes videoNotePopIn {
    from { transform: scale(0.78); opacity: 0.55; }
    to { transform: scale(1); opacity: 1; }
  }

  @keyframes videoRingPulse {
    0% { transform: scale(1); opacity: 0.8; }
    70% { transform: scale(1.1); opacity: 0.2; }
    100% { transform: scale(1.14); opacity: 0; }
  }

  @keyframes recordDotPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.35; transform: scale(0.85); }
  }

  @keyframes videoNotePlayIn {
    from { transform: scale(0.92); opacity: 0.7; }
    to { transform: scale(1); opacity: 1; }
  }

  .message.message-video-note {
    background: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none;
    padding: 0;
    max-width: none;
    border-radius: 0;
  }

  html.has-chat-bg .message.message-video-note.incoming,
  html.has-chat-bg .message.message-video-note.outgoing {
    background: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .message-video-note-inner {
    display: block;
    line-height: 0;
  }

  .video-note-player {
    position: relative;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    overflow: visible;
    cursor: pointer;
    background: transparent;
    flex-shrink: 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.28);
    animation: videoNotePlayIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition: transform 0.15s ease;
  }

  .video-note-player:active { transform: scale(0.97); }

  .video-note-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
  }

  .video-note-progress {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
  }

  .video-note {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #000;
    border-radius: 50%;
  }

  .video-note-play {
    position: absolute;
    inset: 0;
    border: none;
    background: rgba(0, 0, 0, 0.12);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
    border-radius: 50%;
  }

  .video-note-play svg { width: 56px; height: 56px; filter: drop-shadow(0 2px 8px rgba(0,0,0,0.55)); }

  .video-note-player:not(.playing) .video-note-play,
  .video-note-player:hover .video-note-play { opacity: 1; }

  .video-note-player.playing .video-note-play { opacity: 0; }
  .video-note-player.playing:hover .video-note-play {
    opacity: 1;
    background: rgba(0, 0, 0, 0.12);
  }

  .video-note-meta {
    position: absolute;
    right: 12px;
    bottom: 10px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    z-index: 2;
    pointer-events: none;
    float: none;
    margin: 0;
    top: auto;
    background: none;
    padding: 0;
    border-radius: 0;
  }

  .video-note-meta .message-time {
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
  }

  .video-note-meta .msg-checks { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6)); }
  .video-note-meta .msg-checks.sent-only { color: rgba(255, 255, 255, 0.75); }
  .video-note-meta .msg-status.msg-failed { color: #ff8a80; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75); }

  .voice-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: #e53935;
    animation: pulse 1s infinite;
  }
  .voice-hint {
    color: var(--text-secondary);
    font-size: 13px;
    margin-left: auto;
  }
  @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

  /* Settings panel */
  .settings-panel {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 320px;
    max-width: 90vw;
    background: var(--bg-primary);
    z-index: 55;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 16px rgba(0,0,0,.4);
    transform: translateX(0);
    transition: transform .25s;
  }
  .settings-panel.hidden { transform: translateX(-100%); pointer-events: none; }

  .settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px 0 16px;
    height: var(--header-height);
    border-bottom: 1px solid var(--border);
  }
  .settings-header strong { font-size: 16px; font-weight: 500; }

  .settings-profile {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
  }
  .settings-profile:hover { background: var(--bg-hover); }
  .settings-profile strong { display: block; font-size: 15px; }
  .settings-profile .muted { display: block; font-size: 14px; margin-top: 2px; }
  .settings-profile .link-text { display: block; font-size: 14px; margin-top: 2px; }

  .settings-list { flex: 1; overflow-y: auto; }

  .settings-item {
    display: flex;
    align-items: center;
    gap: 18px;
    width: 100%;
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
  }
  .settings-item:hover { background: var(--bg-hover); }
  .settings-item .di { width: 24px; height: 24px; color: var(--text-secondary); flex-shrink: 0; }
  .settings-item span { display: block; font-size: 15px; }
  .settings-item small { display: block; font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
  a.settings-item { text-decoration: none; }

  .settings-footer {
    padding: 12px 20px 16px;
    font-size: 12px;
    text-align: center;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
  }

  /* Profile modal TG */
  .profile-overlay {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.6);
    padding: 20px;
  }
  .profile-overlay.hidden { opacity: 0; pointer-events: none; }

  .profile-modal {
    background: var(--bg-primary);
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 12px 40px rgba(0,0,0,.5);
  }

  .profile-modal-header {
    display: flex;
    justify-content: space-between;
    padding: 12px 12px 0;
  }

  .profile-modal-hero {
    text-align: center;
    padding: 8px 24px 20px;
  }
  .profile-modal-hero h2 { font-size: 20px; font-weight: 500; margin-top: 16px; }

  .profile-info-list { border-top: 1px solid var(--border); }
  .profile-info-row {
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
  }
  .profile-info-row span { display: block; font-size: 15px; }
  .profile-info-row small { display: block; font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

  /* Music panel — keep fixed overlay like other settings panels */
  #music-panel { z-index: 56; }
  .music-header-actions { display: flex; gap: 4px; }
  .music-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .music-tab {
    flex: 1;
    padding: 10px 4px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
  }
  .music-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
  }
  .music-offline-hint {
    padding: 8px 14px;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    flex-shrink: 0;
  }
  .music-offline-hint.hidden { display: none; }
  .music-list { flex: 1; overflow-y: auto; }
  .music-item-badges { display: inline-flex; gap: 4px; margin-left: 6px; vertical-align: middle; }
  .music-badge { font-size: 12px; }
  .music-track-menu {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    padding: 12px 8px 16px;
    z-index: 5;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.35);
  }
  .music-track-menu.hidden { display: none; }
  .music-menu-title {
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 4px 12px 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .music-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 15px;
    padding: 12px 16px;
    cursor: pointer;
    border-radius: 10px;
  }
  .music-menu-item:hover { background: var(--bg-hover); }
  .music-menu-item.danger { color: #ff8a80; }
  .music-menu-item.muted { color: var(--text-secondary); text-align: center; margin-top: 4px; border-top: 1px solid var(--border); border-radius: 0; }
  .music-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-secondary);
    font-size: 14px;
  }
  .music-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
  }
  .music-item:hover { background: var(--bg-hover); }
  .music-item-play {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    color: var(--accent);
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
  }
  .music-item-info { flex: 1; min-width: 0; }
  .music-item-title {
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .music-item-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
  }
  .music-item-more {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
  }
  .music-mode-row {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
  }
  .music-mode-btn {
    flex: 1;
    padding: 8px 10px;
    border: none;
    border-radius: 10px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
  }
  .music-mode-btn.active {
    background: rgba(106, 179, 243, 0.18);
    color: var(--accent);
    font-weight: 600;
  }
  .music-global-bar {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    z-index: 1;
    margin-top: auto;
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
  }
  .music-global-bar.hidden { display: none; }
  .music-global-open {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    padding: 0;
    color: inherit;
  }
  .music-player-info { flex: 1; min-width: 0; }
  .music-now-title {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .music-now-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
  .music-play-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  #music-audio { display: none; }

  /* Friends panel */
  .friends-search {
    flex: 1;
    background: var(--bg-secondary);
    border: none;
    outline: none;
    border-radius: 20px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
  }
  .friends-list { overflow-y: auto; }
  .friends-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
  }
  .friends-item:hover { background: var(--bg-hover); }
  .friends-item-info { flex: 1; min-width: 0; }
  .friends-item-name { font-size: 15px; font-weight: 500; }
  .friends-item-nick { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }
  .friends-item-btn {
    flex-shrink: 0;
    border: none;
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
  }
  .friends-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
    flex-shrink: 0;
  }
  .friends-tab {
    flex: 1;
    padding: 10px 4px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
  }
  .friends-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
  }
  .fr-tab-content { display: flex; flex-direction: column; flex: 1; overflow-y: auto; }
  .fr-tab-content.hidden { display: none; }
  .fr-badge {
    background: var(--danger, #ef4444);
    color: #fff;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    padding: 0 3px;
    text-align: center;
  }
  .fr-badge.hidden { display: none; }
  .friends-item-remove {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--danger, #ef4444);
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
    opacity: 0.7;
    transition: opacity .15s;
  }
  .friends-item-remove:hover { opacity: 1; background: rgba(239,68,68,.12); }
  .friends-section-label {
    padding: 10px 16px 4px;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .profile-qr-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 24px 8px;
    border-top: 1px solid var(--border);
  }
  .profile-qr-section #profile-qr-canvas { background: #fff; border-radius: 8px; padding: 8px; }
  .profile-qr-hint { font-size: 12px; color: var(--text-secondary); margin-top: 8px; }

  .profile-edit {
    padding: 20px 24px 24px;
  }
  .profile-edit label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
  .profile-edit input {
    width: 100%;
    padding: 12px 14px;
    border: none;
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    margin-bottom: 16px;
  }

  .mobile-only { display: none; }

  @media (max-width: 768px) {
    .sidebar {
      position: absolute;
      left: 0; top: 0; bottom: 0;
      width: 100%; min-width: 100%;
      z-index: 3;
      transition: transform .25s;
    }
    .messenger.chat-open .sidebar { transform: translateX(-100%); }
    .mobile-only { display: flex; }
    .msg-row { max-width: 92%; }
    .settings-panel { width: 100%; max-width: 100%; }
  }

  .message-image-btn {
    border: none;
    padding: 0;
    background: transparent;
    display: block;
    cursor: pointer;
  }

  .photo-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
  }

  .photo-lightbox-frame {
    position: relative;
    display: inline-flex;
    max-width: min(92vw, 720px);
    max-height: min(85vh, 720px);
  }

  .photo-lightbox img {
    display: block;
    max-width: min(92vw, 720px);
    max-height: min(85vh, 720px);
    border-radius: 8px;
    object-fit: contain;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  }

  .photo-lightbox-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  }

  .photo-lightbox-close:hover { background: rgba(0, 0, 0, 0.72); }

  .message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
  }

  .reaction-chip {
    border: none;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-primary);
  }

  .reaction-chip.mine { background: rgba(51, 144, 236, 0.25); }

  .message-actions-row {
    display: none;
    position: absolute;
    top: 2px;
    right: 2px;
    gap: 4px;
    z-index: 3;
  }

  .msg-row:hover .message-actions-row,
  .message:focus-within .message-actions-row,
  .message.reaction-active .message-actions-row { display: flex; }

  @media (hover: none) {
    .message-actions-row { display: flex; opacity: 0.55; }
    .message:focus-within .message-actions-row,
    .msg-row:active .message-actions-row { opacity: 1; }
  }

  .msg-react-btn {
    border: none;
    background: var(--bg-secondary);
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 14px;
    cursor: pointer;
  }

  .message { position: relative; }

  .msg-sender-name {
    font-size: 12px;
    color: var(--text-link);
    margin-bottom: 2px;
    font-weight: 500;
  }

  .reaction-picker {
    position: fixed;
    z-index: 200;
    background: var(--bg-secondary);
    border-radius: 24px;
    padding: 6px 10px 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: calc(100vw - 16px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.08);
  }

  .reaction-picker::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 14px;
  }

  .reaction-picker button {
    border: none;
    background: transparent;
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
  }

  .reaction-picker button:hover { background: var(--bg-hover); }

  .avatar.group {
    background: #5288c1;
    font-size: 16px;
  }

  .group-modal .profile-modal-header strong { font-size: 16px; padding: 4px 8px; }

  .emoji-grid { max-height: 240px; }

  /* ── Video Call Overlay ─────────────────────── */
  .call-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: #0e0e1a;
    display: flex;
    flex-direction: column;
  }
  .call-overlay.hidden { display: none; }
  .call-remote-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #1a1a2e;
  }
  .call-local-video {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 120px;
    height: 168px;
    object-fit: cover;
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.4);
    z-index: 2;
    background: #222;
  }
  .call-top-info {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 16px 16px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, transparent 100%);
    gap: 4px;
  }
  .call-partner-name { color: #fff; font-size: 22px; font-weight: 700; }
  .call-state-label { color: rgba(255,255,255,0.75); font-size: 15px; }
  .call-incoming-btns, .call-active-btns {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    z-index: 3;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 24px 32px 40px;
  }
  .call-incoming-btns.hidden, .call-active-btns.hidden { display: none; }
  .call-active-btns { background: rgba(0,0,0,0.5); padding-top: 18px; }
  .call-round-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .call-reject { background: #e53935; }
  .call-accept { background: #43a047; }
  .call-ctrl-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 12px;
    padding: 10px 16px;
    cursor: pointer;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 72px;
  }
  .call-ctrl-btn.active { background: rgba(255,255,255,0.3); }
