/* ===== ChatNet â€” MeGap Design System ===== */
@import url('../vendor/css/vazirmatn.css');

:root {
    --cn-primary: #6C5CE7;
    --cn-primary-deep: #5849D6;
    --cn-primary-soft: #EFEBFF;
    --cn-primary-ink: #2A1F6F;
    --cn-bg: #FAF8FF;
    --cn-card: #FFFFFF;
    --cn-ink: #1B1730;
    --cn-ink-sub: #6B6783;
    --cn-ink-mute: #A09CB8;
    --cn-border: #ECE9F5;
    --cn-border-soft: #F4F2FA;
    --cn-online: #2DD879;
    --cn-bubble-me: #6C5CE7;
    --cn-bubble-me-ink: #FFFFFF;
    --cn-bubble-them: #F2EFFA;
    --cn-bubble-them-ink: #1B1730;
    --cn-danger: #FF4F8B;
    --cn-radius: 16px;
    --cn-radius-sm: 12px;
    --cn-radius-xs: 8px;
    --cn-shadow: 0 2px 12px rgba(108,92,231,0.08);
    --cn-shadow-lg: 0 8px 24px rgba(108,92,231,0.15);
}

* { box-sizing: border-box; }

body {
    font-family: 'Vazirmatn', system-ui, -apple-system, sans-serif;
    background: var(--cn-bg);
    color: var(--cn-ink);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

.dropdown-menu, .dropdown-menu-end {
    z-index: 9999999999999999999999999999999 !important;
}

a { color: var(--cn-primary); }
a:hover { color: var(--cn-primary-deep); }

/* ===== NAVBAR ===== */
.cn-navbar {
    background: var(--cn-card);
    border-bottom: 1px solid var(--cn-border);
    padding: 10px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}
.cn-navbar .navbar-brand {
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--cn-ink);
    display: flex;
    align-items: center;
    gap: 8px;
}
.cn-navbar .navbar-brand .brand-icon {
    width: 32px; height: 32px; border-radius: 10px;
    background: linear-gradient(135deg, var(--cn-primary), #9b8aff);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(108,92,231,0.3);
    color: #fff;
}
.cn-navbar .nav-link {
    color: var(--cn-ink-mute);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 8px 12px;
    border-radius: var(--cn-radius-sm);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.cn-navbar .nav-link:hover { color: var(--cn-primary); background: var(--cn-primary-soft); }
.cn-navbar .nav-link.active {
    color: var(--cn-primary);
    background: var(--cn-primary-soft);
    font-weight: 700;
}
.cn-badge {
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px;
    background: var(--cn-danger);
    color: #fff;
    font-size: 10px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    border: 2px solid var(--cn-card);
    line-height: 1;
}
.cn-navbar .dropdown-menu {
    z-index: 9999999999999;
    border: 1px solid var(--cn-border);
    border-radius: var(--cn-radius);
    box-shadow: var(--cn-shadow-lg);
    padding: 6px;
}
.cn-navbar .dropdown-item {
    border-radius: var(--cn-radius-xs);
    font-size: 0.9rem;
    padding: 8px 12px;
}
.cn-navbar .dropdown-item:hover { background: var(--cn-primary-soft); }

/* ===== CARDS ===== */
.cn-card {
    background: var(--cn-card);
    border-radius: var(--cn-radius);
    box-shadow: var(--cn-shadow);
    border: 1px solid var(--cn-border);
    overflow: hidden;
}

/* ===== BUTTONS ===== */
.btn-cn {
    background: var(--cn-primary);
    color: #fff;
    border: none;
    border-radius: var(--cn-radius-sm);
    font-weight: 700;
    font-size: 0.9rem;
    padding: 10px 20px;
    box-shadow: 0 4px 14px rgba(108,92,231,0.3);
    transition: all 0.2s;
}
.btn-cn:hover { background: var(--cn-primary-deep); color: #fff; box-shadow: 0 6px 20px rgba(108,92,231,0.4); }
.btn-cn-outline {
    background: transparent;
    color: var(--cn-primary);
    border: 1.5px solid var(--cn-primary);
    border-radius: var(--cn-radius-sm);
    font-weight: 600;
    padding: 8px 18px;
    transition: all 0.2s;
}
.btn-cn-outline:hover { background: var(--cn-primary-soft); color: var(--cn-primary); }
.btn-cn-soft {
    background: var(--cn-primary-soft);
    color: var(--cn-primary);
    border: none;
    border-radius: var(--cn-radius-sm);
    font-weight: 600;
    padding: 8px 16px;
}
.btn-cn-soft:hover { background: #E0DAFF; }

/* Neutral secondary button (Cancel, Add option, …). Theme-agnostic. */
.btn-cn-secondary {
    background: rgba(127, 127, 127, 0.12);
    color: var(--cn-ink);
    border: 1px solid transparent;
    border-radius: var(--cn-radius-sm);
    font-weight: 700;
    font-size: 0.88rem;
    padding: 10px 18px;
    cursor: pointer;
    transition: all 0.18s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn-cn-secondary:hover { background: rgba(127, 127, 127, 0.2); color: var(--cn-ink); }
.btn-cn-secondary:active { transform: scale(0.97); }
.btn-cn-secondary.btn-sm { padding: 6px 12px; font-size: 0.8rem; font-weight: 600; }
.btn-cn-icon {
    width: 38px; height: 38px; border-radius: var(--cn-radius-sm);
    background: var(--cn-primary-soft); border: none;
    color: var(--cn-primary);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.btn-cn-icon:hover { background: #E0DAFF; }

/* ===== FORM INPUTS ===== */
.cn-input {
    background: var(--cn-border-soft);
    border: 1.5px solid transparent;
    border-radius: 14px;
    padding: 11px 16px;
    font-size: 0.95rem;
    color: var(--cn-ink);
    transition: all 0.2s;
    width: 100%;
}
.cn-input:focus {
    outline: none;
    border-color: var(--cn-primary);
    background: var(--cn-card);
    box-shadow: 0 0 0 3px rgba(108,92,231,0.12);
}
.cn-input::placeholder { color: var(--cn-ink-mute); }

.form-control-readonly:disabled,
.form-control-readonly[disabled] {
    background: var(--cn-border-soft);
    color: var(--cn-ink-sub);
    cursor: not-allowed;
    opacity: 1;
}

/* ===== AUTH PAGES ===== */
.auth-hero {
    position: relative; overflow: hidden;
    background: radial-gradient(120% 80% at 50% 0%, #8E7BFF 0%, var(--cn-primary) 50%, var(--cn-primary-deep) 100%);
    padding: 60px 24px 40px;
    text-align: center; color: #fff;
}
.auth-hero::before {
    content: ''; position: absolute;
    width: 220px; height: 220px; border-radius: 50%;
    background: rgba(255,255,255,0.12); top: -60px; right: -60px;
}
.auth-hero::after {
    content: ''; position: absolute;
    width: 140px; height: 140px; border-radius: 50%;
    background: rgba(255,255,255,0.08); top: 80px; left: -40px;
}
.auth-hero .brand-icon-lg {
    width: 72px; height: 72px; border-radius: 22px;
    background: rgba(255,255,255,0.15); backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.3);
    display: inline-flex; align-items: center; justify-content: center;
    margin-bottom: 16px;
}
.auth-card {
    background: var(--cn-card);
    border-radius: 24px 24px 0 0;
    margin-top: -20px;
    position: relative;
    padding: 32px 24px;
    min-height: 50vh;
}
.otp-boxes {
    display: flex; gap: 8px; direction: ltr; justify-content: center;
}
.otp-box {
    width: 48px; height: 56px; border-radius: 14px;
    background: var(--cn-card); border: 1.5px solid var(--cn-border);
    text-align: center; font-size: 22px; font-weight: 700;
    color: var(--cn-primary);
}
.otp-box:focus { border-color: var(--cn-primary); background: var(--cn-primary-soft); outline: none; }

/* ===== STORIES BAR ===== */
.stories-bar {
    display: flex; gap: 14px; padding: 14px 16px;
    overflow-x: auto; scrollbar-width: none;
    background: var(--cn-card);
    border-bottom: 1px solid var(--cn-border);
}
.stories-bar::-webkit-scrollbar { display: none; }
.story-item {
    flex-shrink: 0; width: 68px;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    cursor: pointer;
}
.story-avatar {
    width: 60px; height: 60px; border-radius: 50%;
    padding: 2.5px;
    background: linear-gradient(135deg, var(--cn-primary), var(--cn-danger));
}
.story-avatar img, .story-avatar .avatar-placeholder {
    width: 100%; height: 100%; border-radius: 50%;
    border: 2.5px solid var(--cn-card);
    object-fit: cover;
}
.story-add {
    width: 60px; height: 60px; border-radius: 50%;
    background: var(--cn-primary-soft);
    display: flex; align-items: center; justify-content: center;
    color: var(--cn-primary); font-size: 1.5rem;
}
.story-name { font-size: 11px; font-weight: 500; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== POST CARD ===== */
.post-card {
    background: var(--cn-card);
    border-bottom: 1px solid var(--cn-border-soft);
    padding: 14px 16px 8px;
}
.post-header {
    display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.post-text { font-size: 14px; line-height: 1.7; margin-bottom: 10px; }
.post-image { border-radius: var(--cn-radius); overflow: hidden; margin-bottom: 10px; }
.post-image img { width: 100%; display: block; }
.post-actions {
    display: flex; align-items: center; gap: 20px; padding-top: 10px;
    border-top: 1px solid var(--cn-border-soft);
}
.post-action-btn {
    display: flex; align-items: center; gap: 6px;
    background: transparent; border: none;
    color: var(--cn-ink); font-size: 13px; font-weight: 600;
    padding: 6px 0; cursor: pointer;
}
.post-action-btn .liked { color: var(--cn-danger); }

/* ===== CHAT LIST ===== */
.chat-list-item {
    display: flex; gap: 12px; padding: 12px 16px;
    align-items: center; text-decoration: none; color: inherit;
    transition: background 0.15s;
    border-bottom: 1px solid var(--cn-border-soft);
}
.chat-list-item:hover { background: var(--cn-primary-soft); color: inherit; }
.chat-section-header {
    display: flex; align-items: center; gap: 6px;
    padding: 14px 16px 8px; background: var(--cn-bg);
    font-size: 12px; font-weight: 700; color: var(--cn-ink-sub);
}
.chat-filter-pills {
    display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 0;
}
.chat-filter-pills::-webkit-scrollbar { display: none; }
.chat-filter-pill {
    padding: 7px 14px; border-radius: 999px; white-space: nowrap;
    font-size: 12px; font-weight: 600; border: 1px solid var(--cn-border);
    background: var(--cn-card); color: var(--cn-ink); cursor: pointer;
}
.chat-filter-pill.active {
    background: var(--cn-primary); color: #fff; border-color: transparent;
}

/* ===== CHAT ROOM / DM ===== */
/* Wrapper around <main> on chat pages: no padding, no scroll â€” the inner .chat-messages handles overflow. */
.chat-page-wrapper {
    padding: 0 !important;
    margin: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}
/* dm.html/room.html add this class so the page itself doesn't scroll. */
html.chat-open, body.chat-open { overflow: hidden; height: 100vh; }
@media (min-width: 768px) {
    .chat-container { border-left: 1px solid var(--cn-border); border-right: 1px solid var(--cn-border); }
}
.chat-header {
    background: var(--cn-card); padding: 12px 14px;
    border-bottom: 1px solid var(--cn-border);
    display: flex; align-items: center; gap: 10px;
}
.chat-container {
    display: flex; flex-direction: column;
    height: calc(100vh - 58px);
    max-width: 800px; margin: 0 auto;
    background: var(--cn-bg);
    overflow: hidden;        /* container itself doesn't scroll; only .chat-messages does */
}
.chat-messages {
    flex: 1 1 auto; min-height: 0; /* min-height:0 lets the flex child actually shrink and scroll */
    overflow-y: auto; padding: 12px 0;
    background: var(--cn-bg);
    scrollbar-width: thin; scrollbar-color: var(--cn-border) transparent;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--cn-border); border-radius: 2px; }

.chat-date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    align-self: stretch;
    clear: both;
    margin: 14px 0;
    padding-inline: 12px;
    pointer-events: none;
    text-align: center;
}

/* Mobile chat viewport: use the real visual viewport so browser bars/keyboard
   do not push the composer below the visible screen. */
:root {
    --mx-viewport-height: 100vh;
    --mx-navbar-height: 58px;
    --mx-chat-header-height: 56px;
    --mx-composer-height: 58px;
    --mx-keyboard-inset: 0px;
    --mx-chat-height: calc(var(--mx-viewport-height) - var(--mx-navbar-height));
}

@supports (height: 100dvh) {
    :root {
        --mx-viewport-height: 100dvh;
    }
}

@media (max-width: 991.98px) {
    html.chat-open,
    body.chat-open {
        width: 100%;
        height: var(--mx-viewport-height) !important;
        min-height: var(--mx-viewport-height) !important;
        max-height: var(--mx-viewport-height) !important;
        overflow: hidden !important;
        overscroll-behavior: none;
    }

    body.chat-conversation-open {
        position: fixed;
        inset: 0;
        padding-bottom: 0 !important;
    }

    body.chat-conversation-open main.chat-page-wrapper {
        height: var(--mx-chat-height) !important;
        min-height: 0 !important;
        max-height: var(--mx-chat-height) !important;
        overflow: hidden !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    body.chat-conversation-open .chat-shell,
    body.chat-conversation-open .chat-main,
    body.chat-conversation-open .chat-container,
    body.chat-conversation-open .chat-container-embedded {
        height: 100% !important;
        min-height: 0 !important;
        max-height: 100% !important;
        overflow: hidden !important;
    }

    body.chat-conversation-open .chat-shell {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        width: 100% !important;
    }

    body.chat-conversation-open .chat-main {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    body.chat-conversation-open .chat-container {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
    }

    body.chat-conversation-open .chat-header,
    body.chat-conversation-open .chat-input-area {
        flex: 0 0 auto !important;
    }

    body.chat-conversation-open .chat-messages {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 12px !important;
    }

    body.chat-conversation-open .chat-input-area {
        padding: 8px max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)) !important;
        transform: translateZ(0);
    }

    body.chat-conversation-open .chat-composer-row {
        width: 100% !important;
        min-width: 0 !important;
        gap: 6px !important;
    }

    body.chat-conversation-open .chat-composer-row .chat-input {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    body.chat-conversation-open .chat-composer-row .chat-input-action,
    body.chat-conversation-open .chat-composer-row .chat-send-btn {
        flex: 0 0 40px !important;
        width: 40px !important;
        height: 40px !important;
        min-height: 40px !important;
    }

    body.chat-conversation-open .chat-header {
        min-height: 56px !important;
        padding: 8px 8px !important;
        gap: 6px !important;
        flex-wrap: nowrap !important;
        overflow: visible !important;
    }

    body.chat-conversation-open .chat-header > a:first-child,
    body.chat-conversation-open .chat-peer-avatar,
    body.chat-conversation-open .chat-call-btn,
    body.chat-conversation-open .chat-header-more {
        flex: 0 0 auto !important;
    }

    body.chat-conversation-open .chat-peer-meta {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        overflow: hidden !important;
    }

    body.chat-conversation-open .chat-peer-title,
    body.chat-conversation-open #user-status,
    body.chat-conversation-open .chat-peer-meta > div {
        display: block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body.chat-conversation-open .chat-header .btn-cn-icon {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        padding: 0 !important;
    }

    body.chat-conversation-open .chat-header .dropdown-menu {
        min-width: 190px;
        border-radius: 10px;
        border: 1px solid var(--cn-border);
        box-shadow: var(--cn-shadow-lg);
    }
}

@media (max-width: 360px) {
    body.chat-conversation-open .chat-peer-avatar {
        display: none !important;
    }

    body.chat-conversation-open .chat-header {
        gap: 5px !important;
    }
}
.chat-date-separator span {
    max-width: min(78vw, 320px);
    padding: 6px 14px;
    border: 1px solid rgba(255,255,255,.42);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.54);
    color: var(--cn-ink-sub);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.10);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
    text-align: center;
    white-space: nowrap;
    backdrop-filter: blur(10px);
}
[data-theme="dark"] .chat-date-separator span {
    background: rgba(15, 23, 42, 0.58);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}
.chat-system-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin: 10px 0;
    padding-inline: 12px;
    pointer-events: none;
}
.chat-system-separator span {
    max-width: min(82vw, 520px);
    padding: 7px 14px;
    border: 1px solid rgba(255,255,255,.42);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.50);
    color: var(--cn-ink-sub);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.10);
    font-size: 11px;
    font-weight: 800;
    line-height: 1.5;
    text-align: center;
    backdrop-filter: blur(14px) saturate(140%);
}
[data-theme="dark"] .chat-system-separator span {
    background: rgba(15, 23, 42, 0.58);
}

/* Message row layout â€” pinned approach.
   Trick: we force the ROW container to LTR direction so flex placement
   becomes intuitive regardless of the page's RTL direction. Then the
   bubble re-enables RTL for its own Persian text.

   Result:
     sent     (mine)  â†’ row justify-content: flex-end   â†’ bubble on RIGHT
     received (other) â†’ row justify-content: flex-start â†’ avatar+bubble on LEFT,
                        in source order [avatar, bubble] so avatar appears LEFT of bubble.  */
.msg-row {
    display: flex;
    direction: ltr;                       /* force LTR on the row itself */
    padding: 2px 14px; margin-bottom: 3px;
    align-items: flex-end; gap: 8px;
}
.msg-row.sent     { justify-content: flex-end; }     /* mine goes to the right edge */
.msg-row.received { justify-content: flex-start; }   /* other side goes to the left edge */
.msg-row.received .cn-avatar { margin: 0 !important; flex-shrink: 0; }
.msg-row .msg-avatar-link { display: inline-flex; align-items: flex-end; flex-shrink: 0; line-height: 0; }
/* Bubble direction:
   Each bubble auto-detects its own direction from its content so that:
     - Persian text gets RTL alignment naturally
     - Latin text (e.g. "khobi?") stays LTR, keeping punctuation on the
       correct visual side instead of being flipped by the surrounding RTL.
   unicode-bidi: plaintext makes the Unicode Bidi algorithm honour the
   FIRST strong character in each paragraph as the direction. */
.msg-bubble {
    unicode-bidi: plaintext;
}
.msg-text {
    unicode-bidi: plaintext;
    text-align: start;            /* let the auto direction decide left/right */
}

.msg-bubble {
    max-width: 78%; padding: 9px 13px; border-radius: 18px;
    font-size: 14px; line-height: 1.65;
    animation: msgIn 0.2s ease;
    position: relative;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.msg-bubble.sent {
    background: var(--cn-bubble-me); color: var(--cn-bubble-me-ink);
    border-bottom-right-radius: 4px;          /* tail toward the bottom-left as in the user's screenshot */
    box-shadow: 0 2px 8px rgba(108,92,231,0.22);
    padding-left: 34px;                      /* extra room on the left for the edit-menu dots */
}
.msg-bubble.received {
    background: var(--cn-bubble-them); color: var(--cn-bubble-them-ink);
    border-bottom-left-radius: 4px;
}

/* Edit menu: sits in the gutter we reserved with padding-left on .msg-bubble.sent */
.msg-menu {
    position: absolute !important;
    top: 4px; left: 4px;
    z-index: 1;
}
.msg-bubble.sent .msg-menu-btn {
    color: rgba(255,255,255,0.85);
}
.msg-bubble.sent .msg-menu-btn:hover {
    color: #fff;
    background: rgba(255,255,255,0.2);
}
.msg-menu-btn {
    background: transparent; border: none;
    padding: 2px 6px; cursor: pointer; border-radius: 6px;
    font-size: 13px; line-height: 1;
    transition: background 0.12s, color 0.12s;
}

.msg-meta {
    display: flex; align-items: center; gap: 4px; justify-content: flex-start;
    margin-top: 3px; font-size: 10px; opacity: 0.7;
}
.msg-bubble.sent .msg-meta { color: rgba(255,255,255,0.85); }
.msg-bubble.received .msg-meta { color: var(--cn-ink-mute); }
.msg-meta .read-tick { font-size: 12px; }
.msg-meta .edited-label { font-size: 10px; opacity: 0.7; display: inline-flex; align-items: center; gap: 2px; }
.msg-meta .edited-label i { font-size: 9px; }
.msg-image { max-width: 250px; border-radius: 12px; cursor: pointer; display: block; margin-bottom: 4px; }
.msg-sender-name { font-size: 12px; font-weight: 600; color: var(--cn-primary); margin-bottom: 2px; }
.msg-bubble.sent .msg-sender-name { color: rgba(255,255,255,0.8); }

.chat-input-area {
    background: var(--cn-card);
    border-top: 1px solid var(--cn-border);
    padding: 10px 12px 14px;
    display: flex; align-items: flex-end; gap: 8px;
}
.chat-input {
    flex: 1; background: var(--cn-border-soft);
    border-radius: 22px; padding: 10px 14px;
    border: none; font-size: 14px; resize: none;
    max-height: 120px; min-height: 40px;
    color: var(--cn-ink);
}
.chat-input:focus { outline: none; background: var(--cn-primary-soft); }
.chat-input::placeholder { color: var(--cn-ink-mute); }
.chat-send-btn {
    width: 42px; height: 42px; border-radius: 14px;
    background: var(--cn-primary); border: none; color: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(108,92,231,0.35);
    transition: all 0.2s;
}
.chat-send-btn:hover { background: var(--cn-primary-deep); }
.chat-input-action {
    width: 38px; height: 38px; border-radius: 12px;
    background: var(--cn-primary-soft); border: none;
    color: var(--cn-primary);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.typing-indicator {
    padding: 0 14px; min-height: 22px;
    font-size: 12px; color: var(--cn-primary);
    font-style: italic;
}
.new-msg-indicator {
    position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
    z-index: 10;
    background: var(--cn-primary); color: #fff;
    border: none; border-radius: 999px;
    padding: 8px 16px; font-size: 12px; font-weight: 700;
    box-shadow: var(--cn-shadow-lg);
}

/* ===== ONLINE DOT ===== */
.online-dot {
    width: 12px; height: 12px; border-radius: 50%;
    border: 2.5px solid var(--cn-card);
    position: absolute; bottom: 0; left: 0;
}
.online-dot.online { background: var(--cn-online); }
.online-dot.offline { background: #C9C5DB; }

/* ===== AVATAR ===== */
.cn-avatar {
    border-radius: 50%; object-fit: cover;
    border: 2px solid var(--cn-border);
}

/* ===== PROFILE ===== */
.profile-stats {
    display: flex; gap: 0;
}
.profile-stat {
    flex: 1; text-align: center; padding: 10px 0;
    text-decoration: none; color: inherit;
    border-inline-start: 1px solid var(--cn-border-soft);
}
.profile-stat:first-child { border-inline-start: none; }
.profile-stat-value { font-size: 18px; font-weight: 800; color: var(--cn-ink); display: block; }
.profile-stat-label { font-size: 12px; color: var(--cn-ink-sub); font-weight: 500; }
.profile-social-links {
    display: flex; gap: 12px; align-items: center;
}
.profile-social-link {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--cn-border-soft);
    display: flex; align-items: center; justify-content: center;
    color: var(--cn-ink-sub); text-decoration: none;
    transition: all 0.2s;
}
.profile-social-link:hover { background: var(--cn-primary-soft); color: var(--cn-primary); }
.post-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.post-grid-item {
    aspect-ratio: 1; overflow: hidden; position: relative;
}
.post-grid-item img { width: 100%; height: 100%; object-fit: cover; }
.post-grid-item .text-preview {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    background: var(--cn-border-soft); padding: 8px;
    font-size: 12px; color: var(--cn-ink-sub); text-align: center;
}

/* ===== NOTIFICATIONS ===== */
.notif-item {
    display: flex; gap: 12px; padding: 12px 16px;
    align-items: center;
    border-bottom: 1px solid var(--cn-border-soft);
    transition: background 0.15s;
}
.notif-item:hover { background: var(--cn-primary-soft); }
.notif-item.unread { background: #F7F4FF; }
.notif-icon-badge {
    position: absolute; bottom: -2px; left: -2px;
    width: 22px; height: 22px; border-radius: 50%;
    border: 2px solid var(--cn-card);
    display: flex; align-items: center; justify-content: center;
    font-size: 10px;
}

/* ===== CONTACTS ===== */
.contact-online-bar {
    display: flex; gap: 14px; padding: 14px 16px;
    overflow-x: auto; scrollbar-width: none;
    background: var(--cn-card);
    border-bottom: 1px solid var(--cn-border);
}
.contact-online-bar::-webkit-scrollbar { display: none; }

/* ===== TOAST ===== */
.toast {
    border: 1px solid var(--cn-border) !important;
    border-radius: var(--cn-radius) !important;
    box-shadow: var(--cn-shadow-lg) !important;
    overflow: hidden;
    animation: toastSlide 0.3s ease;
}
@keyframes toastSlide { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast .toast-header { background: var(--cn-primary); color: #fff; border: none; }

/* ===== LIGHTBOX ===== */
.lightbox-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.85);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.lightbox-overlay img { max-width: 90%; max-height: 85vh; border-radius: var(--cn-radius); }

/* ===== LETTER SPACING OTP ===== */
.letter-spacing-wide { letter-spacing: 12px; font-size: 1.5rem; font-weight: bold; }

/* ===== UTILITIES ===== */
.min-width-0 { min-width: 0; }
.object-fit-cover { object-fit: cover; }
.animate-pulse { animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ===== ALERTS ===== */
.alert { border-radius: var(--cn-radius-sm); border: none; }

/* ===== MOBILE ===== */
@media (max-width: 768px) {
    .cn-navbar .navbar-brand { font-size: 1rem; }
    .msg-bubble { max-width: 85%; }
    .chat-header { padding: 8px 12px; }
    .chat-input-area { padding: 8px 12px 10px; }
    .profile-stat-value { font-size: 16px; }
}

/* ===== PC ENHANCEMENTS ===== */
@media (min-width: 992px) {
    .cn-card { max-width: 640px; margin-left: auto; margin-right: auto; }
    .post-card { max-width: 640px; margin-left: auto; margin-right: auto; }
    .stories-bar { max-width: 640px; margin-left: auto; margin-right: auto; border-radius: var(--cn-radius) var(--cn-radius) 0 0; }
}

/* ===== PLYR CUSTOM ===== */
.msg-bubble .plyr{--plyr-color-main:var(--cn-primary);--plyr-audio-controls-background:transparent;--plyr-audio-control-color:inherit;--plyr-range-fill-background:var(--cn-primary);border-radius:10px;min-width:200px;max-width:260px}
.msg-bubble.sent .plyr{--plyr-audio-control-color:#fff;--plyr-audio-controls-background:transparent}
.msg-bubble .plyr--audio .plyr__controls{padding:4px 8px;gap:4px}
.msg-bubble video.plyr-init+.plyr{max-width:280px}
.msg-bubble .plyr--video{border-radius:12px;overflow:hidden;max-width:280px}

/* ===========================================================================
   RTL HARDENING
   The whole UI is Persian / RTL. We've already set <html dir="rtl"> and we use
   Bootstrap's RTL build. The block below fixes the remaining spots where
   physical directions (left/right) creep in via inline styles or libraries.
   =========================================================================== */

/* Close-button corner (used on image/media previews).
   Inline styles set top:-6px;right:-6px â€” we override to use the logical end
   of the inline axis, which is the visual LEFT in RTL. */
[dir="rtl"] #clear-img-btn,
[dir="rtl"] #clear-img-btn-2 {
    right: auto !important;
    left: -6px !important;
}

/* Unread badge inside the "unread" tab on chat list:
   inline `right:12px` becomes the visual LEFT in RTL â€” flip it. */
[dir="rtl"] .chat-filter-pill .cn-badge,
[dir="rtl"] .nav-link .cn-badge,
[dir="rtl"] a[href*="tab=unread"] .cn-badge {
    right: auto !important;
    left: 12px !important;
}

/* Toast container: Bootstrap's .position-fixed.top-0.end-0 with RTL CSS already
   handles this, but force it explicitly to avoid edge-case overrides. */
[dir="rtl"] #toast-container { right: 0 !important; left: auto !important; }

/* Margin helpers that were authored with physical sides:
   in our codebase we have a few `margin-right:8px` style usages around the
   unblock button label. Flip those automatically. */
[dir="rtl"] [style*="margin-right:8px"]:not([data-no-rtl-flip]) {
    margin-right: 0 !important;
    margin-left: 8px !important;
}

/* Number / time strings inside Persian text: keep them embedded LTR so that
   "11:25" or "غ±غ²:غ³غ°" doesn't visually flip when followed by punctuation. */
.msg-time, .chat-time, .notif-time, .post-time {
    unicode-bidi: embed;
    direction: ltr;
    display: inline-block;
}

/* Make sure dropdown menus open toward the inline-start in RTL by default.
   Bootstrap RTL handles this automatically for .dropdown-menu-end, but our
   custom dropdowns sometimes use plain .dropdown-menu. */
[dir="rtl"] .dropdown-menu { text-align: right; }

/* Forms / inputs: Persian text should be right-aligned. Some Bootstrap form
   controls are LTR-aligned via .form-control. */
[dir="rtl"] .form-control,
[dir="rtl"] .cn-input,
[dir="rtl"] textarea,
[dir="rtl"] input[type="text"],
[dir="rtl"] input[type="search"],
[dir="rtl"] input[type="tel"],
[dir="rtl"] input[type="password"],
[dir="rtl"] input[type="email"] {
    text-align: right;
    direction: rtl;
}

/* The chat input textarea contains Persian by default but is also used to type
   phone numbers / English commands. Let the browser auto-decide per content. */
[dir="rtl"] .chat-input { direction: rtl; text-align: right; }
[dir="rtl"] .chat-input::placeholder { text-align: right; }

/* OTP / phone inputs are always LTR even on RTL pages */
input[type="tel"][name="phone"],
input[name="otp"], input[name="code"],
input[inputmode="numeric"] {
    direction: ltr !important;
    text-align: center !important;
    unicode-bidi: bidi-override;
}

/* Bootstrap icons that are inherently directional (arrows) need flipping in RTL.
   We use bi-arrow-right / bi-arrow-left intentionally for "back" / "forward".
   In RTL, "back" should point right; we already use bi-arrow-right for back
   buttons, which is correct in RTL. Don't auto-flip those â€” keep them as-is. */

/* Bootstrap utilities that DO take a physical side regardless of RTL */
.text-end-physical { text-align: left !important; }     /* visual left in any dir */
.text-start-physical { text-align: right !important; }  /* visual right in any dir */

/* Scrollbar position: WebKit puts the scrollbar on the inline-end (left in RTL).
   That's the expected behavior for Persian users â€” keep it. */

/* Ensure all flex rows we author respect RTL by default. Bootstrap's flex
   utilities are already RTL-aware. Custom .d-flex rows authored with
   `gap` and no `flex-direction` get RTL ordering automatically. */


/* ============================================================
   CHAT SHELL â€” two-column layout for chat list / dm / room / channel
   Sidebar LEFT, main panel RIGHT (per the design mockup).
   ============================================================ */

.chat-shell {
    display: flex;
    direction: ltr;            /* flex order: child #1 on the left, #2 on the right */
    height: calc(100vh - 58px); /* below the top nav (58px) */
    background: var(--cn-bg);
    overflow: hidden;
}
.chat-shell > * { direction: rtl; } /* contents themselves render RTL */

.chat-sidebar {
    flex: 0 0 320px;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    background: var(--cn-card);
    border-inline-end: 1px solid var(--cn-border);
    overflow: hidden;
}
.chat-sidebar-header {
    padding: 14px 14px 0;
    border-bottom: 1px solid var(--cn-border);
    flex-shrink: 0;
}
.chat-sidebar-search {
    position: relative;
    margin-bottom: 12px;
}
.chat-sidebar-search > i {
    position: absolute;
    inset-inline-start: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cn-ink-mute);
    font-size: 14px;
    pointer-events: none;
}
.chat-sidebar-search > input {
    width: 100%;
    padding: 9px 36px 9px 12px;
    border: 1px solid var(--cn-border);
    border-radius: 10px;
    background: var(--cn-bg);
    font-size: 13px;
    color: var(--cn-ink);
    outline: none;
    transition: border-color .15s, background .15s;
}
.chat-sidebar-search > input:focus {
    border-color: var(--cn-primary);
    background: var(--cn-card);
}
.chat-sidebar-search > input::placeholder { color: var(--cn-ink-mute); }

.chat-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 4px;
    background: var(--cn-bg);
    border-radius: 12px;
    margin: 0 8px;
    -webkit-overflow-scrolling: touch;
}
.chat-tabs::-webkit-scrollbar { display: none; }
button.chat-tab, .chat-tab {
    /* Reset ALL native button styling â€” important due to browser defaults */
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
    padding: 8px 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--cn-ink-mute) !important;
    text-decoration: none;
    background: transparent !important;
    background-image: none !important;
    border: 0 !important;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: color .15s, background .15s;
    box-shadow: none !important;
    outline: none !important;
    font-family: inherit !important;
    line-height: 1.4;
    margin: 0;
}
button.chat-tab:hover, .chat-tab:hover {
    color: var(--cn-ink) !important;
    background: rgba(255,255,255,.6) !important;
}
button.chat-tab.active, .chat-tab.active {
    color: var(--cn-primary) !important;
    background: var(--cn-card) !important;
    font-weight: 700;
    box-shadow: 0 1px 2px rgba(0,0,0,.05) !important;
}
button.chat-tab:focus, .chat-tab:focus,
button.chat-tab:focus-visible, .chat-tab:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}
button.chat-tab.active:focus, .chat-tab.active:focus {
    box-shadow: 0 1px 2px rgba(0,0,0,.05) !important;
}

.chat-sidebar-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 6px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--cn-border) transparent;
}
.chat-sidebar-list::-webkit-scrollbar { width: 4px; }
.chat-sidebar-list::-webkit-scrollbar-thumb { background: var(--cn-border); border-radius: 2px; }

.chat-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    text-decoration: none;
    color: inherit;
    border-radius: 10px;
    margin: 2px 6px;
    transition: background .12s;
    cursor: pointer;
}
.chat-list-item:hover { background: var(--cn-primary-soft); }
.chat-list-item.active { background: var(--cn-primary-soft); }

.ci-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}
.ci-avatar-fallback {
    width: 48px; height: 48px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 20px;
}
.group-grad { background: linear-gradient(135deg, var(--cn-primary), #FF7A89); }
.ch-grad    { background: linear-gradient(135deg, #9B8AFF, #6A5ACD); }

.ci-body {
    flex: 1;
    min-width: 0;
}
.ci-head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
}
.ci-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--cn-ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 0 1 auto;
    max-width: 100%;
}
.chat-pill {
    font-size: 10px;
    color: #fff;
    padding: 1px 6px;
    border-radius: 6px;
    font-weight: 600;
    flex-shrink: 0;
}
.pill-group   { background: linear-gradient(135deg, var(--cn-primary), #9b8aff); }
.pill-channel { background: linear-gradient(135deg, #6A5ACD, #3A2DBB); }

.ci-preview {
    font-size: 12px;
    color: var(--cn-ink-sub);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ci-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}
.ci-meta .chat-time { font-size: 11px; }
.chat-unread-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--cn-primary);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-sidebar-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--cn-ink-mute);
}
.chat-sidebar-empty > i { font-size: 42px; }
.chat-sidebar-empty > p { margin: 12px 0 16px; font-size: 13px; }

/* ---- Main panel ---- */
.chat-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--cn-bg);
    overflow: hidden;
}
.chat-empty-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    color: var(--cn-ink-mute);
}
.chat-empty-bubble {
    width: 100px; height: 100px;
    border-radius: 50%;
    background: var(--cn-primary-soft);
    color: var(--cn-primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 44px;
    margin-bottom: 18px;
}
.chat-empty-pane h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--cn-ink);
    margin-bottom: 8px;
}
.chat-empty-pane p {
    font-size: 13px;
    color: var(--cn-ink-mute);
    line-height: 1.7;
}

/* On narrow screens, collapse to a single-column experience:
   either the sidebar or the main panel is visible at one time.
   When a chat is opened, dm/room/channel pages get the `.chat-with-back`
   helper which hides the sidebar and shows only the main panel on mobile. */
@media (max-width: 768px) {
    .chat-sidebar { flex: 0 0 100%; max-width: 100%; }
    .chat-main { display: none; }
    .chat-shell.chat-active .chat-sidebar { display: none; }
    .chat-shell.chat-active .chat-main { display: flex; flex: 0 0 100%; }
}

/* ============================================================
   CHANNEL page extras
   ============================================================ */
.channel-post {
    background: var(--cn-card);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 12px;
    max-width: 640px;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.channel-post .cp-text { white-space: pre-wrap; word-wrap: break-word; font-size: 14px; line-height: 1.7; }
.channel-post .cp-meta {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: var(--cn-ink-mute);
}
.channel-post .cp-meta .cp-views { display: inline-flex; align-items: center; gap: 4px; }
.channel-post .cp-meta .cp-views i { font-size: 13px; }
.channel-post .cp-media img,
.channel-post .cp-media video {
    max-width: 100%;
    border-radius: 10px;
    display: block;
    margin-bottom: 8px;
}
.channel-post .cp-actions {
    margin-inline-start: auto;
}

.channel-post-composer {
    background: var(--cn-card);
    border-top: 1px solid var(--cn-border);
    padding: 12px 16px;
}
.channel-post-composer textarea {
    width: 100%;
    border: 1px solid var(--cn-border);
    border-radius: 10px;
    padding: 10px 12px;
    resize: vertical;
    min-height: 60px;
    font-size: 14px;
}
.channel-post-composer textarea:focus {
    outline: none;
    border-color: var(--cn-primary);
}
.channel-post-composer .composer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

/* When chat-container is embedded inside chat-main (two-column shell),
   override its default centered max-width so it fills the right pane. */
.chat-main .chat-container,
.chat-container-embedded {
    max-width: 100%;
    margin: 0;
    height: 100%;
    border-left: none;
    border-right: none;
}


/* ============================================================
   SOCIAL HOME â€” three-column layout (per the mockup)
   ============================================================ */
.social-three-col {
    margin-top: 8px;
}
.social-left-aside,
.social-right-aside {
    padding-top: 4px;
}
.social-center-col {
    padding-top: 0;
}

/* Mini stories strip (right sidebar) */
.stories-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 4px 0;
}
.story-item-mini {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    width: 56px;
}
.story-mini-add {
    width: 48px; height: 48px; border-radius: 50%;
    background: var(--cn-primary-soft); color: var(--cn-primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    border: 2px dashed var(--cn-primary);
}
.story-mini-avatar {
    width: 48px; height: 48px; border-radius: 50%;
    padding: 2px;
    background: linear-gradient(135deg, var(--cn-primary), #FF7A89);
}
.story-mini-avatar img {
    width: 100%; height: 100%; border-radius: 50%;
    border: 2px solid var(--cn-card);
    object-fit: cover;
}
.story-mini-name {
    font-size: 10px; max-width: 56px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Mention + hashtag links (used by linkify_mh) */
.mention-link, .hashtag-link {
    color: var(--cn-primary);
    text-decoration: none;
    font-weight: 600;
    direction: ltr;
    display: inline-block;
}
.mention-link:hover, .hashtag-link:hover {
    text-decoration: underline;
}


/* ============================================================
   DISCOVER pages (groups / channels) â€” tabs + rows
   ============================================================ */
.discover-tabs {
    display: flex;
    gap: 6px;
    border-radius: 12px;
    background: var(--cn-bg);
    padding: 4px;
}
.discover-tab {
    flex: 1;
    text-align: center;
    padding: 8px 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--cn-ink-mute);
    text-decoration: none;
    border-radius: 8px;
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.discover-tab i { font-size: 12px; margin-inline-end: 4px }
.discover-tab:hover { color: var(--cn-ink); }
.discover-tab.active {
    background: var(--cn-card);
    color: var(--cn-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.discover-row { padding: 10px 14px; }
.discover-row:hover { transform: translateY(-1px); transition: transform .15s; }


/* ============================================================
   MEDIA PLAYERS â€” hide volume controls; Telegram-style audio
   ============================================================ */

/* Hide native volume on video/audio (best-effort cross-browser).
   Chromium: --webkit-media-controls-mute-button + volume-slider hidden.
   We also use controlsList="nomute" on the elements themselves. */
video::-webkit-media-controls-mute-button,
audio::-webkit-media-controls-mute-button,
video::-webkit-media-controls-volume-slider,
audio::-webkit-media-controls-volume-slider,
video::-webkit-media-controls-volume-control-container,
audio::-webkit-media-controls-volume-control-container {
    display: none !important;
}

/* The <audio> element inside our tg-audio container is hidden:
   we drive playback programmatically and show our own UI. */
.tg-audio audio { display: none !important; }
/* Hide ALL audio elements anywhere in the chat â€” only tg-audio UI is allowed.
   This is defensive: even if a template renders <audio controls> we never
   want the native player to appear. */
.chat-messages audio,
.msg-bubble audio,
.msg-row audio,
.channel-post audio {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    visibility: hidden !important;
    position: absolute !important;
}

/* WhatsApp-style voice/music player (wavesurfer.js based) â”€â”€â”€ */
.tg-audio {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px 8px 8px;
    background: var(--cn-primary-soft);
    border-radius: 14px;
    min-width: 260px;
    max-width: 340px;
    direction: ltr;
    margin-top: 4px;
}
/* Sent (right) bubble: translucent on the purple background */
.msg-bubble.sent .tg-audio { background: rgba(255,255,255,.20); }

.tg-audio .tg-play {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--cn-primary);
    color: #fff;
    border: none;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform .12s, background .15s;
    padding: 0;
}
.msg-bubble.sent .tg-audio .tg-play { background: #fff; color: var(--cn-primary); }
.tg-audio .tg-play:hover { transform: scale(1.05); }
.tg-audio .tg-play:active { transform: scale(0.95); }
.tg-audio .tg-play i { font-size: 18px; line-height: 1; }

.tg-audio .tg-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Container for the wavesurfer canvas */
.tg-audio .ws-waveform {
    width: 100%;
    height: 32px;
    cursor: pointer;
    overflow: hidden;
}
/* wavesurfer.js renders a wrapper + canvas inside .ws-waveform */
.tg-audio .ws-waveform > div { height: 100% !important; }
.tg-audio .ws-waveform canvas { display: block; }

.tg-audio .ws-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--cn-ink-mute);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}
.msg-bubble.sent .tg-audio .ws-meta { color: rgba(255,255,255,.85); }
.tg-audio .ws-divider { opacity: .6; }
.tg-audio .ws-size { font-size: 10px; opacity: .85; }
.tg-audio .tg-time { font-variant-numeric: tabular-nums; }

/* Speed chip â€” sits on the right side of the meta line */
.tg-audio .tg-speed {
    margin-inline-start: auto;
    background: rgba(108, 92, 231, 0.15);
    color: var(--cn-primary);
    border: none;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 8px;
    cursor: pointer;
    font-variant-numeric: tabular-nums;
    line-height: 1.4;
    transition: background .15s;
}
.tg-audio .tg-speed:hover { background: rgba(108, 92, 231, 0.25); }
.msg-bubble.sent .tg-audio .tg-speed {
    background: rgba(255,255,255,.25);
    color: #fff;
}
.msg-bubble.sent .tg-audio .tg-speed:hover { background: rgba(255,255,255,.35); }

/* CRITICAL: hide every <audio> tag inside the chat. wavesurfer creates its
   own internal element which it places inside .ws-waveform. */
.tg-audio audio { display: none !important; }

/* Video uses native player but volume buttons hidden via CSS above.
   Just constrain size & rounded corners. */
.tg-video {
    max-width: 320px;
    width: 100%;
    border-radius: 12px;
    display: block;
}


/* ============================================================
   REPLY + REACTIONS UI (chat messages)
   ============================================================ */

/* Reply quote bubble shown ABOVE a message that's a reply */
.msg-reply {
    display: block;
    background: rgba(108, 92, 231, 0.12);
    border-inline-start: 3px solid var(--cn-primary);
    padding: 6px 10px;
    border-radius: 6px;
    margin: 0 0 8px 0;
    cursor: pointer;
    max-width: 280px;
    overflow: hidden;
    /* Ensure two lines stack â€” no overlap */
    line-height: 1.4;
}
.msg-bubble.sent .msg-reply {
    background: rgba(255, 255, 255, 0.18);
    border-inline-start-color: #fff;
}
.msg-reply-from {
    font-size: 11px;
    font-weight: 700;
    color: var(--cn-primary);
    display: block;
    line-height: 1.4;
    margin: 0 0 2px 0;
}
.msg-bubble.sent .msg-reply-from { color: #fff; opacity: .95; }
.msg-reply-text {
    font-size: 12px;
    color: var(--cn-ink-sub);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    display: block;
    line-height: 1.4;
}
.msg-bubble.sent .msg-reply-text { color: rgba(255,255,255,0.92); }

/* Hover/long-press action bar on each message */
.msg-row { position: relative; }
.msg-bubble { position: relative; }
.msg-actions {
    position: absolute;
    top: -14px;
    /* Always place the action bar at the inside-end edge of the bubble
       so it stays visible regardless of sent/received and never overflows
       the chat-main column. */
    inset-inline-end: 8px;
    background: var(--cn-card);
    border: 1px solid var(--cn-border);
    border-radius: 18px;
    padding: 2px;
    display: none;
    gap: 2px;
    box-shadow: 0 2px 8px rgba(0,0,0,.10);
    z-index: 5;
    white-space: nowrap;
}
/* Sent messages: bar appears at the start (left in RTL = inside chat area) */
.msg-row.sent .msg-actions {
    inset-inline-end: auto;
    inset-inline-start: 8px;
}
/* Show on hover anywhere within the row, on focus, and when mobile taps */
.msg-row:hover .msg-actions,
.msg-row:focus-within .msg-actions { display: flex; }
.msg-actions button {
    width: 28px; height: 28px; border-radius: 50%;
    border: none; background: transparent;
    color: var(--cn-ink-sub); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    transition: background .12s;
    padding: 0;
}
.msg-actions button:hover { background: var(--cn-primary-soft); color: var(--cn-primary); }

/* Reaction picker popup */
.reaction-picker {
    position: absolute;
    top: -42px;
    inset-inline-end: 0;
    background: var(--cn-card);
    border: 1px solid var(--cn-border);
    border-radius: 24px;
    padding: 4px 6px;
    display: flex;
    gap: 2px;
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
    z-index: 20;
}
.reaction-picker button {
    border: none; background: transparent;
    width: 32px; height: 32px;
    font-size: 18px; cursor: pointer; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: transform .12s, background .12s;
}
.reaction-picker button:hover { background: var(--cn-primary-soft); transform: scale(1.2); }

/* Reaction chips shown below a message */
.msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}
.reaction-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--cn-card);
    border: 1px solid var(--cn-border);
    border-radius: 14px;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
    transition: all .12s;
}
.reaction-chip:hover { background: var(--cn-primary-soft); }
.reaction-chip.mine {
    background: var(--cn-primary-soft);
    border-color: var(--cn-primary);
    color: var(--cn-primary);
    font-weight: 700;
}
.reaction-chip .emoji { font-size: 14px; }
.reaction-chip .count { font-size: 11px; }

/* Reply-target preview shown above the composer (when replying) */
.reply-banner {
    background: var(--cn-primary-soft);
    border-inline-start: 3px solid var(--cn-primary);
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 6px;
    margin-bottom: 6px;
}
.reply-banner-body { flex: 1; min-width: 0; overflow: hidden; }
.reply-banner-from { font-size: 11px; font-weight: 700; color: var(--cn-primary); }
.reply-banner-preview {
    font-size: 12px; color: var(--cn-ink-sub);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.reply-banner-close {
    background: transparent; border: none; color: var(--cn-ink-mute);
    cursor: pointer; padding: 4px; font-size: 14px;
}


/* ============================================================
   PINNED BAR + SEARCH PANEL
   ============================================================ */
.pinned-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--cn-card);
    border-bottom: 1px solid var(--cn-border);
    border-inline-start: 3px solid var(--cn-primary);
    font-size: 12px;
    cursor: pointer;
    transition: background .12s;
}
.pinned-bar:hover { background: var(--cn-primary-soft); }
.pinned-bar i.bi-pin-fill { color: var(--cn-primary); font-size: 14px; flex-shrink: 0 }
.pinned-bar .pin-body { flex: 1; min-width: 0 }
.pinned-bar .pin-label { font-size: 10px; color: var(--cn-primary); font-weight: 700 }
.pinned-bar .pin-text  { color: var(--cn-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.pinned-bar .pin-unpin {
    background: transparent; border: none; color: var(--cn-ink-mute);
    cursor: pointer; padding: 4px; flex-shrink: 0;
}

/* Visual indicator that a message is the pinned one */
.msg-row.is-pinned .msg-bubble {
    box-shadow: 0 0 0 2px var(--cn-primary-soft);
}

/* Search panel (overlay on top of message list) */
.chat-search-overlay {
    position: absolute;
    top: 56px;          /* below chat-header */
    inset-inline: 0;
    background: var(--cn-card);
    border-bottom: 1px solid var(--cn-border);
    z-index: 30;
    box-shadow: 0 4px 8px rgba(0,0,0,.06);
    display: none;
    flex-direction: column;
    max-height: 60vh;
}
.chat-search-overlay.visible { display: flex }
.chat-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--cn-border);
}
.chat-search-bar input {
    flex: 1;
    border: 1px solid var(--cn-border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    outline: none;
}
.chat-search-bar input:focus { border-color: var(--cn-primary) }
.chat-search-results {
    overflow-y: auto;
    padding: 4px;
}
.chat-search-row {
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
}
.chat-search-row:hover { background: var(--cn-primary-soft) }
.chat-search-row .sr-sender { font-weight: 700; color: var(--cn-primary); font-size: 11px }
.chat-search-row .sr-text { color: var(--cn-ink); margin-top: 2px }
.chat-search-row mark { background: yellow; padding: 0 2px; border-radius: 2px }
.chat-search-empty { text-align: center; padding: 30px; color: var(--cn-ink-mute); font-size: 13px }


/* ============================================================
   POLLS & THREADS
   ============================================================ */
.poll-card {
    background: var(--cn-card);
    /* The poll sits inside a chat bubble (sent bubbles have white text). Force
       the card's own dark text colour so the question/options stay readable. */
    color: var(--cn-ink);
    border: 1px solid var(--cn-border);
    border-radius: 14px;
    padding: 14px 16px;
    margin-top: 6px;
    min-width: 240px;
    max-width: 360px;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.poll-question {
    color: var(--cn-ink);
    font-weight: 800; margin-bottom: 3px; font-size: 14.5px; line-height: 1.5;
}
.poll-meta {
    font-size: 11px; color: var(--cn-ink-mute); margin-bottom: 12px;
    text-transform: none; letter-spacing: .2px;
}
.poll-options { display: flex; flex-direction: column; gap: 7px; }
.poll-option {
    position: relative;
    background: var(--cn-bg);
    border: 1.5px solid var(--cn-border);
    border-radius: 11px;
    padding: 10px 13px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    overflow: hidden;
}
.poll-option:hover { border-color: var(--cn-primary); }
.poll-option.voted {
    border-color: var(--cn-primary);
    background: var(--cn-primary-soft);
}
.poll-option .po-fill {
    position: absolute;
    inset-block: 0; inset-inline-start: 0;
    background: linear-gradient(90deg, rgba(108,92,231,0.22), rgba(108,92,231,0.12));
    z-index: 0;
    border-radius: 11px;
    transition: width .35s cubic-bezier(.4,0,.2,1);
}
.poll-option .po-content {
    position: relative; z-index: 1;
    display: flex; align-items: center; gap: 9px;
}
.poll-option .po-text { flex: 1; font-size: 13.5px; font-weight: 500; }
.poll-option .po-count {
    font-size: 11.5px; color: var(--cn-ink-mute); font-weight: 700;
    font-variant-numeric: tabular-nums; white-space: nowrap;
}
.poll-option.voted .po-text { font-weight: 800; color: var(--cn-primary); }
.poll-option.voted .po-count { color: var(--cn-primary); }
.poll-option input[type=checkbox], .poll-option input[type=radio] {
    accent-color: var(--cn-primary); width: 16px; height: 16px; flex-shrink: 0; cursor: pointer;
}
.poll-footer { font-size: 11.5px; color: var(--cn-ink-mute); margin-top: 10px; }
.poll-footer .poll-close-link { font-weight: 700; text-decoration: none; }

.poll-vote-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--cn-primary), var(--cn-primary-deep));
    color: #fff;
    border: none;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 800;
    margin-top: 12px;
    cursor: pointer;
    transition: filter .15s, transform .05s;
    box-shadow: 0 4px 14px rgba(108,92,231,0.3);
}
.poll-vote-btn:hover { filter: brightness(1.07); }
.poll-vote-btn:active { transform: scale(0.98); }
.poll-vote-btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

/* (Threads removed: clicking reply now scrolls inline to the parent message
   and the parent quote on the reply itself is enough context.) */



/* ============================================================
   LOCATION message bubble + share dialog
   ============================================================ */
.msg-location {
    display: block;
    width: 240px;
    max-width: 100%;
    border-radius: 12px;
    overflow: hidden;
    margin-top: 4px;
}
.msg-location iframe,
.msg-location .ml-map-placeholder {
    width: 100%;
    height: 160px;
    border: 0;
    display: block;
}
.msg-location .ml-map-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--cn-primary);
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--cn-primary) 12%, transparent) 25%, transparent 25%) 0 0 / 22px 22px,
        linear-gradient(315deg, color-mix(in srgb, var(--cn-primary) 10%, transparent) 25%, transparent 25%) 0 0 / 22px 22px,
        color-mix(in srgb, var(--cn-primary) 7%, var(--cn-card));
}
.msg-location .ml-map-placeholder i {
    font-size: 32px;
}
.msg-location .ml-map-placeholder span {
    direction: ltr;
    font-size: 12px;
    font-weight: 700;
    color: var(--cn-ink-sub);
}
.msg-location .ml-meta {
    background: var(--cn-card);
    color: var(--cn-ink-sub);
    padding: 6px 10px;
    font-size: 12px;
    border-top: 1px solid var(--cn-border);
}
.msg-location .ml-meta a {
    color: var(--cn-primary);
    text-decoration: none;
    font-weight: 600;
}

/* Muted bell next to chat name */
.chat-mute-icon {
    color: var(--cn-ink-mute);
    font-size: 12px;
    margin-inline-start: 4px;
}


/* ============================================================
   PIN CHAT + ARCHIVE in sidebar
   ============================================================ */
.chat-list-item-wrap { position: relative; }
.chat-list-item-wrap:hover .chat-row-menu-btn { opacity: 1; }
.chat-row-menu-btn {
    position: absolute;
    top: 50%; transform: translateY(-50%);
    inset-inline-end: 6px;
    width: 24px; height: 24px;
    border-radius: 6px;
    background: var(--cn-card);
    border: 1px solid var(--cn-border);
    color: var(--cn-ink-mute);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s;
    font-size: 12px;
    z-index: 2;
}
.chat-list-item.is-pinned-chat {
    background: linear-gradient(90deg, rgba(108,92,231,.05), transparent 60%);
}

/* Context menu */
.chat-row-context-menu {
    background: var(--cn-card);
    border: 1px solid var(--cn-border);
    border-radius: 10px;
    padding: 4px;
    min-width: 160px;
    box-shadow: 0 4px 14px rgba(0,0,0,.12);
    z-index: 2000;
    display: flex; flex-direction: column;
}
.chat-row-context-menu button {
    background: transparent; border: none;
    padding: 8px 12px;
    text-align: start;
    font-size: 13px;
    color: var(--cn-ink);
    border-radius: 6px;
    cursor: pointer;
    display: flex; align-items: center; gap: 8px;
}
.chat-row-context-menu button:hover { background: var(--cn-primary-soft); color: var(--cn-primary); }
.chat-row-context-menu button i { font-size: 14px; }
.chat-row-context-menu button.chat-row-context-danger { color: #ef4444; }
.chat-row-context-menu button.chat-row-context-danger:hover { background: rgba(239,68,68,.10); color: #dc2626; }


/* ============================================================
   FORWARD MESSAGE modal
   ============================================================ */
.fwd-modal-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 4px;
}
.fwd-target {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .12s;
}
.fwd-target:hover { background: var(--cn-primary-soft); }
.fwd-target.selected { background: var(--cn-primary-soft); border-inline-start: 3px solid var(--cn-primary); }
.fwd-target input[type=checkbox] { accent-color: var(--cn-primary); }
.fwd-target .ft-avatar img,
.fwd-target .ft-avatar div { width: 36px; height: 36px; border-radius: 50%; }
.fwd-target .ft-name { font-weight: 600; font-size: 13px; flex: 1; }
.fwd-target .ft-pill {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 8px;
    background: var(--cn-border-soft);
    color: var(--cn-ink-mute);
}

/* Forward source preview at the top */
.fwd-source-preview {
    background: var(--cn-primary-soft);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--cn-ink-sub);
    border-inline-start: 3px solid var(--cn-primary);
}


/* ============================================================
   STICKERS / Big emoji rendering
   ============================================================ */
.msg-text.is-emoji-only {
    font-size: 48px;
    line-height: 1.2;
    padding: 0;
    background: transparent !important;
    margin: 0;
}
.msg-bubble.emoji-only {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
}
.msg-bubble.emoji-only .msg-meta {
    /* No bubble bg → force dark, readable time/ticks over the chat background
       (otherwise sent bubbles render the time white = invisible). */
    color: var(--cn-ink-mute) !important;
    background: rgba(0,0,0,.06);
    border-radius: 8px;
    padding: 2px 7px;
    margin-top: 4px;
    display: inline-flex;
}
.msg-bubble.emoji-only .msg-meta .msg-time,
.msg-bubble.emoji-only .msg-meta .read-tick,
.msg-bubble.emoji-only .msg-meta .edited-label {
    color: var(--cn-ink-mute) !important;
}
[data-theme="dark"] .msg-bubble.emoji-only .msg-meta { background: rgba(255,255,255,.12); }

/* Emoji/sticker picker popup */
.emoji-picker {
    position: absolute;
    bottom: 60px;
    inset-inline-end: 50px;
    width: 320px;
    max-height: 320px;
    background: var(--cn-card);
    border: 1px solid var(--cn-border);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    z-index: 100;
    overflow-y: auto;
    padding: 8px;
    display: none;
}
.emoji-picker.visible { display: block; }
.emoji-picker .ep-category {
    font-size: 11px;
    color: var(--cn-ink-mute);
    font-weight: 700;
    padding: 6px 4px 4px;
}
.emoji-picker .ep-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
}
.emoji-picker .ep-grid button {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 22px;
    padding: 6px;
    border-radius: 6px;
    transition: background .1s;
}
.emoji-picker .ep-grid button:hover {
    background: var(--cn-primary-soft);
    transform: scale(1.1);
}

/* ============================================================
   IMAGE GALLERY modal
   ============================================================ */
.gallery-modal {
    max-width: 900px !important;
}
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 6px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 4px;
}
.gallery-item {
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 8px;
    cursor: pointer;
    background: var(--cn-bg);
    position: relative;
}
.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .2s;
}
.gallery-item:hover img {
    transform: scale(1.05);
}
.gallery-empty {
    text-align: center;
    padding: 40px;
    color: var(--cn-ink-mute);
}
.gallery-loader {
    text-align: center;
    padding: 16px;
}

/* ============================================================
   JITSI video call link
   ============================================================ */
.jitsi-link-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #1f2937, #374151);
    color: #fff;
    border-radius: 12px;
    text-decoration: none;
    margin-top: 4px;
    max-width: 280px;
    transition: transform .15s;
}
.jitsi-link-card:hover {
    color: #fff;
    transform: translateY(-1px);
}
.jitsi-link-card .jl-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: rgba(255,255,255,.15);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 20px;
}
.jitsi-link-card .jl-body {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.jitsi-link-card .jl-title {
    font-weight: 700;
    font-size: 13px;
}
.jitsi-link-card .jl-sub {
    font-size: 11px;
    opacity: .8;
}


/* ============================================================
   DARK MODE
   ============================================================ */
[data-theme="dark"] {
    --cn-primary: #8B7CFF;
    --cn-primary-deep: #6C5CE7;
    --cn-primary-soft: #2A2547;
    --cn-primary-ink: #C7BDFF;
    --cn-bg: #0E0B1F;
    --cn-card: #1A1530;
    --cn-ink: #F0EEFB;
    --cn-ink-sub: #B4ADD0;
    --cn-ink-mute: #7873A0;
    --cn-border: #2A2547;
    --cn-border-soft: #221D3D;
    --cn-online: #2DD879;
    --cn-bubble-me: #6C5CE7;
    --cn-bubble-me-ink: #FFFFFF;
    --cn-bubble-them: #2A2547;
    --cn-bubble-them-ink: #F0EEFB;
    --cn-danger: #FF6B9F;
    --cn-shadow: 0 2px 12px rgba(0,0,0,0.4);
    --cn-shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}

[data-theme="dark"] body { background: var(--cn-bg); color: var(--cn-ink); }
[data-theme="dark"] .dropdown-menu {
    background: var(--cn-card) !important;
    border-color: var(--cn-border) !important;
}
[data-theme="dark"] .dropdown-item { color: var(--cn-ink); }
[data-theme="dark"] .dropdown-item:hover { background: var(--cn-primary-soft); color: var(--cn-primary); }
[data-theme="dark"] .dropdown-divider { border-color: var(--cn-border); }
[data-theme="dark"] .modal-content { background: var(--cn-card); color: var(--cn-ink); }
[data-theme="dark"] .modal-title { color: var(--cn-ink); }
[data-theme="dark"] .form-control,
[data-theme="dark"] .cn-input,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] input[type="tel"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background: var(--cn-card);
    color: var(--cn-ink);
    border-color: var(--cn-border);
}
[data-theme="dark"] .form-control:focus { background: var(--cn-card); color: var(--cn-ink); }
[data-theme="dark"] .btn-close { filter: invert(0.9); }
[data-theme="dark"] img.cn-avatar { background: var(--cn-card); }
[data-theme="dark"] hr { border-color: var(--cn-border); }
[data-theme="dark"] code, [data-theme="dark"] pre { background: var(--cn-border-soft); color: var(--cn-ink); }

/* Dark-mode toggle in topbar */
.theme-toggle-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--cn-ink-sub);
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.theme-toggle-btn:hover { background: var(--cn-primary-soft); color: var(--cn-primary); }
.theme-toggle-btn i { font-size: 18px; }


/* ============================================================
   QR PROFILE modal
   ============================================================ */
.qr-modal-content {
    background: var(--cn-card);
    text-align: center;
    padding: 24px;
}
.qr-canvas-wrap {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    display: inline-block;
    margin: 16px auto;
    box-shadow: var(--cn-shadow);
}
.qr-canvas-wrap canvas { display: block; }
.qr-username {
    font-size: 18px;
    font-weight: 800;
    margin-top: 12px;
    color: var(--cn-primary);
}
.qr-hint {
    font-size: 12px;
    color: var(--cn-ink-mute);
    margin-top: 8px;
}


/* ============================================================
   LOCK SCREEN
   ============================================================ */
.lock-overlay {
    position: fixed;
    inset: 0;
    background: var(--cn-bg);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.lock-icon {
    width: 96px; height: 96px;
    background: linear-gradient(135deg, var(--cn-primary), var(--cn-primary-deep));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 42px;
    box-shadow: var(--cn-shadow-lg);
    margin-bottom: 24px;
}
.lock-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--cn-ink);
    margin-bottom: 6px;
}
.lock-subtitle {
    font-size: 13px;
    color: var(--cn-ink-mute);
    margin-bottom: 24px;
}
.lock-pin-dots {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}
.lock-pin-dot {
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--cn-border);
    transition: background .15s;
}
.lock-pin-dot.filled { background: var(--cn-primary); }
.lock-pin-dot.error { background: var(--cn-danger); animation: shake .4s; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}
.lock-keypad {
    display: grid;
    grid-template-columns: repeat(3, 70px);
    gap: 12px;
}
.lock-key {
    width: 70px; height: 70px;
    border-radius: 50%;
    background: var(--cn-card);
    border: 1px solid var(--cn-border);
    font-size: 24px;
    font-weight: 600;
    color: var(--cn-ink);
    cursor: pointer;
    transition: background .12s, transform .08s;
}
.lock-key:active { transform: scale(0.96); background: var(--cn-primary-soft); }
.lock-key.empty { background: transparent; border: none; cursor: default; }
.lock-key.action { background: var(--cn-primary-soft); color: var(--cn-primary); font-size: 18px; }

.security-lock-page {
    max-width: 760px;
    margin: 32px auto;
    padding: 0 12px;
}
.security-lock-panel {
    border: 1px solid rgba(255,255,255,.42);
    border-radius: 18px;
    background: rgba(255,255,255,.62);
    box-shadow: 0 18px 48px rgba(15, 23, 42, .10);
    backdrop-filter: blur(18px) saturate(145%);
    padding: 22px;
}
.security-lock-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}
.security-lock-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--cn-primary), var(--cn-primary-deep));
    color: #fff;
    font-size: 24px;
    flex: 0 0 auto;
}
.security-lock-head h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 900;
    color: var(--cn-ink);
}
.security-lock-head p {
    margin: 4px 0 0;
    color: var(--cn-ink-mute);
    font-size: 13px;
}
.security-lock-status {
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--cn-border-soft);
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 18px;
    background: rgba(255,255,255,.44);
}
.security-lock-status .sl-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--cn-danger);
}
.security-lock-status.active .sl-dot {
    background: var(--cn-online);
}
.security-lock-status strong {
    font-size: 13px;
    color: var(--cn-ink);
}
.security-lock-status small {
    color: var(--cn-ink-mute);
    font-size: 12px;
}
.security-lock-form {
    display: grid;
    gap: 14px;
}
.security-lock-form label span {
    display: block;
    margin-bottom: 7px;
    color: var(--cn-ink-sub);
    font-size: 12px;
    font-weight: 800;
}
.security-lock-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
}
[data-theme="dark"] .security-lock-panel,
[data-theme="dark"] .security-lock-status {
    background: rgba(15,23,42,.58);
}


/* ============================================================
   TELEGRAM-STYLE MESSAGE CONTEXT MENU
   ============================================================ */
.tg-msg-menu {
    position: fixed;
    z-index: 10000;
    background: var(--cn-card);
    border: 1px solid var(--cn-border);
    border-radius: 14px;
    box-shadow: 0 8px 28px rgba(0,0,0,.15);
    min-width: 200px;
    padding: 6px;
    animation: tgMenuFadeIn .15s ease-out;
    direction: rtl;
}
@keyframes tgMenuFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

.tg-msg-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--cn-ink);
    background: transparent;
    border: none;
    width: 100%;
    text-align: start;
    transition: background .12s;
}
.tg-msg-menu-item:hover { background: var(--cn-primary-soft); color: var(--cn-primary); }
.tg-msg-menu-item.danger { color: var(--cn-danger); }
.tg-msg-menu-item.danger:hover { background: rgba(255, 79, 139, 0.12); color: var(--cn-danger); }
.tg-msg-menu-item .tg-mi-icon {
    font-size: 16px;
    flex-shrink: 0;
    min-width: 20px;
    text-align: center;
}
.tg-msg-menu-item .tg-mi-label {
    flex: 1;
}

.tg-msg-menu-divider {
    height: 1px;
    background: var(--cn-border);
    margin: 4px 6px;
}

/* Reactions row â€” above the menu, fluent compact look */
.tg-msg-reactions {
    position: fixed;
    z-index: 10000;
    background: var(--cn-card);
    border: 1px solid var(--cn-border);
    border-radius: 24px;
    padding: 4px 6px;
    display: flex;
    gap: 2px;
    box-shadow: 0 8px 28px rgba(0,0,0,.15);
    animation: tgMenuFadeIn .15s ease-out;
    direction: ltr;
}
.tg-msg-reactions button {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: transform .15s, background .12s;
    line-height: 1;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tg-msg-reactions button:hover {
    transform: scale(1.25);
    background: var(--cn-primary-soft);
}

/* Backdrop to dismiss menu on click outside */
.tg-msg-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: transparent;
}

/* Hide old hover action bar â€” we use the new context menu instead */
.msg-actions { display: none !important; }


/* ============================================================
   WebRTC VOICE / VIDEO CALL
   ============================================================ */
.mx-call-window {
    position: fixed;
    top: 80px;
    inset-inline-end: 24px;
    width: 360px;
    background: linear-gradient(135deg, #1f1d3a, #2a2547);
    color: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 36px rgba(0,0,0,.4);
    z-index: 9999;
    overflow: hidden;
    transition: all .2s;
}
.mx-call-window.minimized { width: 240px; }
.mx-call-window.minimized .mx-call-video-area { display: none; }
.mx-call-window.minimized .mx-call-controls { padding: 8px; gap: 6px; }
.mx-call-window.minimized .mx-cc-btn { width: 36px; height: 36px; font-size: 14px; }

.mx-call-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(0,0,0,.2);
}
.mx-call-peer { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mx-call-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.mx-call-name { font-weight: 700; font-size: 13px; color: #fff; }
.mx-call-status { font-size: 11px; color: rgba(255,255,255,.7); font-variant-numeric: tabular-nums; }
.mx-call-min {
    background: rgba(255,255,255,.1);
    border: none;
    color: #fff;
    width: 28px; height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .12s;
}
.mx-call-min:hover { background: rgba(255,255,255,.2); }

.mx-call-video-area {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #000;
    overflow: hidden;
}
.mx-remote-grid {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    grid-auto-rows: minmax(110px, 1fr);
    gap: 1px;
    background: rgba(255,255,255,.08);
}
.mx-remote-tile {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: radial-gradient(circle at center, #3d3675 0%, #1f1d3a 100%);
}
.mx-remote-media {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.mx-remote-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    color: rgba(255,255,255,.88);
}
.mx-remote-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,.32);
}
.mx-remote-name {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 700;
}
.mx-remote-tile.has-video .mx-remote-placeholder {
    display: none;
}
.mx-local-video {
    position: absolute;
    bottom: 12px;
    inset-inline-end: 12px;
    width: 88px;
    height: 66px;
    object-fit: cover;
    background: #222;
    border-radius: 10px;
    border: 2px solid rgba(255,255,255,.3);
    box-shadow: 0 4px 12px rgba(0,0,0,.4);
}
/* Voice-only blob (shown instead of video) */
.mx-call-voice-blob {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    color: rgba(255,255,255,.4);
    background: radial-gradient(circle at center, #3d3675 0%, #1f1d3a 100%);
}
.mx-call-video-area.voice-only .mx-local-video { display: none; }
.mx-call-video-area.voice-only .mx-call-voice-blob { display: flex; }
.mx-call-video-area.voice-only .mx-remote-grid:not(:empty) + .mx-local-video + .mx-call-voice-blob {
    display: none;
}
.mx-call-window.is-group {
    width: 420px;
}

.mx-call-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 14px;
    background: rgba(0,0,0,.15);
}
.mx-cc-btn {
    width: 48px; height: 48px;
    border-radius: 50%;
    border: none;
    color: #fff;
    background: rgba(255,255,255,.15);
    cursor: pointer;
    font-size: 18px;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, transform .12s;
}
.mx-cc-btn:hover { background: rgba(255,255,255,.25); }
.mx-cc-btn:active { transform: scale(0.92); }
.mx-cc-btn.off { background: rgba(255, 80, 80, .35); }
.mx-cc-btn.mx-hangup-btn { background: #ff4f5f; }
.mx-cc-btn.mx-hangup-btn:hover { background: #ff3a4d; }

/* Incoming call prompt (centered) */
.mx-incoming-prompt {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, var(--cn-primary), var(--cn-primary-deep));
    color: #fff;
    padding: 32px 36px;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 16px 48px rgba(0,0,0,.4);
    z-index: 10001;
    animation: mxPulse 1.5s infinite alternate;
}
@keyframes mxPulse {
    0%   { box-shadow: 0 16px 48px rgba(108,92,231,.4), 0 0 0 0 rgba(108,92,231,.5); }
    100% { box-shadow: 0 16px 48px rgba(108,92,231,.4), 0 0 0 24px rgba(108,92,231,0); }
}
.mx-incoming-avatar {
    width: 96px; height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255,255,255,.4);
    margin-bottom: 16px;
}
.mx-incoming-name {
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 4px;
}
.mx-incoming-sub {
    font-size: 13px;
    color: rgba(255,255,255,.85);
    margin-bottom: 24px;
}
.mx-incoming-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
}
.mx-incoming-accept,
.mx-incoming-reject {
    width: 60px; height: 60px;
    border-radius: 50%;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,.3);
    transition: transform .12s;
}
.mx-incoming-accept { background: #2ecc71; }
.mx-incoming-accept:hover { transform: scale(1.1); }
.mx-incoming-reject { background: #ff4f5f; }
.mx-incoming-reject:hover { transform: scale(1.1); }

/* Toast for call events */
.mx-call-toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,.85);
    color: #fff;
    padding: 10px 20px;
    border-radius: 12px;
    z-index: 10002;
    font-size: 13px;
    animation: mxToastIn .2s;
}
@keyframes mxToastIn {
    from { opacity: 0; transform: translate(-50%, -20px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}


/* Fake placeholder bars (shown before user clicks play) */
.tg-audio .ws-fake-wave {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 32px;
}
.tg-audio .ws-fake-bar {
    flex: 1;
    background: rgba(108, 92, 231, 0.25);
    border-radius: 1.5px;
    min-height: 4px;
}
.msg-bubble.sent .tg-audio .ws-fake-bar { background: rgba(255,255,255,.30); }

.tg-audio .ws-real-wave { width: 100%; }

/* Loading spinner inside play button */
.tg-audio .ws-spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: wsSpin .8s linear infinite;
}
@keyframes wsSpin { to { transform: rotate(360deg); } }
.msg-bubble.sent .tg-audio .ws-spinner {
    border-color: rgba(108,92,231,.3);
    border-top-color: var(--cn-primary);
}


/* ============================================================
   RTL / LTR â€” direction-aware base styles
   Most layout relies on flexbox + logical properties (inset-inline-*)
   so flipping `dir` on <html> is enough. These overrides handle the
   few places we used physical properties.
   ============================================================ */
html[dir="ltr"] body { direction: ltr; text-align: left; }
html[dir="rtl"] body { direction: rtl; text-align: right; }

/* Bootstrap RTL doesn't auto-load with non-RTL languages; for LTR we
   need to neutralize the .me-* / .ms-* swap.  We let Bootstrap default
   classes do the work and add `unicode-bidi: plaintext` for inputs so
   typing English in a Persian UI (or vice versa) renders cleanly. */
input, textarea { unicode-bidi: plaintext; }

/* Switcher / theme buttons need a fixed direction so the icon sits on
   the same side regardless of UI language. */
.theme-toggle-btn { direction: ltr; }


/* ============================================================
   PHASE 6 â€” PINK THEME
   Soft pastel pink, friendly & playful. Same primary saturation
   curve as default, just rotated hue. Backgrounds stay near-white
   so it's still readable in bright environments.
   ============================================================ */
[data-theme="pink"] {
    --cn-primary: #E84393;
    --cn-primary-deep: #C7307A;
    --cn-primary-soft: #FFE4F1;
    --cn-primary-ink: #6B1A45;
    --cn-bg: #FFF5FA;
    --cn-card: #FFFFFF;
    --cn-ink: #2A1828;
    --cn-ink-sub: #7A5A6E;
    --cn-ink-mute: #B89BAB;
    --cn-border: #FBD9E9;
    --cn-border-soft: #FDEEF5;
    --cn-online: #2DD879;
    --cn-bubble-me: #E84393;
    --cn-bubble-me-ink: #FFFFFF;
    --cn-bubble-them: #FFE4F1;
    --cn-bubble-them-ink: #2A1828;
    --cn-danger: #FF3366;
    --cn-shadow: 0 2px 12px rgba(232,67,147,0.10);
    --cn-shadow-lg: 0 8px 24px rgba(232,67,147,0.18);
}
[data-theme="pink"] body { background: var(--cn-bg); color: var(--cn-ink); }

/* ============================================================
   PHASE 6 â€” TELEGRAM THEME
   Telegram-style soft blue with cool greys. Lighter than dark
   mode, bluer than light mode. Approximates the Telegram desktop
   palette without copying any assets.
   ============================================================ */
[data-theme="telegram"] {
    --cn-primary: #2AABEE;
    --cn-primary-deep: #1E96D6;
    --cn-primary-soft: #E1F3FC;
    --cn-primary-ink: #0C5D85;
    --cn-bg: #F4F4F5;
    --cn-card: #FFFFFF;
    --cn-ink: #0F1620;
    --cn-ink-sub: #6B7785;
    --cn-ink-mute: #9AA4B1;
    --cn-border: #E4E7EB;
    --cn-border-soft: #F0F2F5;
    --cn-online: #4DCD5E;
    --cn-bubble-me: #EEFFDE;
    --cn-bubble-me-ink: #0F1620;
    --cn-bubble-them: #FFFFFF;
    --cn-bubble-them-ink: #0F1620;
    --cn-danger: #E53E3E;
    --cn-shadow: 0 2px 12px rgba(42,171,238,0.08);
    --cn-shadow-lg: 0 8px 24px rgba(42,171,238,0.14);
}
[data-theme="telegram"] body { background: var(--cn-bg); color: var(--cn-ink); }
[data-theme="telegram"] .form-control,
[data-theme="telegram"] .cn-input,
[data-theme="telegram"] textarea,
[data-theme="telegram"] select {
    background: var(--cn-card); color: var(--cn-ink);
    border-color: var(--cn-border);
}

/* Social color themes */
[data-theme="whatsapp"] {
    --cn-primary: #25D366;
    --cn-primary-deep: #128C7E;
    --cn-primary-soft: #E7F8EF;
    --cn-primary-ink: #075E54;
    --cn-bg: #F4F7F5;
    --cn-card: #FFFFFF;
    --cn-ink: #17251E;
    --cn-ink-sub: #5F7168;
    --cn-ink-mute: #94A39B;
    --cn-border: #DDE8E2;
    --cn-border-soft: #EEF5F1;
    --cn-bubble-me: #25D366;
    --cn-bubble-me-ink: #FFFFFF;
    --cn-bubble-them: #FFFFFF;
    --cn-bubble-them-ink: #17251E;
    --cn-danger: #E5486D;
    --cn-shadow: 0 2px 12px rgba(37,211,102,0.08);
    --cn-shadow-lg: 0 8px 24px rgba(37,211,102,0.16);
}
[data-theme="signal"] {
    --cn-primary: #3A76F0;
    --cn-primary-deep: #1F56D8;
    --cn-primary-soft: #EAF1FF;
    --cn-primary-ink: #133B8C;
    --cn-bg: #F7F9FD;
    --cn-card: #FFFFFF;
    --cn-ink: #152033;
    --cn-ink-sub: #66758F;
    --cn-ink-mute: #9AA8BC;
    --cn-border: #E1E8F3;
    --cn-border-soft: #F0F4FA;
    --cn-bubble-me: #3A76F0;
    --cn-bubble-me-ink: #FFFFFF;
    --cn-bubble-them: #FFFFFF;
    --cn-bubble-them-ink: #152033;
    --cn-danger: #E5486D;
}
[data-theme="instagram"] {
    --cn-primary: #D62976;
    --cn-primary-deep: #962FBF;
    --cn-primary-soft: #FCEAF3;
    --cn-primary-ink: #5C184E;
    --cn-bg: #FFF7FB;
    --cn-card: #FFFFFF;
    --cn-ink: #281726;
    --cn-ink-sub: #775B72;
    --cn-ink-mute: #B69CAE;
    --cn-border: #F2D9E7;
    --cn-border-soft: #FBEDF5;
    --cn-bubble-me: #D62976;
    --cn-bubble-me-ink: #FFFFFF;
    --cn-bubble-them: #FFFFFF;
    --cn-bubble-them-ink: #281726;
    --cn-danger: #E5486D;
}
[data-theme="discord"] {
    --cn-primary: #5865F2;
    --cn-primary-deep: #4752C4;
    --cn-primary-soft: #ECEEFF;
    --cn-primary-ink: #20256B;
    --cn-bg: #F7F7FC;
    --cn-card: #FFFFFF;
    --cn-ink: #1E2030;
    --cn-ink-sub: #656A86;
    --cn-ink-mute: #9BA0B8;
    --cn-border: #E4E6F2;
    --cn-border-soft: #F1F2F8;
    --cn-bubble-me: #5865F2;
    --cn-bubble-me-ink: #FFFFFF;
    --cn-bubble-them: #FFFFFF;
    --cn-bubble-them-ink: #1E2030;
    --cn-danger: #ED4245;
}
[data-theme="x"] {
    --cn-primary: #111111;
    --cn-primary-deep: #000000;
    --cn-primary-soft: #EDEFF2;
    --cn-primary-ink: #000000;
    --cn-bg: #F6F7F8;
    --cn-card: #FFFFFF;
    --cn-ink: #111111;
    --cn-ink-sub: #536471;
    --cn-ink-mute: #8B98A5;
    --cn-border: #DFE5EA;
    --cn-border-soft: #F0F3F5;
    --cn-bubble-me: #111111;
    --cn-bubble-me-ink: #FFFFFF;
    --cn-bubble-them: #FFFFFF;
    --cn-bubble-them-ink: #111111;
    --cn-danger: #F4212E;
}
[data-theme="youtube"] {
    --cn-primary: #FF0033;
    --cn-primary-deep: #CC0029;
    --cn-primary-soft: #FFE8ED;
    --cn-primary-ink: #730016;
    --cn-bg: #FAF7F7;
    --cn-card: #FFFFFF;
    --cn-ink: #241819;
    --cn-ink-sub: #746568;
    --cn-ink-mute: #A99EA1;
    --cn-border: #EDE0E2;
    --cn-border-soft: #F7EFF1;
    --cn-bubble-me: #FF0033;
    --cn-bubble-me-ink: #FFFFFF;
    --cn-bubble-them: #FFFFFF;
    --cn-bubble-them-ink: #241819;
    --cn-danger: #FF0033;
}
[data-theme="linkedin"] {
    --cn-primary: #0A66C2;
    --cn-primary-deep: #004182;
    --cn-primary-soft: #E8F2FC;
    --cn-primary-ink: #073A6D;
    --cn-bg: #F4F7FA;
    --cn-card: #FFFFFF;
    --cn-ink: #17212C;
    --cn-ink-sub: #667789;
    --cn-ink-mute: #A0ACB8;
    --cn-border: #DDE6EF;
    --cn-border-soft: #EEF3F7;
    --cn-bubble-me: #0A66C2;
    --cn-bubble-me-ink: #FFFFFF;
    --cn-bubble-them: #FFFFFF;
    --cn-bubble-them-ink: #17212C;
    --cn-danger: #CC1016;
}
[data-theme="snapchat"] {
    --cn-primary: #D9B800;
    --cn-primary-deep: #A88F00;
    --cn-primary-soft: #FFF8C8;
    --cn-primary-ink: #4D4100;
    --cn-bg: #FFFDF0;
    --cn-card: #FFFFFF;
    --cn-ink: #17150B;
    --cn-ink-sub: #6F6A48;
    --cn-ink-mute: #AAA27A;
    --cn-border: #EFE7B8;
    --cn-border-soft: #FAF5D8;
    --cn-bubble-me: #D9B800;
    --cn-bubble-me-ink: #17150B;
    --cn-bubble-them: #FFFFFF;
    --cn-bubble-them-ink: #17150B;
    --cn-danger: #E5486D;
}
[data-theme="reddit"] {
    --cn-primary: #FF4500;
    --cn-primary-deep: #CC3700;
    --cn-primary-soft: #FFEDE6;
    --cn-primary-ink: #7A2100;
    --cn-bg: #FFF8F5;
    --cn-card: #FFFFFF;
    --cn-ink: #251A16;
    --cn-ink-sub: #765F55;
    --cn-ink-mute: #AD9D96;
    --cn-border: #F0DED6;
    --cn-border-soft: #FAF0EC;
    --cn-bubble-me: #FF4500;
    --cn-bubble-me-ink: #FFFFFF;
    --cn-bubble-them: #FFFFFF;
    --cn-bubble-them-ink: #251A16;
    --cn-danger: #D93A00;
}
[data-theme="twitch"] {
    --cn-primary: #9146FF;
    --cn-primary-deep: #772CE8;
    --cn-primary-soft: #F0E8FF;
    --cn-primary-ink: #3B146E;
    --cn-bg: #FAF7FF;
    --cn-card: #FFFFFF;
    --cn-ink: #20182D;
    --cn-ink-sub: #6E5D86;
    --cn-ink-mute: #A99DBB;
    --cn-border: #E6DCF5;
    --cn-border-soft: #F4EEFC;
    --cn-bubble-me: #9146FF;
    --cn-bubble-me-ink: #FFFFFF;
    --cn-bubble-them: #FFFFFF;
    --cn-bubble-them-ink: #20182D;
    --cn-danger: #EB496F;
}

/* ============================================================
   PHASE 7 â€” XP BADGE
   Tier colours echo the typical bronze / silver / gold / diamond
   gradient. Sizes: -sm (inline next to a username), -lg (profile).
   ============================================================ */
.xp-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-weight: 700;
    border-radius: 999px;
    border: 1px solid transparent;
    white-space: nowrap;
    line-height: 1;
}
.xp-badge i { font-size: 0.85em; }
.xp-badge-sm {
    font-size: 10px;
    padding: 3px 7px;
}
.xp-badge-lg {
    font-size: 13px;
    padding: 6px 12px;
}
.xp-bronze {
    background: linear-gradient(135deg, #FCE4C2 0%, #E8AE6A 100%);
    color: #5B3A14;
    border-color: #D49156;
}
.xp-silver {
    background: linear-gradient(135deg, #F0F1F4 0%, #B8BEC7 100%);
    color: #3A4250;
    border-color: #98A0AC;
}
.xp-gold {
    background: linear-gradient(135deg, #FFF1B0 0%, #E6B91A 100%);
    color: #5B4407;
    border-color: #C99E0A;
}
.xp-diamond {
    background: linear-gradient(135deg, #C8F0FF 0%, #6CB9FF 50%, #B998FF 100%);
    color: #14315B;
    border-color: #6CB9FF;
}

/* XP progress ring/bar used on profile + leaderboard */
.xp-progress {
    height: 6px;
    border-radius: 999px;
    background: var(--cn-border-soft);
    overflow: hidden;
}
.xp-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--cn-primary), var(--cn-primary-deep));
    transition: width 0.4s ease;
}

/* Leaderboard rows */
.leaderboard-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--cn-border);
    transition: background 0.15s;
}
.leaderboard-row:last-child { border-bottom: 0; }
.leaderboard-row:hover { background: var(--cn-border-soft); }
.leaderboard-rank {
    width: 32px;
    text-align: center;
    font-weight: 800;
    font-size: 15px;
    color: var(--cn-ink-sub);
}
.leaderboard-rank-1 { color: #E6B91A; font-size: 18px; }
.leaderboard-rank-2 { color: #98A0AC; font-size: 17px; }
.leaderboard-rank-3 { color: #D49156; font-size: 16px; }
.leaderboard-info {
    flex: 1;
    min-width: 0;
}
.leaderboard-info-name {
    font-weight: 700;
    color: var(--cn-ink);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
.leaderboard-info-name:hover { color: var(--cn-primary); }
.leaderboard-info-meta {
    font-size: 12px;
    color: var(--cn-ink-mute);
    margin-top: 2px;
}
.leaderboard-xp {
    font-weight: 800;
    color: var(--cn-primary);
    font-size: 14px;
}

/* Phase 6 â€” theme picker dropdown items */
.theme-picker-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    cursor: pointer;
    color: var(--cn-ink) !important;
    text-decoration: none;
}
.theme-picker-item:hover { background: var(--cn-primary-soft); color: var(--cn-primary) !important; }
.theme-picker-item.active { background: var(--cn-primary-soft); color: var(--cn-primary) !important; font-weight: 700; }
.theme-picker-check {
    display: none !important;
}
.theme-picker-item span:not(.theme-picker-swatch) {
    color: inherit !important;
}
.theme-picker-swatch {
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 1px solid var(--cn-border);
    flex-shrink: 0;
}
.theme-picker-swatch-light    { background: #FFFFFF; }
.theme-picker-swatch-dark     { background: #0E0B1F; }
.theme-picker-swatch-pink     { background: #E84393; }
.theme-picker-swatch-telegram { background: #2AABEE; }
.theme-picker-swatch-whatsapp { background: #25D366; }
.theme-picker-swatch-signal   { background: #3A76F0; }
.theme-picker-swatch-instagram { background: linear-gradient(135deg, #FEDA75, #D62976 52%, #4F5BD5); }
.theme-picker-swatch-discord  { background: #5865F2; }
.theme-picker-swatch-x        { background: #111111; }
.theme-picker-swatch-youtube  { background: #FF0033; }
.theme-picker-swatch-linkedin { background: #0A66C2; }
.theme-picker-swatch-snapchat { background: #FFFC00; }
.theme-picker-swatch-reddit   { background: #FF4500; }
.theme-picker-swatch-twitch   { background: #9146FF; }

#theme-picker-btn + .dropdown-menu {
    max-height: min(70vh, 430px);
    overflow-y: auto;
}

/* Phase 5 â€” privacy / visibility group inside edit_profile */
.priv-row {
    display: grid;
    grid-template-columns: 1fr 140px;
    gap: 10px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dashed var(--cn-border);
}
.priv-row:last-child { border-bottom: 0; }
.priv-row-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--cn-ink);
}
.priv-row-hint {
    font-size: 11px;
    color: var(--cn-ink-mute);
    margin-top: 2px;
}
.visibility-select {
    font-size: 12px !important;
    padding: 4px 8px !important;
    height: auto !important;
}
@media (max-width: 480px) {
    .priv-row { grid-template-columns: 1fr; }
}

/* ============================================================
   UI refresh layer
   Cohesive app polish for the main shell, social feed, chat, and forms.
   ============================================================ */
:root[data-theme="light"] {
    --cn-primary: #355CFE;
    --cn-primary-deep: #2146DB;
    --cn-primary-soft: #EAF0FF;
    --cn-primary-ink: #132765;
    --cn-accent: #00A389;
    --cn-accent-soft: #E4F8F4;
    --cn-warning: #F59E0B;
    --cn-bg: #F6F7FB;
    --cn-card: #FFFFFF;
    --cn-ink: #172033;
    --cn-ink-sub: #657084;
    --cn-ink-mute: #9AA3B5;
    --cn-border: #E3E7EF;
    --cn-border-soft: #F0F3F8;
    --cn-online: #14B87A;
    --cn-bubble-me: #355CFE;
    --cn-bubble-me-ink: #FFFFFF;
    --cn-bubble-them: #FFFFFF;
    --cn-bubble-them-ink: #172033;
    --cn-danger: #E5486D;
    --cn-radius: 8px;
    --cn-radius-sm: 8px;
    --cn-radius-xs: 6px;
    --cn-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
    --cn-shadow-lg: 0 16px 36px rgba(15, 23, 42, 0.14);
}

body {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.72), rgba(246,247,251,0) 220px),
        var(--cn-bg);
}

main.container {
    max-width: 1180px;
}

.cn-navbar {
    background: rgba(255,255,255,0.88);
    backdrop-filter: blur(16px);
    box-shadow: 0 1px 0 rgba(15,23,42,0.04);
}
.cn-navbar .container {
    max-width: 1200px;
}
.cn-navbar .navbar-brand {
    letter-spacing: 0;
}
.cn-navbar .navbar-brand .brand-icon {
    border-radius: 8px;
    background: var(--cn-primary);
    box-shadow: none;
}
.cn-navbar .nav-link {
    border-radius: 8px;
    min-height: 38px;
}
.cn-navbar .nav-link i {
    font-size: 16px;
}
.cn-navbar .nav-link.active {
    box-shadow: inset 0 0 0 1px rgba(53,92,254,0.08);
}
.cn-navbar .dropdown-menu,
.dropdown-menu {
    z-index: 99999999999999999999999;
    border-radius: 8px !important;
    border-color: var(--cn-border);
    box-shadow: var(--cn-shadow-lg);
}

/* Readable dropdown text/icons in every theme (light/dark/pink/telegram).
   Previously the light themes fell back to Bootstrap defaults → low contrast. */
.dropdown-menu {
    background: var(--cn-card);
    color: var(--cn-ink);
}
.dropdown-item {
    color: var(--cn-ink);
}
.dropdown-item i {
    color: var(--cn-primary);
}
.dropdown-item:hover,
.dropdown-item:focus,
.dropdown-item:active {
    background: var(--cn-primary-soft);
    color: var(--cn-primary);
}
.dropdown-menu .dropdown-divider {
    border-top-color: var(--cn-border);
}

/* Chat composer attach menu must sit clearly ABOVE messages/polls. */
.chat-composer-row .dropdown-menu,
.chat-composer-row .dropdown-menu.show {
    z-index: 3000;
    background: var(--cn-card);
    box-shadow: 0 -4px 24px rgba(0,0,0,.18);
}
.theme-toggle-btn,
.btn-cn-icon,
.chat-input-action,
.chat-send-btn {
    border-radius: 8px !important;
}

.cn-card,
.post-card,
.auth-card,
.modal-content {
    border-radius: 8px !important;
}
.cn-card {
    box-shadow: var(--cn-shadow);
}

.btn-cn,
.btn-cn-outline,
.btn-cn-soft,
.btn-primary-cn {
    border-radius: 8px !important;
    box-shadow: none;
}
.btn-cn:hover,
.btn-primary-cn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(53,92,254,0.18);
}
.btn-cn-outline {
    background: var(--cn-card);
}
.btn-cn-outline:hover {
    background: var(--cn-primary-soft);
}

.cn-input,
.form-control,
.form-select,
.chat-input {
    border-radius: 8px !important;
    border: 1px solid var(--cn-border);
    background: var(--cn-card);
}
.cn-input:focus,
.form-control:focus,
.form-select:focus,
.chat-input:focus {
    box-shadow: 0 0 0 4px rgba(53,92,254,0.10);
}

.social-three-col {
    align-items: flex-start;
}
.social-left-aside,
.social-right-aside {
    position: sticky;
    top: 74px;
}
.social-left-aside .cn-card,
.social-right-aside .cn-card {
    overflow: hidden;
}
.social-left-aside a,
.social-right-aside a {
    border-radius: 8px;
}
.social-left-aside a:hover,
.social-right-aside a:hover {
    background: var(--cn-primary-soft);
}
.social-center-col > div:first-child {
    border: 1px solid var(--cn-border);
    border-radius: 8px;
    margin-bottom: 12px;
    box-shadow: var(--cn-shadow);
}

.post-card {
    border: 1px solid var(--cn-border);
    margin-bottom: 12px;
    box-shadow: var(--cn-shadow);
    padding: 16px;
}
.post-header {
    margin-bottom: 14px;
}
.post-text {
    font-size: 14px;
    line-height: 1.85;
}
.post-image {
    border-radius: 8px;
    border: 1px solid var(--cn-border-soft);
}
.post-actions {
    gap: 10px;
}
.post-action-btn {
    min-height: 36px;
    padding: 0 12px;
    border-radius: 8px;
    color: var(--cn-ink-sub);
}
.post-action-btn:hover {
    background: var(--cn-border-soft);
    color: var(--cn-primary);
}
.post-action-btn .liked {
    color: var(--cn-danger);
}

.chat-shell {
    display: grid;
    grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
    height: calc(100vh - 58px);
    background: var(--cn-bg);
}
.chat-sidebar {
    background: var(--cn-card);
    border-inline-end: 1px solid var(--cn-border);
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.chat-sidebar-header {
    padding: 14px;
    border-bottom: 1px solid var(--cn-border);
}
.chat-sidebar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--cn-border-soft);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0 10px;
    min-height: 40px;
}
.chat-sidebar-search:focus-within {
    border-color: rgba(53,92,254,0.32);
    background: var(--cn-card);
}
.chat-search-input {
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--cn-ink);
    min-width: 0;
}
.chat-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin-top: 10px;
}
.chat-tab {
    border: 1px solid var(--cn-border);
    border-radius: 8px;
    background: var(--cn-card);
    color: var(--cn-ink-sub);
    font-size: 12px;
    font-weight: 700;
    min-height: 34px;
}
.chat-tab.active {
    background: var(--cn-primary);
    border-color: var(--cn-primary);
    color: #fff;
}
.chat-sidebar-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 6px;
}
.chat-list-item {
    border: 0;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 4px;
}
.chat-list-item:hover,
.chat-list-item.active {
    background: var(--cn-primary-soft);
}
.chat-list-item.is-pinned-chat {
    background: linear-gradient(90deg, var(--cn-primary-soft), transparent 70%);
}
.ci-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}
.ci-avatar-fallback {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}
.group-grad { background: var(--cn-accent); }
.ch-grad { background: var(--cn-primary); }
.ci-body {
    flex: 1;
    min-width: 0;
}
.ci-head {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.ci-name,
.chat-preview {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ci-name {
    font-size: 14px;
    font-weight: 800;
    color: var(--cn-ink);
}
.ci-preview {
    font-size: 12px;
    color: var(--cn-ink-mute);
    margin-top: 3px;
}
.ci-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    min-width: 44px;
}
.chat-time {
    font-size: 11px;
}
.chat-unread-badge {
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    background: var(--cn-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
}
.chat-pill {
    border-radius: 999px;
    padding: 2px 7px;
    font-size: 10px;
    font-weight: 800;
}
.pill-group {
    background: var(--cn-accent-soft);
    color: var(--cn-accent);
}
.pill-channel {
    background: var(--cn-primary-soft);
    color: var(--cn-primary);
}
.chat-row-menu-btn {
    position: absolute;
    top: 12px;
    inset-inline-end: 8px;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--cn-ink-mute);
    opacity: 0;
}
.chat-list-item-wrap:hover .chat-row-menu-btn {
    opacity: 1;
}

.chat-main {
    min-width: 0;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.74), rgba(246,247,251,0) 180px),
        var(--cn-bg);
}
.chat-empty-pane {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--cn-ink-sub);
    padding: 32px;
}
.chat-empty-bubble {
    width: 76px;
    height: 76px;
    border-radius: 8px;
    background: var(--cn-primary-soft);
    color: var(--cn-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    margin-bottom: 16px;
}
.chat-container {
    max-width: none;
    height: calc(100vh - 58px);
    border: 0;
    background: transparent;
}
.chat-container-embedded {
    margin: 0;
}
.chat-header,
.chat-input-area {
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(14px);
}
.chat-header {
    min-height: 64px;
    padding: 10px 16px;
}
.chat-messages {
    padding: 18px 0;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.65), rgba(246,247,251,0) 180px),
        var(--cn-bg);
}
.msg-row {
    padding-inline: 18px;
}
.msg-bubble {
    border-radius: 8px;
    max-width: min(680px, 76%);
    box-shadow: 0 1px 2px rgba(15,23,42,0.08);
}
.msg-bubble.sent {
    border-bottom-right-radius: 8px;
    box-shadow: 0 8px 18px rgba(53,92,254,0.18);
}
.msg-bubble.received {
    border: 1px solid var(--cn-border);
    border-bottom-left-radius: 8px;
}
.msg-meta {
    font-variant-numeric: tabular-nums;
}
.chat-input-area {
    padding: 12px 16px;
}
.chat-input {
    min-height: 42px;
    max-height: 132px;
}

.profile-stats {
    background: var(--cn-border-soft);
}
.profile-stat {
    background: var(--cn-card);
}
.profile-stat:hover {
    background: var(--cn-primary-soft);
}
.post-grid {
    gap: 8px;
}
.post-grid-item {
    border-radius: 8px;
    box-shadow: var(--cn-shadow);
}

[data-theme="dark"] .cn-navbar,
[data-theme="dark"] .chat-header,
[data-theme="dark"] .chat-input-area {
    background: rgba(18,18,28,0.88);
}
[data-theme="dark"] .chat-main,
[data-theme="dark"] .chat-messages {
    background: var(--cn-bg);
}

@media (max-width: 991.98px) {
    main.container {
        max-width: 100%;
    }
    .social-center-col > div:first-child,
    .post-card {
        border-inline: 0;
        border-radius: 0 !important;
    }
    .chat-shell {
        grid-template-columns: 1fr;
    }
    .chat-active .chat-sidebar {
        display: none;
    }
    .chat-shell.chat-active .chat-sidebar {
        display: none;
    }
    .chat-shell.chat-active .chat-main {
        display: block;
        flex: initial;
        min-width: 0;
    }
    .chat-sidebar {
        height: calc(100vh - 58px);
    }
    .chat-row-menu-btn {
        opacity: 1;
    }
    .msg-bubble {
        max-width: 84%;
    }
}

@media (max-width: 575.98px) {
    .cn-navbar {
        padding: 6px 0;
    }
    .cn-navbar .nav-link {
        min-height: 36px;
    }
    .post-card {
        padding: 14px;
    }
    .chat-tabs {
        display: flex;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .chat-tab {
        min-width: 82px;
        padding-inline: 10px;
    }
    .chat-header {
        padding-inline: 10px;
    }
    .msg-row {
        padding-inline: 10px;
    }
    .msg-bubble {
        max-width: 88%;
    }
    .chat-input-area {
        padding: 10px;
    }
}

/* Social refresh */
.social-panel-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--cn-ink);
}
.social-panel-action {
    font-size: 11px;
    font-weight: 800;
    color: var(--cn-primary);
    text-decoration: none;
}
.social-panel-action:hover {
    text-decoration: underline;
}
.social-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 8px 10px;
    color: inherit;
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    border-radius: 8px;
}
.social-nav-link i {
    width: 22px;
    text-align: center;
    color: var(--cn-primary);
}
.social-mini-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--cn-border);
}
.social-mini-user:last-child {
    border-bottom: 0;
}
.social-mini-user-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--cn-ink);
    text-decoration: none;
    font-size: 12px;
    font-weight: 800;
}
.social-mini-user-meta,
.social-muted-empty {
    color: var(--cn-ink-mute);
    font-size: 11px;
}
.social-muted-empty {
    margin: 8px 0 0;
}
.social-composer-card {
    background: var(--cn-card);
    border: 1px solid var(--cn-border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--cn-shadow);
}
.social-composer-input {
    min-height: 70px;
    resize: vertical;
}
.social-post-card {
    overflow: hidden;
}
.social-post-header {
    align-items: flex-start;
}
.social-post-avatar-link {
    position: relative;
    flex-shrink: 0;
}
.social-post-author {
    flex: 1;
    min-width: 0;
}
.social-post-author-name,
.social-result-link {
    color: var(--cn-ink);
    text-decoration: none;
}
.social-post-author-name {
    font-size: 14px;
    font-weight: 800;
}
.social-post-author-name:hover,
.social-result-link:hover {
    color: var(--cn-primary);
}
.social-post-time,
.social-comment-time {
    color: var(--cn-ink-mute);
    font-size: 11px;
}
.social-post-menu-btn {
    background: transparent;
    border: 0;
    color: var(--cn-ink-mute);
    width: 32px;
    height: 32px;
    border-radius: 8px;
}
.social-post-menu-btn:hover {
    background: var(--cn-border-soft);
    color: var(--cn-primary);
}
.social-post-text {
    white-space: pre-wrap;
}
.social-post-image {
    display: block;
    width: 100%;
    padding: 0;
    border: 1px solid var(--cn-border-soft);
    background: transparent;
    overflow: hidden;
    cursor: zoom-in;
}
.social-post-image img {
    width: 100%;
    display: block;
}
.social-post-actions {
    border-top: 1px solid var(--cn-border-soft);
    margin-top: 12px;
}
.post-action-label {
    font-size: 12px;
}
.social-comments-panel {
    padding-top: 12px;
}
.social-comments-list {
    display: grid;
    gap: 8px;
}
.social-comment-item {
    display: flex;
    gap: 8px;
    padding: 0 4px;
}
.social-comment-body {
    flex: 1;
    min-width: 0;
    background: var(--cn-border-soft);
    border-radius: 8px;
    padding: 8px 10px;
}
.social-comment-author {
    font-size: 13px;
    font-weight: 800;
    color: var(--cn-ink);
    text-decoration: none;
}
.social-comment-text {
    font-size: 13px;
    color: var(--cn-ink);
}
/* Comment actions: like + reply + time */
.social-comment-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 5px;
}
.sc-like-btn, .sc-reply-btn {
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--cn-ink-mute);
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color .15s, transform .1s;
}
.sc-like-btn:hover, .sc-reply-btn:hover { color: var(--cn-primary); }
.sc-like-btn:active, .sc-reply-btn:active { transform: scale(.9); }
.sc-like-btn.liked { color: var(--cn-danger); }
.sc-like-btn.liked i { color: var(--cn-danger); }
.sc-like-count { font-variant-numeric: tabular-nums; font-weight: 700; }
.social-comment-actions .social-comment-time { margin: 0; }

/* Nested replies indent */
.social-comment-replies {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    padding-inline-start: 36px;
}
.social-comment-replies:empty { display: none; margin: 0; }
.social-comment-item.is-reply .social-comment-body { background: var(--cn-bg); }

/* "Replying to @x" indicator above the composer */
.reply-indicator {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    color: var(--cn-ink-mute);
    background: var(--cn-primary-soft);
    border-radius: 8px;
    padding: 5px 10px;
    margin: 8px 4px 0;
}
.reply-indicator b { color: var(--cn-primary); }
.reply-cancel {
    background: transparent; border: none; cursor: pointer;
    color: var(--cn-ink-mute); font-size: 18px; line-height: 1; padding: 0 4px;
}
.reply-cancel:hover { color: var(--cn-danger); }

.social-comment-composer {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding: 0 4px;
}
.social-comment-composer .cn-input {
    font-size: 13px;
    padding: 8px 12px;
}
.social-search-card,
.social-suggestions-card {
    overflow: hidden;
}
.social-search-header,
.social-list-header {
    padding: 18px;
    border-bottom: 1px solid var(--cn-border);
}
.social-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.social-list-header p {
    margin: 4px 0 0;
    color: var(--cn-ink-mute);
    font-size: 12px;
}
.social-list-header > i {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: var(--cn-primary);
    background: var(--cn-primary-soft);
    font-size: 22px;
}
.social-page-title {
    font-size: 24px;
    font-weight: 900;
    color: var(--cn-ink);
    margin: 0 0 14px;
    letter-spacing: 0;
}
.social-search-box {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    background: var(--cn-border-soft);
    border: 1px solid transparent;
    border-radius: 8px;
}
.social-search-box:focus-within {
    background: var(--cn-card);
    border-color: rgba(53,92,254,.32);
    box-shadow: 0 0 0 4px rgba(53,92,254,.08);
}
.social-search-box i {
    color: var(--cn-ink-mute);
}
.social-search-box input {
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--cn-ink);
    min-width: 0;
}
.social-tabs {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    overflow-x: auto;
    scrollbar-width: none;
}
.social-tab-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--cn-border);
    color: var(--cn-ink-sub);
    text-decoration: none;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}
.social-tab-link.active,
.social-tab-link:hover {
    background: var(--cn-primary);
    border-color: var(--cn-primary);
    color: #fff;
}
.social-section-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px 6px;
    background: var(--cn-bg);
    color: var(--cn-ink-mute);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0;
}
.social-result-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--cn-border-soft);
}
.social-result-row:last-child {
    border-bottom: 0;
}
.social-result-row:hover {
    background: var(--cn-border-soft);
}
.social-result-avatar {
    position: relative;
    flex-shrink: 0;
}
.social-result-fallback {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    background: var(--cn-primary);
    color: #fff;
}
.social-result-body {
    flex: 1;
    min-width: 0;
}
.social-result-title {
    display: block;
    font-size: 14px;
    font-weight: 900;
    color: var(--cn-ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.social-result-meta {
    color: var(--cn-ink-mute);
    font-size: 11px;
    margin-top: 2px;
}
.social-result-meta span,
.social-result-meta.is-online {
    color: var(--cn-online);
    font-weight: 800;
}
.social-result-desc {
    color: var(--cn-ink-sub);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
}
.social-result-action {
    padding: 7px 14px !important;
    font-size: 12px !important;
}
.social-result-actions {
    display: flex;
    gap: 8px;
}
.social-secondary-icon {
    background: transparent !important;
    border: 1px solid var(--cn-border) !important;
}
.social-secondary-icon i {
    color: var(--cn-ink-sub);
}
.follow-btn.is-done {
    opacity: .75;
}
.social-empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--cn-ink-mute);
}
.social-empty-state i {
    font-size: 44px;
    display: block;
    margin-bottom: 12px;
    opacity: .72;
}
.social-empty-state p {
    margin: 0 auto;
    max-width: 320px;
    line-height: 1.7;
}
.social-request-row {
    transition: background .18s ease, opacity .18s ease, transform .18s ease;
}
.social-request-row.is-accepted {
    background: color-mix(in srgb, var(--cn-online) 10%, transparent);
}
.social-danger-btn {
    width: 38px;
    height: 38px;
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-color: color-mix(in srgb, var(--cn-danger) 55%, transparent) !important;
    color: var(--cn-danger) !important;
    border-radius: var(--cn-radius-sm);
}
.social-danger-btn:hover {
    background: color-mix(in srgb, var(--cn-danger) 9%, transparent) !important;
    color: var(--cn-danger) !important;
}
.social-accepted-label {
    color: var(--cn-online);
    font-size: 13px;
    font-weight: 750;
    white-space: nowrap;
}
.social-hashtag-row {
    color: inherit;
    text-decoration: none;
}
.social-rank {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--cn-primary-soft);
    color: var(--cn-primary);
    font-weight: 850;
    font-size: 14px;
    flex: 0 0 auto;
}
.social-ltr {
    direction: ltr;
    text-align: right;
}
.social-row-chevron {
    color: var(--cn-ink-mute);
    font-size: 14px;
    flex: 0 0 auto;
}
.social-hash-hero,
.social-hash-empty {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--cn-primary), var(--cn-teal));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    flex: 0 0 auto;
}
.social-hash-empty {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    margin: 0 auto 16px;
    font-size: 34px;
}
.social-empty-copy {
    color: var(--cn-ink-mute);
    font-size: 14px;
    line-height: 1.75;
    margin: 12px auto 20px;
    max-width: 420px;
}

@media (max-width: 575.98px) {
    .social-composer-card {
        border-inline: 0;
        border-radius: 0;
    }
    .social-result-row {
        padding: 12px 14px;
    }
    .social-result-actions {
        width: 100%;
        justify-content: flex-start;
    }
    .social-request-row .social-result-actions {
        width: auto;
        justify-content: flex-end;
    }
    .post-action-label {
        display: none;
    }
}

/* ============================================================
   UI refresh v2 â€” calmer, denser, more polished app experience
   ============================================================ */
:root {
    --cn-teal: #00A389;
    --cn-orange: #F97316;
    --cn-accent: #00A389;
    --cn-accent-soft: #E4F8F4;
    --cn-warning: #F59E0B;
    --cn-surface-1: rgba(255,255,255,0.78);
    --cn-surface-2: rgba(255,255,255,0.94);
    --cn-ring: 0 0 0 4px color-mix(in srgb, var(--cn-primary) 14%, transparent);
}

html {
    min-height: 100%;
    background: var(--cn-bg);
}

body {
    min-height: 100vh;
    text-rendering: optimizeLegibility;
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--cn-primary-soft) 34%, #fff) 0, transparent 260px),
        linear-gradient(90deg, color-mix(in srgb, var(--cn-accent-soft, #e4f8f4) 42%, transparent), transparent 36%, color-mix(in srgb, #fff 72%, transparent)),
        var(--cn-bg);
}

::selection {
    background: color-mix(in srgb, var(--cn-primary) 22%, transparent);
}

:focus-visible {
    outline: none;
    box-shadow: var(--cn-ring) !important;
}

main.container {
    padding-top: 22px !important;
}

.cn-navbar {
    border-bottom: 1px solid color-mix(in srgb, var(--cn-border) 78%, transparent);
    padding: 9px 0;
}

.cn-navbar .navbar-brand {
    padding: 4px 8px;
    border-radius: 10px;
}

.cn-navbar .navbar-brand:hover {
    background: var(--cn-border-soft);
}

.cn-navbar .navbar-brand .brand-icon {
    width: 36px;
    height: 36px;
    color: #fff;
}

.cn-navbar .navbar-nav {
    gap: 3px;
}

.cn-navbar .nav-link {
    color: var(--cn-ink-sub);
    padding: 8px 11px;
    border: 1px solid transparent;
}

.cn-navbar .nav-link:hover {
    border-color: var(--cn-border);
    background: var(--cn-card);
    color: var(--cn-ink);
}

.cn-navbar .nav-link.active {
    background: var(--cn-primary);
    color: #fff;
    border-color: var(--cn-primary);
}

.cn-navbar .nav-link.active .cn-badge {
    background: #fff;
    color: var(--cn-primary);
    border-color: var(--cn-primary);
}

.cn-badge {
    box-shadow: 0 4px 10px color-mix(in srgb, var(--cn-danger) 24%, transparent);
}

.dropdown-menu {
    padding: 8px !important;
}

.dropdown-item,
.theme-picker-item {
    border-radius: 7px;
    min-height: 36px;
}

.cn-card,
.social-composer-card,
.post-card,
.social-search-card,
.social-suggestions-card {
    background: var(--cn-surface-2);
    backdrop-filter: blur(14px);
    border-color: color-mix(in srgb, var(--cn-border) 86%, transparent);
}

.cn-card:hover,
.post-card:hover,
.social-composer-card:hover {
    border-color: color-mix(in srgb, var(--cn-primary) 22%, var(--cn-border));
}

.btn-cn,
.btn-cn-outline,
.btn-cn-soft,
.btn-cn-icon,
.theme-toggle-btn,
.chat-send-btn,
.chat-input-action {
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease, color .15s ease;
}

.btn-cn {
    background: linear-gradient(135deg, var(--cn-primary), var(--cn-primary-deep));
}

.btn-cn:active,
.btn-cn-outline:active,
.btn-cn-soft:active,
.btn-cn-icon:active,
.theme-toggle-btn:active {
    transform: translateY(1px) scale(.98);
}

.btn-cn-icon,
.theme-toggle-btn,
.chat-input-action {
    border: 1px solid var(--cn-border);
    background: var(--cn-card);
}

.btn-cn-icon:hover,
.theme-toggle-btn:hover,
.chat-input-action:hover {
    border-color: color-mix(in srgb, var(--cn-primary) 28%, var(--cn-border));
    background: var(--cn-primary-soft);
}

.cn-avatar {
    background: var(--cn-card);
    box-shadow: 0 0 0 3px var(--cn-card);
}

.online-dot.online {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cn-online) 18%, transparent);
}

.social-three-col {
    --bs-gutter-x: 18px;
    max-width: 1180px;
    margin-inline: auto;
}

.social-left-aside .cn-card,
.social-right-aside .cn-card {
    max-width: none;
    padding: 14px !important;
}

.social-panel-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.social-nav-link {
    position: relative;
}

.social-nav-link i {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    flex: 0 0 30px;
    aspect-ratio: 1 / 1;
    border-radius: 7px;
    display: inline-grid;
    place-items: center;
    background: var(--cn-primary-soft);
}

.social-nav-link:hover {
    transform: none;
}

html[dir="ltr"] .social-nav-link:hover {
    transform: none;
}

.social-mini-user {
    border-bottom-style: dashed;
}

.stories-strip {
    gap: 12px;
}

.story-mini-add,
.story-mini-avatar {
    box-shadow: 0 8px 18px color-mix(in srgb, var(--cn-primary) 14%, transparent);
}

.story-mini-add {
    background: color-mix(in srgb, var(--cn-primary-soft) 74%, var(--cn-card));
}

.social-composer-card {
    position: relative;
    overflow: hidden;
}

.social-composer-card::before {
    content: "";
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--cn-primary), var(--cn-accent, var(--cn-teal)));
}

.social-composer-input {
    min-height: 82px;
    background: var(--cn-border-soft);
}

.social-composer-input:focus {
    background: var(--cn-card);
}

.post-card {
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(15,23,42,.09);
}

.social-post-author-name {
    letter-spacing: 0;
}

.social-post-time,
.social-comment-time,
.social-mini-user-meta,
.social-result-meta {
    font-variant-numeric: tabular-nums;
}

.social-post-image {
    border-radius: 10px;
}

.social-post-image img {
    transition: transform .28s ease;
}

.social-post-image:hover img {
    transform: scale(1.018);
}

.post-actions {
    justify-content: space-between;
}

.post-action-btn {
    flex: 1;
    justify-content: center;
}

.social-comment-body {
    background: color-mix(in srgb, var(--cn-border-soft) 78%, var(--cn-card));
}

.social-search-card {
    max-width: 760px;
}

.social-search-header,
.social-list-header {
    background: linear-gradient(180deg, var(--cn-card), color-mix(in srgb, var(--cn-border-soft) 68%, var(--cn-card)));
}

.social-page-title {
    font-size: clamp(22px, 3vw, 30px);
}

.social-result-row {
    transition: background .16s ease, transform .16s ease;
}

.social-result-row:hover {
    transform: translateX(-2px);
}

html[dir="ltr"] .social-result-row:hover {
    transform: translateX(2px);
}

.chat-shell {
    border-top: 1px solid var(--cn-border);
}

.chat-sidebar {
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--cn-card) 90%, var(--cn-primary-soft)), var(--cn-card) 190px),
        var(--cn-card);
}

.chat-sidebar-header {
    padding: 16px;
}

.chat-sidebar-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.chat-sidebar-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.chat-sidebar-heading-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--cn-primary);
    color: #fff;
    box-shadow: 0 10px 20px color-mix(in srgb, var(--cn-primary) 22%, transparent);
    flex: 0 0 auto;
}

.chat-sidebar-title {
    font-size: 18px;
    line-height: 1.2;
    font-weight: 900;
    color: var(--cn-ink);
}

.chat-sidebar-subtitle {
    margin-top: 2px;
    font-size: 11px;
    color: var(--cn-ink-mute);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-sidebar-search {
    min-height: 44px;
    border-radius: 10px;
}

.chat-sidebar-search > i {
    inset-inline-start: 14px;
}

.chat-sidebar-search > .chat-search-input {
    font-size: 13px;
    height: 100%;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding-block: 0;
    padding-inline-start: 34px;
    padding-inline-end: 4px;
    box-shadow: none !important;
}

.chat-tabs {
    background: color-mix(in srgb, var(--cn-border-soft) 74%, var(--cn-card));
    padding: 5px;
    border-radius: 10px;
}

button.chat-tab,
.chat-tab {
    min-height: 36px;
    border: 0 !important;
}

button.chat-tab.active,
.chat-tab.active {
    background: var(--cn-card) !important;
    color: var(--cn-primary) !important;
    box-shadow: 0 6px 14px rgba(15,23,42,.08) !important;
}

.chat-sidebar-list {
    padding: 8px;
}

.chat-list-item-wrap {
    border-radius: 10px;
}

.chat-list-item {
    min-height: 70px;
    border-radius: 10px;
    padding: 11px;
}

.chat-list-item:hover,
.chat-list-item.active {
    background: color-mix(in srgb, var(--cn-primary-soft) 82%, var(--cn-card));
}

.chat-list-item.active {
    box-shadow: inset 3px 0 0 var(--cn-primary);
}

html[dir="rtl"] .chat-list-item.active {
    box-shadow: inset -3px 0 0 var(--cn-primary);
}

.ci-name {
    font-size: 14.5px;
}

.ci-preview {
    line-height: 1.5;
}

.chat-row-menu-btn {
    background: var(--cn-card);
    box-shadow: 0 4px 10px rgba(15,23,42,.08);
}

.chat-main {
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--cn-card) 70%, transparent), transparent 210px),
        repeating-linear-gradient(135deg, color-mix(in srgb, var(--cn-border) 18%, transparent) 0 1px, transparent 1px 18px),
        var(--cn-bg);
}

.chat-header {
    border-bottom-color: color-mix(in srgb, var(--cn-border) 80%, transparent);
}

.chat-empty-pane h3 {
    font-size: 21px;
    font-weight: 900;
}

.chat-empty-pane p {
    max-width: 430px;
}

.chat-empty-bubble {
    width: 86px;
    height: 86px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--cn-primary), var(--cn-accent, var(--cn-teal)));
    color: #fff;
    box-shadow: 0 18px 36px color-mix(in srgb, var(--cn-primary) 22%, transparent);
}

.chat-empty-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.chat-messages {
    background: transparent;
}

.msg-bubble {
    padding: 10px 14px;
}

.msg-bubble.received {
    background: var(--cn-card);
}

.msg-bubble.sent {
    background: linear-gradient(135deg, var(--cn-primary), var(--cn-primary-deep));
}

.chat-input-area {
    border-top-color: color-mix(in srgb, var(--cn-border) 80%, transparent);
}

.chat-input {
    background: var(--cn-card);
}

.profile-stats {
    gap: 1px;
    background: var(--cn-border);
}

.profile-stat {
    border: 0;
}

.post-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.post-grid-item {
    background: var(--cn-card);
}

.profile-social-link {
    border: 1px solid var(--cn-border);
    background: var(--cn-card);
}

[data-theme="dark"] {
    --cn-surface-1: rgba(26,21,48,0.76);
    --cn-surface-2: rgba(26,21,48,0.92);
    --cn-accent: #22C7A9;
    --cn-accent-soft: #0F332F;
}

[data-theme="dark"] body {
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--cn-primary-soft) 52%, transparent) 0, transparent 260px),
        var(--cn-bg);
}

[data-theme="dark"] .cn-navbar,
[data-theme="dark"] .chat-header,
[data-theme="dark"] .chat-input-area {
    background: rgba(20,16,38,.86);
}

[data-theme="dark"] .btn-cn-icon,
[data-theme="dark"] .theme-toggle-btn,
[data-theme="dark"] .chat-input-action {
    background: var(--cn-card);
}

[data-theme="dark"] .post-card:hover {
    box-shadow: 0 14px 32px rgba(0,0,0,.28);
}

@media (max-width: 991.98px) {
    .cn-navbar .navbar-collapse {
        margin-top: 10px;
        padding: 10px;
        background: var(--cn-card);
        border: 1px solid var(--cn-border);
        border-radius: 10px;
        box-shadow: var(--cn-shadow);
    }

    .cn-navbar .navbar-nav {
        gap: 6px;
    }

    .social-left-aside,
    .social-right-aside {
        position: static;
    }
}

@media (max-width: 575.98px) {
    main.container {
        padding-top: 12px !important;
    }

    .social-three-col {
        --bs-gutter-x: 0;
    }

    .social-composer-card,
    .post-card {
        box-shadow: none;
    }

    .post-card:hover {
        transform: none;
    }

    .chat-sidebar-header {
        padding: 12px;
    }

    .chat-sidebar-heading-icon {
        width: 36px;
        height: 36px;
        border-radius: 9px;
    }

    .chat-sidebar-title {
        font-size: 16px;
    }

    .chat-sidebar-subtitle {
        display: none;
    }

    .chat-list-item {
        min-height: 66px;
    }

    .chat-empty-actions {
        flex-direction: column;
    }

    .chat-empty-actions > * {
        width: min(260px, 100%);
        text-align: center;
        justify-content: center;
    }
}

/* Theme picker contrast and color-name menu */
#theme-picker-btn + .dropdown-menu {
    background: #FFFFFF !important;
    color: #111827 !important;
    border-color: rgba(17, 24, 39, .12) !important;
}

#theme-picker-btn + .dropdown-menu .theme-picker-item {
    color: #111827 !important;
}

#theme-picker-btn + .dropdown-menu .theme-picker-item:hover,
#theme-picker-btn + .dropdown-menu .theme-picker-item.active {
    background: #F3F6FA !important;
    color: #111827 !important;
}

#theme-picker-btn + .dropdown-menu .theme-picker-check {
    color: #111827 !important;
}

[data-theme="dark"] #theme-picker-btn + .dropdown-menu {
    background: #151827 !important;
    color: #FFFFFF !important;
    border-color: rgba(255, 255, 255, .16) !important;
}

[data-theme="dark"] #theme-picker-btn + .dropdown-menu .theme-picker-item {
    color: #FFFFFF !important;
}

[data-theme="dark"] #theme-picker-btn + .dropdown-menu .theme-picker-item:hover,
[data-theme="dark"] #theme-picker-btn + .dropdown-menu .theme-picker-item.active {
    background: #242A3A !important;
    color: #FFFFFF !important;
}

[data-theme="dark"] #theme-picker-btn + .dropdown-menu .theme-picker-check {
    color: #FFFFFF !important;
}

/* Global no-underline policy */
a,
a:hover,
a:focus,
a:active,
a:visited,
.dropdown-item,
.nav-link,
.btn,
.btn-cn,
.btn-cn-outline,
.btn-cn-soft,
.btn-cn-icon,
.theme-picker-item,
.social-nav-link,
.social-panel-action,
.social-result-row,
.social-result-title,
.social-post-author-name,
.profile-stat,
.profile-social-link,
.chat-list-item,
.contact-card,
.text-decoration-none {
    text-decoration: none !important;
}

/* Chat desktop panes must sit flush against each other */
@media (min-width: 769px) {
    .chat-page-wrapper {
        padding: 0 !important;
        margin: 0 !important;
        max-width: none !important;
        width: 100% !important;
        overflow: hidden !important;
    }

    .chat-shell {
        display: grid !important;
        grid-template-columns: 380px minmax(0, 1fr) !important;
        gap: 0 !important;
        column-gap: 0 !important;
        height: calc(100vh - 58px) !important;
        width: 100% !important;
        overflow: hidden !important;
        align-items: stretch !important;
        border-top: 1px solid var(--cn-border);
    }

    .chat-shell > * {
        direction: inherit !important;
    }

    .chat-sidebar {
        grid-column: 1 !important;
        width: 380px !important;
        max-width: 380px !important;
        height: 100% !important;
        border-inline-end: 1px solid var(--cn-border) !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }

    .chat-shell[dir="rtl"] {
        direction: rtl !important;
        grid-template-columns: minmax(0, 1fr) 380px !important;
    }

    .chat-shell[dir="rtl"] .chat-sidebar {
        grid-column: 2 !important;
        border-inline-end: 0 !important;
        border-inline-start: 1px solid var(--cn-border) !important;
    }

    .chat-shell[dir="rtl"] .chat-main {
        grid-column: 1 !important;
    }

    .chat-shell[dir="ltr"] {
        direction: ltr !important;
        grid-template-columns: 380px minmax(0, 1fr) !important;
    }

    .chat-shell[dir="ltr"] .chat-sidebar {
        grid-column: 1 !important;
        border-inline-start: 0 !important;
        border-inline-end: 1px solid var(--cn-border) !important;
    }

    .chat-shell[dir="ltr"] .chat-main {
        grid-column: 2 !important;
    }

    .chat-main {
        grid-column: 2 !important;
        min-width: 0 !important;
        height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 0 !important;
        overflow: hidden !important;
    }

    .chat-main .chat-container,
    .chat-container-embedded {
        width: 100% !important;
        max-width: none !important;
        height: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }
}

/* Keep chat composer buttons exactly aligned with the text input. */
.chat-composer-row {
    align-items: center !important;
    /* Sit above the message list so the (upward) attach menu isn't covered
       by message/poll content. */
    position: relative;
    z-index: 40;
}

.chat-composer-row .chat-input,
.chat-composer-row .chat-input-action,
.chat-composer-row .chat-send-btn {
    height: 42px !important;
    min-height: 42px !important;
    box-sizing: border-box;
}

.chat-composer-row .chat-input {
    line-height: 20px;
    padding-block: 10px !important;
    overflow-y: auto;
}

.chat-composer-row .chat-input-action,
.chat-composer-row .chat-send-btn {
    width: 42px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 42px !important;
    align-self: center !important;
}



/* Polished compact reaction chips below chat bubbles. */
.msg-reactions {
    display: flex !important;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
    align-items: center;
}
.msg-row.sent .msg-reactions {
    justify-content: flex-end;
}
.reaction-chip {
    min-width: 34px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--cn-card) 86%, transparent);
    border: 1px solid color-mix(in srgb, var(--cn-border) 74%, transparent);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
    line-height: 1;
}
.msg-bubble.sent .reaction-chip {
    background: rgba(255,255,255,.18);
    border-color: rgba(255,255,255,.24);
    color: #fff;
    box-shadow: none;
}
.reaction-chip.mine {
    background: var(--cn-primary-soft);
    border-color: var(--cn-primary);
    color: var(--cn-primary);
}
.msg-bubble.sent .reaction-chip.mine {
    background: #fff;
    border-color: #fff;
    color: var(--cn-primary);
}
.reaction-chip .emoji { font-size: 14px; line-height: 1; }
.reaction-chip .count { font-size: 11px; font-weight: 800; line-height: 1; }


/* Duration menu for chat mute control. */
.chat-mute-menu {
    position: fixed;
    z-index: 10020;
    min-width: 190px;
    padding: 8px;
    border-radius: 10px;
    background: var(--cn-card);
    border: 1px solid var(--cn-border);
    box-shadow: var(--cn-shadow-lg);
    color: var(--cn-ink);
}
.chat-mute-menu-title {
    padding: 6px 10px 8px;
    font-size: 12px;
    font-weight: 800;
    color: var(--cn-ink-mute);
}
.chat-mute-menu button {
    width: 100%;
    border: 0;
    background: transparent;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    text-align: start;
    cursor: pointer;
}
.chat-mute-menu button:hover {
    background: var(--cn-primary-soft);
    color: var(--cn-primary);
}
.chat-mute-menu button i {
    width: 18px;
    text-align: center;
    font-size: 15px;
}
.chat-mute-menu-divider {
    height: 1px;
    margin: 6px 4px;
    background: var(--cn-border);
}
.chat-mute-unmute {
    color: var(--cn-danger) !important;
}
.chat-mute-unmute:hover {
    background: rgba(255, 79, 139, 0.12) !important;
    color: var(--cn-danger) !important;
}


/* Requested polish: story seen state, stable chat desktop panes, and geo communities UI. */
.story-item-mini.story-seen .story-mini-avatar {
    background: linear-gradient(135deg, #A8B0BD, #D8DEE8) !important;
    box-shadow: none !important;
}
.story-item-mini.story-seen .story-mini-avatar img {
    filter: saturate(.72);
}
.story-item-mini.story-seen .story-mini-name {
    color: var(--cn-ink-mute) !important;
}

@media (min-width: 769px) {
    .chat-shell {
        display: grid !important;
        grid-template-rows: minmax(0, 1fr) !important;
        align-items: stretch !important;
    }
    .chat-sidebar,
    .chat-main {
        grid-row: 1 !important;
        min-height: 0 !important;
    }
    .chat-main {
        display: flex !important;
        align-self: stretch !important;
    }
    .chat-empty-pane {
        width: 100% !important;
        min-height: 100% !important;
    }
}

.geo-wrapper {
    max-width: 1120px !important;
}
.geo-page-header {
    padding: 18px 0 26px !important;
    text-align: center !important;
}
.geo-page-title {
    font-size: 30px !important;
    font-weight: 900 !important;
    letter-spacing: 0 !important;
}
.geo-page-subtitle {
    max-width: 560px !important;
    margin-inline: auto !important;
    line-height: 1.9 !important;
}
.geo-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)) !important;
    gap: 14px !important;
}
.geo-tile {
    min-height: 132px !important;
    border-radius: 8px !important;
    padding: 16px !important;
    background: color-mix(in srgb, var(--cn-card) 94%, var(--cn-primary-soft)) !important;
    box-shadow: 0 10px 26px rgba(15,23,42,.055) !important;
}
.geo-tile:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 16px 34px rgba(15,23,42,.09) !important;
}
.geo-tile-head {
    align-items: flex-start !important;
}
.geo-tile-icon {
    width: 46px !important;
    height: 46px !important;
    border-radius: 8px !important;
}
.geo-tile-icon.flag {
    font-size: 32px !important;
    background: var(--cn-card) !important;
    border: 1px solid var(--cn-border) !important;
}
.geo-tile-name {
    font-size: 15px !important;
    font-weight: 900 !important;
}
.geo-tile-meta {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    align-items: center !important;
    margin-top: 4px !important;
}
.geo-tile-actions {
    gap: 8px !important;
}
.geo-btn {
    min-height: 38px !important;
    border-radius: 8px !important;
    font-weight: 800 !important;
}
.geo-hero {
    border-radius: 8px !important;
    box-shadow: 0 14px 34px rgba(15,23,42,.07) !important;
}


.sv-viewers {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 72px;
    z-index: 12;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    color: #fff;
    pointer-events: auto;
}
.sv-viewers-title,
.sv-viewer-row,
.sv-viewer-empty {
    min-height: 32px;
    border: 0;
    border-radius: 8px;
    background: rgba(0,0,0,.42);
    color: #fff;
    backdrop-filter: blur(8px);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    font-size: 12px;
    font-weight: 800;
    text-decoration: none !important;
}
.sv-viewer-row img {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,.55);
}
.sv-viewer-empty {
    opacity: .86;
}

/* Chat media messages need tighter, predictable padding than text bubbles. */
.msg-row[data-msg-type="image"] .msg-bubble,
.msg-row[data-msg-type="video"] .msg-bubble,
.msg-row[data-msg-type="file"] .msg-bubble,
.msg-row[data-msg-type="location"] .msg-bubble {
    padding: 6px !important;
    border-radius: 8px !important;
    overflow: hidden;
}
.msg-row[data-msg-type="image"] .msg-bubble.sent,
.msg-row[data-msg-type="video"] .msg-bubble.sent,
.msg-row[data-msg-type="file"] .msg-bubble.sent,
.msg-row[data-msg-type="location"] .msg-bubble.sent {
    padding-left: 6px !important;
}
.msg-row[data-msg-type="image"] .msg-image,
.msg-row[data-msg-type="video"] .tg-video {
    display: block;
    width: min(320px, 64vw);
    max-width: 100%;
    max-height: min(420px, 58vh);
    object-fit: cover;
    margin: 0 !important;
    border-radius: 6px !important;
}
.msg-row[data-msg-type="image"] .msg-text,
.msg-row[data-msg-type="video"] .msg-text,
.msg-row[data-msg-type="file"] .msg-text,
.msg-row[data-msg-type="location"] .msg-text {
    margin: 6px 4px 0 !important;
    line-height: 1.55;
}
.msg-row[data-msg-type="image"] .msg-meta,
.msg-row[data-msg-type="video"] .msg-meta,
.msg-row[data-msg-type="file"] .msg-meta,
.msg-row[data-msg-type="location"] .msg-meta {
    margin: 4px 4px 0 !important;
    line-height: 1.2;
}
.msg-row[data-msg-type="file"] .msg-bubble > a {
    min-width: 220px;
    padding: 6px 8px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--cn-border-soft) 52%, transparent);
}

/* Compact Instagram-like preview for story replies/reactions inside DM. */
.msg-story-card {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 9px;
    align-items: center;
    min-width: 190px;
    max-width: 260px;
    padding: 6px;
    border-radius: 12px;
    cursor: pointer;
    background: color-mix(in srgb, var(--cn-border-soft) 72%, transparent);
}
.msg-bubble.sent .msg-story-card {
    background: rgba(255,255,255,.18);
}
.msg-story-thumb {
    width: 58px;
    height: 82px;
    border-radius: 9px;
    object-fit: cover;
    display: block;
    background: rgba(0,0,0,.12);
}
.msg-story-copy {
    min-width: 0;
    display: grid;
    gap: 4px;
}
.msg-story-title {
    font-size: 12px;
    font-weight: 800;
    line-height: 1.35;
    word-break: break-word;
}
.msg-story-body {
    font-size: 12px;
    line-height: 1.45;
    opacity: .82;
    word-break: break-word;
}
.msg-bubble.sent .msg-story-title,
.msg-bubble.sent .msg-story-body {
    color: #fff;
}

/* Chat text bubbles: polished message-style radius and spacing without touching media cards. */
.msg-row:not([data-msg-type="image"]):not([data-msg-type="video"]):not([data-msg-type="file"]):not([data-msg-type="location"]) .msg-bubble {
    padding: 8px 12px !important;
    border-radius: 18px !important;
    max-width: min(560px, 72%) !important;
    line-height: 1.55;
    overflow: visible;
}
.msg-row.sent:not([data-msg-type="image"]):not([data-msg-type="video"]):not([data-msg-type="file"]):not([data-msg-type="location"]) .msg-bubble.sent {
    border-radius: 18px 18px 6px 18px !important;
    padding-inline: 12px !important;
    box-shadow: 0 8px 20px color-mix(in srgb, var(--cn-primary) 24%, transparent) !important;
}
.msg-row.received:not([data-msg-type="image"]):not([data-msg-type="video"]):not([data-msg-type="file"]):not([data-msg-type="location"]) .msg-bubble.received {
    border-radius: 18px 18px 18px 6px !important;
    box-shadow: 0 4px 14px rgba(15,23,42,.07) !important;
}
.msg-row:not([data-msg-type="image"]):not([data-msg-type="video"]):not([data-msg-type="file"]):not([data-msg-type="location"]) .msg-text {
    margin: 0 !important;
    word-break: break-word;
}
.msg-row:not([data-msg-type="image"]):not([data-msg-type="video"]):not([data-msg-type="file"]):not([data-msg-type="location"]) .msg-meta {
    margin-top: 4px !important;
    line-height: 1.2;
}
.msg-row:not([data-msg-type="image"]):not([data-msg-type="video"]):not([data-msg-type="file"]):not([data-msg-type="location"]) .msg-reactions {
    margin-top: 6px !important;
    gap: 4px !important;
}
.msg-row:not([data-msg-type="image"]):not([data-msg-type="video"]):not([data-msg-type="file"]):not([data-msg-type="location"]) .reaction-chip {
    min-width: 30px;
    height: 24px;
    padding: 0 8px;
    border-radius: 999px;
}
@media (max-width: 768px) {
    .msg-row:not([data-msg-type="image"]):not([data-msg-type="video"]):not([data-msg-type="file"]):not([data-msg-type="location"]) .msg-bubble {
        max-width: 82% !important;
    }
}

/* Professional profile page refresh. */
.profile-page-shell {
    max-width: 980px;
    margin: 0 auto 48px;
    display: grid;
    gap: 18px;
}
.profile-hero-card {
    overflow: hidden;
    border-radius: 12px !important;
    padding: 0 !important;
}
.profile-hero-cover {
    height: 118px;
    background:
        radial-gradient(circle at 18% 40%, color-mix(in srgb, var(--cn-accent, #00A389) 24%, transparent), transparent 30%),
        linear-gradient(135deg, color-mix(in srgb, var(--cn-primary) 18%, var(--cn-card)), color-mix(in srgb, var(--cn-border-soft) 72%, var(--cn-card)));
    border-bottom: 1px solid var(--cn-border);
}
.profile-hero-body {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 20px;
    align-items: start;
    padding: 0 24px 22px;
    margin-top: -46px;
}
.profile-avatar-wrap {
    position: relative;
    width: 112px;
    height: 112px;
    flex: 0 0 auto;
}
.profile-avatar-xl {
    width: 112px;
    height: 112px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--cn-card);
    border: 5px solid var(--cn-card);
    box-shadow: 0 16px 34px rgba(15,23,42,.14);
}
.profile-online-dot {
    position: absolute;
    right: 12px;
    bottom: 10px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--cn-online);
    border: 3px solid var(--cn-card);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--cn-online) 18%, transparent);
}
.profile-main-info {
    min-width: 0;
    padding-top: 52px;
}
.profile-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.profile-title-row h1 {
    margin: 0;
    font-size: clamp(22px, 3vw, 30px);
    font-weight: 950;
    color: var(--cn-ink);
    letter-spacing: 0;
}
.profile-username {
    color: var(--cn-ink-mute);
    font-size: 13px;
    font-weight: 700;
    margin-top: 3px;
}
.profile-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 26px;
    border-radius: 999px;
    padding: 0 9px;
    background: var(--cn-border-soft);
    color: var(--cn-ink-sub);
    font-size: 11px;
    font-weight: 850;
}
.profile-chip.is-online {
    background: color-mix(in srgb, var(--cn-online) 12%, var(--cn-card));
    color: var(--cn-online);
}
.profile-chip i {
    font-size: 10px;
}
.profile-status,
.profile-last-seen,
.profile-website {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 10px;
    color: var(--cn-ink-sub);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}
.profile-website {
    color: var(--cn-primary);
    direction: ltr;
}
.profile-bio {
    margin: 10px 0 0;
    max-width: 620px;
    color: var(--cn-ink);
    line-height: 1.8;
    font-size: 14px;
}
.profile-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 54px;
}
.profile-action-primary,
.profile-action-secondary {
    min-height: 40px;
    padding: 0 15px !important;
    border-radius: 8px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 13px !important;
    font-weight: 850 !important;
    white-space: nowrap;
}
.profile-more-btn {
    width: 40px !important;
    height: 40px !important;
    border-radius: 8px !important;
}
.profile-stats-v2 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-top: 1px solid var(--cn-border);
    background: color-mix(in srgb, var(--cn-border-soft) 70%, var(--cn-card));
    gap: 1px;
}
.profile-stat-v2 {
    min-height: 78px;
    display: grid;
    place-items: center;
    align-content: center;
    text-decoration: none;
    color: inherit;
    background: var(--cn-card);
    transition: background .15s ease, color .15s ease;
}
.profile-stat-v2:hover {
    background: var(--cn-primary-soft);
    color: var(--cn-primary);
}
.profile-stat-v2 span {
    color: var(--cn-ink);
    font-size: 22px;
    font-weight: 950;
    line-height: 1;
}
.profile-stat-v2 small {
    margin-top: 7px;
    color: var(--cn-ink-mute);
    font-size: 12px;
    font-weight: 800;
}
.profile-info-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(260px, .8fr);
    gap: 18px;
}
.profile-info-card {
    padding: 18px !important;
    border-radius: 12px !important;
}
.profile-section-head,
.profile-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--cn-ink);
    font-size: 14px;
    font-weight: 950;
    margin-bottom: 14px;
}
.profile-section-head i,
.profile-section-title i {
    width: 30px;
    height: 30px;
    display: inline-grid;
    place-items: center;
    border-radius: 8px;
    color: var(--cn-primary);
    background: var(--cn-primary-soft);
}
.profile-info-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.profile-info-item {
    min-height: 66px;
    border: 1px solid var(--cn-border-soft);
    border-radius: 8px;
    background: color-mix(in srgb, var(--cn-border-soft) 46%, transparent);
    padding: 10px 12px;
}
.profile-info-item small {
    display: block;
    color: var(--cn-ink-mute);
    font-size: 11px;
    font-weight: 800;
    margin-bottom: 5px;
}
.profile-info-item strong {
    color: var(--cn-ink);
    font-size: 13px;
    font-weight: 900;
    word-break: break-word;
}
.profile-xp-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    color: var(--cn-primary);
    font-weight: 900;
}
.profile-xp-line small {
    color: var(--cn-ink-mute);
}
.profile-posts-section {
    display: grid;
    gap: 12px;
}
.profile-post-grid {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 10px !important;
}
.profile-post-tile {
    border-radius: 10px !important;
    border: 1px solid var(--cn-border);
    background: var(--cn-card);
    box-shadow: 0 8px 20px rgba(15,23,42,.055) !important;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.profile-post-tile:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--cn-primary) 30%, var(--cn-border));
    box-shadow: 0 16px 30px rgba(15,23,42,.09) !important;
}
.profile-empty-state,
.profile-private-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 54px 20px;
    color: var(--cn-ink-mute);
}
.profile-empty-state i,
.profile-private-state > i {
    width: 70px;
    height: 70px;
    display: inline-grid;
    place-items: center;
    border-radius: 18px;
    background: var(--cn-primary-soft);
    color: var(--cn-primary);
    font-size: 32px;
    margin-bottom: 14px;
}
.profile-empty-state h3,
.profile-private-state h3 {
    margin: 0 0 8px;
    color: var(--cn-ink);
    font-size: 18px;
    font-weight: 950;
}
.profile-empty-state p,
.profile-private-state p {
    margin: 0 auto;
    max-width: 340px;
    line-height: 1.8;
    font-size: 13px;
}
.profile-private-state {
    border-radius: 12px !important;
}

@media (max-width: 767.98px) {
    .profile-page-shell {
        gap: 14px;
        margin-bottom: 28px;
    }
    .profile-hero-cover {
        height: 94px;
    }
    .profile-hero-body {
        grid-template-columns: 1fr;
        text-align: center;
        justify-items: center;
        padding: 0 16px 18px;
        gap: 12px;
    }
    .profile-main-info,
    .profile-actions {
        padding-top: 0;
        justify-content: center;
    }
    .profile-title-row {
        justify-content: center;
    }
    .profile-info-grid,
    .profile-info-list {
        grid-template-columns: 1fr;
    }
    .profile-stats-v2 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .profile-stat-v2 {
        min-height: 70px;
    }
    .profile-stat-v2 span {
        font-size: 19px;
    }
}

/* Profile edit username input polish */
.profile-username-input {
    direction: ltr;
    flex-wrap: nowrap;
}
.profile-username-input .input-group-text {
    border-radius: 8px 0 0 8px !important;
    border-right: 0;
    min-width: 38px;
    justify-content: center;
    background: var(--cn-surface-soft, #f8fafc);
    color: var(--cn-ink, #172033);
}
.profile-username-input .form-control {
    direction: ltr;
    text-align: left;
    border-radius: 0 8px 8px 0 !important;
}
html[dir="rtl"] .profile-username-input .input-group-text {
    border-left: 1px solid var(--cn-border, #e5e7eb);
    border-right: 0;
}

/* Profile page professional layout override */
.profile-page-shell {
    width: min(100%, 1080px);
    max-width: 1080px;
    margin: 0 auto 56px;
    gap: 20px;
}
.profile-page-shell .cn-card,
.profile-hero-card,
.profile-info-card,
.profile-private-state {
    max-width: none !important;
}
.profile-hero-card {
    border: 1px solid color-mix(in srgb, var(--cn-primary) 14%, var(--cn-border)) !important;
    border-radius: 16px !important;
    box-shadow: 0 18px 45px rgba(15,23,42,.08) !important;
    position: relative;
}
.profile-hero-cover {
    height: 164px;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--cn-primary) 18%, var(--cn-card)) 0%, color-mix(in srgb, var(--cn-accent, #00A389) 10%, var(--cn-card)) 54%, var(--cn-card) 100%),
        repeating-linear-gradient(135deg, rgba(255,255,255,.18) 0 1px, transparent 1px 18px);
    border-bottom: 1px solid var(--cn-border);
}
.profile-hero-body {
    grid-template-columns: 132px minmax(0, 1fr) auto;
    gap: 24px;
    padding: 0 28px 24px;
    margin-top: -64px;
    align-items: end;
}
.profile-avatar-wrap,
.profile-avatar-xl {
    width: 132px;
    height: 132px;
}
.profile-avatar-xl {
    border-width: 6px;
    box-shadow: 0 18px 44px rgba(15,23,42,.16);
}
.profile-online-dot {
    right: 14px;
    bottom: 14px;
    width: 18px;
    height: 18px;
}
.profile-main-info {
    padding-top: 72px;
}
.profile-title-row h1 {
    font-size: clamp(26px, 3vw, 36px);
    line-height: 1.15;
}
.profile-username {
    width: fit-content;
    margin-top: 7px;
    padding: 4px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--cn-border-soft) 74%, transparent);
    border: 1px solid var(--cn-border-soft);
}
.profile-actions {
    padding-top: 72px;
    align-self: end;
}
.profile-action-primary,
.profile-action-secondary,
.profile-more-btn {
    box-shadow: 0 8px 18px rgba(15,23,42,.07);
}
.profile-stats-v2 {
    margin: 0 28px 26px;
    border: 1px solid var(--cn-border);
    border-radius: 14px;
    overflow: hidden;
    background: var(--cn-border);
}
.profile-stat-v2 {
    min-height: 86px;
}
.profile-stat-v2 span {
    font-size: 25px;
}
.profile-stat-v2 small {
    font-size: 12px;
}
.profile-info-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
}
.profile-info-card {
    border-radius: 16px !important;
    padding: 22px !important;
    border: 1px solid var(--cn-border) !important;
    box-shadow: 0 14px 34px rgba(15,23,42,.06) !important;
}
.profile-info-list {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.profile-info-item {
    min-height: 78px;
    border-radius: 12px;
    padding: 13px 14px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--cn-border-soft) 62%, transparent), color-mix(in srgb, var(--cn-card) 92%, transparent));
}
.profile-info-item small {
    font-size: 12px;
}
.profile-info-item strong {
    font-size: 14px;
}
.profile-posts-section {
    border: 1px solid var(--cn-border);
    border-radius: 16px;
    background: var(--cn-card);
    padding: 20px;
    box-shadow: 0 14px 34px rgba(15,23,42,.055);
}
.profile-post-grid {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px !important;
}
.profile-empty-state {
    min-height: 260px;
    display: grid;
    place-items: center;
    align-content: center;
    border: 1px dashed color-mix(in srgb, var(--cn-primary) 26%, var(--cn-border));
    border-radius: 14px;
    background: color-mix(in srgb, var(--cn-primary-soft) 32%, transparent);
}
.profile-empty-state i,
.profile-private-state > i {
    border-radius: 16px;
}
.profile-private-state {
    padding: 56px 24px !important;
    border-radius: 16px !important;
}

@media (max-width: 991.98px) {
    .profile-page-shell {
        width: 100%;
    }
    .profile-hero-body {
        grid-template-columns: 116px minmax(0, 1fr);
    }
    .profile-avatar-wrap,
    .profile-avatar-xl {
        width: 116px;
        height: 116px;
    }
    .profile-actions {
        grid-column: 1 / -1;
        padding-top: 0;
        justify-content: flex-start;
    }
}
@media (max-width: 767.98px) {
    .profile-hero-cover {
        height: 116px;
    }
    .profile-hero-body {
        grid-template-columns: 1fr;
        margin-top: -58px;
        align-items: center;
    }
    .profile-main-info,
    .profile-actions {
        padding-top: 0;
    }
    .profile-username {
        margin-left: auto;
        margin-right: auto;
    }
    .profile-stats-v2 {
        margin: 0 14px 18px;
    }
    .profile-posts-section,
    .profile-info-card {
        padding: 16px !important;
    }
}


/* Strong profile redesign: full-width hero + structured content */
.profile-page-shell {
    width: min(100%, 1120px) !important;
    max-width: 1120px !important;
    margin: 0 auto 64px !important;
    gap: 22px !important;
}
.profile-page-shell .cn-card,
.profile-page-shell .profile-hero-card,
.profile-page-shell .profile-info-card,
.profile-page-shell .profile-private-state {
    width: 100% !important;
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}
.profile-hero-card {
    overflow: visible !important;
    border-radius: 18px !important;
    border: 1px solid color-mix(in srgb, var(--cn-primary) 18%, var(--cn-border)) !important;
    box-shadow: 0 22px 60px rgba(15,23,42,.10) !important;
    background: var(--cn-card) !important;
}
.profile-hero-cover {
    height: 210px !important;
    border-radius: 18px 18px 0 0;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--cn-primary) 28%, var(--cn-card)) 0%, color-mix(in srgb, var(--cn-accent, #00A389) 15%, var(--cn-card)) 52%, color-mix(in srgb, var(--cn-primary) 8%, var(--cn-card)) 100%),
        repeating-linear-gradient(135deg, rgba(255,255,255,.20) 0 1px, transparent 1px 20px) !important;
}
.profile-hero-body {
    grid-template-columns: 148px minmax(0, 1fr) auto !important;
    gap: 28px !important;
    padding: 0 34px 24px !important;
    margin-top: -76px !important;
    align-items: end !important;
}
.profile-avatar-wrap,
.profile-avatar-xl {
    width: 148px !important;
    height: 148px !important;
}
.profile-avatar-xl {
    border: 7px solid var(--cn-card) !important;
    box-shadow: 0 20px 52px rgba(15,23,42,.20) !important;
}
.profile-online-dot {
    right: 18px !important;
    bottom: 18px !important;
    width: 20px !important;
    height: 20px !important;
}
.profile-main-info {
    padding-top: 88px !important;
}
.profile-title-row {
    gap: 10px !important;
}
.profile-title-row h1 {
    font-size: clamp(30px, 3.4vw, 42px) !important;
    line-height: 1.08 !important;
}
.profile-chip {
    min-height: 28px !important;
    padding: 0 11px !important;
    border: 1px solid color-mix(in srgb, var(--cn-primary) 14%, var(--cn-border-soft));
}
.profile-username {
    margin-top: 9px !important;
    font-size: 12px !important;
    background: color-mix(in srgb, var(--cn-primary-soft) 58%, var(--cn-card)) !important;
}
.profile-actions {
    padding-top: 88px !important;
    gap: 10px !important;
}
.profile-action-primary,
.profile-action-secondary {
    min-height: 44px !important;
    padding: 0 18px !important;
}
.profile-more-btn {
    width: 44px !important;
    height: 44px !important;
}
.profile-stats-v2 {
    margin: 0 34px 30px !important;
    border-radius: 16px !important;
    border: 1px solid var(--cn-border) !important;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
}
.profile-stat-v2 {
    min-height: 92px !important;
}
.profile-stat-v2 span {
    font-size: 28px !important;
}
.profile-stat-v2 small {
    font-size: 12px !important;
}
.profile-content-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 20px;
    align-items: start;
}
.profile-info-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
    order: 2;
}
.profile-posts-section,
.profile-private-state {
    order: 1;
    min-width: 0;
}
html[dir="ltr"] .profile-info-grid { order: 1; }
html[dir="ltr"] .profile-posts-section,
html[dir="ltr"] .profile-private-state { order: 2; }
.profile-info-card,
.profile-posts-section,
.profile-private-state {
    border-radius: 18px !important;
    border: 1px solid var(--cn-border) !important;
    box-shadow: 0 16px 42px rgba(15,23,42,.065) !important;
    background: var(--cn-card) !important;
}
.profile-info-card {
    padding: 20px !important;
}
.profile-section-head,
.profile-section-title {
    margin-bottom: 16px !important;
    font-size: 15px !important;
}
.profile-info-list {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
}
.profile-info-item {
    min-height: 82px !important;
    border-radius: 14px !important;
    background: color-mix(in srgb, var(--cn-primary-soft) 22%, var(--cn-card)) !important;
    border-color: color-mix(in srgb, var(--cn-primary) 14%, var(--cn-border)) !important;
}
.profile-posts-section {
    padding: 22px !important;
}
.profile-post-grid {
    min-height: 330px;
}
.profile-empty-state {
    min-height: 330px !important;
    border-radius: 16px !important;
    background: linear-gradient(180deg, color-mix(in srgb, var(--cn-primary-soft) 34%, transparent), transparent) !important;
}
@media (max-width: 991.98px) {
    .profile-content-layout {
        grid-template-columns: 1fr;
    }
    .profile-info-grid,
    .profile-posts-section,
    .profile-private-state {
        order: initial !important;
    }
    .profile-hero-body {
        grid-template-columns: 128px minmax(0, 1fr) !important;
    }
    .profile-avatar-wrap,
    .profile-avatar-xl {
        width: 128px !important;
        height: 128px !important;
    }
    .profile-actions {
        grid-column: 1 / -1;
        padding-top: 0 !important;
        justify-content: flex-start !important;
    }
}
@media (max-width: 767.98px) {
    .profile-page-shell {
        margin-bottom: 36px !important;
        gap: 16px !important;
    }
    .profile-hero-cover {
        height: 132px !important;
    }
    .profile-hero-body {
        grid-template-columns: 1fr !important;
        margin-top: -64px !important;
        padding: 0 16px 20px !important;
        justify-items: center !important;
        text-align: center !important;
    }
    .profile-avatar-wrap,
    .profile-avatar-xl {
        width: 124px !important;
        height: 124px !important;
    }
    .profile-main-info,
    .profile-actions {
        padding-top: 0 !important;
    }
    .profile-stats-v2 {
        margin: 0 14px 18px !important;
    }
}

/* Sidebar stories alignment fix */
.social-left-aside .stories-strip,
.social-right-aside .stories-strip,
.stories-strip {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    justify-items: center;
    align-items: start;
    gap: 12px 8px !important;
    padding: 8px 0 2px !important;
}
.story-item-mini {
    width: 64px !important;
    min-width: 64px !important;
    max-width: 64px !important;
    display: grid !important;
    justify-items: center !important;
    align-items: start !important;
    gap: 6px !important;
    text-align: center !important;
}
.story-mini-add,
.story-mini-avatar {
    width: 52px !important;
    height: 52px !important;
    display: grid !important;
    place-items: center !important;
    margin: 0 auto !important;
    flex: 0 0 52px !important;
    box-sizing: border-box !important;
}
.story-mini-avatar {
    padding: 2px !important;
    overflow: hidden;
}
.story-mini-avatar img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    box-sizing: border-box !important;
}
.story-mini-name {
    display: block !important;
    width: 64px !important;
    max-width: 64px !important;
    text-align: center !important;
    line-height: 1.35 !important;
    font-size: 10.5px !important;
    font-weight: 700;
    margin: 0 auto !important;
}

/* Align social post action icon/count/label on one line */
.social-post-actions .post-action-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-direction: row !important;
    gap: 6px !important;
    min-height: 38px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
}
.social-post-actions .post-action-btn > span,
.social-post-actions .post-action-btn > i {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    vertical-align: middle !important;
}
.social-post-actions .post-action-btn i {
    font-size: 15px !important;
    line-height: 1 !important;
}
.social-post-actions .like-count,
.social-post-actions .repost-count,
.social-post-actions .post-action-label {
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
}
.repost-icon-wrap {
    position: relative;
    width: 17px;
    height: 17px;
}
.repost-icon-wrap .bi-repeat {
    position: absolute;
    inset: 0;
}
.repost-check-icon {
    position: absolute;
    right: -7px;
    bottom: -6px;
    display: none !important;
    font-size: 10px !important;
    color: var(--cn-success, #198754);
    background: var(--cn-card);
    border-radius: 50%;
}
.repost-action-btn.is-reposted,
.repost-action-btn.is-reposted .repost-count,
.repost-action-btn.is-reposted .post-action-label {
    color: var(--cn-success, #198754) !important;
}
.repost-action-btn.is-reposted .repost-check-icon {
    display: inline-flex !important;
}
.post-action-btn.is-shared {
    color: var(--cn-primary) !important;
}


/* Mobile app shell navigation */
.mobile-app-bottom-nav,
.mobile-more-panel {
    display: none;
}

@media (max-width: 767.98px) {
    html {
        scroll-padding-bottom: 92px;
    }

    body {
        padding-bottom: calc(78px + env(safe-area-inset-bottom));
    }

    .cn-navbar {
        padding: 6px 0 !important;
        z-index: 1040;
        background: color-mix(in srgb, var(--cn-card) 88%, transparent) !important;
        backdrop-filter: blur(18px);
    }

    .cn-navbar .container {
        min-height: 52px;
        padding-inline: 12px;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 8px;
    }

    .cn-navbar .navbar-brand {
        min-width: 0;
        padding: 4px 0 !important;
        font-size: 1rem !important;
    }

    .cn-navbar .navbar-brand .brand-icon {
        width: 34px !important;
        height: 34px !important;
        border-radius: 10px !important;
    }

    .cn-navbar .navbar-toggler {
        display: none !important;
    }

    .cn-navbar .navbar-collapse {
        display: flex !important;
        flex-basis: auto;
        justify-content: flex-end;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    .cn-navbar .navbar-collapse > .navbar-nav.me-auto {
        display: none !important;
    }

    .cn-navbar .navbar-collapse > .navbar-nav {
        flex-direction: row;
        align-items: center;
        gap: 6px;
        margin: 0 !important;
    }

    .cn-navbar .theme-toggle-btn {
        width: 38px;
        height: 38px;
        border-radius: 12px;
    }

    .cn-navbar .navbar-collapse > .navbar-nav .dropdown-toggle {
        min-height: 38px;
        padding: 0 !important;
        gap: 0 !important;
        font-size: 0;
    }

    .cn-navbar .navbar-collapse > .navbar-nav .dropdown-toggle::after {
        display: none;
    }

    .cn-navbar .cn-avatar {
        width: 36px;
        height: 36px;
    }

    #theme-picker-btn + .dropdown-menu {
        max-height: min(70vh, 460px);
        overflow-y: auto;
    }

    main.container {
        width: 100%;
        max-width: 100% !important;
        padding: 12px 12px 96px !important;
    }

    .social-three-col {
        --bs-gutter-x: 0;
    }

    .social-center-col,
    .social-three-col > [class*="col-"] {
        padding-inline: 0 !important;
    }

    .social-left-aside,
    .social-right-aside {
        display: none !important;
    }

    .social-composer-card,
    .post-card,
    .cn-card {
        border-radius: 14px;
    }

    .mobile-app-bottom-nav {
        position: fixed;
        inset-inline: 0;
        bottom: 0;
        z-index: 1060;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 6px;
        padding: 8px max(10px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-right));
        background: color-mix(in srgb, var(--cn-card) 92%, transparent);
        border-top: 1px solid color-mix(in srgb, var(--cn-border) 88%, transparent);
        box-shadow: 0 -14px 34px rgba(15, 23, 42, .12);
        backdrop-filter: blur(18px);
    }

    .mobile-bottom-link {
        position: relative;
        min-width: 0;
        height: 54px;
        border: 0;
        border-radius: 16px;
        background: transparent;
        color: var(--cn-ink-sub);
        text-decoration: none;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        font: inherit;
        line-height: 1;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-bottom-link i {
        font-size: 20px;
        line-height: 1;
    }

    .mobile-bottom-link span:not(.mobile-bottom-badge) {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 10.5px;
        font-weight: 800;
        letter-spacing: 0;
    }

    .mobile-bottom-link.active {
        color: #fff;
        background: var(--cn-primary);
        box-shadow: 0 10px 22px color-mix(in srgb, var(--cn-primary) 30%, transparent);
    }

    .mobile-bottom-badge {
        position: absolute;
        top: 5px;
        inset-inline-end: 11px;
        min-width: 18px;
        height: 18px;
        padding-inline: 5px;
        border-radius: 999px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: #ff2f63;
        color: #fff;
        border: 2px solid var(--cn-card);
        font-size: 10px;
        font-weight: 900;
        line-height: 1;
    }

    .mobile-bottom-link.active .mobile-bottom-badge {
        background: #fff;
        color: var(--cn-primary);
        border-color: var(--cn-primary);
    }

    .mobile-more-panel.offcanvas {
        display: flex !important;
        height: auto;
        max-height: min(78vh, 560px);
        color: var(--cn-ink);
        background: var(--cn-card);
        border-top: 1px solid var(--cn-border);
        border-radius: 22px 22px 0 0;
        box-shadow: 0 -18px 44px rgba(15, 23, 42, .18);
    }

    .mobile-more-panel .offcanvas-header {
        padding: 16px 18px 10px;
        align-items: flex-start;
        border-bottom: 1px solid var(--cn-border-soft);
    }

    .mobile-more-panel .offcanvas-title {
        margin: 0;
        font-size: 18px;
        font-weight: 950;
    }

    .mobile-more-panel .offcanvas-header small {
        display: block;
        margin-top: 3px;
        color: var(--cn-ink-mute);
        font-size: 12px;
        font-weight: 700;
    }

    .mobile-more-panel .offcanvas-body {
        padding: 12px 14px calc(18px + env(safe-area-inset-bottom));
    }

    .mobile-more-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .mobile-more-link {
        position: relative;
        min-height: 54px;
        padding: 12px;
        border-radius: 14px;
        border: 1px solid var(--cn-border);
        background: color-mix(in srgb, var(--cn-border-soft) 58%, var(--cn-card));
        color: var(--cn-ink);
        text-decoration: none;
        display: flex;
        align-items: center;
        gap: 10px;
        font-size: 13px;
        font-weight: 850;
    }

    .mobile-more-link i {
        width: 34px;
        height: 34px;
        border-radius: 12px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: var(--cn-primary-soft);
        color: var(--cn-primary);
        font-size: 16px;
        flex: 0 0 auto;
    }

    .mobile-more-link span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-more-link b {
        margin-inline-start: auto;
        min-width: 20px;
        height: 20px;
        padding-inline: 6px;
        border-radius: 999px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: #ff2f63;
        color: #fff;
        font-size: 11px;
        line-height: 1;
    }

    .mobile-more-logout {
        margin-top: 10px;
        color: #e11d48;
        background: color-mix(in srgb, #e11d48 8%, var(--cn-card));
        border-color: color-mix(in srgb, #e11d48 22%, var(--cn-border));
    }

    .mobile-more-logout i {
        color: #e11d48;
        background: color-mix(in srgb, #e11d48 12%, var(--cn-card));
    }

    body.chat-open {
        padding-bottom: calc(78px + env(safe-area-inset-bottom));
    }

    body.chat-conversation-open {
        padding-bottom: 0;
    }

    body.chat-conversation-open .mobile-app-bottom-nav {
        display: none !important;
    }

    @supports selector(body:has(.chat-shell.chat-active)) {
        body.chat-open:has(.chat-shell.chat-active) {
            padding-bottom: 0;
        }

        body.chat-open:has(.chat-shell.chat-active) .mobile-app-bottom-nav {
            display: none !important;
        }
    }
}

@media (min-width: 768px) {
    .mobile-app-bottom-nav,
    .mobile-more-panel {
        display: none !important;
    }
}

[data-theme="dark"] .mobile-app-bottom-nav,
[data-theme="dark"] .mobile-more-panel.offcanvas {
    background: color-mix(in srgb, var(--cn-card) 92%, #000);
    box-shadow: 0 -18px 44px rgba(0, 0, 0, .36);
}


/* Proposed profile UI: wide hero, cards, tabs, feed */
.profile-page-shell {
    width: min(100%, 1320px) !important;
    max-width: 1320px !important;
    margin: 26px auto 72px !important;
    gap: 28px !important;
}
.profile-hero-card {
    position: relative !important;
    overflow: hidden !important;
    border-radius: 22px !important;
    border: 1px solid color-mix(in srgb, var(--cn-primary) 18%, var(--cn-border)) !important;
    background: rgba(255,255,255,.88) !important;
    box-shadow: 0 24px 70px rgba(88, 68, 180, .13) !important;
}
.profile-hero-cover {
    position: relative;
    height: 245px !important;
    border-radius: 22px 22px 0 0 !important;
    background:
        radial-gradient(circle at 14% 22%, rgba(139,92,246,.28) 0 46px, transparent 47px),
        radial-gradient(circle at 83% 20%, rgba(168,85,247,.18) 0 44px, transparent 45px),
        linear-gradient(116deg, rgba(132,92,246,.66) 0%, rgba(191,219,254,.72) 48%, rgba(252,231,243,.82) 100%) !important;
}
.profile-hero-cover::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 22% 52%, rgba(255,255,255,.92) 0 1px, transparent 2px),
        radial-gradient(circle at 45% 28%, rgba(255,255,255,.78) 0 1px, transparent 2px),
        radial-gradient(circle at 76% 44%, rgba(255,255,255,.72) 0 1px, transparent 2px),
        linear-gradient(145deg, transparent 24%, rgba(255,255,255,.55) 24.2%, transparent 24.6%);
    opacity: .72;
}
.profile-hero-cover.has-image {
    background-image: var(--profile-cover-url) !important;
    background-position: center !important;
    background-size: cover !important;
    background-repeat: no-repeat !important;
}
.profile-hero-cover.has-image::before {
    background: linear-gradient(180deg, rgba(17, 12, 36, .05), rgba(17, 12, 36, .32));
    opacity: 1;
}
.profile-cover-controls {
    position: absolute;
    inset-inline-end: 16px;
    top: 16px;
    z-index: 2;
    display: flex;
    gap: 8px;
}
.profile-cover-action {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    padding: 0 13px;
    border: 1px solid rgba(255,255,255,.6);
    border-radius: 12px;
    background: rgba(20,15,35,.58);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    backdrop-filter: blur(10px);
    cursor: pointer;
}
.profile-cover-action:hover {
    background: rgba(20,15,35,.76);
}
.profile-cover-action.is-danger {
    border: 1px solid rgba(255,255,255,.6);
}
.profile-cover-action.is-loading {
    opacity: .62;
    pointer-events: none;
}
@media (max-width: 767.98px) {
    .profile-cover-controls {
        inset-inline: 10px auto;
        top: 10px;
        gap: 6px;
    }
    .profile-cover-action {
        min-height: 34px;
        padding-inline: 10px;
        border-radius: 10px;
        font-size: 10px;
    }
    .profile-cover-action.is-danger span {
        display: none;
    }
    .profile-cover-action.is-danger {
        width: 34px;
        padding: 0;
    }
}
.profile-hero-body {
    position: relative !important;
    grid-template-columns: minmax(240px, auto) minmax(0, 1fr) 170px !important;
    grid-template-areas: "actions info avatar" !important;
    align-items: end !important;
    gap: 30px !important;
    padding: 0 36px 34px !important;
    margin-top: -58px !important;
    min-height: 150px;
    background: linear-gradient(180deg, rgba(255,255,255,.82), rgba(255,255,255,.94));
}
html[dir="ltr"] .profile-hero-body {
    grid-template-areas: "avatar info actions" !important;
}
.profile-avatar-wrap {
    grid-area: avatar;
    justify-self: center;
    align-self: start;
    width: 164px !important;
    height: auto !important;
    margin-top: -48px;
}
.profile-avatar-image-shell {
    position: relative;
    width: 164px;
    height: 164px;
}
.profile-avatar-cover-controls {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 9px;
}
.profile-avatar-cover-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 11px;
    border: 1px solid color-mix(in srgb, var(--cn-primary) 25%, var(--cn-border));
    border-radius: 10px;
    background: var(--cn-card);
    color: var(--cn-primary);
    box-shadow: 0 7px 18px rgba(88, 68, 180, .10);
    font-size: 10px;
    font-weight: 850;
    white-space: nowrap;
    cursor: pointer;
}
.profile-avatar-cover-action:hover {
    border-color: var(--cn-primary);
    background: var(--cn-primary-soft);
    transform: translateY(-1px);
}
.profile-avatar-cover-action.is-danger {
    width: 34px;
    padding: 0;
    color: #e11d48;
}
@media (max-width: 767.98px) {
    .profile-avatar-image-shell {
        width: 122px;
        height: 122px;
    }
    .profile-avatar-cover-controls {
        margin-top: 7px;
    }
    .profile-avatar-cover-action {
        min-height: 32px;
        padding-inline: 9px;
    }
    .profile-avatar-cover-action.is-danger {
        width: 32px;
    }
}
.profile-avatar-xl {
    width: 164px !important;
    height: 164px !important;
    border: 8px solid rgba(255,255,255,.94) !important;
    box-shadow: 0 24px 50px rgba(88, 68, 180, .20) !important;
}
.profile-online-dot {
    width: 22px !important;
    height: 22px !important;
    right: 20px !important;
    bottom: 22px !important;
    border: 4px solid #fff !important;
}
.profile-main-info {
    grid-area: info;
    text-align: center;
    padding-top: 54px !important;
    display: grid;
    justify-items: center;
    gap: 10px;
}
.profile-title-row {
    justify-content: center !important;
    gap: 10px !important;
}
.profile-title-row h1 {
    font-size: clamp(34px, 3.2vw, 48px) !important;
    line-height: 1.04 !important;
    letter-spacing: 0 !important;
    color: #211733 !important;
}
.profile-chip {
    border-radius: 999px !important;
    font-size: 12px !important;
    min-height: 28px !important;
    padding: 0 12px !important;
    background: color-mix(in srgb, var(--cn-primary-soft) 68%, #fff) !important;
    border: 1px solid color-mix(in srgb, var(--cn-primary) 16%, var(--cn-border)) !important;
}
.profile-chip.is-online {
    color: #049560 !important;
    background: #dcfce7 !important;
    border-color: #bbf7d0 !important;
}
.profile-username {
    color: var(--cn-primary) !important;
    background: color-mix(in srgb, var(--cn-primary-soft) 76%, #fff) !important;
    border-radius: 999px !important;
    padding: 5px 14px !important;
    font-size: 12px !important;
    font-weight: 850 !important;
}
.profile-status,
.profile-bio,
.profile-website,
.profile-last-seen {
    max-width: 680px;
    margin: 0 !important;
    color: #675f77 !important;
    font-size: 14px !important;
    line-height: 1.8 !important;
}
.profile-status {
    display: inline-flex !important;
    align-items: center;
    gap: 7px;
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
}
.profile-actions {
    grid-area: actions;
    align-self: end !important;
    justify-content: flex-start !important;
    padding-top: 0 !important;
    padding-bottom: 10px;
    flex-wrap: wrap;
    gap: 12px !important;
}
html[dir="ltr"] .profile-actions {
    justify-content: flex-end !important;
}
.profile-action-primary,
.profile-action-secondary,
.profile-more-btn {
    min-height: 48px !important;
    border-radius: 9px !important;
    box-shadow: 0 14px 28px rgba(88, 68, 180, .12) !important;
    font-weight: 900 !important;
}
.profile-action-primary {
    padding-inline: 24px !important;
}
.profile-share-btn {
    background: rgba(255,255,255,.82) !important;
}
.profile-more-btn {
    width: 48px !important;
    height: 48px !important;
    background: #fff !important;
}
.profile-stats-v2 {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    margin: 0 34px 34px !important;
    overflow: hidden !important;
    border: 1px solid color-mix(in srgb, var(--cn-primary) 18%, var(--cn-border)) !important;
    border-radius: 14px !important;
    background: rgba(255,255,255,.84) !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.9) !important;
}
.profile-stat-v2 {
    position: relative;
    min-height: 98px !important;
    display: grid !important;
    align-content: center !important;
    justify-items: center !important;
    gap: 5px !important;
    color: #211733 !important;
    text-decoration: none !important;
    background: transparent !important;
    border: 0 !important;
}
.profile-stat-v2:not(:last-child) {
    border-inline-end: 1px solid color-mix(in srgb, var(--cn-primary) 15%, var(--cn-border)) !important;
}
.profile-stat-v2::after {
    content: "\F4D7";
    font-family: bootstrap-icons;
    position: absolute;
    inset-inline-end: 36px;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--cn-primary);
    background: color-mix(in srgb, var(--cn-primary-soft) 74%, #fff);
    font-size: 24px;
}
.profile-stat-v2:nth-child(1)::after { content: "\F38B"; }
.profile-stat-v2:nth-child(2)::after { content: "\F4CF"; }
.profile-stat-v2:nth-child(3)::after { content: "\F4D7"; }
.profile-stat-v2 span {
    font-size: 30px !important;
    font-weight: 950 !important;
    line-height: 1 !important;
}
.profile-stat-v2 small {
    color: #7b7190 !important;
    font-size: 12px !important;
    font-weight: 850 !important;
}
.profile-content-layout {
    grid-template-columns: 370px minmax(0, 1fr) !important;
    gap: 22px !important;
    align-items: start !important;
}
html[dir="rtl"] .profile-content-layout {
    grid-template-columns: minmax(0, 1fr) 370px !important;
}
.profile-info-grid {
    gap: 22px !important;
}
.profile-info-card,
.profile-posts-section,
.profile-private-state {
    border-radius: 14px !important;
    border: 1px solid color-mix(in srgb, var(--cn-primary) 16%, var(--cn-border)) !important;
    background: rgba(255,255,255,.9) !important;
    box-shadow: 0 20px 48px rgba(88, 68, 180, .08) !important;
}
.profile-section-head,
.profile-section-title {
    min-height: 56px;
    margin: -20px -20px 12px !important;
    padding: 0 20px;
    border-bottom: 1px solid color-mix(in srgb, var(--cn-primary) 13%, var(--cn-border));
    display: flex !important;
    align-items: center !important;
    justify-content: space-between;
    color: #211733 !important;
    font-size: 16px !important;
    font-weight: 950 !important;
}
.profile-section-head i,
.profile-section-title i,
.profile-content-tab i {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--cn-primary-soft) 78%, #fff);
    color: var(--cn-primary);
}
.profile-info-list {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 0 !important;
}
.profile-info-item {
    min-height: 54px !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 14px;
    border-bottom: 1px solid color-mix(in srgb, var(--cn-primary) 10%, var(--cn-border-soft)) !important;
}
.profile-info-item:last-child {
    border-bottom: 0 !important;
}
.profile-info-item small {
    color: #948aa7 !important;
    font-size: 13px !important;
    font-weight: 850 !important;
}
.profile-info-item strong {
    color: #211733 !important;
    font-size: 14px !important;
    font-weight: 900 !important;
    text-align: end;
}
.profile-posts-section {
    padding: 0 !important;
    overflow: hidden;
}
.profile-content-tabs {
    height: 64px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-bottom: 1px solid color-mix(in srgb, var(--cn-primary) 14%, var(--cn-border));
    background: rgba(255,255,255,.72);
}
.profile-content-tab {
    position: relative;
    border: 0;
    background: transparent;
    color: #7a7190;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font: inherit;
    font-size: 13px;
    font-weight: 900;
}
.profile-content-tab.active {
    color: var(--cn-primary);
}
.profile-content-tab.active::after {
    content: "";
    position: absolute;
    inset-inline: 22px;
    bottom: 0;
    height: 3px;
    border-radius: 999px 999px 0 0;
    background: var(--cn-primary);
}
.profile-composer-card {
    margin: 22px;
    padding: 18px;
    border: 1px solid color-mix(in srgb, var(--cn-primary) 13%, var(--cn-border));
    border-radius: 14px;
    background: rgba(255,255,255,.86);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
}
.profile-composer-row {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}
.profile-composer-avatar {
    width: 54px;
    height: 54px;
    border-radius: 50%;
}
.profile-composer-main {
    flex: 1;
    min-width: 0;
}
.profile-composer-input {
    min-height: 72px !important;
    border: 0 !important;
    border-bottom: 1px solid color-mix(in srgb, var(--cn-primary) 12%, var(--cn-border)) !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    resize: vertical;
}
.profile-composer-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 12px;
}
.profile-tool-btn {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--cn-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
}
.profile-tool-btn:hover {
    background: var(--cn-primary-soft);
}
.profile-publish-btn {
    margin-inline-start: auto;
    min-height: 42px;
    padding-inline: 22px !important;
    border-radius: 10px !important;
    font-weight: 900 !important;
    box-shadow: 0 12px 24px color-mix(in srgb, var(--cn-primary) 24%, transparent);
}
.profile-image-preview-wrap {
    position: relative;
    display: inline-block;
    margin-top: 12px;
}
.profile-image-preview-wrap img {
    max-height: 220px;
    max-width: 100%;
    border-radius: 14px;
    display: block;
}
.profile-image-preview-wrap button {
    position: absolute;
    top: 8px;
    inset-inline-end: 8px;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(15,23,42,.78);
    color: #fff;
}
.profile-feed-list {
    display: grid;
    gap: 18px;
    padding: 0 22px 22px;
}
.profile-feed-list .post-card {
    margin: 0 !important;
    max-width: none !important;
    border-radius: 14px !important;
    border: 1px solid color-mix(in srgb, var(--cn-primary) 12%, var(--cn-border)) !important;
    box-shadow: 0 16px 34px rgba(88,68,180,.07) !important;
    padding: 18px !important;
}
.profile-feed-list .post-actions {
    justify-content: flex-start !important;
    gap: 18px !important;
}
.profile-empty-state {
    margin: 22px !important;
    min-height: 310px !important;
    border-radius: 16px !important;
    border: 1px dashed color-mix(in srgb, var(--cn-primary) 26%, var(--cn-border)) !important;
    background: linear-gradient(180deg, color-mix(in srgb, var(--cn-primary-soft) 48%, #fff), #fff) !important;
}
[data-theme="dark"] .profile-hero-card,
[data-theme="dark"] .profile-info-card,
[data-theme="dark"] .profile-posts-section,
[data-theme="dark"] .profile-private-state,
[data-theme="dark"] .profile-composer-card {
    background: color-mix(in srgb, var(--cn-card) 88%, #120f1e) !important;
}
[data-theme="dark"] .profile-hero-body {
    background: linear-gradient(180deg, rgba(20,16,38,.86), rgba(20,16,38,.96));
}
[data-theme="dark"] .profile-title-row h1,
[data-theme="dark"] .profile-info-item strong,
[data-theme="dark"] .profile-section-head,
[data-theme="dark"] .profile-section-title {
    color: var(--cn-ink) !important;
}
@media (max-width: 1199.98px) {
    .profile-content-layout,
    html[dir="rtl"] .profile-content-layout {
        grid-template-columns: 330px minmax(0, 1fr) !important;
    }
}
@media (max-width: 991.98px) {
    .profile-page-shell {
        margin-top: 14px !important;
    }
    .profile-hero-body,
    html[dir="ltr"] .profile-hero-body {
        grid-template-columns: 1fr !important;
        grid-template-areas: "avatar" "info" "actions" !important;
        justify-items: center !important;
        text-align: center !important;
        gap: 14px !important;
        padding: 0 18px 24px !important;
    }
    .profile-main-info,
    .profile-actions {
        padding-top: 0 !important;
        justify-content: center !important;
    }
    .profile-content-layout,
    html[dir="rtl"] .profile-content-layout {
        grid-template-columns: 1fr !important;
    }
}
@media (max-width: 767.98px) {
    .profile-page-shell {
        margin: 0 auto 28px !important;
        gap: 14px !important;
    }
    .profile-hero-card {
        border-radius: 16px !important;
    }
    .profile-hero-cover {
        height: 170px !important;
        border-radius: 16px 16px 0 0 !important;
    }
    .profile-avatar-wrap,
    .profile-avatar-xl {
        width: 122px !important;
        height: 122px !important;
    }
    .profile-avatar-wrap {
        margin-top: -20px !important;
    }
    .profile-title-row h1 {
        font-size: 28px !important;
    }
    .profile-actions {
        width: 100%;
    }
    .profile-action-primary,
    .profile-share-btn {
        flex: 1 1 160px;
        justify-content: center;
    }
    .profile-stats-v2 {
        margin: 0 12px 16px !important;
    }
    .profile-stat-v2 {
        min-height: 86px !important;
    }
    .profile-stat-v2::after {
        display: none;
    }
    .profile-content-tabs {
        overflow-x: auto;
        grid-template-columns: repeat(4, minmax(118px, 1fr));
    }
    .profile-content-tab span {
        white-space: nowrap;
    }
    .profile-composer-card,
    .profile-feed-list,
    .profile-empty-state {
        margin: 12px !important;
        padding: 12px !important;
    }
    .profile-feed-list {
        gap: 12px;
    }
    .profile-composer-row {
        gap: 10px;
    }
    .profile-composer-avatar {
        width: 42px;
        height: 42px;
    }
    .profile-composer-toolbar {
        gap: 6px;
    }
    .profile-publish-btn {
        padding-inline: 14px !important;
    }
}


/* Hard fix: profile username must always behave as LTR handle input */
#profile-form .profile-username-input,
#profile-form .profile-username-input * {
    direction: ltr !important;
    unicode-bidi: isolate !important;
}
#profile-form .profile-username-input .form-control,
#profile-form input#id_username {
    direction: ltr !important;
    text-align: left !important;
    unicode-bidi: plaintext !important;
}
#profile-form .profile-username-input .input-group-text {
    order: 0 !important;
    border-radius: 8px 0 0 8px !important;
}
#profile-form .profile-username-input .form-control {
    order: 1 !important;
    border-radius: 0 8px 8px 0 !important;
}


/* Profile RTL/LTR direction hardening */
.profile-page-shell.is-rtl {
    direction: rtl !important;
    text-align: right !important;
}
.profile-page-shell.is-ltr {
    direction: ltr !important;
    text-align: left !important;
}
.profile-page-shell.is-rtl .profile-hero-body {
    grid-template-areas: "actions info avatar" !important;
}
.profile-page-shell.is-ltr .profile-hero-body {
    grid-template-areas: "avatar info actions" !important;
}
.profile-page-shell.is-rtl .profile-main-info,
.profile-page-shell.is-rtl .profile-info-card,
.profile-page-shell.is-rtl .profile-posts-section,
.profile-page-shell.is-rtl .profile-composer-card,
.profile-page-shell.is-rtl .profile-feed-list,
.profile-page-shell.is-rtl .profile-empty-state {
    direction: rtl !important;
    text-align: right !important;
}
.profile-page-shell.is-rtl .profile-title-row,
.profile-page-shell.is-rtl .profile-section-head,
.profile-page-shell.is-rtl .profile-actions,
.profile-page-shell.is-rtl .profile-composer-toolbar,
.profile-page-shell.is-rtl .profile-content-tab,
.profile-page-shell.is-rtl .profile-stat-v2,
.profile-page-shell.is-rtl .post-actions {
    direction: rtl !important;
}
.profile-page-shell.is-rtl .profile-actions {
    justify-content: flex-start !important;
}
.profile-page-shell.is-rtl .profile-username,
.profile-page-shell.is-rtl .profile-website,
.profile-page-shell.is-rtl [dir="ltr"] {
    direction: ltr !important;
    unicode-bidi: isolate !important;
}
.profile-page-shell.is-rtl .profile-username {
    text-align: right !important;
}
.profile-page-shell.is-rtl .profile-website {
    text-align: right !important;
    display: inline-flex;
    flex-direction: row-reverse;
}
.profile-page-shell.is-rtl .dropdown-menu {
    direction: rtl;
    text-align: right;
}
@media (max-width: 991.98px) {
    .profile-page-shell.is-rtl .profile-hero-body,
    .profile-page-shell.is-ltr .profile-hero-body {
        grid-template-areas: "avatar" "info" "actions" !important;
        text-align: center !important;
    }
    .profile-page-shell.is-rtl .profile-main-info,
    .profile-page-shell.is-ltr .profile-main-info {
        text-align: center !important;
    }
    .profile-page-shell.is-rtl .profile-actions,
    .profile-page-shell.is-ltr .profile-actions {
        justify-content: center !important;
    }
}


/* Profile content tabs behavior */
.profile-feed-item.d-none,
.profile-empty-state.d-none,
.profile-composer-card.d-none {
    display: none !important;
}
.profile-content-tab {
    cursor: pointer;
}
.profile-content-tab[aria-selected="true"] {
    color: var(--cn-primary);
}

/* Instagram-style story highlights on profile */
.profile-highlights-strip {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    overflow-x: auto;
    padding: 4px 4px 14px;
}
.profile-highlight-item,
.profile-highlight-create {
    width: 92px;
    flex: 0 0 92px;
    text-align: center;
    color: var(--cn-ink);
}
.profile-highlight-ring,
.profile-highlight-create span {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    border: 2px solid var(--cn-border);
    background: var(--cn-card);
    padding: 3px;
    display: grid;
    place-items: center;
    margin: 0 auto 7px;
    overflow: hidden;
}
.profile-highlight-ring {
    cursor: pointer;
}
.profile-highlight-ring:hover {
    border-color: var(--cn-primary);
}
.profile-highlight-ring img,
.profile-highlight-ring video,
.profile-highlight-ring span {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}
.profile-highlight-create {
    border: 0;
    background: transparent;
    cursor: pointer;
}
.profile-highlight-create span {
    width: 76px;
    height: 76px;
    aspect-ratio: 1;
    flex: 0 0 76px;
    color: var(--cn-primary);
    font-size: 26px;
}
.profile-highlight-name,
.profile-highlight-create strong {
    display: block;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.profile-highlight-meta {
    margin-top: 3px;
    font-size: 10px;
    color: var(--cn-muted);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Shared social/profile composer controls */
.social-emoji-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--cn-border);
    border-radius: 14px;
    background: var(--cn-card);
    box-shadow: var(--cn-shadow-sm);
}
.social-emoji-picker.d-none,
.social-poll-builder.d-none {
    display: none !important;
}
.social-emoji-picker button {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 9px;
    background: var(--cn-bg);
    font-size: 19px;
    cursor: pointer;
}
.social-emoji-picker button:hover {
    background: var(--cn-primary-soft);
    transform: translateY(-1px);
}
.social-poll-builder {
    display: grid;
    gap: 8px;
    margin-top: 10px;
    padding: 12px;
    border: 1px solid var(--cn-border);
    border-radius: 14px;
    background: var(--cn-bg);
}
.social-poll-builder-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.social-poll-builder-head button,
.social-poll-add-option {
    border: 0;
    background: transparent;
    color: var(--cn-primary);
    cursor: pointer;
    font-weight: 700;
}
.social-poll-builder [data-social-poll-options] {
    display: grid;
    gap: 7px;
}

/* Polished shared poll composer (feed + profile) */
form[data-social-composer] .social-poll-builder {
    gap: 12px;
    margin-top: 12px;
    padding: 15px;
    border: 1px solid color-mix(in srgb, var(--cn-primary) 22%, var(--cn-border));
    border-radius: 16px;
    background: linear-gradient(145deg, var(--cn-card), color-mix(in srgb, var(--cn-primary-soft) 35%, var(--cn-card)));
    box-shadow: 0 12px 30px rgba(64, 39, 104, .07);
}
form[data-social-composer] .social-poll-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
form[data-social-composer] .social-poll-title-icon {
    display: grid;
    place-items: center;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    color: var(--cn-primary);
    background: var(--cn-primary-soft);
}
form[data-social-composer] .social-poll-title div {
    display: grid;
    gap: 2px;
}
form[data-social-composer] .social-poll-title strong {
    font-size: 14px;
    color: var(--cn-ink);
}
form[data-social-composer] .social-poll-title small,
form[data-social-composer] .social-poll-limit {
    color: var(--cn-ink-mute);
    font-size: 10px;
}
form[data-social-composer] button.social-poll-close {
    display: grid !important;
    place-items: center;
    flex: 0 0 34px;
    width: 34px !important;
    height: 34px !important;
    padding: 0 !important;
    border: 1px solid var(--cn-border) !important;
    border-radius: 11px !important;
    background: var(--cn-card) !important;
    color: var(--cn-ink-mute) !important;
    box-shadow: 0 5px 14px rgba(30, 20, 50, .06);
}
form[data-social-composer] button.social-poll-close:hover {
    border-color: #fb7185 !important;
    color: #e11d48 !important;
    background: #fff1f2 !important;
    transform: translateY(-1px);
}
form[data-social-composer] .social-poll-builder > .cn-input,
form[data-social-composer] .social-poll-builder [data-social-poll-options] .cn-input {
    min-height: 44px;
    padding-inline: 13px;
    border-radius: 12px !important;
    background: var(--cn-card) !important;
}
form[data-social-composer] .social-poll-builder > .cn-input {
    border-color: color-mix(in srgb, var(--cn-primary) 30%, var(--cn-border)) !important;
    font-weight: 750;
}
form[data-social-composer] button.social-poll-add-option {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 42px;
    padding: 8px 14px !important;
    border: 1px dashed color-mix(in srgb, var(--cn-primary) 55%, var(--cn-border)) !important;
    border-radius: 12px !important;
    background: color-mix(in srgb, var(--cn-primary-soft) 58%, transparent) !important;
    color: var(--cn-primary) !important;
    font-size: 12px;
}
form[data-social-composer] button.social-poll-add-option span {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    color: #fff;
    background: var(--cn-primary);
}
form[data-social-composer] button.social-poll-add-option:hover {
    background: var(--cn-primary-soft) !important;
    transform: translateY(-1px);
}
form[data-social-composer] button.social-poll-add-option:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
}
form[data-social-composer] .social-poll-limit {
    text-align: end;
    margin-top: -7px;
}
.social-post-poll {
    margin: 12px 16px;
    padding: 14px;
    border: 1px solid var(--cn-border);
    border-radius: 16px;
    background: var(--cn-bg);
}
.social-post-poll-question {
    display: block;
    margin-bottom: 10px;
}
.social-post-poll-options {
    display: grid;
    gap: 7px;
}
.social-post-poll-options button {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--cn-border);
    border-radius: 11px;
    background: var(--cn-card);
    color: var(--cn-ink);
    cursor: pointer;
}
.social-post-poll-options button:hover,
.social-post-poll-options button.selected {
    border-color: var(--cn-primary);
    background: var(--cn-primary-soft);
}
.social-post-poll > small {
    display: block;
    margin-top: 9px;
    color: var(--cn-ink-mute);
}
.profile-highlight-actions {
    margin-top: 5px;
    display: inline-flex;
    gap: 4px;
}
.profile-highlight-actions button {
    width: 24px;
    height: 24px;
    border: 1px solid var(--cn-border);
    border-radius: 8px;
    background: var(--cn-card);
    color: var(--cn-muted);
    display: grid;
    place-items: center;
}
.highlight-manager-modal {
    border: 0;
    border-radius: 18px;
    overflow: hidden;
}
.highlight-picker-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 800;
}
.highlight-story-picker {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    max-height: 360px;
    overflow: auto;
}
.highlight-story-choice {
    position: relative;
    min-width: 0;
    cursor: pointer;
}
.highlight-story-choice input {
    position: absolute;
    inset-inline-start: 7px;
    top: 7px;
    z-index: 2;
}
.highlight-story-choice span {
    display: block;
    aspect-ratio: 9/16;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid transparent;
    background: var(--cn-soft);
}
.highlight-story-choice input:checked + span {
    border-color: var(--cn-primary);
}
.highlight-story-choice img,
.highlight-story-choice video,
.highlight-story-choice i {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.highlight-story-choice em {
    display: block;
    margin-top: 4px;
    font-size: 10px;
    color: var(--cn-muted);
    font-style: normal;
    text-align: center;
}
.profile-highlight-viewer {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: #000;
    align-items: center;
    justify-content: center;
}
.phv-shell {
    position: relative;
    width: min(420px, 100vw);
    height: 100vh;
    overflow: hidden;
    background: #050505;
}
.phv-progress {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 4;
    display: flex;
    gap: 4px;
}
.phv-progress span {
    flex: 1;
    height: 3px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255,255,255,.28);
}
.phv-progress b {
    display: block;
    height: 100%;
    width: 0;
    background: #fff;
}
.phv-header {
    position: absolute;
    top: 24px;
    left: 14px;
    right: 56px;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
}
.phv-header strong,
.phv-header small {
    display: block;
    line-height: 1.2;
}
.phv-header small {
    color: rgba(255,255,255,.65);
}
.phv-close {
    position: absolute;
    top: 22px;
    right: 12px;
    z-index: 5;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: rgba(0,0,0,.36);
    color: #fff;
}
.phv-content,
.phv-media,
.phv-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.phv-media {
    object-fit: cover;
}
.phv-text {
    position: absolute;
    transform: translate(-50%,-50%);
    max-width: 80%;
    padding: 8px 14px;
    border-radius: 12px;
    background: rgba(0,0,0,.25);
    color: #fff;
    font-weight: 800;
    white-space: pre-wrap;
    text-align: center;
    z-index: 3;
}
.phv-nav {
    position: absolute;
    top: 20%;
    bottom: 16%;
    width: 50%;
    z-index: 3;
    border: 0;
    background: transparent;
}
.phv-prev { left: 0; }
.phv-next { right: 0; }
.phv-viewers-btn {
    position: absolute;
    left: 14px;
    bottom: 18px;
    z-index: 5;
    border: 0;
    border-radius: 999px;
    padding: 9px 14px;
    background: rgba(255,255,255,.92);
    color: #111;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.story-viewers-panel {
    position: fixed;
    inset: 0;
    z-index: 10020;
    background: rgba(0,0,0,.45);
    display: grid;
    place-items: end center;
}
.story-viewers-card {
    width: min(420px, 100%);
    max-height: 72vh;
    background: var(--cn-card);
    border-radius: 20px 20px 0 0;
    overflow: hidden;
    box-shadow: 0 -18px 50px rgba(0,0,0,.28);
}
.story-viewers-head {
    height: 54px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--cn-border);
}
.story-viewers-head button {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: var(--cn-soft);
    color: var(--cn-ink);
}
.story-viewers-list {
    max-height: calc(72vh - 54px);
    overflow: auto;
    padding: 8px;
}
.story-viewers-list a {
    display: grid;
    grid-template-columns: 42px 1fr;
    column-gap: 10px;
    padding: 8px;
    border-radius: 12px;
    color: var(--cn-ink);
    text-decoration: none;
}
.story-viewers-list a:hover {
    background: var(--cn-soft);
}
.story-viewers-list img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    grid-row: span 2;
}
.story-viewers-list span {
    font-weight: 800;
}
.story-viewers-list small,
.story-viewers-empty {
    color: var(--cn-muted);
    font-size: 12px;
}

/* Profile tabs must fit mobile width without horizontal page scroll */
@media (max-width: 767.98px) {
    .profile-content-tabs {
        width: 100% !important;
        min-width: 0 !important;
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        overflow: hidden !important;
        height: 54px !important;
    }
    .profile-content-tab {
        min-width: 0 !important;
        padding: 0 4px !important;
        gap: 0 !important;
        font-size: 12px !important;
        line-height: 1.2 !important;
    }
    .profile-content-tab i {
        display: none !important;
    }
    .profile-content-tab span {
        max-width: 100% !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    .profile-content-tab.active::after {
        inset-inline: 12px !important;
    }
    .profile-posts-section {
        overflow: hidden !important;
    }
}


/* Global inline media/text vertical alignment */
a:has(> i),
a:has(> svg),
a:has(> img),
button:has(> i),
button:has(> svg),
button:has(> img),
label:has(> i),
label:has(> svg),
label:has(> img),
.btn:has(> i),
.btn:has(> svg),
.btn:has(> img),
.dropdown-item:has(> i),
.dropdown-item:has(> svg),
.dropdown-item:has(> img),
.btn-cn,
.btn-cn-outline,
.btn-cn-soft,
.geo-btn,
.post-action-btn,
.social-nav-link,
.social-panel-action,
.social-result-action,
.theme-picker-item,
.mobile-more-link,
.profile-action-primary,
.profile-action-secondary,
.profile-publish-btn,
.social-accepted-label {
    align-items: center !important;
}
.btn-cn,
.btn-cn-outline,
.btn-cn-soft,
.geo-btn,
.profile-action-primary,
.profile-action-secondary,
.profile-publish-btn,
.social-accepted-label {
    display: inline-flex !important;
    justify-content: center;
    gap: .42rem;
}
a > i,
a > svg,
a > img,
button > i,
button > svg,
button > img,
label > i,
label > svg,
label > img,
.btn > i,
.btn > svg,
.btn > img,
.dropdown-item > i,
.dropdown-item > svg,
.dropdown-item > img,
.btn-cn > i,
.btn-cn-outline > i,
.btn-cn-soft > i,
.geo-btn > i,
.post-action-btn > i,
.social-nav-link > i,
.profile-action-primary > i,
.profile-action-secondary > i,
.profile-publish-btn > i,
.social-accepted-label > i {
    align-self: center !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    vertical-align: middle !important;
    flex: 0 0 auto;
}
.geo-btn span,
.btn-cn span,
.btn-cn-outline span,
.btn-cn-soft span,
.post-action-btn span,
.social-nav-link span,
.profile-action-primary span,
.profile-action-secondary span,
.profile-publish-btn span {
    line-height: 1.2;
}


/* Navbar brand should never get a hover/focus background */
.cn-navbar .navbar-brand,
.cn-navbar .navbar-brand:hover,
.cn-navbar .navbar-brand:focus,
.cn-navbar .navbar-brand:active,
body.chat-open .cn-navbar .navbar-brand:hover,
body.chat-open .cn-navbar .navbar-brand:focus {
    background: transparent !important;
    box-shadow: none !important;
    transform: none !important;
    outline: 0 !important;
}
.cn-navbar .navbar-brand:hover .brand-icon,
.cn-navbar .navbar-brand:focus .brand-icon {
    filter: none !important;
}


/* Mobile navbar user menu: fixed trigger, no ugly selected outline */
@media (max-width: 767.98px) {
    .cn-navbar .navbar-nav > .nav-item.dropdown:has(> .dropdown-toggle .cn-avatar) {
        position: relative !important;
        flex: 0 0 auto !important;
    }
    .cn-navbar .navbar-nav > .nav-item.dropdown > .dropdown-toggle:has(.cn-avatar) {
        position: relative !important;
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        max-width: 38px !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0 !important;
        overflow: hidden !important;
        color: transparent !important;
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        outline: 0 !important;
    }
    .cn-navbar .navbar-nav > .nav-item.dropdown > .dropdown-toggle:has(.cn-avatar):hover,
    .cn-navbar .navbar-nav > .nav-item.dropdown > .dropdown-toggle:has(.cn-avatar):focus,
    .cn-navbar .navbar-nav > .nav-item.dropdown > .dropdown-toggle:has(.cn-avatar):focus-visible,
    .cn-navbar .navbar-nav > .nav-item.dropdown > .dropdown-toggle:has(.cn-avatar)[aria-expanded="true"] {
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        outline: 0 !important;
    }
    .cn-navbar .navbar-nav > .nav-item.dropdown > .dropdown-toggle:has(.cn-avatar)::after {
        display: none !important;
    }
    .cn-navbar .navbar-nav > .nav-item.dropdown > .dropdown-toggle:has(.cn-avatar) .cn-avatar {
        position: absolute !important;
        inset: 1px !important;
        width: 36px !important;
        height: 36px !important;
        margin: 0 !important;
        color: initial !important;
        box-shadow: 0 0 0 2px var(--cn-card) !important;
    }
    .cn-navbar .navbar-nav > .nav-item.dropdown > .dropdown-menu {
        position: absolute !important;
        top: calc(100% + 8px) !important;
        inset-inline-start: auto !important;
        inset-inline-end: 0 !important;
        margin: 0 !important;
        min-width: 158px !important;
        transform: none !important;
    }
}

/* Final mobile chat viewport override. Keep this at the end of the stylesheet. */
@media (max-width: 991.98px) {
    html.chat-open,
    body.chat-open {
        width: 100%;
        height: var(--mx-viewport-height) !important;
        min-height: var(--mx-viewport-height) !important;
        max-height: var(--mx-viewport-height) !important;
        overflow: hidden !important;
        overscroll-behavior: none;
    }

    body.chat-conversation-open {
        position: fixed;
        inset: 0;
        padding-bottom: 0 !important;
    }

    body.chat-conversation-open main.chat-page-wrapper {
        height: var(--mx-chat-height) !important;
        min-height: 0 !important;
        max-height: var(--mx-chat-height) !important;
        overflow: hidden !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    body.chat-conversation-open .chat-shell,
    body.chat-conversation-open .chat-main,
    body.chat-conversation-open .chat-container,
    body.chat-conversation-open .chat-container-embedded {
        height: 100% !important;
        min-height: 0 !important;
        max-height: 100% !important;
        overflow: hidden !important;
    }

    body.chat-conversation-open .chat-shell {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        width: 100% !important;
    }

    body.chat-conversation-open .chat-main {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    body.chat-conversation-open .chat-container {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
    }

    body.chat-conversation-open .chat-header,
    body.chat-conversation-open .chat-input-area {
        flex: 0 0 auto !important;
    }

    body.chat-conversation-open .chat-messages {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 12px !important;
    }

    body.chat-conversation-open .chat-input-area {
        padding: 8px max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)) !important;
        transform: translateZ(0);
    }

    body.chat-conversation-open .chat-composer-row {
        width: 100% !important;
        min-width: 0 !important;
        gap: 6px !important;
    }

    body.chat-conversation-open .chat-composer-row .chat-input {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    body.chat-conversation-open .chat-composer-row .chat-input-action,
    body.chat-conversation-open .chat-composer-row .chat-send-btn {
        flex: 0 0 40px !important;
        width: 40px !important;
        height: 40px !important;
        min-height: 40px !important;
    }
}

/* Chrome Android keeps changing the visible viewport while its bottom toolbar
   appears/disappears. Pin the composer to the visual viewport and reserve its
   space in the scroll area so it cannot disappear under browser controls. */
@media (max-width: 991.98px) {
    body.chat-conversation-open .chat-container {
        position: relative !important;
    }

    body.chat-conversation-open .chat-messages {
        height: calc(var(--mx-chat-height) - var(--mx-chat-header-height) - var(--mx-composer-height)) !important;
        max-height: calc(var(--mx-chat-height) - var(--mx-chat-header-height) - var(--mx-composer-height)) !important;
        flex: 0 1 auto !important;
        padding-bottom: calc(var(--mx-composer-height) + 14px) !important;
    }

    body.chat-conversation-open .chat-input-area {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: max(0px, env(safe-area-inset-bottom)) !important;
        z-index: 1055 !important;
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
        border-top: 1px solid var(--cn-border) !important;
        box-shadow: 0 -8px 22px rgba(15, 23, 42, .08) !important;
    }

    body.chat-conversation-open .chat-input-area .dropdown-menu {
        max-height: min(58vh, 360px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Profile feed posts: mobile-safe card/actions. Keep at stylesheet end so it
   wins over shared social action rules. */
@media (max-width: 767.98px) {
    .profile-posts-section,
    .profile-feed-list,
    .profile-feed-item,
    .profile-feed-list .post-card,
    .profile-feed-list .social-post-card {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    .profile-posts-section {
        overflow: hidden !important;
    }

    .profile-posts-section .profile-content-tabs {
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        width: 100% !important;
        min-width: 0 !important;
        height: 48px !important;
        overflow: hidden !important;
    }

    .profile-posts-section .profile-content-tab {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        padding: 0 2px !important;
        gap: 0 !important;
        font-size: 11px !important;
        line-height: 1.15 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        overflow: hidden !important;
    }

    .profile-posts-section .profile-content-tab i {
        display: none !important;
    }

    .profile-posts-section .profile-content-tab span {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        text-align: center !important;
    }

    .profile-posts-section .profile-content-tab.active::after,
    .profile-posts-section .profile-content-tab[aria-selected="true"]::after {
        inset-inline: 8px !important;
        height: 3px !important;
    }

    .profile-feed-list {
        margin: 0 !important;
        padding: 10px !important;
        gap: 10px !important;
        overflow: hidden !important;
    }

    .profile-feed-list .post-card {
        padding: 12px !important;
        overflow: hidden !important;
        border-radius: 12px !important;
    }

    .profile-feed-list .social-post-header {
        display: flex !important;
        align-items: flex-start !important;
        gap: 8px !important;
        min-width: 0 !important;
    }

    .profile-feed-list .social-post-author {
        min-width: 0 !important;
        overflow: hidden !important;
    }

    .profile-feed-list .social-post-author-name,
    .profile-feed-list .social-post-author > div,
    .profile-feed-list .social-post-time {
        display: block !important;
        max-width: 100% !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    .profile-feed-list .social-post-actions {
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        gap: 4px !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    .profile-feed-list .social-post-actions .post-action-btn {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        flex: initial !important;
        padding: 0 4px !important;
        gap: 4px !important;
        justify-content: center !important;
    }

    .profile-feed-list .social-post-actions .post-action-label {
        display: none !important;
        width: 0 !important;
        max-width: 0 !important;
        overflow: hidden !important;
        font-size: 0 !important;
    }

    .profile-feed-list .social-post-actions .like-count,
    .profile-feed-list .social-post-actions .repost-count,
    .profile-feed-list .social-post-actions .post-action-btn > span:not(.post-action-label),
    .profile-feed-list .social-post-actions .post-action-btn > i {
        flex: 0 0 auto !important;
    }
}

/* Profile desktop/tablet grid: posts own the flexible column and the personal
   information sidebar stays compact. Explicit placement prevents RTL auto-flow
   from swapping the fixed and flexible columns at the 1200px breakpoint. */
@media (min-width: 992px) {
    .profile-page-shell.is-rtl .profile-content-layout {
        grid-template-columns: minmax(0, 1fr) 285px !important;
    }
    .profile-page-shell.is-rtl .profile-info-grid {
        grid-column: 2 !important;
    }
    .profile-page-shell.is-rtl .profile-posts-section,
    .profile-page-shell.is-rtl .profile-private-state {
        grid-column: 1 !important;
    }
    .profile-page-shell.is-ltr .profile-content-layout {
        grid-template-columns: 285px minmax(0, 1fr) !important;
    }
    .profile-page-shell.is-ltr .profile-info-grid {
        grid-column: 1 !important;
    }
    .profile-page-shell.is-ltr .profile-posts-section,
    .profile-page-shell.is-ltr .profile-private-state {
        grid-column: 2 !important;
    }
}
@media (min-width: 992px) and (max-width: 1199.98px) {
    .profile-page-shell.is-rtl .profile-content-layout {
        grid-template-columns: minmax(0, 1fr) 255px !important;
    }
    .profile-page-shell.is-ltr .profile-content-layout {
        grid-template-columns: 255px minmax(0, 1fr) !important;
    }
}

/* Mobile chat header menus must float above the message scroller. */
@media (max-width: 991.98px) {
    body.chat-conversation-open .chat-header {
        position: relative !important;
        z-index: 1070 !important;
        overflow: visible !important;
        isolation: isolate;
    }

    body.chat-conversation-open .chat-header-more,
    body.chat-conversation-open .chat-header .dropdown {
        position: relative !important;
        z-index: 1071 !important;
    }

    body.chat-conversation-open .chat-header .dropdown-menu {
        z-index: 1080 !important;
        box-shadow: 0 18px 42px rgba(15, 23, 42, .18) !important;
    }

    body.chat-conversation-open .chat-messages {
        position: relative !important;
        z-index: 1 !important;
    }
}

.message-status {
    margin-inline-start: 3px;
    font-size: 12px;
    line-height: 1;
    color: var(--cn-ink-mute);
}
.message-status.status-sending {
    opacity: .75;
}
.message-status.status-sent,
.message-status.status-delivered {
    color: #D9DDE7;
}
.msg-bubble.received .message-status.status-sent,
.msg-bubble.received .message-status.status-delivered {
    color: var(--cn-ink-mute);
}
.message-status.status-seen {
    color: #21C063;
}

/* Final annotation fixes: mobile chat overlays, social actions, security lock, QR. */
.chat-container,
.chat-container-embedded {
    position: relative;
}
.chat-search-overlay {
    position: absolute !important;
    top: var(--mx-chat-header-height, 56px) !important;
    inset-inline: 0 !important;
    z-index: 1065 !important;
    max-height: min(44vh, 320px) !important;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
}
@media (max-width: 991.98px) {
    body.chat-conversation-open .chat-search-overlay {
        top: var(--mx-chat-header-height, 56px) !important;
    }
    body.chat-conversation-open .chat-search-bar {
        padding: 8px 14px !important;
    }
    body.chat-conversation-open .chat-search-empty {
        padding: 18px 12px !important;
    }
    .chat-mute-menu {
        width: min(320px, calc(100vw - 24px));
        max-width: calc(100vw - 24px);
        border-radius: 14px;
        box-shadow: 0 18px 44px rgba(15, 23, 42, .16);
    }
}

@media (max-width: 767.98px) {
    .social-post-actions {
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        gap: 3px !important;
        width: 100% !important;
        min-width: 0 !important;
        overflow: visible !important;
    }
    .social-post-actions .post-action-btn {
        min-width: 0 !important;
        width: 100% !important;
        padding: 0 2px !important;
        gap: 3px !important;
        font-size: 10.5px !important;
        justify-content: center !important;
    }
    .social-post-actions .post-action-label {
        display: inline-flex !important;
        min-width: 0 !important;
        max-width: 42px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        font-size: 10px !important;
    }
    .profile-feed-list .social-post-actions .post-action-label {
        display: none !important;
        width: 0 !important;
        max-width: 0 !important;
        overflow: hidden !important;
        font-size: 0 !important;
    }
}

.security-lock-status {
    align-items: flex-start;
}
.security-lock-status small {
    display: block;
    line-height: 1.7;
}
.security-lock-actions .btn-cn,
.security-lock-actions .btn-cn-secondary,
.security-lock-actions .btn-cn-outline {
    min-height: 42px;
    border-radius: 12px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-weight: 800;
}
#sl-lock-now {
    background: var(--cn-border-soft) !important;
    border: 1px solid var(--cn-border) !important;
    color: var(--cn-ink) !important;
    box-shadow: none !important;
}
#sl-lock-now:hover {
    background: var(--cn-primary-soft) !important;
    color: var(--cn-primary) !important;
}

.qr-modal-content {
    position: relative;
}
.qr-modal-close {
    position: absolute;
    top: 14px;
    inset-inline-start: 14px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--cn-ink-mute);
    display: grid;
    place-items: center;
}
.qr-modal-close:hover {
    background: var(--cn-border-soft);
    color: var(--cn-ink);
}
#qr-download-btn {
    width: 100%;
    min-height: 44px;
    border-radius: 12px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-weight: 800;
}

@media (max-width: 767.98px) {
    .profile-feed-list .social-post-actions .post-action-label {
        display: none !important;
        width: 0 !important;
        max-width: 0 !important;
        overflow: hidden !important;
        font-size: 0 !important;
    }
}

/* ───────────────────────────────────────────────────────────────
   Rich-text message formatting (bold/italic/underline/strike/
   spoiler/code). Markup is rendered by social.mentions_hashtags
   linkify(rich=True) and static/js/text_format.js.
─────────────────────────────────────────────────────────────── */
.msg-text strong { font-weight: 700; }
.msg-text em { font-style: italic; }
.msg-text u { text-decoration: underline; }
.msg-text s { text-decoration: line-through; opacity: .8; }
.msg-text code.msg-code {
    font-family: 'Fira Code', Consolas, monospace;
    font-size: .9em;
    background: rgba(127,127,127,.18);
    padding: .1em .35em;
    border-radius: 5px;
    direction: ltr;
    unicode-bidi: plaintext;
}
.msg-text pre.msg-pre {
    font-family: 'Fira Code', Consolas, monospace;
    font-size: .88em;
    background: rgba(127,127,127,.16);
    padding: .55em .7em;
    border-radius: 9px;
    margin: .3em 0;
    overflow-x: auto;
    white-space: pre;
    direction: ltr;
    unicode-bidi: plaintext;
}
.msg-text .msg-spoiler {
    background: currentColor;
    color: inherit;
    border-radius: 4px;
    cursor: pointer;
    transition: background .2s ease;
    /* Hide the text until revealed by blending it into a solid block */
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}
.msg-text .msg-spoiler:not(.revealed) {
    filter: blur(0);
    position: relative;
    color: transparent !important;
}
.msg-text .msg-spoiler:not(.revealed)::selection { background: transparent; }
.msg-text .msg-spoiler.revealed {
    background: rgba(127,127,127,.15);
    color: inherit;
    cursor: default;
}

/* ── Composer: formatting toolbar + schedule popup (Phase 1) ── */
/* Collapsed into one icon (#fmt-toggle); the bar opens as a popover above it. */
.chat-composer-row { position: relative; }
.chat-format-bar {
    display: none;
    position: absolute;
    bottom: calc(100% + 10px);
    inset-inline-start: 6px;
    gap: 3px;
    align-items: center;
    background: var(--cn-card, #fff);
    border: 1px solid var(--cn-border, #e5e5ea);
    border-radius: 12px;
    padding: 5px;
    box-shadow: 0 10px 30px rgba(0,0,0,.18);
    z-index: 1300;
}
.chat-format-bar.show { display: flex; }
#fmt-toggle.active { background: var(--cn-primary-soft, #eee); color: var(--cn-primary, #6C5CE7); }
/* Attach/options menu must sit above the composer, format popover and bubbles. */
.chat-composer-row .dropdown-menu { z-index: 1500; }

/* Chat attachments: compact preview and a clear two-column action sheet. */
.chat-input-area {
    gap: 8px;
}
.chat-attachment-preview {
    display: flex;
    align-items: center;
    gap: 11px;
    max-width: 430px;
    min-height: 72px;
    margin: 0;
    padding: 7px 9px;
    border: 1px solid color-mix(in srgb, var(--cn-primary) 24%, var(--cn-border));
    border-radius: 14px;
    background: color-mix(in srgb, var(--cn-primary-soft) 30%, var(--cn-card));
    box-shadow: 0 8px 22px rgba(42, 25, 72, .07);
}
.chat-attachment-preview.d-none {
    display: none !important;
}
.chat-attachment-preview-image {
    width: 56px;
    height: 56px;
    flex: 0 0 56px;
    border-radius: 10px;
    object-fit: cover;
    background: var(--cn-bg);
}
.chat-attachment-preview-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    flex: 0 0 56px;
    border-radius: 10px;
    background: var(--cn-primary-soft);
    color: var(--cn-primary);
    font-size: 23px;
}
.chat-attachment-preview-copy {
    display: grid;
    gap: 3px;
    min-width: 0;
    flex: 1;
}
.chat-attachment-preview-copy strong {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--cn-ink);
    font-size: 12px;
}
.chat-attachment-preview-copy strong i {
    color: var(--cn-primary);
}
.chat-attachment-preview-copy small {
    color: var(--cn-ink-mute);
    font-size: 10px;
}
.chat-attachment-preview-remove {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    padding: 0;
    border: 1px solid color-mix(in srgb, #e11d48 22%, var(--cn-border));
    border-radius: 10px;
    background: var(--cn-card);
    color: #e11d48;
    cursor: pointer;
}
.chat-attachment-preview-remove:hover {
    background: #fff1f2;
    border-color: #fb7185;
}
.chat-composer-row .chat-attach-menu,
.chat-composer-row .chat-attach-menu.show {
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    width: min(340px, calc(100vw - 28px));
    padding: 10px;
    border: 1px solid color-mix(in srgb, var(--cn-primary) 18%, var(--cn-border)) !important;
    border-radius: 16px !important;
    background: color-mix(in srgb, var(--cn-card) 96%, transparent);
    box-shadow: 0 18px 50px rgba(31, 20, 52, .18);
    backdrop-filter: blur(18px);
}
.chat-composer-row .chat-attach-menu.show {
    display: grid;
}
.chat-attach-menu > li {
    min-width: 0;
}
.chat-attach-menu > li:has(.dropdown-divider) {
    grid-column: 1 / -1;
    height: 1px;
}
.chat-attach-menu .dropdown-divider {
    margin: 0;
    border-color: var(--cn-border);
}
.chat-attach-menu .dropdown-item {
    display: flex !important;
    align-items: center;
    gap: 9px;
    width: 100%;
    min-height: 44px;
    padding: 7px 9px;
    border: 1px solid transparent;
    border-radius: 11px;
    color: var(--cn-ink);
    font-size: 11px;
    font-weight: 750;
    white-space: normal;
}
.chat-attach-menu .dropdown-item > i {
    display: grid !important;
    place-items: center;
    width: 30px;
    height: 30px;
    margin: 0 !important;
    flex: 0 0 30px;
    border-radius: 9px;
    background: var(--cn-primary-soft);
    color: var(--cn-primary);
    font-size: 14px;
}
.chat-attach-menu .dropdown-item:hover,
.chat-attach-menu .dropdown-item:focus {
    border-color: color-mix(in srgb, var(--cn-primary) 20%, var(--cn-border));
    background: var(--cn-primary-soft);
    color: var(--cn-primary);
}
@media (max-width: 600px) {
    .chat-attachment-preview {
        max-width: 100%;
        min-height: 64px;
    }
    .chat-attachment-preview-image {
        width: 50px;
        height: 50px;
        flex-basis: 50px;
    }
    .chat-attachment-preview-icon {
        width: 50px;
        height: 50px;
        flex-basis: 50px;
    }
    .chat-composer-row .chat-attach-menu,
    .chat-composer-row .chat-attach-menu.show {
        width: min(330px, calc(100vw - 20px));
    }
}
.chat-format-bar .fmt-btn {
    width: 30px; height: 30px;
    border: none; background: transparent;
    color: var(--cn-ink-soft, #888);
    border-radius: 8px; cursor: pointer;
    font-size: 13px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s ease, color .15s ease;
}
.chat-format-bar .fmt-btn:hover { background: rgba(127,127,127,.15); color: var(--cn-primary, #6C5CE7); }
.dropdown-item.active #silent-state { color: var(--cn-primary, #6C5CE7); font-weight: 700; }

.schedule-pop {
    position: fixed; inset: 0; z-index: 3000;
    background: rgba(0,0,0,.45);
    display: flex; align-items: center; justify-content: center;
}
.schedule-card {
    background: var(--cn-card, #fff); color: var(--cn-ink, #111);
    border-radius: 16px; padding: 18px; width: min(340px, 92vw);
    box-shadow: 0 18px 50px rgba(0,0,0,.3);
}
.schedule-card .schedule-title { font-weight: 700; margin-bottom: 12px; }
.schedule-card input[type="text"],
.schedule-card input[type="time"] {
    width: 100%; padding: 9px 11px; border-radius: 10px;
    border: 1px solid var(--cn-border, #ddd);
    background: var(--cn-bg, #fff); color: inherit;
}
.schedule-card .schedule-actions {
    display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px;
}

@media (max-width: 600px) {
    .chat-format-bar { display: none; }  /* keep mobile composer compact */
}

/* Final mobile ergonomics pass: no accidental zoom, larger touch targets,
   and a keyboard-safe composer. Keep this block last. */
@media (max-width: 767.98px) {
    html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
        touch-action: manipulation;
    }

    body {
        overflow-x: hidden;
        -webkit-tap-highlight-color: rgba(108, 92, 231, .14);
    }

    input,
    textarea,
    select,
    button {
        font-size: 16px;
    }

    .btn,
    .btn-cn,
    .btn-cn-outline,
    .btn-cn-soft,
    .nav-link,
    .dropdown-item,
    .social-nav-link,
    .mobile-bottom-link,
    .mobile-more-link,
    .chat-input-action,
    .chat-send-btn,
    .profile-action-btn,
    .profile-more-btn {
        min-height: 44px;
        touch-action: manipulation;
    }

    .cn-navbar .navbar-brand {
        font-size: 1.22rem;
    }

    .cn-navbar .nav-link,
    .dropdown-item,
    .social-nav-link,
    .mobile-more-link {
        font-size: .98rem;
    }

    .cn-card,
    .post-card,
    .social-post-card,
    .profile-card {
        border-radius: 18px;
    }

    .chat-header {
        min-height: 60px;
        padding-block: 10px;
    }

    .chat-input-area {
        padding-block: 10px !important;
    }

    .chat-composer-row {
        gap: 8px !important;
    }

    .chat-composer-row .chat-input {
        min-height: 46px !important;
        max-height: 132px !important;
        font-size: 16px !important;
        line-height: 1.55 !important;
        padding: 11px 14px !important;
    }

    .chat-composer-row .chat-input-action,
    .chat-composer-row .chat-send-btn {
        flex-basis: 44px !important;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        font-size: 18px !important;
    }

    .chat-messages {
        scroll-padding-bottom: calc(var(--mx-composer-height, 64px) + env(safe-area-inset-bottom) + 18px);
    }
}

@media (max-width: 991.98px) {
    html[data-keyboard-open] body.chat-conversation-open .chat-input-area {
        bottom: max(var(--mx-keyboard-inset, 0px), env(safe-area-inset-bottom)) !important;
    }

    html[data-keyboard-open] body.chat-conversation-open .chat-messages {
        height: calc(var(--mx-viewport-height) - var(--mx-chat-header-height) - var(--mx-composer-height)) !important;
        max-height: calc(var(--mx-viewport-height) - var(--mx-chat-header-height) - var(--mx-composer-height)) !important;
        padding-bottom: calc(var(--mx-composer-height) + 18px) !important;
    }
}

/* ── Channel post comments (Discussion) ── */
.cp-comments-toggle { cursor: pointer; display: inline-flex; align-items: center; gap: 3px; }
.cp-comments-toggle:hover { color: var(--cn-primary, #6C5CE7); }
.cp-comments { margin-top: 10px; border-top: 1px solid var(--cn-border, #eee); padding-top: 10px; }
.cpc-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.cpc-item { display: flex; gap: 8px; align-items: flex-start; }
.cpc-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex: 0 0 30px; }
.cpc-avatar-ph { display: flex; align-items: center; justify-content: center;
    background: var(--cn-primary-soft, #eee); color: var(--cn-primary, #6C5CE7);
    font-weight: 700; text-transform: uppercase; }
.cpc-body { flex: 1; min-width: 0; }
.cpc-head { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.cpc-head b { color: var(--cn-ink, #111); }
.cpc-time { color: var(--cn-ink-mute, #999); font-size: 10px; }
.cpc-del { margin-inline-start: auto; background: transparent; border: none;
    color: var(--cn-danger, #e74c3c); cursor: pointer; padding: 0 4px; font-size: 11px; }
.cpc-text { font-size: 13px; color: var(--cn-ink, #111); word-break: break-word; }
.cpc-empty, .cpc-locked { text-align: center; color: var(--cn-ink-mute, #999); font-size: 12px; padding: 6px; }
.cpc-form { display: flex; gap: 6px; }
.cpc-input { flex: 1; border: 1px solid var(--cn-border, #ddd); border-radius: 20px;
    padding: 7px 14px; background: var(--cn-bg, #fff); color: inherit; font-size: 13px; }
.cpc-send { border: none; background: var(--cn-primary, #6C5CE7); color: #fff;
    border-radius: 20px; padding: 7px 16px; cursor: pointer; font-size: 13px; }

/* ── Scheduled channel posts UI ── */
.cp-schedule-hint { margin-top: 8px; font-size: 12px; color: var(--cn-primary, #6C5CE7);
    display: flex; align-items: center; gap: 6px; }
.cp-schedule-hint button { background: transparent; border: none; color: var(--cn-danger, #e74c3c);
    cursor: pointer; font-size: 15px; line-height: 1; }
.sched-list { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 12px;
    max-height: 50vh; overflow-y: auto; }
.sched-row { display: flex; align-items: center; gap: 10px;
    border: 1px solid var(--cn-border, #eee); border-radius: 10px; padding: 8px 10px; }
.sched-info { flex: 1; min-width: 0; }
.sched-when { font-size: 12px; font-weight: 700; color: var(--cn-primary, #6C5CE7); }
.sched-text { font-size: 12px; color: var(--cn-ink-mute, #888);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sched-ops { display: flex; gap: 6px; flex: 0 0 auto; }

/* ── Composer format toolbar + schedule popup (dm/room) ── */
/* (display handled by the popover rule above — do not force flex here) */
.fmt-btn { width: 28px; height: 28px; border: none; background: transparent;
    color: var(--cn-ink-mute, #888); border-radius: 6px; cursor: pointer; font-size: 13px; line-height: 1; }
.fmt-btn:hover { background: var(--cn-primary-soft, #eee); color: var(--cn-primary, #6C5CE7); }
#silent-toggle-item.active { color: var(--cn-primary, #6C5CE7); font-weight: 600; }
.schedule-pop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 3000;
    display: flex; align-items: center; justify-content: center; }
.schedule-card { background: var(--cn-card, #fff); border-radius: 14px; padding: 18px;
    width: min(92vw, 320px); box-shadow: 0 18px 50px rgba(0,0,0,.3); }
.schedule-title { font-weight: 700; margin-bottom: 12px; }
.schedule-card input[type=datetime-local],
.schedule-card input[type=text],
.schedule-card input[type=time] { width: 100%; padding: 9px 12px;
    border: 1px solid var(--cn-border, #ddd); border-radius: 9px; background: var(--cn-bg, #fff); color: inherit; }
.schedule-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ── Saved Messages page ── */
.saved-wrap { max-width: 720px; margin: 0 auto; }
.saved-header h4 { font-weight: 800; margin: 0; }
.saved-sub { color: var(--cn-ink-mute, #999); font-size: 13px; margin: 2px 0 14px; }
.saved-folders { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.saved-folder-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
    border-radius: 20px; background: var(--cn-card, #f3f3f7); border: 1px solid var(--cn-border, #e5e5ea);
    font-size: 13px; cursor: pointer; color: var(--cn-ink, #222); }
.saved-folder-chip.active { background: var(--cn-primary, #6C5CE7); color: #fff; border-color: transparent; }
.saved-folder-chip.active a, .saved-folder-chip.active i { color: #fff !important; }
.saved-folder-del { background: transparent; border: none; color: inherit; opacity: .55; cursor: pointer; padding: 0 0 0 2px; }
.saved-folder-del:hover { opacity: 1; color: var(--cn-danger, #e74c3c); }
.saved-add-box { background: var(--cn-card, #fff); border: 1px solid var(--cn-border, #e5e5ea);
    border-radius: 14px; padding: 12px; margin-bottom: 18px; }
.saved-input { width: 100%; border: none; resize: vertical; background: transparent;
    color: inherit; font-size: 14px; outline: none; }
.saved-add-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.saved-select { border: 1px solid var(--cn-border, #ddd); border-radius: 8px; padding: 6px 10px;
    background: var(--cn-bg, #fff); color: inherit; font-size: 12px; }
.saved-file-btn { display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
    color: var(--cn-ink-mute, #888); font-size: 12px; margin: 0; }
.saved-save-btn { margin-inline-start: auto; border: none; background: var(--cn-primary, #6C5CE7);
    color: #fff; border-radius: 20px; padding: 7px 16px; cursor: pointer; font-size: 13px; }
.saved-items { display: flex; flex-direction: column; gap: 10px; }
.saved-item { display: flex; gap: 8px; background: var(--cn-card, #fff);
    border: 1px solid var(--cn-border, #ececf1); border-radius: 12px; padding: 12px 14px; }
.saved-item.pinned { border-color: var(--cn-primary, #6C5CE7); box-shadow: 0 0 0 1px var(--cn-primary-soft, #eee); }
.saved-item-body { flex: 1; min-width: 0; }
.saved-src { font-size: 11px; color: var(--cn-primary, #6C5CE7); margin-bottom: 4px; }
.saved-text { font-size: 14px; word-break: break-word; }
.saved-link { color: var(--cn-primary, #6C5CE7); word-break: break-all; font-size: 13px; }
.saved-file-link { color: var(--cn-ink, #222); text-decoration: none; font-size: 13px; }
.saved-media-img { max-width: 100%; max-height: 320px; border-radius: 10px; display: block; }
.saved-meta { font-size: 10px; color: var(--cn-ink-mute, #aaa); margin-top: 6px; }
.saved-item-actions { display: flex; flex-direction: column; gap: 4px; }
.saved-item-actions button { background: transparent; border: none; cursor: pointer;
    color: var(--cn-ink-mute, #999); padding: 2px 5px; font-size: 13px; }
.saved-pin.on { color: var(--cn-primary, #6C5CE7); }
.saved-del:hover { color: var(--cn-danger, #e74c3c); }
.saved-empty { text-align: center; color: var(--cn-ink-mute, #aaa); padding: 50px 0; }
.saved-empty i { font-size: 40px; opacity: .5; }

/* ── Collapse formatting toolbar into one icon (popover) ── */
.chat-format-bar {
    display: none !important;
    position: absolute;
    bottom: calc(100% + 8px);
    inset-inline-start: 6px;
    flex-direction: row;
    align-items: center;
    background: var(--cn-card);
    border: 1px solid var(--cn-border);
    border-radius: 12px;
    padding: 4px;
    gap: 2px;
    box-shadow: 0 8px 28px rgba(0,0,0,.2);
    z-index: 60;
}
.chat-format-bar.show { display: flex !important; }
#fmt-toggle.active { color: var(--cn-primary); background: var(--cn-primary-soft); }

/* ── Sticker / emoji-only message: no background + readable (dark) time ── */
.msg-bubble.emoji-only { background: transparent !important; border: none !important; box-shadow: none !important; padding: 0 !important; }
.msg-bubble.emoji-only .msg-meta,
.msg-bubble.emoji-only.sent .msg-meta,
.msg-bubble.emoji-only.received .msg-meta {
    color: var(--cn-ink-mute) !important;
    background: rgba(0,0,0,.06);
    border-radius: 8px;
    padding: 2px 7px;
    display: inline-flex;
}
.msg-bubble.emoji-only .msg-meta .read-tick { color: var(--cn-primary) !important; }

/* Jalali date picker */
.jalali-date-input {
    direction: ltr !important;
    text-align: left !important;
    unicode-bidi: plaintext;
}
.jalali-date-picker {
    display: none;
    position: absolute;
    z-index: 2500;
    min-width: 260px;
    margin-top: 6px;
    padding: 12px;
    background: var(--cn-card, #fff);
    border: 1px solid var(--cn-border, #e5e7eb);
    border-radius: 14px;
    box-shadow: 0 18px 46px rgba(15, 23, 42, .18);
}
.jalali-date-picker.open { display: block; }
.jalali-date-picker-head {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}
.jalali-date-picker-head select {
    width: 100%;
    border: 1px solid var(--cn-border, #e5e7eb);
    border-radius: 10px;
    padding: 9px 10px;
    background: var(--cn-bg, #fff);
    color: var(--cn-ink, #111827);
    font-size: 13px;
}
.jalali-date-picker-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}
.jalali-date-picker-day {
    min-width: 0;
    min-height: 36px;
    border: 1px solid var(--cn-border, #e5e7eb);
    border-radius: 10px;
    background: var(--cn-border-soft, #f8fafc);
    color: var(--cn-ink, #111827);
    font-size: 13px;
    cursor: pointer;
}
.jalali-date-picker-day:hover,
.jalali-date-picker-day.active {
    background: var(--cn-primary, #6C5CE7);
    border-color: var(--cn-primary, #6C5CE7);
    color: #fff;
}

/* Firefox-safe chat composer: no inner horizontal scroll.
   The textarea grows up to 3 lines, then only vertical scroll is allowed. */
.chat-input-area,
.chat-composer-row {
    min-width: 0;
    overflow-x: clip;
}
.chat-composer-row {
    align-items: flex-end !important;
}
.chat-composer-row .chat-input {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
    height: auto !important;
    min-height: 42px !important;
    max-height: calc((20px * 3) + 20px) !important;
    line-height: 20px !important;
    padding: 10px 14px !important;
    overflow-x: hidden !important;
    overflow-y: hidden;
    resize: none !important;
    white-space: pre-wrap !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    scrollbar-width: none;
}
.chat-composer-row .chat-input::-webkit-scrollbar {
    width: 0;
    height: 0;
}
