.global-intelligence-sheet {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1500;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    pointer-events: none;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.global-intelligence-sheet.is-open {
    pointer-events: all;
}

.sheet-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.35s ease;
    z-index: 1;
}

.global-intelligence-sheet.is-open .sheet-backdrop {
    opacity: 1;
}

.sheet-content {
    position: relative;
    width: 100%;
    height: 80vh;
    background: rgba(18, 18, 18, 0.85);
    backdrop-filter: blur(24px);
    border-top: 1px solid rgba(0, 255, 153, 0.3);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    z-index: 2;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.global-intelligence-sheet.is-open .sheet-content {
    transform: translateY(0);
}

.sheet-drag-handle {
    width: 40px;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    margin: 10px auto 4px auto;
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.header-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ai-avatar-badge {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(0, 255, 153, 0.15) 0%, rgba(0, 240, 255, 0.15) 100%);
    border: 1px solid rgba(0, 255, 153, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-avatar-badge ::deep i {
    color: var(--nexus-neon, #00FF99);
}

.header-info h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #FFFFFF;
    margin: 0;
}

.header-info .subtitle {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    padding: 6px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #FFFFFF;
}

.sheet-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
}

.chat-thread {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding-bottom: 2rem;
}

.welcome-container {
    text-align: center;
    padding: 4rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.welcome-glow-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(0, 255, 153, 0.05);
    border: 1px solid rgba(0, 255, 153, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
    box-shadow: 0 0 20px rgba(0, 255, 153, 0.1);
}

.welcome-glow-icon ::deep i {
    color: var(--nexus-neon, #00FF99);
}

.welcome-container h4 {
    font-size: 1.1rem;
    font-weight: 550;
    color: #FFFFFF;
    margin-bottom: 0.5rem;
}

.welcome-container p {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.55);
    line-height: 1.5;
    max-width: 280px;
}

.message-row {
    display: flex;
    gap: 0.75rem;
    max-width: 88%;
}

.message-row.user-row {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-row.ai-row {
    align-self: flex-start;
}

.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-row .message-avatar {
    background-color: rgba(0, 255, 153, 0.1);
    border: 1px solid rgba(0, 255, 153, 0.2);
}

.message-avatar ::deep i {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
}

.user-row .message-avatar ::deep i {
    color: var(--nexus-neon, #00FF99);
}

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: 14px;
    position: relative;
}

.user-bubble {
    background-color: rgba(0, 255, 153, 0.08);
    border: 1px solid rgba(0, 255, 153, 0.2);
    border-top-right-radius: 2px;
}

.ai-bubble {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-top-left-radius: 2px;
}

.message-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
    gap: 1rem;
}

.sender-name {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.user-bubble .sender-name {
    color: var(--nexus-neon, #00FF99);
}

.ai-bubble .sender-name {
    color: rgba(255, 255, 255, 0.7);
}

.message-time {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.4);
}

.message-text {
    font-size: 0.85rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.9);
}

.message-text strong {
    color: #FFFFFF;
}

.nexus-mobile-citation {
    background-color: rgba(0, 240, 255, 0.15);
    border: 1px solid rgba(0, 240, 255, 0.3);
    color: #00F0FF;
    border-radius: 4px;
    padding: 1px 4px;
    font-size: 0.75rem;
    font-weight: bold;
    cursor: pointer;
    margin-left: 2px;
    display: inline-block;
}

.nexus-mobile-code-block {
    background-color: rgba(0, 0, 0, 0.4);
    border-left: 3px solid var(--nexus-neon, #00FF99);
    padding: 0.75rem;
    border-radius: 6px;
    margin: 0.5rem 0;
    overflow-x: auto;
    font-family: monospace;
    font-size: 0.75rem;
}

.nexus-mobile-inline-code {
    background-color: rgba(255, 255, 255, 0.08);
    color: #FF7B72;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.75rem;
}

/* Typing indicator */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.loading-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin-left: 8px;
    vertical-align: middle;
}

.sheet-footer {
    padding: 0.75rem 1rem 1.5rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background-color: rgba(10, 10, 10, 0.5);
}

.scope-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 0.5rem;
}

.scope-indicator ::deep i {
    color: rgba(255, 255, 255, 0.4);
}

.input-container {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.nexus-mobile-input {
    flex: 1;
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.65rem 0.9rem;
    font-size: 0.85rem;
    color: #FFFFFF;
    outline: none;
    transition: all 0.25s ease;
}

.nexus-mobile-input:focus {
    border-color: rgba(0, 255, 153, 0.4);
    background-color: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 8px rgba(0, 255, 153, 0.15);
}

.send-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, #00FF99 0%, #00F0FF 100%);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0b0c10;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(0, 255, 153, 0.2);
    flex-shrink: 0;
}

.send-btn.disabled {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.3);
    box-shadow: none;
    cursor: not-allowed;
}

.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0,0,0,0.1);
    border-top: 2px solid #000000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Citation Modal Overlay & Glassmorphic Card */
.citation-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: fadeIn 0.25s ease-out;
}

.citation-modal {
    width: 100%;
    max-width: 320px;
    background: rgba(20, 20, 20, 0.85);
    border: 1px solid rgba(0, 240, 255, 0.25);
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.15);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.citation-modal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.citation-modal .book-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #FFFFFF;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.citation-modal .book-title ::deep i {
    color: #00F0FF;
}

.citation-modal .close-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.citation-modal .modal-body {
    padding: 1rem;
    font-size: 0.8rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.citation-modal .citation-author,
.citation-modal .citation-page {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin: 0;
}

.citation-modal .citation-author strong,
.citation-modal .citation-page strong {
    color: rgba(255, 255, 255, 0.75);
}

.citation-modal .citation-snippet {
    font-style: italic;
    background: rgba(0, 240, 255, 0.04);
    border-left: 2px solid #00F0FF;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.9);
    margin: 0.25rem 0 0 0;
}

.citation-modal .modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.citation-modal .btn-nexus {
    font-size: 0.8rem;
    padding: 0.4rem 1rem;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.2) 0%, rgba(0, 255, 153, 0.2) 100%);
    border: 1px solid rgba(0, 240, 255, 0.4);
    color: #FFFFFF;
    font-weight: 550;
    cursor: pointer;
    transition: all 0.2s ease;
}

.citation-modal .btn-nexus:hover {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.35) 0%, rgba(0, 255, 153, 0.35) 100%);
    border-color: rgba(0, 240, 255, 0.6);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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