/* ═════════════════════════════════════════════════════════════════════
   DYO SECURE PROTOCOL THEME (Theme Variant 2)
   100% Scoped to: html[data-theme-style="protocol"]
   Does NOT affect Classic Theme!
   ═════════════════════════════════════════════════════════════════════ */

/* ── Light Protocol Theme (Primary Default) ── */
html[data-theme-style="protocol"],
html[data-theme-style="protocol"][data-theme="light"] {
    --bg-base: #edf1f5;
    --glass-bg: #ffffff;
    --glass-border: rgba(0, 0, 0, 0.05);
    --glass-shadow: rgba(0, 0, 0, 0.04);
    --glass-hover: #f1f5f9;

    --text-main: #0f172a;
    --text-muted: #64748b;
    --primary: #9f86c0;
    --primary-hover: #8b5cf6;
    --primary-soft: #b4a5d7;

    --msg-in-bg: #ffffff;
    --msg-in-text: #0f172a;
    --msg-out-bg: #b4a5d7;
    --msg-out-text: #1e1b4b;

    --online-dot: #10b981;
    --badge-bg: #00b074;
    --voice-btn: #9f86c0;

    --card-bg: #ffffff;
    --card-border: rgba(0, 0, 0, 0.04);
    --card-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);

    --search-bg: #ffffff;
    --search-border: rgba(0, 0, 0, 0.06);
    --search-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    --search-placeholder: #94a3b8;

    --pill-active-bg: #18202c;
    --pill-active-text: #ffffff;
    --pill-inactive-bg: #ffffff;
    --pill-inactive-border: #e2e8f0;
    --pill-inactive-text: #334155;
    --pill-inactive-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);

    --dock-bg: rgba(255, 255, 255, 0.98);
    --dock-border: rgba(0, 0, 0, 0.05);
    --dock-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    --dock-active-bg: #edf2f7;
    --dock-active-color: #1e293b;
    --dock-inactive-color: #94a3b8;
    --dock-avatar-border: #e2e8f0;

    --input-bg: #ffffff;
    --input-border: #cbd5e1;

    --chat-bg: #edf1f5;
    --contacts-bg: #edf1f5;
}

/* ── Dark Protocol Theme (Switchable in Settings) ── */
html[data-theme-style="protocol"][data-theme="dark"] {
    --bg-base: #0b101b;
    --glass-bg: #121a26;
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-shadow: rgba(0, 0, 0, 0.6);
    --glass-hover: #182232;

    --text-main: #f8fafc;
    --text-muted: #7e91a7;
    --primary: #7b68ee;
    --primary-hover: #8b5cf6;
    --primary-soft: #6d599a;

    --msg-in-bg: #141c28;
    --msg-in-text: #f8fafc;
    --msg-out-bg: #6d599a;
    --msg-out-text: #ffffff;

    --online-dot: #00e5ff;
    --badge-bg: #00c49f;
    --voice-btn: #7b68ee;

    --card-bg: #131b27;
    --card-border: rgba(255, 255, 255, 0.05);
    --card-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);

    --search-bg: #141c28;
    --search-border: rgba(255, 255, 255, 0.06);
    --search-shadow: none;
    --search-placeholder: #62758d;

    --pill-active-bg: #1e293b;
    --pill-active-text: #ffffff;
    --pill-inactive-bg: #131b27;
    --pill-inactive-border: rgba(255, 255, 255, 0.07);
    --pill-inactive-text: #7e91a7;
    --pill-inactive-shadow: none;

    --dock-bg: rgba(14, 22, 35, 0.96);
    --dock-border: rgba(255, 255, 255, 0.08);
    --dock-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
    --dock-active-bg: #1c283a;
    --dock-active-color: #ffffff;
    --dock-inactive-color: #64748b;
    --dock-avatar-border: rgba(255, 255, 255, 0.15);

    --input-bg: #141c28;
    --input-border: rgba(255, 255, 255, 0.07);

    --chat-bg: #0b101b;
    --contacts-bg: #0b101b;
}

/* ── Base App & Canvas ── */
html[data-theme-style="protocol"] body {
    background: var(--bg-base) !important;
    color: var(--text-main) !important;
    overflow-x: hidden !important;
}

html[data-theme-style="protocol"][dir="rtl"],
html[data-theme-style="protocol"][dir="rtl"] body {
    direction: rtl !important;
    text-align: right !important;
    font-family: 'Vazirmatn', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

html[data-theme-style="protocol"][dir="ltr"],
html[data-theme-style="protocol"][dir="ltr"] body {
    direction: ltr !important;
    text-align: left !important;
    font-family: 'Inter', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

html[data-theme-style="protocol"] .bg-blobs {
    display: none !important;
}

/* ── Layout Resets ── */
html[data-theme-style="protocol"] .app-container {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

html[data-theme-style="protocol"] .main-wrapper {
    flex: 1 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
    display: flex !important;
    overflow: hidden !important;
}

html[data-theme-style="protocol"] #desktop-container {
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    position: relative !important;
    overflow: hidden !important;
}

/* ── Hide WhatsApp-style FAB and Saved Messages Big Pin in Protocol Theme ── */
html[data-theme-style="protocol"] #contacts-plus-fab,
html[data-theme-style="protocol"] .fab,
html[data-theme-style="protocol"] #saved-msgs-pin,
html[data-theme-style="protocol"] .saved-msgs-pin,
html[data-theme-style="protocol"] #main-story-shell {
    display: none !important;
}

/* ── Contacts Panel Container ── */
html[data-theme-style="protocol"] .contacts-panel {
    background: var(--bg-base) !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 410px !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
    position: relative !important;
    left: 0 !important;
    right: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    height: 100% !important;
    overflow-x: hidden !important;
}

@media (max-width: 768px) {
    html[data-theme-style="protocol"] #desktop-container {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
    }

    html[data-theme-style="protocol"] body:not(.mobile-chat-open) .chat-area {
        display: none !important;
    }

    html[data-theme-style="protocol"] body:not(.mobile-chat-open) .contacts-panel {
        display: flex !important;
        position: relative !important;
        left: 0 !important;
        right: 0 !important;
        top: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 410px !important;
        margin: 0 auto !important;
        height: 100% !important;
        flex: 1 !important;
    }

    html[data-theme-style="protocol"] body.mobile-chat-open .contacts-panel {
        display: none !important;
    }

    html[data-theme-style="protocol"] body.mobile-chat-open .chat-area {
        display: flex !important;
        position: relative !important;
        width: 100% !important;
        height: 100% !important;
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
    }

    /* Hide bottom navigation dock when mobile chat is open */
    html[data-theme-style="protocol"] body.mobile-chat-open .sidebar,
    body.mobile-chat-open .sidebar {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        transform: translateY(100%) !important;
        z-index: -1 !important;
    }

    html[data-theme-style="protocol"] body.mobile-chat-open .input-bar,
    html[data-theme-style="protocol"] body.mobile-chat-open .chat-input-container,
    html[data-theme-style="protocol"] body.mobile-chat-open #mci-root {
        position: relative !important;
        bottom: 0 !important;
        margin-bottom: 0 !important;
        padding-bottom: max(10px, env(safe-area-inset-bottom, 10px)) !important;
    }
}

@media (min-width: 769px) {
    html[data-theme-style="protocol"] .contacts-panel {
        width: 380px !important;
        max-width: 380px !important;
        margin: 0 !important;
        border-right: 1px solid var(--glass-border) !important;
    }

    html[data-theme-style="protocol"][dir="rtl"] body .sidebar {
        right: 20px !important;
        left: auto !important;
        margin: 0 !important;
        width: 340px !important;
        max-width: 340px !important;
    }

    html[data-theme-style="protocol"][dir="ltr"] body .sidebar {
        left: 20px !important;
        right: auto !important;
        margin: 0 !important;
        width: 340px !important;
        max-width: 340px !important;
    }
}

/* ── Center Header with DYO SECURE PROTOCOL ── */
html[data-theme-style="protocol"] body .contacts-panel .header-top {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 20px 16px 8px !important;
    margin-bottom: 0 !important;
    position: relative !important;
    direction: ltr !important;
    text-align: center !important;
    border: none !important;
    background: transparent !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

html[data-theme-style="protocol"] .greeting {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
}

html[data-theme-style="protocol"] .greeting-text {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 3px !important;
    width: 100% !important;
}

html[data-theme-style="protocol"] body #connection-status {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
    font-style: normal !important;
    font-weight: 800 !important;
    font-size: 26px !important;
    letter-spacing: 3px !important;
    text-transform: uppercase !important;
    color: var(--text-main) !important;
    line-height: 1.1 !important;
    text-align: center !important;
    margin: 0 !important;
}

html[data-theme-style="protocol"] body #connection-status::after {
    content: 'SECURE PROTOCOL';
    display: block !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    letter-spacing: 2px !important;
    opacity: 0.7 !important;
    color: var(--text-muted) !important;
    margin-top: 4px !important;
    text-align: center !important;
}

/* Hide legacy header actions (bell, hamburger, search toggle) to match clean mockup header */
html[data-theme-style="protocol"] .header-actions {
    display: none !important;
}
html[data-theme-style="protocol"] #offline-badge {
    display: none !important;
}

/* ── Permanent Search Bar & Filter Pills Container ── */
html[data-theme-style="protocol"] #contacts-search-container,
html[data-theme-style="protocol"] .contacts-search-container {
    display: flex !important;
    flex-direction: column !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    margin: 4px 16px 12px !important;
    padding: 0 !important;
    box-shadow: none !important;
    gap: 12px !important;
    overflow: visible !important;
    width: calc(100% - 32px) !important;
    box-sizing: border-box !important;
}

/* Search input capsule */
html[data-theme-style="protocol"] #contactsSearchBox,
html[data-theme-style="protocol"] #contacts-search-container .search-input-box {
    background: var(--search-bg) !important;
    border: 1px solid var(--search-border) !important;
    border-radius: 9999px !important;
    height: 46px !important;
    padding: 0 16px !important;
    box-shadow: var(--search-shadow) !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    box-sizing: border-box !important;
    width: 100% !important;
}

html[data-theme-style="protocol"][dir="rtl"] #contactsSearchBox,
html[data-theme-style="protocol"][dir="rtl"] #contacts-search-container .search-input-box {
    direction: rtl !important;
}

html[data-theme-style="protocol"][dir="ltr"] #contactsSearchBox,
html[data-theme-style="protocol"][dir="ltr"] #contacts-search-container .search-input-box {
    direction: ltr !important;
}

html[data-theme-style="protocol"] #contactsSearchBox svg,
html[data-theme-style="protocol"] #contacts-search-container svg {
    color: var(--search-placeholder) !important;
    flex-shrink: 0 !important;
}

html[data-theme-style="protocol"] #contactsSearch {
    color: var(--text-main) !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    flex: 1 !important;
    height: 100% !important;
    font-family: inherit !important;
    margin: 0 !important;
}

html[data-theme-style="protocol"][dir="rtl"] #contactsSearch {
    text-align: right !important;
}

html[data-theme-style="protocol"][dir="ltr"] #contactsSearch {
    text-align: left !important;
}

html[data-theme-style="protocol"] #contactsSearch::placeholder {
    color: var(--search-placeholder) !important;
    opacity: 1 !important;
}

/* Filter Pills Bar */
html[data-theme-style="protocol"] #contactsFilterPillsBar,
html[data-theme-style="protocol"] #contacts-search-container .filter-pills-bar {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    gap: 8px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

html[data-theme-style="protocol"][dir="rtl"] #contactsFilterPillsBar,
html[data-theme-style="protocol"][dir="rtl"] #contacts-search-container .filter-pills-bar {
    direction: rtl !important;
}

html[data-theme-style="protocol"][dir="ltr"] #contactsFilterPillsBar,
html[data-theme-style="protocol"][dir="ltr"] #contacts-search-container .filter-pills-bar {
    direction: ltr !important;
}

html[data-theme-style="protocol"] .mac-filter-chip {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    height: 36px !important;
    padding: 0 6px !important;
    border-radius: 9999px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    background: var(--pill-inactive-bg) !important;
    border: 1px solid var(--pill-inactive-border) !important;
    color: var(--pill-inactive-text) !important;
    box-shadow: var(--pill-inactive-shadow) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.15s ease !important;
    cursor: pointer !important;
    outline: none !important;
    box-sizing: border-box !important;
    white-space: nowrap !important;
}

html[data-theme-style="protocol"] .mac-filter-chip svg {
    display: none !important;
}

html[data-theme-style="protocol"] .filter-add-chip svg {
    display: block !important;
    width: 16px !important;
    height: 16px !important;
    stroke: var(--text-muted) !important;
}

html[data-theme-style="protocol"] .filter-add-chip:hover svg,
html[data-theme-style="protocol"] .filter-add-chip.active svg {
    stroke: var(--text-main) !important;
}

html[data-theme-style="protocol"] .mac-filter-chip.active {
    background: var(--pill-active-bg) !important;
    color: var(--pill-active-text) !important;
    border-color: var(--pill-active-bg) !important;
    box-shadow: none !important;
    font-weight: 700 !important;
}

html[data-theme-style="protocol"] .mac-filter-chip[data-filter="favorites"] {
    display: none !important;
}

/* ── Chat List & Floating Cards (Highest Specificity) ── */
html[data-theme-style="protocol"] body .contact-list,
html[data-theme-style="protocol"] body .modern-contact-list {
    padding: 4px 16px 100px 16px !important;
    gap: 10px !important;
    display: flex !important;
    flex-direction: column !important;
    overflow-y: auto !important;
    width: 100% !important;
    box-sizing: border-box !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
}

html[data-theme-style="protocol"] body .contact-item,
html[data-theme-style="protocol"] body .modern-contact-list .contact-item,
html[data-theme-style="protocol"] body[data-theme="dark"] .modern-contact-list .contact-item,
html[data-theme-style="protocol"] body[data-theme="light"] .modern-contact-list .contact-item,
html[data-theme-style="protocol"] body .contact-manager-item {
    background: var(--card-bg) !important;
    border: 1px solid var(--card-border) !important;
    border-radius: 20px !important;
    padding: 12px 16px !important;
    margin-bottom: 0 !important;
    box-shadow: var(--card-shadow) !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 14px !important;
    transition: transform 0.15s ease, box-shadow 0.15s ease !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

html[data-theme-style="protocol"][dir="rtl"] body .contact-item,
html[data-theme-style="protocol"][dir="rtl"] body .modern-contact-list .contact-item,
html[data-theme-style="protocol"][dir="rtl"] body .contact-manager-item {
    direction: rtl !important;
    text-align: right !important;
}

html[data-theme-style="protocol"][dir="ltr"] body .contact-item,
html[data-theme-style="protocol"][dir="ltr"] body .modern-contact-list .contact-item,
html[data-theme-style="protocol"][dir="ltr"] body .contact-manager-item {
    direction: ltr !important;
    text-align: left !important;
}

html[data-theme-style="protocol"] body .contact-item:hover {
    transform: translateY(-1px) !important;
}

html[data-theme-style="protocol"] body .contact-item.active {
    border-color: var(--primary) !important;
    box-shadow: 0 4px 20px rgba(123, 104, 238, 0.25) !important;
}

/* Hide call, video and 3-dot buttons inside contact card */
html[data-theme-style="protocol"] .contact-call-btn,
html[data-theme-style="protocol"] .contact-menu-btn,
html[data-theme-style="protocol"] .contact-fav-btn,
html[data-theme-style="protocol"] .c-more-btn {
    display: none !important;
}

/* ── Floating Island Bottom Dock Navigation ── */
html[data-theme-style="protocol"] body .sidebar {
    position: fixed !important;
    bottom: 16px !important;
    left: 0 !important;
    right: 0 !important;
    margin: 0 auto !important;
    width: calc(100% - 32px) !important;
    max-width: 360px !important;
    height: 64px !important;
    border-radius: 36px !important;
    padding: 0 14px !important;
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-around !important;
    align-items: center !important;
    box-sizing: border-box !important;
    z-index: 9999 !important;
    background: var(--dock-bg) !important;
    border: 1px solid var(--dock-border) !important;
    box-shadow: var(--dock-shadow) !important;
    backdrop-filter: blur(24px) !important;
    -webkit-backdrop-filter: blur(24px) !important;
    pointer-events: auto !important;
    transform: none !important;
}

html[data-theme-style="protocol"][dir="rtl"] body .sidebar {
    direction: rtl !important;
}

html[data-theme-style="protocol"][dir="ltr"] body .sidebar {
    direction: ltr !important;
}

html[data-theme-style="protocol"] body .sidebar .nav-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: var(--dock-inactive-color) !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
}

html[data-theme-style="protocol"] body .sidebar .nav-btn svg {
    width: 22px !important;
    height: 22px !important;
    color: inherit !important;
}

html[data-theme-style="protocol"] body .sidebar .nav-btn.active {
    color: var(--dock-active-color) !important;
    background: var(--dock-active-bg) !important;
    border-radius: 14px !important;
    box-shadow: none !important;
}

/* Dock Profile Avatar Circle */
html[data-theme-style="protocol"] body .dock-avatar-wrap {
    width: 28px !important;
    height: 28px !important;
    border-radius: 50% !important;
    overflow: hidden !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 1.5px solid var(--dock-avatar-border) !important;
}

/* Hide ALL non-essential buttons in the 5-item dock with maximum specificity */
html[data-theme-style="protocol"] body .sidebar #trade-nav-btn,
html[data-theme-style="protocol"] body .sidebar #wallet-nav-btn,
html[data-theme-style="protocol"] body .sidebar #games-nav-btn,
html[data-theme-style="protocol"] body .sidebar #upload-nav-btn,
html[data-theme-style="protocol"] body .sidebar #story-nav-btn,
html[data-theme-style="protocol"] body #trade-nav-btn,
html[data-theme-style="protocol"] body [id="trade-nav-btn"] {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    pointer-events: none !important;
}

/* ── Chat Messages (In-Conversation) ── */
html[data-theme-style="protocol"] .chat-area {
    background: var(--chat-bg) !important;
}

html[data-theme-style="protocol"] .message.received .message-bubble,
html[data-theme-style="protocol"] .msg-in .msg-bubble {
    background: var(--msg-in-bg) !important;
    color: var(--msg-in-text) !important;
    border-radius: 20px 20px 20px 6px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
    border: 1px solid var(--glass-border) !important;
}

html[data-theme-style="protocol"] .message.sent .message-bubble,
html[data-theme-style="protocol"] .msg-out .msg-bubble {
    background: var(--msg-out-bg) !important;
    color: var(--msg-out-text) !important;
    border-radius: 20px 20px 6px 20px !important;
    box-shadow: 0 4px 14px rgba(123, 104, 238, 0.25) !important;
    border: none !important;
}

html[data-theme-style="protocol"] .chat-input-container {
    background: var(--glass-bg) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 28px !important;
    margin: 8px 16px 16px !important;
    box-shadow: var(--card-shadow) !important;
}

html[data-theme-style="protocol"] #msg-input {
    background: transparent !important;
    border: none !important;
    color: var(--text-main) !important;
}

/* ── Settings Drawer Overrides ── */
html[data-theme-style="protocol"] .settings-container,
html[data-theme-style="protocol"] .settings-drawer {
    background: var(--glass-bg) !important;
    color: var(--text-main) !important;
}

html[data-theme-style="protocol"] .tms-btn.active,
html[data-theme-style="protocol"] .tms-btn--active {
    background: var(--primary) !important;
    color: #ffffff !important;
}

/* ── Filter Pills: Subtle '+' Button ── */
html[data-theme-style="protocol"] .filter-add-chip {
    flex: 0 0 34px !important;
    width: 34px !important;
    min-width: 34px !important;
    max-width: 34px !important;
    height: 34px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: var(--pill-inactive-bg) !important;
    border: 1px solid var(--pill-inactive-border) !important;
    color: var(--pill-inactive-text) !important;
    cursor: pointer !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    margin-left: 2px !important;
}

html[data-theme-style="protocol"][dir="rtl"] .filter-add-chip {
    margin-left: 0 !important;
    margin-right: 2px !important;
}

html[data-theme-style="protocol"] .filter-add-chip:hover,
html[data-theme-style="protocol"] .filter-add-chip.active {
    background: var(--card-bg) !important;
    border-color: var(--primary) !important;
    color: var(--primary) !important;
    transform: scale(1.08) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
}

/* ── Apps Hub Dropdown Menu ── */
.apps-hub-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 125px 16px 20px;
    box-sizing: border-box;
}

.apps-hub-overlay.active {
    display: flex;
}

.apps-hub-popover {
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--card-border, #e2e8f0);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 360px;
    padding: 18px;
    box-sizing: border-box;
    transform: translateY(-8px) scale(0.96);
    animation: popInHub 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes popInHub {
    from { opacity: 0; transform: translateY(-8px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.apps-hub-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--glass-border, rgba(0,0,0,0.06));
}

.apps-hub-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.apps-hub-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
}

.apps-hub-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.apps-hub-item {
    background: var(--pill-inactive-bg, rgba(0,0,0,0.03));
    border: 1px solid var(--pill-inactive-border, rgba(0,0,0,0.06));
    border-radius: 16px;
    padding: 12px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.18s ease;
    text-decoration: none;
    color: var(--text-main);
}

.apps-hub-item:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.apps-hub-icon-wrap {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.apps-hub-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.apps-hub-footer {
    border-top: 1px solid var(--glass-border, rgba(0,0,0,0.06));
    padding-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.apps-hub-manage-btn {
    background: transparent;
    border: none;
    color: var(--primary, #6366f1);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 10px;
    transition: background 0.15s;
    font-family: inherit;
}

.apps-hub-manage-btn:hover {
    background: rgba(99, 102, 241, 0.08);
}

/* ── PIN Code Protection Modal ── */
.secure-pin-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.secure-pin-overlay.active {
    display: flex;
}

.secure-pin-card {
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--card-border, #e2e8f0);
    border-radius: 28px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 330px;
    padding: 24px 20px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
    animation: popInHub 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.secure-pin-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.secure-pin-title {
    font-size: 16.5px;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 6px;
    text-align: center;
}

.secure-pin-subtitle {
    font-size: 12.5px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 20px;
    line-height: 1.4;
}

.secure-pin-dots {
    display: flex;
    gap: 14px;
    margin-bottom: 24px;
    direction: ltr;
}

.secure-pin-dot {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.secure-pin-dot.filled {
    background: var(--primary, #6366f1);
    border-color: var(--primary, #6366f1);
    transform: scale(1.15);
}

.secure-pin-dots.shake {
    animation: shakeDots 0.35s ease;
}

@keyframes shakeDots {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.secure-pin-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 250px;
    direction: ltr;
}

.secure-key-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 1px solid var(--glass-border, rgba(0,0,0,0.08));
    background: var(--pill-inactive-bg, rgba(0,0,0,0.03));
    color: var(--text-main);
    font-size: 21px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    transition: all 0.15s ease;
    font-family: inherit;
}

.secure-key-btn:active {
    background: var(--primary);
    color: #fff;
    transform: scale(0.92);
}

.secure-key-action {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    border: none;
    background: transparent;
}

.secure-key-action:active {
    background: transparent;
    color: var(--text-main);
}

/* ── Shop / Store Tab Design ── */
#shop-tab {
    display: none;
    flex-direction: column;
    height: 100%;
    width: 100%;
    max-width: 410px;
    margin: 0 auto;
    padding: 0 16px 90px;
    box-sizing: border-box;
    overflow-y: auto;
}

.shop-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 0 14px;
    margin-bottom: 6px;
}

.shop-header-title {
    font-size: 19px;
    font-weight: 800;
    color: var(--text-main);
}

.shop-categories-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 10px;
    margin-bottom: 14px;
    scrollbar-width: none;
}

.shop-categories-bar::-webkit-scrollbar {
    display: none;
}

.shop-cat-pill {
    padding: 7px 13px;
    border-radius: 9999px;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    background: var(--pill-inactive-bg);
    border: 1px solid var(--pill-inactive-border);
    color: var(--pill-inactive-text);
    transition: all 0.2s;
}

.shop-cat-pill.active {
    background: var(--pill-active-bg);
    border-color: var(--pill-active-border);
    color: var(--pill-active-text);
}

.shop-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.shop-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 16px;
    box-shadow: var(--card-shadow);
    display: flex;
    gap: 14px;
    align-items: center;
    transition: transform 0.15s ease;
}

.shop-card:hover {
    transform: translateY(-2px);
}

.shop-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.shop-card-body {
    flex: 1;
    min-width: 0;
}

.shop-card-title {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}

.shop-card-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 8px;
}

.shop-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.shop-card-price {
    font-size: 13.5px;
    font-weight: 800;
    color: var(--primary);
}

.shop-card-btn {
    padding: 6px 14px;
    border-radius: 12px;
    border: none;
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.15s;
}

.shop-card-btn:hover {
    opacity: 0.9;
}

/* ── Protocol Back Button (Direction-Aware) ── */
.protocol-back-btn svg,
#chat-back-btn svg {
    transition: transform 0.2s ease;
}

html[dir="rtl"] .protocol-back-btn svg,
body[dir="rtl"] .protocol-back-btn svg,
html[dir="rtl"] #chat-back-btn svg,
body[dir="rtl"] #chat-back-btn svg,
html[data-theme-style="protocol"][dir="rtl"] #chat-back-btn svg {
    transform: rotate(180deg) !important;
}

/* ── In active chat mode, ensure bottom dock is never displayed ── */
body.mobile-chat-open .sidebar,
html[data-theme-style="protocol"] body.mobile-chat-open .sidebar,
body.chat-open .sidebar {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translateY(100%) !important;
    z-index: -1 !important;
}

/* ── Chat Header & Back Button (Direction-Aware) ── */
html[data-theme-style="protocol"][dir="rtl"] #chat-header-bar {
    direction: rtl !important;
}

html[data-theme-style="protocol"][dir="ltr"] #chat-header-bar {
    direction: ltr !important;
}

html[data-theme-style="protocol"] #chat-back-btn {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    border-radius: 12px !important;
    background: var(--card-bg, #ffffff) !important;
    border: 1px solid var(--card-border, rgba(0, 0, 0, 0.08)) !important;
    color: var(--text-main, #0f172a) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04) !important;
    cursor: pointer !important;
    display: none;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0 !important;
}

html[data-theme-style="protocol"] #chat-back-btn:hover {
    background: var(--glass-hover, rgba(0, 0, 0, 0.05)) !important;
}

html[data-theme-style="protocol"] body.mobile-chat-open #chat-back-btn,
html[data-theme-style="protocol"] body.chat-open #chat-back-btn {
    display: inline-flex !important;
}
