/* Messages area, input bar, image viewer — index/messages.css */
    /* --- Messages Area --- */
    .messages-container {
      flex: 1;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      position: relative;
      background-color: var(--bg-primary-dark);
    }
    .messages-container::before {
      content: '';
      position: absolute;
      inset: 0;
      background-image: url('/assets/bg/pattern.svg');
      background-repeat: repeat;
      background-size: 420px auto;
      opacity: 0.07;
      pointer-events: none;
      z-index: 0;
    }

    #messages {
      position: relative;
      z-index: 1;
      flex: 1;
      overflow-y: auto;
      padding: 20px;
      scroll-behavior: auto;
      overflow-anchor: auto;
      transition: filter 0.2s ease;
    }

    .messages-container.history-loading #messages {
      opacity: 0;
      transform: translateY(10px) scale(0.992);
      transition: transform 0.2s ease, filter 0.2s ease;
      pointer-events: none;
    }

    .chat-history-loader {
      position: absolute;
      inset: 0;
      z-index: 12;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 12px;
      opacity: 0;
      pointer-events: none;
      background:
        radial-gradient(circle at top, color-mix(in srgb, var(--accent) 12%, transparent), transparent 46%),
        color-mix(in srgb, var(--bg-primary) 86%, transparent);
      backdrop-filter: blur(5px);
      -webkit-backdrop-filter: blur(5px);
      transition: opacity 0.18s ease;
    }

    .chat-history-loader.visible {
      opacity: 1;
    }

    .chat-history-loader-spinner {
      width: 42px;
      height: 42px;
      border-radius: 50%;
      border: 3px solid color-mix(in srgb, var(--border) 72%, transparent);
      border-top-color: var(--accent);
      box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 8%, transparent);
      animation: spin 0.72s linear infinite;
    }

    .chat-history-loader-label {
      color: var(--text-muted);
      font-size: 13px;
      font-weight: 600;
      letter-spacing: 0.02em;
    }

    #messages.ptt-blurred {
      filter: blur(6px);
    }

    #messages::-webkit-scrollbar { width: 6px; }
    #messages::-webkit-scrollbar-track { background: transparent; }
    #messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

    .msg-day-separator {
      display: flex;
      justify-content: center;
      margin: 10px 0;
      pointer-events: none;
      overflow-anchor: none; /* never pick separators as scroll anchor — anchor to .msg only */
    }
    .msg-day-separator span {
      padding: 3px 10px;
      border-radius: 999px;
      border: 1px solid var(--border);
      background: var(--msg-day-separator-bg, rgba(15, 23, 42, 0.75));
      color: var(--msg-day-separator-text, var(--text-muted));
      font-size: 11px;
      font-weight: 600;
    }

    #chat-date-float-badge {
      position: absolute;
      top: 10px;
      left: 50%;
      transform: translateX(-50%);
      padding: 4px 12px;
      border-radius: 999px;
      border: 1px solid var(--border);
      background: var(--msg-day-separator-bg, rgba(15, 23, 42, 0.82));
      color: var(--msg-day-separator-text, var(--text-primary));
      font-size: 12px;
      font-weight: 600;
      opacity: 0;
      pointer-events: none;
      z-index: 11;
      transition: opacity 0.15s ease;
    }
    #chat-date-float-badge.visible {
      opacity: 0.7;
    }

    #scroll-to-bottom-btn {
      position: absolute;
      bottom: 72px;
      right: 14px;
      width: 40px;
      height: 40px;
      border-radius: 50%;
      background: var(--bg-tertiary);
      border: 1px solid var(--border);
      box-shadow: 0 2px 10px rgba(0,0,0,0.3);
      cursor: pointer;
      display: none;
      align-items: center;
      justify-content: center;
      color: var(--text-primary);
      font-size: 15px;
      z-index: 10;
      transition: opacity 0.15s;
    }
    #scroll-to-bottom-btn.visible { display: flex; }
    #messages.multi-select-mode ~ #scroll-to-bottom-btn {
      bottom: calc(72px + 44px);
    }
    #scroll-to-bottom-badge {
      position: absolute;
      top: -6px;
      right: -6px;
      background: var(--accent);
      color: #fff;
      border-radius: 10px;
      font-size: 10px;
      font-weight: 700;
      padding: 1px 5px;
      min-width: 16px;
      text-align: center;
      line-height: 14px;
      display: none;
    }
    #scroll-to-bottom-badge.visible { display: block; }

    #dm-user-list::-webkit-scrollbar { width: 4px; }
    #dm-user-list::-webkit-scrollbar-track { background: transparent; }
    #dm-user-list::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 4px; }

    .msg {
      display: flex;
      flex-direction: column;
      margin-bottom: 6px;
      position: relative;
      padding-left: 0;
      padding-right: 0;
    }
    .msg.msg-appear-own {
      animation: msgAppearOwn 0.42s cubic-bezier(0.2, 0.9, 0.26, 1) both;
    }
    .msg.msg-appear-other {
      animation: msgAppearOther 0.46s cubic-bezier(0.18, 0.86, 0.32, 1) both;
    }
    .msg.msg-channel-fantasy-in {
      animation: msgChannelFantasyIn 0.62s cubic-bezier(0.16, 0.84, 0.24, 1) both;
      transform-origin: center top;
    }
    .msg.msg-channel-fantasy-in .msg-bubble {
      position: relative;
      overflow: hidden;
      box-shadow: 0 0 0 0 rgba(45, 212, 191, 0.0);
      animation: msgChannelGlowPulse 0.72s ease;
    }
    .msg.msg-channel-fantasy-in .msg-bubble::after {
      content: '';
      position: absolute;
      inset: 0;
      border-radius: inherit;
      background: linear-gradient(120deg, rgba(255,255,255,0) 10%, rgba(255,255,255,0.2) 45%, rgba(255,255,255,0) 85%);
      transform: translateX(-130%);
      animation: msgChannelShineSweep 0.78s ease;
      pointer-events: none;
    }
    .msg.pending-msg {
      animation: msgSendQueued 0.5s cubic-bezier(0.2, 0.9, 0.26, 1) both;
    }
    .msg.other {
      align-items: flex-start;
    }
    @keyframes msgAppearOwn {
      0% { opacity: 0; transform: translateY(16px) translateX(14px) scale(0.92); filter: saturate(0.9) brightness(0.95); }
      62% { opacity: 1; transform: translateY(-1px) translateX(-1px) scale(1.012); filter: saturate(1.05) brightness(1.03); }
      100% { opacity: 1; transform: translateY(0) translateX(0) scale(1); filter: none; }
    }
    @keyframes msgAppearOther {
      0% { opacity: 0; transform: translateY(16px) translateX(-14px) scale(0.92); filter: saturate(0.9) brightness(0.95); }
      60% { opacity: 1; transform: translateY(-1px) translateX(1px) scale(1.012); filter: saturate(1.05) brightness(1.03); }
      100% { opacity: 1; transform: translateY(0) translateX(0) scale(1); filter: none; }
    }
    @keyframes msgChannelFantasyIn {
      0% { opacity: 0; transform: translateY(16px) scale(0.96); }
      56% { opacity: 1; transform: translateY(-2px) scale(1.012); }
      100% { opacity: 1; transform: translateY(0) scale(1); }
    }
    .msg-history-load {
      animation: msgHistoryItemIn var(--stagger-dur, 0.36s) calc(var(--stagger-delay, 0ms)) cubic-bezier(0.17, 0.84, 0.44, 1) both;
    }
    @keyframes msgHistoryItemIn {
      0%   { opacity: 0; transform: translateY(22px) scale(0.95); filter: blur(4px) saturate(0.7); }
      55%  { opacity: 1; transform: translateY(-2px) scale(1.008); filter: blur(0px) saturate(1.08); }
      100% { opacity: 1; transform: translateY(0) scale(1); filter: none; }
    }
    #messages.history-entering {
      animation: msgsContainerIn 0.38s cubic-bezier(0.17, 0.84, 0.44, 1) both;
    }
    @keyframes msgsContainerIn {
      0%   { opacity: 0; filter: blur(8px) saturate(0.6) brightness(0.92); transform: scale(0.985); }
      60%  { opacity: 1; filter: blur(0px) saturate(1.06) brightness(1.02); transform: scale(1.003); }
      100% { opacity: 1; filter: none; transform: scale(1); }
    }
    @keyframes msgChannelGlowPulse {
      0% { box-shadow: 0 0 0 0 rgba(45, 212, 191, 0.0); }
      50% { box-shadow: 0 0 0 5px rgba(45, 212, 191, 0.16), 0 10px 24px rgba(6, 182, 212, 0.2); }
      100% { box-shadow: 0 0 0 0 rgba(45, 212, 191, 0.0); }
    }
    @keyframes msgChannelShineSweep {
      0% { transform: translateX(-130%); opacity: 0.2; }
      28% { opacity: 0.95; }
      100% { transform: translateX(130%); opacity: 0; }
    }
    @keyframes msgSendQueued {
      0% { opacity: 0; transform: translateY(18px) scale(0.9); }
      55% { opacity: 1; transform: translateY(-1px) scale(1.02); }
      100% { opacity: 1; transform: translateY(0) scale(1); }
    }
    .msg-highlight { animation: msgHighlight 1.5s ease !important; }
    .msg-pin-flag { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--accent); opacity: 0.75; padding: 1px 8px 3px; }
    .msg-pin-flag i { font-size: 9px; transform: rotate(45deg); }
    .msg.own .msg-pin-flag { justify-content: flex-end; }
    @keyframes msgHighlight { 0%,100% { background: transparent; } 30% { background: rgba(99,179,237,0.18); } }
    .msg.own { align-items: flex-end; }
    .msg-bubble-row {
      display: flex;
      align-items: flex-start;
      width: 100%;
      background: transparent;
      justify-content: flex-start;
      gap: 2px;
    }
    .msg.own .msg-bubble-row { justify-content: flex-end; }

    /* ── Message action button (⋮) ─────────────────────────────────── */
    .msg-action-btn {
      flex-shrink: 0;
      align-self: flex-start;
      margin-top: 6px;
      width: 17px;
      height: 26px;
      border-radius: 50%;
      border: none;
      background: transparent;
      color: #788087;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 13px;
      opacity: 1;
      transition: background 0.15s ease;
      padding: 0;
    }
    .msg-action-btn:hover,
    .msg-action-btn:focus { background: var(--hover, rgba(148,163,184,0.18)); outline: none; }
    .msg-action-btn:active { background: var(--hover, rgba(148,163,184,0.28)); }
    /* own messages: button before the bubble */
    .msg.own .msg-action-btn { order: -1; }
    .msg::before {
      content: '';
      position: absolute;
      top: 50%;
      left: 2px;
      width: 18px;
      height: 18px;
      border-radius: 50%;
      border: 2px solid rgba(148, 163, 184, 0.8);
      background: transparent;
      transform: translateY(-50%) scale(0.85);
      opacity: 0;
      transition: opacity 0.14s ease, transform 0.14s ease, background 0.14s ease, border-color 0.14s ease;
      pointer-events: none;
      box-sizing: border-box;
    }
    .msg.own::before {
      left: auto;
      right: 2px;
    }
    #messages.multi-select-mode .msg {
      padding-left: 28px;
    }
    #messages.multi-select-mode .msg.own {
      padding-left: 0;
      padding-right: 28px;
    }
    #messages.multi-select-mode .msg::before {
      opacity: 1;
      transform: translateY(-50%) scale(1);
    }
    #messages.multi-select-mode .msg.msg-selected::before {
      background: var(--accent);
      border-color: var(--accent);
    }
    .msg.msg-selected::after {
      content: '';
      position: absolute;
      top: 50%;
      left: 8px;
      width: 5px;
      height: 9px;
      border-right: 2px solid #fff;
      border-bottom: 2px solid #fff;
      transform: translateY(-55%) rotate(45deg);
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.12s ease;
    }
    .msg.own.msg-selected::after {
      left: auto;
      right: 8px;
    }
    #messages.multi-select-mode .msg.msg-selected::after {
      opacity: 1;
    }
    .msg.msg-selected .msg-bubble {
      outline: 2px solid rgba(125, 211, 252, 0.75);
      box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.18);
    }

    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(6px); }
      to { opacity: 1; transform: translateY(0); }
    }

    .msg-username {
      font-size: 12px;
      font-weight: 600;
      margin-bottom: 6px;
      padding: 0 4px;
      color: var(--msg-sender-name, #e94560);
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .msg-username span {
      line-height: 1;
    }

    .msg-bubble {
      max-width: 90%;
      padding: 8px 10px 6px 10px;
      border-radius: 18px;
      position: relative;
      word-wrap: break-word;
      min-width: 100px;
    }
    #messages.channel-room .msg {
      align-items: stretch;
    }
    #messages.channel-room .msg-bubble {
      width: 100%;
      max-width: 380px;
      min-width: 0;
    }
    #messages.bot-room .msg-bubble {
      max-width: 100%;
    }
    #messages.channel-room .msg-image-wrap {
      width: 100%;
      max-width: none;
      align-items: center;
    }
    #messages.channel-room .msg-image {
      margin: 0 auto;
      max-width: 100%;
      max-height: 100%;
    }
    #messages.channel-room .msg-image-caption {
      width: 100%;
      text-align: start;
    }
    #messages.channel-room .msg-username {
      display: none;
    }
    /* AI typing indicator */
    .ai-typing-indicator {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 10px 16px;
      margin: 4px 0;
      font-size: 13px;
      color: #c4b5fd;
      animation: aiFadeIn 0.3s ease;
    }
    .ai-typing-dot {
      width: 8px; height: 8px;
      border-radius: 50%;
      background: #8b5cf6;
      animation: aiDotPulse 1.4s infinite ease-in-out;
    }
    .ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
    .ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }
    @keyframes aiDotPulse {
      0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
      40% { transform: scale(1); opacity: 1; }
    }
    @keyframes aiFadeIn {
      from { opacity: 0; transform: translateY(8px); }
      to { opacity: 1; transform: translateY(0); }
    }
    .msg.own .msg-bubble {
      background: var(--msg-own-bg, var(--accent));
      color: var(--msg-own-text, #fff);
      border-top-right-radius: 4px;
    }
    .msg.other .msg-bubble {
      background: var(--msg-other-bg, var(--bg-tertiary));
      color: var(--msg-other-text, var(--text-primary));
      border-top-left-radius: 4px;
    }
    .msg.msg-emoji-only .msg-bubble {
      min-width: 0;
      padding: 6px 2px 4px;
      overflow: visible;
      background: transparent !important;
      box-shadow: none !important;
    }
    .msg.msg-emoji-only .msg-bubble::before {
      content: none;
    }
    .msg.own.msg-emoji-only .msg-bubble {
      background: transparent !important;
      box-shadow: none !important;
    }
    .msg.other.msg-emoji-only .msg-bubble {
      background: transparent !important;
      box-shadow: none !important;
    }
    .msg.msg-emoji-only .msg-bubble > * {
      position: relative;
      z-index: 1;
    }
       .msg.other .msg-bubble .msg-deleted {
      color: #3c64d9;
      font-style: italic;
      font-size: 12px;

    }

    .msg-text {
      font-size: var(--msg-font-size);
      line-height: 1.5;
      word-wrap: break-word;
      white-space: pre-wrap;
      user-select: text;
    }
    .msg-text.msg-text-emoji-only {
      font-size: clamp(3.4rem, 7vw, 5.6rem);
      line-height: 1;
      text-align: center;
      letter-spacing: 0.02em;
      padding: 2px 0 4px;
      filter: drop-shadow(0 6px 14px rgba(255, 191, 36, 0.18));
    }
    .msg-text .msg-emoji {
      font-size: 1.45em;
      line-height: 0;
      vertical-align: -0.12em;
    }
    /* Rich HTML content within messages */
    .msg-text strong, .msg-text b { font-weight: 600; }
    .msg-text em, .msg-text i { font-style: italic; }
    .msg-text u { text-decoration: underline; }
    .msg-text s, .msg-text del { text-decoration: line-through; }
    .msg-text code { font-family: monospace; background: rgba(0,0,0,0.1); padding: 1px 4px; border-radius: 3px; font-size: 0.88em; }
    .msg-text pre { font-family: monospace; background: rgba(0,0,0,0.08); padding: 8px 10px; border-radius: 6px; overflow-x: auto; white-space: pre; margin: 4px 0; }
    .msg-text blockquote { border-left: 3px solid var(--accent); padding-left: 8px; opacity: 0.85; margin: 4px 0; }
    .msg-text ul, .msg-text ol { padding-left: 20px; margin: 4px 0; }
    .msg-text li { margin: 2px 0; }
    .msg-text a { color: var(--accent); text-decoration: none; word-break: break-all; }
    .msg-text a:hover { text-decoration: underline; }
    .msg.own .msg-text a { color: #fff; }
    .msg.own .msg-text a:hover { color: #e0e0e0; }
    .msg-text p { margin: 0 0 4px 0; }
    .msg-text p:last-child { margin-bottom: 0; }
    .msg-text h1, .msg-text h2, .msg-text h3, .msg-text h4, .msg-text h5, .msg-text h6 { margin: 4px 0; font-weight: 600; line-height: 1.3; }
    .msg-text mark { background: rgba(255,220,0,0.45); border-radius: 2px; padding: 0 2px; }
    .msg-text hr { border: none; border-top: 1px solid rgba(128,128,128,0.3); margin: 6px 0; }
    .msg-text .katex-display { white-space: normal; margin: 4px 0;  }    .msg-text .katex { white-space: normal; }
    .msg-text table { border-collapse: collapse; margin: 4px 0; font-size: 0.92em; }
    .msg-text th, .msg-text td { border: 1px solid rgba(128,128,128,0.35); padding: 3px 8px; text-align: start; }
    .msg-text th { background: rgba(0,0,0,0.06); font-weight: 600; }
    /* HTML-format messages (bot responses with markup) */
    .msg-text.msg-html {
      white-space: normal;
    }
    /* Contain lists inside the bubble — bullets render inside with left padding */
    .msg-text.msg-html ul, .msg-text.msg-html ol {
      padding-inline-start: 1.4em;
      margin: 2px 0 6px 0;
      box-sizing: border-box;
    }
    .msg-text.msg-html li { margin: 3px 0; }
    /* Collapse excessive <p> spacing from AI responses */
    .msg-text.msg-html p { margin: 0 0 6px 0; }
    .msg-text.msg-html p:last-child { margin-bottom: 0; }
    /* Scale down headings to chat-appropriate sizes */
    .msg-text.msg-html h1 { font-size: 1.15em; }
    .msg-text.msg-html h2 { font-size: 1.08em; }
    .msg-text.msg-html h3 { font-size: 1em; font-weight: 700; }
    .msg-text.msg-html h4, .msg-text.msg-html h5, .msg-text.msg-html h6 { font-size: 0.95em; }
    /* Slight overflow-x scroll for wide tables or math */
    .msg-text.msg-html { overflow-x: auto; }
    /* KaTeX display blocks in HTML messages */
    .msg-text.msg-html .katex-display { overflow-x: auto; overflow-y: hidden; margin: 6px 0; }
    .msg-text.msg-text-emoji-only .msg-emoji {
      display: inline-block;
      font-size: 1em;
      line-height: 1;
      vertical-align: middle;
      transform-origin: center;
      animation: msgEmojiFantasyIn 0.76s cubic-bezier(0.18, 0.88, 0.3, 1.18) both, msgEmojiShimmer 2.8s ease-in-out 0.9s infinite;
    }
    .msg-text.rtl {
      direction: rtl;
      text-align: right;
    }
    .msg-text.msg-text-emoji-only.rtl {
      text-align: center;
    }

    @keyframes msgEmojiFantasyIn {
      0% { opacity: 0; transform: translateY(20px) scale(0.42) rotate(-10deg); filter: blur(8px) saturate(0.8); }
      58% { opacity: 1; transform: translateY(-4px) scale(1.12) rotate(4deg); filter: blur(0) saturate(1.08); }
      100% { opacity: 1; transform: translateY(0) scale(1) rotate(0deg); filter: none; }
    }
    @keyframes msgEmojiShimmer {
      0%, 100% { transform: translateY(0) scale(1); filter: drop-shadow(0 0 0 rgba(255, 191, 36, 0)); }
      50% { transform: translateY(-1px) scale(1.04); filter: drop-shadow(0 8px 12px rgba(255, 191, 36, 0.2)); }
    }
    @keyframes msgEmojiAura {
      0%, 100% { transform: scale(0.96); opacity: 0.55; }
      50% { transform: scale(1.06); opacity: 0.95; }
    }

    .msg-footer {
      display: flex;
      justify-content: flex-end;
      align-items: center;
      gap: 4px;
      margin-top: 2px;
    }
    .msg-time {
      font-size: 10px;
      opacity: 0.65;
    }
    .msg.other .msg-time { opacity: 0.55; color: #a6b2db; }
    .msg-ticks {
      font-size: 11px;
      line-height: 1;
      color: rgba(255,255,255,0.6);
      position: relative;
    }
    .msg-ticks.seen { color: #7dd3fc; }
    .pending-msg .msg-bubble {
      opacity: 0.8;
      box-shadow: 0 0 0 0 rgba(125, 211, 252, 0.0);
      animation: pendingMsgPulse 1.6s ease-in-out infinite;
    }
    @keyframes pendingMsgPulse {
      0%, 100% { box-shadow: 0 0 0 0 rgba(125, 211, 252, 0); }
      50% { box-shadow: 0 0 0 5px rgba(125, 211, 252, 0.08); }
    }
    .pending-spinner { color: var(--text-muted) !important; }
    .pending-spinner .fa-spin { font-size: 11px; }
    .msg-failed-icon { color: #e74c3c !important; }
    .msg-failed-icon .fa-circle-exclamation { font-size: 11px; }
    /* Optimistic update spinner (shown after 3s if server hasn't confirmed) */
    .msg-update-spinner {
      display: inline-flex;
      align-items: center;
      margin-left: 3px;
      color: var(--text-muted);
      vertical-align: middle;
    }
    .msg-update-spinner .fa-spinner { font-size: 10px; }
    .msg.msg-updating .msg-bubble {
      opacity: 0.82;
      transition: opacity 0.3s;
    }
    .msg.msg-send-failed .msg-bubble {
      opacity: 0.85;
      border: 1px solid rgba(231, 76, 60, 0.45);
      background: linear-gradient(135deg, rgb(231 76 60) 0%, rgba(192, 57, 43, 0.10) 100%) !important;
      animation: none;
    }
    .msg-resend-bar {
      display: flex;
      justify-content: flex-end;
      margin-top: 3px;
      padding-right: 2px;
    }
    .msg-resend-link {
      font-size: 11px;
      color: #e74c3c;
      text-decoration: none;
      cursor: pointer;
      opacity: 0.9;
      transition: opacity 0.15s;
    }
    .msg-resend-link:hover { opacity: 1; text-decoration: underline; }
    .msg-cancel-btn {
      flex-shrink: 0;
      align-self: flex-start;
      margin-top: 6px;
      width: 17px;
      height: 26px;
      border-radius: 50%;
      border: none;
      background: transparent;
      color: rgba(128, 0, 0, 0.788);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 13px;
      padding: 0;
      transition: color 0.15s;
    }
    .msg.own .msg-cancel-btn { order: -2; }
    .msg-cancel-btn:hover { color: rgba(255, 0, 0, 0.85); }
    .msg-ticks .seen-tooltip {
      display: none;
      position: absolute;
      bottom: 18px;
      right: 0;
      background: var(--bg2, #1e2030);
      color: var(--text, #cdd6f4);
      font-size: 11px;
      padding: 4px 8px;
      border-radius: 6px;
      white-space: nowrap;
      z-index: 50;
      border: 1px solid var(--border, #313244);
      pointer-events: none;
    }
    .msg-ticks .seen-tooltip { display: none; }

    /* Message context popup menu */
    #msg-context-menu {
      position: fixed;
      z-index: 1000;
      background: var(--bg-secondary);
      backdrop-filter: blur(14px);
      -webkit-backdrop-filter: blur(14px);
      border: 1px solid var(--border);
      border-radius: 10px;
      box-shadow: 0 4px 20px rgba(0,0,0,0.4);
      overflow: visible;
      min-width: 220px;
      max-width: min(92vw, 260px);
      transform-origin: top left;
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
      transform: translateY(-4px) scale(0.97);
      transition: opacity 0.13s ease, transform 0.13s ease, visibility 0.13s;
    }
    #msg-context-menu.open {
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
      transform: none;
    }
    .ctx-menu-item {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 6px 14px;
      cursor: pointer;
      font-size: 12px;
      color: var(--ctx-menu-color, var(--text-primary));
      transition: background 0.12s;
      white-space: nowrap;
    }
    .ctx-menu-item:hover { background: var(--bg-hover); }
    .ctx-menu-item.danger { color: #f87171; }
    .ctx-menu-sep { height: 1px; background: var(--border); margin: 2px 0; }
    .ctx-menu-summary-wrap {
      display: none;
      padding: 6px 10px 7px;
      border-top: 1px solid var(--border);
      background: color-mix(in srgb, var(--bg-secondary) 94%, transparent);
      position: relative;
    }
    .ctx-menu-summary-item {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 9px;
      padding: 0px 3px;
      border: none;
      border-radius: 12px;
     color: var(--text-primary);
      font: inherit;
      cursor: pointer;
      transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
      background-color: transparent;
    }
    .ctx-menu-summary-main {
      display: flex;
      align-items: center;
      gap: 8px;
      min-width: 0;
    }
    .ctx-menu-summary-icon {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 18px;
      min-width: 18px;
      font-size: 13px;
      line-height: 1;
      color: var(--text-primary);
    }
    .ctx-menu-summary-item.is-reacted .ctx-menu-summary-icon {
      color: #ef4444;
    }
    .ctx-menu-summary-item.is-seen-only .ctx-menu-summary-icon {
      color: var(--accent, #3b82f6);
    }
    .ctx-menu-summary-item:hover,
    .ctx-menu-summary-item:focus {
      outline: none;
    }
    .ctx-menu-summary-count {
      font-size: 12px;
      font-weight: 600;
      color: var(--text-secondary);
      text-align: start;
      white-space: nowrap;
      padding-top: 2px;
    }
    .ctx-menu-summary-avatars {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      min-width: fit-content;
      padding-left: 8px;
    }
    .ctx-menu-summary-avatars > [data-avatar-un] {
      margin-left: -8px;
      border: 2px solid var(--bg-secondary);
      box-shadow: 0 2px 8px rgba(0,0,0,0.16);
      width: 27px;
      height: 27px;
    }
    .ctx-menu-summary-avatars > [data-avatar-un]:first-child {
      margin-left: 0;
    }
    .ctx-menu-detail-card {
      position: absolute;
      top: 8px;
      left: calc(100% + 10px);
      width: 216px;
      border: 1px solid var(--border);
      border-radius: 14px;
      background: color-mix(in srgb, var(--bg-secondary) 96%, transparent);
      box-shadow: 0 10px 28px rgba(0,0,0,0.28);
      overflow: hidden;
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
    }
    .ctx-menu-detail-card.align-left {
      left: auto;
      right: calc(100% + 10px);
    }
    .ctx-menu-detail-row {
      width: 100%;
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 9px 12px;
      border: none;
      border-bottom: 1px solid color-mix(in srgb, var(--border) 86%, transparent);
      background: transparent;
      color: var(--text-primary);
      font: inherit;
      text-align: left;
      cursor: pointer;
    }
    .ctx-menu-detail-row:last-child {
      border-bottom: none;
    }
    .ctx-menu-detail-row:hover,
    .ctx-menu-detail-row:focus {
      background: var(--bg-hover);
      outline: none;
    }
    .ctx-menu-detail-name {
      flex: 1;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-size: 13px;
    }
    .ctx-menu-detail-indicator {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 20px;
      font-size: 14px;
      line-height: 1;
      color: var(--text-secondary);
    }
    .ctx-menu-detail-indicator.is-seen {
      color: var(--accent, #3b82f6);
      font-size: 12px;
    }

    @media (max-width: 640px) {
      .ctx-menu-summary-wrap.has-detail {
        padding-bottom: 10px;
      }
      .ctx-menu-detail-card,
      .ctx-menu-detail-card.align-left {
        position: static;
        left: auto;
        right: auto;
        width: auto;
        margin-top: 8px;
      }
    }

    /* Seen-by / Who-reacted info modal */
    #msg-info-sheet-overlay {
      position: fixed; inset: 0; z-index: 1200;
      background: rgba(0,0,0,0.45);
      backdrop-filter: blur(4px);
      -webkit-backdrop-filter: blur(4px);
      display: flex; align-items: center; justify-content: center;
      padding: 16px;
      opacity: 0; visibility: hidden; pointer-events: none;
      transition: opacity 0.18s ease, visibility 0.18s;
    }
    #msg-info-sheet-overlay.open {
      opacity: 1; visibility: visible; pointer-events: auto;
    }
    #msg-info-sheet {
      width: 100%; max-width: 400px;
      background: var(--bg-secondary);
      backdrop-filter: blur(20px);
      -webkit-backdrop-filter: blur(20px);
      border: 1px solid var(--border);
      border-radius: 14px;
      box-shadow: 0 8px 40px rgba(0,0,0,0.45);
      padding: 0;
      transform: scale(0.95) translateY(8px);
      transition: transform 0.22s cubic-bezier(0.2,0.8,0.25,1), opacity 0.18s ease;
      max-height: 70vh; display: flex; flex-direction: column;
    }
    #msg-info-sheet-overlay.open #msg-info-sheet {
      transform: scale(1) translateY(0);
    }
    .mis-header {
      display: flex; align-items: center; justify-content: space-between;
      padding: 14px 18px 10px;
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
    }
    .mis-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
    .mis-close-btn {
      background: none; border: none; color: var(--text-secondary); cursor: pointer;
      font-size: 16px; padding: 4px; border-radius: 6px; line-height: 1;
      transition: background 0.12s;
    }
    .mis-close-btn:hover { background: var(--bg-hover); }
    .mis-tabs {
      display: flex; gap: 0; flex-shrink: 0;
      border-bottom: 1px solid var(--border);
    }
    .mis-tab {
      flex: 1; text-align: center; padding: 9px 12px;
      font-size: 12px; font-weight: 500; color: var(--text-secondary);
      cursor: pointer; border-bottom: 2px solid transparent;
      transition: color 0.14s, border-color 0.14s;
    }
    .mis-tab.active { color: var(--accent, #3b82f6); border-bottom-color: var(--accent, #3b82f6); }
    .mis-body {
      overflow-y: auto; flex: 1; padding: 8px 0;
    }
    .mis-user-row {
      display: flex; align-items: center; gap: 10px;
      padding: 7px 18px; transition: background 0.1s;
    }
    .mis-user-row:hover { background: var(--bg-hover); }
    .mis-user-name-wrap {
      display: flex;
      flex: 1;
      min-width: 0;
      flex-direction: column;
      gap: 2px;
    }
    .mis-user-name { font-size: 13px; color: var(--text-primary); }
    .mis-user-meta { font-size: 11px; color: var(--text-secondary); }
    .mis-empty {
      text-align: center; color: var(--text-secondary);
      font-size: 13px; padding: 28px 16px;
    }
    .mis-reaction-group { padding: 4px 0 0; }
    .mis-reaction-header {
      display: flex; align-items: center; gap: 6px;
      padding: 8px 18px 4px;
    }
    .mis-reaction-emoji { font-size: 20px; line-height: 1; }
    .mis-reaction-count { font-size: 12px; color: var(--text-secondary); margin-left: 2px; }

    /* Forward modal */
    #forward-modal .modal-box { max-width: 380px; width: 92vw; }
    .forward-tabs {
      display: flex;
      gap: 8px;
      margin-bottom: 12px;
      border-bottom: 1px solid var(--border);
    }
    .forward-tab {
      flex: 1;
      padding: 10px 8px;
      background: none;
      border: none;
      color: var(--text-muted);
      font-size: 13px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.2s;
      border-bottom: 2px solid transparent;
      margin-bottom: -1px;
    }
    .forward-tab:hover { color: var(--text-primary); }
    .forward-tab.active {
      color: var(--accent);
      border-bottom-color: var(--accent);
    }
    .forward-search {
      width: 100%;
      padding: 9px 12px;
      border: 1px solid var(--border);
      border-radius: 10px;
      background: var(--bg-tertiary);
      color: var(--text-primary);
      font-size: 13px;
      font-family: inherit;
      outline: none;
      margin-bottom: 10px;
    }
    .forward-search:focus { border-color: var(--accent); }
    .forward-list {
      max-height: 300px;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
      gap: 2px;
      margin-bottom: 4px;
    }
    .forward-item {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 9px 10px;
      border-radius: 10px;
      cursor: pointer;
      transition: background 0.12s;
    }
    .forward-item:hover { background: var(--bg-hover); }
    .forward-avatar {
      width: 38px; height: 38px;
      border-radius: 50%;
      display: inline-flex; align-items: center; justify-content: center;
      font-size: 15px; font-weight: 700;
      color: #fff;
      flex-shrink: 0;
      overflow: hidden;
    }
    .forward-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
    .forward-name { font-size: 14px; font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .forward-status { font-size: 11px; color: var(--text-muted); }
    .forward-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
    .forward-empty { font-size: 13px; color: var(--text-muted); text-align: center; padding: 18px 0; }

    /* Forward indicator */
    .msg-forwarded-from {
      font-size: 11px;
      color: var(--text-muted);
      padding: 4px 8px;
      margin: 4px 0;
      border-left: 2px solid var(--accent);
      background: var(--bg-tertiary);
      border-radius: 4px;
      display: flex;
      align-items: center;
      gap: 6px;
    }

    /* Reply quote inside bubble */
    .msg-reply-quote {
      border-left: 3px solid var(--msg-reply-quote-border, #ffffff);
      padding: 4px 8px;
      margin-bottom: 6px;
      border-radius: 4px;
      background: var(--msg-reply-quote-bg, rgb(249 249 249 / 52%));
      font-size: 11px;
      cursor: pointer;
      overflow: hidden;
    }
    .msg-reply-quote .rq-name { font-weight: 600; color: var(--rq-name-color, var(--accent)); margin-bottom: 2px; }
    .msg-reply-quote .rq-text { color: var(--msg-reply-quote-text, var(--text-muted)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

    /* Reply bar above input */
    #reply-bar {
      display: none;
      align-items: center;
      gap: 8px;
      padding: 6px 12px;
      background: var(--bg-secondary);
      border-top: 1px solid var(--border);
      font-size: 12px;
    }
    #reply-bar.active { display: flex; }
    #reply-bar-text { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    #reply-bar-name { font-weight: 600; color: var(--accent); margin-right: 4px; }
    #reply-cancel { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 18px; line-height: 1; padding: 0 4px; }
    #reply-cancel:hover { color: var(--text); }

    /* Edit bar above input */
    #edit-bar {
      display: none;
      align-items: center;
      gap: 8px;
      padding: 6px 12px;
      background: var(--bg-secondary);
      border-top: 1px solid var(--border);
      font-size: 12px;
      color: var(--text-muted);
    }
    #edit-bar.active { display: flex; }
    #edit-bar > span:first-child { color: var(--accent); }
    #edit-bar-text { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-style: italic; color: var(--accent); }
    #edit-cancel { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 18px; line-height: 1; padding: 0 4px; }
    #edit-cancel:hover { color: var(--text); }

    #multi-select-bar {
      display: none;
      align-items: center;
      gap: 10px;
      padding: 8px 12px;
      background: var(--bg-secondary);
      border-top: 1px solid var(--border);
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
      position: relative;
      z-index: 1;
    }
    #multi-select-bar.active { display: flex; }
    #multi-select-count {
      font-size: 12px;
      color: var(--text-muted);
      font-weight: 600;
      min-width: 70px;
    }
    .multi-select-btn {
      border: 1px solid var(--border);
      background: var(--bg-tertiary);
      color: var(--text-primary);
      border-radius: 8px;
      padding: 6px 10px;
      font-size: 12px;
      cursor: pointer;
      font-family: inherit;
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }
    .multi-select-btn:hover { border-color: var(--accent); color: var(--accent); }
    .multi-select-btn.danger:hover { border-color: #ef4444; color: #ef4444; }
    .multi-select-btn.cancel { margin-left: auto; }

    /* Deleted message */
    .msg-deleted { color: #631717; font-style: italic; font-size: 12px; }
    .msg-edited-label { font-size: 10px; color: rgba(255,255,255,0.5); margin-right: 4px; }
    .msg.other .msg-edited-label { color: var(--text-muted); }
    .msg-edit-input {
      width: 100%; min-width: 160px; max-width: 340px;
      background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.3);
      border-radius: 6px; color: inherit; font-size: 13px; font-family: inherit;
      padding: 6px 8px; resize: none; line-height: 1.5; box-sizing: border-box;
      outline: none;
    }
    .msg.other .msg-edit-input { background: var(--bg2); border-color: var(--border); color: var(--text); }
    .msg-edit-btns { display: flex; gap: 6px; margin-top: 6px; justify-content: flex-end; }
    .msg-edit-save { background: #16a34a; border: 1px solid #15803d; color: #fff; border-radius: 6px; padding: 4px 12px; font-size: 12px; cursor: pointer; font-family: inherit; }
    .msg-edit-cancel { background: transparent; border: 1px solid rgba(255,255,255,0.4); color: inherit; border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; font-family: inherit; }
    .msg.other .msg-edit-cancel { border-color: var(--border); }
    /* Emoji reactions */
    .ctx-emoji-row {
      display: flex;
      gap: 2px;
      padding: 8px 6px 6px;
      overflow-x: auto;
      flex-wrap: nowrap;
      scrollbar-width: none;
      -ms-overflow-style: none;
      cursor: grab;
      font-size: 16px;
      -webkit-mask-image: linear-gradient(to right, #000 0, #000 100%);
      mask-image: linear-gradient(to right, #000 0, #000 100%);
      -webkit-mask-repeat: no-repeat;
      mask-repeat: no-repeat;
      -webkit-mask-size: 100% 100%;
      mask-size: 100% 100%;
      transition: -webkit-mask-image 0.16s ease, mask-image 0.16s ease;
    }
    .ctx-emoji-row::-webkit-scrollbar { display: none; }
    .ctx-emoji-row.dragging { cursor: grabbing; user-select: none; }
    .ctx-emoji-row.has-end-fade {
      -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 28px), transparent 100%);
      mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 28px), transparent 100%);
    }
    .ctx-emoji-row .ctx-emoji-btn { flex-shrink: 0; cursor: pointer; border-radius: 8px; padding: 7px 2px 3px 2px; transition: background 0.15s, transform 0.15s, box-shadow 0.15s; line-height:1; font-size: 19px; }
    .ctx-emoji-row .ctx-emoji-btn:hover { background: rgba(255,255,255,0.15); transform: scale(1.04); }
    .ctx-emoji-row .ctx-emoji-btn.selected {
      background: rgba(59,130,246,0.28);
      box-shadow: 0 0 0 1px rgba(125,211,252,0.45) inset;
    }
    .msg-reactions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; padding: 0; }
    .reaction-badge { position: relative; display: inline-flex; align-items: center; gap: 3px; background:rgb(186 199 221 / 30%); border-radius: 12px; padding: 2px 8px; font-size: 16px; cursor: pointer; user-select: none; transition: background 0.15s; }
    .reaction-badge.mine { background: rgba(176, 206, 255, 0.3); }
    .reaction-badge:hover { background: rgba(255,255,255,0.22); }
    .reaction-badge .r-count { font-size: 14px; color: inherit; opacity: 0.9; }
    .msg-bubble.reaction-magic {
      animation: reactionMagicBubble 1.02s cubic-bezier(0.2, 0.8, 0.2, 1);
      transform-origin: center;
    }
    .reaction-badge.magic-pop {
      animation: reactionMagicBadge 1.06s cubic-bezier(0.18, 0.88, 0.22, 1);
      z-index: 1;
    }
    .reaction-badge .r-emoji {
      display: inline-block;
      transform-origin: center;
    }
    .reaction-badge.magic-pop .r-emoji {
      animation: reactionAssignedPulse 1.06s ease-in-out;
    }
    .reaction-badge.magic-pop::after {
      content: '✨';
      position: absolute;
      left: 50%;
      top: 45%;
      transform: translate(-50%, -50%);
      font-size: 13px;
      opacity: 0;
      pointer-events: none;
      filter: drop-shadow(0 0 8px rgba(250, 204, 21, 0.72));
      animation: reactionMagicSparkle 1.06s ease-out;
    }
    @keyframes reactionMagicBubble {
      0% { transform: translateZ(0) scale(1); box-shadow: 0 0 0 rgba(250, 204, 21, 0); }
      30% { transform: translateZ(0) scale(1.04); box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.22); }
      62% { transform: translateZ(0) scale(0.992); box-shadow: 0 0 0 10px rgba(250, 204, 21, 0.08); }
      100% { transform: translateZ(0) scale(1); box-shadow: 0 0 0 rgba(250, 204, 21, 0); }
    }
    @keyframes reactionMagicBadge {
      0% { transform: scale(0.78) rotate(-8deg); }
      36% { transform: scale(1.28) rotate(3deg); }
      68% { transform: scale(0.96) rotate(-1.5deg); }
      100% { transform: scale(1) rotate(0); }
    }
    @keyframes reactionMagicSparkle {
      0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
      35% { opacity: 1; transform: translate(-50%, -95%) scale(1.12); }
      100% { opacity: 0; transform: translate(-50%, -135%) scale(0.68); }
    }
    @keyframes reactionAssignedPulse {
      0% { transform: scale(1); }
      22% { transform: scale(1.34); }
      46% { transform: scale(0.92); }
      68% { transform: scale(1.2); }
      100% { transform: scale(1); }
    }
    .msg-missed-call { display:flex; align-items:center; gap:7px; font-size:13px; padding:1px 0; }
    .msg-missed-icon { font-size:13px; color:#ef4444; }
    .msg.own .msg-missed-call { color:rgba(255,255,255,0.85); }
    .msg.own .msg-missed-icon { color:rgba(255,160,160,1); }
    .msg-call-ended { display:flex; align-items:center; gap:7px; font-size:13px; padding:1px 0; }
    .msg-call-icon { font-size:13px; color:#22c55e; }
    .msg.own .msg-call-ended { color:rgba(255,255,255,0.85); }
    .msg.own .msg-call-icon { color:rgba(160,255,160,1); }

    #msg-system-float {
      position: absolute;
      bottom: 72px;
      left: 50%;
      transform: translateX(-50%);
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 6px;
      pointer-events: none;
      z-index: 12;
      max-width: min(80%, 360px);
    }

    .msg-system {
      color: var(--text-muted);
      font-size: 12px;
      font-style: italic;
      text-align: center;
      background: var(--bg-secondary);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 4px 14px;
      width: max-content;
      max-width: 100%;
      box-shadow: 0 2px 8px rgba(0,0,0,0.18);
      animation: msgSystemSlideUp 0.3s ease-out forwards;
    }

    .msg-system.msg-system-removing {
      animation: msgSystemSlideDown 0.3s ease-in forwards !important;
    }

    @keyframes msgSystemSlideUp {
      from {
        opacity: 0;
        transform: translateY(8px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    @keyframes msgSystemSlideDown {
      to {
        opacity: 0;
        transform: translateY(8px);
      }
    }

    /* --- Input Area --- */
    .input-bar {
      display: flex;
      align-items: center;
      gap: 0px;
      padding: 10px 10px 10px 7px;
      background: var(--bg-secondary);
      border-top: 1px solid var(--border);
      flex-shrink: 0;
      position: relative;
      z-index: 1;
    }

    .input-bar #msg-input {
        flex: 1;
        padding: 8px 10px;
        margin: 0px 6px;
        border-radius: 7px;
        border: 1px solid var(--input-border, var(--border));
        background: var(--bg-tertiary);
        color: var(--text-primary);
        font-size: 15px;
        font-family: inherit;
        outline: none;
        transition: border-color 0.2s;
        overflow-y: hidden;
        line-height: 1.45;
        min-height: 36px;
        max-height: calc(1.45em * 3 + 14px);
        overflow-y: auto;
        box-sizing: border-box;
        display: block;
        white-space: pre-wrap;
        word-break: break-word;
    }
    .input-bar #msg-input[contenteditable="false"] {
      opacity: 0.6;
      cursor: not-allowed;
    }
    .input-bar #msg-input:empty::before {
      content: attr(data-placeholder);
      color: var(--text-muted, #999);
      pointer-events: none;
    }
    .input-bar #msg-input:focus { border-color: var(--accent); }
    .input-bar #msg-input strong, .input-bar #msg-input b { font-weight: 600; }
    .input-bar #msg-input em, .input-bar #msg-input i { font-style: italic; }
    .input-bar #msg-input u { text-decoration: underline; }
    .input-bar #msg-input s, .input-bar #msg-input del { text-decoration: line-through; }
    .input-bar #msg-input code { font-family: monospace; background: rgba(0,0,0,0.08); padding: 1px 3px; border-radius: 3px; font-size: 0.9em; }

    .icon-btn {
      width: 28px;
      height: 28px;
      border-radius: 6px;
      border: none;
      background: transparent;
      color: var(--text-secondary);
      font-size: 18px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: color 0.2s;
      flex-shrink: 0;
      position: relative;
      padding: 0;
    }

    .icon-btn:hover { color: var(--accent); }
    .icon-btn.recording { color: #ef4444; animation: pulse 1s ease-in-out infinite; transform-origin: center; }
    .icon-btn.hidden { display: none; }

    #voice-btn {
      width: 38px;
      height: 38px;
      border-radius: 50%;
      background: linear-gradient(180deg, #38bdf8 0%, #2563eb 100%);
      color: #fff;
      transition: transform 0.2s, filter 0.2s, box-shadow 0.2s;
    }

    #voice-btn:hover {
      color: #fff;
      filter: brightness(1.06);
      transform: translateY(-1px);
      box-shadow: 0 12px 26px rgba(37, 99, 235, 0.34);
    }

    #voice-btn.recording {
      background: linear-gradient(180deg, #f87171 0%, #dc2626 100%);
      color: #fff;
      box-shadow: 0 12px 26px rgba(220, 38, 38, 0.32);
    }

    .send-btn {
      width: 38px;
      height: 38px;
      border-radius: 10px;
      border: none;
      background: var(--accent);
      color: white;
      font-size: 16px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: all 0.2s;
      flex-shrink: 0;
    }

    .send-btn:hover { background: var(--accent-hover); }
    .send-btn.hidden { display: none; }
    #voice-btn.hidden { display: none; }

    .recording-indicator {
      display: none;
      width: 18px;
      height: 18px;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }

    .recording-indicator-dot {
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background: #ef4444;
      box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.38);
      animation: recorderBlink 1s ease-in-out infinite, recorderGlow 1.4s ease-out infinite;
    }

    .record-time {
      display: none;
      min-width: 56px;
      font-size: 13px;
      font-weight: 700;
      font-variant-numeric: tabular-nums;
      color: #ef4444;
      align-items: center;
      justify-content: flex-start;
      flex-shrink: 0;
    }

    .record-actions {
      display: none;
      align-items: center;
      gap: 8px;
      margin: 0 auto;
    }

    .record-action-btn {
      width: 38px;
      height: 38px;
      border-radius: 50%;
      border: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
      background: color-mix(in srgb, var(--bg-tertiary) 92%, transparent);
      color: var(--text-primary);
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 15px;
      transition: transform 0.2s, border-color 0.2s, background 0.2s;
      flex-shrink: 0;
    }

    .record-action-btn:hover {
      transform: translateY(-1px);
      border-color: var(--accent);
      background: color-mix(in srgb, var(--accent) 14%, var(--bg-tertiary));
    }

    .input-bar.recording-mode #emoji-btn,
    .input-bar.recording-mode #attach-btn,
    .input-bar.recording-mode #msg-input,
    .input-bar.recording-mode #voice-btn,
    .input-bar.recording-mode form { display: none !important; }

    .input-bar.recording-mode .recording-indicator,
    .input-bar.recording-mode .record-time,
    .input-bar.recording-mode .record-actions,
    .input-bar.recording-mode .send-btn { display: flex; }

    .input-bar.recording-mode .send-btn {
      margin-left: auto;
      border-radius: 50%;
      background: linear-gradient(135deg, #ef4444, #dc2626) !important;
      animation: composerSendPulse 1.2s ease-in-out infinite;
      box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.75), 0 8px 24px rgba(239, 68, 68, 0.45);
      position: relative;
      overflow: visible;
    }

    @keyframes recorderBlink {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.28; }
    }

    @keyframes recorderGlow {
      0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
      70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
      100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
    }

    @keyframes composerSendPulse {
      0%   { transform: scale(1);    background: linear-gradient(135deg, #ef4444, #dc2626); box-shadow: 0 0 0 0 rgba(239,68,68,0.75), 0 8px 24px rgba(239,68,68,0.45); }
      20%  { background: linear-gradient(135deg, #f97316, #ea580c); }
      40%  { transform: scale(1.18); background: linear-gradient(135deg, #ec4899, #db2777); box-shadow: 0 0 0 16px rgba(239,68,68,0), 0 8px 28px rgba(236,72,153,0.55); }
      60%  { background: linear-gradient(135deg, #f97316, #ea580c); }
      80%  { transform: scale(1.05); background: linear-gradient(135deg, #ef4444, #dc2626); box-shadow: 0 0 0 6px rgba(239,68,68,0.15), 0 8px 22px rgba(239,68,68,0.38); }
      100% { transform: scale(1);    background: linear-gradient(135deg, #ef4444, #dc2626); box-shadow: 0 0 0 0 rgba(239,68,68,0.75), 0 8px 24px rgba(239,68,68,0.45); }
    }

    /* --- Image Viewer --- */
    #image-viewer {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 10000;
      background: #000;
      color: #fff;
      overflow: hidden;
      touch-action: none;
      user-select: none;
      -webkit-user-select: none;
    }
    #image-viewer.iv-open { display: block; }
    .iv-header {
      position: absolute;
      top: 0; left: 0; right: 0;
      z-index: 20;
      display: flex;
      align-items: center;
      gap: 2px;
      padding: max(12px, env(safe-area-inset-top)) 4px 14px;
      background: linear-gradient(to bottom, rgba(0,0,0,0.72) 0%, rgba(0,0,0,0) 100%);
      transition: opacity 0.25s, transform 0.25s;
    }
    .iv-header.iv-ui-hidden {
      opacity: 0;
      pointer-events: none;
      transform: translateY(-100%);
    }
    .iv-btn {
      width: 44px; height: 44px;
      display: inline-flex; align-items: center; justify-content: center;
      border: none; border-radius: 50%;
      background: transparent;
      color: #fff; font-size: 18px;
      cursor: pointer;
      -webkit-tap-highlight-color: transparent;
      transition: background 0.15s, transform 0.1s;
      flex-shrink: 0;
    }
    .iv-btn:hover { background: rgba(255,255,255,0.14); }
    .iv-btn:active { background: rgba(255,255,255,0.22); transform: scale(0.9); }
    .iv-title-area {
      flex: 1;
      min-width: 0;
      text-align: center;
      padding: 0 4px;
    }
    .iv-title {
      font-size: 15px; font-weight: 600;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .iv-subtitle {
      font-size: 12px; color: rgba(255,255,255,0.52);
      margin-top: 1px;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .iv-stage {
      position: absolute; inset: 0;
      overflow: hidden;
      touch-action: none;
    }
    .iv-track {
      position: absolute; inset: 0;
      will-change: transform;
    }
    .iv-slide {
      position: absolute;
      top: 0; bottom: 0;
      width: 100%;
      display: flex; align-items: center; justify-content: center;
    }
    .iv-canvas {
      will-change: transform;
      transform-origin: center center;
      cursor: grab;
      display: flex; align-items: center; justify-content: center;
    }
    .iv-canvas.iv-dragging { cursor: grabbing; }
    .iv-img {
      display: block;
      max-width: 100vw;
      max-height: 100dvh;
      width: auto; height: auto;
      object-fit: contain;
      pointer-events: none;
      -webkit-user-drag: none;
      user-select: none;
    }
    .iv-nav-btn {
      position: absolute; top: 50%; z-index: 15;
      transform: translateY(-50%);
      width: 40px; height: 40px;
      display: flex; align-items: center; justify-content: center;
      border: none; border-radius: 50%;
      background: rgba(0,0,0,0.5);
      color: #fff; font-size: 15px;
      cursor: pointer;
      -webkit-tap-highlight-color: transparent;
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      transition: background 0.15s;
    }
    .iv-nav-btn:hover { background: rgba(0,0,0,0.78); }
    .iv-nav-btn.iv-prev { left: 10px; }
    .iv-nav-btn.iv-next { right: 10px; }
    @media (max-width: 640px) { .iv-nav-btn { display: none; } }
    .iv-footer {
      position: absolute;
      left: 0; right: 0; bottom: 0;
      z-index: 20;
      padding: 28px 16px max(14px, env(safe-area-inset-bottom));
      background: linear-gradient(to top, rgba(0,0,0,0.72) 0%, rgba(0,0,0,0) 100%);
      display: flex; flex-direction: column; gap: 8px;
      transition: opacity 0.25s, transform 0.25s;
    }
    .iv-footer.iv-ui-hidden {
      opacity: 0;
      pointer-events: none;
      transform: translateY(100%);
    }
    .iv-caption {
      font-size: 13.5px; line-height: 1.5;
      color: rgba(255,255,255,0.9);
      white-space: pre-wrap; word-break: break-word;
    }
    .iv-counter {
      font-size: 12px; color: rgba(255,255,255,0.6);
      background: rgba(255,255,255,0.12);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      border-radius: 20px;
      padding: 3px 11px;
      align-self: flex-start;
      letter-spacing: 0.02em;
    }
    .iv-menu {
      position: absolute;
      top: max(60px, calc(env(safe-area-inset-top) + 52px));
      right: 4px;
      z-index: 25;
      min-width: 190px;
      border-radius: 14px;
      background: rgba(22,22,24,0.97);
      border: 1px solid rgba(255,255,255,0.1);
      box-shadow: 0 12px 38px rgba(0,0,0,0.6);
      backdrop-filter: blur(24px);
      -webkit-backdrop-filter: blur(24px);
      overflow: hidden;
      display: flex; flex-direction: column;
      transform-origin: top right;
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
      transform: translateY(-4px) scale(0.95);
      transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s;
    }
    .iv-menu.iv-open {
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
      transform: none;
    }
    @keyframes ivMenuIn {
      from { opacity: 0; transform: scale(0.88); }
      to   { opacity: 1; transform: scale(1); }
    }
    .iv-menu-item {
      display: flex; align-items: center; gap: 12px;
      padding: 13px 16px;
      border: none; background: transparent;
      color: #fff; font-size: 14px; font-family: inherit;
      cursor: pointer; text-align: left;
      transition: background 0.1s;
    }
    .iv-menu-item + .iv-menu-item { border-top: 1px solid rgba(255,255,255,0.07); }
    .iv-menu-item:hover { background: rgba(255,255,255,0.09); }
    .iv-menu-item:active { background: rgba(255,255,255,0.16); }
    .iv-menu-item.iv-danger { color: #ff6b6b; }
    .iv-menu-item i { width: 16px; text-align: center; }
    .emoji-picker {
      display: flex;
      flex-direction: column;
      position: absolute;
      bottom: calc(100% + 8px);
      left: 0;
      background: var(--bg-secondary);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 0;
      width: 320px;
      max-height: 320px;
      overflow: hidden;
      box-shadow: var(--shadow);
      z-index: 40;
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
      transform: translateY(4px) scale(0.97);
      transition: opacity 0.13s ease, transform 0.13s ease, visibility 0.13s;
    }

    .emoji-picker.open {
      transform-origin: bottom left;
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
      transform: none;
    }
    .emoji-picker-tabs {
      display: flex;
      gap: 0;
      padding: 6px;
      border-bottom: 1px solid var(--border);
      background: rgba(255,255,255,0.03);
    }
    .emoji-picker-tab {
      flex: 1;
      border: 0;
      background: transparent;
      color: var(--text-secondary);
      font: inherit;
      font-size: 13px;
      font-weight: 700;
      padding: 10px 12px;
      border-radius: 10px;
      cursor: pointer;
      transition: background 0.15s ease, color 0.15s ease;
    }
    .emoji-picker-tab.active {
      background: var(--bg-tertiary);
      color: var(--text-primary);
    }
    .emoji-picker-body {
      display: none;
      padding: 10px;
      overflow-y: auto;
      min-height: 188px;
      scrollbar-width: thin;
      scrollbar-color: var(--border) transparent;
    }
    .emoji-picker-body::-webkit-scrollbar {
      width: 5px;
    }
    .emoji-picker-body::-webkit-scrollbar-track {
      background: transparent;
    }
    .emoji-picker-body::-webkit-scrollbar-thumb {
      background: var(--border);
      border-radius: 10px;
    }
    .emoji-picker-body.active {
      display: block;
    }
    .emoji-picker-emoji-grid {
      display: grid;
      grid-template-columns: repeat(8, minmax(0, 1fr));
      gap: 4px;
    }
    .emoji-picker-emoji-btn {
      border: 0;
      background: transparent;
      font-size: 22px;
      cursor: pointer;
      padding: 6px 4px;
      border-radius: 8px;
      transition: background 0.15s;
      line-height: 1;
    }
    .emoji-picker-emoji-btn:hover { background: var(--bg-tertiary); }
    .emoji-picker-gif-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 8px;
    }
    .emoji-picker-gif-card {
      border: 1px solid rgba(255,255,255,0.08);
      background: rgba(255,255,255,0.03);
      border-radius: 12px;
      overflow: hidden;
      cursor: pointer;
      padding: 0;
      transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
    }
    .emoji-picker-gif-card:hover {
      transform: translateY(-1px);
      border-color: rgba(125, 211, 252, 0.3);
      background: rgba(255,255,255,0.06);
    }
    .emoji-picker-gif-card img {
      display: block;
      width: 100%;
      height: 85px;
      object-fit: cover;
      background: rgba(255,255,255,0.04);
    }
    .emoji-picker-gif-name {
      display: block;
      padding: 8px 9px 9px;
      font-size: 11px;
      line-height: 1.35;
      color: var(--text-secondary);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      text-align: left;
    }
    @keyframes gif-skeleton-pulse {
      0%, 100% { opacity: 0.45; }
      50% { opacity: 0.2; }
    }
    .gif-skeleton-card {
      border: 1px solid rgba(255,255,255,0.08);
      background: rgba(255,255,255,0.04);
      border-radius: 12px;
      overflow: hidden;
      pointer-events: none;
      animation: gif-skeleton-pulse 1.2s ease-in-out infinite;
    }
    .gif-skeleton-img {
      width: 100%;
      height: 104px;
      background: rgba(255,255,255,0.1);
    }

/* Jibit bot copy icon */
.jibit-copy-icon {
  font-size: 13px;
  font-style: normal !important;
  margin-right: 8px;
  color: #065c99;
}

.jibit-copy-btn {
  background-color: transparent;
  border: none;
  cursor: pointer;
  padding: 0 0 0 5px;
  color: var(--muted, #9ca3af);
  vertical-align: middle;
  opacity: 0.75;
  font-size: 13px;
}

.jibit-new-inquiry-btn {
  font-family: Vazirmatn, sans-serif;
  border: 1px solid rgba(8, 145, 178, 0.28);
  background: rgba(8, 145, 178, 0.1);
  color: #0f766e;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.jibit-new-inquiry-btn:hover {
  background: rgba(8, 145, 178, 0.16);
  border-color: rgba(8, 145, 178, 0.42);
  transform: translateY(-1px);
}

.msg-outside-actions {
  margin-top: 6px;
}

.msg.other .msg-outside-actions {
  align-self: flex-start;
}

.msg.own .msg-outside-actions {
  align-self: flex-end;
}


/* ── Download progress bar ───────────────────────────────────── */
#dl-progress-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px 14px;
  min-width: 240px;
  max-width: min(380px, 92vw);
  z-index: 3000;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
#dl-progress-toast.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.dl-progress-icon {
  font-size: 16px;
  color: var(--accent);
  flex-shrink: 0;
}
.dl-progress-info {
  flex: 1;
  min-width: 0;
}
.dl-progress-name {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
  color: var(--text-primary);
}
.dl-progress-track {
  height: 3px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}
.dl-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.12s linear;
}
.dl-progress-fill.indeterminate {
  width: 35%;
  animation: dl-indeterminate 1.1s infinite ease-in-out;
}
@keyframes dl-indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(320%); }
}
.dl-progress-pct {
  font-size: 11px;
  color: var(--text-secondary);
  flex-shrink: 0;
  min-width: 32px;
  text-align: end;
}

/* ── Poll Card (standalone, not inside message bubble) ──────────────────── */

/* Neutralize the bubble wrapper for poll messages */
.poll-bubble {
  background: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
  max-width: 380px !important;
}
.poll-bubble .msg-footer { display: none !important; }
.poll-bubble .msg-reactions { padding: 2px 0 0 !important; }

/* The poll card itself */
.poll-card {
  background: var(--bg-primary);
  border: 1.5px solid var(--border-color);
  border-radius: 18px;
  padding: 15px 16px 13px;
  width: 100%;
  box-sizing: border-box;
  user-select: none;
  box-shadow: 0 2px 14px rgba(0,0,0,0.07);
}
[data-theme="dark"] .poll-card,
.dark-mode .poll-card {
  background: var(--bg-secondary);
  box-shadow: 0 2px 14px rgba(0,0,0,0.22);
}

/* Card header: icon + "Poll" label + optional status badge */
.poll-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 11px;
}
.poll-card-icon {
  width: 26px;
  height: 26px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  flex-shrink: 0;
}
.poll-card-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  flex: 1;
}
.poll-card-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
}
.poll-card-badge.closed {
  background: rgba(229,57,53,0.1);
  color: var(--error, #e53e3e);
}

/* Question */
.poll-question {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.45;
  word-break: break-word;
  margin-bottom: 13px;
}
.poll-question.rtl { direction: rtl; text-align: right; }

/* Options list */
.poll-options {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 11px;
}

/* Each option row: relative-positioned for background fill bar */
.poll-option-row {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  border: 1.5px solid var(--border-color);
  background: var(--bg-tertiary);
  transition: border-color 0.15s;
}
.poll-option-row:hover:not(.closed) { border-color: var(--accent); }
.poll-option-row.closed { cursor: default; }
.poll-option-row.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--bg-primary));
}

/* Animated background fill bar (absolutely positioned, behind content) */
.poll-bar-track {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.poll-bar-fill {
  height: 100%;
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  border-radius: 9px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.poll-option-row.selected .poll-bar-fill {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

/* Content row above the bar (z-index: 1) */
.poll-option-label {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
}
.poll-option-label.rtl { flex-direction: row-reverse; direction: rtl; }

/* Radio / checkbox dot */
.poll-option-check {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  transition: background 0.15s, border-color 0.15s;
}
.poll-option-check.multi { border-radius: 5px; }
.poll-option-row.selected .poll-option-check {
  background: var(--accent);
  border-color: var(--accent);
}
.poll-option-check i { font-size: 10px; color: #fff; }

/* Option text */
.poll-option-label > span:not(.poll-bar-pct) {
  flex: 1;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-word;
}

/* Percentage (inline, right-aligned) */
.poll-bar-pct {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 34px;
  text-align: right;
  flex-shrink: 0;
}
.poll-option-label.rtl .poll-bar-pct { text-align: left; }

/* Meta row (votes count, view-votes link, deadline, status badge) */
.poll-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 9px;
}
.poll-status-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}
.poll-status-badge.closed {
  background: rgba(229,57,53,0.1);
  color: var(--error, #e53e3e);
}

/* "View votes" inline link button */
.poll-view-votes-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  transition: opacity 0.12s;
}
.poll-view-votes-btn:hover { opacity: 0.75; }

/* Time footer inside the card */
.poll-card-time {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--border-color);
  font-size: 11px;
  color: var(--text-muted);
}

/* Hidden results placeholder */
.poll-results-hidden {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 6px 0 2px;
}

/* Loading spinner inside poll options */
.poll-loading-indicator {
  text-align: center;
  padding: 12px 0;
  color: var(--text-muted);
  font-size: 16px;
}

/* ── Poll Voters Modal ──────────────────────────────────────────────────────── */
.poll-voters-box {
  max-width: 360px;
  padding: 0;
  max-height: 76vh;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
}
.poll-voters-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px 11px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.poll-voters-modal-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.poll-voters-modal-body {
  overflow-y: auto;
  flex: 1;
  padding: 13px 15px 15px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.poll-voters-question {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
  line-height: 1.4;
}
.poll-voters-question i { color: var(--accent); margin-top: 2px; flex-shrink: 0; }
.poll-voters-question.rtl { flex-direction: row-reverse; direction: rtl; }
.poll-voters-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.poll-voters-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.poll-voters-group-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  word-break: break-word;
}
.poll-voters-group-text.rtl { direction: rtl; text-align: right; }
.poll-voters-group-count {
  font-size: 11px;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  border-radius: 20px;
  padding: 1px 8px;
  flex-shrink: 0;
}
.poll-voters-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-left: 4px;
}
.poll-voters-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-primary);
}
.poll-voters-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.poll-voters-empty {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  padding: 2px 0 2px 4px;
}
.poll-voters-anon-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
  padding: 20px 0;
  justify-content: center;
}
.poll-voters-anon-notice i { font-size: 18px; }
