        /* ===== SHARED MEDIA GALLERY ===== */
        .gallery-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.6);
            z-index: 1500;
            display: none;
            align-items: center;
            justify-content: center;
            padding: 40px 20px;
        }
        .gallery-overlay.active {
            display: flex;
        }
        .gallery-panel {
            background: var(--sidebar-bg);
            border-radius: 12px;
            width: 760px;
            max-width: 100%;
            max-height: 100%;
            display: flex;
            flex-direction: column;
            min-height: 0;
            box-shadow: 0 8px 40px rgba(0,0,0,0.5);
        }
        .gallery-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 16px 20px;
            border-bottom: 1px solid var(--input-bg);
            flex-shrink: 0;
        }
        .gallery-title {
            font-size: 1.05rem;
            font-weight: 600;
            color: white;
        }
        .gallery-sub {
            font-size: 0.75rem;
            color: var(--text-secondary);
        }
        .gallery-grid {
            flex-grow: 1;
            min-height: 0;
            overflow-y: auto;
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
            gap: 4px;
            padding: 12px;
        }
        .gallery-item {
            position: relative;
            aspect-ratio: 1 / 1;
            border-radius: 6px;
            overflow: hidden;
            cursor: zoom-in;
            background: var(--input-bg);
            display: block;
        }
        .gallery-item .media-thumb {
            filter: blur(8px);
            transform: scale(1.2);
        }
        .gallery-item img.gallery-full {
            position: relative;
            width: 100%;
            height: 100%;
            object-fit: cover;
            opacity: 0;
            transition: opacity 0.2s ease;
        }
        .gallery-item img.gallery-full.loaded {
            opacity: 1;
        }
        .gallery-item:hover {
            outline: 2px solid var(--accent);
        }
        .gallery-badge {
            position: absolute;
            right: 5px;
            bottom: 5px;
            background: rgba(0,0,0,0.65);
            color: #fff;
            font-size: 0.62rem;
            padding: 1px 5px;
            border-radius: 4px;
            pointer-events: none;
        }
        .gallery-empty {
            grid-column: 1 / -1;
            text-align: center;
            color: var(--text-secondary);
            font-size: 0.85rem;
            padding: 50px 20px;
        }

        /* Call log entry (phone / video) */
        .call-block {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 2px 0;
        }
        .call-icon {
            width: 34px;
            height: 34px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1rem;
            background: rgba(255,255,255,0.1);
            flex-shrink: 0;
        }
        .call-block.failed .call-icon {
            background: rgba(239, 68, 68, 0.18);
        }
        .call-text {
            min-width: 0;
        }
        .call-label {
            font-size: 0.9rem;
            font-weight: 500;
            color: white;
            white-space: nowrap;
        }
        .call-block.failed .call-label {
            color: #f87171;
        }
        .call-meta {
            font-size: 0.72rem;
            color: var(--text-secondary);
            white-space: nowrap;
        }

        /* Fallback for documents, oversized files, and failed downloads */
        .media-chip {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 10px 12px;
            border-radius: 12px;
            background: rgba(255,255,255,0.05);
            color: inherit;
            text-decoration: none;
            font-size: 0.9rem;
            margin-bottom: 6px;
        }
        .media-chip:hover {
            background: rgba(255,255,255,0.08);
        }
        .media-chip-name {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .media-chip-size {
            margin-left: auto;
            opacity: 0.7;
            font-size: 0.8rem;
            white-space: nowrap;
        }

        /* Message Input Bar */
        .message-input-bar {
            padding: 12px 20px;
            background: var(--header-bg);
            border-top: 1px solid var(--panel-border);
            display: flex;
            align-items: center;
            gap: 12px;
            flex-shrink: 0;
        }
        .msg-input-field {
            flex-grow: 1;
            background: var(--input-bg);
            border: none;
            border-radius: 20px;
            padding: 10px 20px;
            color: var(--text-primary);
            outline: none;
            font-size: 0.95rem;
            transition: all 0.2s;
        }
        .msg-input-field:focus {
            background: #2e3c4a;
        }
        .msg-input-field::placeholder {
            color: var(--text-secondary);
        }

        /* Floating drawer control panel */
        .control-drawer {
            position: fixed;
            left: -370px;
            top: 0;
            width: 360px;
            height: 100vh;
            background: var(--sidebar-bg);
            border-right: 1px solid var(--panel-border);
            z-index: 1000;
            transition: left 0.25s ease;
            display: flex;
            flex-direction: column;
            padding: 20px;
        }
        .control-drawer.active {
            left: 0;
        }

        .drawer-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            background: rgba(0,0,0,0.4);
            z-index: 999;
            display: none;
        }
        .drawer-overlay.active {
            display: block;
        }

        .drawer-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 1px solid var(--panel-border);
        }
        .drawer-close {
            background: transparent;
            border: none;
            color: var(--text-secondary);
            font-size: 1.4rem;
            cursor: pointer;
            padding: 4px;
            border-radius: 8px;
        }
        .drawer-close:hover {
            color: white;
            background: rgba(255,255,255,0.05);
        }

        .drawer-content {
            flex-grow: 1;
            overflow-y: auto;
            min-height: 0;
            display: flex;
            flex-direction: column;
            gap: 18px;
        }

        /* Status indicator for the joker daemon */
        .status-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            flex-shrink: 0;
            align-self: center;
            background: var(--danger);
        }
        .status-dot.danger {
            background: var(--danger);
        }

        /* Terminal inside drawer */
        .drawer-terminal {
            height: 200px;
            display: flex;
            flex-direction: column;
            border-radius: 8px;
            border: 1px solid var(--panel-border);
            overflow: hidden;
            margin-top: auto;
            flex-shrink: 0;
        }
        .drawer-terminal-header {
            background: #0f1720;
            padding: 8px 12px;
            font-size: 0.8rem;
            color: var(--text-secondary);
            font-family: 'Fira Code', monospace;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .drawer-terminal-content {
            background: #0a1017;
            flex-grow: 1;
            padding: 10px;
            font-family: 'Fira Code', monospace;
            font-size: 0.8rem;
            color: #4caf50;
            overflow-y: auto;
            white-space: pre-wrap;
        }

        /* General dashboard styles inside drawer */
        .drawer-section-title {
            font-size: 0.95rem;
            color: white;
            font-weight: 500;
            margin-bottom: 10px;
            display: flex;
            justify-content: space-between;
        }
        .btn-glow {
            background: var(--accent);
            border: none;
            color: white;
            padding: 10px 16px;
            border-radius: 8px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s;
            font-size: 0.9rem;
        }
        .btn-glow:hover {
            background: #2f83d8;
        }
        .btn-glow:active {
            transform: scale(0.98);
        }
        .btn-secondary {
            background: rgba(255,255,255,0.05);
            border: 1px solid rgba(255,255,255,0.1);
            color: white;
            padding: 8px 12px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.85rem;
            transition: all 0.2s;
        }
        .btn-secondary:hover {
            background: rgba(255,255,255,0.1);
        }
        .btn-secondary-red {
            background: rgba(239, 68, 68, 0.1);
            border: 1px solid rgba(239, 68, 68, 0.2);
            color: #f87171;
            padding: 8px 12px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.85rem;
            transition: all 0.2s;
        }
        .btn-secondary-red:hover {
            background: rgba(239, 68, 68, 0.2);
        }

        .select-dark {
            background: var(--input-bg);
            border: none;
            color: white;
            padding: 10px 12px;
            border-radius: 8px;
            outline: none;
            width: 100%;
            font-size: 0.9rem;
        }

        /* Preset control grid */
        .controls-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 10px;
        }

        /* Toast notification */
        .toast {
            position: fixed;
            bottom: 20px;
            right: 20px;
            padding: 12px 18px;
            border-radius: 8px;
            background: #242f3d;
            color: white;
            box-shadow: 0 4px 12px rgba(0,0,0,0.3);
            display: flex;
            align-items: center;
            gap: 10px;
            transform: translateY(100px);
            opacity: 0;
            transition: all 0.3s ease;
            z-index: 1001;
            font-size: 0.9rem;
        }
        .toast.show {
            transform: translateY(0);
            opacity: 1;
        }

        /* Loading spinner */
        .spinner {
            border: 3px solid rgba(255, 255, 255, 0.1);
            width: 36px;
            height: 36px;
            border-radius: 50%;
            border-top-color: var(--accent);
            animation: spin 0.8s linear infinite;
            margin: auto;
        }
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .no-chat-selected {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100%;
            color: var(--text-secondary);
            gap: 15px;
        }
        .no-chat-logo {
            font-size: 4rem;
            opacity: 0.3;
        }

