/* ================================================================
   THE ORACLE - RESPONSIVE STYLES
   Created by: Dakota Stewart
   Delphi Labs - AGI MODEL 7
   ================================================================ */

@media (max-width: 768px) {
    .oracle-welcome {
    min-width: unset;
    max-width: 100%;
}
    .welcome-header {
    flex-direction: column;
    gap: 10px;
    text-align: center;
}
    .welcome-logo {
    font-size: 1.4rem;
}
    .system-item {
    padding: 10px 12px;
}
    .system-name {
    font-size: 0.75rem;
}
    .system-desc {
    display: none;
}
    .prompt-text {
    font-size: 0.75rem;
    letter-spacing: 2px;
}
}

@media (max-width: 768px) {
    .character-3d-container {
    width: 300px;
    height: 380px;
}
    .character-glow-ring {
    width: 220px;
    height: 45px;
}
}

@media (max-width: 1200px) { .topbar-actions .text { display: none; } .action-btn { padding: 8px 12px; } }

@media (max-width: 1024px) { .overdrive-grid { grid-template-columns: 1fr; } .chat-title { max-width: 200px; font-size: 1rem; } }

@media (max-width: 768px) {
    /* ============================================
       PREMIUM DARK MODE MOBILE UI - v4.0
       Premium quality design
       Clean, minimal, $100M product feel
       ============================================ */

    /* ================================================================
       1. DARK MODE FOUNDATION + SAFARI FIX
       ================================================================ */
    html, body {
        background: #000000 !important;
        background-color: #000000 !important;
        /* Safari fix - ensure full height without overflow */
        min-height: 100% !important;
        min-height: -webkit-fill-available !important;
        height: 100% !important;
    }

    .app-container {
        background: #000000 !important;
        background-color: #000000 !important;
        /* Add padding for fixed topbar including safe area - reduced to 36px for compact iOS header */
        /* NOTE: Only app-container gets this, NOT main-content (they nest, would double) */
        padding-top: calc(36px + env(safe-area-inset-top, 0)) !important;
    }

    .main-content {
        background: #000000 !important;
        background-color: #000000 !important;
        /* NO top padding - app-container already has it */
        padding-top: 0 !important;
    }

    .chat-container {
        background: #000000 !important;
        border: none !important;
    }

    /* ================================================================
       2. HIDE UNWANTED ELEMENTS
       ================================================================ */
    .welcome-brain,
    .welcome-brain video,
    .brain-container-corporate,
    .brain-container-corporate video,
    .crystal-brain-img,
    .think-icon-video,
    .thinking-brain-video,
    .floating-brain,
    .boot-sequence-banner,
    .message-avatar,
    .mode-chip .mode-icon,
    .input-footer,
    .action-buttons-row,
    .hide-on-mobile,
    .deep-think-toggle-btn,
    .think-toggle,
    .deep-think-panel {
        display: none !important;
    }

    /* ================================================================
       3. PREMIUM TYPOGRAPHY - Inter Font
       ================================================================ */
    body {
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text',
                     'Segoe UI', sans-serif !important;
        -webkit-font-smoothing: antialiased !important;
        -moz-osx-font-smoothing: grayscale !important;
        text-rendering: optimizeLegibility !important;
        color: #e5e5e5 !important;
        font-feature-settings: 'kern' 1, 'liga' 1 !important;
    }

    /* ================================================================
       3.5 SCROLLBAR - Minimal, Dark
       ================================================================ */
    ::-webkit-scrollbar {
        width: 6px !important;
    }

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

    ::-webkit-scrollbar-thumb {
        background: #2a2a2a !important;
        border-radius: 3px !important;
    }

    ::-webkit-scrollbar-thumb:hover {
        background: #3a3a3a !important;
    }

    /* Firefox scrollbar */
    * {
        scrollbar-width: thin !important;
        scrollbar-color: #2a2a2a transparent !important;
    }

    /* ================================================================
       4. WELCOME SCREEN - ChatGPT Style (centered, clean)
       ================================================================ */
    /* Position welcome overlay ABOVE the centered input box */
    .welcome-overlay {
        position: absolute;
        top: 22%;
        left: 50%;
        transform: translateX(-50%);
        bottom: auto;
        z-index: 40;
        background: transparent;
        width: 100%;
        padding: 0 20px;
    }

    .welcome-content {
        background: transparent;
        padding: 20px;
    }

    .welcome-message,
    .greeting,
    .welcome-text {
        text-align: center;
        padding: 60px 20px;
    }

    .welcome-message h1,
    .greeting-text,
    .welcome-title {
        font-family: 'Inter', sans-serif;
        font-size: 24px;
        font-weight: 600;
        color: #ffffff;
        margin-bottom: 8px;
        letter-spacing: -0.02em;
    }

    .welcome-message p,
    .welcome-subtitle {
        font-family: 'Inter', sans-serif;
        font-size: 16px;
        color: #666666;
        margin: 0;
    }

    .welcome-greeting {
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
        font-size: 17px;
        font-weight: 500;
        letter-spacing: -0.02em;
        line-height: 1.4;
        color: #ffffff;
        margin-bottom: 8px;
        text-align: center;
        max-width: none;
        width: 90vw;
        margin-left: auto;
        margin-right: auto;
        padding: 0;
        word-wrap: normal;
        white-space: normal;
    }

    .welcome-subtitle {
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
        font-size: 15px;
        font-weight: 400;
        letter-spacing: -0.01em;
        line-height: 1.5;
        color: #888888;
        text-align: center;
    }

    /* ================================================================
       5. CHAT MESSAGES - Premium ChatGPT Style
       ================================================================ */
    .chat-container {
        padding: 16px;
        /* Just small top padding - main-content already has padding for fixed topbar */
        padding-top: 16px;
        /* CRITICAL: Enough bottom padding for fixed input bar + tab bar + safe area */
        /* Input bar ~55px + Tab bar ~52px + buffer = 130px */
        padding-bottom: calc(130px + env(safe-area-inset-bottom, 0px)) !important;
        scroll-behavior: smooth;
        gap: 18px;
    }

    .message {
        background: transparent;
        border: none;
        margin-bottom: 18px;
        padding: 0;
        box-shadow: none;
        animation: messageIn 0.3s ease-out;
        width: 100%;
        max-width: 100%;
    }

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

    .message-content {
        max-width: 100%;
        width: 100%;
    }

    .message-text {
        font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
        font-size: 17px;
        font-weight: 400;
        line-height: 1.6;
        letter-spacing: -0.01em;
        -webkit-font-smoothing: antialiased;
        border: none;
        box-shadow: none;
    }

    /* AI Messages - Clean, full-width like ChatGPT (NO bubble) */
    .message.ai {
        background: transparent;
        border: none;
        max-width: 100%;
    }

    .message.ai .message-content {
        max-width: 100%;
        width: 100%;
        background: transparent;
        border: none;
        border-radius: 0;
        box-shadow: none;
        padding: 0;
    }

    .message.ai .message-text {
        background: transparent;
        color: #e8e8e8;
        border-radius: 0;
        padding: 0;
        border: none;
        box-shadow: none;
        max-width: 100%;
    }

    .message.ai .message-text p {
        margin: 0 0 16px 0;
        color: #e8e8e8;
    }

    .message.ai .message-text p:last-child {
        margin-bottom: 0;
    }

    /* Bold headlines - ChatGPT style visual hierarchy */
    .message.ai .message-text strong,
    .message.ai .message-text b {
        font-weight: 700;
        color: #ffffff;
        display: inline;
    }

    .message.ai .message-text em,
    .message.ai .message-text i {
        font-style: italic;
        color: #e8e8e8;
    }

    .message.ai .message-text ul,
    .message.ai .message-text ol {
        margin: 14px 0;
        padding-left: 20px;
    }

    .message.ai .message-text li {
        margin: 0 0 12px 0;
        line-height: 1.6;
        color: #e8e8e8;
        font-size: 17px;
    }

    .message.ai .message-text li:last-child {
        margin-bottom: 0;
    }

    /* Inline code */
    .message.ai .message-text code {
        background: #1a1a1a;
        padding: 3px 8px;
        border-radius: 6px;
        font-size: 15px;
        font-family: 'SF Mono', 'Fira Code', Monaco, Consolas, monospace;
        color: #a78bfa;
        border: 1px solid #2a2a2a;
    }

    /* Code blocks */
    .message.ai .message-text pre {
        background: #1a1a1a;
        border-radius: 12px;
        padding: 16px;
        overflow-x: auto;
        margin: 16px 0;
        border: 1px solid #2a2a2a;
    }

    .message.ai .message-text pre code {
        background: transparent;
        padding: 0;
        border: none;
        color: #e0e0e0;
        font-size: 14px;
        line-height: 1.5;
    }

    /* Links - Visible accent color */
    .message.ai .message-text a {
        color: #a78bfa;
        text-decoration: none;
        font-weight: 500;
        transition: color 0.15s ease;
    }

    .message.ai .message-text a:hover,
    .message.ai .message-text a:active {
        color: #c4b5fd;
        text-decoration: underline;
    }

    /* User Messages - Purple bubbles aligned right */
    .message.user {
        background: transparent;
        border: none;
        display: flex;
        justify-content: flex-end;
    }

    .message.user .message-content {
        max-width: 70%;
        margin-left: auto;
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        /* Remove purple gradient - only .message-text should have background */
        background: transparent;
        border: none;
        padding: 0;
        box-shadow: none;
    }

    .message.user .message-text {
        background: #3a3a3c;
        color: #ffffff;
        /* iMessage-style compact bubble - fits content */
        border-radius: 18px 18px 4px 18px;
        padding: 10px 14px;
        border: none;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
        /* Compact: only as wide as content needs */
        display: inline-block;
        width: fit-content;
        max-width: 100%;
        /* Prevent vertical text: use overflow-wrap instead of word-wrap */
        overflow-wrap: break-word;
        word-break: normal;
        white-space: pre-wrap;
        text-align: left;
        font-weight: 400;
        font-size: 16px;
        line-height: 1.4;
    }

    /* Hide avatars */
    .message-avatar {
        display: none !important;
    }

    /* Timestamps - Subtle, 12-13px as specified */
    .message-time {
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
        font-size: 12px;
        font-weight: 400;
        color: rgba(255, 255, 255, 0.5);
        margin-top: 10px;
        letter-spacing: 0.02em;
    }

    .message-time::before,
    .message-time::after {
        content: none;
        display: none;
    }

    /* ================================================================
       5.5 MESSAGE ACTION ICONS - ChatGPT Style
       ================================================================ */
    .message-actions {
        display: flex;
        gap: 4px;
        margin-top: 12px;
        padding: 0;
    }

    .message-actions .action-btn,
    .message-actions button {
        background: transparent;
        border: none;
        padding: 8px;
        color: #525252;
        cursor: pointer;
        border-radius: 6px;
        transition: all 0.15s ease;
    }

    .message-actions .action-btn:hover,
    .message-actions button:hover {
        color: #ffffff;
        background: #1a1a1a;
    }

    .message-actions .action-btn svg,
    .message-actions button svg,
    .message-actions .action-btn i,
    .message-actions button i {
        width: 18px;
        height: 18px;
        stroke-width: 1.5;
    }

    /* ================================================================
       6. MODE CHIPS - HIDDEN (Moved to header dropdown)
       ================================================================ */
    .chat-mode-selector {
        display: none !important;
    }

    .chat-mode-selector::-webkit-scrollbar {
        display: none !important;
    }

    /* Mode Divider - hide it */
    .mode-divider {
        display: none !important;
    }

    /* Hide Image mode chip on mobile - already in bottom nav */
    .mode-chip.image-mode,
    #modeImage {
        display: none !important;
    }

    /* ================================================================
       6.5 HEADER MODE DROPDOWN - ChatGPT Style
       ================================================================ */
    .header-mode-dropdown {
        position: relative;
        display: flex !important;
        align-items: center;
    }

    .header-mode-btn {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 8px 14px;
        /* Clean style - no grey box */
        background: transparent;
        border: none;
        border-radius: 20px;
        color: #ffffff;
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        transition: all 0.2s ease;
    }

    .header-mode-btn:active {
        background: rgba(255, 255, 255, 0.08);
        transform: scale(0.98);
    }

    .header-mode-btn .mode-arrow {
        font-size: 10px;
        margin-left: 2px;
        transition: transform 0.2s ease;
    }

    .header-mode-btn.open .mode-arrow {
        transform: rotate(180deg);
    }

    .header-mode-menu {
        position: fixed !important;
        top: 60px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        background: #1a1a1a;
        border: 1px solid #333;
        border-radius: 16px;
        padding: 8px;
        min-width: 220px;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
        z-index: 999999 !important;
        display: none;
        flex-direction: column;
        gap: 4px;
    }

    .header-mode-menu.show {
        display: flex !important;
    }

    .header-mode-option {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 16px;
        background: transparent;
        border: none;
        border-radius: 12px;
        color: #cccccc;
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
        font-size: 15px;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.15s ease;
        text-align: left;
        width: 100%;
    }

    .header-mode-option:active {
        background: rgba(124, 58, 237, 0.2);
    }

    .header-mode-option.selected {
        background: rgba(124, 58, 237, 0.2);
        color: #a78bfa;
    }

    .header-mode-option .option-icon {
        font-size: 18px;
        width: 24px;
        text-align: center;
    }

    .header-mode-option .option-check {
        margin-left: auto;
        color: #a78bfa;
        opacity: 0;
    }

    .header-mode-option.selected .option-check {
        opacity: 1;
    }

    .header-mode-backdrop {
        position: fixed !important;
        inset: 0 !important;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999998 !important;
        display: none;
    }

    .header-mode-backdrop.show {
        display: block !important;
    }

    /* MODE BUTTONS - SOLID, VISIBLE, TAPPABLE */
    .mode-chip {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8px !important;
        /* SOLID VISIBLE BACKGROUND */
        background: #1a1a1a !important;
        border: 1.5px solid #333333 !important;
        border-radius: 12px !important;
        /* Proper sizing - Apple touch guidelines */
        padding: 12px 18px !important;
        min-height: 46px !important;
        min-width: 90px !important;
        /* Typography */
        color: #b0b0b0 !important;
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
        font-size: 14px !important;
        font-weight: 500 !important;
        letter-spacing: -0.01em !important;
        text-transform: none !important;
        /* Interaction */
        box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
        white-space: nowrap !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        flex-shrink: 0 !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
    }

    /* Show icons on mode chips */
    .mode-chip .mode-icon {
        display: inline-flex !important;
        font-size: 16px !important;
        line-height: 1 !important;
    }

    .mode-chip .mode-label {
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
        font-size: 14px !important;
        font-weight: 500 !important;
        letter-spacing: -0.01em !important;
        text-transform: none !important;
    }

    /* Hover state */
    .mode-chip:hover {
        background: #252525 !important;
        border-color: #444444 !important;
        color: #ffffff !important;
        transform: translateY(-1px) !important;
        box-shadow: 0 4px 12px rgba(0,0,0,0.4) !important;
    }

    /* ACTIVE/SELECTED state - OBVIOUS purple glow */
    .mode-chip.active {
        background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%) !important;
        border-color: #a855f7 !important;
        color: #ffffff !important;
        box-shadow: 0 4px 20px rgba(124, 58, 237, 0.5) !important;
        font-weight: 600 !important;
    }

    .mode-chip.active .mode-icon {
        filter: brightness(1.2) !important;
    }

    /* Pressed state */
    .mode-chip:active {
        transform: scale(0.96) !important;
        box-shadow: 0 1px 4px rgba(0,0,0,0.3) !important;
    }

    /* Specific mode colors when active */
    .mode-chip.deep-think.active {
        background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%) !important;
        box-shadow: 0 4px 20px rgba(124, 58, 237, 0.5) !important;
    }

    .mode-chip.reason-mode.active {
        background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
        box-shadow: 0 4px 20px rgba(59, 130, 246, 0.5) !important;
    }

    .mode-chip.web-search.active {
        background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
        box-shadow: 0 4px 20px rgba(16, 185, 129, 0.5) !important;
    }

    .mode-chip.code-mode.active {
        background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
        box-shadow: 0 4px 20px rgba(245, 158, 11, 0.5) !important;
    }

    .mode-chip.image-mode.active {
        background: linear-gradient(135deg, #ec4899 0%, #db2777 100%) !important;
        box-shadow: 0 4px 20px rgba(236, 72, 153, 0.5) !important;
    }

    /* ================================================================
       7. INPUT AREA - Fixed above Bottom Nav (iOS Fix)
       CRITICAL: Must be position:fixed to work on iOS WebKit/Safari
       ================================================================ */
    .input-area {
        background: #000000 !important;
        border-top: 1px solid rgba(255,255,255,0.1) !important;
        padding: 8px 16px !important;
        padding-bottom: 6px !important;
        margin-bottom: 0 !important;
        /* FIXED positioning - works reliably on iOS WebKit */
        position: fixed !important;
        /* Position directly above tab bar - 66px nav height (6px top + 54px button + 6px bottom) */
        bottom: calc(66px + env(safe-area-inset-bottom, 0px)) !important;
        left: 0 !important;
        right: 0 !important;
        /* High z-index to ensure visibility above everything except modals */
        z-index: 999 !important;
        /* Ensure visibility */
        display: flex !important;
        flex-direction: column !important;
        visibility: visible !important;
        opacity: 1 !important;
        transform: none !important;
    }

    /* Input wrapper - contains input container + send button */
    .input-wrapper,
    #messageForm {
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-end !important;
        gap: 12px !important;
        width: 100% !important;
    }

    /* Input buttons container - send button */
    .input-buttons {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-shrink: 0 !important;
    }

    .input-container {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 12px !important;
        background: #1a1a1a !important;
        border: 2px solid #2a2a2a !important;
        border-radius: 24px !important;
        padding: 10px 16px !important;
        /* Only transition border/shadow, not size changes */
        transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
        min-height: 48px !important;
        flex: 1 !important;
    }

    .input-container:focus-within {
        /* Silver focus border - no purple glow */
        border-color: #5a5a5a !important;
        box-shadow: none !important;
    }

    #messageInput {
        flex: 1 1 auto !important;
        /* iOS fix: explicit width prevents vertical text wrapping */
        width: 100% !important;
        min-width: 0 !important;
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text',
                     system-ui, sans-serif !important;
        font-size: 17px !important; /* 16px+ prevents iOS zoom */
        font-weight: 400 !important;
        line-height: 1.5 !important;
        letter-spacing: 0 !important;
        color: #ffffff !important;
        background: transparent !important;
        border: none !important;
        outline: none !important;
        -webkit-font-smoothing: antialiased !important;
        min-height: 28px !important;
        max-height: 150px !important;
        resize: none !important;
        padding: 0 !important;
        margin: 0 !important;
        /* Change text cursor color from iOS blue to white */
        caret-color: #ffffff !important;
        /* iOS cursor jumping prevention */
        -webkit-appearance: none !important;
        -webkit-text-size-adjust: 100% !important;
        transform: translateZ(0) !important;
        -webkit-transform: translateZ(0) !important;
        backface-visibility: hidden !important;
        -webkit-backface-visibility: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        /* Prevent iOS keyboard issues */
        touch-action: manipulation !important;
        /* Ensure horizontal text flow */
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        white-space: pre-wrap !important;
    }

    #messageInput::placeholder {
        color: #888888 !important;
        font-weight: 400 !important;
        font-size: 17px !important;
    }

    /* Hide input extras */
    .input-footer,
    .action-buttons-row,
    .input-hint {
        display: none !important;
    }

    /* Input action buttons (attach, etc) */
    .input-action-btn {
        background: transparent !important;
        border: none !important;
        padding: 8px !important;
        color: #666666 !important;
        font-size: 20px !important;
        cursor: pointer !important;
        border-radius: 8px !important;
        transition: all 0.15s ease !important;
        min-width: 40px !important;
        min-height: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .input-action-btn:active {
        color: #ffffff !important;
        background: #2a2a2a !important;
    }

    /* Send button - Premium purple gradient */
    .send-btn,
    #sendButton,
    .submit-btn {
        background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%) !important;
        border: none !important;
        border-radius: 50% !important;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4) !important;
        color: #ffffff !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        flex-shrink: 0 !important;
        touch-action: manipulation !important;
    }

    .send-btn:hover,
    #sendButton:hover,
    .submit-btn:hover {
        transform: scale(1.05) !important;
        box-shadow: 0 6px 20px rgba(124, 58, 237, 0.5) !important;
    }

    .send-btn:active,
    #sendButton:active,
    .submit-btn:active {
        transform: scale(0.95) !important;
        box-shadow: 0 2px 8px rgba(124, 58, 237, 0.4) !important;
    }

    .send-btn svg,
    #sendButton svg,
    .submit-btn svg,
    .send-btn i,
    #sendButton i,
    .submit-btn i {
        width: 20px !important;
        height: 20px !important;
        color: #ffffff !important;
        stroke: #ffffff !important;
    }

    /* ================================================================
       7.5 THINKING INDICATORS - Premium Animated
       ================================================================ */

    /* QUICK THINKING - Shimmer Lines - NO BOX */
    .thinking-container,
    .shimmer-container {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 0 16px;
        margin: 0;
        background: transparent;
        border-radius: 0;
        border: none;
    }

    .shimmer-line {
        height: 12px;
        background: linear-gradient(90deg, #1a1a1a 0%, #2a2a2a 50%, #1a1a1a 100%);
        background-size: 200% 100%;
        border-radius: 6px;
        animation: shimmer 1.2s infinite ease-in-out;
    }

    .shimmer-line:nth-child(1) { width: 85%; animation-delay: 0s; }
    .shimmer-line:nth-child(2) { width: 65%; animation-delay: 0.1s; }
    .shimmer-line:nth-child(3) { width: 45%; animation-delay: 0.2s; }

    @keyframes shimmer {
        0% { background-position: 200% 0; }
        100% { background-position: -200% 0; }
    }

    /* DEEP THINKING - Premium Status Container */
    .deep-thinking {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 16px 20px;
        margin: 16px;
        background: linear-gradient(135deg, rgba(124, 58, 237, 0.1) 0%, rgba(16, 16, 16, 1) 100%);
        border: 1px solid rgba(124, 58, 237, 0.3);
        border-radius: 16px;
        box-shadow: 0 4px 20px rgba(124, 58, 237, 0.15);
    }

    .deep-thinking-spinner {
        width: 22px;
        height: 22px;
        border: 2.5px solid #2a2a2a;
        border-top-color: #a78bfa;
        border-radius: 50%;
        animation: spin 0.7s linear infinite;
        flex-shrink: 0;
    }

    @keyframes spin {
        to { transform: rotate(360deg); }
    }

    .deep-thinking-text {
        font-family: 'Inter', sans-serif;
        font-size: 14px;
        font-weight: 500;
        color: #a0a0a0;
        line-height: 1.4;
    }

    .deep-thinking-text span {
        color: #a78bfa;
        font-weight: 600;
    }

    /* Oracle Thinking Indicator - Shimmer Bar (matches Coding Studio) */
    .oracle-thinking {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 14px 16px 6px;
    }

    .oracle-thinking-shimmer {
        height: 3px;
        border-radius: 2px;
        overflow: hidden;
        background: #1e1e24;
        width: 100%;
        max-width: 280px;
    }

    .oracle-thinking-shimmer-bar {
        height: 100%;
        width: 40%;
        border-radius: 2px;
        background: linear-gradient(90deg, #8ab4f8, #c084fc, #8ab4f8);
        background-size: 200% 100%;
        animation: oracleShimmerSlide 1.8s ease-in-out infinite;
    }

    @keyframes oracleShimmerSlide {
        0% { transform: translateX(-100%); background-position: 200% 0; }
        50% { background-position: 0% 0; }
        100% { transform: translateX(350%); background-position: 200% 0; }
    }

    .oracle-thinking-status {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 13px;
        color: #9aa0a6;
        min-height: 20px;
    }

    .oracle-text {
        font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
        font-size: 13px;
        font-weight: 400;
        color: #9aa0a6;
        animation: oracleTextFadeIn 0.4s ease-out;
    }

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

    .oracle-thinking-dots {
        display: inline-flex;
        gap: 3px;
        align-items: center;
    }

    .oracle-thinking-dots i {
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background: #8ab4f8;
        display: inline-block;
        font-style: normal;
        animation: oracleDotBounce 1.4s ease-in-out infinite;
    }

    .oracle-thinking-dots i:nth-child(2) { animation-delay: 0.2s; }
    .oracle-thinking-dots i:nth-child(3) { animation-delay: 0.4s; }

    @keyframes oracleDotBounce {
        0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
        40% { opacity: 1; transform: scale(1.2); }
    }

    /* ================================================================
       SHIMMER THINKING INDICATOR — iOS/Mobile version
       Compact shimmer bar + rotating status, touch-friendly
       ================================================================ */

    .oracle-shimmer {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 12px 16px 6px;
    }

    .oracle-shimmer-bar-wrap {
        height: 3px;
        border-radius: 2px;
        overflow: hidden;
        background: #1e1e24;
        width: 100%;
        max-width: 260px;
    }

    .oracle-shimmer-bar {
        height: 100%;
        width: 40%;
        border-radius: 2px;
        background: linear-gradient(90deg, #a78bfa, #c084fc, #a78bfa);
        background-size: 200% 100%;
        animation: oracle-shimmer-slide 1.8s ease-in-out infinite;
    }

    .oracle-shimmer.deep-think-shimmer .oracle-shimmer-bar-wrap {
        max-width: 300px;
    }
    .oracle-shimmer.deep-think-shimmer .oracle-shimmer-bar {
        background: linear-gradient(90deg, #8b5cf6, #a855f7, #d946ef, #a855f7, #8b5cf6);
        background-size: 300% 100%;
        animation: oracle-shimmer-slide 2.2s ease-in-out infinite;
    }

    @keyframes oracle-shimmer-slide {
        0%   { transform: translateX(-100%); background-position: 200% 0; }
        50%  { background-position: 0% 0; }
        100% { transform: translateX(350%); background-position: 200% 0; }
    }

    .oracle-shimmer-status {
        display: flex;
        align-items: center;
        gap: 6px;
        font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
        font-size: 13px;
        color: #9ca3af;
        min-height: 20px;
    }

    .oracle-shimmer-status span:first-child {
        animation: oracle-text-fade 0.4s ease-out;
    }

    @keyframes oracle-text-fade {
        from { opacity: 0; transform: translateY(4px); }
        to   { opacity: 1; transform: translateY(0); }
    }

    .oracle-shimmer-dots {
        display: inline-flex;
        gap: 3px;
        align-items: center;
    }

    .oracle-shimmer-dots i {
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background: #a78bfa;
        animation: oracle-dot-bounce 1.4s ease-in-out infinite;
        font-style: normal;
    }

    .oracle-shimmer-dots i:nth-child(2) { animation-delay: 0.2s; }
    .oracle-shimmer-dots i:nth-child(3) { animation-delay: 0.4s; }

    @keyframes oracle-dot-bounce {
        0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
        40% { opacity: 1; transform: scale(1.2); }
    }

    .oracle-shimmer.deep-think-shimmer .oracle-shimmer-dots i {
        background: #c084fc;
    }

    /* Legacy thinking indicators - still supported */
    .thinking-indicator,
    .typing-indicator,
    .loading-message,
    .ai-thinking {
        background: transparent;
        border: none;
        padding: 0 16px;
        color: #666666;
        font-family: 'Inter', sans-serif;
        font-size: 14px;
        margin: 16px 0;
    }

    .thinking-dots span,
    .typing-dots span,
    .loading-dots span {
        display: inline-block;
        width: 6px;
        height: 6px;
        background: #525252;
        border-radius: 50%;
        margin-right: 4px;
        animation: thinkingDots 1.4s infinite ease-in-out both;
    }

    .thinking-dots span:nth-child(1),
    .typing-dots span:nth-child(1),
    .loading-dots span:nth-child(1) {
        animation-delay: -0.32s;
    }

    .thinking-dots span:nth-child(2),
    .typing-dots span:nth-child(2),
    .loading-dots span:nth-child(2) {
        animation-delay: -0.16s;
    }

    .thinking-dots span:nth-child(3),
    .typing-dots span:nth-child(3),
    .loading-dots span:nth-child(3) {
        animation-delay: 0s;
    }

    @keyframes thinkingDots {
        0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
        40% { transform: scale(1); opacity: 1; }
    }

    /* ================================================================
       8. BOTTOM NAVIGATION - Premium Tab Bar
       iOS CRITICAL: Nav bar MUST be flush at screen bottom with ZERO gaps
       ================================================================ */
    .mobile-quick-bar {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        margin: 0 !important;
        background: #000000 !important;
        border: none !important;
        box-shadow: none !important;
        height: auto !important;
        padding: 6px 0 !important;
        /* Ensure safe area padding with minimum fallback for iOS home indicator */
        padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)) !important;
        display: flex !important;
        justify-content: space-around !important;
        align-items: center !important;
        z-index: 99998 !important;
        transform: none !important;
    }

    .mobile-quick-btn {
        background: transparent !important;
        border: none !important;
        border-radius: 12px !important;
        padding: 10px 14px !important;
        color: #666666 !important;
        box-shadow: none !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 6px !important;
        transition: all 0.2s ease !important;
        min-width: 64px !important;
        min-height: 54px !important;
        cursor: pointer !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
    }

    /* Active/Selected tab - OBVIOUS highlight */
    .mobile-quick-btn.active {
        background: rgba(124, 58, 237, 0.15) !important;
        color: #a78bfa !important;
    }

    .mobile-quick-btn:active {
        transform: scale(0.95) !important;
        background: rgba(255,255,255,0.05) !important;
    }

    /* Lucide Icon Styling - Larger */
    .mobile-quick-btn svg,
    .mobile-quick-btn [data-lucide],
    .mobile-quick-btn i {
        width: 26px !important;
        height: 26px !important;
        stroke: currentColor !important;
        stroke-width: 1.75 !important;
        fill: none !important;
        transition: all 0.2s ease !important;
        font-size: 24px !important;
    }

    .mobile-quick-btn.active svg,
    .mobile-quick-btn.active [data-lucide],
    .mobile-quick-btn.active i {
        stroke: #a78bfa !important;
        color: #a78bfa !important;
        filter: drop-shadow(0 0 6px rgba(167, 139, 250, 0.5)) !important;
    }

    /* Tab labels - Readable */
    .mobile-quick-btn span {
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
        font-size: 11px !important;
        font-weight: 500 !important;
        letter-spacing: 0.01em !important;
        text-transform: capitalize !important;
        color: inherit !important;
        -webkit-font-smoothing: antialiased !important;
        line-height: 1.2 !important;
    }

    .mobile-quick-btn.active span {
        color: #a78bfa !important;
        font-weight: 600 !important;
    }

    /* ================================================================
       9. HEADER / TOPBAR - Show with mode dropdown on iOS
       ================================================================ */
    .topbar {
        display: flex !important;
        justify-content: center !important;
        align-items: flex-end !important;
        /* Padding: content sits at bottom, safe area at top is just background */
        /* iOS fix: Reduced padding to minimize space between status bar and dropdown */
        padding: 0 15px 4px 60px !important;
        padding-top: env(safe-area-inset-top, 0) !important;
        /* Compact height - reduced from 44px to 36px for minimal iOS status bar gap */
        height: calc(36px + env(safe-area-inset-top, 0)) !important;
        min-height: calc(36px + env(safe-area-inset-top, 0)) !important;
        /* Match the dark UI background - PURE BLACK */
        background: #000000 !important;
        border-bottom: none !important;
        /* Ensure topbar starts at very top */
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1000 !important;
    }

    /* REMOVE the red gradient line under topbar on mobile */
    .topbar::after {
        display: none !important;
        content: none !important;
    }

    /* Hide chat title on mobile - mode dropdown replaces it */
    .chat-title {
        display: none !important;
    }

    /* Show header mode dropdown prominently on mobile */
    .header-mode-dropdown {
        display: flex !important;
        position: absolute !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }

    /* Hide topbar action buttons on mobile - clean ChatGPT style */
    .topbar-actions {
        display: none !important;
    }

    .topbar-actions .action-btn {
        background: transparent !important;
        border: none !important;
        color: #888888 !important;
        padding: 10px !important;
        border-radius: 10px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        transition: all 0.15s ease !important;
    }

    .topbar-actions .action-btn:active,
    .topbar-actions .action-btn.active {
        color: #ffffff !important;
        background: rgba(255,255,255,0.1) !important;
    }

    /* WEB SEARCH BUTTON - Obvious green glow when active */
    .topbar-actions #webModeBtn.active {
        background: rgba(34, 197, 94, 0.35) !important;
        border: 2px solid rgba(34, 197, 94, 0.8) !important;
        box-shadow: 0 0 15px rgba(34, 197, 94, 0.5), inset 0 0 10px rgba(34, 197, 94, 0.2) !important;
        color: #22c55e !important;
    }

    .topbar-actions #webModeBtn.active .icon svg {
        stroke: #22c55e !important;
        filter: drop-shadow(0 0 4px rgba(34, 197, 94, 0.8)) !important;
    }

    .topbar-actions .action-btn .icon {
        font-size: 20px !important;
    }

    /* Hide text labels on mobile */
    .topbar-actions .action-btn .text {
        display: none !important;
    }

    /* ================================================================
       10. SCROLLBAR & MISC
       ================================================================ */
    .chat-container::-webkit-scrollbar {
        width: 4px !important;
    }

    .chat-container::-webkit-scrollbar-track {
        background: transparent !important;
    }

    .chat-container::-webkit-scrollbar-thumb {
        background: #2a2a2a !important;
        border-radius: 2px !important;
    }

    /* Code blocks */
    .message-text code {
        background: #000000;
        border: 1px solid #2a2a2a;
        color: #e0e0e0;
        font-family: 'SF Mono', Menlo, Monaco, monospace;
        font-size: 14px;
        padding: 2px 6px;
        border-radius: 4px;
    }

    .message-text pre {
        background: #000000;
        border: 1px solid #2a2a2a;
        border-radius: 8px;
        padding: 16px;
    }

    /* Links */
    .message-text a {
        color: #a78bfa;
        text-decoration: none;
    }

    /* Bold text */
    .message-text strong,
    .message-text b {
        color: #ffffff;
        font-weight: 600;
    }

    /* Lists */
    .message-text ul,
    .message-text ol {
        padding-left: 20px;
        margin: 12px 0;
    }

    .message-text li {
        margin-bottom: 8px;
        color: #ffffff;
    }

    .message-text li::marker {
        color: #666666;
    }

    /* CRITICAL: Ensure ALL sidebar elements are clickable */
    .sidebar,
    .sidebar *,
    #sidebar,
    #sidebar *,
    .sidebar-buttons,
    .sidebar-buttons *,
    .sidebar-btn,
    .mobile-entity-switcher,
    #mobileEntitySwitcher,
    .user-info,
    .system-status-bar,
    /* Balance display elements */
    .balance-display,
    .balance-item,
    .balance-manage-btn,
    .balance-cancel-btn,
    .balance-action {
        pointer-events: auto !important;
    }

    /* CRITICAL: Balance buttons must be super clickable on mobile */
    .balance-item,
    .balance-manage-btn,
    .balance-cancel-btn {
        position: relative !important;
        z-index: 10 !important;
        cursor: pointer !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(255,0,64,0.3) !important;
    }

    /* Balance item children should not block clicks */
    .balance-item .balance-icon,
    .balance-item .balance-label,
    .balance-item .balance-value,
    .balance-item .balance-action {
        pointer-events: none !important;
    }

    /* Visual feedback on tap for balance items */
    .balance-item:active,
    .balance-manage-btn:active,
    .balance-cancel-btn:active {
        transform: scale(0.97) !important;
        opacity: 0.8 !important;
    }

    /* CRITICAL: Sidebar buttons must be clickable */
    /* iOS FIX: Larger touch targets and more spacing to prevent accidental clicks */
    .sidebar-btn {
        position: relative !important;
        z-index: 10 !important;
        pointer-events: auto !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(255,0,64,0.3) !important;
        cursor: pointer !important;
        overflow: hidden !important; /* Contain pseudo-elements */
        /* iOS: Minimum 44px touch target + extra padding */
        min-height: 48px !important;
        padding: 14px 20px !important;
        margin-bottom: 8px !important; /* More spacing between buttons */
    }

    /* iOS: Improve sidebar scrolling area spacing */
    .sidebar-buttons {
        padding: 12px 10px !important;
        gap: 10px !important; /* More gap between buttons */
    }

    /* CRITICAL: Pseudo-elements and child elements must not block clicks */
    .sidebar-btn::before,
    .sidebar-btn::after,
    .sidebar-btn .btn-icon,
    .sidebar-btn span,
    .mobile-entity-switcher::before,
    .mobile-entity-switcher::after,
    .mobile-entity-switcher *,
    .entity-switcher-content,
    .entity-switcher-left,
    .entity-switcher-icon,
    .entity-switcher-name,
    .entity-switcher-arrow {
        pointer-events: none !important;
    }

    /* CRITICAL: Mobile entity switcher must be clickable */
    .mobile-entity-switcher {
        position: relative !important;
        z-index: 10 !important;
        pointer-events: auto !important;
        touch-action: manipulation !important;
        cursor: pointer !important;
        -webkit-tap-highlight-color: rgba(255,0,64,0.3) !important;
        /* Button reset styles */
        background: linear-gradient(135deg, rgba(102,126,234,0.1), rgba(118,75,162,0.1)) !important;
        border: 1px solid rgba(102,126,234,0.3) !important;
        border-radius: 12px !important;
        padding: 12px 16px !important;
        width: 100% !important;
        text-align: left !important;
        font-family: inherit !important;
        color: inherit !important;
        margin-bottom: 15px !important;
    }

    /* Visual feedback on tap for entity switcher */
    .mobile-entity-switcher:active {
        transform: scale(0.97) !important;
        opacity: 0.8 !important;
        background: linear-gradient(135deg, rgba(102,126,234,0.2), rgba(118,75,162,0.2)) !important;
    }

    /* CRITICAL: Ensure mobile toggle is absolutely clickable */
    #mobileToggle,
    .mobile-toggle {
        position: fixed !important;
        z-index: 2147483647 !important; /* Maximum possible z-index */
        pointer-events: auto !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(255,0,64,0.3) !important;
        cursor: pointer !important;
    }

    /* CRITICAL: Ensure mobile quick bar is clickable */
    #mobileQuickBar,
    .mobile-quick-bar {
        z-index: 2147483646 !important;
        pointer-events: auto !important;
    }

    .mobile-quick-btn {
        pointer-events: auto !important;
        touch-action: manipulation !important;
    }

    /* Root fixes - prevent scroll bounce and fill entire screen */
    html {
        height: 100%;
        height: 100vh;
        height: 100dvh;
        height: -webkit-fill-available;
        overflow: hidden;
        overscroll-behavior: none;
    }
    body {
        height: 100%;
        height: 100vh;
        height: 100dvh;
        height: -webkit-fill-available;
        overflow: hidden;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        overscroll-behavior: none;
        -webkit-text-size-adjust: 100%;
        /* Ensure body fills to bottom edge including safe area */
        padding-bottom: 0 !important;
        margin: 0 !important;
    }

    /* App container - full screen with safe areas */
    .app-container {
        display: flex;
        flex-direction: column;
        height: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        min-height: -webkit-fill-available;
        width: 100%;
        overflow: hidden;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: 0;
    }

    /* iOS WKWebView fix - ensure page extends to full screen edges */
    /* This fills the safe area below the bottom nav bar on iOS */
    /* CRITICAL: fallback MUST be 0 to avoid creating gaps on devices without safe areas */
    html::after {
        content: '';
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: env(safe-area-inset-bottom, 0);
        background: #000000;
        z-index: 99997;
        pointer-events: none;
    }
    /* Mobile menu toggle - just lines, no box (like ChatGPT) */
    .mobile-toggle {
    display: flex !important;
    position: fixed;
    top: max(12px, env(safe-area-inset-top, 12px));
    left: 12px;
    z-index: 99999 !important;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #ffffff;
    font-size: 1.4rem;
    box-shadow: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    pointer-events: auto !important;
    cursor: pointer;
}
    .mobile-toggle:active {
    transform: scale(0.95);
    background: rgba(255,255,255,0.1);
}
    /* Sidebar as slide-out drawer - KEEP ORIGINAL WHITE/CORPORATE THEME */
    .sidebar {
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        bottom: 0 !important;
        width: 85% !important;
        max-width: 320px !important;
        transform: translateX(-100%);
        z-index: 2147483645 !important;
        pointer-events: auto !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        /* Keep original white/corporate theme */
        background: #ffffff !important;
        border-right: 1px solid #e5e5e5 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        box-shadow: 2px 0 20px rgba(0,0,0,0.15) !important;
    }
    .sidebar.open {
        transform: translateX(0) !important;
        box-shadow: 4px 0 30px rgba(0,0,0,0.2) !important;
    }

    /* SIDEBAR CONTENT - White/Corporate Theme Overrides */
    .sidebar .sidebar-header {
        background: #ffffff;
        border-bottom: 1px solid #e5e5e5;
    }

    .sidebar .sidebar-logo,
    .sidebar .logo-text {
        color: #000000;
        text-shadow: none;
    }

    .sidebar .user-info {
        background: #f8f8f8;
        border: 1px solid #e0e0e0;
        color: #000000;
    }

    .sidebar .user-name,
    .sidebar .user-role {
        color: #333333;
    }

    .sidebar .system-status-bar {
        background: #f5f5f5;
        border: 1px solid #e0e0e0;
        color: #666666;
    }

    .sidebar .status-item,
    .sidebar .status-label,
    .sidebar .status-value {
        color: #333333;
    }

    /* Sidebar buttons - Corporate styling */
    .sidebar .sidebar-btn {
        background: #f8f8f8;
        border: 1px solid #e0e0e0;
        color: #000000;
    }

    .sidebar .sidebar-btn:hover,
    .sidebar .sidebar-btn:active {
        background: #eeeeee;
        border-color: #cccccc;
    }

    .sidebar .sidebar-btn .btn-icon {
        color: #333333;
    }

    .sidebar .sidebar-btn span {
        color: #000000;
    }

    .sidebar .sidebar-buttons {
        background: transparent;
        padding-bottom: 100px; /* Ensure logout button is visible above mobile browser nav */
    }

    /* Make sure logout button is visible */
    .sidebar .sidebar-btn.logout {
        display: flex;
        margin-bottom: 20px;
    }

    /* Sidebar section titles */
    .sidebar .section-title,
    .sidebar h3,
    .sidebar h4 {
        color: #666666;
    }
    /* Sidebar overlay - CRITICAL: Must not block sidebar clicks */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        /* Start AFTER the sidebar width so it doesn't block sidebar */
        left: min(85%, 320px);
        background: rgba(0,0,0,0.5);
        z-index: 2147483644 !important;
        -webkit-tap-highlight-color: transparent;
        pointer-events: none !important;
    }
    .sidebar-overlay.show {
        display: block;
        pointer-events: auto !important;
    }

    /* Topbar - slim and clean - PURE BLACK like ChatGPT */
    .topbar {
    position: relative;
    padding: 0 10px 0 60px;
    height: 56px;
    min-height: 56px;
    gap: 8px;
    background: #000000 !important;
    border-bottom: none !important;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}
    /* Hide chat title on mobile */
    .chat-title {
    display: none !important;
}
    /* Topbar actions container */
    .topbar-actions {
    display: flex;
    gap: 8px;
    flex: 0;
    justify-content: flex-end;
    align-items: center;
}
    /* Hide ALL action buttons by default on mobile */
    .topbar-actions .action-btn,
    .topbar-actions .personality-switcher {
    display: none !important;
}
    /* Show ONLY these 5 buttons on mobile: SEARCH, TASKS, ENTITY, ORACLE, VOICE */
    /* HIDDEN - Clean ChatGPT style has no topbar buttons */
    .topbar-actions #webModeBtn,
    .topbar-actions #tasksBtn,
    .topbar-actions #entityBtn,
    .topbar-actions #oracleVoiceBtn,
    .topbar-actions #voiceBtn {
    display: none !important;
}
    /* Show personality switcher container */
    .topbar-actions .personality-switcher {
    display: flex !important;
}
    /* Hide button text on mobile - icons only */
    .topbar-actions .action-btn .text {
    display: none !important;
}
    .topbar-actions .action-btn .icon {
    font-size: 1.3rem;
}
    /* Settings button on mobile - HIDE (already in mobile-quick-actions bar) */
    .settings-btn {
        display: none !important;
    }

    /* HIDE desktop-only topbar elements on mobile */
    /* Only Instant dropdown should show on iOS */
    .oracle-tools-dropdown,
    #oracleToolsDropdown,
    .topbar > #entityBtn {
        display: none !important;
    }

    /* ENTITY MENU - Mobile Fullscreen Modal */
    .personality-menu {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) scale(0.9) !important;
    min-width: 90vw;
    max-width: 340px;
    border-radius: 20px;
    opacity: 0;
    visibility: hidden;
    z-index: 9999999 !important;
    pointer-events: none;
    background: #0a0a12 !important;
    border: 2px solid rgba(0,247,255,0.6) !important;
}
    body.entity-menu-open .personality-menu {
    transform: translate(-50%, -50%) scale(1) !important;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
    /* Make sure options are clickable */
    .personality-option {
    padding: 20px 22px;
    pointer-events: auto !important;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    background: transparent !important;
}
    .personality-option:active {
    background: rgba(0,247,255,0.2) !important;
}
    .personality-menu::before {
    padding: 18px 20px;
    font-size: 0.8rem;
    letter-spacing: 4px;
}
    .personality-option .p-icon {
    font-size: 2.5rem;
    pointer-events: none;
}
    .personality-option .p-info {
    pointer-events: none;
}
    .personality-option .p-name {
    font-size: 1.1rem;
}
    .personality-option .p-desc {
    font-size: 0.85rem;
}
    .p-check {
    width: 28px;
    height: 28px;
    pointer-events: none;
}
    /* Entity transition on mobile */
    .entity-transition-content {
    padding: 20px;
}
    .entity-icon-large {
    font-size: 5rem !important;
}
    .entity-name-large {
    font-size: 1.8rem !important;
    letter-spacing: 4px !important;
}
    .entity-desc-large {
    font-size: 1rem !important;
}
    /* Brain container - remove black background on mobile */
    .brain-container-corporate {
        background: transparent !important;
        box-shadow: none !important;
    }
    .brain-container-corporate video,
    .crystal-brain-img {
        background: transparent !important;
    }

    /* Hide desktop elements */
    #agiHudStrip,
    #thoughtWave,
    .code-lab {
    display: none !important;
}
    /* Main content - flex fill */
    .main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    position: relative;
    background: #000000 !important;
}
    /* Chat container - scrollable with momentum */
    .chat-container {
        flex: 1;
        padding: 12px;
        /* CRITICAL: Enough bottom padding for fixed input bar + tab bar + safe area */
        /* Reduced from 170px to 140px to match tighter input bar positioning */
        padding-bottom: calc(140px + env(safe-area-inset-bottom, 0px)) !important;
        background: #000000 !important;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
        scroll-behavior: smooth;
        /* Prevent rubber-banding at top/bottom */
        overscroll-behavior: none;
    }
    /* Messages - ChatGPT style */
    .message {
        max-width: 100% !important;
        padding: 0 !important;
        border-radius: 0 !important;
        margin-bottom: 18px !important;
        background: transparent !important;
        border: none !important;
    }

    /* AI messages - NO BOX */
    .message.ai {
        background: transparent !important;
        border: none !important;
    }

    /* User messages - keep bubble */
    .message.user {
        background: transparent !important;
        border: none !important;
    }

    .message-avatar {
        width: 34px;
        height: 34px;
        font-size: 1rem;
        flex-shrink: 0;
    }

    /* ================================================================
       PREMIUM MESSAGE TEXT - High Quality
       ================================================================ */
    .message-text {
        /* Premium system font stack - SF Pro on iOS */
        font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui,
                     'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
        font-size: 17px;
        font-weight: 400;
        line-height: 1.6;
        letter-spacing: 0;

        /* Crisp, premium text rendering */
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
        font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1;
        font-optical-sizing: auto;
    }

    /* AI Message - NO BOX, just clean text */
    .message.ai .message-text {
        background: transparent;
        border: none;
        border-radius: 0;
        padding: 0;
        color: #e8e8e8;
        box-shadow: none;
    }

    /* User Message - Compact iMessage-style bubble */
    .message.user .message-text {
        font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
        font-size: 16px;
        font-weight: 400;
        line-height: 1.4;
        letter-spacing: 0;
        -webkit-font-smoothing: antialiased;
        /* Compact padding - fits content naturally */
        padding: 10px 14px;
    }

    /* Message container spacing */
    .message-content {
        max-width: 100%;
    }

    .message.ai .message-content {
        max-width: 100%;
        background: transparent;
        border: none;
        padding: 0;
    }
    /* Input area - above quick bar with proper safe area */
    /* iOS CRITICAL: small padding, nav bar handles its own spacing */
    .input-area {
        flex-shrink: 0;
        padding: 10px 12px;
        padding-bottom: 8px !important;
        background: #000000 !important;
        border-top: none !important;
        /* Ensure input stays above keyboard */
        position: relative;
        z-index: 50;
    }
    .mode-divider {
    height: 20px;
}
    .deep-thinking-indicator {
    padding: 8px 12px;
    margin-bottom: 8px;
}
    .thinking-brain {
    font-size: 1rem;
}
    .thinking-text {
    font-size: 0.65rem;
    letter-spacing: 1px;
}
    /* Input wrapper - iOS specific override */
    .input-wrapper {
        display: flex !important;
        gap: 12px !important;
        align-items: flex-end !important;
        width: 100% !important;
    }

    /* Input buttons - ensure send button visible */
    .input-buttons {
        display: flex;
        flex-shrink: 0;
        align-items: center;
    }
    /* ================================================================
       PREMIUM INPUT FIELD - ChatGPT Quality
       ================================================================ */
    #messageInput {
        /* Premium system font - matches messages */
        font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui,
                     'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
        font-size: 16px !important; /* Prevents iOS zoom */
        font-weight: 400 !important;
        line-height: 1.5 !important;
        letter-spacing: -0.01em !important;
        min-height: 44px;
        max-height: 120px;
        color: #f5f5f5 !important;
        -webkit-appearance: none !important;
        appearance: none !important;
        border-radius: 0 !important;
        background: transparent !important;

        /* Premium text rendering */
        -webkit-font-smoothing: antialiased !important;
        -moz-osx-font-smoothing: grayscale !important;
        text-rendering: optimizeLegibility !important;

        /* Better touch handling */
        touch-action: manipulation;

        /* White text cursor instead of iOS blue */
        caret-color: #ffffff !important;

        /* iOS cursor jumping prevention */
        -webkit-text-size-adjust: 100% !important;
        transform: translateZ(0) !important;
        -webkit-transform: translateZ(0) !important;
        backface-visibility: hidden !important;
        -webkit-backface-visibility: hidden !important;
        -webkit-overflow-scrolling: touch !important;
    }

    #messageInput::placeholder {
        color: rgba(255, 255, 255, 0.5) !important;
        font-weight: 400 !important;
        letter-spacing: -0.01em !important;
    }

    /* Input container - ChatGPT dark theme */
    .input-container {
        background: #1a1a1a;
        border: 2px solid #2a2a2a;
        border-radius: 24px;
        padding: 12px 16px;
    }

    .input-container:focus-within {
        /* Silver focus border - no purple glow */
        border-color: #5a5a5a;
        box-shadow: none;
    }
    .input-actions {
    display: none;
}
    .send-btn, .stop-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    border-radius: 50%;
    font-size: 1.2rem;
    background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%) !important;
    border: none !important;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4) !important;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    color: #ffffff !important;
}
    .send-btn:active, .stop-btn:active {
    transform: scale(0.9);
}
    .input-footer {
    display: none;
}
    .action-buttons-row {
    display: none !important;
}
    /* Side panels - full screen */
    .side-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    height: 100%;
    z-index: 300;
    border-radius: 0;
    transition: right 0.3s ease;
}
    .side-panel.show {
    right: 0;
}
    /* Modals - Full screen on mobile */
    .modal {
        padding: 0;
        align-items: stretch;
    }

    .modal-content {
        padding: 16px;
        padding-top: calc(16px + env(safe-area-inset-top, 0px));
        padding-bottom: calc(120px + env(safe-area-inset-bottom, 20px));
        border-radius: 0;
        max-height: 100vh;
        height: 100%;
        max-width: 100%;
        width: 100%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        background: #000000;
        border: none;
        display: flex;
        flex-direction: column;
    }

    /* Modal header - sticky */
    .modal-header {
        position: sticky;
        top: 0;
        background: #000000;
        padding: 12px 0 16px 0;
        margin: 0;
        z-index: 10;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: 1px solid #1f1f1f;
        margin-bottom: 16px;
    }

    .modal-title {
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
        font-size: 18px;
        font-weight: 600;
        color: #ffffff;
    }

    .modal-close {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        background: #1a1a1a;
        border: none;
        border-radius: 50%;
        color: #ffffff;
        font-size: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Modal inputs */
    .modal-input,
    .modal-select {
        background: #1a1a1a;
        border: 1px solid #2a2a2a;
        border-radius: 12px;
        padding: 14px 16px;
        font-size: 16px;
        color: #ffffff;
        width: 100%;
        margin-bottom: 12px;
    }

    .modal-input:focus,
    .modal-select:focus {
        border-color: #7c3aed;
        outline: none;
    }

    .modal-input::placeholder {
        color: #666666;
    }

    /* Modal fields */
    .modal-field {
        margin-bottom: 16px;
    }

    .modal-label {
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
        font-size: 14px;
        font-weight: 500;
        color: #888888;
        margin-bottom: 8px;
        display: block;
    }

    /* Aspect ratio buttons */
    .aspect-buttons {
        display: flex;
        gap: 8px;
    }

    .aspect-btn {
        flex: 1;
        padding: 12px;
        background: #1a1a1a;
        border: 1px solid #2a2a2a;
        border-radius: 10px;
        color: #888888;
        font-size: 14px;
        font-weight: 500;
        min-height: 44px;
    }

    .aspect-btn.active {
        background: #7c3aed;
        border-color: #7c3aed;
        color: #ffffff;
    }

    /* Slider */
    .slider-container {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .modal-slider {
        flex: 1;
        height: 6px;
        -webkit-appearance: none;
        background: #2a2a2a;
        border-radius: 3px;
    }

    .modal-slider::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 24px;
        height: 24px;
        background: #7c3aed;
        border-radius: 50%;
    }

    .slider-value {
        color: #ffffff;
        font-size: 14px;
        font-weight: 600;
        min-width: 40px;
    }

    /* Upload area */
    .file-upload-area {
        background: #1a1a1a;
        border: 2px dashed #2a2a2a;
        border-radius: 12px;
        padding: 24px;
        min-height: 100px;
    }

    .upload-placeholder {
        text-align: center;
        color: #666666;
    }

    .upload-icon {
        font-size: 32px;
        display: block;
        margin-bottom: 8px;
    }

    /* Modal button */
    .modal-btn {
        width: 100%;
        padding: 16px;
        background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%);
        border: none;
        border-radius: 12px;
        color: #ffffff;
        font-size: 16px;
        font-weight: 600;
        margin-top: 16px;
        min-height: 52px;
    }

    /* Video/Image result */
    .video-result,
    .image-result {
        margin-top: 16px;
    }

    /* Model info */
    .model-info {
        background: rgba(124, 58, 237, 0.1);
        border: 1px solid rgba(124, 58, 237, 0.3);
        color: #a78bfa;
    }
    /* Oracle overlay - full screen, touch friendly */
    .oracle-overlay {
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
    .oracle-orb-container {
    transform: scale(0.65);
    margin-top: -30px;
}
    .oracle-caption {
    font-size: 1.2rem !important;
    margin-top: 10px;
}
    .oracle-subcaption {
    font-size: 0.8rem !important;
}
    .oracle-btn-group {
    flex-direction: column;
    gap: 12px;
    padding: 0 20px;
    width: 100%;
    max-width: 300px;
}
    /* Oracle stop/close buttons - use compact style, not full width */
    .oracle-stop-btn,
    .oracle-close-btn {
    width: 52px;
    height: 52px;
    padding: 0;
    border-radius: 8px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}
    .oracle-close-btn {
    border-radius: 50%;
}
    /* Boot overlay - tap anywhere */
    #bootOverlay {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    cursor: pointer;
}
    #mobileAudioPrompt {
    bottom: 80px !important;
}
    #mobileAudioPrompt > div {
    padding: 20px 40px !important;
    font-size: 1rem !important;
}
    /* AGI Core Orb */
    #agiCoreOrb {
    display: none !important;
}
    /* Mobile oracle floating btn */
    .mobile-oracle-btn {
    display: none;
}
}

@media (max-width: 480px) {
    /* Keep 48x48 minimum for iOS touch targets */
    .mobile-toggle {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    top: max(8px, env(safe-area-inset-top, 8px));
    left: 8px;
    font-size: 1.4rem;
}
    .topbar {
    padding-left: 58px;
    height: 50px;
}
    .chat-title {
    font-size: 0.8rem;
    max-width: 100px;
}
    .message {
    max-width: 95%;
    padding: 10px 12px;
}
    .message-avatar {
    width: 32px;
    height: 32px;
}
    .message-text {
        font-size: 0.9rem;
        line-height: 1.6;
        letter-spacing: -0.01em;
    }
    .input-area {
    padding: 8px 10px;
    padding-bottom: 8px !important;
}
    .send-btn, .stop-btn {
    width: 46px;
    height: 46px;
    min-width: 46px;
    min-height: 46px;
}
    /* Debate Arena Mobile */
    .debate-arena {
    padding: 10px;
    height: 100vh;
}
    .debate-title {
    font-size: 1.5rem;
    letter-spacing: 4px;
}
    .debate-subtitle {
    font-size: 0.7rem;
    letter-spacing: 4px;
}
    .debate-topic {
    font-size: 0.85rem;
    padding: 8px 15px;
    max-width: 95%;
}
    .debate-stage {
    min-height: 200px;
}
    .fighter-hologram {
    width: 100px;
    height: 130px;
}
    .fighter-head {
    font-size: 2.5rem;
}
    .fighter-torso {
    width: 40px;
    height: 30px;
}
    .fighter-name {
    font-size: 1rem;
    letter-spacing: 2px;
}
    .fighter-stance {
    font-size: 0.7rem;
    padding: 3px 10px;
}
    .health-bar {
    width: 100px;
    height: 12px;
}
    .health-text {
    font-size: 0.75rem;
}
    .debate-vs {
    font-size: 2rem;
}
    .debate-arguments {
    flex-direction: column;
    gap: 10px;
}
    .argument-box {
    min-height: 80px;
    max-height: 100px;
    padding: 12px;
}
    .argument-text {
    font-size: 0.85rem;
}
    .debate-round {
    font-size: 0.9rem;
    padding: 6px 15px;
}
    .debate-controls {
    flex-direction: column;
    gap: 10px;
}
    .debate-btn {
    padding: 12px 20px;
    font-size: 0.75rem;
    min-width: 100%;
}
    .debate-exit {
    top: 10px;
    right: 10px;
    padding: 8px 15px;
    font-size: 0.7rem;
}
    .fight-announcer {
    font-size: 3rem;
}
    .fatality-text {
    font-size: 4rem;
    letter-spacing: 8px;
}
    .fatality-winner {
    font-size: 1.2rem;
}
    .fatality-victim {
    font-size: 1rem;
}
    .fatality-scene {
    font-size: 4rem;
}
    /* Memory Palace Mobile - Dark Theme - Full Screen */
    .memory-palace-overlay {
        z-index: 100000 !important;
        background: #000000 !important;
    }

    .memory-palace-overlay.show {
        display: flex !important;
    }

    .memory-palace-overlay .palace-container {
        width: 100%;
        max-width: 100%;
        max-height: 100vh;
        height: 100%;
        padding: 0;
        margin: 0;
        border-radius: 0;
        background: #000000;
    }

    .palace-header {
        background: #000000;
        border-bottom: 1px solid #222;
        padding: 16px;
        position: relative;
        z-index: 10;
    }

    .palace-header h2,
    .palace-title {
        font-size: 1.3rem;
        color: #ffffff;
    }

    .palace-subtitle {
        color: #888;
    }

    /* Palace close button - VISIBLE and CLICKABLE */
    .palace-close {
        position: absolute;
        top: 50%;
        right: 16px;
        transform: translateY(-50%);
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 50%;
        color: #ffffff;
        font-size: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 100;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .palace-close:active {
        background: rgba(255, 255, 255, 0.2);
        transform: translateY(-50%) scale(0.95);
    }

    .palace-tabs {
        flex-wrap: wrap;
        gap: 8px;
        background: #000000;
        padding: 12px;
        border-bottom: 1px solid #222;
    }
    .palace-tab {
        padding: 10px 15px;
        font-size: 0.8rem;
        background: #1a1a1a;
        color: #ffffff;
    }
    .memories-container {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: unset !important;
        background: #000000;
    }
    .memory-categories {
        width: 100%;
        max-height: none;
        border-right: none !important;
        border-bottom: 1px solid #1f1f1f;
        background: #000000;
    }
    .category-list {
        background: #000000;
    }
    .memory-items-panel {
        padding: 15px;
        background: #000000;
    }
    .memory-items-list {
        background: #000000;
    }
    .palace-card {
        padding: 15px;
        background: #1a1a1a;
    }
    .palace-body {
        background: #000000;
    }
    .palace-content {
        background: #000000;
    }
    .empty-state {
        background: transparent;
        color: #888888;
    }
    .empty-state-icon {
        color: #666666;
    }
    .empty-state-text {
        color: #888888;
    }
}

@media (max-width: 480px) {
    .sidebar-logo { font-size: 1.3rem; letter-spacing: 3px; }
    .brain-container { width: 70px; height: 70px; }
    .brain-core { font-size: 1.8rem; }
    .sidebar-btn {
    padding: 12px 14px;
    font-size: 0.8rem;
    border-radius: 12px;
}
    /* Even simpler topbar */
    .topbar {
    padding: 0 8px 0 50px;
    height: 50px;
}
    .chat-title {
    font-size: 0.85rem;
    max-width: 120px;
}
    /* Compact topbar buttons */
    .topbar-actions #entityBtn,
    .topbar-actions #oracleVoiceBtn,
    .topbar-actions #overdriveBtn,
    .topbar-actions #voiceBtn {
    min-width: 40px;
    height: 40px;
    padding: 8px;
}
    .topbar-actions .action-btn .icon {
    font-size: 1.1rem;
}
    /* Messages - full width */
    .message {
    max-width: 95%;
    padding: 12px 14px;
    border-radius: 16px;
}
    .message-avatar {
    width: 34px;
    height: 34px;
    font-size: 1rem;
}
    .message-text {
        font-size: 0.95rem;
        line-height: 1.65;
        letter-spacing: -0.01em;
    }
    /* Input - compact but beautiful */
    .input-area {
    padding: 10px;
}
    .input-container {
    padding: 10px 14px;
    border-radius: 22px;
}
    .send-btn, .stop-btn {
    width: 46px;
    height: 46px;
}
    /* Mobile oracle button */
    .mobile-oracle-btn {
    width: 54px;
    height: 54px;
    bottom: 85px;
    right: 12px;
    font-size: 1.6rem;
}
    /* Mobile hamburger - keep 44px minimum for iOS */
    .mobile-toggle {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    font-size: 1.3rem;
}
    /* Debate arena compact */
    .debate-title {
    font-size: 1.2rem;
}
    .debate-topic {
    font-size: 0.75rem;
}
    .fighter-head {
    font-size: 2rem;
}
    .fight-announcer {
    font-size: 2.5rem;
}
    .fatality-text {
    font-size: 3rem;
}
}

/* ================================================================
   SAFARI MOBILE BROWSER - Extra bottom padding for Safari toolbar
   Safari on iOS has a bottom toolbar (Reader Available, etc.) that
   covers content. This adds extra spacing to compensate.
   ================================================================ */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 768px) {
        /* Safari-specific: Add extra bottom spacing for Safari's bottom toolbar */
        .input-area {
            /* Extra padding for Safari's bottom UI elements - reduced from 85px */
            bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
        }

        .chat-container {
            /* Extra padding for Safari's bottom toolbar - reduced from 190px */
            padding-bottom: calc(160px + env(safe-area-inset-bottom, 0px)) !important;
        }
    }
}

@media (max-width: 768px) and (orientation: landscape) {
    .topbar {
        height: 44px;
    }
    .chat-container {
        padding: 8px;
        /* Keep enough bottom padding even in landscape - reduced */
        padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px)) !important;
    }
    .input-area {
        padding: 8px 16px !important;
        /* Landscape: tab bar is shorter - reduced from 60px */
        bottom: calc(50px + env(safe-area-inset-bottom, 0px)) !important;
    }
    #agiCoreOrb {
    display: none !important;
}
    .mobile-oracle-btn {
    bottom: 70px;
    width: 44px;
    height: 44px;
}
}

@media (max-width: 768px) {
    /* Only show oracle overlay when .show class is present */
    .oracle-overlay.show {
        padding: 15px !important;
        padding-bottom: calc(30px + env(safe-area-inset-bottom)) !important;
        background: #000000 !important;
        overflow-y: auto !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
    }
    /* Ensure overlay is completely hidden when not showing */
    .oracle-overlay:not(.show) {
        display: none !important;
    }

    .oracle-orb-video-wrapper,
    #oracleOrbWebP {
        background: transparent !important;
    }

    .oracle-orb-container {
        transform: scale(0.75);
        margin-top: -30px;
        background: transparent !important;
    }
    .oracle-orb {
    width: 200px;
    height: 200px;
}
    .oracle-orb-core {
    width: 160px;
    height: 160px;
}
    .oracle-orb-core-pupil {
    width: 120px;
    height: 120px;
}
    .oracle-orb-container::before {
    width: 350px;
    height: 350px;
}
    .oracle-orb-container::after {
    width: 330px;
    height: 330px;
}
    .debris-shard {
    transform-origin: 100px 100px;
}
    .debris-shard:nth-child(1),
    .debris-shard:nth-child(2),
    .debris-shard:nth-child(3),
    .debris-shard:nth-child(4),
    .debris-shard:nth-child(5),
    .debris-shard:nth-child(6) {
    --orbit-duration: 20s;
}
    @keyframes debrisOrbit {
    0% { transform: rotate(0deg) translateX(120px) rotate(0deg); }
    100% { transform: rotate(360deg) translateX(120px) rotate(-360deg); }
}
    .oracle-caption {
    font-size: 1.2rem;
    letter-spacing: 4px;
    margin-top: 15px;
}
    .oracle-subcaption {
    font-size: 0.85rem;
    margin-top: 6px;
}
    .oracle-btn-group {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    position: fixed !important;
    bottom: calc(90px + env(safe-area-inset-bottom)) !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 90% !important;
    max-width: 350px !important;
    padding: 0 20px !important;
    align-items: center !important;
    z-index: 999999 !important;
}
    /* Note: oracle-stop-btn and oracle-close-btn are now compact 52px buttons in oracle-controls-container */
    /* The oracle-btn-group styles are kept for legacy compatibility but won't affect the new layout */
    /* Oracle status text for mobile */
    .oracle-status-mobile {
    position: absolute;
    bottom: 100px;
    left: 0;
    right: 0;
    text-align: center;
    color: rgba(0, 229, 255, 0.8);
    font-size: 0.9rem;
    font-family: 'Orbitron', sans-serif;
    animation: pulse 2s ease-in-out infinite;
}
}

@media (max-width: 768px) {
    /* Ensure everything is touch-friendly - CRITICAL for Settings panel */
    button, .action-btn, .sidebar-btn, .mobile-quick-btn,
    .toggle-switch, .theme-btn, .metric-item, .device-card, .integration-item, .smart-btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}
    /* Make toggle switches larger on mobile for easier tapping */
    .toggle-switch {
    min-width: 54px;
    min-height: 30px;
    padding: 4px;
}
    /* Better send button for mobile */
    .send-btn {
    min-width: 54px;
    min-height: 54px;
    touch-action: manipulation;
}
    /* Fix input container on mobile */
    .input-container {
    min-height: 50px;
}
    /* Message input should not zoom on iOS - Premium typography */
    #messageInput {
        font-family: var(--font-sans);
        font-size: 16px !important;
        letter-spacing: -0.01em;
        -webkit-font-smoothing: antialiased;
        transform: none;
        /* White text cursor instead of iOS blue */
        caret-color: #ffffff !important;
    }
    /* Make modals scrollable */
    .modal-content {
    max-height: 85vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
    /* Chat container scrolling */
    .chat-container {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
    /* Side panel on mobile */
    .side-panel {
    width: 100%;
    right: -100%;
}
    .side-panel.open {
    right: 0;
}
    /* Hide desktop-only elements */
    .code-lab,
    #agiHudStrip,
    #thoughtWave {
    display: none !important;
}
    /* Mobile sidebar overlay tap to close - DISABLED to prevent click blocking */
    /* The sidebar-overlay element handles this functionality instead */
    .sidebar.open::after {
        display: none !important;
    }
}

@media (max-width: 380px) {
    .oracle-orb-container {
    transform: scale(0.6);
    margin-top: -50px;
}
    .oracle-caption {
    font-size: 1rem;
}
    .oracle-btn-group {
    padding: 0 10px;
}
    /* oracle-stop-btn and oracle-close-btn use compact button style from components.css */
}

@media (max-width: 768px) {
    .mobile-quick-bar {
    display: flex;
}
}

@media (max-width: 380px) {
    .mobile-quick-btn {
    padding: 6px 10px;
    min-width: 48px;
    font-size: 1.2rem;
}
    .mobile-quick-btn span {
    font-size: 0.5rem;
}
}

/* ================================================================
   BOOT/LOADING SCREEN - White Background, Black Matrix Rain
   Clean, minimal style to match main UI
   ================================================================ */

/* Boot Overlay - White Background */
#bootOverlay {
    background: #ffffff !important;
    color: #000000 !important;
}

/* Hide decorative green layers */
#bootOverlay #starsLayer,
#bootOverlay #warningPulse {
    opacity: 0 !important;
}

/* Matrix canvas - reduce opacity */
#matrixBootCanvas {
    opacity: 0.3 !important;
}

/* CRT scanlines - hide */
#bootOverlay > div[style*="repeating-linear-gradient"] {
    display: none !important;
}

/* Header - white bg */
#broadcastHeader {
    background: linear-gradient(180deg, rgba(255,255,255,0.98), transparent) !important;
}

#broadcastHeader * {
    color: #000000 !important;
    text-shadow: none !important;
}

#broadcastHeader span[style*="color:rgba"] {
    color: #666666 !important;
}

/* AI Face section - black text */
#aiFace * {
    text-shadow: none !important;
}

#aiFace div[style*="color:#00ff88"],
#aiFace div[style*="color:rgba(0,255,136"] {
    color: #000000 !important;
}

#aiFace div[style*="font-size:0.85rem"] {
    color: #666666 !important;
}

/* Rings - subtle black */
#aiFace div[style*="border:"][style*="solid"] {
    border-color: rgba(0,0,0,0.1) !important;
    box-shadow: none !important;
}

#aiFace div[style*="border:"][style*="dashed"],
#aiFace div[style*="border:"][style*="dotted"] {
    border-color: rgba(0,0,0,0.05) !important;
}

/* Orbit particles - black */
#aiFace .orbit-particle div {
    background: #000000 !important;
    box-shadow: 0 0 10px rgba(0,0,0,0.2) !important;
}

/* Decorative line - black */
#aiFace div[style*="height:1px"][style*="background:linear"] {
    background: linear-gradient(90deg, transparent, #000000, transparent) !important;
    box-shadow: none !important;
}

/* Message box - white card */
#broadcastBox {
    background: rgba(255,255,255,0.98) !important;
    border-color: #e0e0e0 !important;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08) !important;
    backdrop-filter: none !important;
}

/* Corner decorations - black */
#broadcastBox > div[style*="position:absolute"][style*="border"] {
    border-color: #000000 !important;
}

/* Message text - black */
#broadcastText {
    color: #000000 !important;
    text-shadow: none !important;
}

/* Cursor - black */
#broadcastCursor {
    background: #000000 !important;
    box-shadow: none !important;
}

/* Status bar - subtle gray */
#statusBar {
    background: rgba(0,0,0,0.02) !important;
    border-color: #e0e0e0 !important;
}

#statusBar * {
    color: #666666 !important;
}

#statusBar span[style*="color:#00ff88"] {
    color: #000000 !important;
}

#statusBar span[style*="background:#00ff88"] {
    background: #000000 !important;
    box-shadow: none !important;
}

/* Boot transition panel - white */
#bootTransition > div[style*="border:1px"] {
    background: rgba(255,255,255,0.98) !important;
    border-color: #e0e0e0 !important;
    box-shadow: 0 4px 30px rgba(0,0,0,0.1) !important;
    backdrop-filter: none !important;
}

#bootTransition * {
    color: #000000 !important;
}

#bootLog {
    color: #333333 !important;
}

/* Boot scan line - black */
#bootTransition div[style*="height:2px"][style*="background:linear"] {
    background: linear-gradient(90deg, transparent, #000000, transparent) !important;
}

/* Skip hint */
#bootOverlay div[style*="bottom:20px"] * {
    color: rgba(0,0,0,0.3) !important;
}

/* Boot hint */
#bootHint {
    color: rgba(0,0,0,0.5) !important;
}

/* Mobile audio prompt */
#mobileAudioPrompt > div {
    background: rgba(0,0,0,0.03) !important;
    border-color: #e0e0e0 !important;
    color: #000000 !important;
}

/* Light beam - hide or make subtle */
#bootOverlay div[style*="top:50%"][style*="height:1px"] {
    opacity: 0.2 !important;
    background: linear-gradient(90deg, transparent, rgba(0,0,0,0.3), rgba(0,0,0,0.5), rgba(0,0,0,0.3), transparent) !important;
    box-shadow: none !important;
}

/* Loading overlay - white */
.loading-overlay {
    background: rgba(255,255,255,0.95);
}

.loading-spinner {
    border-color: #e0e0e0;
    border-top-color: #000000;
}

.loading-text {
    color: #000000;
}

/* ================================================================
   MOBILE-FIRST REDESIGN - Clean, Minimal, Apple-style
   - System Control Center: White bg, black text, touch-friendly
   - Sidebar: Clean buttons, entity switcher, no confusing stats
   - Memory Palace: Touch-friendly rows
   ================================================================ */

@media (max-width: 768px) {

    /* ============================================
       MOBILE SYSTEM CONTROL CENTER - Full Screen Modal
       ============================================ */

    /* Hide desktop System Panel on mobile */
    #systemPanel {
        display: none !important;
    }

    /* Mobile System Panel - Full Screen, White */
    #mobileSystemPanel {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 10000;
        background: #ffffff;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: env(safe-area-inset-top, 20px) 20px env(safe-area-inset-bottom, 20px) 20px;
    }

    #mobileSystemPanel.show {
        display: block;
    }

    .mobile-panel-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 0;
        border-bottom: 1px solid #e0e0e0;
        margin-bottom: 20px;
        position: sticky;
        top: 0;
        background: #ffffff;
        z-index: 10;
    }

    .mobile-panel-title {
        font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
        font-size: 1.5rem;
        font-weight: 600;
        color: #000000;
        letter-spacing: -0.5px;
    }

    .mobile-panel-close {
        width: 48px;
        height: 48px;
        border: none;
        background: #f5f5f5;
        border-radius: 50%;
        font-size: 1.5rem;
        color: #000000;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-panel-close:active {
        transform: scale(0.95);
        background: #e0e0e0;
    }

    /* Section Styling */
    .mobile-section {
        margin-bottom: 24px;
    }

    .mobile-section-title {
        font-family: -apple-system, BlinkMacSystemFont, sans-serif;
        font-size: 0.75rem;
        font-weight: 600;
        color: #666666;
        letter-spacing: 1px;
        text-transform: uppercase;
        margin-bottom: 12px;
        padding-left: 4px;
    }

    /* Toggle Row */
    .mobile-toggle-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px;
        background: #ffffff;
        border: 1px solid #e0e0e0;
        border-radius: 12px;
        margin-bottom: 8px;
        min-height: 56px;
        touch-action: manipulation;
    }

    .mobile-toggle-label {
        font-family: -apple-system, BlinkMacSystemFont, sans-serif;
        font-size: 1rem;
        color: #000000;
    }

    .mobile-toggle-switch {
        position: relative;
        width: 51px;
        height: 31px;
        background: #e0e0e0;
        border-radius: 31px;
        cursor: pointer;
        transition: background 0.3s ease;
        flex-shrink: 0;
    }

    .mobile-toggle-switch.active {
        background: #000000;
    }

    .mobile-toggle-switch::after {
        content: '';
        position: absolute;
        top: 2px;
        left: 2px;
        width: 27px;
        height: 27px;
        background: #ffffff;
        border-radius: 50%;
        box-shadow: 0 2px 4px rgba(0,0,0,0.2);
        transition: transform 0.3s ease;
    }

    .mobile-toggle-switch.active::after {
        transform: translateX(20px);
    }

    /* Integration Cards - 2x2 Grid */
    .mobile-integration-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .mobile-integration-card {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 20px 16px;
        background: #ffffff;
        border: 1px solid #e0e0e0;
        border-radius: 16px;
        min-height: 100px;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        transition: all 0.2s ease;
    }

    .mobile-integration-card:active {
        transform: scale(0.98);
        background: #f5f5f5;
    }

    .mobile-integration-card.connected {
        border-color: #000000;
    }

    .mobile-integration-icon {
        font-size: 2rem;
        margin-bottom: 8px;
    }

    .mobile-integration-name {
        font-family: -apple-system, BlinkMacSystemFont, sans-serif;
        font-size: 0.9rem;
        font-weight: 500;
        color: #000000;
    }

    .mobile-integration-status {
        font-size: 0.75rem;
        color: #666666;
        margin-top: 4px;
    }

    /* Status Grid - 2x2 */
    .mobile-status-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .mobile-status-card {
        padding: 16px;
        background: #f8f8f8;
        border-radius: 12px;
        text-align: center;
    }

    .mobile-status-label {
        font-size: 0.75rem;
        color: #666666;
        margin-bottom: 4px;
    }

    .mobile-status-value {
        font-family: -apple-system, BlinkMacSystemFont, sans-serif;
        font-size: 1rem;
        font-weight: 600;
        color: #000000;
    }

    /* Action Buttons */
    .mobile-action-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        padding: 16px;
        background: #ffffff;
        border: 1px solid #e0e0e0;
        border-radius: 12px;
        font-family: -apple-system, BlinkMacSystemFont, sans-serif;
        font-size: 1rem;
        color: #000000;
        margin-bottom: 8px;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        min-height: 52px;
    }

    .mobile-action-btn:active {
        background: #f5f5f5;
        transform: scale(0.99);
    }

    .mobile-action-btn.danger {
        color: #ff3b30;
        border-color: #ff3b30;
    }

    /* Legal Links - Mobile Tap Support */
    .mobile-legal-links {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        gap: 16px;
        padding: 20px 16px;
        border-top: 1px solid #2a2a2a;
        margin-top: 20px;
        position: relative;
        z-index: 10;
    }

    .mobile-legal-link {
        font-family: 'Inter', sans-serif;
        font-size: 13px;
        font-weight: 500;
        color: #666666;
        text-decoration: none;
        cursor: pointer;
        padding: 10px 14px;
        border-radius: 8px;
        background: transparent;
        pointer-events: auto;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(124, 58, 237, 0.2);
        transition: color 0.15s ease, background 0.15s ease;
    }

    .mobile-legal-link:hover,
    .mobile-legal-link:active {
        color: #ffffff;
        background: #1a1a1a;
    }

    /* Legal Footer - Below Chat (Mobile Tap Support) */
    .legal-footer {
        display: block !important;
        background: #000000 !important;
        border-top: 1px solid #1a1a1a !important;
        padding: 16px !important;
        padding-bottom: calc(90px + env(safe-area-inset-bottom, 10px)) !important;
        position: relative !important;
        z-index: 5 !important;
    }

    .legal-footer-content {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: 8px;
    }

    .legal-footer .legal-company {
        font-family: 'Inter', sans-serif;
        font-size: 11px;
        color: #525252;
        width: 100%;
        text-align: center;
        margin-bottom: 8px;
    }

    .legal-footer .legal-separator {
        display: none;
    }

    .legal-footer .legal-link {
        font-family: 'Inter', sans-serif;
        font-size: 13px;
        font-weight: 500;
        color: #666666;
        text-decoration: none;
        padding: 10px 14px;
        border-radius: 8px;
        background: #1a1a1a;
        pointer-events: auto;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(124, 58, 237, 0.2);
        transition: all 0.15s ease;
    }

    .legal-footer .legal-link:active {
        background: #2a2a2a;
        color: #ffffff;
        transform: scale(0.98);
    }

    /* ============================================
       MOBILE SIDEBAR - Clean, Entity Switcher
       ============================================ */

    /* Clean up sidebar header */
    .sidebar .emotion-meter,
    .sidebar .power-status {
        display: none !important;
    }

    /* Entity Switcher in Sidebar - White/Corporate Theme */
    .mobile-entity-switcher {
        display: block;
        margin: 0 15px 15px 15px;
        padding: 14px 16px;
        background: #f8f8f8 !important;
        border: 1px solid #e0e0e0 !important;
        border-radius: 12px;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-entity-switcher:active {
        background: #eeeeee !important;
    }

    .entity-switcher-content {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .entity-switcher-left {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .entity-switcher-icon {
        font-size: 1.5rem;
    }

    .entity-switcher-name {
        font-family: 'Orbitron', sans-serif;
        font-size: 0.9rem;
        color: #000000 !important;
        letter-spacing: 1px;
    }

    .entity-switcher-arrow {
        color: #666666 !important;
        font-size: 0.8rem;
    }

    /* Clean sidebar buttons */
    .sidebar-btn {
        min-height: 48px;
        margin-bottom: 8px;
    }

    /* ============================================
       MOBILE MEMORY PALACE - Simple Single Column
       ============================================ */

    .memory-palace-overlay {
        padding: 0 !important;
        background: #000000 !important;
    }

    .memory-palace-overlay .palace-container {
        background: #000000;
        max-width: 100%;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        padding: 0;
        display: flex;
        flex-direction: column;
    }

    /* Simple dark header */
    .palace-header {
        background: #000000;
        border-bottom: 1px solid #1f1f1f;
        padding: 16px 20px;
        padding-top: calc(16px + env(safe-area-inset-top, 0px));
        position: sticky;
        top: 0;
        z-index: 10;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .palace-header .palace-header-glow,
    .palace-header .palace-orb {
        display: none !important;
    }

    .palace-title {
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
        font-size: 18px;
        font-weight: 600;
        color: #ffffff;
        letter-spacing: -0.02em;
        text-shadow: none;
    }

    .palace-subtitle {
        display: none !important;
    }

    .palace-close {
        width: 44px;
        height: 44px;
        background: #1a1a1a;
        border: none;
        color: #ffffff;
        font-size: 20px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Mobile tabs - horizontal scrollable */
    .palace-tabs {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 8px;
        padding: 12px 16px;
        background: #000000;
        border-bottom: 1px solid #222;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .palace-tabs::-webkit-scrollbar {
        display: none;
    }

    .palace-tab {
        flex-shrink: 0;
        padding: 10px 16px;
        font-size: 0.85rem;
        background: #1a1a1a;
        color: #ffffff;
        border-radius: 20px;
        border: 1px solid #333;
        min-width: fit-content;
    }

    .palace-tab.active {
        background: #7c3aed;
        border-color: #7c3aed;
    }

    .palace-tab .tab-icon {
        margin-right: 6px;
    }

    .palace-tab .tab-count {
        margin-left: 6px;
        background: rgba(255,255,255,0.2);
        padding: 2px 8px;
        border-radius: 10px;
        font-size: 0.75rem;
    }

    /* Main content area - single column scroll */
    .palace-content {
        display: flex;
        flex-direction: column;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        background: #000000;
    }

    /* Override grid layout - make single column */
    .memories-container {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: unset !important;
        background: #000000;
        height: 100%;
    }

    .category-list {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        gap: 8px;
        padding: 0;
        background: transparent;
        overflow-x: auto;
    }

    .palace-body {
        background: #000000;
        flex: 1;
    }

    /* Hide category sidebar - show as horizontal scroll instead */
    .memory-categories {
        background: #000000;
        border-right: none !important;
        border-bottom: 1px solid #1f1f1f;
        padding: 12px 16px;
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto;
        gap: 8px;
        flex-shrink: 0;
    }

    .category-header {
        display: none !important;
    }

    .category-item {
        background: #1a1a1a;
        border: 1px solid #2a2a2a;
        border-left: none !important;
        border-radius: 20px;
        padding: 10px 16px;
        margin-bottom: 0;
        flex-shrink: 0;
        min-width: fit-content;
    }

    .category-item.active {
        background: #7c3aed;
        border-color: #7c3aed;
    }

    .category-name {
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
        color: #ffffff;
        font-size: 14px;
        font-weight: 500;
    }

    .category-count {
        color: #888888;
        margin-left: 6px;
    }

    .category-item.active .category-count {
        color: rgba(255,255,255,0.8);
    }

    .category-icon {
        display: none !important;
    }

    /* Memory items panel - full width */
    .memory-items-panel {
        background: #000000;
        flex: 1;
        padding: 16px;
    }

    .memory-items-list {
        background: #000000;
        padding: 0;
    }

    /* Empty state - dark themed */
    .empty-state {
        background: transparent;
        color: #888888;
        padding: 40px 20px;
    }

    .empty-state-icon {
        color: #444444;
        font-size: 48px;
    }

    .empty-state-text {
        color: #666666;
        font-size: 14px;
    }

    .memory-items-header {
        display: none !important;
    }

    #currentCategoryTitle {
        display: none !important;
    }

    /* Memory items as cards */
    .memory-item {
        background: #1a1a1a;
        border: 1px solid #2a2a2a;
        border-radius: 12px;
        padding: 16px;
        margin-bottom: 12px;
    }

    .memory-item-content {
        color: #e5e5e5;
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
        font-size: 15px;
        line-height: 1.5;
    }

    .memory-item-date {
        color: #666666;
        font-size: 12px;
        margin-top: 8px;
    }

    .memory-item-actions {
        margin-top: 12px;
        display: flex;
        gap: 8px;
    }

    .memory-item-actions button {
        background: #2a2a2a;
        border: none;
        color: #888888;
        padding: 8px 12px;
        border-radius: 8px;
        font-size: 13px;
    }

    .palace-btn {
        background: #000000;
        color: #ffffff;
        border: none;
        border-radius: 8px;
        padding: 10px 16px;
        font-family: -apple-system, BlinkMacSystemFont, sans-serif;
        font-size: 0.85rem;
    }

    .palace-btn.secondary {
        background: #f5f5f5;
        color: #000000;
        border: 1px solid #e0e0e0;
    }

    .palace-btn.danger {
        background: #ffffff;
        color: #ff3b30;
        border: 1px solid #ff3b30;
    }

    /* Palace footer */
    .palace-footer {
        background: #f8f8f8;
        border-top: 1px solid #e0e0e0;
        padding: 16px;
        position: sticky;
        bottom: 0;
    }

    .palace-stats {
        justify-content: center;
        gap: 20px;
        margin-bottom: 16px;
    }

    .stat-item {
        color: #666666;
        font-family: -apple-system, BlinkMacSystemFont, sans-serif;
        font-size: 0.85rem;
    }

    .palace-actions {
        display: flex;
        gap: 8px;
    }

    .palace-actions .palace-btn {
        flex: 1;
        text-align: center;
    }

    /* Hide matrix backgrounds in Memory Palace */
    .palace-matrix-bg,
    #palaceMatrixBg {
        display: none !important;
    }

    /* Chat history items */
    .palace-list {
        padding: 12px;
    }

    .chat-item,
    .project-item {
        background: #ffffff;
        border: 1px solid #e0e0e0;
        border-radius: 12px;
        padding: 14px 16px;
        margin-bottom: 8px;
    }

    .chat-item:active,
    .project-item:active {
        background: #f5f5f5;
    }

    .chat-title,
    .project-title {
        font-family: -apple-system, BlinkMacSystemFont, sans-serif;
        color: #000000;
        font-weight: 500;
    }

    .chat-preview,
    .project-desc {
        color: #666666;
    }

    .chat-date,
    .project-date {
        color: #999999 !important;
        font-size: 0.75rem !important;
    }

    /* Entity Dropdown - Mobile Fullscreen */
    #entityDropdown {
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 90% !important;
        max-width: 340px !important;
        min-width: unset !important;
        z-index: 2147483647 !important;
        pointer-events: auto !important;
    }

    /* Entity dropdown options must be clickable */
    #entityDropdown > div {
        pointer-events: auto !important;
        cursor: pointer !important;
        touch-action: manipulation !important;
    }

    #entityDropdown > div:active {
        opacity: 0.7 !important;
        background: rgba(0,247,255,0.2) !important;
    }

    /* Entity backdrop must be above sidebar overlay */
    #entityBackdropNew {
        z-index: 2147483646 !important;
        pointer-events: auto !important;
    }

    /* ================================================================
       CLUTTER REMOVAL - Remove visual noise
       ================================================================ */

    /* Hide floating emojis and decorations */
    .floating-emoji,
    .decoration,
    .sparkle,
    .glow-effect,
    .star-decoration,
    .matrix-decoration {
        display: none !important;
    }

    /* Remove gradient text unless intentional */
    .gradient-text {
        background: none !important;
        -webkit-background-clip: unset !important;
        -webkit-text-fill-color: #ffffff !important;
    }

    /* Remove excessive text shadows */
    .message-text,
    .chat-text,
    p,
    span,
    h1, h2, h3, h4, h5, h6 {
        text-shadow: none !important;
    }

    /* Clean up cards and panels */
    .card,
    .panel,
    .container {
        box-shadow: none !important;
    }

    /* ================================================================
       PDF VIEWER - Mobile Responsive Fixes
       Prevent horizontal overflow and fit content to screen
       ================================================================ */

    /* Prevent horizontal overflow on body */
    body, html {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }

    /* PDF Container - Make responsive */
    .pdf-container,
    .pdf-viewer,
    .pdf-wrapper,
    iframe[src*="pdf"],
    iframe.pdf-frame {
        width: 100%;
        max-width: 100vw;
        height: auto;
        min-height: 70vh;
        overflow-x: hidden;
        padding: 0;
        margin: 0;
        border: none;
    }

    /* Object and embed tags for PDF */
    object[type="application/pdf"],
    embed[type="application/pdf"] {
        width: 100%;
        height: 85vh;
        max-width: 100vw;
    }

    /* PDF.js viewer container */
    #viewerContainer,
    .pdfViewer {
        overflow-x: hidden;
        width: 100%;
    }

    /* PDF page containers */
    .pdf-page-container {
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
        margin: 0 auto 16px auto;
        padding: 0;
    }

    /* PDF page canvas - scale to fit width */
    .pdf-page-container canvas,
    .page canvas {
        width: 100%;
        height: auto;
        max-width: 100%;
        display: block;
    }

    /* Document preview panel - full screen on mobile */
    .document-preview-panel {
        width: 100vw;
        min-width: unset;
        max-width: 100vw;
        right: -100vw;
        height: 100vh;
        height: 100dvh;
        top: 0;
        bottom: auto;
        border-left: none;
    }

    .document-preview-panel.active {
        right: 0;
    }

    body.doc-preview-open .main-content {
        display: none !important;
    }

    body.doc-preview-open .sidebar,
    body.doc-preview-open .mobile-quick-bar {
        display: none !important;
    }

    /* Document preview content - scrollable */
    .doc-preview-content {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        padding: 12px;
        width: 100%;
        max-width: 100vw;
    }

    /* Document preview content canvas - fit width */
    .doc-preview-content canvas {
        width: 100%;
        height: auto;
        max-width: calc(100vw - 24px);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }

    /* PDF page number label */
    .pdf-page-number {
        font-size: 11px;
        padding: 4px 10px;
        margin-top: 8px;
    }

    /* PDF download cards - stack vertically */
    .pdf-download-container {
        flex-direction: column;
        gap: 8px;
        padding: 12px;
    }

    .pdf-download-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 16px;
    }

    .pdf-ready-card {
        flex-direction: column;
        text-align: center;
        padding: 16px;
        gap: 12px;
    }

    .pdf-ready-card .pdf-info {
        align-items: center;
    }

    .pdf-ready-card .pdf-download-btn {
        width: 100%;
    }

    /* PDF link cards */
    .pdf-card {
        flex-direction: column;
        gap: 8px;
    }

    .pdf-link {
        width: 100%;
        max-width: 100%;
    }

    .pdf-text {
        max-width: 100%;
        white-space: normal;
        word-break: break-word;
    }

    /* Allow pinch-to-zoom on PDF container */
    .pdf-container,
    .doc-preview-content {
        touch-action: pan-x pan-y pinch-zoom;
    }

    /* Document preview header - compact */
    .doc-preview-header {
        padding: 12px 16px;
        gap: 8px;
    }

    .doc-preview-title {
        font-size: 13px;
        flex: 1;
        min-width: 0;
    }

    .doc-filename {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 150px;
    }

    /* Document preview actions - compact */
    .doc-preview-actions {
        gap: 4px;
    }

    .doc-action-btn {
        padding: 6px 10px;
        font-size: 12px;
        min-width: 36px;
    }

    /* Document preview footer - compact */
    .doc-preview-footer {
        padding: 10px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .doc-zoom-controls {
        order: 2;
        width: 100%;
        justify-content: center;
    }

    /* PDF loading state */
    .pdf-page-loading {
        min-height: 200px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        background: #f5f5f5;
        border-radius: 8px;
    }
}

/* ================================================================
   iOS FIXES - Hide boot overlay, fix white bar at top
   ================================================================ */
@media (max-width: 768px) {
    /* HIDE boot overlay completely on mobile/iOS */
    #bootOverlay,
    .boot-overlay,
    .boot-sequence,
    .boot-message,
    [id*="boot"],
    [class*="boot"] {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        position: absolute !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
    }

    /* HIDE Game Hub overlay by default - only show when .show class added */
    #gameHubOverlay,
    .game-hub-overlay {
        display: none !important;
    }
    #gameHubOverlay.show,
    .game-hub-overlay.show {
        display: flex !important;
    }

    /* HIDE Legal Footer on iOS - it bleeds through at top incorrectly */
    .legal-footer,
    .legal-footer-content {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* FIX white/gray bar at top - extend topbar background to top edge */
    html, body {
        background: #000000 !important;
        background-color: #000000 !important;
    }

    /* Make sure body has no top margin/padding */
    body {
        margin: 0 !important;
        padding: 0 !important;
        padding-top: 0 !important;
    }

    /* Topbar should extend to absolute top with safe area as part of the gradient */
    .topbar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        /* Reduced height - only safe area + minimal padding for dropdown */
        min-height: calc(36px + env(safe-area-inset-top, 0)) !important;
        padding-top: env(safe-area-inset-top, 0) !important;
        padding-bottom: 4px !important;
        background: #000000 !important;
        z-index: 1000 !important;
    }

    /* Main content padding to account for fixed topbar */
    /* NOTE: Only app-container gets padding, main-content is nested inside it */
    .app-container {
        padding-top: calc(36px + env(safe-area-inset-top, 0)) !important;
        background: #000000 !important;
    }

    .main-content {
        padding-top: 0 !important;
        background: #000000 !important;
    }
}

/* iOS PDF Close Button - Ensure visibility on all iOS devices */
@media screen and (max-width: 768px) {
    .ios-fixed-close {
        /* Use safe area insets for proper positioning on notched devices */
        top: calc(16px + env(safe-area-inset-top, 0px)) !important;
        top: calc(16px + var(--safe-area-top, env(safe-area-inset-top, 0px))) !important;
        right: calc(16px + env(safe-area-inset-right, 0px)) !important;
        right: calc(16px + var(--safe-area-right, env(safe-area-inset-right, 0px))) !important;
        z-index: 100002 !important;
        width: 56px !important;
        height: 56px !important;
        min-width: 56px !important;
        min-height: 56px !important;
        font-size: 1.4rem !important;
    }

    /* Ensure iOS save modal doesn't cover the close button */
    .ios-save-modal {
        z-index: 100000 !important;
    }

    .ios-save-content {
        z-index: 100001 !important;
        margin-top: calc(80px + env(safe-area-inset-top, 0px)) !important;
        margin-top: calc(80px + var(--safe-area-top, env(safe-area-inset-top, 0px))) !important;
        max-height: calc(85vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* Extra small devices (iPhone SE, etc.) */
@media screen and (max-width: 375px) {
    .ios-fixed-close {
        top: calc(12px + env(safe-area-inset-top, 0px)) !important;
        right: calc(12px + env(safe-area-inset-right, 0px)) !important;
        width: 52px !important;
        height: 52px !important;
        min-width: 52px !important;
        min-height: 52px !important;
        font-size: 1.3rem !important;
    }
}

/* iOS Native App specific styles */
body.ios-native-app .ios-fixed-close {
    /* Use injected CSS variables from native app */
    top: calc(16px + var(--safe-area-top, 44px)) !important;
    right: calc(16px + var(--safe-area-right, 0px)) !important;
}

/* ================================================================
   iOS TWO-BOX SYSTEM - Centered Initial, Bottom After Message
   Matches desktop Perplexity-style input behavior
   ================================================================ */
@media (max-width: 768px) {
    /* Hide mode activation toast on mobile */
    .toast {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
    }

    /* INITIAL STATE: Input centered in middle of screen (no messages) */
    .app-container:not(.has-messages) .input-area {
        position: fixed !important;
        top: 45% !important;
        bottom: auto !important;
        left: 50% !important;
        right: auto !important;
        width: calc(100% - 32px) !important;
        max-width: 500px !important;
        transform: translate(-50%, -50%) !important;
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
        z-index: 100 !important;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    /* AFTER FIRST MESSAGE: Move input to bottom */
    .app-container.has-messages .input-area {
        position: fixed !important;
        top: auto !important;
        /* 66px = nav bar height (6px top + 54px button + 6px bottom) */
        bottom: calc(66px + env(safe-area-inset-bottom, 0px)) !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: none !important;
        transform: none !important;
        background: #000000 !important;
        border-top: 1px solid rgba(255,255,255,0.1) !important;
        padding: 8px 16px !important;
        padding-bottom: 6px !important;
        z-index: 999 !important;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    /* INITIAL STATE: Taller rectangular input box with shimmer */
    .app-container:not(.has-messages) .input-container {
        background: #1e1e1e !important;
        border: 1px solid #3a3a3a !important;
        border-radius: 14px !important;
        padding: 16px 18px !important;
        min-height: 100px !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
        display: flex !important;
        flex-direction: column !important;
        position: relative !important;
        /* Must be visible for dropdown suggestions to show */
        overflow: visible !important;
    }

    /* AFTER FIRST MESSAGE: Slightly shorter but still taller than before */
    .app-container.has-messages .input-container {
        background: #1a1a1a !important;
        border: 1px solid #3a3a3a !important;
        border-radius: 14px !important;
        padding: 14px 16px !important;
        min-height: 80px !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: flex-end !important;
        gap: 12px !important;
        position: relative !important;
        overflow: visible !important;
    }

    /* Animated silver shimmer border effect for initial input */
    .app-container:not(.has-messages) .input-container::before {
        content: '' !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        border-radius: 14px !important;
        border: 2px solid transparent !important;
        background: linear-gradient(90deg,
            transparent 0%,
            rgba(180, 180, 190, 0.5) 25%,
            rgba(220, 220, 230, 0.7) 50%,
            rgba(180, 180, 190, 0.5) 75%,
            transparent 100%) border-box !important;
        -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0) !important;
        mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0) !important;
        -webkit-mask-composite: xor !important;
        mask-composite: exclude !important;
        background-size: 200% 100% !important;
        animation: shimmerBorderMobile 3s ease-in-out infinite !important;
        pointer-events: none !important;
    }

    /* Also show shimmer when input is at bottom - MATCHES DESKTOP EXACTLY */
    .app-container.has-messages .input-container::before {
        content: '' !important;
        position: absolute !important;
        inset: -2px !important;
        border-radius: 16px !important;
        background: linear-gradient(90deg,
            transparent 0%,
            rgba(180, 180, 190, 0.4) 20%,
            rgba(220, 220, 230, 0.6) 50%,
            rgba(180, 180, 190, 0.4) 80%,
            transparent 100%) !important;
        background-size: 200% 100% !important;
        animation: shimmerBorderMobile 3s ease-in-out infinite !important;
        z-index: -1 !important;
        opacity: 1 !important;
    }

    @keyframes shimmerBorderMobile {
        0% { background-position: 200% 0; }
        100% { background-position: -200% 0; }
    }

    /* INITIAL STATE: Message input taller */
    .app-container:not(.has-messages) #messageInput {
        flex: 1 1 auto !important;
        width: 100% !important;
        min-height: 60px !important;
        max-height: 120px !important;
        font-size: 17px !important;
        font-weight: 400 !important;
        line-height: 1.5 !important;
        color: #ffffff !important;
        background: transparent !important;
        border: none !important;
        outline: none !important;
        padding: 0 !important;
        margin: 0 !important;
        resize: none !important;
        caret-color: #ffffff !important;
    }

    /* AFTER FIRST MESSAGE: Textarea styling */
    .app-container.has-messages #messageInput {
        flex: 1 1 auto !important;
        width: 100% !important;
        min-width: 0 !important;
        min-height: 40px !important;
        max-height: 100px !important;
        font-size: 17px !important;
        font-weight: 400 !important;
        line-height: 1.5 !important;
        color: #ffffff !important;
        background: transparent !important;
        border: none !important;
        outline: none !important;
        padding: 0 !important;
        margin: 0 !important;
        resize: none !important;
        caret-color: #ffffff !important;
    }

    /* INITIAL STATE: Send button positioning (inside box) */
    .app-container:not(.has-messages) .input-buttons {
        position: absolute !important;
        right: 14px !important;
        bottom: 14px !important;
        display: flex !important;
        align-items: center !important;
        flex-shrink: 0 !important;
    }

    /* AFTER FIRST MESSAGE: Send button aligned with input */
    .app-container.has-messages .input-buttons {
        position: relative !important;
        display: flex !important;
        align-items: center !important;
        flex-shrink: 0 !important;
    }

    /* Send button styling - transparent with grey icon like desktop */
    .app-container .send-btn,
    .app-container .stop-btn {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
        border-radius: 0 !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        color: #6b7280 !important;
        font-size: 1.2rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        -webkit-tap-highlight-color: transparent !important;
    }

    .app-container .send-btn:active,
    .app-container .stop-btn:active {
        transform: scale(0.95) !important;
        background: transparent !important;
        color: #ffffff !important;
    }

    /* Chat wrapper padding for initial centered state */
    .app-container:not(.has-messages) .chat-think-wrapper {
        padding-bottom: 20px !important;
    }

    /* Chat wrapper padding when input is at bottom */
    .app-container.has-messages .chat-think-wrapper {
        padding-bottom: calc(140px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Hide input actions on iOS - file button is already in nav bar */
    .app-container .input-actions {
        display: none !important;
    }

    /* Search suggestions - hidden by default, shown when .active */
    .app-container:not(.has-messages) .input-suggestions {
        display: none !important;
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        right: 0 !important;
        background: #1e1e1e !important;
        border: 1px solid #3a3a3a !important;
        border-top: none !important;
        border-radius: 0 0 14px 14px !important;
        max-height: 300px !important;
        overflow-y: auto !important;
        z-index: 1000 !important;
        padding: 8px 0 !important;
        margin-top: -2px !important;
    }

    .app-container:not(.has-messages) .input-suggestions.active {
        display: block !important;
    }

    /* Suggestion items styling for iOS */
    .app-container:not(.has-messages) .suggestion-item {
        display: flex !important;
        align-items: center !important;
        gap: 12px !important;
        padding: 12px 16px !important;
        cursor: pointer !important;
        color: #ffffff !important;
        font-size: 15px !important;
    }

    .app-container:not(.has-messages) .suggestion-item:active {
        background: rgba(255, 255, 255, 0.1) !important;
    }

    .app-container:not(.has-messages) .suggestion-icon {
        color: #6b7280 !important;
        font-size: 16px !important;
    }

    /* Hide input suggestions/welcome after first message on mobile */
    .app-container.has-messages .input-suggestions,
    .app-container.has-messages .input-suggestions.active {
        display: none !important;
    }

    /* Hide input actions on iOS - file button is already in nav bar */
    .app-container .input-actions {
        display: none !important;
    }

    /* CRITICAL: Remove any extra space at bottom of screen */
    html, body {
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
        padding-top: 0 !important;
        margin-top: 0 !important;
    }

    /* CRITICAL: Remove the html::after black overlay bar at bottom */
    html::after {
        display: none !important;
        height: 0 !important;
        content: none !important;
    }

    /* Remove any topbar extra height/padding */
    .topbar {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }

    /* CRITICAL: Bottom nav bar flush to screen bottom */
    /* WebKit thinks there's a URL bar - force flush with no safe-area padding */
    .mobile-quick-bar,
    #mobileQuickBar {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        margin: 0 !important;
        padding: 8px 0 8px 0 !important;
        background: #000000 !important;
        z-index: 99999 !important;
        /* Force to actual screen bottom - no safe area */
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
    }

    /* Hide any overlays/footers that might block nav bar */
    .legal-footer,
    .input-footer {
        display: none !important;
    }

    /* Adjust input bar position - nav bar is ~66px tall (6px top + 54px button + 6px bottom) */
    .app-container.has-messages .input-area {
        bottom: calc(66px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Hide welcome greeting after first message */
    .app-container.has-messages .welcome-greeting,
    .app-container.has-messages #welcomeGreeting {
        display: none !important;
    }

    /* HIDE artifact console toggle (red circle) on mobile */
    #artifact-console-toggle {
        display: none !important;
    }
}

