      /* ============================================================
       DESIGN TOKENS
       ============================================================ */
     :root{
    /* Brand */
    --brand-900:#314238;
    --brand-800:#3E5347;
    --brand-700:#56705F;
    --brand-600:#6E8A75;
    --brand-500:#7FA387;
    --brand-400:#A5C0AA;

    /* Accent */
    --accent:#C89B5B;
    --accent-soft:rgba(200,155,91,.15);

    /* Backgrounds */
    --bg-app:#F3EEE6;
    --bg-pane:#FBF9F4;
    --bg-chat:#F7F4EE;
    --bg-chat-pattern:rgba(84,96,74,.03);

    /* Surface */
    --surface:#FFFFFF;
    --surface-raised:#FFFDFC;

    /* Login */
    --bg-login:#F8F4ED;

    /* Message */
    --bubble-them:#FFFFFF;
    --bubble-them-text:#2B2A27;

    --bubble-me:#EFE7DA;
    --bubble-me-text:#2C2A26;

    /* Text */
    --ink:#2D2A27;
    --ink-soft:#6F6B65;
    --ink-faint:#AAA39A;

    /* Border */
    --line:#E6DFD5;
    --line-soft:rgba(0,0,0,.05);

    /* Status */
    --online:#5E8966;
    --online-bg:rgba(94,137,102,.12);

    --danger:#C45B4A;
    --danger-bg:#FBEAE7;

    --warn:#C89B5B;

    /* Shadow */
    --shadow-1:0 1px 2px rgba(0,0,0,.05);
    --shadow-2:0 6px 18px rgba(0,0,0,.08);
    --shadow-3:0 18px 40px rgba(0,0,0,.12);

    --r-xs:8px;
    --r-sm:12px;
    --r-md:16px;
    --r-lg:22px;
    --r-pill:999px;
}

      * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
        -webkit-tap-highlight-color: transparent;
      }

      html,
      body {
        height: 100%;
      }

      body {
        font-family: var(--font-display);
        background: var(--bg-app);
        color: var(--ink);
        display: flex;
        height: 100dvh;
        overflow-y: auto;
        overflow-x: hidden;
        direction: rtl;
        font-size: 15px;
      }

      button,
      input,
      textarea {
        font-family: inherit;
        color: inherit;
      }

      ::-webkit-scrollbar {
        width: 6px;
        height: 6px;
      }

      ::-webkit-scrollbar-track {
        background: transparent;
      }

      ::-webkit-scrollbar-thumb {
        background: rgba(11, 61, 46, 0.18);
        border-radius: 10px;
      }

      ::-webkit-scrollbar-thumb:hover {
        background: rgba(11, 61, 46, 0.32);
      }

      /* ============================================================
       AUTH SCREEN
       ============================================================ */
    /* ============================================================
   AUTH SCREEN
   ============================================================ */

#auth-screen {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background:
    radial-gradient(circle at top left, rgba(200, 155, 91, .16), transparent 38%),
    radial-gradient(circle at bottom right, rgba(107, 139, 115, .10), transparent 42%),
    linear-gradient(180deg, #FCFAF6 0%, #F5F0E8 55%, #EEE6DA 100%);
  position: relative;
  overflow: auto;
  padding: 24px;
}

.auth-card {
  background: rgba(255, 255, 253, .94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid #E8DFD2;
  border-radius: var(--r-lg);
  box-shadow: 0 20px 50px rgba(80, 60, 30, .12);
  padding: 2.4rem 2rem;
  width: 100%;
  max-width: 408px;
  position: relative;
  animation: cardIn .45s var(--ease);
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-logo {
  text-align: center;
  margin-bottom: 1.8rem;
}

.auth-logo-icon {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #C79A5A, #B9854A);
  border-radius: 18px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 28px rgba(185, 133, 74, .28);
  position: relative;
}

.auth-logo-icon svg {
  width: 30px;
  height: 30px;
}

.auth-logo h1 {
  font-size: 1.4rem;
  font-weight: 800;
  color: #3E3126;
  letter-spacing: -.2px;
}

.auth-logo p {
  font-size: .8rem;
  color: #7A756D;
  margin-top: 5px;
}

#auth-error,
#auth-success {
  font-size: .78rem;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  margin-bottom: 14px;
  display: none;
  text-align: center;
  line-height: 1.6;
}

#auth-error {
  background: #FBEAE6;
  border: 1px solid #F0CCC2;
  color: #C24A3B;
}

#auth-success {
  background: rgba(107, 139, 115, .12);
  border: 1px solid rgba(107, 139, 115, .25);
  color: #587861;
}

.form-group {
  margin-bottom: 13px;
}

.form-group label {
  display: block;
  font-size: .76rem;
  font-weight: 600;
  color: #6D675F;
  margin-bottom: 6px;
  padding-right: 2px;
}

.form-group input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #E3DDD2;
  border-radius: var(--r-sm);
  font-size: .9rem;
  background: #FFF;
  transition: var(--t-fast);
  outline: none;
  color: #2D2A27;
}

.form-group input:focus {
  border-color: #C79A5A;
  box-shadow: 0 0 0 4px rgba(200, 155, 91, .16);
}

.form-group input::placeholder {
  color: #A7A095;
}

.unique-id-status {
  font-size: .72rem;
  margin-top: 5px;
  padding-right: 2px;
}

.unique-id-available {
  color: #587861;
}

.unique-id-taken {
  color: #C24A3B;
}

.unique-id-checking {
  color: #9A948B;
}

.btn-primary {
  width: 100%;
  padding: 12px 20px;
  background: linear-gradient(135deg, #6F8C76, #56705F);
  color: #FFF;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: .9rem;
  font-weight: 700;
  transition: .25s ease;
  box-shadow: 0 8px 22px rgba(86, 112, 95, .25);
  letter-spacing: .2px;
  margin-top: 4px;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #5D7865, #476051);
  box-shadow: 0 12px 28px rgba(86, 112, 95, .35);
  transform: translateY(-2px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.auth-toggle {
  text-align: center;
  margin-top: 18px;
  font-size: .82rem;
  color: #6F8C76;
  cursor: pointer;
  font-weight: 600;
}

.auth-toggle:hover {
  color: #56705F;
  text-decoration: underline;
}
      /* ============================================================
       APP SHELL
       ============================================================ */
      #app-screen {
        display: none;
        width: 100%;
        height: 100%;
        flex-direction: row;
        overflow: hidden;
        background: var(--bg-app);
      }

      .sidebar {
        width: 380px;
        min-width: 300px;
        max-width: 420px;
        background: var(--bg-pane);
        display: flex;
        flex-direction: column;
        flex-shrink: 0;
        border-left: 1px solid var(--line);
      }

      .sidebar-header {
        padding: 14px 16px;
        background: var(--bg-pane);
        flex-shrink: 0;
      }

      .sidebar-top {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 14px;
      }

      .sidebar-brand {
        display: flex;
        align-items: center;
        gap: 9px;
      }

      .sidebar-brand-icon {
        width: 36px;
        height: 36px;
        background: linear-gradient(140deg, var(--brand-700), var(--brand-500));
        border-radius: 11px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 3px 10px rgba(17, 87, 64, 0.25);
      }

      .sidebar-brand-icon svg {
        width: 19px;
        height: 19px;
      }

      .sidebar-brand span {
        font-weight: 800;
        font-size: 1.08rem;
        color: var(--brand-800);
        letter-spacing: -0.2px;
      }

      .sidebar-actions {
        display: flex;
        gap: 6px;
      }

      .icon-btn {
        background: transparent;
        border: none;
        border-radius: 50%;
        cursor: pointer;
        width: 38px;
        height: 38px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: var(--t-fast);
        color: var(--ink-soft);
      }

      .icon-btn svg {
        width: 19px;
        height: 19px;
      }

      .icon-btn:hover {
        background: var(--line-soft);
        color: var(--brand-700);
      }

      .icon-btn.danger:hover {
        background: var(--danger-bg);
        color: var(--danger);
      }

      .sidebar-search {
        position: relative;
      }

      .sidebar-search input {
        width: 100%;
        padding: 10px 40px 10px 16px;
        border: none;
        border-radius: var(--r-pill);
        font-size: 0.84rem;
        background: var(--surface);
        box-shadow: var(--shadow-1);
        transition: var(--t-fast);
        outline: none;
      }

      .sidebar-search input:focus {
        box-shadow: 0 0 0 3px rgba(30, 142, 99, 0.14);
      }

      .sidebar-search-icon {
        position: absolute;
        right: 14px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--ink-faint);
        pointer-events: none;
        display: flex;
      }

      .sidebar-search-icon svg {
        width: 16px;
        height: 16px;
      }

      .sidebar-tabs {
        display: flex;
        gap: 8px;
        padding: 10px 16px 0;
        flex-shrink: 0;
      }

      .sidebar-tab {
        padding: 7px 16px;
        font-size: 0.78rem;
        font-weight: 700;
        color: var(--ink-soft);
        cursor: pointer;
        border-radius: var(--r-pill);
        transition: var(--t-fast);
        white-space: nowrap;
        background: transparent;
      }

      .sidebar-tab.active {
        color: #fff;
        background: var(--brand-700);
      }

      .sidebar-tab:hover:not(.active) {
        background: var(--line-soft);
        color: var(--brand-700);
      }

      .sidebar-body {
        flex: 1;
        overflow-y: auto;
        padding: 10px 0 12px;
      }

      .section-label {
        font-size: 0.68rem;
        font-weight: 700;
        color: var(--ink-faint);
        text-transform: uppercase;
        letter-spacing: 0.7px;
        padding: 10px 20px 6px;
      }

      .list-empty {
        padding: 50px 24px;
        text-align: center;
        color: var(--ink-faint);
        font-size: 0.84rem;
        line-height: 1.7;
      }

      /* ─── CHAT ITEM ─────────────────────────── */
      .chat-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 16px;
        cursor: pointer;
        transition: background var(--t-fast);
        position: relative;
      }

      .chat-item:hover {
        background: rgba(11, 61, 46, 0.05);
      }

      .chat-item.active {
        background: rgba(30, 142, 99, 0.12);
      }

      .chat-item.active .chat-name {
        color: var(--brand-800);
      }

      .avatar-wrap {
        position: relative;
        flex-shrink: 0;
      }

      .avatar {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background: linear-gradient(140deg, #C9E8D8, #9FD4B8);
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 700;
        font-size: 1.05rem;
        color: var(--brand-700);
        flex-shrink: 0;
        overflow: hidden;
      }

      .avatar.group {
        background: linear-gradient(140deg, #F2DFB0, #E8C780);
        color: #8A6418;
      }

      .avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 50%;
      }

      .online-dot {
        position: absolute;
        bottom: 1px;
        left: 1px;
        width: 13px;
        height: 13px;
        background: var(--online);
        border-radius: 50%;
        border: 2.5px solid var(--bg-pane);
      }

      .chat-info {
        flex: 1;
        min-width: 0;
      }

      .chat-name-row {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        margin-bottom: 3px;
        gap: 8px;
      }

      .chat-name {
        font-size: 0.92rem;
        font-weight: 700;
        color: var(--ink);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .chat-time {
        font-size: 0.7rem;
        color: var(--ink-faint);
        white-space: nowrap;
        flex-shrink: 0;
      }

      .chat-preview-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
      }

      .chat-preview {
        font-size: 0.81rem;
        color: var(--ink-soft);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
      }

      .chat-preview.unread-preview {
        color: var(--ink);
        font-weight: 700;
      }

      .unread-badge {
        background: var(--brand-500);
        color: #fff;
        font-size: 0.68rem;
        font-weight: 700;
        min-width: 19px;
        height: 19px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 6px;
        flex-shrink: 0;
      }

      .sidebar-tick {
        font-size: 0.7rem;
        margin-right: 4px;
        flex-shrink: 0;
        line-height: 1;
      }

      /* ============================================================
       MAIN / CHAT COLUMN
       ============================================================ */
      .main {
        flex: 1;
        display: flex;
        flex-direction: column;
        background: var(--bg-chat);
        min-width: 0;
        overflow: hidden;
        position: relative;
      }

      .main::before {
        content: '';
        position: absolute;
        inset: 0;
        background-image:
          radial-gradient(var(--bg-chat-pattern) 1.1px, transparent 1.1px);
        background-size: 26px 26px;
        pointer-events: none;
        z-index: 0;
      }

      .chat-header {
        background: var(--bg-pane);
        border-bottom: 1px solid var(--line);
        padding: 10px 18px;
        display: flex;
        align-items: center;
        gap: 12px;
        flex-shrink: 0;
        z-index: 2;
        position: relative;
      }

      .header-back-btn {
        display: none;
      }

      .chat-header-avatar {
        position: relative;
      }

      .chat-header-info {
        flex: 1;
        min-width: 0;
        cursor: pointer;
      }

      .chat-header-name {
        font-size: 0.95rem;
        font-weight: 700;
        color: var(--ink);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .chat-header-status {
        font-size: 0.76rem;
        margin-top: 2px;
        display: flex;
        align-items: center;
        gap: 5px;
      }

      .status-online {
        color: var(--online);
        font-weight: 600;
      }

      .status-offline {
        color: var(--ink-faint);
      }

      .status-typing {
        color: var(--brand-500);
        font-weight: 600;
      }

      .chat-header-actions {
        display: flex;
        gap: 2px;
      }

      .messages-area {
        flex: 1;
        padding: 18px 6% 12px;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        gap: 5px;
        position: relative;
        z-index: 1;
        scroll-behavior: auto;
      }

      .msg-loading-older {
        text-align: center;
        padding: 10px;
        font-size: 0.76rem;
        color: var(--ink-faint);
        flex-shrink: 0;
      }

      .date-divider {
        text-align: center;
        margin: 14px 0 10px;
        position: sticky;
        top: 4px;
        z-index: 1;
        align-self: center;
      }

      .date-divider span {
        background: rgba(255, 255, 255, 0.88);
        backdrop-filter: blur(4px);
        padding: 5px 14px;
        font-size: 0.72rem;
        color: var(--ink-soft);
        font-weight: 600;
        border-radius: var(--r-pill);
        box-shadow: var(--shadow-1);
      }

      .msg-row {
        display: flex;
        gap: 8px;
        max-width: 68%;
        animation: msgIn 0.22s var(--ease);
      }

      .msg-row.me {
        align-self: flex-end;
        flex-direction: row-reverse;
      }

      .msg-row.them {
        align-self: flex-start;
      }

      @keyframes msgIn {
        from {
          opacity: 0;
          transform: translateY(6px) scale(0.985);
        }

        to {
          opacity: 1;
          transform: translateY(0) scale(1);
        }
      }

      .msg-avatar {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        background: linear-gradient(140deg, #C9E8D8, #9FD4B8);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.7rem;
        font-weight: 700;
        color: var(--brand-700);
        flex-shrink: 0;
        align-self: flex-end;
        overflow: hidden;
        visibility: hidden;
      }

      .msg-row.them.show-avatar .msg-avatar {
        visibility: visible;
      }

      .msg-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 50%;
      }

      .msg-bubble {
        padding: 8px 12px 9px;
        border-radius: var(--r-md);
        font-size: 0.875rem;
        line-height: 1.65;
        word-break: break-word;
        position: relative;
        max-width: 100%;
        box-shadow: var(--shadow-1);
      }

      .msg-row.them .msg-bubble {
        background: var(--bubble-them);
        color: var(--bubble-them-text);
        border-radius: var(--r-md) var(--r-md) var(--r-md) 4px;
      }

      .msg-row.me .msg-bubble {
        background: var(--bubble-me);
        color: var(--bubble-me-text);
        border-radius: var(--r-md) var(--r-md) 4px var(--r-md);
      }

      .msg-row.consecutive.them .msg-bubble {
        border-radius: var(--r-md);
      }

      .msg-row.consecutive.me .msg-bubble {
        border-radius: var(--r-md);
      }

      .msg-sender-name {
        font-size: 0.71rem;
        font-weight: 700;
        color: var(--brand-600);
        margin-bottom: 3px;
      }

      .msg-file-img {
        max-width: 280px;
        max-height: 220px;
        border-radius: 10px;
        margin-bottom: 5px;
        cursor: pointer;
        display: block;
      }

      .msg-file-link {
        display: inline-flex;
        align-items: center;
        gap: 7px;
        padding: 8px 12px;
        background: rgba(11, 61, 46, 0.06);
        border-radius: 10px;
        margin-bottom: 5px;
        font-size: 0.8rem;
        text-decoration: none;
        color: inherit;
        font-weight: 600;
      }

      .msg-row.me .msg-file-link {
        background: rgba(11, 61, 46, 0.08);
      }

      .msg-text {
        font-family: 'Vazirmatn', 'Noto Color Emoji', 'Segoe UI Emoji', 'Apple Color Emoji', sans-serif;
        white-space: pre-wrap;
        /* این خط مهمه - فاصله‌ها و خطوط رو حفظ می‌کنه */
        word-break: break-word;
      }

      .msg-meta {
        display: flex;
        align-items: center;
        gap: 5px;
        margin-top: 2px;
        justify-content: flex-end;
        float: left;
        transform: translateY(2px);
      }

      .msg-time {
        font-size: 0.65rem;
        color: var(--ink-faint);
      }

      .msg-row.me .msg-time {
        color: rgba(20, 36, 28, 0.55);
      }

      .msg-status {
        font-size: 0.78rem;
        line-height: 1;
        color: var(--ink-faint);
      }

      .msg-status.read {
        color: var(--brand-500);
      }

      .msg-edited {
        font-size: 0.65rem;
        color: var(--ink-faint);
      }

      .msg-row.me .msg-edited {
        color: rgba(20, 36, 28, 0.5);
      }

      .msg-edit-btn {
        font-size: 0.7rem;
        cursor: pointer;
        opacity: 0;
        transition: opacity var(--t-fast);
        width: 18px;
        height: 18px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        color: inherit;
      }

      .msg-bubble:hover .msg-edit-btn {
        opacity: 0.55;
      }

      .msg-edit-btn:hover {
        opacity: 1 !important;
        background: rgba(0, 0, 0, 0.08);
      }

      .msg-edit-btn svg {
        width: 11px;
        height: 11px;
      }

      .typing-row {
        display: flex;
        gap: 8px;
        align-items: flex-end;
        align-self: flex-start;
        animation: msgIn 0.2s var(--ease);
      }

      .typing-bubble {
        background: var(--bubble-them);
        border-radius: var(--r-md) var(--r-md) var(--r-md) 4px;
        padding: 11px 16px;
        display: flex;
        align-items: center;
        gap: 4px;
        box-shadow: var(--shadow-1);
      }

      .typing-dot {
        width: 6px;
        height: 6px;
        background: var(--ink-faint);
        border-radius: 50%;
        animation: typingBounce 1.3s infinite ease-in-out;
      }

      .typing-dot:nth-child(2) {
        animation-delay: 0.15s;
        background: var(--brand-500);
        opacity: 0.75;
      }

      .typing-dot:nth-child(3) {
        animation-delay: 0.3s;
        background: var(--brand-500);
      }

      @keyframes typingBounce {

        0%,
        60%,
        100% {
          transform: translateY(0);
        }

        30% {
          transform: translateY(-5px);
        }
      }

      .typing-label {
        font-size: 0.71rem;
        color: var(--brand-600);
        font-style: normal;
        font-weight: 600;
        align-self: flex-end;
        padding-bottom: 5px;
      }

      .input-area {
        background: var(--bg-pane);
        border-top: 1px solid var(--line);
        padding: 10px 16px;
        display: none;
        flex-shrink: 0;
        z-index: 2;
        position: relative;
      }

      .editing-banner {
        display: none;
        align-items: center;
        justify-content: space-between;
        background: var(--accent-soft);
        border-radius: var(--r-sm);
        padding: 7px 12px;
        margin-bottom: 8px;
        font-size: 0.78rem;
        color: #8A6418;
        font-weight: 600;
      }

      .editing-banner.show {
        display: flex;
      }

      .editing-banner-cancel {
        cursor: pointer;
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        flex-shrink: 0;
      }

      .editing-banner-cancel:hover {
        background: rgba(0, 0, 0, 0.08);
      }

      .editing-banner-cancel svg {
        width: 12px;
        height: 12px;
      }

      .input-row {
        display: flex;
        gap: 8px;
        align-items: flex-end;
      }

      .attach-btn {
        width: 42px;
        height: 42px;
        border-radius: 50%;
        background: transparent;
        border: none;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: var(--t-fast);
        color: var(--ink-soft);
        flex-shrink: 0;
      }

      .attach-btn svg {
        width: 21px;
        height: 21px;
      }

      .attach-btn:hover {
        background: var(--line-soft);
        color: var(--brand-700);
      }

      .msg-input-wrap {
        flex: 1;
        position: relative;
      }

      .msg-input {
        width: 100%;
        padding: 11px 18px;
        border: none;
        border-radius: var(--r-pill);
        font-size: 0.9rem;
        background: var(--surface);
        resize: none;
        outline: none;
        transition: var(--t-fast);
        max-height: 120px;
        overflow-y: auto;
        line-height: 1.5;
        box-shadow: var(--shadow-1);
      }

      .msg-input:focus {
        box-shadow: 0 0 0 3px rgba(30, 142, 99, 0.14);
      }

      .send-btn {
        width: 42px;
        height: 42px;
        background: linear-gradient(140deg, var(--brand-700), var(--brand-500));
        border: none;
        border-radius: 50%;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: var(--t-fast);
        flex-shrink: 0;
        box-shadow: 0 4px 14px rgba(17, 87, 64, 0.35);
      }

      .send-btn svg {
        width: 18px;
        height: 18px;

      }

      .send-btn:hover {
        transform: scale(1.06);
      }

      .send-btn:active {
        transform: scale(0.95);
      }

      .file-pending-banner {
        display: none;
        align-items: center;
        gap: 8px;
        background: var(--online-bg);
        color: #1E8052;
        border-radius: var(--r-sm);
        padding: 7px 12px;
        margin-bottom: 8px;
        font-size: 0.78rem;
        font-weight: 600;
      }

      .file-pending-banner.show {
        display: flex;
      }

      .empty-state {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 18px;
        color: var(--ink-soft);
        padding: 40px;
        z-index: 1;
        position: relative;
      }

      .empty-state-icon {
        width: 96px;
        height: 96px;
        background: var(--surface);
        border-radius: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: var(--shadow-2);
      }

      .empty-state-icon svg {
        width: 46px;
        height: 46px;
        color: var(--brand-400);
      }

      .empty-state h3 {
        font-size: 1.15rem;
        font-weight: 800;
        color: var(--brand-800);
      }

      .empty-state p {
        font-size: 0.86rem;
        text-align: center;
        line-height: 1.7;
        max-width: 320px;
        color: var(--ink-soft);
      }

      .panel-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(4, 34, 26, 0.32);
        z-index: 50;
        animation: fadeIn var(--t-med);
      }

      .panel-overlay.open {
        display: block;
      }

      @keyframes fadeIn {
        from {
          opacity: 0;
        }

        to {
          opacity: 1;
        }
      }

      .side-panel {
        width: 380px;
        max-width: 92vw;
        background: var(--surface);
        display: none;
        flex-direction: column;
        box-shadow: var(--shadow-3);
        overflow-y: auto;
        z-index: 51;
        position: fixed;
        top: 0;
        bottom: 0;
        right: 0;
        animation: panelSlide var(--t-med);
      }

      @keyframes panelSlide {
        from {
          transform: translateX(100%);
        }

        to {
          transform: translateX(0);
        }
      }

      .side-panel.open {
        display: flex;
      }

      .panel-header {
        padding: 18px 20px;
        border-bottom: 1px solid var(--line);
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: sticky;
        top: 0;
        background: var(--surface);
        z-index: 1;
      }

      .panel-title {
        font-size: 1rem;
        font-weight: 800;
        color: var(--brand-800);
        display: flex;
        align-items: center;
        gap: 9px;
      }

      .panel-title svg {
        width: 19px;
        height: 19px;
        color: var(--brand-600);
      }

      .panel-close {
        width: 34px;
        height: 34px;
        border-radius: 50%;
        background: var(--danger-bg);
        border: none;
        color: var(--danger);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: var(--t-fast);
      }

      .panel-close svg {
        width: 15px;
        height: 15px;
      }

      .panel-close:hover {
        background: #F5D7CF;
      }

      .panel-body {
        padding: 18px 20px 28px;
        flex: 1;
      }

      .panel-section {
        margin-bottom: 26px;
      }

      .panel-section-title {
        font-size: 0.7rem;
        font-weight: 700;
        color: var(--ink-faint);
        text-transform: uppercase;
        letter-spacing: 0.7px;
        margin-bottom: 12px;
      }

      .panel-form .form-group {
        margin-bottom: 12px;
      }

      .panel-form .form-group label {
        font-size: 0.76rem;
        color: var(--ink-soft);
        font-weight: 600;
        margin-bottom: 5px;
        display: block;
      }

      .panel-form .form-group input,
      .panel-form .form-group textarea {
        width: 100%;
        padding: 10px 13px;
        border: 1.5px solid var(--line);
        border-radius: var(--r-sm);
        font-size: 0.85rem;
        background: var(--bg-pane);
        outline: none;
        transition: var(--t-fast);
      }

      .panel-form .form-group textarea {
        resize: vertical;
        min-height: 64px;
      }

      .panel-form .form-group input:focus,
      .panel-form .form-group textarea:focus {
        border-color: var(--brand-500);
        background: var(--surface);
      }

      .btn-sm {
        padding: 10px 18px;
        font-size: 0.81rem;
        font-weight: 700;
        background: linear-gradient(140deg, var(--brand-700), var(--brand-500));
        color: #fff;
        border: none;
        border-radius: var(--r-sm);
        cursor: pointer;
        transition: var(--t-fast);
        box-shadow: 0 4px 12px rgba(17, 87, 64, 0.25);
      }

      .btn-sm:hover {
        box-shadow: 0 6px 16px rgba(17, 87, 64, 0.34);
        transform: translateY(-1px);
      }

      .btn-danger-sm {
        padding: 6px 13px;
        font-size: 0.72rem;
        font-weight: 700;
        background: var(--danger-bg);
        color: var(--danger);
        border: none;
        border-radius: var(--r-sm);
        cursor: pointer;
        transition: var(--t-fast);
      }

      .btn-danger-sm:hover {
        background: #F5D7CF;
      }

      .panel-search-row {
        display: flex;
        gap: 7px;
        margin-bottom: 0;
      }

      .panel-search-row input {
        flex: 1;
        padding: 10px 13px;
        border: 1.5px solid var(--line);
        border-radius: var(--r-sm);
        font-size: 0.85rem;
        background: var(--bg-pane);
        outline: none;
        transition: var(--t-fast);
      }

      .panel-search-row input:focus {
        border-color: var(--brand-500);
        background: var(--surface);
      }

      .panel-search-row .btn-sm {
        width: 42px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
      }

      .panel-search-row .btn-sm svg {
        width: 16px;
        height: 16px;
      }

      .search-result-item,
      .group-list-item {
        display: flex;
        align-items: center;
        gap: 11px;
        padding: 9px 10px;
        border-radius: var(--r-sm);
        cursor: pointer;
        transition: var(--t-fast);
      }

      .search-result-item:hover,
      .group-list-item:hover {
        background: var(--line-soft);
      }

      .group-list-item span {
        font-size: 0.86rem;
        font-weight: 700;
        flex: 1;
      }

      .avatar-list {
        display: flex;
        flex-wrap: wrap;
        gap: 9px;
        margin-top: 9px;
      }

      .avatar-item {
        position: relative;
        width: 64px;
        height: 64px;
        border-radius: var(--r-sm);
        overflow: hidden;
        cursor: pointer;
        border: 2.5px solid transparent;
        transition: var(--t-fast);
      }

      .avatar-item:hover {
        border-color: var(--brand-400);
      }

      .avatar-item.active-avatar {
        border-color: var(--brand-500);
        box-shadow: 0 0 0 3px rgba(30, 142, 99, 0.16);
      }

      .avatar-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }

      .avatar-item .avatar-actions {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(4, 34, 26, 0.66);
        display: flex;
        justify-content: center;
        gap: 4px;
        padding: 4px;
        opacity: 0;
        transition: var(--t-fast);
      }

      .avatar-item:hover .avatar-actions {
        opacity: 1;
      }

      .avatar-item .avatar-action-btn {
        background: none;
        border: none;
        color: #fff;
        cursor: pointer;
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 5px;
      }

      .avatar-item .avatar-action-btn svg {
        width: 12px;
        height: 12px;
      }

      .avatar-item .avatar-action-btn:hover {
        background: rgba(255, 255, 255, 0.25);
      }

      .avatar-upload-area {
        border: 2px dashed var(--line);
        border-radius: var(--r-sm);
        padding: 18px;
        text-align: center;
        cursor: pointer;
        transition: var(--t-fast);
        margin-top: 9px;
      }

      .avatar-upload-area:hover {
        border-color: var(--brand-500);
        background: var(--line-soft);
      }

      .avatar-upload-area svg {
        width: 22px;
        height: 22px;
        color: var(--brand-500);
        margin-bottom: 6px;
      }

      .avatar-upload-area .upload-main {
        font-size: 0.84rem;
        font-weight: 600;
        color: var(--ink);
      }

      .avatar-upload-area .upload-sub {
        font-size: 0.71rem;
        color: var(--ink-faint);
        margin-top: 3px;
      }

      /* ─── Profile preview (my profile) ─────────── */
      .profile-avatar-box {
        width: 96px;
        height: 96px;
        border-radius: 50%;
        background: linear-gradient(140deg, #C9E8D8, #9FD4B8);
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 700;
        font-size: 2rem;
        color: var(--brand-700);
        margin: 0 auto 16px;
        overflow: hidden;
        box-shadow: var(--shadow-2);
        border: 3px solid var(--surface);
      }

      /* ─── Square avatar cropper ─────────────────── */
      .avatar-crop-modal-overlay {
        position: fixed;
        inset: 0;
        background: rgba(4, 34, 26, 0.6);
        z-index: 9998;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 20px;
        animation: fadeIn 0.2s ease;
      }

      .avatar-crop-modal {
        background: var(--surface);
        border-radius: var(--r-lg);
        padding: 22px;
        width: 100%;
        max-width: 380px;
        box-shadow: var(--shadow-3);
        text-align: center;
      }

      .avatar-crop-modal h3 {
        font-size: 1rem;
        font-weight: 800;
        color: var(--brand-800);
        margin-bottom: 14px;
      }

      .avatar-crop-square {
        width: 100%;
        aspect-ratio: 1 / 1;
        max-width: 300px;
        margin: 0 auto 16px;
        border-radius: var(--r-md);
        overflow: hidden;
        background: #EFEBDF repeating-conic-gradient(#e4e0d3 0% 25%, transparent 0% 50%) 50% / 20px 20px;
        position: relative;
        touch-action: none;
        cursor: grab;
      }

      .avatar-crop-square:active {
        cursor: grabbing;
      }

      .avatar-crop-square img {
        position: absolute;
        user-select: none;
        -webkit-user-drag: none;
        pointer-events: none;
        top: 0;
        left: 0;
        transform-origin: 0 0;
      }

      .avatar-crop-controls {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 16px;
      }

      .avatar-crop-controls input[type="range"] {
        flex: 1;
        accent-color: var(--brand-500);
      }

      .avatar-crop-actions {
        display: flex;
        gap: 10px;
      }

      .avatar-crop-actions button {
        flex: 1;
      }

      .btn-secondary-sm {
        padding: 10px 18px;
        font-size: 0.81rem;
        font-weight: 700;
        background: var(--line-soft);
        color: var(--ink-soft);
        border: none;
        border-radius: var(--r-sm);
        cursor: pointer;
        transition: var(--t-fast);
      }

      .btn-secondary-sm:hover {
        background: var(--line);
        color: var(--ink);
      }

      /* ─── User profile viewer ───────────────────── */
      .user-profile-header {
        text-align: center;
        padding: 8px 0 20px;
      }

      .user-profile-avatar {
        width: 104px;
        height: 104px;
        border-radius: 50%;
        margin: 0 auto 14px;
        overflow: hidden;
        background: linear-gradient(140deg, #C9E8D8, #9FD4B8);
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 700;
        font-size: 2.1rem;
        color: var(--brand-700);
        box-shadow: var(--shadow-2);
        border: 3px solid var(--surface);
        cursor: pointer;
      }

      .user-profile-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }

      .user-profile-name {
        font-size: 1.15rem;
        font-weight: 800;
        color: var(--brand-800);
      }

      .user-profile-username {
        font-size: 0.82rem;
        color: var(--ink-faint);
        margin-top: 3px;
        font-weight: 600;
      }

      .user-profile-bio {
        font-size: 0.85rem;
        color: var(--ink-soft);
        line-height: 1.7;
        margin-top: 10px;
        padding: 0 12px;
      }

      .user-profile-gallery {
        display: flex;
        flex-wrap: wrap;
        gap: 9px;
      }

      .user-profile-gallery-item {
        width: 72px;
        height: 72px;
        border-radius: var(--r-sm);
        overflow: hidden;
        cursor: pointer;
        background: var(--line-soft);
      }

      .user-profile-gallery-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        loading: lazy;
      }

      .divider {
        height: 1px;
        background: var(--line);
        margin: 18px 0;
      }

      /* ─── Floating scroll-to-bottom button ─────── */
      .scroll-bottom-btn {
        position: absolute;
        left: 50%;
        transform: translateX(-50%) translateY(12px);
        bottom: 16px;
        width: 42px;
        height: 42px;
        border-radius: 50%;
        background: var(--surface);
        border: 1px solid var(--line);
        box-shadow: var(--shadow-2);
        display: none;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: var(--brand-700);
        z-index: 3;
        transition: var(--t-fast), transform var(--t-med);
      }

      .scroll-bottom-btn.visible {
        display: flex;
        transform: translateX(-50%) translateY(0);
      }

      .scroll-bottom-btn:hover {
        background: var(--line-soft);
      }

      .scroll-bottom-btn svg {
        width: 20px;
        height: 20px;
      }

      .scroll-bottom-badge {
        position: absolute;
        top: -4px;
        right: -4px;
        background: var(--brand-500);
        color: #fff;
        font-size: 0.62rem;
        font-weight: 800;
        min-width: 17px;
        height: 17px;
        border-radius: 9px;
        display: none;
        align-items: center;
        justify-content: center;
        padding: 0 4px;
        border: 2px solid var(--surface);
      }

      .scroll-bottom-badge.show {
        display: flex;
      }

      /* ─── TOAST ─────────────────────────────── */
      #toast-container {
        position: fixed;
        bottom: 26px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 9999;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        pointer-events: none;
      }

      .toast {
        padding: 12px 24px;
        border-radius: var(--r-pill);
        font-size: 0.85rem;
        font-weight: 600;
        box-shadow: var(--shadow-3);
        white-space: nowrap;
        opacity: 0;
        transform: translateY(16px);
        transition: transform 0.3s var(--ease), opacity 0.3s;
        display: flex;
        align-items: center;
        gap: 8px;
      }

      .toast.toast-visible {
        opacity: 1;
        transform: translateY(0);
      }

      .toast.toast-hide {
        opacity: 0;
        transform: translateY(-8px);
      }

      .toast-success {
        background: #1E8052;
        color: #fff;
      }

      .toast-error {
        background: var(--danger);
        color: #fff;
      }

      .toast-info {
        background: var(--brand-800);
        color: #fff;
      }

      .avatar-crop-actions .btn-sm:disabled {
        opacity: 0.5;
        cursor: not-allowed;
        transform: none !important;
        box-shadow: none !important;
      }

      .context-menu {
        position: fixed;
        background: var(--surface);
        border-radius: var(--r-sm);
        box-shadow: var(--shadow-3);
        z-index: 9999;
        min-width: 140px;
        padding: 6px 0;
        animation: fadeIn 0.12s ease;
        border: 1px solid var(--line);
      }

      .context-menu-item {
        padding: 8px 14px;
        font-size: 0.82rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 8px;
        transition: background var(--t-fast);
        font-weight: 500;
        color: var(--ink);
      }

      .context-menu-item:hover {
        background: var(--line-soft);
      }

      .context-menu-item svg {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
      }

      .context-menu-item.danger {
        color: var(--danger);
      }

      .context-menu-item.danger:hover {
        background: var(--danger-bg);
      }

      .context-menu-divider {
        height: 1px;
        background: var(--line);
        margin: 4px 0;
      }

      @keyframes pulse {

        0%,
        100% {
          opacity: 1;
        }

        50% {
          opacity: 0.3;
        }
      }

      .input-actions {
        display: flex;
        align-items: center;
        gap: 4px;
        flex-shrink: 0;
      }

      .attach-btn {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        border: none;
        background: transparent;
        color: var(--ink-faint);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s;
      }

      .attach-btn:hover {
        background: var(--hover);
        color: var(--ink);
      }

      .voice-bubble {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 8px 12px;
        background: var(--brand-bg, #E8F4E5);
        border-radius: 16px;
        min-width: 200px;
        max-width: 280px;
      }

      .voice-play-btn {
        width: 38px;
        height: 38px;
        border-radius: 50%;
        border: none;
        background: var(--brand-500, #2BAF6A);
        color: #fff;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        transition: transform 0.15s;
      }

      .voice-play-btn:active {
        transform: scale(0.92);
      }

      .voice-waveform {
        flex: 1;
        height: 36px;
        display: flex;
        align-items: flex-end;
        gap: 2px;
        padding: 0 4px;
      }

      .voice-waveform .bar {
        flex: 1;
        background: var(--brand-500, #2BAF6A);
        border-radius: 2px;
        transition: height 0.3s;
        min-width: 2px;
        opacity: 0.6;
      }

      .voice-waveform .bar.active {
        opacity: 1;
      }

      .voice-duration {
        font-size: 0.75rem;
        color: var(--brand-700, #16704F);
        font-weight: 600;
        white-space: nowrap;
        min-width: 36px;
        text-align: right;
      }

      #saved-messages-list {
        min-height: 200px;
        overflow-y: auto;
      }

      /* استایل پیام‌های ذخیره شده */
      .saved-msg-row {
        display: flex;
        align-items: flex-start;
        gap: 8px;
        padding: 4px 16px;
        margin: 4px 0;
        animation: fadeInUp 0.3s ease;
      }

      .saved-msg-bubble {
        background: linear-gradient(135deg, #f8faff 0%, #f0f4ff 100%);
        border: 1px solid #dde5f8;
        border-radius: 16px;
        padding: 12px 16px;
        flex: 1;
        transition: all 0.2s ease;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
      }

      .saved-msg-bubble:hover {
        background: linear-gradient(135deg, #eef3ff 0%, #e4ecff 100%);
        border-color: #c5d5f7;
        transform: translateX(4px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
      }

      .saved-msg-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 8px;
        padding-bottom: 8px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
      }

      .saved-msg-sender {
        font-weight: 700;
        font-size: 0.85rem;
        color: var(--brand-600);
      }

      .saved-msg-source {
        font-size: 0.72rem;
        color: var(--ink-medium);
        background: rgba(0, 0, 0, 0.03);
        padding: 4px 12px;
        border-radius: 20px;
        cursor: pointer;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        gap: 4px;
      }

      .saved-msg-source:hover {
        background: rgba(0, 0, 0, 0.06);
        color: var(--brand-500);
      }

      @keyframes fadeInUp {
        from {
          opacity: 0;
          transform: translateY(10px);
        }

        to {
          opacity: 1;
          transform: translateY(0);
        }
      }

      .group-member-row {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 8px 12px;
        border-radius: 8px;
        cursor: pointer;
        transition: background 0.2s;
      }

      .group-member-row:hover {
        background: var(--surface-hover);
      }

      .role-badge {
        font-size: 0.7rem;
        padding: 2px 8px;
        border-radius: 10px;
        margin-right: auto;
      }

      .role-owner {
        background: #FFF3CD;
        color: #856404;
      }

      .role-admin {
        background: #D1ECF1;
        color: #0C5460;
      }

      .role-member {
        background: #E2E3E5;
        color: #383D41;
      }

      .group-members-list {
        max-height: 300px;
        overflow-y: auto;
      }







      .group-member-actions {
        display: none;
        gap: 4px;
        position: absolute;
        left: 8px;
        background: var(--surface);
        border-radius: 8px;
        padding: 2px;
      }

      .group-member-row:hover .group-member-actions {
        display: flex;
      }

      .group-member-action-btn {
        width: 28px;
        height: 28px;
        border: none;
        border-radius: 6px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.75rem;
        background: transparent;
        color: var(--ink-medium);
      }

      .group-member-action-btn:hover {
        background: var(--surface-hover);
      }

      .group-member-action-btn.kick:hover {
        background: #FEE2E2;
        color: #DC2626;
      }

      .group-member-action-btn.promote:hover {
        background: #D1ECF1;
        color: #0C5460;
      }

      .group-info-actions {
        display: flex;
        gap: 8px;
        justify-content: center;
        margin-top: 12px;
        flex-wrap: wrap;
      }

      .context-menu-header {
        padding: 8px 16px 6px;
        font-size: 0.75rem;
        font-weight: 700;
        color: var(--ink-faint);
        text-align: right;
      }

      .seen-by-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 16px 8px;
        font-size: 0.82rem;
        color: var(--ink-dark);
      }

      .seen-by-time {
        font-size: 0.78rem;
        color: var(--brand-500);
        font-weight: 600;
      }

      .context-menu-divider {
        height: 1px;
        background: var(--border-light);
        margin: 6px 0;
      }

      .upload-progress {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 6px 10px;
      }

      .upload-progress-bar {
        flex: 1;
        height: 4px;
        background: var(--border-light);
        border-radius: 2px;
        overflow: hidden;
      }

      .upload-progress-fill {
        height: 100%;
        background: var(--brand-500);
        transition: width 0.2s;
        border-radius: 2px;
      }

      .upload-progress-text {
        font-size: 0.75rem;
        color: var(--ink-faint);
        min-width: 35px;
      }

      .file-download-bubble {
        display: flex;
        align-items: center;
        gap: 10px;
        cursor: pointer;
        padding: 8px 12px;
        background: rgba(255, 255, 255, 0.08);
        border-radius: 12px;
        transition: background 0.2s;
      }

      .file-download-bubble:hover {
        background: rgba(255, 255, 255, 0.15);
      }

      .download-circle {
        position: relative;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
      }

      .download-circle-svg {
        position: absolute;
        width: 100%;
        height: 100%;
      }

      .download-circle-fill {
        color: var(--brand-500);
        transition: stroke-dashoffset 0.2s;
      }

      .download-circle-text {
        font-size: 0.6rem;
        color: var(--ink-faint);
        max-width: 60px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin-left: 8px;
      }
      /* ═══════════════════════════════════════════════════════════
   FORWARD TAG - مثل تلگرام
   ═══════════════════════════════════════════════════════════ */
.msg-forward-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--brand-500);
  margin-bottom: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(43, 175, 106, 0.06);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.msg-forward-tag strong {
  font-weight: 700;
  color: var(--brand-600);
}

/* ═══════════════════════════════════════════════════════════
   REPLY PREVIEW - مثل تلگرام
   ═══════════════════════════════════════════════════════════ */
.reply-preview-box {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-bottom: 6px;
  border-radius: var(--r-sm);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s ease;
  max-width: 100%;
  border-left: 3px solid var(--brand-500);
}

.reply-preview-box:hover {
  filter: brightness(0.92);
}

/* ریپلای روی پیام خودم (حباب سبز) */
.reply-preview-box.reply-me {
  background: rgba(210, 165, 70, 0.25);
  border-left-color: rgba(180, 135, 40, 0.8);
}

.reply-preview-box.reply-me:hover {
  background: rgba(210, 165, 70, 0.35);
}

/* ریپلای روی پیام طرف مقابل (حباب سفید/طوسی) */
.reply-preview-box.reply-them {
  background: rgba(210, 165, 70, 0.12);
  border-left-color: var(--accent, #c9952e);
}

.reply-preview-box.reply-them:hover {
  background: rgba(210, 165, 70, 0.2);
}

.reply-preview-bar {
  display: none;
}

.reply-preview-content {
  padding: 6px 10px;
  min-width: 0;
  flex: 1;
}

.reply-preview-sender {
  font-size: 0.7rem;
  font-weight: 700;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #6b4513;
  letter-spacing: -0.01em;
}

.reply-preview-text {
  font-size: 0.7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  color: #3d2a0a;
  opacity: 0.75;
  margin-top: 1px;
}
/* ═══════════════════════════════════════════════════════════
   MULTI-SELECT TOOLBAR - پایین صفحه مثل تلگرام
   ═══════════════════════════════════════════════════════════ */
.multi-select-toolbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 500;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
  transform: translateY(100%);
  transition: transform 0.25s var(--ease);
  gap: 12px;
}

.multi-select-toolbar.show {
  transform: translateY(0);
}

.multi-select-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-dark);
  white-space: nowrap;
}

.multi-select-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.multi-select-actions .icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--ink-medium);
  cursor: pointer;
  transition: all 0.15s ease;
}

.multi-select-actions .icon-btn:hover {
  background: var(--hover);
  color: var(--ink-dark);
}

.multi-select-actions .icon-btn.danger {
  color: var(--danger);
}

.multi-select-actions .icon-btn.danger:hover {
  background: var(--danger-bg);
}

/* ═══════════════════════════════════════════════════════════
   CHECKBOX SELECT - مثل تلگرام
   ═══════════════════════════════════════════════════════════ */
.msg-select-checkbox {
  display: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  align-self: center;
  margin: 0 4px;
  transition: all 0.2s ease;
  background: transparent;
}

.msg-select-checkbox.show {
  display: flex;
}

.msg-select-checkbox.checked {
  background: var(--brand-500);
  border-color: var(--brand-500);
}

.msg-select-checkbox.checked svg {
  display: block;
}

.msg-select-checkbox svg {
  display: none;
}

/* وقتی تو حالت سلکشن هستیم، پیام‌ها یکم کوچیک‌تر شن */
.multi-select-mode-active .msg-row {
  cursor: pointer;
}

.multi-select-mode-active .msg-bubble {
  pointer-events: none;
}
/* نوار ریپلای بالای input مثل تلگرام */
#reply-banner {
  display: none;
  align-items: center;
  gap: 0;
  padding: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  overflow: hidden;
  animation: slideDown 0.2s ease;
}

#reply-banner.show {
  display: flex;
}

@keyframes slideDown {
  from { max-height: 0; opacity: 0; }
  to { max-height: 60px; opacity: 1; }
}

.reply-banner-bar {
  width: 4px;
  height: 40px;
  background: var(--brand-500);
  border-radius: 2px;
  flex-shrink: 0;
  margin: 8px;
}

.reply-banner-content {
  flex: 1;
  min-width: 0;
  padding: 8px 4px;
  cursor: pointer;
}

.reply-banner-content:hover {
  opacity: 0.8;
}

.reply-banner-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--brand-600);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-banner-title strong {
  font-weight: 800;
}

.reply-banner-text {
  font-size: 0.75rem;
  color: var(--ink-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-banner-cancel {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin: 0 8px;
  transition: all 0.15s ease;
}

.reply-banner-cancel:hover {
  background: var(--hover);
  color: var(--ink-dark);
}
/* ═══════════════════════════════════════════════════════════
   LINK PREVIEW - مثل تلگرام
   ═══════════════════════════════════════════════════════════ */
.msg-link {
  color: #1a73e8;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
  transition: all 0.15s ease;
}

.msg-link:hover {
  color: #1557b0;
  text-decoration-thickness: 2px;
}

/* پیش‌نمایش لینک */
.link-preview-card {
  margin-top: 8px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.04);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  display: block;
  max-width: 320px;
}

.link-preview-card:hover {
  background: rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.link-preview-image {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
  background: var(--hover);
}

.link-preview-info {
  padding: 10px 12px;
}

.link-preview-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-dark);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-preview-desc {
  font-size: 0.72rem;
  color: var(--ink-faint);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.link-preview-url {
  font-size: 0.68rem;
  color: var(--ink-faint);
  opacity: 0.6;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* تو حباب خودم */
.msg-row.me .link-preview-card {
  background: rgba(255, 255, 255, 0.12);
}

.msg-row.me .link-preview-card:hover {
  background: rgba(255, 255, 255, 0.2);
}

.msg-row.me .link-preview-title {
  color: rgba(255, 255, 255, 0.95);
}

.msg-row.me .link-preview-desc,
.msg-row.me .link-preview-url {
  color: rgba(255, 255, 255, 0.7);
}
/* ═══════════════════════════════════════════════════════════
   SWIPE TO REPLY - مثل تلگرام
   ═══════════════════════════════════════════════════════════ */
.msg-row {
  position: relative;
  transition: transform 0.18s ease-out;
  touch-action: pan-y;
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.msg-row.swiping {
  transition: none;
  z-index: 2;
}

.msg-row .swipe-reply-indicator {
  position: absolute;
  top: 50%;
  transform: translateY(-50%) scale(0.5);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-500);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.12s ease, transform 0.12s ease;
  pointer-events: none;
  z-index: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  will-change: transform, opacity;
}

/* پیام خودم (سمت چپ) → آیکون ریپلای سمت راست */
.msg-row.me .swipe-reply-indicator {
  right: 12px;
}

/* پیام مخاطب (سمت راست) → آیکون ریپلای سمت چپ */
.msg-row.them .swipe-reply-indicator {
  left: 12px;
}

.msg-row.swiping .swipe-reply-indicator {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

.msg-row.swipe-reply-active .swipe-reply-indicator {
  opacity: 1;
  transform: translateY(-50%) scale(1);
  background: var(--brand-600);
  box-shadow: 0 4px 14px rgba(43, 175, 106, 0.4);
}

/* ═══════════════════════════════════════════════════════════
   FORWARD MODAL - Bottom Sheet مثل تلگرام
   ═══════════════════════════════════════════════════════════ */
.forward-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.forward-modal-sheet {
  background: var(--surface);
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s var(--ease);
  overflow: hidden;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.forward-modal-handle {
  width: 36px;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin: 10px auto 6px;
  flex-shrink: 0;
}

.forward-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.forward-modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink-dark);
}

.forward-modal-search {
  padding: 10px 16px;
  flex-shrink: 0;
}

.forward-modal-search input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  background: var(--hover);
  font-size: 0.88rem;
  color: var(--ink-dark);
  outline: none;
  transition: all 0.2s ease;
}

.forward-modal-search input:focus {
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--brand-500);
}

.forward-modal-search input::placeholder {
  color: var(--ink-faint);
}

.forward-modal-selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 10px;
  flex-shrink: 0;
}

.forward-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--brand-100);
  color: var(--brand-700);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}

.forward-chip-remove {
  cursor: pointer;
  font-size: 0.7rem;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.forward-chip-remove:hover {
  opacity: 1;
}

.forward-modal-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  max-height: 50vh;
}

.forward-target-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.forward-target-item:hover {
  background: var(--hover);
}

.forward-target-item.selected {
  background: var(--brand-50);
}

.forward-target-item .avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  background: var(--brand-100);
  color: var(--brand-700);
  flex-shrink: 0;
  overflow: hidden;
}

.forward-target-item .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.forward-target-item .avatar.group {
  background: var(--accent-light, #fef3c7);
  color: var(--accent, #d9a441);
}

.forward-target-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.forward-target-check.checked {
  background: var(--brand-500);
  border-color: var(--brand-500);
}

.forward-modal-footer {
  padding: 12px 20px 20px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.forward-modal-send-btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  background: var(--brand-500);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.forward-modal-send-btn:hover:not(:disabled) {
  background: var(--brand-600);
  transform: translateY(-1px);
}

.forward-modal-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.list-empty {
  text-align: center;
  padding: 24px;
  color: var(--ink-faint);
  font-size: 0.85rem;
}
.voice-record-btn {
  color: var(--ink-medium);
  transition: all 0.15s ease;
}

.voice-record-btn:hover {
  color: var(--brand-500);
  background: var(--brand-50);
}

.voice-record-btn:active {
  transform: scale(0.92);
}
/* ═══════════════════════════════════════════════════════════
   CHAT INFO PANEL - Media, Files, Voice مثل تلگرام
   ═══════════════════════════════════════════════════════════ */
.chat-info-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}

.chat-info-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 4px 10px;
  cursor: pointer;
  color: var(--ink-faint);
  font-size: 0.7rem;
  transition: all 0.15s ease;
  border-bottom: 2px solid transparent;
  user-select: none;
}

.chat-info-tab:hover {
  color: var(--ink-medium);
  background: var(--hover);
}

.chat-info-tab.active {
  color: var(--brand-500);
  border-bottom-color: var(--brand-500);
}

.chat-info-tab svg {
  flex-shrink: 0;
}

/* گرید تصاویر و ویدئوها */
.chat-info-media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 4px;
}

.chat-info-media-item {
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: var(--hover);
  transition: all 0.15s ease;
}

.chat-info-media-item:hover {
  transform: scale(0.96);
  opacity: 0.9;
}

.chat-info-media-item img,
.chat-info-media-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-info-media-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  color: #fff;
  font-size: 1.5rem;
  pointer-events: none;
}

/* لیست فایل‌ها و ویس‌ها */
.chat-info-files-list {
  padding: 4px;
}

.chat-info-file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.chat-info-file-item:hover {
  background: var(--hover);
}

.chat-info-file-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--hover);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-medium);
  flex-shrink: 0;
}

.chat-info-file-info {
  flex: 1;
  min-width: 0;
}

.chat-info-file-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-info-file-meta {
  font-size: 0.72rem;
  color: var(--ink-faint);
  margin-top: 2px;
}
/* ═══════════════════════════════════════════════════════════
   DELETE CONFIRMATION MODAL - وسط صفحه، کوچیک و جمع‌وجور
   ═══════════════════════════════════════════════════════════ */
.delete-confirm-sheet {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
}

.delete-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  transition: background 0.2s ease;
}

.delete-sheet-backdrop.show {
  background: rgba(0, 0, 0, 0.5);
}

.delete-sheet-content {
  position: relative;
  background: var(--surface);
  width: 90%;
  max-width: 320px;
  border-radius: 14px;
  padding: 20px 20px 16px;
  transform: scale(0.85);
  opacity: 0;
  transition: all 0.2s var(--ease);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.delete-sheet-content.show {
  transform: scale(1);
  opacity: 1;
}

.delete-sheet-handle {
  display: none;
}

.delete-sheet-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--danger);
  flex-shrink: 0;
}

.delete-sheet-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink-dark);
  text-align: center;
}

.delete-sheet-desc {
  font-size: 0.8rem;
  color: var(--ink-medium);
  text-align: center;
  line-height: 1.6;
  padding: 0 4px;
}

.delete-sheet-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--hover);
  cursor: pointer;
  width: 100%;
  transition: all 0.15s ease;
  user-select: none;
}

.delete-sheet-option:hover {
  background: var(--line);
}

.delete-sheet-option:active {
  transform: scale(0.98);
}

.delete-sheet-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
  background: transparent;
}

.delete-sheet-checkbox.checked {
  background: var(--brand-500);
  border-color: var(--brand-500);
}

.delete-sheet-checkbox svg {
  opacity: 0;
  transition: opacity 0.15s ease;
}

.delete-sheet-checkbox.checked svg {
  opacity: 1;
}

.delete-sheet-option-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-dark);
}

.delete-sheet-option-desc {
  font-size: 0.7rem;
  color: var(--ink-faint);
  margin-top: 1px;
}

.delete-sheet-actions {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-top: 6px;
}

.delete-sheet-btn {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: none;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.delete-sheet-btn.cancel {
  background: var(--hover);
  color: var(--ink-dark);
}

.delete-sheet-btn.cancel:hover {
  background: var(--line);
}

.delete-sheet-btn.confirm {
  background: var(--danger);
  color: #fff;
}

.delete-sheet-btn.confirm:hover {
  background: #dc2626;
}

.delete-sheet-btn:active {
  transform: scale(0.97);
}
/* ═══════════════════════════════════════════════════════════
   EMOJI PICKER - مثل تلگرام
   ═══════════════════════════════════════════════════════════ */
.emoji-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: none;
}

.emoji-picker-overlay.show {
  display: block;
}

.emoji-picker {
  position: fixed;
  bottom: 80px;
  left: 8px;
  right: 8px;
  max-width: 400px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.2s ease;
  height: 380px;
}

.emoji-picker.show {
  display: flex;
}

.emoji-picker-header {
  display: flex;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--surface);
}

.emoji-picker-header::-webkit-scrollbar {
  display: none;
}

.emoji-picker-tab {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 1.3rem;
  flex-shrink: 0;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  opacity: 0.6;
}

.emoji-picker-tab.active {
  opacity: 1;
  border-bottom-color: var(--brand-500);
}

.emoji-picker-tab:hover {
  opacity: 1;
  background: var(--hover);
}

.emoji-picker-recent {
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  min-height: 44px;
  align-items: center;
  flex-shrink: 0;
}

.emoji-picker-recent-label {
  font-size: 0.7rem;
  color: var(--ink-faint);
  width: 100%;
  margin-bottom: 4px;
}

.emoji-picker-recent:empty {
  display: none;
}

.emoji-picker-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 2px;
}

.emoji-item {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.1s;
  user-select: none;
  flex-shrink: 0;
}

.emoji-item:hover {
  background: var(--hover);
  transform: scale(1.2);
}

.emoji-item:active {
  transform: scale(0.9);
  background: var(--line);
}

.emoji-picker-search {
  padding: 8px 12px;
  flex-shrink: 0;
}

.emoji-picker-search input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  border: none;
  background: var(--hover);
  font-size: 0.85rem;
  outline: none;
}

.emoji-picker-search input:focus {
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--brand-500);
}

/* ═══════════════════════════════════════════════════════════
   EMOJI BUTTON INSIDE INPUT
   ═══════════════════════════════════════════════════════════ */
.msg-input-wrap {
  position: relative;
  display: flex;
  align-items: flex-end;
  flex: 1;
}

.emoji-inside-btn {
  position: absolute;
  left: 8px;
  bottom: 8px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.emoji-inside-btn:hover {
  color: var(--brand-500);
  background: var(--brand-50);
}

.emoji-inside-btn:active {
  transform: scale(0.9);
}

.msg-input {
  padding-left: 44px !important;
}

/* ═══════════════════════════════════════════════════════════
   EMOJI PICKER - مثل تلگرام
   ═══════════════════════════════════════════════════════════ */
.emoji-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: none;
}

.emoji-picker-overlay.show {
  display: block;
}

.emoji-picker {
  position: fixed;
  bottom: 80px;
  left: 8px;
  right: 8px;
  max-width: 400px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.2s ease;
  height: 380px;
}

.emoji-picker.show {
  display: flex;
}

.emoji-picker-header {
  display: flex;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  white-space: nowrap;
  padding: 2px 4px;
  cursor: grab;
  user-select: none;
  background: var(--surface);
}

.emoji-picker-header::-webkit-scrollbar {
  height: 4px;
}

.emoji-picker-header::-webkit-scrollbar-track {
  background: transparent;
}

.emoji-picker-header::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 2px;
}

.emoji-picker-header:active {
  cursor: grabbing;
}

.emoji-picker-tab {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 1.3rem;
  flex-shrink: 0;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  opacity: 0.6;
  min-width: 40px;
  text-align: center;
}

.emoji-picker-tab.active {
  opacity: 1;
  border-bottom-color: var(--brand-500);
}

.emoji-picker-tab:hover {
  opacity: 1;
  background: var(--hover);
}

.emoji-picker-recent {
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  min-height: 44px;
  align-items: center;
  flex-shrink: 0;
}

.emoji-picker-recent-label {
  font-size: 0.7rem;
  color: var(--ink-faint);
  width: 100%;
  margin-bottom: 4px;
}

.emoji-picker-recent:empty {
  display: none;
}

.emoji-picker-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 2px;
}

.emoji-item {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.1s;
  user-select: none;
  flex-shrink: 0;
}

.emoji-item:hover {
  background: var(--hover);
  transform: scale(1.2);
}

.emoji-item:active {
  transform: scale(0.9);
  background: var(--line);
}

.emoji-picker-search {
  padding: 8px 12px;
  flex-shrink: 0;
}

.emoji-picker-search input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  border: none;
  background: var(--hover);
  font-size: 0.85rem;
  outline: none;
}

.emoji-picker-search input:focus {
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--brand-500);
}
.emoji-picker-body .emoji-item {
  font-size: 1.5rem;
  line-height: 1;
  font-family: 'Twemoji Mozilla', 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}
      /* ============================================================
       RESPONSIVE
       ============================================================ */
      @media (max-width: 900px) {
        .sidebar {
          width: 320px;
          min-width: 280px;
        }
      }

      @media (max-width: 760px) {
        #app-screen.chat-open .sidebar {
          display: none;
        }

        #app-screen:not(.chat-open) .main {
          display: none;
        }

        .sidebar {
          width: 100%;
          max-width: 100%;
          border-left: none;
        }

        .main {
          width: 100%;
        }

        .header-back-btn {
          display: flex;
          width: 34px;
          height: 34px;
          border-radius: 50%;
          background: transparent;
          border: none;
          align-items: center;
          justify-content: center;
          cursor: pointer;
          color: var(--ink-soft);
          flex-shrink: 0;
          margin-left: -4px;
        }

        .header-back-btn svg {
          width: 21px;
          height: 21px;
        }

        .header-back-btn:hover {
          background: var(--line-soft);
        }

        .msg-row {
          max-width: 84%;
        }

        .messages-area {
          padding: 14px 3% 10px;
        }

        .side-panel {
          width: 100%;
          max-width: 100%;
        }
      }

      @media (max-width: 420px) {
        .auth-card {
          padding: 2rem 1.4rem;
        }

        .chat-header {
          padding: 8px 12px;
        }

        .input-area {
          padding: 8px 10px;
        }
      }

      @media (prefers-reduced-motion: reduce) {

        *,
        *::before,
        *::after {
          animation-duration: 0.001ms !important;
          transition-duration: 0.001ms !important;
        }
      }

      button:focus-visible,
      input:focus-visible,
      textarea:focus-visible,
      [tabindex]:focus-visible {
        outline: 2px solid var(--brand-500);
        outline-offset: 2px;
      }
