:root {
    --bg-primary: #131314;
    --bg-secondary: #1e1f20;
    --bg-tertiary: #2d2e30;
    --bg-hover: #2a2b2c;
    --text-primary: #e3e3e3;
    --text-secondary: #bdc1c6;
    --accent: #8a9aff;
    --border-color: #3a3a3a;
    --code-bg: #0d1117;
    --accent-rgb: 138, 154, 255;
    --messenger-bg: #0f1011;
    --bubble-sent-bg: #373a63;
    --bubble-received-bg: #2d2e30;
    
    --glass-bg: rgba(30, 31, 32, 0.45);
    --glass-border: rgba(255, 255, 255, 0.25);
    --glass-blur: 20px;
    --glass-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

html.light {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f1f3f4;
    --bg-hover: #e8eaed;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --accent: #1a73e8;
    --border-color: #e0e0e0;
    --code-bg: #f6f8fa;
    --accent-rgb: 26, 115, 232;
    --messenger-bg: #f0f2f5;
    --bubble-sent-bg: #e7f3ff;
    --bubble-received-bg: #ffffff;

    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(0, 0, 0, 0.15);
}

html {
    height: 100%;
}

body {
    height: 100%;
    transition: background-color 0.3s, color 0.3s;
    overflow: hidden;
    background-color: #0f0f11;
    background-image: 
        radial-gradient(at 0% 0%, rgba(138, 154, 255, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(120, 50, 200, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(50, 100, 200, 0.1) 0px, transparent 50%);
    background-attachment: fixed;
}

html.light body {
    background-color: #f3f4f6;
    background-image: 
        radial-gradient(at 0% 0%, rgba(26, 115, 232, 0.1) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(200, 50, 100, 0.05) 0px, transparent 50%);
}

.history-sidebar, .main-sidebar {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 767px) {
    .history-sidebar, .main-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        height: 100%;
        z-index: 50;
    }

    html[dir="rtl"] .main-sidebar {
        left: auto;
        right: 0;
        transform: translateX(100%);
    }

    html[dir="rtl"] .history-sidebar {
        right: auto;
        left: 0;
        transform: translateX(-100%);
    }

    html[dir="ltr"] .main-sidebar {
        right: auto;
        left: 0;
        transform: translateX(-100%);
    }

    html[dir="ltr"] .history-sidebar {
        left: auto;
        right: 0;
        transform: translateX(100%);
    }

    .main-sidebar.mobile-menu-open {
        transform: translateX(0) !important;
        box-shadow: 0 0 15px rgba(0,0,0,0.5);
    }

    .history-sidebar.open {
        transform: translateX(0) !important;
        box-shadow: 0 0 15px rgba(0,0,0,0.5);
    }
}

@media (min-width: 768px) {
    .history-sidebar {
        transform: translateX(0) !important;
        width: 18rem;
        position: relative;
    }
    .main-sidebar {
        transform: translateX(0) !important;
        width: 5rem;
        position: relative;
    }
    
    /* حذف کدهای مربوط به order در حالت RTL دسکتاپ 
       این کار باعث می‌شود منوی اصلی به جایگاه طبیعی خود (راست) برگردد */
}

#main-menu-toggle {
    transition: all 0.3s;
}

html[dir="rtl"] #main-menu-toggle {
    left: auto;
    right: 1rem;
    top: 1rem;
}

html[dir="ltr"] #main-menu-toggle {
    right: auto;
    left: 1rem;
    top: 1rem;
}

.font-fa {
    font-family: 'Vazirmatn', sans-serif;
}

.font-en {
    font-family: 'Inter', sans-serif;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.glass-effect {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-top: 1px solid var(--glass-border);
}

.history-sidebar, 
.main-sidebar {
    background-color: var(--glass-bg) !important;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: none !important;
    box-shadow: var(--glass-shadow);
}

.header {
    background-color: var(--glass-bg) !important;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--glass-border) !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 20;
}

#auth-modal, 
#gem-modal, 
.user-list-modal, 
#story-upload-modal, 
#new-chat-modal, 
#conv-settings-modal, 
#prompt-modal,
#enamad-modal,
.dropdown-menu {
    background-color: var(--glass-bg) !important;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.4) !important;
    border-left: 1px solid rgba(255, 255, 255, 0.4) !important;
    box-shadow: var(--glass-shadow);
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

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

.animate-fade-in {
    animation: fadeInScale 0.3s ease-out forwards;
}

.message-bubble, .ai-message, .post-card, .story-item {
    animation: slideUp 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

button:active {
    transform: scale(0.96);
    transition: transform 0.1s;
}

.dropdown-menu, .suggestion-card, .history-item .dropdown-menu {
    transition: all 0.2s;
    animation: fadeInScale 0.2s ease-out;
}

.dark .main-sidebar .nav-item.active i {
    color: var(--accent);
    filter: drop-shadow(0 0 8px rgba(var(--accent-rgb), 0.4));
}

.light .main-sidebar .nav-item.active i {
    color: var(--accent);
}

.ai-content {
    width: 100%;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    overflow-x: hidden;
    line-height: 1.8;
}

.ai-content pre {
    position: relative;
    padding-top: 2.5rem;
    max-width: 100%;
    overflow-x: auto;
    white-space: pre;
    background-color: var(--code-bg);
    border-radius: 0.75rem;
    direction: ltr;
    text-align: left;
    border: 1px solid var(--border-color);
}

.ai-content table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
    border-collapse: collapse;
}

.ai-content p {
    overflow-wrap: break-word;
    margin-bottom: 0.75rem;
}

.copy-code-btn {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

html[dir="rtl"] .copy-code-btn {
    left: auto;
    right: 0.5rem;
}

.ai-content pre:hover .copy-code-btn {
    opacity: 1;
}

#toast-container {
    position: fixed;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
}

.toast {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--text-primary);
    padding: 0.75rem 1.25rem;
    border-radius: 1rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transform: translateY(-100px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease-out;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.theme-toggle-switch {
    transition: all 0.2s ease-in-out;
}

html[dir="ltr"] .theme-toggle-switch {
    left: 0.25rem;
}

html[dir="rtl"] .theme-toggle-switch {
    right: 0.25rem;
}

html[dir="ltr"] .theme-toggle-switch:checked {
    left: 1.75rem;
}

html[dir="rtl"] .theme-toggle-switch:checked {
    right: 1.75rem;
}

#auth-modal-overlay, #gem-modal-overlay, #tour-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    z-index: 9998;
    display: none;
}

#auth-modal, #gem-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 450px;
    z-index: 9999;
    display: none;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeInScale 0.3s ease-out;
}

.image-preview {
    max-width: 100%;
    height: auto;
    border-radius: 0.75rem;
    margin-top: 1rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

html[dir="rtl"] .ai-content {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .ai-content p, html[dir="rtl"] .ai-content ul, html[dir="rtl"] .ai-content ol, html[dir="rtl"] .ai-content h1, html[dir="rtl"] .ai-content h2, html[dir="rtl"] .ai-content h3 {
    text-align: right;
}

html[dir="rtl"] #empty-chat-container, html[dir="rtl"] #auth-modal {
    direction: rtl;
}

.ai-content code {
    direction: ltr;
    text-align: left;
    font-family: 'Fira Code', monospace;
}

.tour-highlight {
    position: relative;
    z-index: 10000;
    border-radius: 0.375rem;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.7);
}

#tour-tooltip {
    position: absolute;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 1rem;
    border-radius: 0.75rem;
    width: 300px;
    z-index: 10001;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    display: none;
}

#tour-tooltip h3 {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

#tour-tooltip p {
    font-size: 0.9rem;
    margin-bottom: 1rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

#tour-tooltip-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#tour-progress {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.gem-display-float {
    background-color: var(--bg-tertiary);
    padding: 0.5rem 1rem;
    border-radius: 0.75rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
    border: 1px solid var(--border-color);
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.gem-display-float:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.3);
}

.gem-display-float .gem-icon {
    color: var(--accent);
    font-size: 1.25rem;
    text-shadow: 0 0 15px rgba(var(--accent-rgb), 0.5);
}

.dark .gem-display-float .gem-text {
    font-weight: 700;
    background: linear-gradient(45deg, #e3e3e3, #bdc1c6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.light .gem-display-float .gem-text {
    font-weight: 700;
    background: linear-gradient(45deg, #202124, #5f6368);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.gem-package-card {
    background: var(--glass-bg);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid var(--glass-border);
    
    border-radius: 1rem;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.gem-package-card:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 10px 25px rgba(var(--accent-rgb), 0.15);
    border-color: var(--accent);
}

.gem-package-card.featured {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(var(--accent-rgb), 0.15);
    background: linear-gradient(145deg, var(--glass-bg), rgba(var(--accent-rgb), 0.1));
}

.gem-package-btn-new {
    background: linear-gradient(45deg, var(--accent), #a1afff);
    color: white;
    font-weight: bold;
    padding: 0.6rem 1.25rem;
    border-radius: 0.75rem;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(var(--accent-rgb), 0.3);
    border: none;
    cursor: pointer;
}

.light .gem-package-btn-new {
    background: linear-gradient(45deg, var(--accent), #4f8dff);
}

.gem-package-btn-new:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(var(--accent-rgb), 0.4);
}

@keyframes skeleton-pulse {
    0%, 100% { background-color: var(--bg-tertiary); }
    50% { background-color: var(--bg-hover); }
}

.skeleton {
    animation: skeleton-pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.skeleton-line {
    height: 1rem;
    border-radius: 0.25rem;
}

.tool-content {
    transition: opacity 0.3s ease-in-out;
}

.styled-audio-player .progress-bar-wrapper:hover .progress-bar {
    background-color: #a1afff;
}

.styled-audio-player .play-pause-btn, .styled-audio-player .download-btn {
    transition: transform 0.2s, background-color 0.2s;
}

.styled-audio-player .play-pause-btn:hover, .styled-audio-player .download-btn:hover {
    transform: scale(1.1);
    background-color: var(--bg-hover);
}

.custom-file-upload {
    border: 2px dashed var(--border-color);
    display: block;
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    width: 100%;
    border-radius: 1rem;
    transition: all 0.2s;
    background-color: rgba(0,0,0,0.02);
}

.custom-file-upload:hover {
    border-color: var(--accent);
    background-color: rgba(var(--accent-rgb), 0.05);
}

.post-card {
    background-color: var(--bg-tertiary);
    border-radius: 1rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease;
}

.post-card:hover {
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.post-card .action-btn.liked {
    color: #ef4444;
    animation: likeBounce 0.3s;
}

@keyframes likeBounce {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.post-card-media-container {
    background-color: var(--bg-secondary);
}

.post-content-text {
    transition: max-height 0.3s ease-in-out;
}

.post-content-collapsed {
    max-height: 100px;
    overflow: hidden;
    position: relative;
}

.post-content-collapsed::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to top, var(--bg-tertiary), transparent);
}

.comment-item .action-btn {
    font-size: 0.75rem;
}

.user-profile-header {
    background: var(--bg-primary);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

@media (min-width: 768px) {
    .user-profile-header {
        flex-direction: row;
        text-align: right;
        gap: 2.5rem;
        padding: 2.5rem;
    }
}

html[dir="rtl"] .user-profile-header {
    text-align: center;
}

@media (min-width: 768px) {
    html[dir="rtl"] .user-profile-header {
        text-align: right;
    }
}

.profile-avatar {
    position: relative;
    flex-shrink: 0;
}

.profile-avatar img {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--bg-tertiary);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

@media (min-width: 768px) {
    .profile-avatar img {
        width: 140px;
        height: 140px;
    }
}

.story-ring {
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border-radius: 50%;
    border: 3px solid var(--accent);
    pointer-events: none;
}

.profile-avatar[data-has-story="true"] .story-ring {
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(138, 154, 255, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(138, 154, 255, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(138, 154, 255, 0); }
}

.profile-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

@media (min-width: 768px) {
    .profile-info {
        align-items: flex-start;
        text-align: right;
    }
}

.profile-stats {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-top: 1rem;
    background: var(--bg-tertiary);
    padding: 0.75rem 1.5rem;
    border-radius: 1rem;
}

@media (min-width: 768px) {
    .profile-stats {
        gap: 2rem;
        justify-content: flex-start;
        margin-top: 1.5rem;
        background: transparent;
        padding: 0;
    }
}

html[dir="rtl"] .profile-stats {
    justify-content: center;
}

@media (min-width: 768px) {
    html[dir="rtl"] .profile-stats {
        justify-content: flex-start;
    }
}

.profile-stats div {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

html[dir="rtl"] .profile-stats div {
    flex-direction: column;
}

.profile-stats div span {
    font-weight: bold;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.profile-actions {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

@media (min-width: 768px) {
    .profile-actions {
        margin-top: 0;
        flex-direction: row;
        width: auto;
    }
}

.medals-section, .story-section {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.section-title {
    font-weight: bold;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title::before {
    content: '';
    width: 4px;
    height: 20px;
    background: var(--accent);
    border-radius: 2px;
    display: inline-block;
}

.badges-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--bg-tertiary);
    padding: 0.5rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
}

.story-highlights {
    display: flex;
    gap: 1.25rem;
    overflow-x: auto;
    padding-bottom: 0.75rem;
    scrollbar-width: none;
}

.story-highlights::-webkit-scrollbar {
    display: none;
}

.story-highlight-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.story-highlight-item:hover {
    transform: translateY(-2px);
}

.story-thumb {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background-color: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    background-size: cover;
    background-position: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.story-highlight-item.add-story .story-thumb {
    border-style: dashed;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.user-list-modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px);
    z-index: 10002;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.user-list-modal-overlay.visible {
    opacity: 1;
}

.user-list-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 400px;
    z-index: 10003;
    background-color: var(--glass-bg) !important;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.4) !important;
    border-left: 1px solid rgba(255, 255, 255, 0.4) !important;
    
    border-radius: 1rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    opacity: 0;
    transform: translate(-50%, -45%) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.user-list-modal.visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.user-list-modal .p-4 {
    display: flex;
    flex-direction: column;
}

.user-list-item, .skeleton-user-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border-color);
}

.user-list-item:last-child, .skeleton-user-item:last-child {
    border-bottom: none;
}

.user-list-item .user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    flex-grow: 1;
    min-width: 0;
}

.user-list-item .user-info span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

.user-list-item .user-info img, .skeleton-user-item .avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.user-list-item .user-info img {
    border: 2px solid var(--border-color);
}

.skeleton-user-item .avatar {
    background-color: var(--bg-tertiary);
    animation: skeleton-pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.skeleton-user-item .text-line {
    height: 1rem;
    border-radius: 0.25rem;
    background-color: var(--bg-tertiary);
    animation: skeleton-pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.user-list-item .action-btn {
    font-size: 0.8rem;
    padding: 0.4rem 1rem;
    border-radius: 0.6rem;
    font-weight: bold;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

html[dir="rtl"] .user-list-item .action-btn {
    margin-left: 0;
    margin-right: 0.5rem;
}

.user-list-item .action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.story-bar {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    overflow-x: auto;
    scrollbar-width: none;
}

.story-feed {
    display: flex;
    gap: 1.25rem;
    padding-bottom: 0.5rem;
}

.story-feed::-webkit-scrollbar {
    display: none;
}

.story-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.story-item:hover {
    transform: translateY(-2px);
}

.story-item-avatar {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-item-avatar.seen {
    background: var(--border-color);
}

.story-item-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--bg-primary);
}

.story-item-name {
    font-size: 0.75rem;
    color: var(--text-primary);
    max-width: 68px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#story-viewer-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.9);
    backdrop-filter: blur(10px);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s;
}

#story-viewer-overlay.visible {
    opacity: 1;
}

#story-viewer {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0.95);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#story-viewer.visible {
    transform: scale(1);
    opacity: 1;
}

.story-container {
    width: 100%;
    height: 100%;
    max-width: 420px;
    max-height: 90vh;
    background-color: #000;
    border-radius: 1.25rem;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.story-media {
    flex-grow: 1;
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-media img, .story-media video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.story-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    z-index: 10;
    background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
}

.story-progress-bars {
    display: flex;
    gap: 4px;
    width: 100%;
}

.progress-bar-container {
    flex-grow: 1;
    height: 3px;
    background-color: rgba(255,255,255,0.3);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: white;
    width: 0;
    transition: width 0.1s linear;
}

.story-user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.story-user-info img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.5);
}

.story-user-info .name {
    font-weight: bold;
    color: white;
    font-size: 0.9rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.story-user-info .time {
    color: rgba(255,255,255,0.8);
    font-size: 0.8rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.story-nav {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    z-index: 5;
}

.story-nav-prev, .story-nav-next {
    flex: 1;
    height: 100%;
    cursor: pointer;
}

.story-nav-prev {
    max-width: 30%;
}

.close-story-viewer {
    background: none;
    border: none;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

#story-upload-modal {
    display: none;
    position: fixed;
    z-index: 10002;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    
    background-color: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}

#story-upload-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px);
    z-index: 10001;
}

#story-preview-container img, #story-preview-container video {
    max-height: 40vh;
    width: 100%;
    object-fit: contain;
    border-radius: 0.75rem;
}

.story-feed .skeleton {
    display: none;
}

.story-feed.loading .skeleton {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.story-feed.loading .skeleton .skeleton-avatar {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background-color: var(--bg-tertiary);
}

.story-feed.loading .skeleton .skeleton-line {
    width: 56px;
    height: 12px;
    border-radius: 4px;
    background-color: var(--bg-tertiary);
}

.story-item.add-story .story-item-avatar {
    background: var(--bg-tertiary);
    border: 2px dashed var(--border-color);
    padding: 0;
    position: relative;
}

.story-item.add-story .story-item-avatar.self {
    border: none;
}

.story-item.add-story .story-item-avatar .plus-icon {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 24px;
    height: 24px;
    background-color: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-primary);
    font-size: 0.8rem;
}

.story-editor-btn {
    background: rgba(0,0,0,0.5);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.2);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
}

.story-editor-btn:hover {
    background-color: rgba(0,0,0,0.8);
    transform: scale(1.1);
}

#story-mention-search-box .mention-result-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 0.5rem;
}

#story-mention-search-box .mention-result-item:hover {
    background-color: var(--bg-hover);
}

#story-mention-search-box .mention-result-item img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.story-mention-tag {
    position: absolute;
    background-color: rgba(0,0,0,0.7);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    cursor: grab;
    user-select: none;
    white-space: nowrap;
    transform: translate(-50%, -50%);
    z-index: 10;
    backdrop-filter: blur(4px);
}

.story-mention-tag-viewer {
    position: absolute;
    background-color: rgba(0,0,0,0.7);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transform: translate(-50%, -50%);
    z-index: 5;
    backdrop-filter: blur(4px);
    transition: transform 0.2s;
}

.story-mention-tag-viewer:hover {
    transform: translate(-50%, -50%) scale(1.1);
}

.story-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.5rem 1rem;
    z-index: 10;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
}

.story-footer-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.story-footer .story-action-btn, .story-footer .story-like-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.6rem;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

.story-footer .story-action-btn:hover, .story-footer .story-like-btn:hover {
    transform: scale(1.15);
}

.story-like-btn.liked i {
    color: #ef4444;
    font-weight: 900;
    animation: likeBounce 0.3s;
}

.story-like-btn span {
    font-size: 1rem;
    font-weight: bold;
}

.story-viewers-btn {
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    backdrop-filter: blur(4px);
}

.notification-item.unread {
    background-color: rgba(var(--accent-rgb), 0.1);
    border-left: 3px solid var(--accent);
}

.notification-item:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

#messenger-main-chat {
    background-color: var(--messenger-bg);
}

.conversation-item {
    border-radius: 0.75rem;
    margin-bottom: 2px;
    transition: all 0.2s;
}

.conversation-item:hover {
    background-color: var(--bg-hover);
}

.conversation-item.active {
    background-color: var(--bg-tertiary);
    border-right: 3px solid var(--accent);
}

html[dir="rtl"] .conversation-item.active {
    border-right: none;
    border-left: 3px solid var(--accent);
}

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: 1.25rem;
    max-width: 80%;
    position: relative;
    word-wrap: break-word;
    line-height: 1.6;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.light .message-bubble {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.message-bubble p {
    margin: 0;
}

.message-bubble.sent {
    background-color: var(--bubble-sent-bg);
    color: var(--text-primary);
    border-bottom-right-radius: 0.25rem;
}

.message-bubble.received {
    background-color: var(--bubble-received-bg);
    color: var(--text-primary);
    border-bottom-left-radius: 0.25rem;
}

html[dir="rtl"] .message-bubble.sent {
    border-bottom-right-radius: 1.25rem;
    border-bottom-left-radius: 0.25rem;
}

html[dir="rtl"] .message-bubble.received {
    border-bottom-left-radius: 1.25rem;
    border-bottom-right-radius: 0.25rem;
}

.message-row {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.message-row.sent {
    justify-content: flex-end;
}

.message-row.received {
    justify-content: flex-start;
}

.message-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    margin-top: 4px;
    float: left;
    clear: both;
    color: var(--text-secondary);
    opacity: 0.8;
}

html[dir="rtl"] .message-meta {
    float: right;
}

.message-meta i {
    font-size: 0.8rem;
}

.new-chat-tab-btn {
    flex: 1;
    padding: 1rem;
    text-align: center;
    background-color: transparent;
    border: none;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.new-chat-tab-btn.active {
    color: var(--accent);
}

.new-chat-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background-color: var(--accent);
    border-radius: 3px 3px 0 0;
}

#selected-group-members .member-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--bg-tertiary);
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
}

#selected-group-members .member-pill button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#selected-group-members .member-pill button:hover {
    color: #ef4444;
}

#messages-list {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.model-selection-container {
    padding: 1.5rem;
    max-width: 900px;
    margin: auto;
}

.model-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1.5rem;
}

.model-card {
    position: relative;
    aspect-ratio: 1 / 1;
    height: auto;
    border-radius: 1rem;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    border: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.model-card:not([disabled]):hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
    border-color: var(--accent);
}

.model-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.5) 50%, transparent 100%);
    transition: background 0.3s;
}

.model-card:hover .model-card-overlay {
    background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.3) 60%, transparent 100%);
}

.model-card-content {
    position: relative;
    z-index: 1;
    padding: 1.25rem;
    color: white;
    text-align: right;
    transition: transform 0.3s ease-in-out;
}

.model-card:hover .model-card-content {
    transform: translateY(-5px);
}

.model-card-title {
    font-size: 1.2rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    margin-bottom: 0.25rem;
}

.model-card-description {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.4;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    transition: all 0.3s ease-in-out;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 2.8em;
    opacity: 0.9;
}

.model-card:hover .model-card-description {
    -webkit-line-clamp: 4;
    max-height: 5.6em;
    opacity: 1;
}

.iti {
    width: 100%;
    direction: ltr;
}

.iti__country-list {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    z-index: 10000;
    border-radius: 0.5rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.iti__country {
    color: var(--text-primary);
    padding: 0.5rem 1rem;
}

.iti__country.iti__highlight {
    background-color: var(--bg-hover);
}

.iti__dial-code {
    color: var(--text-secondary);
}

html.light .iti__country {
    color: var(--text-primary);
}

.iti input {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 100%;
    border-radius: 0.75rem;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    padding-right: 58px;
    transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}

html[dir="rtl"] .iti input {
    padding-right: 6px;
    padding-left: 58px;
}

.code-input-group {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

.code-input {
    width: 3.5rem;
    height: 4rem;
    text-align: center;
    font-size: 1.75rem;
    font-weight: bold;
    border: 2px solid var(--border-color);
    background-color: var(--bg-tertiary);
    border-radius: 0.75rem;
    color: var(--text-primary);
    transition: all 0.2s;
    -moz-appearance: textfield;
}

.code-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.2);
    transform: translateY(-2px);
}

#resend-code-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#showcase-feed[dir="rtl"] .post-card {
    text-align: right;
}

#showcase-feed .post-card .dropdown-menu {
    left: 0.75rem;
    right: auto;
}

.ai-edit-toolbar {
    transition: all 0.2s ease-in-out;
    opacity: 0;
    transform: translateY(5px);
    pointer-events: none;
}

.ai-edit-toolbar.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.ai-edit-btn {
    background-color: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    width: 2.2rem;
    height: 2.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-edit-btn:hover {
    background-color: var(--accent);
    color: white;
    border-color: var(--accent);
}

.ai-edit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-edit-status {
    animation: pulse 1.5s infinite ease-in-out;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

html[dir="rtl"] .ai-edit-toolbar {
    right: auto;
    left: 0;
}

.model-cost-badge {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

html[dir="rtl"] .model-cost-badge {
    left: auto;
    right: 0.75rem;
}

.model-cost-badge .fa-gem {
    color: #38bdf8;
    filter: drop-shadow(0 0 5px rgba(56, 189, 248, 0.5));
}

.stat-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1.25rem;
}

.stat-card {
    background-color: var(--bg-tertiary);
    padding: 1.25rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    text-align: center;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
}

.stat-card-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.stat-card-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

#support-chat-widget {
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease-out;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
}

#support-chat-widget.visible {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.safe-area-pb {
    padding-bottom: env(safe-area-inset-bottom);
}

body.full-mode .main-sidebar,
body.full-mode .history-sidebar {
    display: none !important;
}

body.full-mode main {
    width: 100% !important;
    flex: 1 1 100% !important;
    padding: 0;
}

.showcase-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    padding-bottom: 60px;
}

.grid-item {
    aspect-ratio: 1 / 1;
    position: relative;
    cursor: pointer;
    overflow: hidden;
    background-color: var(--bg-tertiary);
}

.grid-item img, .grid-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.grid-item:hover img {
    transform: scale(1.05);
}

.grid-item-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    color: white;
    font-size: 1.2rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.grid-item-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(45deg, #373a63, #2d2e30);
    color: #e3e3e3;
    font-size: 0.75rem;
    padding: 10px;
    text-align: center;
}

#post-view-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    animation: slideUp 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#post-view-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 15px;
}