/* ================= Chat AI Styles & Code Editor ================= */

/* پیام هوش مصنوعی */
.ai-message .message-body {
    background-color: transparent;
    padding: 12px 0;
    max-width: 100%;
}
.ai-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-surface-solid, #fff);
    flex-shrink: 0; padding: 2px;
    border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    position: relative;
    overflow: hidden;
}
.ai-avatar-img {
    width: 100%; height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}
[data-theme="dark"] .ai-avatar {
    background: #282a2c;
    border-color: rgba(168, 199, 250, 0.18);
}
.welcome-ai-icon {
    width: 72px; height: 72px; border-radius: 22px;
    display: grid; place-items: center; margin: 0;
    background: var(--bg-surface-solid, #fff);
    border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}
.welcome-ai-icon .welcome-logo {
    width: 42px; height: 42px;
    object-fit: contain;
    display: block;
}
.ai-avatar-thinking {
    background: var(--bg-surface-solid, #fff);
    box-shadow: 0 0 0 2px rgba(11, 87, 208, 0.12);
}
.ai-avatar-thinking .ai-avatar-img {
    animation: aiIconPulse 2s ease-in-out infinite;
    opacity: 0.88;
}
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.user-avatar:not(.top-avatar) { overflow: hidden; }
.user-avatar--initial {
    background: var(--ua-bg, #e8eaed);
    color: var(--ua-text, #5f6368);
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(60, 64, 67, 0.1);
}
.user-avatar--initial span { line-height: 1; }
.user-avatar--hue-0 { --ua-bg: #e8f0fe; --ua-text: #1967d2; }
.user-avatar--hue-1 { --ua-bg: #e8eaed; --ua-text: #5f6368; }
.user-avatar--hue-2 { --ua-bg: #e3e8ef; --ua-text: #445968; }
.user-avatar--hue-3 { --ua-bg: #e8f0fe; --ua-text: #0b57d0; }
.user-avatar--hue-4 { --ua-bg: #eef0f4; --ua-text: #3c4043; }
.user-avatar--hue-5 { --ua-bg: #e3ecf7; --ua-text: #185abc; }
[data-theme="dark"] .user-avatar--initial {
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: none;
}
[data-theme="dark"] .user-avatar--hue-0 { --ua-bg: #394457; --ua-text: #a8c7fa; }
[data-theme="dark"] .user-avatar--hue-1 { --ua-bg: #3c4043; --ua-text: #e8eaed; }
[data-theme="dark"] .user-avatar--hue-2 { --ua-bg: #35363a; --ua-text: #c4c7c5; }
[data-theme="dark"] .user-avatar--hue-3 { --ua-bg: #394457; --ua-text: #a8c7fa; }
[data-theme="dark"] .user-avatar--hue-4 { --ua-bg: #3c4043; --ua-text: #e3e3e3; }
[data-theme="dark"] .user-avatar--hue-5 { --ua-bg: #353f4f; --ua-text: #8ab4f8; }
.user-avatar-img {
    width: 100%; height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.top-avatar.user-avatar--initial { font-size: 0.95rem; }
@keyframes aiIconPulse {
    0%, 100% { transform: scale(1); opacity: 0.92; }
    50% { transform: scale(1.06); opacity: 1; }
}
.ai-avatar-ring {
    position: absolute; inset: -4px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: rgba(255, 255, 255, 0.95);
    border-right-color: rgba(255, 255, 255, 0.35);
    animation: aiAvatarSpin 1.1s linear infinite;
}
@keyframes aiAvatarGradient {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}
@keyframes aiAvatarSpin { to { transform: rotate(360deg); } }

/* اندیکاتور فکر کردن AI — مینیمال، بدون کادر */
.ai-is-thinking .ai-thinking-body {
    width: auto !important;
    max-width: none;
    padding: 6px 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
}
.ai-thinking-stage {
    display: block !important;
    padding: 0 !important;
}
.ai-thinking-indicator {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0;
    border: none;
    background: none;
    box-shadow: none;
}
.ai-thinking-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.ai-thinking-dots > span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent, #0b57d0);
    animation: aiThinkingDot 1.4s ease-in-out infinite;
    opacity: 0.35;
}
.ai-thinking-dots > span:nth-child(1) { animation-delay: 0s; }
.ai-thinking-dots > span:nth-child(2) { animation-delay: 0.2s; }
.ai-thinking-dots > span:nth-child(3) { animation-delay: 0.4s; }
.ai-thinking-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted, #5f6368);
    letter-spacing: -0.01em;
    animation: aiThinkingTextPulse 2.2s ease-in-out infinite;
}
[data-theme="dark"] .ai-thinking-dots > span {
    background: #a8c7fa;
}
@keyframes aiThinkingDot {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.3; }
    40% { transform: translateY(-3px); opacity: 1; }
}
@keyframes aiThinkingTextPulse {
    0%, 100% { opacity: 0.65; }
    50% { opacity: 1; }
}

/* سازگاری با کلاس قدیمی */
.typing-indicator { display: block; padding: 0 !important; }
.typing-indicator > span:not(.ai-thinking-text) { display: none; }

/* ================= ویرایشگر کد حرفه‌ای (IDE Style) ================= */
.code-block-wrapper {
    background: #181818; 
    border-radius: 12px; 
    margin: 16px 0; 
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08); 
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    direction: ltr !important; /* کدها همیشه چپ‌چین هستند */
}

/* هدر ویرایشگر */
.code-header {
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    background: #242424;
    padding: 12px 16px; 
    border-bottom: 1px solid #333;
}

/* دکمه‌های استایل مک */
.mac-controls {
    display: flex;
    gap: 6px;
    align-items: center;
}
.mac-dot {
    width: 12px; height: 12px; border-radius: 50%;
}
.mac-dot.red { background-color: #ff5f56; }
.mac-dot.yellow { background-color: #ffbd2e; }
.mac-dot.green { background-color: #27c93f; }

/* رنگ‌بندی‌های اختصاصی زبان‌های برنامه‌نویسی */
.code-lang-badge {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem; 
    font-family: 'Consolas', monospace; 
    font-weight: 700; 
    text-transform: uppercase; 
    letter-spacing: 1px;
    color: #a8c7fa; /* رنگ پیش‌فرض */
}
/* رنگ‌های اختصاصی زبان‌ها */
.code-lang-badge[data-lang="php"] { color: #8892BF; }
.code-lang-badge[data-lang="javascript"], .code-lang-badge[data-lang="js"] { color: #F7DF1E; }
.code-lang-badge[data-lang="html"], .code-lang-badge[data-lang="markup"] { color: #E34F26; }
.code-lang-badge[data-lang="css"] { color: #1572B6; }
.code-lang-badge[data-lang="python"], .code-lang-badge[data-lang="py"] { color: #3776AB; }
.code-lang-badge[data-lang="bash"], .code-lang-badge[data-lang="sh"] { color: #4EAA25; }
.code-lang-badge[data-lang="sql"] { color: #00758F; }
.code-lang-badge[data-lang="json"] { color: #000000; text-shadow: 0 0 1px #fff; }

.code-actions { display: flex; gap: 8px; }
.code-btn {
    background: #333; 
    border: 1px solid #444; 
    color: #e3e3e3; 
    display: flex; align-items: center; gap: 6px; 
    font-size: 0.8rem; cursor: pointer; padding: 6px 12px; 
    border-radius: 6px; transition: all 0.2s ease;
    font-family: inherit; font-weight: 500;
}
.code-btn:hover { background: #444; color: #fff; border-color: #555; transform: translateY(-1px); }

/* محفظه اصلی کد و شماره خطوط (حل باگ هماهنگی) */
.code-scroll-container {
    display: flex;
    overflow-x: auto;
    background: #181818;
}

/* استایل ثابت شماره خطوط */
.line-numbers-col {
    position: sticky;
    left: 0;
    background: #181818; 
    border-right: 1px solid #333;
    padding: 16px 12px;
    text-align: right;
    color: #6e7681;
    user-select: none;
    z-index: 10;
    display: flex;
    flex-direction: column;
}

.line-numbers-col span {
    font-family: 'Consolas', 'Monaco', monospace; 
    font-size: 0.95rem; 
    line-height: 1.6; 
    min-height: 1.6em;
}

.code-scroll-container pre { 
    margin: 0; 
    padding: 16px; 
    min-width: 100%; 
    direction: ltr !important;
    text-align: left !important;
}
.code-scroll-container code { 
    font-family: 'Consolas', 'Monaco', monospace; 
    font-size: 0.95rem; 
    color: #e3e3e3; 
    line-height: 1.6; 
    display: block;
    direction: ltr !important;
    text-align: left !important;
}


/* ================= پیام‌های طولانی (Read More) ================= */
.expandable-msg { position: relative; }
.toggle-more-btn {
    background: transparent; border: none; color: var(--accent, #0b57d0); font-family: inherit; 
    font-size: 0.9rem; font-weight: bold; cursor: pointer; display: inline-flex; align-items: center; 
    gap: 6px; margin-top: 8px; padding: 4px 0; transition: 0.2s;
}
.toggle-more-btn svg { transition: transform 0.3s ease; }
.toggle-more-btn:hover { filter: brightness(0.8); }

.message-footer-actions { display: flex; gap: 8px; margin-top: 12px; opacity: 1; transition: opacity 0.3s; }
.ai-message:hover .message-footer-actions { opacity: 1; }
.msg-action-btn {
    background: transparent; border: none; color: var(--text-muted); cursor: pointer; width: 34px; height: 34px; 
    border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: 0.2s;
}
.msg-action-btn:hover { background: var(--border); color: var(--text-main); }


/* ================= Top Nav & Profile Menu ================= */
.temp-chat-btn { color: var(--text-muted); transition: 0.3s; }
.temp-chat-btn:hover, .temp-chat-btn.active { color: var(--accent); }
.temp-chat-btn.active svg { color: #d97706; }

.top-profile-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
    overflow: visible;
    z-index: 60;
}
/* —— هدر: آواتار + نشان اشتراک (اختصاصی) —— */
.top-profile-block {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}
.top-profile-block:focus-visible {
    outline: 2px solid var(--accent, #0b57d0);
    outline-offset: 3px;
    border-radius: 50%;
}
.top-avatar-shell {
    position: relative;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    transition: transform 0.28s cubic-bezier(0.34, 1.2, 0.64, 1);
}
.top-avatar-shell:not(.top-avatar-shell--pro) .user-avatar.top-avatar {
    width: 34px;
    height: 34px;
    border: none;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.1);
}
.top-avatar-shell--pro {
    width: 36px;
    height: 36px;
}
.top-profile-block:hover .top-avatar-shell,
.top-profile-block:focus-visible .top-avatar-shell {
    transform: scale(1.06);
}
.top-profile-block:active .top-avatar-shell {
    transform: scale(0.97);
}
/* حلقهٔ گرادیان فقط برای Pro */
.top-avatar-shell--pro::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(145deg, #2563eb 0%, #6366f1 42%, #a855f7 68%, #d97706 100%);
    opacity: 1;
    z-index: 0;
}
.top-avatar-shell--pro::after {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    background: var(--bg-app, #f0f4f9);
    z-index: 0;
}
[data-theme="dark"] .top-avatar-shell--pro::after {
    background: #131314;
}
.top-profile-block .user-avatar.top-avatar {
    position: relative;
    z-index: 1;
    width: 30px;
    height: 30px;
    border: 2px solid var(--bg-app, #f0f4f9);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.1);
    transition: box-shadow 0.25s ease;
}
[data-theme="dark"] .top-profile-block .user-avatar.top-avatar {
    border-color: #131314;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}
.top-profile-block:hover .top-avatar {
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.22);
}
.top-avatar {
    overflow: hidden;
    flex-shrink: 0;
}
.top-avatar .user-avatar-img,
.top-avatar > img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}
.top-avatar.user-avatar--initial > span {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.top-avatar.user-avatar--initial { font-size: 0.82rem; }
/* چیپ Pro — گوشهٔ پایین آواتار */
.top-plan-chip {
    position: absolute;
    z-index: 4;
    inset-inline-start: -5px;
    inset-block-end: -3px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 14px;
    padding: 0 5px 0 3px;
    border-radius: 7px;
    font-size: 0.5rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.02em;
    color: #fff;
    white-space: nowrap;
    background: linear-gradient(145deg, #1e40af 0%, #2563eb 45%, #3b82f6 100%);
    border: 1.5px solid rgba(255, 255, 255, 0.92);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.14),
        0 3px 10px rgba(37, 99, 235, 0.38),
        inset 0 1px 0 rgba(255, 255, 255, 0.28);
    pointer-events: none;
    user-select: none;
}
.top-plan-chip__icon {
    flex-shrink: 0;
    opacity: 0.95;
    filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.4));
}
.top-plan-chip__text {
    font-size: 0.5rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
[data-theme="dark"] .top-plan-chip {
    color: #eff6ff;
    background: linear-gradient(145deg, #1e3a8a 0%, #2563eb 50%, #60a5fa 100%);
    border-color: rgba(30, 31, 32, 0.95);
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.4),
        0 3px 12px rgba(37, 99, 235, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
@media (prefers-reduced-motion: reduce) {
    .top-avatar-shell,
    .top-profile-block:hover .top-avatar-shell { transition: none; }
}

.profile-dropdown-menu {
    position: absolute; top: calc(100% + 15px); left: 0; width: 260px;
    background: var(--bg-surface-solid); border-radius: 20px; padding: 8px 0;
    box-shadow: 0 15px 40px rgba(0,0,0,0.15); border: 1px solid var(--border);
    display: none; flex-direction: column; z-index: 2000;
}
[data-theme="dark"] .profile-dropdown-menu { background: #1e1f20; box-shadow: 0 15px 40px rgba(0,0,0,0.4); }
.profile-dropdown-menu.active { display: flex; animation: dropFade 0.2s ease-out; }
@keyframes dropFade { from {opacity: 0; transform: translateY(-10px);} to {opacity: 1; transform: translateY(0);} }

.menu-item-header { 
    padding: 12px 20px; font-weight: bold; font-size: 1rem; color: var(--text-main); 
    display: flex; align-items: center; justify-content: space-between; direction: ltr;
}
.profile-dropdown-menu .menu-item {
    display: flex; align-items: center; gap: 14px; padding: 12px 20px; border: none; 
    background: transparent; width: 100%; text-align: right; cursor: pointer; 
    color: var(--text-main); font-family: inherit; font-size: 0.95rem; transition: 0.2s;
}
.profile-dropdown-menu .menu-item:hover { background: var(--bg-app); }
.profile-dropdown-menu .menu-item svg { color: var(--text-muted); }
.profile-dropdown-menu .menu-item:hover svg { color: var(--text-main); }
.notification-dot { width: 8px; height: 8px; background: var(--danger); border-radius: 50%; margin-right: auto; box-shadow: 0 0 8px var(--danger); }
.text-danger { color: var(--danger) !important; }
.text-danger svg { color: var(--danger) !important; }


/* ================= Input Box & Resizer ================= */
.input-section { position: relative; padding-bottom: 24px; padding-top: 10px; overflow: visible !important; z-index: 120; }
.input-wrapper {
    position: relative;
    min-height: 60px;
    transition: height 0.1s;
    overflow: visible;
    z-index: 120;
}
.input-wrapper.has-open-popup {
    z-index: 10050;
    overflow: visible;
}

#normal-input-controls.input-controls {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    width: 100%;
    min-width: 0;
}

#chat-input {
    flex: 1 1 0;
    min-width: 0;
    max-width: 100%;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-family: inherit;
    font-size: var(--chat-font-size, 15px);
    line-height: 1.5;
    color: var(--text-main);
    padding: 10px 4px;
    max-height: 200px;
}

.action-menu-container {
    flex: 0 0 auto;
}

#normal-input-controls .voice-btn,
#normal-input-controls .send-btn,
#normal-input-controls > .icon-btn {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .btn-pro-prompt-quick {
        display: none !important;
    }

    #normal-input-controls.input-controls {
        gap: 4px;
    }

    .action-menu-container {
        margin-left: 0;
    }

    #chat-input {
        padding: 8px 2px;
        font-size: 16px;
    }

    #normal-input-controls .voice-btn,
    #normal-input-controls .send-btn,
    .action-menu-container .icon-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }

    .input-section {
        padding-left: 8px;
        padding-right: 8px;
    }
}

/* دستگیره تغییر سایز */
.resizer-handle {
    position: absolute; top: -1px; left: -1px; width: 30px; height: 30px; cursor: nwse-resize; z-index: 10;
    background: linear-gradient(135deg, rgba(11,87,208,0.3) 0%, transparent 50%);
    border-top-left-radius: 24px; opacity: 0; transition: opacity 0.3s;
}
.input-wrapper:hover .resizer-handle { opacity: 1; }

.action-menu-container { position: relative; display: flex; align-items: center; justify-content: center; margin-left: 8px; z-index: 9999 !important; }
.action-menu-trigger { transition: transform 0.3s, color 0.3s; }
.action-menu-trigger.active { transform: rotate(45deg); color: var(--accent); }

/* منوی شناور + */
.floating-menu {
    position: absolute; bottom: calc(100% + 15px); right: 0; width: 250px;
    background: var(--bg-surface-solid); border-radius: 20px; padding: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15); border: 1px solid var(--border);
    display: none; z-index: 10060 !important;
}
[data-theme="dark"] .floating-menu { background: #1e1f20; }
.floating-menu.active { display: block; animation: menuFadeIn 0.2s ease-out; }
.floating-menu .menu-item { 
    display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px; 
    cursor: pointer; transition: 0.2s; color: var(--text-main); font-size: 0.95rem; 
}
.floating-menu .menu-item:hover { background: var(--bg-app); }
.floating-menu .menu-item svg { color: var(--text-muted); }
.menu-divider { height: 1px; background: var(--border); margin: 6px 12px; }

/* زیر منو (بیشتر) */
.has-submenu { position: relative; }
.has-submenu .chevron { margin-right: auto; transition: transform 0.2s; }
.has-submenu:hover .chevron { transform: rotate(90deg); }
.sub-menu {
    position: absolute; bottom: 0; right: calc(100% + 5px); width: 210px;
    background: var(--bg-surface-solid); display: none; border-radius: 16px; padding: 8px; 
    border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}
[data-theme="dark"] .sub-menu { background: #1e1f20; }
.has-submenu:hover .sub-menu { display: block; animation: dropFade 0.2s ease-out; }

/* ================= Response mode picker (Gemini-style) ================= */
.response-mode-container {
    position: relative;
    flex: 0 0 auto;
    z-index: 10061;
}

.response-mode-trigger {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-surface-solid);
    color: var(--text-main);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
    max-width: 96px;
}

.response-mode-trigger:hover,
.response-mode-trigger.active {
    border-color: var(--accent);
    background: var(--accent-light, rgba(11, 87, 208, 0.08));
    color: var(--accent);
}

.response-mode-trigger:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.response-mode-trigger-icon {
    display: flex;
    color: var(--accent);
}

.response-mode-trigger-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.response-mode-chevron {
    opacity: 0.65;
    flex-shrink: 0;
}

.response-mode-menu {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 0;
    width: min(280px, calc(100vw - 32px));
    padding: 8px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: var(--bg-surface-solid);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.14);
    display: none;
    z-index: 10062 !important;
}

.response-mode-menu.active {
    display: block;
    animation: menuFadeIn 0.2s ease-out;
}

.response-mode-option {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: none;
    border-radius: 14px;
    background: transparent;
    color: var(--text-main);
    cursor: pointer;
    text-align: right;
    transition: background 0.15s;
}

.response-mode-option:hover {
    background: var(--bg-app);
}

.response-mode-option-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.response-mode-option-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.response-mode-option-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.response-mode-check {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: transparent;
    flex-shrink: 0;
}

.response-mode-option.is-active .response-mode-check {
    background: var(--accent);
}

.response-mode-option.is-active .response-mode-check svg {
    opacity: 1;
}

.response-mode-check svg {
    opacity: 0;
}

.response-mode-option.is-active .response-mode-check svg {
    opacity: 1;
}

.response-mode-upgrade {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-light, rgba(11, 87, 208, 0.1));
    padding: 4px 10px;
    border-radius: 999px;
    flex-shrink: 0;
}

.response-mode-option.is-locked {
    opacity: 0.92;
}

.response-mode-option.is-locked .response-mode-check {
    display: none;
}

.response-mode-option.is-locked:hover {
    background: var(--bg-app);
}

@media (max-width: 768px) {
    .response-mode-trigger {
        height: 40px;
        padding: 0 8px;
        max-width: 84px;
        font-size: 0.75rem;
    }

    .response-mode-trigger-icon {
        display: none;
    }

    .response-mode-menu {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        max-width: 100% !important;
        border-radius: 24px 24px 0 0 !important;
        padding: 20px 16px 28px !important;
        z-index: 100000 !important;
        animation: slideUpBottomSheet 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    }

    .response-mode-menu::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: var(--border);
        border-radius: 4px;
        margin: 0 auto 16px;
    }
}

/* ================= Footer Text & Icons ================= */
.footer-disclaimer { text-align: center; padding-top: 12px; line-height: 1.5; display: flex; justify-content: center; }
.disclaimer-text { font-size: 0.75rem; color: var(--text-muted); }

/* آیکون هشدار جایگزین متن در موبایل */
.disclaimer-icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 50%;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.disclaimer-icon-btn:hover {
    color: var(--accent);
    background: var(--accent-light);
}


/* ================= Advanced Settings Modal ================= */
.settings-modal-box {
    display: flex; flex-direction: row; padding: 0 !important; max-width: 850px !important; 
    height: 70vh !important; min-height: 500px; overflow: hidden !important;
}
.settings-sidebar { 
    width: 260px; background: var(--bg-app); border-left: 1px solid var(--border); 
    display: flex; flex-direction: column; padding: 24px 0; z-index: 2;
}
[data-theme="dark"] .settings-sidebar { background: #18191a; }
.settings-header-title { 
    padding: 0 24px 20px; font-size: 1.4rem; font-weight: bold; color: var(--text-main); 
    border-bottom: 1px solid var(--border); margin-bottom: 16px; 
}
.settings-tabs { display: flex; flex-direction: column; gap: 4px; padding: 0 12px; flex: 1; }
.tab-btn { 
    display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: none; 
    background: transparent; color: var(--text-muted); font-family: inherit; font-size: 1rem; 
    cursor: pointer; border-radius: 12px; transition: 0.2s; font-weight: 500; 
}
.tab-btn:hover { background: rgba(11, 87, 208, 0.05); color: var(--text-main); }
.tab-btn.active { background: rgba(11, 87, 208, 0.1); color: var(--accent); font-weight: bold; }
.tab-btn.active svg { color: var(--accent); }
.settings-version { padding: 16px 24px; color: var(--text-muted); font-size: 0.8rem; text-align: left; }

.settings-modal-box { position: relative; }
.modal-close-btn {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 10;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-surface-solid, #fff);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
.modal-close-btn:hover {
    color: var(--text-main);
    border-color: rgba(11, 87, 208, 0.35);
    background: var(--accent-light, rgba(11, 87, 208, 0.08));
    transform: scale(1.04);
}
[data-theme="dark"] .modal-close-btn {
    background: #282a2c;
    border-color: rgba(255, 255, 255, 0.1);
}

.pane-subtitle {
    margin: -12px 0 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.55;
}
.settings-row--switch { gap: 16px; }
.settings-switch {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
    cursor: pointer;
}
.settings-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.settings-switch__track {
    width: 44px;
    height: 26px;
    border-radius: 999px;
    background: var(--border);
    transition: background 0.2s;
    position: relative;
}
.settings-switch__track::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}
.settings-switch input:checked + .settings-switch__track {
    background: var(--accent, #0b57d0);
}
.settings-switch input:checked + .settings-switch__track::after {
    transform: translateX(-18px);
}
.settings-save-btn {
    width: auto !important;
    min-width: 180px;
    margin-top: 8px;
    padding: 0 28px !important;
}
.glass-hint,
.settings-voice-hint {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    margin: 16px 0;
    border-radius: 12px;
    background: rgba(11, 87, 208, 0.06);
    border: 1px solid rgba(11, 87, 208, 0.12);
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.5;
}
.settings-voice-hint svg { flex-shrink: 0; color: var(--accent); margin-top: 1px; }

/* وضعیت بسته */
.plan-status-root { width: 100%; }
.plan-status-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    background: linear-gradient(145deg, var(--bg-app, #f8fafc) 0%, var(--bg-surface-solid, #fff) 100%);
}
[data-theme="dark"] .plan-status-card {
    background: linear-gradient(145deg, #1a1b1c 0%, #1e1f20 100%);
}
.plan-status-card--pro {
    border-color: rgba(11, 87, 208, 0.35);
    box-shadow: 0 4px 20px rgba(11, 87, 208, 0.12);
}
.plan-status-card--loading { text-align: center; padding: 28px; }
.plan-status-loading { margin: 0; color: var(--text-muted); font-size: 0.875rem; }
.plan-status-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}
.plan-status-badge {
    display: inline-block;
    font-size: 0.625rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(11, 87, 208, 0.12);
    color: var(--accent);
    margin-bottom: 6px;
}
.plan-status-card--pro .plan-status-badge {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
}
.plan-status-name {
    margin: 0 0 4px;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
}
.plan-status-expiry {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.plan-status-upgrade {
    flex-shrink: 0;
    padding: 8px 14px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 700;
    text-decoration: none;
    transition: opacity 0.2s, transform 0.15s;
}
.plan-status-upgrade:hover { opacity: 0.92; transform: translateY(-1px); }
.plan-usage-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.plan-usage-item__top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.8125rem;
    color: var(--text-muted);
}
.plan-usage-bar {
    height: 6px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}
.plan-usage-bar__fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), #60a5fa);
    transition: width 0.4s ease;
}
.plan-usage-bar__fill.is-warn {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}
.plan-usage-bar__fill.is-danger {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.settings-content-area { flex: 1; padding: 32px; overflow-y: auto; position: relative; background: var(--bg-surface-solid); }
.settings-tab-pane { display: none; }
.settings-tab-pane.active { display: block; }
.settings-tab-pane[hidden] { display: none !important; }
.pane-title { font-size: 1.3rem; font-weight: bold; margin-bottom: 24px; color: var(--text-main); border-bottom: 1px solid var(--border); padding-bottom: 16px; }

/* فرم‌های تنظیمات و شخصی‌سازی */
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--border); }
.settings-row:last-child { border-bottom: none; }
.row-info h4 { font-size: 1rem; color: var(--text-main); margin-bottom: 6px; }
.row-info p { font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }

.custom-select { 
    background: var(--bg-app); border: 1px solid var(--border); padding: 10px 16px; 
    border-radius: 12px; color: var(--text-main); font-family: inherit; outline: none; cursor: pointer;
}
[data-theme="dark"] .custom-select { background: #1e1f20; }

.settings-row-col { display: flex; flex-direction: column; gap: 12px; padding: 20px 0; border-bottom: 1px solid var(--border); }
.settings-row-col h4 { font-size: 1rem; color: var(--text-main); }
.custom-textarea { 
    width: 100%; background: var(--bg-app); border: 1px solid var(--border); padding: 14px; 
    border-radius: 16px; color: var(--text-main); font-family: inherit; resize: vertical; 
    min-height: 100px; outline: none; transition: 0.2s; line-height: 1.6;
}
.custom-textarea:focus, .custom-input-line:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(11,87,208,0.1); }
[data-theme="dark"] .custom-textarea, [data-theme="dark"] .custom-input-line { background: #1e1f20; }

.custom-input-line { 
    width: 100%; background: var(--bg-app); border: 1px solid var(--border); padding: 14px; 
    border-radius: 12px; color: var(--text-main); font-family: inherit; outline: none; 
    transition: 0.2s; margin-bottom: 8px;
}

.tone-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tone-tag { 
    background: transparent; border: 1px solid var(--border); padding: 8px 16px; 
    border-radius: 20px; font-size: 0.85rem; color: var(--text-muted); cursor: pointer; transition: 0.2s; 
}
.tone-tag:hover { border-color: var(--accent); color: var(--accent); }
.tone-tag.active { background: var(--accent); color: white; border-color: var(--accent); }

/* ================= استایل‌های پیشرفته مارک‌دان (Markdown) ================= */

/* تیترها */
.ai-message h1, .ai-message h2, .ai-message h3, .ai-message h4 {
    color: var(--text-main); margin: 24px 0 12px 0; font-weight: 700; line-height: 1.4;
}
.ai-message h1 { font-size: 1.5rem; color: var(--accent); }
.ai-message h2 { font-size: 1.3rem; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.ai-message h3 { font-size: 1.1rem; }

/* پاراگراف‌ها و فاصله‌ها */
.ai-message p { margin-bottom: 12px; line-height: 1.8; }

/* لیست‌های مرتب و نامرتب */
.ai-message ul, .ai-message ol { margin: 12px 0 12px 24px; padding: 0; }
.ai-message li { margin-bottom: 6px; line-height: 1.6; }

/* نقل‌قول‌ها (Blockquotes) */
.ai-message blockquote {
    border-right: 4px solid var(--accent);
    background: var(--bg-app);
    padding: 12px 16px;
    margin: 16px 0;
    border-radius: 8px 0 0 8px;
    color: var(--text-muted);
    font-style: italic;
}

/* تضمین چپ‌چین بودن کدها در هر شرایطی */
.ai-message pre, 
.ai-message code {
    direction: ltr !important;
    text-align: left !important;
}
.ai-message p code, .ai-message li code {
    background: var(--border); color: var(--danger); padding: 2px 6px;
    border-radius: 6px; font-family: 'Consolas', monospace; font-size: 0.9em;
    display: inline-block;
}

/* رفع مشکل نامرئی بودن متن کد در صورت لود نشدن استایل دارک */
.ai-message pre code {
    color: #333; 
}
[data-theme="dark"] .ai-message pre code {
    color: #e3e3e3;
}
.code-block-wrapper pre code {
    color: #e3e3e3 !important; 
}

/* ================= استایل حرفه‌ای Infobox (Wikipedia/Gemini Style) ================= */
.infobox-container {
    background: #ffffff !important; 
    border: 1px solid var(--border);
    border-radius: 20px; margin: 20px 0; overflow: hidden;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    direction: rtl; 
}
[data-theme="dark"] .infobox-container { background: #1e1e1e !important; }

.infobox-header {
    background: #f8f9fa; padding: 12px 16px; font-weight: bold;
    font-size: 0.95rem; color: var(--accent); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 8px;
}
[data-theme="dark"] .infobox-header { background: #2d2d2d; }

.table-responsive { width: 100%; overflow-x: auto; }
.ai-table { width: 100%; border-collapse: collapse; background: #ffffff !important; }
[data-theme="dark"] .ai-table { background: #1e1e1e !important; }

.ai-table th {
    background: #fdfdfd; color: var(--text-main); padding: 14px 16px;
    text-align: right !important; width: 35%; border-left: 1px solid var(--border); font-weight: 800;
}
[data-theme="dark"] .ai-table th { background: #252525; }

.ai-table td { padding: 14px 16px; color: var(--text-main); text-align: right !important; }
.ai-table tr { border-bottom: 1px solid var(--border); }
.ai-table tr:last-child { border-bottom: none; }
.ai-table tr:nth-child(even) td, .ai-table tr:nth-child(even) th { background: #fafafa; }
[data-theme="dark"] .ai-table tr:nth-child(even) td, [data-theme="dark"] .ai-table tr:nth-child(even) th { background: rgba(255, 255, 255, 0.02); }

/* --- استایل بخش‌های تاشو (Details/Summary) --- */
.ai-message details {
    background: #ffffff; border: 1px solid var(--border); border-radius: 16px;
    margin: 16px 0; padding: 12px 16px; transition: var(--transition);
    box-shadow: 0 4px 12px rgba(0,0,0,0.02); direction: rtl;
}
[data-theme="dark"] .ai-message details { background: #1e1e1e; }
.ai-message summary {
    cursor: pointer; font-weight: 800; color: var(--text-main); list-style: none;
    display: flex; align-items: center; gap: 10px; outline: none;
}
.ai-message summary::-webkit-details-marker { display: none; }
.ai-message details[open] summary { margin-bottom: 12px; border-bottom: 1px dashed var(--border); padding-bottom: 12px; color: var(--accent); }
.ai-message b, .ai-message strong { color: var(--accent); font-weight: 800; }

/* ================= بهینه‌سازی موبایل ================= */
@media (max-width: 768px) {
    .infobox-container { margin: 12px 0; border-radius: 15px; }
    .ai-table th { width: 40%; }
    .ai-table th, .ai-table td { padding: 10px 12px; font-size: 0.9rem; }
    
    .code-block-wrapper { margin: 12px 0; border-radius: 12px; }
    .code-header { padding: 10px 12px; }
    .code-scroll-container pre { padding: 12px; }
    .code-scroll-container code { font-size: 0.85rem; }
    .code-btn span { display: none; } 
    .mac-controls { display: none; } /* مخفی کردن دکمه‌های مک در موبایل برای فضای بیشتر */
    .code-lang-badge { position: static; transform: none; }

    .message-footer-actions { opacity: 1; margin-top: 8px; } 
    .ai-avatar { width: 30px; height: 30px; font-size: 14px; }
    
    .floating-menu { width: 220px; bottom: calc(100% + 10px); left: 0; right: auto; }
    .sub-menu { right: 0; bottom: 100%; width: 100%; }

    .settings-modal-box { flex-direction: column; height: 85vh !important; }
    .settings-sidebar { width: 100%; padding: 16px 0; border-left: none; border-bottom: 1px solid var(--border); }
    .settings-tabs { flex-direction: row; overflow-x: auto; padding-bottom: 8px; }
    .tab-btn { white-space: nowrap; padding: 10px 14px; }
    .settings-content-area { padding: 20px; }
    .settings-version { display: none; }
    
    .settings-row { padding: 16px 0; flex-wrap: wrap; gap: 12px; }
    .settings-row .custom-select { width: 100%; }
    .settings-row-col { padding: 24px 0; }
    .custom-select { padding: 12px 18px; font-size: 1rem; }
    .plan-status-card__head { flex-direction: column; align-items: stretch; }
    .plan-status-upgrade { text-align: center; }
    .modal-close-btn { top: 10px; left: 10px; width: 34px; height: 34px; }
    .settings-content-area { padding: 16px; padding-top: 48px; }
    
    .disclaimer-text { display: none !important; }
    .disclaimer-icon-btn { display: flex !important; }
}

/* اصلاح بخش پیام‌ها در chat.css */
.chat-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.message {
    width: 100% !important;
    display: flex !important;
    flex-direction: row !important; 
    align-items: flex-start;
    margin-bottom: 15px;
    gap: 12px;
    clear: both;
}
.user-message { justify-content: flex-start; }
.ai-message { justify-content: flex-start; }

.message-body {
    max-width: calc(100% - 50px); 
    line-height: 1.8;
    word-wrap: break-word;
    position: relative;
}
.ai-avatar, .user-avatar {
    flex-shrink: 0; 
    z-index: 5;
}


.usage-stats-container { margin-bottom: 15px; padding: 0 10px; }
.usage-header { display: flex; justify-content: space-between; font-size: 0.8rem; margin-bottom: 8px; color: var(--text-muted); }
.usage-progress-bg { height: 6px; background: var(--bg-body); border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.usage-progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #ff9a9e); border-radius: 10px; transition: width 0.4s ease; }

/* Image generation — ChatGPT-style */
:root {
    --gpt-image-size: min(480px, calc(100vw - 88px));
    --gpt-image-radius: 20px;
    --gpt-image-canvas-bg: #3a3a3a;
    --gpt-image-canvas-bg-light: #ececec;
}

body.image-gen-mode-active #chat-input::placeholder { color: var(--accent); }
body.image-gen-mode-active .menu-item[data-action="generate-image"] { background: rgba(99,102,241,0.12); color: var(--accent); border-radius: 10px; }
.image-gen-banner { border-color: rgba(168, 85, 247, 0.35); }
.image-welcome-hint { color: var(--text-muted); font-size: 0.95rem; margin-top: 8px; }
.image-welcome-icon { font-size: 2.4rem; }
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* تصویر پیوست‌شده در پیام کاربر */
.user-message .chat-user-image {
    display: block;
    max-width: var(--gpt-image-size);
    max-height: 520px;
    width: auto;
    height: auto;
    object-fit: cover;
    border-radius: var(--gpt-image-radius);
    margin-bottom: 10px;
    border: 1px solid var(--border);
}

.ai-message.ai-image-message .message-body,
.ai-message .message-body:has(.generated-image-card),
.image-gen-loading-message .message-body {
    max-width: var(--gpt-image-size) !important;
    width: 100% !important;
    padding: 4px 0 8px !important;
    background: transparent !important;
    box-shadow: none !important;
}

.generated-image-card {
    display: block;
    width: 100%;
    max-width: var(--gpt-image-size);
    opacity: 0;
    transform: translateY(8px) scale(0.985);
    animation: gptImageReveal 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.generated-image-card.is-revealed {
    animation: none;
    opacity: 1;
    transform: none;
}

.generated-image-frame,
.gpt-image-canvas {
    position: relative;
    width: 100%;
    max-width: var(--gpt-image-size);
    aspect-ratio: 1 / 1;
    border-radius: var(--gpt-image-radius);
    overflow: hidden;
    background: var(--gpt-image-canvas-bg);
    border: none;
    box-shadow: none;
}
[data-theme="light"] .generated-image-frame,
[data-theme="light"] .gpt-image-canvas {
    background: var(--gpt-image-canvas-bg-light);
}

.generated-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    cursor: zoom-in;
}
.generated-image-frame.is-loaded .generated-image {
    animation: gptImageFadeIn 0.45s ease-out forwards;
}
.generated-image-zoomable { cursor: zoom-in; }

.generated-image-actions {
    display: flex;
    margin-top: 10px;
    opacity: 0.85;
    transition: opacity 0.2s ease;
}
.generated-image-card:hover .generated-image-actions { opacity: 1; }

/* Canvas لودینگ — شبیه ChatGPT */
.gpt-image-stage { width: 100%; max-width: var(--gpt-image-size); }
.gpt-image-canvas.is-creating {
    animation: gptCanvasPulse 2.4s ease-in-out infinite;
}
.gpt-image-creating-label {
    position: absolute;
    top: 14px;
    left: 16px;
    z-index: 4;
    font-size: 0.9rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.92);
    letter-spacing: 0.01em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    transition: opacity 0.35s ease;
}
[data-theme="light"] .gpt-image-creating-label {
    color: rgba(0, 0, 0, 0.75);
    text-shadow: none;
}

.gpt-image-dot-grid {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.14) 1px, transparent 1px);
    background-size: 14px 14px;
    animation: gptDotDrift 3s linear infinite;
    opacity: 0.85;
}
[data-theme="light"] .gpt-image-dot-grid {
    background-image: radial-gradient(circle, rgba(0, 0, 0, 0.12) 1px, transparent 1px);
}

.gpt-image-shimmer-wave {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        105deg,
        transparent 0%,
        transparent 40%,
        rgba(255, 255, 255, 0.07) 48%,
        rgba(255, 255, 255, 0.14) 50%,
        rgba(255, 255, 255, 0.07) 52%,
        transparent 60%,
        transparent 100%
    );
    background-size: 220% 100%;
    animation: gptShimmerSweep 2.2s ease-in-out infinite;
    z-index: 2;
}

.gpt-image-glow {
    position: absolute;
    inset: -20%;
    background: radial-gradient(ellipse at 30% 20%, rgba(99, 102, 241, 0.12), transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(168, 85, 247, 0.1), transparent 55%);
    animation: gptGlowRotate 6s linear infinite;
    z-index: 1;
    pointer-events: none;
}

@keyframes gptDotDrift {
    0% { background-position: 0 0; }
    100% { background-position: 14px 14px; }
}
@keyframes gptShimmerSweep {
    0% { background-position: 120% 0; }
    100% { background-position: -120% 0; }
}
@keyframes gptGlowRotate {
    to { transform: rotate(360deg); }
}
@keyframes gptCanvasPulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.06); }
}
@keyframes gptImageReveal {
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes gptImageFadeIn {
    from { opacity: 0; transform: scale(1.02); }
    to { opacity: 1; transform: scale(1); }
}
.image-lightbox { position: fixed; inset: 0; z-index: 10050; display: grid; place-items: center; padding: 24px; background: rgba(0,0,0,0.88); backdrop-filter: blur(4px); }
.image-lightbox[hidden] { display: none !important; }
body.image-lightbox-open { overflow: hidden; }
.image-lightbox-img { max-width: min(96vw, 1100px); max-height: 92vh; object-fit: contain; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.45); }
.image-lightbox-close { position: absolute; top: 16px; left: 16px; width: 40px; height: 40px; border: none; border-radius: 50%; background: rgba(255,255,255,0.12); color: #fff; font-size: 1.6rem; line-height: 1; cursor: pointer; }
.image-download-btn { display: none; }
.image-gen-error {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 0.9rem;
    max-width: var(--gpt-image-size);
}

/* lazy load داخل همان canvas */
.generated-image-frame.is-loading .generated-image { opacity: 0; }
.generated-image-skeleton.gpt-image-canvas {
    position: absolute;
    inset: 0;
    z-index: 3;
    max-width: none;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
}
.generated-image-frame.is-loaded .generated-image-skeleton,
.generated-image-frame.is-error .generated-image-skeleton {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.35s ease;
}
.generated-image-frame.is-error .generated-image { opacity: 0.35; filter: grayscale(0.4); }
.generated-image-error-text {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    padding: 12px;
    text-align: center;
}

/* اسکلتون بارگذاری گفتگو */
.chat-history-skeleton { padding: 20px 16px 32px; display: flex; flex-direction: column; gap: 22px; max-width: 820px; margin: 0 auto; }
.chat-skel-row { display: flex; gap: 12px; align-items: flex-start; animation: chatSkelPulse 1.4s ease-in-out infinite; }
.chat-skel-row.user { flex-direction: row-reverse; }
.chat-skel-row.ai { animation-delay: 0.15s; }
.chat-skel-row:nth-child(3) { animation-delay: 0.3s; }
.chat-skel-avatar { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(168,85,247,0.18)); }
.chat-skel-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.chat-skel-row.user .chat-skel-lines { align-items: flex-end; }
.chat-skel-line { display: block; height: 12px; border-radius: 8px; background: linear-gradient(90deg, var(--bg-surface-solid) 0%, rgba(99,102,241,0.08) 50%, var(--bg-surface-solid) 100%);
    background-size: 200% 100%; animation: chatSkelShimmer 1.2s ease-in-out infinite; }
.chat-skel-line.w90 { width: 90%; max-width: 420px; }
.chat-skel-line.w80 { width: 80%; max-width: 380px; }
.chat-skel-line.w75 { width: 75%; max-width: 320px; }
.chat-skel-line.w70 { width: 70%; max-width: 340px; }
.chat-skel-line.w55 { width: 55%; max-width: 240px; }
.chat-skel-line.w40 { width: 40%; max-width: 180px; }
@keyframes chatSkelShimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes chatSkelPulse { 0%, 100% { opacity: 0.65; } 50% { opacity: 1; } }

/* نوار ابزار پیام — سبک ChatGPT */
.msg-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.message-footer-actions.msg-toolbar {
    margin-top: 12px;
}
.generated-image-actions.msg-toolbar {
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
    padding: 2px 0;
    max-width: var(--gpt-image-size, min(480px, 92vw));
}
.msg-toolbar-start,
.msg-toolbar-end {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}
.msg-toolbar-icon {
    display: block;
    flex-shrink: 0;
}
.msg-toolbar-btn,
.msg-toolbar-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: rgba(255, 255, 255, 0.72);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
[data-theme="light"] .msg-toolbar-btn,
[data-theme="light"] .msg-toolbar-download {
    color: rgba(0, 0, 0, 0.55);
}
.msg-toolbar-btn:hover,
.msg-toolbar-download:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.95);
}
[data-theme="light"] .msg-toolbar-btn:hover,
[data-theme="light"] .msg-toolbar-download:hover {
    background: rgba(0, 0, 0, 0.06);
    color: rgba(0, 0, 0, 0.85);
}
.msg-feedback-btn.is-active {
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
}
[data-theme="light"] .msg-feedback-btn.is-active {
    color: var(--accent);
    background: rgba(11, 87, 208, 0.1);
}
.btn-pro-prompt:hover {
    color: #c4b5fd;
    background: rgba(167, 139, 250, 0.12);
}
.msg-feedback-group {
    display: inline-flex;
    align-items: center;
    gap: 0;
}
/* سازگاری با استایل قدیمی */
.msg-action-btn {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.image-download-btn {
    display: none;
}

/* مودال پرامت حرفه‌ای — طراحی sheet مدرن (موبایل) / دیالوگ (دسکتاپ) */
.image-pro-modal { z-index: 10060; }
.image-pro-modal.active {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    animation: imageProOverlayIn 0.28s ease;
}
@keyframes imageProOverlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@media (min-width: 640px) {
    .image-pro-modal.active {
        align-items: center;
        padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
    }
}
.image-pro-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(10px) saturate(1.15);
    -webkit-backdrop-filter: blur(10px) saturate(1.15);
}
[data-theme="dark"] .image-pro-modal-backdrop {
    background: rgba(0, 0, 0, 0.72);
}
.image-pro-modal-panel {
    position: relative;
    width: 100%;
    max-width: 540px;
    max-height: min(94dvh, 760px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    border-radius: 24px 24px 0 0;
    z-index: 1;
    border: 1px solid var(--border);
    background: var(--bg-surface-solid);
    box-shadow:
        0 -12px 48px rgba(15, 23, 42, 0.22),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    animation: imageProSheetUp 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}
.image-pro-modal-panel::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    border-radius: var(--radius-full);
    background: rgba(0, 0, 0, 0.14);
    margin: 10px auto 0;
    flex-shrink: 0;
}
[data-theme="dark"] .image-pro-modal-panel::before {
    background: rgba(255, 255, 255, 0.22);
}
@keyframes imageProSheetUp {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}
@media (min-width: 640px) {
    .image-pro-modal-panel {
        border-radius: 22px;
        max-height: min(90dvh, 720px);
        animation: imageProDialogIn 0.32s cubic-bezier(0.22, 1, 0.36, 1);
        box-shadow:
            0 28px 80px rgba(15, 23, 42, 0.28),
            0 0 0 1px rgba(255, 255, 255, 0.06) inset;
    }
    .image-pro-modal-panel::before {
        display: none;
    }
    @keyframes imageProDialogIn {
        from { opacity: 0; transform: translateY(10px) scale(0.98); }
        to { opacity: 1; transform: translateY(0) scale(1); }
    }
}
.image-pro-modal-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 20px 16px;
    flex-shrink: 0;
    background: var(--bg-surface-solid);
    border-bottom: 1px solid var(--border);
}
.image-pro-modal-brand {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-width: 0;
    padding-left: 4px;
}
.image-pro-modal-icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: linear-gradient(145deg, rgba(11, 87, 208, 0.14), rgba(99, 102, 241, 0.1));
    color: var(--accent);
    box-shadow: 0 1px 2px rgba(11, 87, 208, 0.08);
    border: 1px solid rgba(11, 87, 208, 0.12);
}
[data-theme="dark"] .image-pro-modal-icon {
    background: linear-gradient(145deg, rgba(168, 199, 250, 0.18), rgba(129, 140, 248, 0.1));
    border-color: rgba(168, 199, 250, 0.2);
}
.image-pro-modal-title {
    margin: 0 0 6px;
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-main);
    line-height: 1.3;
}
.image-pro-modal-sub {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.55;
    max-width: 36ch;
}
.image-pro-modal-close {
    position: static;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 12px;
}
.image-pro-modal-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 20px 8px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.image-pro-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.pro-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 20px 0 4px;
    padding: 16px;
    border-radius: 16px;
    background: var(--bg-app);
    border: 1px solid var(--border);
}
[data-theme="dark"] .pro-form-grid {
    background: rgba(0, 0, 0, 0.22);
}
.pro-form-grid::before {
    content: 'تنظیمات خروجی';
    grid-column: 1 / -1;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.pro-field-wide { grid-column: 1 / -1; }
.pro-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.pro-field label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0;
}
.pro-field textarea,
.pro-field select {
    width: 100%;
    min-height: 44px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-input, var(--bg-surface-solid));
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9375rem;
    line-height: 1.45;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}
.pro-field select {
    padding-left: 36px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23444746' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    background-size: 16px;
}
[data-theme="dark"] .pro-field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23c4c7c5' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
.pro-field textarea {
    resize: vertical;
    min-height: 112px;
    line-height: 1.65;
    padding: 14px 16px;
}
.pro-field textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.72;
}
.pro-field textarea:hover,
.pro-field select:hover {
    border-color: rgba(11, 87, 208, 0.22);
}
[data-theme="dark"] .pro-field textarea:hover,
[data-theme="dark"] .pro-field select:hover {
    border-color: rgba(168, 199, 250, 0.28);
}
.pro-field textarea:focus,
.pro-field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
    background: var(--bg-surface-solid);
}
.pro-field-required {
    margin-bottom: 4px;
}
@media (max-width: 639px) {
    .image-pro-modal-topbar {
        padding: 8px 16px 14px;
    }
    .image-pro-modal-body {
        padding: 16px 16px 0;
    }
    .pro-form-grid {
        grid-template-columns: 1fr;
        gap: 14px;
        margin-top: 16px;
        padding: 14px;
    }
    .pro-field-wide { grid-column: auto; }
    .image-pro-modal-title { font-size: 1.05rem; }
    .image-pro-modal-sub { font-size: 0.78rem; }
    .pro-field textarea { min-height: 100px; }
}
@media (max-width: 380px) {
    .image-pro-modal-brand { gap: 10px; }
    .image-pro-modal-icon { width: 40px; height: 40px; }
}
.pro-field textarea.field-invalid,
.pro-field select.field-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.14);
}
.pro-field-required label::after { content: ' *'; color: var(--danger); font-weight: 700; }
.field-error {
    margin: 6px 0 0;
    font-size: 0.8rem;
    color: #f87171;
    line-height: 1.4;
}
/* لودینگ ساخت پرامت */
.image-pro-modal.is-building-prompt .image-pro-modal-panel {
    pointer-events: none;
}
.pro-prompt-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 28px 16px;
    margin: 8px 0 4px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(167, 139, 250, 0.08));
    border: 1px solid rgba(99, 102, 241, 0.25);
    text-align: center;
}
.pro-prompt-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--accent, #6366f1);
    border-radius: 50%;
    animation: proPromptSpin 0.85s linear infinite;
}
.pro-prompt-loading-text {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}
.pro-prompt-loading-hint {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}
@keyframes proPromptSpin {
    to { transform: rotate(360deg); }
}
#btn-build-pro-prompt.is-loading {
    opacity: 0.85;
    pointer-events: none;
}
#btn-build-pro-prompt .btn-build-label[hidden],
#btn-build-pro-prompt .btn-build-loading-label[hidden] {
    display: none !important;
}
#btn-build-pro-prompt .btn-build-loading-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
#btn-build-pro-prompt.is-loading .btn-build-loading-label::before {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: proPromptSpin 0.7s linear infinite;
}

/* پیش‌نمایش بخش‌بندی‌شده */
.pro-prompt-preview-wrap {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}
.pro-preview-title {
    margin: 0 0 14px;
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}
.pro-prompt-sections {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: 280px;
    overflow-y: auto;
    padding-inline-end: 4px;
}
.pro-prompt-section-block {
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
}
[data-theme="light"] .pro-prompt-section-block {
    background: rgba(0, 0, 0, 0.02);
}
.pro-prompt-section-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--accent, #818cf8);
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}
.pro-prompt-section-body {
    font-size: 0.88rem;
    line-height: 1.7;
    color: var(--text-main);
    white-space: pre-wrap;
}
.pro-prompt-section-block[data-section-id="final_prompt"] {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.35);
}
.pro-prompt-section-block[data-section-id="final_prompt"] .pro-prompt-section-label {
    color: #c4b5fd;
}
.btn-ghost {
    background: transparent !important;
    border: 1px solid var(--border) !important;
    color: var(--text-muted) !important;
    font-size: 0.85rem !important;
}
.pro-prompt-preview {
    margin-top: 12px;
    padding: 14px;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    font-size: 0.88rem;
    line-height: 1.65;
    color: var(--text-main);
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
}
.image-pro-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin-top: 16px;
    padding: 12px 0 max(16px, env(safe-area-inset-bottom));
    background: linear-gradient(
        180deg,
        transparent 0%,
        var(--bg-surface-solid) 28%
    );
}
.image-pro-confirm-wrap {
    margin-top: 16px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.image-pro-modal #btn-build-pro-prompt.btn-secondary {
    width: 100%;
    min-height: 48px;
    padding: 14px 20px;
    border-radius: 14px;
    border: none;
    background: linear-gradient(165deg, var(--accent) 0%, #2563eb 52%, #4f46e5 100%);
    color: #fff;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.22s ease, opacity 0.2s ease, filter 0.2s ease;
    box-shadow:
        0 1px 2px rgba(11, 87, 208, 0.2),
        0 8px 24px rgba(11, 87, 208, 0.32);
}
.image-pro-modal #btn-build-pro-prompt.btn-secondary:hover {
    transform: translateY(-1px);
    filter: brightness(1.04);
    box-shadow:
        0 2px 4px rgba(11, 87, 208, 0.22),
        0 12px 28px rgba(11, 87, 208, 0.38);
}
.image-pro-modal #btn-build-pro-prompt.btn-secondary:active {
    transform: translateY(0);
    filter: brightness(0.98);
}
.image-pro-modal #btn-build-pro-prompt.btn-secondary.is-loading {
    opacity: 0.88;
    pointer-events: none;
}
@media (min-width: 640px) {
    .image-pro-actions {
        position: static;
        padding-bottom: 4px;
        background: none;
    }
}
.btn-secondary.is-loading { opacity: 0.7; pointer-events: none; }
.chat-item[data-category="image-gen"] .chat-icon { color: #a78bfa; }

/* دکمه سریع پرامت کنار + */
.btn-pro-prompt-quick {
    color: #c4b5fd !important;
    margin-inline-end: 4px;
}
.btn-pro-prompt-quick:hover {
    background: rgba(167, 139, 250, 0.15) !important;
    color: #e9d5ff !important;
}
.action-menu-container {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

/* ——— ضبط صدا ——— */
#main-input-wrapper.is-voice-recording,
#main-input-wrapper.is-voice-preview {
    border-color: rgba(11, 87, 208, 0.22);
    box-shadow: 0 0 0 1px rgba(11, 87, 208, 0.08), 0 12px 28px rgba(11, 87, 208, 0.1);
}
.gpt-voice-recording {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 16px;
    min-height: 52px;
    border-radius: 999px;
    background: linear-gradient(135deg, #1a1b1f 0%, #2d2f36 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}
[data-theme="light"] .gpt-voice-recording {
    background: linear-gradient(135deg, #f8fafc 0%, #e8eef8 100%);
    border-color: rgba(11, 87, 208, 0.15);
    box-shadow: 0 8px 24px rgba(11, 87, 208, 0.12);
}
.gpt-voice-recording-mid {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.gpt-voice-live-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55);
    animation: gptVoicePulse 1.4s ease-out infinite;
    flex-shrink: 0;
}
@keyframes gptVoicePulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); }
    70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
.gpt-voice-cancel {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.gpt-voice-cancel:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
}
.gpt-voice-dots {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 0;
    overflow: hidden;
    opacity: 0.45;
}
.gpt-voice-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    color: var(--text-muted);
}
.gpt-voice-wave {
    flex: 1;
    min-width: 80px;
    height: 36px;
    display: block;
    width: 100%;
}
.gpt-voice-stop {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 10px;
    background: #ef4444;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, background 0.15s;
}
.gpt-voice-stop:hover {
    transform: scale(1.05);
    background: #dc2626;
}
.gpt-voice-timer {
    font-size: 0.82rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-main, #1f1f1f);
    flex-shrink: 0;
    min-width: 40px;
    text-align: center;
}
[data-theme="dark"] .gpt-voice-timer {
    color: #f3f4f6;
}
.gpt-voice-send {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 10px;
    background: #fff;
    color: #111;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s;
}
.gpt-voice-send:hover {
    transform: scale(1.05);
}

/* پیش‌نمایش قبل از ارسال */
.gpt-voice-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 16px;
    min-height: 52px;
    border-radius: 999px;
    background: linear-gradient(135deg, #1a1b1f 0%, #2d2f36 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}
[data-theme="light"] .gpt-voice-preview {
    background: linear-gradient(135deg, #f8fafc 0%, #e8eef8 100%);
    border-color: rgba(11, 87, 208, 0.15);
    box-shadow: 0 8px 24px rgba(11, 87, 208, 0.12);
}
.gpt-voice-preview-discard {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.gpt-voice-preview-discard:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}
.gpt-voice-preview-play {
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 0;
    transition: transform 0.15s ease, background 0.15s ease;
}
.gpt-voice-preview-play:hover {
    transform: scale(1.05);
}
[data-theme="light"] .gpt-voice-preview-play {
    background: #fff;
    color: var(--accent, #0b57d0);
    box-shadow: 0 2px 8px rgba(11, 87, 208, 0.18);
}
.gpt-voice-preview-play .gp-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
}
.gpt-voice-preview-play .gp-icon svg {
    display: block;
    margin: 0;
}
.gpt-voice-preview-play .gp-icon--pause {
    display: none;
}
.gpt-voice-preview.is-playing .gpt-voice-preview-play .gp-icon--play {
    display: none;
}
.gpt-voice-preview.is-playing .gpt-voice-preview-play .gp-icon--pause {
    display: inline-flex;
}
.gpt-voice-preview-wave {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    height: 30px;
    padding: 0 4px;
}
.gpt-voice-preview-wave span {
    display: inline-block;
    width: 3px;
    height: 8px;
    border-radius: 3px;
    background: linear-gradient(180deg, #7dd3fc 0%, #3b82f6 100%);
    opacity: 0.85;
}
[data-theme="light"] .gpt-voice-preview-wave span {
    background: linear-gradient(180deg, #60a5fa 0%, #0b57d0 100%);
    opacity: 0.9;
}
.gpt-voice-preview-wave span:nth-child(3n) { height: 14px; }
.gpt-voice-preview-wave span:nth-child(5n) { height: 20px; }
.gpt-voice-preview-wave span:nth-child(7n) { height: 10px; }
.gpt-voice-preview.is-playing .gpt-voice-preview-wave span {
    animation: gpWave 0.9s ease-in-out infinite alternate;
}
.gpt-voice-preview.is-playing .gpt-voice-preview-wave span:nth-child(odd) {
    animation-delay: 0.15s;
}
@keyframes gpWave {
    from { transform: scaleY(0.35); opacity: 0.45; }
    to { transform: scaleY(1); opacity: 1; }
}
.gpt-voice-preview-time {
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 36px;
    text-align: center;
}
.gpt-voice-preview-send {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: var(--accent, #3b82f6);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s;
}
.gpt-voice-preview-send:hover {
    transform: scale(1.06);
}

/* پیام صوتی در چت */
.chat-voice-bubble {
    margin-top: 2px;
    max-width: min(300px, 88vw);
    user-select: none;
}

/* پیام صوتی: کادر جدا (نه حباب سنگین کل message-body) */
.user-message .message-body:has(.chat-voice-bubble),
.ai-message .message-body:has(.chat-voice-bubble) {
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    max-width: min(320px, 92vw);
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

.user-message .message-body:has(.chat-voice-bubble) {
    align-items: flex-end;
}

.user-message .chat-voice-bubble,
.ai-message .chat-voice-bubble {
    max-width: 100%;
    width: 100%;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--bg-surface-solid);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.05),
        0 4px 16px rgba(15, 23, 42, 0.04);
}

[data-theme="dark"] .user-message .chat-voice-bubble,
[data-theme="dark"] .ai-message .chat-voice-bubble {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.22);
}

/* متن همراه صدا (مثلاً پاسخ AI) — حباب جدا زیر کادر صدا */
.user-message .message-body:has(.chat-voice-bubble) > :not(.chat-voice-bubble):not(:empty),
.ai-message .message-body:has(.chat-voice-bubble) > :not(.chat-voice-bubble):not(:empty) {
    background: var(--bg-message-user);
    padding: 10px 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    max-width: 100%;
}

.ai-message .message-body:has(.chat-voice-bubble) > :not(.chat-voice-bubble) {
    background: var(--bg-app);
}

[data-theme="dark"] .ai-message .message-body:has(.chat-voice-bubble) > :not(.chat-voice-bubble) {
    background: rgba(255, 255, 255, 0.04);
}

.chat-voice-audio-native {
    display: none !important;
}

/* پیش‌فرض (پاسخ AI و موارد دیگر) */
.chat-voice-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--bg-app);
    border: 1px solid var(--border);
    min-width: 188px;
}

[data-theme="dark"] .ai-message .chat-voice-inner {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.08);
}

/* داخل کادر: فقط ردیف کنترل‌ها */
.user-message .chat-voice-inner,
.ai-message .chat-voice-inner {
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 0;
    min-width: 176px;
    gap: 12px;
    box-shadow: none;
}

.cv-play {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(11, 87, 208, 0.28);
    transition: transform 0.18s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.user-message .cv-play:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 14px rgba(11, 87, 208, 0.35);
}

.ai-message .cv-play {
    background: var(--bg-surface-solid);
    color: var(--accent);
    border: 1px solid var(--border);
    box-shadow: none;
}

[data-theme="dark"] .ai-message .cv-play {
    background: #282a2c;
}

.cv-play .cv-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.cv-play .cv-icon--pause {
    display: none;
}

.chat-voice-bubble.is-playing .cv-play .cv-icon--play {
    display: none;
}

.chat-voice-bubble.is-playing .cv-play .cv-icon--pause {
    display: flex;
}

.chat-voice-bubble.cv-load-error .cv-play {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.cv-waveform {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 2px;
    height: 32px;
    min-width: 72px;
}

.cv-wave-bar {
    display: inline-block;
    width: 2.5px;
    height: calc(var(--h, 8) * 1px);
    min-height: 4px;
    max-height: 26px;
    border-radius: 2px;
    background: var(--accent);
    opacity: 0.32;
    transform: scaleY(0.32);
    transform-origin: center bottom;
    transition: transform 0.08s ease, opacity 0.08s ease;
}

.ai-message .cv-wave-bar {
    background: var(--text-muted);
    opacity: 0.4;
}

.chat-voice-bubble.is-playing .cv-wave-bar {
    opacity: 0.88;
}

.user-message .chat-voice-bubble.is-playing .cv-wave-bar {
    background: var(--accent);
}

.cv-time {
    font-size: 0.75rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 30px;
    text-align: end;
}
.user-message .message-body:has(.voice-uploading) {
    background: transparent !important;
    padding: 0 !important;
}

.voice-uploading {
    font-size: 0.8125rem;
    color: var(--text-muted);
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px dashed var(--border);
    background: var(--bg-surface-solid);
}

@media (max-width: 480px) {
    .user-message .chat-voice-bubble,
    .ai-message .chat-voice-bubble {
        padding: 10px 12px;
        border-radius: 14px;
    }
}

/* پاپ‌آپ سراسری: ساخت پرامت / تولید تصویر */
.image-workflow-overlay {
    position: fixed;
    inset: 0;
    z-index: 10100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: imageWorkflowFadeIn 0.22s ease;
}
.image-workflow-overlay[hidden] {
    display: none !important;
}
body.image-workflow-open {
    overflow: hidden;
}
body.image-workflow-open .image-pro-modal.active .image-pro-modal-body {
    visibility: hidden;
}
body.image-workflow-open .image-pro-modal.active {
    pointer-events: none;
}
.image-workflow-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(10px);
}
.image-workflow-card {
    position: relative;
    z-index: 1;
    width: min(400px, 92vw);
    padding: 32px 28px;
    border-radius: 24px;
    text-align: center;
    border: 1px solid rgba(99, 102, 241, 0.35);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}
.image-workflow-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 20px;
    border: 3px solid rgba(255, 255, 255, 0.12);
    border-top-color: var(--accent, #818cf8);
    border-radius: 50%;
    animation: proPromptSpin 0.75s linear infinite;
}
.image-workflow-title {
    margin: 0 0 8px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
}
.image-workflow-hint {
    margin: 0 0 16px;
    font-size: 0.86rem;
    line-height: 1.55;
    color: var(--text-muted);
}
.image-workflow-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}
.image-workflow-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #c4b5fd;
    background: rgba(99, 102, 241, 0.18);
    border: 1px solid rgba(129, 140, 248, 0.35);
}
[data-theme="light"] .image-workflow-chip {
    color: #4f46e5;
    background: rgba(79, 70, 229, 0.1);
}
@keyframes imageWorkflowFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.image-pro-modal.is-building-prompt .image-pro-modal-panel {
    pointer-events: none;
}
.image-pro-modal.is-building-prompt .image-pro-modal-body {
    opacity: 0.5;
    transition: opacity 0.25s ease;
}
.image-pro-modal .pro-prompt-section-block {
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--bg-app);
    border: 1px solid var(--border);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.image-pro-modal .pro-prompt-section-block:hover {
    border-color: rgba(11, 87, 208, 0.28);
    box-shadow: 0 2px 8px rgba(11, 87, 208, 0.06);
}
.image-pro-modal .pro-prompt-section-block[data-section-id="final_prompt"],
.image-pro-modal .pro-prompt-section--final_prompt {
    background: linear-gradient(145deg, rgba(11, 87, 208, 0.08), rgba(99, 102, 241, 0.06));
    border-color: rgba(11, 87, 208, 0.22);
}
[data-theme="dark"] .image-pro-modal .pro-prompt-section-block[data-section-id="final_prompt"],
[data-theme="dark"] .image-pro-modal .pro-prompt-section--final_prompt {
    background: linear-gradient(145deg, rgba(168, 199, 250, 0.12), rgba(129, 140, 248, 0.06));
    border-color: rgba(168, 199, 250, 0.28);
}
.image-pro-modal .pro-prompt-section-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    margin-bottom: 10px;
}
.image-pro-modal .btn-ghost {
    min-height: 44px;
    border-radius: 12px;
    font-weight: 600;
}
