/** ==========================================================================
    Cortexa AI — Styles
    ========================================================================== **/
 
    
/* ==========================================================================
   SECTION 1. CORE UI CSS CUSTOM PROPERTIES (DESIGN TOKENS)
   ========================================================================== */

:root {
    --font-stack: "Google Sans", -apple-system, BlinkMacSystemFont, sans-serif;
    
    /* Safe Area Environment Variables */
    --sat: env(safe-area-inset-top, 0px);
    --sab: env(safe-area-inset-bottom, 0px);
    --sal: env(safe-area-inset-left, 0px);
    --sar: env(safe-area-inset-right, 0px);
    
    /* Animation & Transitions */
    --transition-smooth: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    
    /* Brand Gradients & Colors */
    --gemini-gradient: linear-gradient(74deg, #4285f4 0%, #9b51e0 30%, #ea4335 65%, #fbbc04 100%);
    --accent-blue: #4285f4;
    --clinical-alert: #f28b82;
    --clinical-warning: #fbbc04;
    --clinical-success: #34a853;
}

.theme-dark {
    color-scheme: dark;
    --bg-main: #121214;
    --bg-sidebar: #18191d;
    --bg-surface: #202228;
    --bg-input: #18191d;
    --bg-hover: #2b2e37;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.09);
    --shadow-alpha: rgba(0, 0, 0, 0.45);
    --bubble-user-bg: #202228;
    --pinned-accent: #ffffff;
    --glass-bg: rgba(28, 30, 36, 0.85);
    --glass-border: rgba(255, 255, 255, 0.12);
}

.theme-light {
    color-scheme: light;
    --bg-main: #f1f5f9;
    --bg-sidebar: #e2e8f0;
    --bg-surface: rgba(255, 255, 255, 0.88);
    --bg-input: #ffffff;
    --bg-hover: #cbd5e1;
    --text-primary: #090d16;
    --text-secondary: #475569;
    --border-color: rgba(15, 23, 42, 0.08);
    --shadow-alpha: rgba(15, 23, 42, 0.08);
    --bubble-user-bg: #e2e8f0;
    --pinned-accent: #090d16;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(15, 23, 42, 0.07);
}

/* ==========================================================================
   SECTION 2: BASE NORMALIZATION & RENDER TOKENS (Includes PWA & WebKit Engines)
   ========================================================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base Viewport & WebKit Stability Enhancements */
html, body {
    font-family: var(--font-stack);
    width: 100%; 
    height: 100vh; 
    height: 100dvh; 
    display: flex; 
    overflow: hidden;
    background-color: var(--bg-main);
    
    /* Safely prevents iOS page-swiping without lobotomizing your horizontal tab scrolling */
    overscroll-behavior-x: none; 
    
    /* PWA Typography & Rendering Optimization */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%; 
    -webkit-touch-callout: none;
}

/* Global Interactive WebKit Fixes (Eliminates Tap Delays & Ghost Highlights) */
button, a, [role="button"] {
    -webkit-tap-highlight-color: transparent; 
    touch-action: manipulation;               
}

/* ==========================================================================
   SECTION 3: BARE-METAL INPUT PERFORMANCE (ZERO LAG, NO STROKES)
   ========================================================================== */
input, textarea, select {
    /* Kill the 300ms tap delay */
    touch-action: manipulation;
    
    /* Eliminate mobile OS ghost highlights */
    -webkit-tap-highlight-color: transparent;
    
    /* Allow native text selection */
    -webkit-user-select: auto !important;
    user-select: auto !important;
    font-family: inherit;
    
    /* Completely disable browser outlines and default shadows */
    outline: none !important;
    box-shadow: none !important;
    
    /* Zero transitions. Instant state changes prevent GPU frame drops when the keyboard slides up. */
    transition: none !important; 
}

/* Instant focus state: NO blue stroke, NO shadow, just a clean border color change */
input:focus, textarea:focus, select:focus {
    border-color: var(--accent-blue) !important;
    box-shadow: none !important; 
    outline: none !important;
}

/* Force all browser-native form elements to inherit custom font */
button, optgroup, option {
    font-family: inherit;
}

/* Primary Application Wrapper */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
    background-color: var(--bg-main);
    overflow: hidden;
}

/* Global Utility States */
.hidden {
    display: none !important;
}

/* ==========================================================================
   SECTION 4: DESKTOP SIDEBAR SHEET CONFIGURATION
   ========================================================================== */

/* --------------------------------------------------
   A. Primary Sidebar Wrapper
   -------------------------------------------------- */
.sidebar {
    width: 268px;
    background-color: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 100;
    
    /* Hardware-Accelerated Bounce Animation for Desktop Expand/Collapse */
    transition: width 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.25), transform 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.25);
    
    padding-top: var(--sat);
    padding-bottom: var(--sab);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
}

.sidebar::-webkit-scrollbar {
    display: none;
}

.sidebar.collapsed {
    width: 68px;
}

/* --------------------------------------------------
   B. Brand Header & Logo
   -------------------------------------------------- */
.sidebar-brand-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px 24px;
    height: 64px;
    overflow: hidden;
    white-space: nowrap;
    transition: padding 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.25);
}

.sidebar.collapsed .sidebar-brand-header {
    padding: 12px 0;
    justify-content: center;
}

.cortexa-sidebar-brand {
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.3px;
    display: inline-block;
    cursor: pointer;
    background: var(--gemini-gradient);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    animation: gemini-shimmer 6s ease infinite;
    white-space: nowrap;
    /* Sync the logo disappearance with the bounce */
    transition: opacity 0.3s ease, width 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.25);
}

.sidebar.collapsed .cortexa-sidebar-brand {
    opacity: 0;
    visibility: hidden;
    width: 0;
}

/* --------------------------------------------------
   C. Top Header & Action Buttons
   -------------------------------------------------- */
.sidebar-header {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-bottom: 1px solid var(--border-color);
}

/* --------------------------------------------------
   D. Scrollable Content Zone
   -------------------------------------------------- */
.sidebar-scroll-zone {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 12px;
    margin-top: 12px;
}

/* --------------------------------------------------
   E. Sidebar Footer
   -------------------------------------------------- */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Base Desktop Settings for Smart Footer (Moved from Step 1) */
.footer-nav-items {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 4px;
}

.footer-separator-line, 
.footer-expander-trigger {
    display: none;
}

/* --------------------------------------------------
   F. Collapsed State Component Overrides
   -------------------------------------------------- */
/* Bulletproof Sync: Text & Badge Sliding (Locks physics to the sidebar bounce) */
.btn-text, 
.history-item-text, 
.pinned-indicator-badge {
    display: inline-block;
    transition: max-width 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.25), opacity 0.3s ease;
    max-width: 200px;
    opacity: 1;
    overflow: hidden;
    vertical-align: middle;
    white-space: nowrap; /* CRITICAL: Prevents text from wrapping into 2 lines during the squish */
}

/* Recent Header (Delete/Collapse) Vertical Slide */
.section-controls-header {
    transition: max-height 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.25), opacity 0.3s ease, padding 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.25), margin 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.25);
    max-height: 50px;
    opacity: 1;
    overflow: hidden;
    white-space: nowrap;
}

/* Professional Collapsed States */
.sidebar.collapsed .btn-text, 
.sidebar.collapsed .history-item-text, 
.sidebar.collapsed .pinned-indicator-badge {
    max-width: 0;
    opacity: 0;
}

.sidebar.collapsed .section-controls-header {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
    pointer-events: none;
    border: none;
}

.sidebar.collapsed .item-action-trigger-btn {
    display: none !important;
}

/* Eliminating the gap and forcing perfect 44x44 squares with rounded corners */
.sidebar.collapsed .sidebar-action-pill-btn,
.sidebar.collapsed .footer-nav-btn,
.sidebar.collapsed .history-item-wrapper,
.sidebar.collapsed .history-item {
    gap: 0 !important;
    width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    justify-content: center !important;
    border-radius: 12px !important;
    margin: 0 auto !important;
}

/* ==========================================================================
   SECTION 5: DESKTOP SIDEBAR COMPRESSED TRANSITION STATES ENGINE
   ========================================================================== */

/* --------------------------------------------------
   A. Universal Sidebar Button Condensation
   -------------------------------------------------- */
/* Condense the buttons ONLY inside the sidebar to protect workspace buttons */
.sidebar .sidebar-action-pill-btn, 
.sidebar .footer-nav-btn, 
.sidebar .history-item { 
    display: flex !important;
    justify-content: flex-start !important;
    align-items: center !important;
    padding: 8px 10px !important; 
    gap: 10px !important;         
    min-height: 38px !important;  
    font-size: 0.85rem !important; 
    font-weight: 500 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    /* Sync width, gap, and padding to the bounce physics, while keeping hover snappy */
    transition: width 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.25), gap 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.25), padding 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.25), background-color 0.15s ease, border-color 0.15s ease !important; 
}

/* --------------------------------------------------
   B. Perfect Icon Alignment & Anti-Wobble
   -------------------------------------------------- */
/* Sidebar menu items locked to identical footprints */
.sidebar .sidebar-action-pill-btn svg, 
.sidebar .sidebar-action-pill-btn .material-symbols-rounded,
.sidebar .footer-nav-btn svg, 
.sidebar .footer-nav-btn .material-symbols-rounded,
.sidebar .history-item svg, 
.sidebar .history-item .material-symbols-rounded {
    flex-shrink: 0 !important;
    width: 18px !important;
    height: 18px !important;
    font-size: 19.75px !important; /* Optically matches the 18px stroke footprint of the SVG */
    line-height: 1 !important;     /* Locks vertical alignment so it doesn't wobble */
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* --------------------------------------------------
   C. Collapsed State Clean Clipping
   -------------------------------------------------- */
/* Ensure the sidebar clips the contents cleanly as it shrinks to 68px */
.sidebar.collapsed .sidebar-header,
.sidebar.collapsed .sidebar-scroll-zone,
.sidebar.collapsed .sidebar-footer {
    padding-left: 12px !important;
    padding-right: 12px !important;
}

/* ==========================================================================
   SECTION 6: INTERACTIVE REUSABLE SIDEBAR WIDGETS
   ========================================================================== */

/* --------------------------------------------------
   A. Base Icon & Pill Buttons
   -------------------------------------------------- */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-primary);
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    margin-bottom: 4px;
    flex-shrink: 0;
}

.icon-btn:hover { background-color: var(--bg-hover); }
.icon-btn:active { transform: scale(0.95); }
.icon-btn svg { flex-shrink: 0; transition: opacity 0.2s ease; }

.sidebar-action-pill-btn {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 10px 16px;
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.sidebar-action-pill-btn:hover {
    background-color: var(--bg-hover);
    border-color: transparent;
}

.sidebar-action-pill-btn svg {
    flex-shrink: 0;
    color: var(--text-secondary);
    transition: color 0.15s ease;
}

.sidebar-action-pill-btn:hover svg {
    color: var(--text-primary);
}

/* --------------------------------------------------
   B. History Section Headers
   -------------------------------------------------- */
.section-controls-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 4px;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.section-action-buttons {
    display: flex;
    align-items: center;
    gap: 2px;
}

.section-utility-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

.section-utility-btn span { font-size: 1.05rem; }
.section-utility-btn:hover { background-color: var(--bg-hover); }
.section-utility-btn.danger:hover { background-color: rgba(234, 67, 53, 0.15); color: #ea4335; }

/* --------------------------------------------------
   C. History List Items
   -------------------------------------------------- */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 2px; /* FIX: Restored native 2px gap to prevent button overlap */
    overflow: visible;
    flex-shrink: 0;
}

.history-list.list-collapsed {
    display: none;
}

.history-item-wrapper {
    display: flex;
    align-items: center;
    border-radius: 12px;
    position: relative;
}

.history-item-wrapper:hover, 
.history-item-wrapper.active {
    background-color: var(--bg-hover);
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 40px 10px 14px;
    border-radius: 20px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.88rem;
    text-align: left;
    cursor: pointer;
    width: 100%;
    overflow: hidden;
}

.history-item-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    color: var(--text-primary);
}

.item-action-trigger-btn {
    position: absolute;
    right: 2px;
    background: transparent !important;
    box-shadow: none !important;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease;
}

.history-item-wrapper:hover .item-action-trigger-btn { display: flex; }

/* Force action buttons to be visible on touchscreens since hover doesn't exist */
@media (hover: none) {
    .item-action-trigger-btn { 
        display: flex !important; 
        opacity: 0.8; 
    }
}
.item-action-trigger-btn:hover { color: var(--text-primary); border-radius: 9px; }

.pinned-indicator-badge {
    position: absolute;
    right: 36px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

.pinned-indicator-badge span { font-size: 0.95rem; }

/* --------------------------------------------------
   D. Footer Navigation Buttons
   -------------------------------------------------- */
.footer-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 10px 16px;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

.footer-nav-btn:hover { background-color: var(--bg-hover); }

/* ==========================================================================
   SECTION 7: MAIN WORKSPACE VIEWPORT LAYOUT ARCHITECTURE
   ========================================================================== */

/* --------------------------------------------------
   A. Core Viewport Structures
   -------------------------------------------------- */
.main-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
}

.nav-right {
    display: flex;
    gap: 8px;
    align-items: center;
    position: relative;
    pointer-events: auto;
}

.content-viewport {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    width: 100%;
    padding-top: calc(72px + var(--sat));
    padding-bottom: max(220px, calc(220px + var(--sab)));
    scroll-padding-top: calc(88px + var(--sat)); /* Prevents card header & patient button from tucking behind top bar */
    scroll-padding-bottom: max(160px, calc(160px + var(--sab))); /* Keeps card actions safely above bottom input deck */
    -webkit-overflow-scrolling: touch;
}

/* Ensure cards and their buttons always maintain their own clean hit-test layer */
.chat-row, 
.ai-message-wrapper, 
.clinical-card-container {
    position: relative;
    z-index: 1;
    pointer-events: auto !important;
}

.view-panel {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: calc(12px + var(--sat)) 16px calc(24px + var(--sab)) 16px;
    padding: 40px 24px 24px 24px;
    animation: panelTransition 0.25s ease-out both;
}

@media (min-width: 768px) {
    .view-panel {
        padding: 40px 24px 24px 24px;
    }
}

/* --------------------------------------------------
   B. Welcome Dashboard Layout
   -------------------------------------------------- */
.welcome-heading {
    font-size: 3.2rem;
    font-weight: 500;
    line-height: 1.15;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.gradient-text {
    display: inline-block;
    background: var(--gemini-gradient);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    text-shadow: none;
    animation: gemini-shimmer 6s ease infinite;
}

.sub-welcome {
    color: var(--text-secondary);
    font-size: 1.25rem;
    font-weight: 400;
}

/* --------------------------------------------------
   C. Global Keyframe Animations
   -------------------------------------------------- */
@keyframes panelTransition {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* ==========================================================================
   SECTION 8: MENU TOGGLE BUTTONS (DESKTOP & TOUCHSCREEN UNIFICATION)
   ========================================================================== */

/* Base Toggle States */
.menu-toggle-btn {
    display: none;
    background: transparent !important;
    box-shadow: none !important;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 12px;
}

.cortexa-dynamic-trigger {
    position: relative;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: transparent !important;
    box-shadow: none !important;
    border: none;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Grouped Interactive Animations */
.menu-toggle-btn:hover,
.cortexa-dynamic-trigger:hover {
    background-color: transparent !important;
    transform: translateY(-1px);
}

.menu-toggle-btn:active,
.cortexa-dynamic-trigger:active {
    transform: translateY(1px) scale(0.96);
}


/* ==========================================================================
   SECTION 9: LIBRARY TAB & SMART HIERARCHY ENGINE
   ========================================================================== */

/* --------------------------------------------------
   A. Scrollable Tab Navigation
   -------------------------------------------------- */
.library-tabs-nav {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}

.library-tabs-nav::-webkit-scrollbar {
    display: none;
}

.lib-tab-btn {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    white-space: nowrap;
    padding: 8px 16px;
    border-radius: 20px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-smooth);
}

.lib-tab-btn:hover {
    background: var(--bg-hover);
}

/* --------------------------------------------------
   B. Advanced System Hierarchies
   -------------------------------------------------- */
.library-system-header {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 32px 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Grouped Icon Resets (Fixes double-spacing bug) */
.library-system-header .material-symbols-rounded,
.lib-tab-btn .material-symbols-rounded {
    opacity: 0.6;
    background: transparent !important;
}

.library-maincat-header {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent-blue);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 20px 0 10px 0;
}

.accordion-header-text-group .node-subcat {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

/* ==========================================================================
   SECTION 10: GRID LAYOUTS & INTERACTIVE COMPONENT BLOCKS
   ========================================================================== */

/* --------------------------------------------------
   A. Global Workspace Containers
   -------------------------------------------------- */
.workspace-internal-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.workspace-header-block h2 {
    font-size: 1.65rem;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.workspace-header-block p {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

/* --------------------------------------------------
   B. Suggestion Grids (Zero State)
   -------------------------------------------------- */
.suggestions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.suggestion-card {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    min-height: 130px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: background-color var(--transition-smooth), transform var(--transition-smooth);
}

.suggestion-card:hover {
    background-color: var(--bg-hover);
    transform: translateY(-2px);
}

.card-header-icon-row {
    display: flex;
    margin-bottom: 12px;
}

.clinical-card-icon {
    color: var(--accent-blue);
    font-size: 1.6rem !important;
}

.card-text {
    font-size: 0.94rem;
    color: var(--text-primary);
    line-height: 1.45;
    font-weight: 500;
}

/* --------------------------------------------------
   C. Universal Accordion Nodes (Moved from Sec 9)
   -------------------------------------------------- */
.accordion-element-node {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 8px;
}

.accordion-element-node.expanded {
    border-color: var(--accent-blue);
}

.accordion-header-trigger {
    width: 100%;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    color: var(--text-primary);
}

.accordion-header-text-group .node-title {
    font-size: 1rem;
    font-weight: 500;
    word-break: break-word;
    white-space: normal;
    line-height: 1.4;
}

.accordion-header-trigger .chevron-icon {
    color: var(--text-secondary);
    transition: transform var(--transition-smooth);
}

.accordion-element-node.expanded .chevron-icon {
    transform: rotate(180deg);
}

.accordion-body-expansion-layer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    background-color: transparent;
}

.accordion-element-node.expanded > .accordion-body-expansion-layer,
.accordion-element-node.expanded .accordion-body-expansion-layer {
    max-height: none !important;
    overflow: visible !important;
    display: block !important;
}

.accordion-expansion-content {
    padding: 16px 20px;
    font-size: 0.94rem;
    line-height: 1.6;
    color: var(--text-primary);
    border-top: 1px solid var(--border-color);
    overflow: visible !important;
}

/* Clean reset for nested clinical cards inside accordions */
.accordion-expansion-content .clinical-card-container {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    width: 100% !important;
}

.accordion-expansion-content .clinical-card-header {
    padding-top: 0 !important;
}

/* --------------------------------------------------
   D. Clinical Knowledge Cards (Moved from Sec 9)
   -------------------------------------------------- */
.clinical-card-container {
    background-color: var(--glass-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 24px;
    margin: 16px 0 0 0;
    box-shadow: 0 10px 30px var(--shadow-alpha);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
}

.clinical-card-container:hover {
    box-shadow: 0 14px 40px var(--shadow-alpha);
}

.inter-alert-card {
    margin-bottom: 16px;
    width: 100%;
    box-sizing: border-box;
    background: var(--glass-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--glass-border);
    padding: 18px 20px;
    border-radius: 16px;
    box-shadow: 0 10px 30px var(--shadow-alpha);
    animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.top-nav-bar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 80;
    background: linear-gradient(to bottom, var(--bg-main) 65%, transparent 100%);
    height: calc(80px + var(--sat));
    padding: calc(var(--sat) + 8px) calc(16px + var(--sar)) 16px calc(16px + var(--sal));
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    border-bottom: none;
    pointer-events: none;
    box-sizing: border-box;
}

.clinical-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    min-width: 0;
    flex-wrap: wrap;
    gap: 12px;
}

.clinical-card-title {
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
    flex: 1 1 auto;
}

.clinical-card-title span:last-child {
    display: -webkit-box;
    -webkit-line-clamp: 2; 
    line-clamp: 2;
    -webkit-box-orient: vertical;
    box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
    min-width: 0;
    flex: 1;
    line-height: 1.3;
}

.clinical-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 12px;
    text-transform: uppercase;
    flex-shrink: 0;
    white-space: normal;
    text-align: left;
    line-height: 1.3;
    max-width: 100%;
    box-sizing: border-box;
}

.clinical-badge.normal { background-color: rgba(52, 168, 83, 0.15); color: var(--clinical-success); }
.clinical-badge.warning { background-color: rgba(251, 188, 4, 0.15); color: var(--clinical-warning); }
.clinical-badge.alert { background-color: rgba(234, 67, 53, 0.15); color: var(--clinical-alert); }

.clinical-card-source-footer {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.clinical-card-source-footer .material-symbols-rounded {
    font-size: 1.1rem;
    opacity: 0.8;
}

/* --------------------------------------------------
   E. Risk Matrix Options
   -------------------------------------------------- */
.risk-matrix-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1.3;
    color: var(--text-primary);
    padding: 4px;
    user-select: none;
    border-radius: 6px;
    box-sizing: border-box;
}

.risk-matrix-option input[type="checkbox"] {
    accent-color: #ea4335;
    width: 16px;
    height: 16px;
    margin-top: 2px;
    cursor: pointer;
    flex-shrink: 0;
}

/* ==========================================================================
   SECTION 11: UNIFIED SMART SEARCH BAR ENGINE
   ========================================================================== */

/* --------------------------------------------------
   A. Global Search Input Wrapper
   -------------------------------------------------- */
.workspace-search-bar-wrapper {
    display: flex;
    align-items: center;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0 16px;
    gap: 12px;
    min-height: 48px;
    height: auto;
    box-sizing: border-box;
    transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth);
}

.workspace-search-bar-wrapper:focus-within {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 1px var(--accent-blue) inset;
}

.workspace-search-bar-wrapper span {
    color: var(--text-secondary);
    font-size: 1.2rem;
    flex-shrink: 0;
}

.workspace-search-bar-wrapper input,
.workspace-search-bar-wrapper textarea {
    background: none;
    border: none;
    outline: none;
    width: 100%;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
}

.workspace-search-bar-wrapper input {
    height: 100%;
}

.workspace-search-bar-wrapper textarea {
    min-width: 0;
    height: auto;
    min-height: 24px;
    max-height: 130px;
    line-height: 1.4;
    resize: none;
    overflow-y: auto;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    white-space: pre-wrap;
    word-break: break-word;
    display: block;
    align-self: center;
}

/* --------------------------------------------------
   B. Search Results Grid & Output Rows
   -------------------------------------------------- */
.search-results-output-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-result-row-card {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 14px 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color var(--transition-smooth);
}

.search-result-row-card:hover {
    background-color: var(--bg-hover);
}

.src-meta-block {
    display: flex;
    align-items: center;
    gap: 14px;
}

.src-meta-block span {
    color: var(--text-secondary);
}

.src-title {
    font-size: 0.94rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* ==========================================================================
   SECTION 12: ADVANCED CLINICAL CONTENT SWITCHER ENGINE
   ========================================================================== */

/* --------------------------------------------------
   A. Content Switcher Core & Animations
   -------------------------------------------------- */
.clinical-content-switcher {
    width: 100% !important;
    position: relative;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    overflow: visible !important;
}

.clinical-content-switcher .card-short-view {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
}

.clinical-content-switcher .card-full-view {
    display: none;
    width: 100% !important;
}

.clinical-content-switcher.is-expanded .card-short-view {
    display: none !important;
}

.clinical-content-switcher.is-expanded .card-full-view {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    animation: expandFadeIn 0.25s ease-out forwards;
}

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

/* Toggle Buttons */
.content-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
    background: rgba(66, 133, 244, 0.08);
    color: var(--accent-blue);
    border: 1px solid rgba(66, 133, 244, 0.2);
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all var(--transition-smooth);
    width: 100%;
}

.content-toggle-btn:hover {
    background: rgba(66, 133, 244, 0.15);
    border-color: rgba(66, 133, 244, 0.3);
}

.content-toggle-btn .material-symbols-rounded {
    font-size: 1.1rem !important;
}

.content-toggle-btn.collapse-btn {
    background: var(--bg-surface);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.content-toggle-btn.collapse-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* --------------------------------------------------
   B. Clinical Typography & Data Rows
   -------------------------------------------------- */
.clinical-data-section {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--border-color);
}

.clinical-data-section:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

.clinical-section-title {
    font-weight: 700;
    color: var(--accent-blue);
    font-size: 0.75rem;
    text-transform: uppercase;
    display: block;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.clinical-section-body {
    font-size: 0.86rem;
    line-height: 1.55;
    color: var(--text-primary);
}

.clinical-section-body.highlight-blue {
    color: var(--accent-blue);
    font-weight: 600;
}

.clinical-data-row {
    margin-bottom: 12px;
}

.clinical-data-label {
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 2px;
}

.clinical-data-value {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    display: block;
}

.clinical-data-value.highlight-blue {
    color: var(--accent-blue);
}

.clinical-data-snippet {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 10px;
}

ul.clinical-list {
    list-style: none !important;
    list-style-type: none !important;
    padding: 0 !important;
    margin: 6px 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

li.clinical-list-item {
    list-style: none !important;
    list-style-type: none !important;
    font-size: 0.88rem !important;
    line-height: 1.5 !important;
    color: var(--text-primary) !important;
    position: relative !important;
    padding-left: 16px !important;
    margin: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    word-break: break-word !important;
}

li.clinical-list-item::before {
    content: "•" !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    color: var(--accent-blue) !important;
    font-weight: 700 !important;
    font-size: 1.15rem !important;
    line-height: 1.35 !important;
}

/* --------------------------------------------------
   C. Inline Calculator Forms
   -------------------------------------------------- */
.inline-calc-form {
    background-color: var(--bg-surface);
    border-radius: 12px;
    padding: 16px;
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.inline-form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.inline-form-row label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.inline-form-row input, 
.inline-form-row select {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 0.92rem;
    outline: none;
    transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth);
}

/* FIX: Added native CSS focus states */
.inline-form-row input:focus, 
.inline-form-row select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 1px var(--accent-blue) inset;
}

.inline-calc-submit-btn {
    align-self: flex-end;
    background-color: var(--accent-blue);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition-smooth);
}

.inline-calc-submit-btn:hover {
    opacity: 0.9;
}

/* --------------------------------------------------
   D. Patient Metrics & Risk Engine Modules
   -------------------------------------------------- */
.patient-metrics-engine-block {
    background-color: rgba(66, 133, 244, 0.05);
    border: 1px dashed var(--accent-blue);
    padding: 14px;
    border-radius: 12px;
    margin-bottom: 16px;
    display: grid;
    grid-template-columns: 1fr; /* FIX: Removed !important */
    gap: 10px;
}

.patient-metrics-engine-block .inline-form-row {
    margin: 0;
}

.patient-metrics-engine-block label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-blue);
    text-transform: uppercase;
    margin-bottom: 4px;
    display: block;
}

.patient-metrics-engine-block select, 
.patient-metrics-engine-block input {
    box-sizing: border-box;
    height: 34px;
    padding: 6px 10px;
    font-size: 0.85rem;
    line-height: 1.2;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 100%;
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth);
}

/* FIX: Added native CSS focus states */
.patient-metrics-engine-block select:focus, 
.patient-metrics-engine-block input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 1px var(--accent-blue) inset;
}

/* Risk Engine Dropdown Systems */
.risk-engine-dropdown-container {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 16px;
    overflow: hidden;
}

.risk-engine-summary-header {
    background-color: var(--bg-hover);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    flex-wrap: nowrap;
    min-width: 0;
}

.risk-engine-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: none;
    letter-spacing: 0;
    min-width: 0;
    flex: 1 1 auto;
    margin-right: 8px;
    overflow: hidden;
}

.risk-engine-title-group span:last-child {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    word-break: keep-all;
    min-width: 0;
}

.risk-active-counter-badge {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    transition: all var(--transition-smooth);
    flex-shrink: 0;
    white-space: nowrap;
    margin-left: auto;
    text-align: center;
    box-sizing: border-box;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    line-height: 1;
    height: 24px;
}

.risk-active-counter-badge.zero {
    opacity: 0.6;
}

.risk-engine-dropdown-content {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background-color: rgba(0, 0, 0, 0.01);
}

/* System-Based Categorization inside Risk Engine */
.risk-category-group {
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--bg-surface);
}

.risk-category-header {
    padding: 10px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.risk-category-content {
    display: none;
    padding: 10px;
    background-color: var(--bg-main);
    border-top: 1px solid var(--border-color);
}

.risk-cards-grid {
    display: grid;
    grid-template-columns: 1fr; /* FIX: Removed !important */
    gap: 6px;
}
/* ==========================================================================
   SECTION 13: CHAT MESSAGE STREAMS & DATA INPUT NODES
   ========================================================================== */

/* --------------------------------------------------
   A. Message Stream Layout
   -------------------------------------------------- */
.message-stream {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.chat-row {
    display: flex;
    align-items: flex-start;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    box-sizing: border-box;
}

.chat-row.user-row {
    display: flex !important;
    justify-content: flex-end !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 0 !important;
    margin: 0 !important;
}

.chat-row:not(.user-row) {
    width: 100% !important;
    max-width: 100% !important;
    justify-content: flex-start;
}

.ai-message-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

/* --------------------------------------------------
   B. Avatar & Bubble Styling
   -------------------------------------------------- */
.avatar-container {
    display: none !important;
}

.bubble-content {
    font-size: 0.98rem;
    line-height: 1.62;
    color: var(--text-primary);
    word-break: break-word;
    box-sizing: border-box;
}

.chat-row:not(.user-row) .bubble-content {
    width: 100% !important;
    max-width: 100% !important;
}

.chat-row.user-row .bubble-content {
    background-color: var(--bubble-user-bg);
    padding: 12px 18px;
    border-radius: 14px;
    width: fit-content !important;
    max-width: 100% !important;
    line-height: 1.5;
    box-sizing: border-box;
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* --------------------------------------------------
   C. AI Typing Indicator (Moved from Sec 12)
   -------------------------------------------------- */
.typing-pulse-container {
    display: flex;
    gap: 6px;
    align-items: center;
    height: 24px;
    padding-left: 4px;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    background-color: var(--text-primary);
    border-radius: 50%;
    animation: smoothWave 1.2s infinite ease-in-out;
}

/* Precise positive delays create a perfect left-to-right sequence */
.pulse-dot:nth-child(1) { animation-delay: 0s; }
.pulse-dot:nth-child(2) { animation-delay: 0.15s; }
.pulse-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes smoothWave {
    0%, 100% { transform: translateY(2px); opacity: 0.3; }
    50% { transform: translateY(-4px); opacity: 1; }
}

/* --------------------------------------------------
   D. Global Input Deck (Footer)
   -------------------------------------------------- */
.input-panel-container {
    width: 100%;
    margin: 0;
    padding: 40px calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal));
    background: linear-gradient(to top, var(--bg-main) 65%, transparent 100%);
    border-top: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none !important; /* Lets clicks pass through the gradient & empty padding to cards underneath */
}

/* Ensure only interactive input elements receive clicks */
.input-panel-container .input-wrapper-matrix,
.input-panel-container .input-disclaimer-text,
.input-panel-container .ctx-deck-attach-menu {
    pointer-events: auto !important;
}

.input-actions-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 38px;
}

.input-action-btn, 
.submit-prompt-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

.input-action-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.submit-prompt-btn:disabled {
    opacity: 0.25;
    cursor: default;
}

.submit-prompt-btn:not(:disabled) {
    color: var(--accent-blue);
}

.input-disclaimer-text {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 12px;
    line-height: 1.35;
    pointer-events: auto;
}

/* Base Disclaimer Rule (Hidden on Desktop by default) */
.chat-stream-disclaimer {
    display: none !important;
}


/* ==========================================================================
   SECTION 14: SYSTEM CONTEXT MENUS & MODAL CORE WINDOWS
   ========================================================================== */

/* --------------------------------------------------
   A. Context Menu Engine
   -------------------------------------------------- */
@keyframes contextMenuPop {
    0% {
        opacity: 0;
        transform: translateY(-8px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#chatContextMenu, 
.context-menu-floating {
    position: fixed;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 12px 32px var(--shadow-alpha);
    padding: 6px 0;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    z-index: 15000 !important;
    transform-origin: top left;
    will-change: transform, opacity;
}

#topNavOptionsMenu:not(.hidden) {
    animation: contextMenuPop 0.18s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transform-origin: top right;
    will-change: transform, opacity;
}

.context-action-item {
    background: none;
    border: none;
    padding: 9px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-size: 0.86rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background-color var(--transition-smooth);
}

.context-action-item span:first-child {
    font-size: 1.1rem !important;
    color: var(--text-secondary);
}

.context-action-item:hover {
    background-color: var(--bg-hover);
}

.context-action-item.danger {
    color: #ea4335;
}

.context-action-item.danger span {
    color: #ea4335 !important;
}

.context-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 4px 0;
}

/* --------------------------------------------------
   B. Modal Core Positioning
   -------------------------------------------------- */
.elegant-modal-card {
    margin-top: var(--sat) !important;
    margin-bottom: var(--sab) !important;
    max-height: calc(100dvh - var(--sat) - var(--sab) - 40px) !important;
}

/* --------------------------------------------------
   C. Global Settings Action Buttons 
   (Note: Architecturally belongs in Sec 4, placed here for continuity)
   -------------------------------------------------- */
.danger-action-pill-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-sizing: border-box;
    width: 100%;
    height: 35px;
    padding: 12px;
    background-color: rgba(168, 52, 52, 0.1);
    color: #a83434;
    border: 1px solid rgba(168, 52, 52, 0.2);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.8rem;
    transition: background-color var(--transition-smooth), border-color var(--transition-smooth);
}

.danger-action-pill-btn:hover {
    background-color: rgba(168, 52, 52, 0.18);
    border-color: rgba(168, 52, 52, 0.4);
}

.create-groq-api-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-sizing: border-box;
    width: 100%;
    height: 35px;
    padding: 12px;
    background-color: rgba(52, 168, 83, 0.1);
    color: #34a853;
    border: 1px solid rgba(52, 168, 83, 0.2);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.8rem;
    transition: background-color var(--transition-smooth), border-color var(--transition-smooth);
}

.create-groq-api-btn:hover {
    background-color: rgba(83, 234, 53, 0.18);
    border-color: rgba(52, 168, 83, 0.4);
}

/* ==========================================================================
   SECTION 15: MESSAGE ACTIONS & EDIT ENGINE UI (Moved up for Cascade Priority)
   ========================================================================== */

/* --------------------------------------------------
   A. Message Action Buttons
   -------------------------------------------------- */
.user-message-wrapper {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

.message-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition-smooth);
    margin-top: 6px;
    padding-right: 8px;
}

@media (hover: none) and (pointer: coarse) {
    .message-actions {
        opacity: 1 !important;
    }
}

.chat-row:hover .message-actions {
    opacity: 1;
}

.msg-action-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    width: auto;
    height: auto;
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.msg-action-btn:hover {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.msg-action-btn.action-success {
    color: var(--text-primary);
}

.msg-action-btn span {
    font-size: 1.1rem !important;
}

/* --------------------------------------------------
   B. Message Edit Mode UI
   -------------------------------------------------- */
.edit-mode-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    animation: panelTransition 0.2s ease-out both;
}

.edit-textarea {
    background: transparent;
    border: none;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.5;
    resize: none;
    min-height: 24px;
    height: auto;
    outline: none;
    width: 100%;
    box-sizing: border-box;
    display: block;
    field-sizing: content;
}

.edit-textarea:focus {
    border-color: var(--accent-blue);
}

.edit-actions-row {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 12px;
}

.edit-btn {
    padding: 8px 20px;
    border-radius: 24px;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--transition-smooth), opacity var(--transition-smooth);
    border: none;
}

.edit-btn.cancel {
    background: transparent;
    color: var(--accent-blue);
}

.edit-btn.cancel:hover {
    background-color: rgba(66, 133, 244, 0.08);
}

.edit-btn.update {
    background: var(--accent-blue);
    color: #ffffff;
}

.edit-btn.update:hover {
    opacity: 0.9;
}

.edited-tag {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-left: 6px;
    user-select: none;
}


/* ==========================================================================
   SECTION 16: GLOBAL OVERLAYS & MASKS (Extracted from Message Actions)
   ========================================================================== */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background-color: transparent;
    backdrop-filter: blur(6px);
    z-index: 199;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-smooth), visibility var(--transition-smooth);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Unify all static pop-up masks (like the Settings Menu) */
.elegant-modal-mask {
    background-color: transparent !important; /* Removes the dark shadow */
    backdrop-filter: blur(6px) !important;    /* Applies the pure glass blur */
}

/* ==========================================================================
   SECTION 17: NUCLEAR RESPONSIVENESS RESTRUCTURING OVERRIDE
   ========================================================================== */
@media (max-width: 767px) {

    /* --------------------------------------------------
       A. Mobile Top Navigation
       -------------------------------------------------- */
    .menu-toggle-btn {
        display: flex !important;
        visibility: visible !important;
        border-radius: 12px !important;
    }

    .welcome-heading { font-size: 2.2rem; }
    .sub-welcome { font-size: 1.05rem; }

    /* --------------------------------------------------
       B. Phone 3D Displacement, Blur & Boundary Bounce Engine
       -------------------------------------------------- */

    /* Main Content: Displacement Shift, Zoom Out, Fade & Blur */
    .main-workspace {
        transition: transform 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.25), 
                    opacity 0.45s ease, 
                    filter 0.45s ease,
                    border-radius 0.45s ease !important;
        transform-origin: left center !important;
        background-color: var(--bg-main);
        will-change: transform, opacity, filter;
    }

    /* Open State: Scaled down, shifted right, blurred & faded */
    body.sidebar-active .main-workspace {
        transform: translateX(260px) scale(0.88) !important;
        opacity: 0.6 !important;
        filter: blur(6px) !important;
        border-radius: 24px !important;
        pointer-events: none !important; 
    }

    /* Phone Sidebar Drawer Engine */
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        height: 100dvh !important;
        display: flex !important;
        flex-direction: column !important;
        background-color: var(--bg-main) !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        z-index: 10000 !important;
        
        /* Hidden Off-Screen */
        opacity: 0 !important;
        visibility: hidden !important;
        transform: translateX(-100%) !important;
        transform-origin: left center !important;
        pointer-events: none !important;
        
        /* Calibrated Spring Bounce (Stops at right border and bounces back inward) */
        transition: transform 0.45s cubic-bezier(0.175, 0.885, 0.28, 1.15), 
                    opacity 0.4s ease, 
                    visibility 0.45s !important;
        
        padding-bottom: 0 !important;
        padding-top: var(--sat) !important;
        
        overflow-y: auto !important; 
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important; 
    }

    .sidebar::-webkit-scrollbar {
        display: none !important;
    }

    /* THE VISIBILITY RULE: Pulls the sidebar onto the screen */
    .sidebar.mobile-open,
    body.sidebar-active #sidebar,
    body.sidebar-active .sidebar.collapsed {
        opacity: 1 !important;
        visibility: visible !important;
        transform: translateX(0) !important;
        pointer-events: auto !important;
    }

    /* Secondary Failsafe for Desktop-to-Mobile Resize */
    .sidebar.collapsed {
        opacity: 0 !important;
        visibility: hidden !important;
        transform: translateX(-100%) !important;
    }

    /* Sidebar Internal Components Mobile Setup */
    .sidebar-brand-header {
        flex-shrink: 0 !important;
        background-color: var(--bg-main) !important;
        z-index: 50 !important;
        border-bottom: 1px solid var(--border-color) !important;
        margin: 0 !important;
        padding: 10px 16px !important;
        display: flex !important;
        align-items: center !important;
        height: auto !important;
    }

    .sidebar-header {
        flex-shrink: 0 !important;
        background-color: transparent !important;
        z-index: 10 !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .sidebar-scroll-zone {
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        min-height: 0 !important;
        height: auto !important;
        padding-bottom: 12px !important;
        padding-top: 12px !important;
        -webkit-overflow-scrolling: touch !important;
        display: block !important;
    }

    .sidebar.collapsed .sidebar-scroll-zone {
        padding: 0 12px !important;
        display: block !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* --------------------------------------------------
       C. Sidebar Footer Mobile Rigging
       -------------------------------------------------- */
    .sidebar-footer {
        flex-shrink: 0 !important;
        position: relative !important;
        bottom: 0 !important;
        background-color: var(--bg-main) !important;
        z-index: 50 !important;
        border-top: 1px solid var(--border-color) !important;
        margin: 0 !important;
        padding: 8px 12px calc(8px + var(--sab)) 12px !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        transition: background-color 0.2s, padding 0.25s !important;
    }

    .sidebar.collapsed .sidebar-footer {
        padding: 12px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .sidebar-footer.is-expanded {
        flex-direction: column !important;
        padding: 12px 12px calc(12px + var(--sab)) 12px !important;
    }

    .footer-nav-items {
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
        flex: 1 !important;
        width: 100% !important;
    }

    .sidebar-footer.is-expanded .footer-nav-items {
        flex-direction: column !important;
        gap: 2px !important;
    }

    .sidebar-footer:not(.is-expanded) .footer-nav-items {
        justify-content: space-evenly !important;
    }

    .sidebar-footer:not(.is-expanded) .footer-nav-btn {
        flex: 0 0 44px !important;
        width: 44px !important;
        height: 44px !important;
        min-height: 44px !important;
        padding: 0 !important;
        justify-content: center !important;
        border-radius: 12px !important;
        margin: 0 !important;
    }

    .sidebar-footer:not(.is-expanded) .btn-text {
        display: none !important;
    }

    /* Footer Expansion UI */
    .footer-separator-line {
        display: block !important;
        width: 1px !important;
        height: 24px !important;
        background-color: var(--border-color) !important;
        margin: 0 10px 0 12px !important;
    }

    .sidebar-footer.is-expanded .footer-separator-line {
        display: none !important;
    }

    .footer-expander-trigger {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 36px !important;
        height: 36px !important;
        background: transparent !important;
        border: none !important;
        border-radius: 8px !important;
        cursor: pointer !important;
        flex-shrink: 0 !important;
        transition: background 0.2s !important;
    }

    .footer-expander-trigger:hover {
        background: var(--bg-hover) !important;
    }

    .sidebar-footer.is-expanded .footer-expander-trigger {
        width: 100% !important;
        height: 28px !important;
        margin-top: 8px !important;
        border: 1px solid var(--border-color) !important;
        background: var(--bg-hover) !important;
    }

    .horizontal-dash {
        width: 18px !important;
        height: 3px !important;
        background-color: var(--text-secondary) !important;
        border-radius: 2px !important;
        transition: width 0.3s, opacity 0.3s, background-color 0.2s !important;
    }

    .footer-expander-trigger:hover .horizontal-dash {
        background-color: var(--text-primary) !important;
    }

    .sidebar-footer.is-expanded .horizontal-dash {
        width: 32px !important;
        height: 4px !important;
        opacity: 0.4 !important;
    }

    /* --------------------------------------------------
       D. Sidebar Content Edge Cases (Mobile)
       -------------------------------------------------- */
    .sidebar .cortexa-dynamic-trigger .fluid-matrix-container {
        -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="3" stroke-linecap="round"><line x1="6" y1="6" x2="18" y2="18"></line><line x1="6" y1="18" x2="18" y2="6"></line></svg>') !important;
        mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="3" stroke-linecap="round"><line x1="6" y1="6" x2="18" y2="18"></line><line x1="6" y1="18" x2="18" y2="6"></line></svg>') !important;
    }

    .sidebar.collapsed .cortexa-sidebar-brand {
        display: block !important;
        opacity: 1 !important;
        width: auto !important;
        visibility: visible !important;
    }

    .sidebar.collapsed .btn-text,
    .sidebar.collapsed .section-controls-header,
    .sidebar.collapsed .history-item-text,
    .sidebar.collapsed .item-action-trigger-btn,
    .sidebar.collapsed .pinned-indicator-badge {
        display: flex !important;
    }

    .sidebar.collapsed .history-item-wrapper,
    .sidebar.collapsed .history-item {
        width: auto !important;
        border-radius: 20px !important;
        justify-content: flex-start !important;
    }

    .sidebar.collapsed .footer-nav-btn {
        width: auto !important;
        border-radius: 20px !important;
        justify-content: flex-start !important;
    }

    .sidebar.collapsed .sidebar-action-pill-btn {
        width: 100% !important;
        border-radius: 24px !important;
        justify-content: flex-start !important;
        padding: 12px 16px !important;
    }

    .history-item-wrapper[data-pinned="false"] .item-action-trigger-btn {
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    /* --------------------------------------------------
       E. Viewport & Spacing Condensation (Edge-to-Edge)
       -------------------------------------------------- */
    .view-panel {
        padding: calc(12px + var(--sat)) 8px calc(24px + var(--sab)) 8px !important;
    }

    .workspace-header-block {
        margin-bottom: 16px !important;
        padding: 0 4px !important;
    }

    .workspace-header-block h2 {
        font-size: 1.35rem !important;
    }

    .workspace-header-block p {
        font-size: 0.85rem !important;
        line-height: 1.4 !important;
    }

    .suggestions-grid,
    .cdss-chip-grid,
    .risk-cards-grid,
    .dynamic-calc-grid {
        grid-template-columns: 1fr !important;
        width: 100% !important;
    }

    /* --------------------------------------------------
       F. Clinical Knowledge Base & Accordion Compression
       -------------------------------------------------- */
    .clinical-card-container {
        padding: 16px 12px !important;
        margin: 10px 0 !important;
        border-radius: 12px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .clinical-card-header {
        margin-bottom: 12px !important;
        padding-bottom: 10px !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-start !important;
        justify-content: space-between !important;
        flex-wrap: nowrap !important;
        width: 100% !important;
        gap: 10px !important;
        box-sizing: border-box !important;
    }

    .clinical-card-title {
        font-size: 1.05rem !important;
        flex: 1 1 auto !important;
        margin-bottom: 0 !important;
        margin-right: 0 !important;
    }

    .clinical-badge {
        font-size: 0.65rem !important;
        padding: 4px 8px !important;
        text-align: right !important;
        margin-left: auto !important;
        flex-shrink: 0 !important;
        align-self: flex-start !important;
    }

    .clinical-data-section {
        padding-bottom: 14px !important;
        margin-bottom: 14px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .clinical-data-row {
        margin-bottom: 14px !important;
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        box-sizing: border-box !important;
    }

    .clinical-data-label {
        font-size: 0.72rem !important;
        margin-bottom: 4px !important;
        letter-spacing: 0.2px !important;
    }

    .clinical-data-value {
        font-size: 0.94rem !important;
        line-height: 1.45 !important;
    }

    .clinical-section-title {
        font-size: 0.8rem !important;
        margin-bottom: 8px !important;
        letter-spacing: 0.2px !important;
    }

    .clinical-section-body {
        font-size: 0.92rem !important;
        line-height: 1.55 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .clinical-data-snippet {
        font-size: 0.92rem !important;
        line-height: 1.55 !important;
    }

    ul.clinical-list {
        width: 100% !important;
        gap: 10px !important;
        margin: 8px 0 !important;
        box-sizing: border-box !important;
    }

    li.clinical-list-item {
        font-size: 0.92rem !important;
        line-height: 1.5 !important;
        padding-left: 14px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    li.clinical-list-item::before {
        left: 0 !important;
        font-size: 1.1rem !important;
        line-height: 1.2 !important;
    }

    .clinical-card-source-footer {
        padding-top: 14px !important;
        margin-top: 14px !important;
        font-size: 0.8rem !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .accordion-element-node {
        margin-bottom: 8px !important;
        border-radius: 12px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .accordion-header-trigger {
        padding: 14px 12px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .accordion-header-text-group .node-title {
        font-size: 0.95rem !important;
    }

    .accordion-body-expansion-layer {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .accordion-expansion-content {
        padding: 14px 12px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .accordion-expansion-content .clinical-card-header {
        padding-top: 0 !important;
        margin-bottom: 12px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* --------------------------------------------------
       G. CDSS Matrix Engine Mobile Overrides
       -------------------------------------------------- */
    .ctx-submenu-card {
        margin-left: -4px;
        margin-right: -4px;
    }

    .inline-form-row {
        width: 100% !important;
    }

    .patient-metrics-engine-block label {
        font-size: 0.8rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .patient-metrics-engine-block select,
    .patient-metrics-engine-block input {
        padding: 6px 8px !important;
        font-size: 0.85rem !important;
        text-align: left;
    }

    .risk-engine-dropdown-content {
        padding: 10px !important;
    }

    .risk-matrix-option { 
        padding: 10px 16px !important; 
        font-size: 0.9rem !important; 
    }

    .risk-matrix-option input[type="checkbox"] {
        width: 18px !important;
        height: 18px !important;
        margin-top: 0 !important;
    }

    .inline-calc-form {
        padding: 12px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
    }

    .cortexa-dynamic-trigger {
        border-radius: 12px !important;
    }

/* Grouped Structural Resets for CDSS Elements */
    .cdss-accordion,
    .cdss-accordion-group,
    .cdss-accordion-header,
    .cdss-accordion-body,
    .cdss-tab,
    .cdss-risk-chip,
    .cdss-action-row {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Individual Component Spacing & Typography */
    .cdss-accordion {
        border-radius: 12px !important;
    }

    .cdss-accordion-group {
        padding: 10px 4px !important;
        gap: 8px !important;
    }

    .cdss-accordion-header {
        padding: 14px 12px !important;
        font-size: 0.85rem !important;
    }

    .cdss-accordion-body {
        padding: 12px 10px !important;
    }

    .cdss-tab {
        padding: 14px 16px !important;
        font-size: 0.85rem !important;
    }

    .cdss-risk-chip {
        padding: 12px 12px !important;
        font-size: 0.85rem !important;
    }

    .cdss-action-row {
        padding: 0 4px 16px 4px !important;
    }

    .risk-engine-summary-header { padding: 10px 12px !important; }
    .risk-engine-title-group { font-size: 0.8rem !important; }

    /* --------------------------------------------------
       H. Native UI Elements Sizing
       -------------------------------------------------- */
    .workspace-search-bar-wrapper {
        min-height: 44px !important;
        height: auto !important;
        padding: 6px 12px !important;
    }

    .workspace-search-bar-wrapper input,
    .workspace-search-bar-wrapper textarea {
        font-size: 16px !important; /* Prevents iOS auto-zoom */
    }

    .workspace-search-bar-wrapper textarea {
        width: 100% !important;
        min-width: 0 !important;
        height: auto;
        min-height: 24px;
        max-height: 130px;
        line-height: 1.4 !important;
        background: transparent !important;
        border: none !important;
        outline: none !important;
        color: var(--text-primary) !important;
        resize: none !important;
        overflow-y: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        white-space: pre-wrap !important;
        word-break: break-word !important;
        display: block !important;
        align-self: center !important;
    }

    .input-wrapper-matrix {
        padding: 8px 12px 8px 16px !important;
        border-radius: 24px !important;
    }

    .input-panel-container {
        padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
        padding-top: 24px !important;
    }
}

/* Desktop default for patient history counter / search badge */
.risk-active-counter-badge[id$="_counter_badge"] {
    width: 120px;
    height: 32px;
    font-size: 0.85rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    padding: 0 10px;
    box-sizing: border-box;
    white-space: nowrap;
}

/* ==========================================================================
   MOBILE-ONLY COMPACT BUTTONS ENGINE
   ========================================================================== */
@media (max-width: 767px) {
    .risk-active-counter-badge[id$="_counter_badge"] {
        width: 32px !important;
        min-width: 32px !important;
        max-width: 32px !important;
        height: 32px !important;
        padding: 0 !important;
        border-radius: 8px !important;
        flex-shrink: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .risk-active-counter-badge[id$="_counter_badge"].hidden {
        display: none !important;
    }

    /* Prescription & Document Generate Buttons Mobile */
    #prescription_action_btn, #document_action_btn {
        width: 32px !important;
        min-width: 32px !important;
        max-width: 32px !important;
        height: 32px !important;
        padding: 0 !important;
        border-radius: 8px !important;
        display: none; /* Managed by JS, flex when active */
        align-items: center !important;
        justify-content: center !important;
        flex-shrink: 0 !important;
        font-size: 0 !important;
    }
    .gen-search-text { display: none !important; }
    .gen-search-icon { display: block !important; }

    #prescription_action_btn .cdss-animated-icon {
        font-size: 1.15rem !important;
    }

    /* 3. Clinical Documentation Suite "Generate" Button */
    #document_action_btn {
        width: 32px !important;
        min-width: 32px !important;
        max-width: 32px !important;
        height: 32px !important;
        padding: 0 !important;
        border-radius: 8px !important;
        display: none; /* Managed by JS, flex when active */
        align-items: center !important;
        justify-content: center !important;
        flex-shrink: 0 !important;
        font-size: 0 !important; /* Hide long text */
    }

    #document_action_btn .cdss-animated-icon {
        font-size: 1.15rem !important;
    }
}

/* ==========================================================================
   SECTION 18: INTERACTIVE PIN & ACTION BUTTON CROSSOVER MATRIX
   ========================================================================== */

/* --------------------------------------------------
   A. Base Wrapper & Trigger Button Constraints
   -------------------------------------------------- */
.history-item-wrapper {
    position: relative;
}

.history-item-wrapper .item-action-trigger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: transparent !important;
    box-shadow: none !important;
    border: none;
    cursor: pointer;
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    transition: opacity 0.15s ease;
}

.history-item-wrapper .item-action-trigger-btn:hover {
    background-color: transparent !important;
    box-shadow: none !important;
    border-radius: 9px !important;
}

/* --------------------------------------------------
   B. Icon Default States
   -------------------------------------------------- */
.history-item-wrapper .item-action-trigger-btn .pin-icon, 
.history-item-wrapper .item-action-trigger-btn .dots-icon {
    display: none;
    font-size: 18px;
}

.history-item-wrapper .item-action-trigger-btn .pin-icon {
    color: var(--pinned-accent) !important;
}

.history-item-wrapper .item-action-trigger-btn .dots-icon {
    color: var(--text-secondary);
}

/* --------------------------------------------------
   C. Unpinned State Logic (data-pinned="false")
   -------------------------------------------------- */
.history-item-wrapper[data-pinned="false"] .item-action-trigger-btn {
    opacity: 0;
    pointer-events: none;
}

.history-item-wrapper[data-pinned="false"]:hover .item-action-trigger-btn {
    opacity: 1;
    pointer-events: auto;
}

.history-item-wrapper[data-pinned="false"] .dots-icon {
    display: inline-block;
}

/* --------------------------------------------------
   D. Pinned State Logic (data-pinned="true")
   -------------------------------------------------- */
.history-item-wrapper[data-pinned="true"] .item-action-trigger-btn {
    opacity: 1;
    pointer-events: auto;
}

.history-item-wrapper[data-pinned="true"] .pin-icon {
    display: inline-block;
}

.history-item-wrapper[data-pinned="true"] .dots-icon {
    display: none;
}

/* Hovering over an already pinned item swaps the icon to the options menu */
.history-item-wrapper[data-pinned="true"]:hover .pin-icon {
    display: none !important;
}

.history-item-wrapper[data-pinned="true"]:hover .dots-icon {
    display: inline-block !important;
}


/* ==========================================================================
   SECTION 19: CORTEXA LIVE WAVE - INFINITE DYNAMIC COLOR ENGINE
   ========================================================================== */

/* --------------------------------------------------
   A. Core Fluid Matrix Container
   -------------------------------------------------- */
.fluid-matrix-container {
    display: inline-block;
    width: 20px;
    height: 20px;
    transform-origin: center center;
    background: var(--gemini-gradient);
    background-size: 200% auto;
    animation: gemini-shimmer 6s ease infinite;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    transition: -webkit-mask-image 0.8s cubic-bezier(0.25, 1, 0.3, 1), 
                mask-image 0.8s cubic-bezier(0.25, 1, 0.3, 1);
}

.cortexa-fluid-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.cortexa-fluid-canvas line {
    /* Hides the raw SVG stroke to let the CSS background gradient show through the mask */
    stroke: transparent !important;
}

/* --------------------------------------------------
   B. Dynamic Menu Icon States (Inline SVG Masks)
   -------------------------------------------------- */
   
/* Default State: Hamburger Menu (Always defaults to this when closed) */
.cortexa-dynamic-trigger .fluid-matrix-container { 
    -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="3" stroke-linecap="round"><line x1="4" y1="8" x2="20" y2="8.1"></line><line x1="4" y1="16" x2="20" y2="16.1"></line></svg>') !important; 
    mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="3" stroke-linecap="round"><line x1="4" y1="8" x2="20" y2="8.1"></line><line x1="4" y1="16" x2="20" y2="16.1"></line></svg>') !important; 
}

/* Active State: 'X' Close Menu (Strictly tied to the actual open state of the Sidebar) */
body.sidebar-active .cortexa-dynamic-trigger .fluid-matrix-container,
.sidebar:not(.collapsed) .cortexa-dynamic-trigger .fluid-matrix-container { 
    -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="3" stroke-linecap="round"><line x1="6" y1="6" x2="18" y2="18"></line><line x1="6" y1="18" x2="18" y2="6"></line></svg>') !important; 
    mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="3" stroke-linecap="round"><line x1="6" y1="6" x2="18" y2="18"></line><line x1="6" y1="18" x2="18" y2="6"></line></svg>') !important; 
}

/* =======================================================================
   SECTION 18-B: THEME TOGGLE SYSTEM
   ======================================================================= */
.theme-quick-toggle-btn {
    position: relative;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50px;
    background-color: transparent !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    transition: box-shadow 0.3s ease, transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-quick-toggle-btn:hover {
    transform: translateY(-1px);
}

.theme-quick-toggle-btn:active {
    transform: translateY(1px) scale(0.96);
}

/* Base Icon Setup */
.theme-quick-toggle-btn .icon-moon, 
.theme-quick-toggle-btn .icon-sun, 
.theme-quick-toggle-btn .icon-auto { 
    position: absolute; 
    font-size: 24px; 
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease; 
    transform-origin: center center; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}

/* Default (Dark Mode) State */
.theme-quick-toggle-btn .icon-moon {
    color: #8F00FF !important;
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.theme-quick-toggle-btn .icon-sun {
    color: #ffb703 !important;
    opacity: 0;
    transform: rotate(90deg) scale(0);
}

.theme-quick-toggle-btn .icon-auto {
    opacity: 0;
    transform: rotate(-90deg) scale(0);
}

/* Light Mode State */
.theme-quick-toggle-btn.is-light .icon-moon {
    opacity: 0;
    transform: rotate(-90deg) scale(0);
}

.theme-quick-toggle-btn.is-light .icon-sun {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.theme-quick-toggle-btn.is-light .icon-auto {
    opacity: 0;
    transform: rotate(90deg) scale(0);
}

/* Auto Mode State */
.theme-quick-toggle-btn.is-auto .icon-moon {
    opacity: 0;
    transform: rotate(90deg) scale(0);
}

.theme-quick-toggle-btn.is-auto .icon-sun {
    opacity: 0;
    transform: rotate(-90deg) scale(0);
}

.theme-quick-toggle-btn.is-auto .icon-auto {
    opacity: 1;
    transform: rotate(0deg) scale(1);
    color: var(--text-primary);
}
/* =======================================================================
   SECTION 19-B: CLINICAL CARD RESPONSES
   ======================================================================= */
.clinical-card-container, 
.system-card-container, 
.ctx-hybrid-card-wrapper,
.accordion-element-node,
.inline-calc-form, 
.inline-form-row { 
    width: 100% !important; 
    max-width: 100% !important; 
    min-width: 0 !important; 
    box-sizing: border-box !important; 
    overflow: visible !important; 
    margin-bottom: 0 !important;
}

.cdss-result-container {
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    margin-bottom: 0 !important;
}

.inline-form-row { 
    display: flex !important; 
    flex-direction: column !important; 
    align-items: stretch !important; 
    justify-content: flex-start !important; 
    float: none !important; 
}

.inline-form-row select, 
.inline-form-row input { 
    width: 100% !important; 
    max-width: 100% !important; 
    min-width: 0 !important; 
    box-sizing: border-box !important; 
    display: block !important; 
    text-overflow: ellipsis !important; 
    white-space: nowrap !important; 
    overflow: hidden !important; 
}

.inline-form-row select option { 
    max-width: 100% !important; 
    overflow: hidden !important; 
    text-overflow: ellipsis !important; 
}

@media (min-width: 768px) { 
        .sidebar { 
            /* RESTORES DESKTOP BOUNCE: Uses the exact same cubic-bezier spring physics as the mobile drawer */
            transition: width 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.25) !important; 
        } 
    }

@media (pointer: coarse) { 
    .item-action-trigger-btn { 
        display: flex !important; 
    } 
    .history-item { 
        padding-right: 44px !important; 
    } 
}

/* Base override */
.clinical-card-header, 
.system-card-header { 
    display: flex !important; 
    gap: 12px !important; 
    width: 100% !important; 
}

/* Desktop: Force in-line alignment for title and badge */
@media (min-width: 768px) {
    .clinical-card-header, 
    .system-card-header {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        flex-wrap: nowrap !important;
    }
    .clinical-card-header .clinical-card-title {
        align-items: center !important;
        margin-bottom: 0 !important;
    }
    .clinical-card-header .clinical-badge {
        margin-left: auto !important;
        align-self: center !important;
    }
}

/* Mobile: Stack items vertically */
@media (max-width: 767px) {
    .clinical-card-header, 
    .system-card-header {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
}

/* Restores natural separation gaps between System Configuration sections */
#settingsWorkspaceScreen .accordion-element-node {
    margin-bottom: 12px !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 12px !important;
    background: var(--glass-bg) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    box-shadow: 0 8px 30px var(--shadow-alpha) !important;
    overflow: hidden !important;
}

#settingsWorkspaceScreen .accordion-header-trigger {
    height: 48px !important;
    min-height: 48px !important;
    padding: 0 16px !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
}

.accordion-element-node {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 16px !important;
    overflow: hidden !important;
    margin-bottom: 12px !important;
    box-shadow: 0 8px 30px var(--shadow-alpha) !important;
}

.accordion-element-node.expanded {
    overflow: visible !important;
}

.accordion-body-expansion-layer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease-in-out;
    background: transparent !important;
    border-radius: 0 0 16px 16px !important;
}

.accordion-element-node.expanded .accordion-body-expansion-layer {
    overflow: visible !important;
}

.accordion-expansion-content {
    padding: 20px;
    font-size: 0.94rem;
    line-height: 1.6;
    color: var(--text-primary);
    border-top: 1px solid var(--border-color);
    background: transparent !important;
    border-radius: 0 0 16px 16px !important;
}

#settingsWorkspaceScreen .workspace-internal-container {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
}

#settingsWorkspaceScreen .input-field-wrapper { 
    position: relative; 
    display: flex; 
    align-items: center; 
    background-color: var(--bg-main); 
    border: 1px solid var(--border-color); 
    border-radius: 12px; 
    padding: 0 14px; 
    height: 35px; 
    transition: border-color var(--transition-smooth); 
}

#settingsWorkspaceScreen .input-field-wrapper:focus-within { 
    border-color: var(--accent-blue); 
}

#settingsWorkspaceScreen .input-field-wrapper input { 
    background: transparent; 
    border: none; 
    color: var(--text-primary); 
    font-size: 0.8rem; 
    padding-left: 12px; 
    width: 100%; 
    outline: none; 
}

#settingsWorkspaceScreen .input-field-wrapper .prefix-icon { 
    color: var(--text-secondary); 
    font-size: 1.25rem; 
}

#settingsToggleBtn.active svg { 
    color: var(--text-primary) !important; 
}

.sidebar.collapsed:not(.mobile-open):not(.sidebar-active) .history-section, 
.sidebar.collapsed:not(.mobile-open):not(.sidebar-active) .sidebar-scroll-zone .history-item-wrapper, 
.sidebar.collapsed:not(.mobile-open):not(.sidebar-active) .sidebar-scroll-zone .history-item { 
    display: none; 
    opacity: 0; 
    visibility: hidden; 
    pointer-events: none; 
}

.sidebar.mobile-open .history-item-wrapper, 
body.sidebar-active #sidebar .history-item-wrapper { 
    display: block; 
    width: 100%; 
}

.sidebar.mobile-open .history-item, 
body.sidebar-active #sidebar .history-item { 
    display: flex; 
    width: 100%; 
    opacity: 1; 
    visibility: visible; 
    pointer-events: auto; 
    border-radius: 12px; 
}

/* Library-Style Header Tabs */
.cdss-header-tabs { 
    display: flex; 
    border-bottom: 1px solid var(--border-color); 
    background: var(--bg-sidebar); 
    padding: 0 12px; 
    margin: 0; 
    border-radius: 16px 16px 0 0; 
    overflow-x: auto; 
    scrollbar-width: none; 
}

.cdss-header-tabs::-webkit-scrollbar { 
    display: none; 
}

.cdss-tab { 
    padding: 16px 20px; 
    color: var(--text-secondary); 
    font-weight: 600; 
    font-size: 0.95rem; 
    cursor: pointer; 
    border-bottom: 2px solid transparent; 
    transition: all 0.2s ease; 
    white-space: nowrap; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
}

.cdss-tab:hover { 
    color: var(--text-primary); 
}

.cdss-tab.active { 
    color: var(--accent-blue); 
    border-bottom-color: var(--accent-blue); 
}

/* Accordion Dropdown Menus */
.cdss-accordion-group { 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
    padding: 20px; 
}

.cdss-accordion { 
    border: 1px solid var(--border-color); 
    border-radius: 12px; 
    background: var(--bg-surface); 
    overflow: hidden; 
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
}

.cdss-accordion-header { 
    padding: 16px 20px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    cursor: pointer; 
    background: var(--bg-hover); 
    color: var(--text-primary); 
    font-weight: 600; 
    font-size: 0.9rem; 
    user-select: none; 
    transition: background 0.2s; 
}

.cdss-accordion-header:hover { 
    background: var(--border-color); 
}

.cdss-accordion-header .chevron { 
    transition: transform 0.3s ease; 
    color: var(--text-secondary); 
}

.cdss-accordion.expanded .cdss-accordion-header .chevron { 
    transform: rotate(180deg); 
    color: var(--accent-blue); 
}

.cdss-accordion-body { 
    max-height: 0; 
    opacity: 0; 
    overflow: hidden; 
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
    background: var(--bg-main); 
}

.cdss-accordion.expanded .cdss-accordion-body { 
    max-height: 2000px; 
    opacity: 1; 
    padding: 16px; 
    border-top: 1px solid var(--border-color); 
}

/* Risk Factor Style Interactive Chips (No Checkboxes) */
.cdss-chip-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); 
    gap: 10px; 
}

.cdss-risk-chip { 
    padding: 12px 16px; 
    border: 1px solid var(--border-color); 
    border-radius: 8px; 
    background: var(--bg-main); 
    color: var(--text-primary); 
    font-size: 0.85rem; 
    font-weight: 500; 
    cursor: pointer; 
    transition: all 0.15s ease-out; 
    user-select: none; 
    display: flex; 
    align-items: center; 
    line-height: 1.4; 
}

.cdss-risk-chip:hover { 
    border-color: var(--text-secondary); 
    background: var(--bg-hover); 
}

.cdss-risk-chip.active { 
    border-color: var(--accent-blue); 
    background: rgba(66, 133, 244, 0.08); 
    color: var(--accent-blue); 
    box-shadow: inset 0 0 0 1px var(--accent-blue); 
}

/* Card Structural Elements */
.cdss-action-row { 
    padding: 0 20px 20px 20px; 
}

.cdss-result-container {
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* ========================================================= */
/* UNIVERSAL BULLETPROOF CART & MATRIX SPACING               */
/* ========================================================= */

/* Desktop Base Layouts */
#inter_active_cards_target, body #inter_active_cards_target,
#lib_active_cards_target, body #lib_active_cards_target,
#cdss_active_cards_target, body #cdss_active_cards_target,
#analysis_active_cards_target, body #analysis_active_cards_target {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    margin-bottom: 24px !important; 
}

#inter_results_target, body #inter_results_target,
#cdss_result_target, body #cdss_result_target {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
}

/* THE UNIVERSAL SNIPER RULE */
#inter_active_cards_target > div, body.mobile-viewport #inter_active_cards_target > div,
#inter_active_cards_target .clinical-card-container, body.mobile-viewport #inter_active_cards_target .clinical-card-container,
#lib_active_cards_target > div, body.mobile-viewport #lib_active_cards_target > div,
#cdss_active_cards_target > div, body.mobile-viewport #cdss_active_cards_target > div,
#analysis_active_cards_target > div, body.mobile-viewport #analysis_active_cards_target > div,
#analysis_active_cards_target .clinical-card-container, body.mobile-viewport #analysis_active_cards_target .clinical-card-container,
#inter_results_target > div, body.mobile-viewport #inter_results_target > div,
#inter_results_target .clinical-card-container, body.mobile-viewport #inter_results_target .clinical-card-container,
#cdss_result_target > div, body.mobile-viewport #cdss_result_target > div {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

@media (max-width: 767px) {
    body #inter_active_cards_target, body.mobile-viewport #inter_active_cards_target,
    body #lib_active_cards_target, body.mobile-viewport #lib_active_cards_target,
    body #cdss_active_cards_target, body.mobile-viewport #cdss_active_cards_target,
    body #analysis_active_cards_target, body.mobile-viewport #analysis_active_cards_target {
        display: flex !important; 
        flex-direction: column !important;
        gap: 10px !important;
        margin-bottom: 20px !important; 
    }
}

/* ==========================================================================
   SECTION 20: NATIVE TEXT TRUNCATION ENGINE (PREVENTS BUTTON OVERLAPS)
   ========================================================================== */

/* Ensure the text understands how to elegantly truncate with an ellipsis */
.history-item-text {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

/* Dynamically retract the text box ONLY when hovered to make exact room for the absolute button */
.history-item-wrapper:hover .history-item {
    padding-right: 42px !important;
}

/* Ensure pinned text does not overlap with the persistent pin icon */
.history-item-wrapper[data-pinned="true"] .history-item {
    padding-right: 38px !important;
}


/* ==========================================================================
   SECTION 21: UNIVERSAL LAYOUT STYLES & ICON EQUALIZER
   ========================================================================== */

/* Condense the buttons and tighten gaps universally */
.sidebar-header { 
    padding: 8px 12px !important; 
    gap: 4px !important; 
}

/* Recents background layout */
.history-list { 
    gap: 2px !important; 
    padding-bottom: 8px !important; 
}

/* Universal Button Sizing */
.sidebar .sidebar-action-pill-btn, 
.sidebar .footer-nav-btn, 
.history-item { 
    padding: 8px 12px !important; 
    gap: 12px !important;         
    min-height: 38px !important;  
    font-size: 0.85rem !important; 
    font-weight: 500 !important;
}

/* Force ALL icons (CDSS, Library, New Chat, etc.) to a perfect 18x18 square */
.sidebar-action-pill-btn svg, 
.sidebar-action-pill-btn .material-symbols-rounded,
.history-item svg, 
.history-item .material-symbols-rounded,
.footer-nav-btn svg, 
.footer-nav-btn .material-symbols-rounded {
    flex-shrink: 0 !important;
    width: 18px !important;
    height: 18px !important;
    font-size: 19px !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* ==========================================================================
   SECTION 22: CDSS ACTION BUTTONS & ANIMATION RESTORATION
   ========================================================================== */

/* Restore the original clean hover-animation for the CDSS icon */
.cdss-animated-icon { 
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important; 
    transform-origin: center !important; 
    will-change: transform !important;
}

.footer-nav-btn:hover .cdss-animated-icon { 
    transform: scale(1.15) translateY(-1px) !important; 
}

.footer-nav-btn:active .cdss-animated-icon { 
    transform: scale(0.95) translateY(1px) !important; 
}

/* --------------------------------------------------
   CDSS Master Action Button
   -------------------------------------------------- */
button#cdss_synthesize_action_btn {
    width: 100%;
    margin-top: 24px;
    margin-bottom: 12px;
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 1.05rem;
    font-weight: 700;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.3px;
    box-shadow: none;
    border: 1px solid transparent;
}

/* Idle State (Start Diagnostic) */
button#cdss_synthesize_action_btn[data-state="idle"] {
    background-color: rgba(66, 133, 244, 0.08) !important;
    color: var(--accent-blue) !important;
    border-color: rgba(66, 133, 244, 0.3) !important;
}

button#cdss_synthesize_action_btn[data-state="idle"]:hover {
    background-color: rgba(66, 133, 244, 0.15) !important;
    color: var(--accent-blue) !important;
    border-color: rgba(66, 133, 244, 0.6) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.1) !important;
}

/* Active State (Clear Data) */
button#cdss_synthesize_action_btn[data-state="active"] {
    background-color: transparent !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}

button#cdss_synthesize_action_btn[data-state="active"]:hover {
    background-color: rgba(234, 67, 53, 0.05) !important;
    color: var(--clinical-alert) !important;
    border-color: rgba(234, 67, 53, 0.4) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(234, 67, 53, 0.05) !important;
}

/* CDSS Icon-Only Action Buttons */
.cdss-action-btn.icon-only {
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--accent-blue);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.cdss-action-btn.icon-only:hover {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
    transform: translateY(-1px);
}

.cdss-action-btn.icon-only .material-symbols-rounded {
    font-size: 22px !important;
}

/* ==========================================================================
   UNIFIED CLINICAL INTELLIGENCE ENGINES MENU (DESKTOP FLYOUT / MOBILE ACCORDION)
   ========================================================================== */

/* Parent Menu Group */
.ctx-intelligence-menu-group {
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

/* Parent Trigger Item */
.ctx-intelligence-trigger {
    width: 100%;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 10px 12px !important;
    border-radius: 12px !important;
    border: 1px solid var(--border-color, rgba(0,0,0,0.1)) !important;
    background: var(--bg-surface, #ffffff) !important;
    color: var(--text-primary, #1e293b) !important;
    cursor: pointer !important;
    transition: background 0.2s ease, border-color 0.2s ease !important;
    box-sizing: border-box !important;
}

.ctx-intelligence-trigger:hover {
    background: var(--bg-hover, rgba(0,0,0,0.05)) !important;
}

/* Active Count Pill on Parent Trigger */
.ctx-intelligence-count-badge {
    font-size: 0.72rem;
    font-weight: 700;
    width: 22px;
    height: 22px;
    min-width: 22px;
    max-width: 22px;
    padding: 0;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    border-radius: 50%;
    background: rgba(66, 133, 244, 0.12);
    color: var(--accent-blue, #1a73e8);
    border: 1px solid rgba(66, 133, 244, 0.3);
    line-height: 1;
    box-sizing: border-box !important;
    flex-shrink: 0;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.ctx-intelligence-count-badge.is-zero {
    background: transparent;
    color: var(--text-secondary, #64748b);
    border-color: var(--border-color, rgba(0, 0, 0, 0.15));
    opacity: 0.65;
}

/* Trigger Chevron Indicator */
.ctx-intelligence-chevron {
    font-size: 1.15rem !important;
    color: var(--text-secondary, #64748b);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), color 0.2s;
}

/* Individual Tool Card inside the Menu */
.ctx-intel-item-card {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 9px 10px !important;
    border-radius: 10px !important;
    border: 1px solid transparent !important;
    background: transparent !important;
    cursor: pointer !important;
    transition: background 0.18s ease, border-color 0.18s ease !important;
    width: 100% !important;
    box-sizing: border-box !important;
    user-select: none !important;
}

.ctx-intel-item-card:hover {
    background: var(--bg-hover, rgba(0,0,0,0.05)) !important;
}

/* iOS-Style Toggle Switch */
.ctx-toggle-track {
    width: 34px;
    height: 20px;
    border-radius: 12px;
    background: var(--border-color, rgba(0,0,0,0.18));
    position: relative;
    flex-shrink: 0;
    transition: background 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.ctx-toggle-track.active-think {
    background: var(--accent-blue, #1a73e8) !important;
}

.ctx-toggle-track.active-search {
    background: var(--clinical-success, #16a34a) !important;
}

.ctx-toggle-track.active-learning {
    background: #8b5cf6 !important;
}

.ctx-toggle-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    position: absolute;
    top: 2px;
    left: 2px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.ctx-toggle-track.is-active .ctx-toggle-thumb {
    transform: translateX(14px);
}

/* --------------------------------------------------
   UNIFIED DOWNWARD ACCORDION ENGINE (DESKTOP & MOBILE)
   -------------------------------------------------- */

/* Base Closed State: Positioned inline beneath the button */
.ctx-intelligence-flyout {
    position: static !important;
    width: 100% !important;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: none !important;
    box-shadow: none !important;
    background: var(--bg-main, rgba(0, 0, 0, 0.03)) !important;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.1)) !important;
    border-radius: 14px !important;
    padding: 0 8px !important;
    margin-top: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-sizing: border-box !important;
    transition: max-height 0.32s cubic-bezier(0.16, 1, 0.3, 1), 
                opacity 0.25s ease, 
                padding 0.3s ease, 
                margin 0.3s ease !important;
}

/* DESKTOP HOVER & CLICK EXPANSION */
@media (min-width: 768px) {
    /* Provide comfortable width in desktop attach menu */
    #ctx_deck_attach_menu {
        min-width: 300px !important;
        width: 315px !important;
    }

    /* Expand downwards strictly on click toggle (.is-open) */
    .ctx-intelligence-menu-group.is-open .ctx-intelligence-flyout {
        max-height: 380px !important;
        opacity: 1 !important;
        visibility: visible !important;
        padding: 8px !important;
        margin-top: 6px !important;
        pointer-events: auto !important;
    }

    .ctx-intelligence-menu-group.is-open .ctx-intelligence-chevron {
        transform: rotate(180deg) !important;
        color: var(--accent-blue, #1a73e8);
    }
}

/* MOBILE TAP / PRESS EXPANSION */
@media (max-width: 767px) {
    .ctx-intelligence-menu-group.is-open .ctx-intelligence-flyout {
        max-height: 380px !important;
        opacity: 1 !important;
        visibility: visible !important;
        padding: 8px !important;
        margin-top: 6px !important;
        pointer-events: auto !important;
    }

    .ctx-intelligence-menu-group.is-open .ctx-intelligence-chevron {
        transform: rotate(180deg) !important;
        color: var(--accent-blue, #1a73e8);
    }
}

/* ==========================================================================
   SECTION 23: CLINICAL CARD TAB ENGINE
   ========================================================================== */
.ctx-card-tab-nav {
    display: flex;
    overflow-x: auto;
    background: var(--bg-surface); /* Blends with the card header */
    border-bottom: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0; /* Matches card container top corners */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.ctx-card-tab-nav::-webkit-scrollbar {
    display: none;
}

.ctx-card-tab-btn {
    flex: 1 0 auto; /* Grows if few tabs exist, but REFUSES to shrink below content width, forcing the horizontal scroll to trigger */
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.02);
    border: none;
    border-right: 1px solid var(--border-color);
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s ease, color 0.2s ease;
}

.ctx-card-tab-btn:last-child {
    border-right: none;
}

.ctx-card-tab-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.ctx-card-tab-btn.active {
    color: var(--text-primary);
    background: var(--bg-main); /* Merges seamlessly with the content pane */
    border-bottom: 2px solid var(--text-primary); /* Clean, simple highlight */
}

.ctx-card-tab-badge {
    font-size: 0.75rem;
    padding: 2px 6px;
    margin-left: 6px;
    border-radius: 4px;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    font-weight: 700;
}

.ctx-card-tab-btn.active .ctx-card-tab-badge {
    border-color: var(--text-primary);
}

/* ==========================================================================
   SECTION 24: MOBILE SIDEBAR HEADER OPTIMIZATIONS
   ========================================================================== */
@media (min-width: 768px) {
    .sidebar-header.mobile-optimized .header-nav-items { display: flex !important; flex-direction: column !important; gap: 4px !important; width: 100% !important; }
    .sidebar-header.mobile-optimized .header-separator-line, 
    .sidebar-header.mobile-optimized .header-expander-trigger { display: none !important; }
}

@media (max-width: 767px), (max-height: 500px) {
    .sidebar-header.mobile-optimized { 
        flex-shrink: 0 !important; 
        background-color: var(--bg-main) !important; 
        z-index: 10 !important; 
        border-bottom: 1px solid var(--border-color) !important; 
        margin: 0 !important; 
        padding: 8px 12px !important; 
        display: flex !important; 
        flex-direction: row !important; 
        flex-wrap: nowrap !important; /* Forces everything onto one line */
        align-items: center !important; 
        transition: background-color 0.2s, padding 0.25s !important; 
    }
    
    .sidebar-header.mobile-optimized.is-expanded { 
        flex-direction: column !important; 
        padding: 12px !important; 
    }
    
    .sidebar-header.mobile-optimized .header-nav-items { 
        display: flex !important; 
        flex-direction: row !important; 
        gap: 8px !important; 
        flex: 1 1 auto !important; 
        width: auto !important; /* <--- Removed 100% so it doesn't push the trigger down */
        justify-content: space-evenly !important;
    }
    
    .sidebar-header.mobile-optimized.is-expanded .header-nav-items { 
        flex-direction: column !important; 
        width: 100% !important; /* Restored 100% width ONLY when expanded */
        gap: 2px !important; 
        order: 2 !important; 
    }
    
    .sidebar-header.mobile-optimized:not(.is-expanded) .sidebar-action-pill-btn { 
        flex: 0 0 44px !important; 
        width: 44px !important; 
        height: 44px !important; 
        min-height: 44px !important; 
        padding: 0 !important; 
        justify-content: center !important; 
        border-radius: 12px !important; 
        margin: 0 !important; 
    }
    
    .sidebar-header.mobile-optimized:not(.is-expanded) .btn-text { 
        display: none !important; 
    }
    
    .sidebar-header.mobile-optimized .header-separator-line { 
        display: block !important; 
        width: 1px !important; 
        height: 24px !important; 
        background-color: var(--border-color) !important; 
        margin: 0 10px 0 12px !important; 
    }
    
    .sidebar-header.mobile-optimized.is-expanded .header-separator-line { 
        display: none !important; 
    }
    
    .sidebar-header.mobile-optimized .header-expander-trigger { 
        display: flex !important; 
        align-items: center !important; 
        justify-content: center !important; 
        width: 36px !important; 
        height: 36px !important; 
        background: transparent !important; 
        border: none !important; 
        border-radius: 8px !important; 
        cursor: pointer !important; 
        flex-shrink: 0 !important; /* Prevents the trigger from being crushed */
        transition: background 0.2s !important; 
    }
    
    .sidebar-header.mobile-optimized .header-expander-trigger:hover { 
        background: var(--bg-hover) !important; 
    }
    
    .sidebar-header.mobile-optimized.is-expanded .header-expander-trigger { 
        order: 1 !important; 
        width: 100% !important; 
        height: 28px !important; 
        margin-top: 0 !important; 
        margin-bottom: 8px !important; 
        border: 1px solid var(--border-color) !important; 
        background: var(--bg-hover) !important; 
    }
    
    .sidebar-header.mobile-optimized .header-horizontal-dash { 
        width: 18px !important; 
        height: 3px !important; 
        background-color: var(--text-secondary) !important; 
        border-radius: 2px !important; 
        transition: width 0.3s, opacity 0.3s, background-color 0.2s !important; 
    }
    
    .sidebar-header.mobile-optimized .header-expander-trigger:hover .header-horizontal-dash { 
        background-color: var(--text-primary) !important; 
    }
    
    .sidebar-header.mobile-optimized.is-expanded .header-horizontal-dash { 
        width: 32px !important; 
        height: 4px !important; 
        opacity: 0.4 !important; 
    }
}

/* Responsive Spacing for Drug Interactions Matrix */
#inter_active_cards_target { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; }
#inter_results_target { display: flex; flex-direction: column; gap: 12px; }

@media (max-width: 767px) {
    #inter_active_cards_target { gap: 8px !important; margin-bottom: 12px !important; }
    #inter_results_target { gap: 8px !important; }
}

/* ==========================================================================
   SECTION 25: HYBRID CARD DECK & TAB SYSTEM (REFRESH-PROOF MOBILE ENGINE)
   ========================================================================== */
.ctx-hybrid-card-wrapper {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* DESKTOP & TABLET / IPAD VIEW */
.ctx-desktop-tab-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 16px;
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

.ctx-desktop-tab-scroll {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 auto;
    overflow-x: auto;
    scrollbar-width: none;
    box-sizing: border-box;
}
.ctx-desktop-tab-scroll::-webkit-scrollbar { display: none; }

.ctx-desktop-nav-arrow {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.25);
    outline: none;
    user-select: none;
    padding: 0;
}
.ctx-desktop-nav-arrow:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.ctx-desktop-tab-btn {
    flex: 1 1 auto;
    min-width: fit-content;
    white-space: nowrap;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    height: 34px;
    padding: 0 16px;
    border-radius: 8px;
    font-size: 0.83rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.25);
    outline: none;
    user-select: none;
    box-sizing: border-box;
}
.ctx-desktop-tab-btn:hover:not(.active) {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.ctx-desktop-tab-btn.active {
    background: var(--bg-main);
    border-color: var(--border-color);
    color: var(--text-primary);
    font-weight: 700;
    box-shadow: 0 2px 8px var(--shadow-alpha);
}

/* Content Viewport */
.ctx-hybrid-content-viewport {
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

/* Desktop/Tablet Pane Behavior */
@media (min-width: 768px) {
    .ctx-mobile-deck-hint { display: none !important; }
    .ctx-hybrid-card-pane {
        display: none;
        width: 100%;
        box-sizing: border-box;
    }
    .ctx-hybrid-card-pane.ctx-pane-active {
        display: block !important;
        animation: ctxPaneFadeIn 0.25s ease-out forwards;
    }
}

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

/* MOBILE VIEW: STRICT ACTIVE CARD ONLY (PREVENTS REFRESH BLEED) */
@media (max-width: 767px) {
    .ctx-desktop-tab-nav {
        display: none !important;
    }

    .ctx-mobile-deck-hint {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 8px 12px;
        margin-bottom: 10px;
        background: var(--bg-surface);
        border: 1px solid var(--border-color);
        border-radius: 10px;
        font-size: 0.82rem;
        font-weight: 700;
        color: var(--text-primary);
        user-select: none;
        cursor: grab;
        touch-action: pan-x;
    }

    .ctx-hybrid-content-viewport {
        display: grid;
        grid-template-columns: 1fr;
        align-items: start;
        padding-bottom: 0 !important;
    }

    .ctx-hybrid-card-pane {
        grid-area: 1 / 1;
        width: 100%;
        box-sizing: border-box;
        transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.25), opacity 0.3s ease;
        will-change: transform, opacity;
    }

    /* ACTIVE TOP CARD ONLY */
    .ctx-hybrid-card-pane.is-top {
        z-index: 10 !important;
        transform: translateX(0) rotate(0deg);
        opacity: 1 !important;
        visibility: visible !important;
        display: block !important;
        pointer-events: auto !important;
    }

    /* INACTIVE CARDS: Completely hidden from DOM rendering */
    .ctx-hybrid-card-pane:not(.is-top) {
        z-index: 0 !important;
        opacity: 0 !important;
        visibility: hidden !important;
        display: none !important;
        pointer-events: none !important;
    }

    .ctx-hybrid-card-pane.is-dragging {
        transition: none !important;
    }
}

/* Stripped Inner Sub-Cards */
.ctx-stripped-card .clinical-card-header { display: none !important; }
.ctx-stripped-card > .clinical-card-container { 
    border: none !important; box-shadow: none !important; 
    margin: 0 !important; padding: 0 !important; 
    background: transparent !important; border-radius: 0 !important; 
    width: 100% !important; box-sizing: border-box !important; 
}

/* Mobile Deck Navigation Buttons */
.ctx-deck-nav-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.25);
    outline: none;
    user-select: none;
}

.ctx-deck-nav-btn:active {
    background: var(--bg-hover);
    border-color: var(--border-color);
    transform: scale(0.92);
}

.ctx-deck-nav-btn .material-symbols-rounded {
    font-size: 20px !important;
}

/* ==========================================================================
   SECTION 26: UNIFIED CARD FOOTER DATA SOURCE STYLING
   ========================================================================== */
.card-footer-source {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    opacity: 0.85;
}

.card-footer-source .material-symbols-rounded {
    font-size: 1rem;
    color: var(--accent-blue);
}

.source-text-mobile {
    display: none;
}

@media (max-width: 767px) {
    .source-text-desktop {
        display: none;
    }
    .source-text-mobile {
        display: inline;
    }
}

/* Reveal timestamp when hovering over the chat row */
.chat-row:hover .msg-timestamp {
    opacity: 1 !important;
}

/* ==========================================================================
   SECTION 27: UNIFIED ZERO STATE & DYNAMIC SUBTITLE ENGINE
   ========================================================================== */

/* Unified Centered Welcome Header */
.welcome-heading-block {
    position: relative;
    z-index: 1;
    text-align: center;
    margin-bottom: 24px;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.zero-state-ambient-bg {
    display: none !important;
}

/* Unified Zero State Viewport: Solid Centered Anchor (Zero Jitter) */
body.zero-state-active .main-workspace {
    justify-content: center !important;
    background-color: var(--bg-main) !important;
}

body.zero-state-active .content-viewport {
    flex: 0 0 auto !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    overflow: visible !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
}

body.zero-state-active .view-panel#zeroStateScreen {
    padding: 0 16px 12px 16px !important;
    margin: 0 auto !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    position: relative !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Centered Search Deck */
body.zero-state-active .input-panel-container {
    position: relative !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    padding: 0 16px 24px 16px !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    z-index: 10 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
}

.zero-state-sub-deck {
    width: 100%;
    text-align: center;
    margin-top: 12px;
}

.zero-state-sub-deck .sub-welcome {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0 auto;
    display: inline-block;
}

/* Hide Disclaimer on Zero State */
body.zero-state-active .input-disclaimer-text {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Minimalist Mobile Viewport Adjustments */
@media (max-width: 767px) {
    body.zero-state-active .welcome-heading {
        font-size: 2.1rem !important;
        margin-bottom: 4px !important;
    }
    body.zero-state-active .welcome-heading-block {
        margin-bottom: 14px !important;
    }
    /* Forces single-line wrap on mobile screens with responsive font scaling */
    .zero-state-sub-deck .sub-welcome {
        font-size: clamp(0.65rem, 3.1vw, 0.85rem) !important;
        white-space: nowrap !important;
        letter-spacing: -0.2px !important;
        line-height: 1.2 !important;
        max-width: 100% !important;
    }
}

/* ==========================================================================
   SECTION 28: FIRST LAUNCH FOOTER SUBTITLE
   ========================================================================== */

/* Positioned at bottom of viewport */
.zero-state-footer-subtitle {
    display: none;
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10;
    opacity: 0.8;
}

/* Display only when zero-state is active */
body.zero-state-active .zero-state-footer-subtitle {
    display: block !important;
}

/* Mobile responsive adjustments */
@media (max-width: 767px) {
    .zero-state-footer-subtitle {
        bottom: 16px;
        font-size: clamp(0.68rem, 3.2vw, 0.78rem) !important;
        max-width: 90% !important;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ==========================================================================
   SECTION 29: IPAD PORTRAIT NATIVE 0PX COLLAPSE OVERRIDE
   ========================================================================== */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {

    /* Show Top Navigation Hamburger Button */
    .menu-toggle-btn {
        display: flex !important;
        visibility: visible !important;
        border-radius: 12px !important;
    }

    /* When closed in portrait, collapse width to absolute left-side */
    .sidebar.collapsed {
        width: 0px !important;
        min-width: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        overflow: hidden !important;
        border: none !important;
    }

    /* Smoothly fade out left-side bar elements */
    .sidebar.collapsed #collapseSidebarBtn,
    .sidebar.collapsed .sidebar-brand-header {
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        padding: 0 !important;
        margin: 0 !important;
        transition: opacity 0.25s ease, visibility 0.25s ease, padding 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.25);
    }
}

/* Responsive Clinical Card Badge Display */
.ctx-cat-desktop {
    display: inline;
}
.ctx-cat-mobile {
    display: none;
}

@media (max-width: 767px) {
    .ctx-cat-desktop {
        display: none !important;
    }
    .ctx-cat-mobile {
        display: inline !important;
    }
}

/* ==========================================================================
   SECTION 30: INTERACTIONS ARCHITECTURE
   ========================================================================== */

/* Interaction Search & Dropdown Elements */
.inter-search-row {
    display: flex;
    margin-bottom: 24px;
    position: relative;
    height: auto !important;
    min-height: 48px;
    z-index: 9999;
}

.ctx-dropdown-menu,
.ctx-select-dropdown,
.ctx-source-popover,
[id$="_risk_mega_menu"],
[id$="_risk_autocomplete_dropdown"],
#lib_autocomplete_dropdown,
#inter_autocomplete_dropdown,
#cdss_specialty_dropdown,
#lib_mega_sort_menu,
#topNavOptionsMenu,
#chatContextMenu {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(24px) !important;
    -webkit-backdrop-filter: blur(24px) !important;
    border: 1px solid var(--glass-border) !important;
    box-shadow: 0 20px 60px var(--shadow-alpha) !important;
    z-index: 999999 !important;
}

.ctx-dropdown-menu {
    display: flex !important;
}

.ctx-dropdown-menu.hidden {
    display: none !important;
}

/* iOS Swipe & Touch Gesture Engine */
.ios-swipe-scroll {
    overflow-x: hidden !important;
    touch-action: none !important;
}

.ios-swipe-action,
.ios-swipe-spacer {
    display: none !important;
}

.swipe-trash-icon-wrapper {
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.25);
}

.drug-card-bouncy-delete {
    transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.25) !important;
}

/* Desktop Hover Actions */
.ctx-inter-action-trigger:hover .check-icon {
    opacity: 0 !important;
    transform: scale(0.85);
}

.ctx-inter-action-trigger:hover .close-icon {
    opacity: 1 !important;
    transform: scale(1);
}

.ctx-inter-action-trigger:hover {
    background: rgba(234, 67, 53, 0.1) !important;
    border-color: rgba(234, 67, 53, 0.3) !important;
}

/* Universal Clean Reset for Results Container */
#inter_results_target,
#inter_results_target.cdss-result-container {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin-top: 14px !important;
}

#inter_results_target ul,
#inter_results_target ol,
#inter_results_target li,
#inter_results_target .clinical-list,
#inter_results_target .clinical-list-item {
    list-style: none !important;
    list-style-type: none !important;
    margin-left: 0 !important;
    padding-left: 0 !important;
}

#inter_results_target li::before,
#inter_results_target li::marker,
#inter_results_target .clinical-list-item::before,
#inter_results_target .clinical-list-item::marker {
    display: none !important;
    content: none !important;
}

/* Google Gemini AI Overview Card Layout */
.inter-gemini-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.inter-gemini-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
    line-height: 1.3;
}

.inter-overview-text {
    font-size: 0.92rem;
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 14px;
    text-align: left;
}

.inter-overview-text b,
.inter-point-item b {
    color: var(--text-primary);
    font-weight: 600;
}

.inter-section-heading {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 12px 0 6px 0;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 6px;
}

.inter-point-item {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 6px;
    text-align: left;
    padding-left: 0;
}

.inter-triage-box {
    margin-top: 14px;
    padding: 12px 14px;
    background: var(--bg-surface);
    border: 1px dashed var(--border-color);
    border-radius: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    text-align: left;
}

/* Dual Summary & Full Content Switching */
.inter-card-full-content {
    display: none;
    animation: fadeIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.25);
}

.inter-alert-card.expanded .inter-card-summary-content {
    display: none !important;
}

.inter-alert-card.expanded .inter-card-full-content {
    display: block !important;
}

/* Right-Aligned Expansion Hyperlink */
.inter-toggle-link {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: var(--accent-blue);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none !important;
    transition: color 0.2s ease, opacity 0.2s ease;
    user-select: none;
}

.inter-toggle-link:hover {
    color: var(--text-primary) !important;
    text-decoration: none !important;
    opacity: 0.85;
}

/* Compact Summary High-Yield Chips */
.inter-summary-chip-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 8px;
}

.inter-summary-chip {
    font-size: 0.84rem;
    color: var(--text-secondary);
    line-height: 1.45;
    text-align: left;
    padding-left: 0;
}

/* Clean Drugs.com Source Hyperlink */
.inter-source-link {
    color: var(--accent-blue);
    text-decoration: none !important;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
    font-size: 0.75rem;
    transition: color 0.2s ease;
}

.inter-source-link:hover {
    color: var(--text-primary) !important;
}

.ctx-source-popover {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    width: 330px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 30px var(--shadow-alpha);
    padding: 12px;
    z-index: 10000;
    display: none;
    flex-direction: column;
    gap: 8px;
    box-sizing: border-box;
    animation: popoverFadeIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.25);
}

@keyframes popoverFadeIn {
    from { opacity: 0; transform: translateY(6px) scale(0.97); }
    to { opacity: 1; transform: translateY(0); }
}

.ctx-source-wrapper:hover .ctx-source-popover,
.ctx-source-wrapper.active .ctx-source-popover {
    display: flex !important;
}

.ctx-source-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.78rem;
    font-weight: 600;
    transition: all 0.15s ease;
}

.ctx-source-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    transform: translateX(2px);
}

/* Responsive Drug Matrix Tags */
.tag-text-desktop { display: inline !important; }
.tag-text-mobile { display: none !important; }

/* Mobile Viewport Rules */
@media (max-width: 767px) {
    .inter-search-row {
        height: auto !important;
        min-height: 44px !important;
        margin-bottom: 16px !important;
    }
    
    #interactions_global_badge:not(.hidden) { 
        width: 32px !important; 
        height: 32px !important;
        min-width: 32px !important; 
        padding: 0 !important; 
        border-radius: 8px !important; 
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .ctx-inter-action-trigger {
        display: none !important;
    }
    
    .ios-swipe-scroll { 
        overflow-x: auto !important; 
        scroll-snap-type: x mandatory !important; 
        -webkit-overflow-scrolling: touch !important; 
        scrollbar-width: none !important; 
        scroll-behavior: smooth !important;
        overscroll-behavior-x: contain !important;
        touch-action: pan-x !important;
    }
    .ios-swipe-scroll::-webkit-scrollbar {
        display: none !important;
    }
    .ios-swipe-action {
        display: flex !important;
    }
    .ios-swipe-spacer {
        display: block !important;
    }
    .ios-swipe-action:active .swipe-trash-icon-wrapper {
        transform: scale(0.8);
    }

    .inter-alert-card {
        padding: 14px 14px !important;
        margin-bottom: 12px !important;
        border-radius: 12px !important;
    }
    .inter-gemini-title {
        font-size: 0.92rem !important;
    }
    .inter-overview-text {
        font-size: 0.86rem !important;
        line-height: 1.5 !important;
    }
    .inter-section-heading {
        font-size: 0.82rem !important;
    }
    .inter-point-item {
        font-size: 0.82rem !important;
        line-height: 1.45 !important;
    }
    .inter-triage-box {
        font-size: 0.8rem !important;
        padding: 10px 12px !important;
    }
    .ctx-source-popover {
        width: 280px !important;
        left: 0 !important;
    }
    
    .tag-text-desktop, .badge-text-desktop {
        display: none !important;
    }
    .tag-text-mobile, .badge-text-mobile {
        display: inline !important;
    }
}

@media (min-width: 768px) {
    .badge-text-desktop {
        display: inline !important;
    }
    .badge-text-mobile {
        display: none !important;
    }
}

/* ==========================================================================
   2-LINE STYLE ASK CORTEXA INPUT DECK
   ========================================================================== */
.ctx-deck-bottom-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
    margin-top: 2px;
}

.ctx-deck-tools-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.ctx-deck-tools-right {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

/* Tool Pill Buttons (Think & Search - Symmetrical & Seamless Single-Unit Animation) */
.ctx-deck-tool-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 33px;
    width: 92px;          /* Identical width for Desktop */
    min-width: 92px;
    padding: 0 8px;
    border-radius: 17px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    box-sizing: border-box;
    gap: 6.5px;
    flex-shrink: 0;
}

/* Vector Sizing (No separate transforms or jitter) */
.ctx-deck-tool-pill .ctx-pill-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    pointer-events: none;
    display: block;
}

.ctx-deck-tool-pill:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-secondary);
    transform: translateY(-0.5px);
}

.ctx-deck-tool-pill:active {
    transform: scale(0.96);
}

.ctx-think-toggle-btn.active {
    background: rgba(66, 133, 244, 0.12);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    box-shadow: 0 0 12px rgba(66, 133, 244, 0.15);
}

.ctx-search-toggle-btn.active {
    background: rgba(52, 168, 83, 0.12);
    border-color: var(--clinical-success);
    color: var(--clinical-success);
    box-shadow: 0 0 12px rgba(52, 168, 83, 0.15);
}

/* Mobile Layout */
@media (max-width: 767px) {
    .input-wrapper-matrix {
        padding: 10px 12px 8px 14px !important;
        border-radius: 18px !important;
    }
    .ctx-deck-tool-pill {
        height: 29px;
        width: 82px;      /* Identical width for Mobile */
        min-width: 82px;
        padding: 0 6px;
        font-size: 0.77rem;
        gap: 5.5px;
    }
    .ctx-deck-tool-pill .ctx-pill-icon {
        width: 14.5px;
        height: 14.5px;
    }
}

/* ==========================================================================
   CORTEXA DYNAMIC LOADER & TYPEWRITER ENGINE
   ========================================================================== */
.cortexa-loader-row { display: flex; align-items: center; gap: 12px; padding: 8px 4px; width: 100%; }
.typing-pulse-container { display: inline-flex; gap: 5px; align-items: center; height: 20px; flex-shrink: 0; }
.pulse-dot { width: 6px; height: 6px; background-color: var(--text-primary); border-radius: 50%; animation: smoothWave 1.2s infinite ease-in-out; }
.pulse-dot:nth-child(1) { animation-delay: 0s; }
.pulse-dot:nth-child(2) { animation-delay: 0.18s; }
.pulse-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes smoothWave { 0%, 100% { transform: translateY(2px); opacity: 0.35; } 50% { transform: translateY(-4px); opacity: 1; } }

.cortexa-loading-status-text { font-size: 0.88rem; font-weight: 500; color: var(--text-secondary); transition: opacity 0.2s ease; white-space: nowrap; }

/* --- GLOBAL SVG ROTATION --- */
.footer-nav-btn:hover .advisor-animated-icon,
.footer-nav-btn.active .advisor-animated-icon,
.footer-nav-btn:hover .library-animated-icon,
.footer-nav-btn.active .library-animated-icon,
.footer-nav-btn:hover .interaction-animated-icon,
.footer-nav-btn.active .interaction-animated-icon,
.footer-nav-btn:hover .analysis-animated-icon,
.footer-nav-btn.active .analysis-animated-icon {
    transform: none !important;
}

/* --- SYSTEM SETTINGS ANIMATION (GEAR SPIN) --- */
#settingsNavBtn svg,
#settingsToggleBtn svg,
.footer-nav-btn[data-action="settings"] svg,
.settings-animated-icon {
    pointer-events: none;
    overflow: visible !important;
    transform-box: fill-box !important;
    transform-origin: center center !important;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), color var(--transition-smooth) !important;
    will-change: transform;
}

/* Material Symbols version if Settings uses a <span> instead of an SVG */
#settingsNavBtn .material-symbols-rounded,
#settingsToggleBtn .material-symbols-rounded,
.footer-nav-btn[data-action="settings"] .material-symbols-rounded {
    display: inline-flex !important;
    transform-origin: center center !important;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), color var(--transition-smooth) !important;
    will-change: transform;
}

/* Trigger 60-degree gear turn on hover */
#settingsNavBtn:hover svg,
#settingsToggleBtn:hover svg,
.footer-nav-btn[data-action="settings"]:hover svg,
.footer-nav-btn:hover .settings-animated-icon,
#settingsNavBtn:hover .material-symbols-rounded,
#settingsToggleBtn:hover .material-symbols-rounded,
.footer-nav-btn[data-action="settings"]:hover .material-symbols-rounded {
    transform: rotate(60deg) !important;
    color: var(--text-primary) !important;
}

/* --- CLINICAL ANALYSIS SMART SCAN ANIMATION --- */
@keyframes scanLensAnim {
    0% { transform: translate(0, 0); }
    33% { transform: translate(-5px, -3px); }
    66% { transform: translate(-2px, 3px); }
    100% { transform: translate(0, 0); }
}

/* Animates ONLY the magnifying glass once per mouse hover */
.footer-nav-btn:hover .analysis-animated-icon .ana-scan-glass {
    animation: scanLensAnim 1.2s ease-in-out 1 forwards;
    transform-origin: center;
}

/* 1. Neutralize global SVG rotation override for the animated icons */
.footer-nav-btn:hover svg.advisor-animated-icon {
    transform: none !important;
}

/* 2. Lock SVG element coordinate space & enable pointer inheritance */
.advisor-animated-icon {
    pointer-events: none; /* Passes hover cleanly to .footer-nav-btn */
    overflow: visible !important;
}

.advisor-animated-icon .advisor-cross,
.advisor-animated-icon .advisor-spikes {
    transform-box: fill-box !important;
    transform-origin: center center !important;
    will-change: transform, opacity;
}

.advisor-animated-icon .advisor-cross {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.advisor-animated-icon .advisor-spikes {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease !important;
}

/* 3. Pure Hover Trigger (Scoped strictly to button hover) */
.footer-nav-btn:hover .advisor-animated-icon .advisor-cross {
    transform: rotate(180deg) !important;
}

.footer-nav-btn:hover .advisor-animated-icon .advisor-spikes {
    opacity: 0 !important;
    transform: scale(0.6) rotate(45deg) !important;
}

/* --- MEDICAL LIBRARY ANIMATION (STRICTLY HOVER ONLY) --- */
.library-animated-icon .book-text {
    stroke-dasharray: 6;
    stroke-dashoffset: 6;
    opacity: 0;
    transition: stroke-dashoffset 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
}
.library-animated-icon .text-left { transition-delay: 0s; }
.library-animated-icon .text-right { transition-delay: 0.1s; }

/* Trigger lines drawing strictly on hover */
.footer-nav-btn:hover .library-animated-icon .book-text {
    stroke-dashoffset: 0;
    opacity: 1;
    transition: stroke-dashoffset 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
}

.footer-nav-btn:hover .library-animated-icon .text-right {
    transition-delay: 0.15s;
}

/* --- INTERACTION CHECKER ANIMATION --- */
.interaction-animated-icon .potion-fluid-group {
    transform-origin: center bottom;
    transform: translateY(6px); /* Strictly translates upwards (fills), no scale/rotate */
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.interaction-animated-icon .potion-bubble {
    opacity: 0;
    transform: translateY(4px);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.footer-nav-btn:hover .interaction-animated-icon .potion-fluid-group,
.footer-nav-btn.active .interaction-animated-icon .potion-fluid-group {
    transform: translateY(0);
    opacity: 1;
}
.footer-nav-btn:hover .interaction-animated-icon .bubble-1,
.footer-nav-btn.active .interaction-animated-icon .bubble-1 {
    opacity: 1;
    transform: translateY(-3px);
    transition-delay: 0.1s;
}
.footer-nav-btn:hover .interaction-animated-icon .bubble-2,
.footer-nav-btn.active .interaction-animated-icon .bubble-2 {
    opacity: 1;
    transform: translateY(-5px);
    transition-delay: 0.2s;
}
.footer-nav-btn:hover .interaction-animated-icon .bubble-3,
.footer-nav-btn.active .interaction-animated-icon .bubble-3 {
    opacity: 1;
    transform: translateY(-2px);
    transition-delay: 0.15s;
}

/* --- NEW CHAT ANIMATION --- */
.new-chat-animated-icon .new-chat-line {
    stroke-dasharray: 10;
    stroke-dashoffset: 10;
    opacity: 0;
    transition: stroke-dashoffset 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}
.new-chat-animated-icon .new-chat-pen {
    transform-origin: center;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-action-pill-btn:hover .new-chat-animated-icon .new-chat-line,
.sidebar-action-pill-btn.active .new-chat-animated-icon .new-chat-line {
    stroke-dashoffset: 0;
    opacity: 1;
}
.sidebar-action-pill-btn:hover .new-chat-animated-icon .new-chat-pen,
.sidebar-action-pill-btn.active .new-chat-animated-icon .new-chat-pen {
    transform: translateX(-1px) translateY(-1px);
}


/* --- SEARCH CHATS ANIMATION (LINES INSIDE - HOVER ONLY) --- */
.sidebar-action-pill-btn:hover .search-animated-icon {
    transform: none !important;
    animation: none !important;
}

.search-animated-icon .search-data-line {
    stroke-dasharray: 8;
    stroke-dashoffset: 8;
    opacity: 0;
    transition: stroke-dashoffset 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
}

.search-animated-icon .line-1 { transition-delay: 0s; }
.search-animated-icon .line-2 { transition-delay: 0.1s; }
.search-animated-icon .line-3 { stroke-dasharray: 5; stroke-dashoffset: 5; transition-delay: 0.2s; }

/* Trigger animation STRICTLY on hover */
.sidebar-action-pill-btn:hover .search-animated-icon .search-data-line {
    stroke-dashoffset: 0;
    opacity: 1;
    transition: stroke-dashoffset 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
}

.sidebar-action-pill-btn:hover .search-animated-icon .line-1 { transition-delay: 0s; }
.sidebar-action-pill-btn:hover .search-animated-icon .line-2 { transition-delay: 0.1s; }
.sidebar-action-pill-btn:hover .search-animated-icon .line-3 { transition-delay: 0.2s; }

/* ==========================================================================
   CORTEXA AI — CONSOLIDATED CORE & CLINICAL COMPONENT STYLES
   ========================================================================== */

/* 1. Category Tag Responsive Rules */
.ctx-cat-desktop { display: inline !important; }
.ctx-cat-mobile { display: none !important; }
@media (max-width: 767px) {
    .ctx-cat-desktop { display: none !important; }
    .ctx-cat-mobile { display: inline !important; }
}

/* 2. Theme-Aware Custom Modal Overlay */
.ctx-modal-overlay { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0, 0, 0, 0.4); 
    backdrop-filter: blur(8px); 
    -webkit-backdrop-filter: blur(8px); 
    z-index: 9999999; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    opacity: 0; 
    transition: opacity 0.25s ease; 
    padding: 20px; 
    box-sizing: border-box; 
}
.ctx-modal-box { 
    background: var(--bg-main); 
    border: 1px solid var(--border-color); 
    border-radius: 16px; 
    width: 100%; 
    max-width: 420px; 
    padding: 24px; 
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4); 
    transform: translateY(15px) scale(0.95); 
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); 
    box-sizing: border-box; 
    max-height: 90vh; 
    overflow-y: auto; 
}
.ctx-modal-input { 
    width: 100%; 
    box-sizing: border-box; 
    padding: 12px; 
    margin-top: 14px; 
    background: var(--bg-surface); 
    border: 1px solid var(--border-color); 
    border-radius: 8px; 
    color: var(--text-primary); 
    outline: none; 
    font-family: monospace; 
    font-size: 1rem; 
    transition: border-color 0.2s; 
}
.ctx-modal-input:focus { border-color: var(--accent-blue); }
.ctx-modal-btn { 
    padding: 10px 18px; 
    border: none; 
    font-weight: 600; 
    cursor: pointer; 
    border-radius: 8px; 
    transition: all 0.2s; 
    font-family: inherit; 
}
.ctx-modal-btn-cancel { 
    background: var(--bg-surface); 
    color: var(--text-primary); 
    border: 1px solid var(--border-color); 
}
.ctx-modal-btn-cancel:hover { background: var(--bg-hover); }
.ctx-modal-btn-confirm { 
    background: var(--accent-blue); 
    color: #fff; 
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); 
}
.ctx-modal-btn-confirm:hover { opacity: 0.9; }
.ctx-modal-btn-danger { 
    background: var(--clinical-alert); 
    color: #fff; 
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); 
}
.ctx-modal-btn-danger:hover { opacity: 0.9; }
.ctx-modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 28px; }

@media (max-width: 768px) {
    .ctx-modal-overlay { padding: 12px; }
    .ctx-modal-box { padding: 18px; border-radius: 12px; max-width: 100%; width: 100%; margin: auto; }
    .ctx-modal-actions { flex-direction: column-reverse; gap: 10px; margin-top: 20px; }
    .ctx-modal-btn { width: 100%; padding: 14px; text-align: center; font-size: 0.95rem; border-radius: 8px; min-height: 48px; display: flex; align-items: center; justify-content: center; }
    .ctx-modal-input { padding: 14px; font-size: 0.95rem; }
}

/* 3. Medico-Legal Gateway (ToS) */
.ctx-tos-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); z-index: 999999; display: flex; align-items: center; justify-content: center; padding: 20px; box-sizing: border-box; opacity: 0; transition: opacity 0.3s ease; }
.ctx-tos-card { max-width: 600px; width: 100%; max-height: 85vh; display: flex; flex-direction: column; background: var(--bg-main); border: 1px solid var(--border-color); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,0.5); overflow: hidden; transform: translateY(20px); transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }
.ctx-tos-hdr { padding: 24px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; gap: 12px; }
.ctx-tos-icn { color: var(--clinical-alert); font-size: 2rem; flex-shrink: 0; }
.ctx-tos-ttl { margin: 0; font-size: 1.25rem; color: var(--text-primary); line-height: 1.2; }
.ctx-tos-sub { margin: 4px 0 0 0; font-size: 0.8rem; color: var(--text-secondary); }
.ctx-tos-bdy { padding: 24px; overflow-y: auto; flex: 1; font-size: 0.85rem; color: var(--text-secondary); line-height: 1.6; }
.ctx-tos-ftr { padding: 16px 24px; border-top: 1px solid var(--border-color); background: var(--bg-surface); display: flex; justify-content: flex-end; gap: 12px; }
.ctx-tos-btn-dec { padding: 10px 16px; border: 1px solid var(--border-color); background: transparent; color: var(--text-primary); border-radius: 6px; cursor: pointer; font-weight: 600; font-family: inherit; transition: background 0.2s; }
.ctx-tos-btn-acc { padding: 10px 24px; background: var(--accent-blue); border: none; color: white; border-radius: 6px; cursor: pointer; font-weight: 600; box-shadow: 0 4px 12px rgba(66,133,244,0.3); font-family: inherit; transition: opacity 0.2s; }
.ctx-tos-btn-dec:hover { background: var(--bg-hover); }
.ctx-tos-btn-acc:hover { opacity: 0.9; }

@media (max-width: 768px) {
    .ctx-tos-hdr { padding: 16px; gap: 10px; }
    .ctx-tos-icn { font-size: 1.6rem; }
    .ctx-tos-ttl { font-size: 1.1rem; }
    .ctx-tos-sub { font-size: 0.75rem; }
    .ctx-tos-bdy { padding: 16px; font-size: 0.8rem; line-height: 1.5; }
    .ctx-tos-ftr { padding: 16px; flex-direction: column-reverse; gap: 10px; }
    .ctx-tos-btn-dec, .ctx-tos-btn-acc { width: 100%; padding: 14px; text-align: center; border-radius: 8px; font-size: 0.95rem; }
}

/* 4. Letter Animation (ML3 Subtitle) */
.ml3-word { display: inline-block; white-space: nowrap; overflow: hidden; vertical-align: bottom; text-align: left; min-width: 9.5ch; }
.ml3-letter { display: inline-block; line-height: 1em; opacity: 0; transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1); }
.ml3-letter.in { opacity: 1; }
.ml3-letter.out { opacity: 0; transition: opacity 0.4s ease; }

/* 5. Input Deck, Attachment Cards & Floating Popover */
.ctx-no-copy-badge { display: inline-block !important; }
.ctx-no-copy-badge::after { content: attr(data-pct) "%"; }

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.35; }
    50% { transform: scale(1.25); opacity: 1; }
}

@keyframes ctxPulseColorBoth {
    0%, 100% { background-color: var(--accent-blue, #4285f4); }
    50% { background-color: var(--clinical-success, #34a853); }
}
@keyframes ctxMicPulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.18); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}
.ctx-mic-active { color: var(--clinical-alert, #ea4335) !important; animation: ctxMicPulse 1.2s infinite ease-in-out !important; }
.typing-pulse-container.pulse-mode-think .pulse-dot { background-color: var(--accent-blue, #4285f4) !important; }
.typing-pulse-container.pulse-mode-search .pulse-dot { background-color: var(--clinical-success, #34a853) !important; }
.typing-pulse-container.pulse-mode-both .pulse-dot {
    animation-name: pulse, ctxPulseColorBoth !important;
    animation-duration: 1.4s, 2s !important;
    animation-iteration-count: infinite, infinite !important;
    animation-timing-function: ease-in-out, ease-in-out !important;
}

/* Multi-row Search Bar: Expands vertically to host files and wraps text into clean rows */
.input-wrapper-matrix {
    width: 100% !important;
    max-width: 760px !important;
    background-color: var(--bg-input) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 24px !important;
    padding: 8px 14px !important;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important; /* Perfect vertical alignment for buttons and text */
    justify-content: space-between !important;
    gap: 6px 10px !important;
    box-shadow: 0 4px 18px var(--shadow-alpha);
    border: 1px solid var(--border-color);
    box-sizing: border-box !important;
    position: relative !important;
    pointer-events: auto !important;
    min-height: 52px !important;
    height: auto !important;
}

/* Upper Attachment Bar container */
.ctx-attached-files-bar {
    width: 100% !important;
    flex: 0 0 100% !important;
    order: 1 !important;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 6px 4px 10px 4px !important;
    margin-bottom: 4px !important;
    border-bottom: 1px solid var(--border-color) !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    box-sizing: border-box !important;
}
.ctx-attached-files-bar::-webkit-scrollbar { display: none !important; }
.ctx-attached-files-bar:empty {
    display: none !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
}

/* Plus Button (+) */
.ctx-deck-plus-btn {
    order: 2 !important;
    flex: 0 0 38px !important;
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    align-self: center !important;
}

/* Input Field Container Wrapper */
.input-wrapper-matrix .input-field-container {
    order: 3 !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    width: auto !important;
    display: flex !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* Textarea: Forces text into multiple rows (wrapping) and stops horizontal scrolling */
.input-wrapper-matrix textarea#chatInputPayload {
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 24px !important;
    max-height: 140px !important;
    line-height: 24px !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    color: var(--text-primary) !important;
    font-size: 16px !important;
    font-family: inherit !important;
    padding: 0 !important;
    margin: 0 !important;
    resize: none !important;
    display: block !important;
    box-sizing: border-box !important;
    white-space: pre-wrap !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    field-sizing: content; /* Modern auto-expand feature */
    align-self: center !important;
}

/* Placeholder styling */
.input-wrapper-matrix textarea#chatInputPayload::placeholder {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 24px !important;
}

/* Submit Button */
.input-wrapper-matrix .submit-prompt-btn {
    order: 4 !important;
    flex: 0 0 38px !important;
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 0 0 auto !important;
    align-self: center !important;
}

/* Row 2: Submit / Stop / Mic Button */
.submit-prompt-btn {
    order: 4 !important;
    flex: 0 0 38px !important;
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Image Thumbnail Card (Square with floating close button, identical to Gemini/ChatGPT) */
.ctx-gemini-file-card.ctx-file-img {
    width: 96px !important;
    min-width: 96px !important;
    max-width: 96px !important;
    height: 96px !important;
    min-height: 96px !important;
    max-height: 96px !important;
    border-radius: 16px !important;
    position: relative !important;
    border: 1px solid var(--border-color) !important;
    background: var(--bg-surface) !important;
    box-shadow: 0 4px 12px var(--shadow-alpha, rgba(0,0,0,0.12)) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 4px 4px 2px 0 !important;
    animation: fadeIn 0.2s ease !important;
}

.ctx-gemini-thumb-img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    border-radius: 11px !important;
}

.ctx-gemini-file-card.ctx-file-img .ctx-gemini-file-close.floating-close {
    position: absolute !important;
    top: -5px !important;
    right: -5px !important;
    width: 18px !important;
    height: 18px !important;
    border-radius: 50% !important;
    background: rgba(20, 20, 20, 0.88) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    backdrop-filter: blur(4px);
    transition: transform 0.15s, background 0.15s !important;
    z-index: 10 !important;
}

.ctx-gemini-file-card.ctx-file-img .ctx-gemini-file-close.floating-close:hover {
    background: var(--clinical-alert, #ea4335) !important;
    transform: scale(1.15) !important;
}

/* Document & Lab Report Card */
.ctx-gemini-file-card.ctx-file-doc {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 12px !important;
    padding: 6px 10px !important;
    width: 160px !important;
    min-width: 160px !important;
    max-width: 180px !important;
    height: 50px !important;
    min-height: 50px !important;
    max-height: 50px !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    position: relative !important;
    animation: fadeIn 0.2s ease !important;
    box-shadow: 0 2px 6px var(--shadow-alpha, rgba(0,0,0,0.08)) !important;
    margin: 4px 4px 2px 0 !important;
}

.ctx-gemini-file-card.ctx-file-doc .ctx-gemini-file-icon {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    border-radius: 8px !important;
    background: rgba(66, 133, 244, 0.12) !important;
    color: var(--accent-blue) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
}

.ctx-gemini-file-card.ctx-file-doc .ctx-gemini-file-info {
    display: flex !important;
    flex-direction: column !important;
    min-width: 0 !important;
    flex: 1 !important;
}

.ctx-gemini-file-card.ctx-file-doc .ctx-gemini-file-name {
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    color: var(--text-primary) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.2 !important;
}

.ctx-gemini-file-card.ctx-file-doc .ctx-gemini-file-meta {
    font-size: 0.65rem !important;
    color: var(--text-secondary) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.35px !important;
    margin-top: 2px !important;
    line-height: 1.2 !important;
}

.ctx-gemini-file-card.ctx-file-doc .ctx-gemini-file-close {
    background: transparent !important;
    border: none !important;
    color: var(--text-secondary) !important;
    cursor: pointer !important;
    padding: 2px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
    transition: color 0.15s, background 0.15s !important;
}

.ctx-gemini-file-card.ctx-file-doc .ctx-gemini-file-close:hover {
    color: var(--clinical-alert, #ea4335) !important;
    background: var(--bg-hover) !important;
}

/* Interactive Document Cards in Chat Body */
.ctx-chat-msg-files-container { display: flex !important; flex-wrap: wrap !important; gap: 8px !important; margin-top: 8px !important; width: 100% !important; box-sizing: border-box !important; }
.ctx-chat-gemini-card {
    display: inline-flex !important;
    align-items: center !important;
    gap: 10px !important;
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 12px !important;
    padding: 8px 12px !important;
    min-width: 180px !important;
    max-width: 280px !important;
    box-sizing: border-box !important;
    box-shadow: 0 2px 8px var(--shadow-alpha, rgba(0,0,0,0.06)) !important;
    transition: transform 0.2s ease, border-color 0.2s ease !important;
}
.ctx-chat-gemini-card:hover { border-color: var(--accent-blue) !important; transform: translateY(-1px) !important; }
.ctx-chat-gemini-icon {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    border-radius: 8px !important;
    background: rgba(66, 133, 244, 0.12) !important;
    color: var(--accent-blue) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    overflow: hidden !important;
}
.ctx-chat-gemini-thumb { width: 100% !important; height: 100% !important; object-fit: cover !important; }
.ctx-chat-gemini-info { display: flex !important; flex-direction: column !important; min-width: 0 !important; flex: 1 !important; }
.ctx-chat-gemini-name { font-size: 0.82rem !important; font-weight: 700 !important; color: var(--text-primary) !important; overflow: hidden !important; text-overflow: ellipsis !important; white-space: nowrap !important; line-height: 1.25 !important; }
.ctx-chat-gemini-meta { font-size: 0.68rem !important; color: var(--text-secondary) !important; text-transform: uppercase !important; letter-spacing: 0.35px !important; line-height: 1.2 !important; margin-top: 2px !important; font-weight: 600 !important; }

/* Deck Plus Button & Popover */
.ctx-deck-plus-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    border-radius: 8px !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    color: var(--text-secondary) !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}
.ctx-deck-plus-btn:hover { background: transparent !important; color: var(--text-primary) !important; }
.ctx-deck-plus-btn.is-active { transform: rotate(45deg) !important; color: var(--clinical-alert, #ea4335) !important; background: transparent !important; border: none !important; }

.ctx-deck-attach-menu {
    position: absolute !important;
    bottom: calc(100% + 10px) !important;
    left: 8px !important;
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35) !important;
    padding: 6px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    z-index: 999999 !important;
    min-width: 190px !important;
    animation: fadeIn 0.18s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
}
.ctx-deck-attach-menu.hidden { display: none !important; }
.ctx-deck-menu-item {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 8px 12px !important;
    border-radius: 8px !important;
    background: transparent !important;
    border: 1px solid transparent !important;
    color: var(--text-primary) !important;
    font-family: inherit !important;
    font-size: 0.86rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    width: 100% !important;
    text-align: left !important;
    box-sizing: border-box !important;
}
.ctx-deck-menu-item:hover { background: var(--bg-hover) !important; }
.ctx-deck-menu-item.active-think { background: rgba(66, 133, 244, 0.12) !important; color: var(--accent-blue) !important; border-color: rgba(66, 133, 244, 0.35) !important; }
.ctx-deck-menu-item.active-search { background: rgba(52, 168, 83, 0.12) !important; color: var(--clinical-success) !important; border-color: rgba(52, 168, 83, 0.35) !important; }
.ctx-deck-menu-item.active-analyze { background: rgba(155, 81, 224, 0.12) !important; color: #9b51e0 !important; border-color: rgba(155, 81, 224, 0.35) !important; }
.ctx-deck-menu-item .material-symbols-rounded, .ctx-deck-menu-item svg { width: 20px !important; height: 20px !important; min-width: 20px !important; max-width: 20px !important; font-size: 20px !important; line-height: 1 !important; display: inline-flex !important; align-items: center !important; justify-content: center !important; flex-shrink: 0 !important; margin: 0 !important; padding: 0 !important; }

/* 6. Advisory Card Headers & Risk Tags */
.ctx-adv-header { display: flex; flex-direction: row; align-items: flex-start; justify-content: space-between; gap: 8px; flex-wrap: nowrap !important; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; margin-bottom: 10px; width: 100%; box-sizing: border-box; }
.ctx-adv-title { font-weight: 700; color: var(--text-primary); font-size: 0.95rem; line-height: 1.25; flex: 1; min-width: 0; margin: 0; word-break: break-word; }
.ctx-adv-badge { display: inline-flex; align-items: center; justify-content: center; font-size: 0.62rem; font-weight: 800; border-radius: 4px; height: 20px; padding: 0 6px; flex-shrink: 0; margin-top: 1px; white-space: nowrap; letter-spacing: 0.3px; }

@media (max-width: 767px) {
    .ctx-adv-header { padding-bottom: 8px !important; margin-bottom: 8px !important; gap: 6px !important; }
    .ctx-adv-title { font-size: 0.86rem !important; line-height: 1.2 !important; }
    .ctx-adv-badge { height: 18px !important; font-size: 0.58rem !important; padding: 0 5px !important; }
    .ctx-mobile-spacer-right { display: block !important; flex: 1 1 0% !important; }
}

.ctx-dropdown-menu { display: flex !important; }
.ctx-dropdown-menu.hidden { display: none !important; }
.ctx-risk-action-btn { cursor: pointer; display: inline-flex; align-items: center; justify-content: center; height: 32px; border-radius: 6px; position: relative; flex-shrink: 0; transition: all 0.2s; overflow: hidden; margin-left: 12px; }
.ctx-risk-action-btn .risk-tag-text { font-size: 0.75rem; font-weight: 800; position: absolute; transition: opacity 0.2s, transform 0.2s; }
.ctx-risk-action-btn .risk-hover-text { font-size: 0.75rem; font-weight: 800; position: absolute; opacity: 0; transition: opacity 0.2s, transform 0.2s; transform: scale(0.8); }
.ctx-risk-action-btn .risk-hover-icon { font-size: 1.25rem; position: absolute; opacity: 0; transition: opacity 0.2s, transform 0.2s; transform: scale(0.8); }

@media (min-width: 768px) {
    .ctx-risk-action-btn { width: 68px; }
    .risk-mobile-tag, .risk-mobile-icon { display: none !important; }
    .risk-mobile-label { display: none !important; }
    .ctx-risk-action-btn.is-remove:hover { background: rgba(234, 67, 53, 0.1) !important; border-color: rgba(234, 67, 53, 0.3) !important; }
    .ctx-risk-action-btn.is-remove:hover .risk-hover-text { opacity: 1; transform: scale(1); color: var(--clinical-alert); }
    .ctx-risk-action-btn.is-add:hover { background: rgba(52, 168, 83, 0.1) !important; border-color: rgba(52, 168, 83, 0.3) !important; }
    .ctx-risk-action-btn.is-add:hover .risk-hover-text { opacity: 1; transform: scale(1); color: var(--clinical-success); }
    .ctx-risk-action-btn:hover .risk-tag-text { opacity: 0; transform: scale(0.8); }
    .ctx-desktop-ring { max-width: 140px !important; margin-bottom: 8px !important; }
    .ctx-desktop-pct { font-size: 1.7rem !important; }
    .ctx-desktop-label { font-size: 1.05rem !important; }
    .ctx-desktop-sub { font-size: 0.85rem !important; }
    .cdss-rerun-full-text { display: inline !important; }
    .cdss-rerun-mobile-text { display: none !important; }
    .cdss-rerun-btn-text { display: inline !important; }
}

@media (max-width: 767px) {
    .ctx-risk-action-btn { width: 32px; }
    .risk-desktop-tag, .risk-desktop-text { display: none !important; }
    .risk-desktop-label { display: none !important; }
    .ctx-risk-action-btn.is-remove:hover, .ctx-risk-action-btn.is-remove:active { background: rgba(234, 67, 53, 0.1) !important; border-color: rgba(234, 67, 53, 0.3) !important; }
    .ctx-risk-action-btn.is-remove:hover .risk-hover-icon, .ctx-risk-action-btn.is-remove:active .risk-hover-icon { opacity: 1; transform: scale(1); color: var(--clinical-alert); }
    .ctx-risk-action-btn.is-add:hover, .ctx-risk-action-btn.is-add:active { background: rgba(52, 168, 83, 0.1) !important; border-color: rgba(52, 168, 83, 0.3) !important; }
    .ctx-risk-action-btn:hover .risk-tag-text, .ctx-risk-action-btn:active .risk-tag-text { opacity: 0; transform: scale(0.8); }
    
    #cdss_search_action_btn { width: 32px !important; min-width: 32px !important; padding: 0 !important; flex-shrink: 0 !important; }
    .cdss-search-text { display: none !important; }
    .cdss-search-icon { display: block !important; }
    .cdss-rerun-full-text { display: none !important; }
    .cdss-rerun-mobile-text { display: inline !important; }
    .cdss-rerun-btn-text { display: none !important; }
    .cdss-rerun-btn { padding: 8px 10px !important; }
    #lib_global_badge:not(.hidden) { width: 32px !important; padding: 0 !important; border-radius: 8px !important; }
}

/* 7. Drug Interaction Card Headers */
.inter-gemini-header { display: flex !important; flex-direction: row !important; align-items: flex-start !important; justify-content: space-between !important; gap: 8px !important; flex-wrap: nowrap !important; margin-bottom: 10px !important; width: 100% !important; box-sizing: border-box !important; }
.inter-gemini-title { font-weight: 700 !important; color: var(--text-primary) !important; font-size: 0.95rem !important; line-height: 1.25 !important; flex: 1 !important; min-width: 0 !important; margin: 0 !important; word-break: break-word !important; }
.inter-gemini-badge { display: inline-flex !important; align-items: center !important; justify-content: center !important; font-size: 0.62rem !important; font-weight: 800 !important; border-radius: 4px !important; height: 20px !important; padding: 0 6px !important; flex-shrink: 0 !important; margin-top: 1px !important; white-space: nowrap !important; letter-spacing: 0.3px !important; }
@media (max-width: 767px) {
    .inter-gemini-header { margin-bottom: 8px !important; gap: 6px !important; }
    .inter-gemini-title { font-size: 0.86rem !important; line-height: 1.2 !important; }
    .inter-gemini-badge { height: 18px !important; font-size: 0.58rem !important; padding: 0 5px !important; }
}

/* ==========================================================================
   SECTION 31: CLINICAL ANALYSIS SUITE 1:1 SIZE & MATRIX PARITY
   ========================================================================== */
.analysis-search-bar-wrapper {
    min-height: 48px !important;
    height: auto !important;
    padding: 0 8px !important;
    border-radius: 12px !important;
    background-color: var(--bg-input) !important;
    border: 1px solid var(--border-color) !important;
    transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth) !important;
}

.analysis-search-bar-wrapper:focus-within {
    border-color: var(--accent-blue) !important;
    box-shadow: 0 0 0 1px var(--accent-blue) inset !important;
}

#analysis_modality_dropdown {
    top: calc(100% + 8px) !important;
    left: 0 !important;
    width: 100% !important;
    border-radius: 12px !important;
    border: 1px solid var(--border-color) !important;
    background: var(--glass-bg) !important;
    backdrop-filter: blur(24px) !important;
    -webkit-backdrop-filter: blur(24px) !important;
    box-shadow: 0 20px 60px var(--shadow-alpha) !important;
    z-index: 999999 !important;
}

@media (max-width: 767px) {
    #analysis_search_row {
        height: auto !important;
        min-height: 44px !important;
        margin-bottom: 16px !important;
    }

    .analysis-search-bar-wrapper {
        min-height: 44px !important;
        height: auto !important;
        padding: 0 8px !important;
        border-radius: 12px !important;
    }

    .analysis-search-bar-wrapper > div:last-of-type {
        height: auto !important;
        min-height: 44px !important;
    }

    #analysisGlobalSearchField {
        font-size: 16px !important;
        padding: 0 !important;
    }

    #analysis_search_action_btn {
        width: 32px !important;
        min-width: 32px !important;
        height: 32px !important;
        padding: 0 !important;
        border-radius: 8px !important;
    }

    .ana-search-text {
        display: none !important;
    }

    .ana-search-icon {
        display: block !important;
    }

    /* Synchronize Analysis, Prescription, Document & History Directories with CDSS on Mobile */
    #analysis_modality_dropdown .cdss-drop-option,
    #rx_modality_dropdown .cdss-drop-option,
    #document_modality_dropdown .cdss-drop-option,
    #history_mega_sort_menu .cdss-drop-option {
        padding: 8px 12px !important;
    }
}

.search-card-hover-wrapper:hover .search-item-hover-delete {
    display: inline-flex !important;
}

.search-card-hover-wrapper:hover .search-default-icon {
    display: none !important;
}

@media (max-width: 767px) {
    .search-card-hover-wrapper:hover .search-item-hover-delete {
        display: none !important;
    }
    .search-card-hover-wrapper:hover .search-default-icon {
        display: inline-block !important;
    }
}

/* --- CDSS DIRECTORY DROPDOWN MOBILE CONDENSATION --- */
@media (max-width: 767px) {
    #cdss_specialty_dropdown {
        top: calc(100% + 8px) !important;
        border-radius: 12px !important;
    }
    #cdss_specialty_dropdown .cdss-drop-option {
        padding: 8px 12px !important;
    }
    .cdss-title-desktop,
    .cdss-sub-desktop {
        display: none !important;
    }
    .cdss-title-mobile,
    .cdss-sub-mobile {
        display: block !important;
    }
}

@media (min-width: 768px) {
    .cdss-title-desktop,
    .cdss-sub-desktop {
        display: block !important;
    }
    .cdss-title-mobile,
    .cdss-sub-mobile {
        display: none !important;
    }
}

/* --- CDSS SEARCH BAR & DROPDOWN SPACING (PARITY WITH ALL TABS) --- */
@media (max-width: 767px) {
    #cdss_search_wrapper {
        height: auto !important;
        min-height: 44px !important;
        max-height: none !important;
        padding: 6px 8px !important;
    }

    #cdss_specialty_dropdown {
        top: calc(100% + 8px) !important;
        border-radius: 12px !important;
        box-shadow: 0 12px 32px var(--shadow-alpha) !important;
    }
}

/* ==========================================================================
   PRODUCTION IN-LINE LIVE CLINICAL DOSE PILLS & ADAPTIVE CDSS BADGES
   ========================================================================== */
.ctx-live-dose-badge {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    padding: 2px 8px !important;
    margin: 2px 0 2px 6px !important;
    border-radius: 6px !important;
    font-size: 0.76rem !important;
    font-weight: 700 !important;
    line-height: 1.35 !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
    border: 1px solid var(--accent-blue, #1a73e8) !important;
    background: rgba(26, 115, 232, 0.08) !important;
    color: var(--accent-blue, #1a73e8) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
    transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.ctx-live-dose-badge .ctx-live-icon {
    font-size: 0.95rem !important;
    line-height: 1 !important;
}

.ctx-live-dose-badge.is-pediatric {
    border-color: #8b5cf6 !important;
    background: rgba(139, 92, 246, 0.09) !important;
    color: #8b5cf6 !important;
}

.ctx-live-dose-badge.is-renal-adjusted {
    border-color: var(--clinical-warning, #d97706) !important;
    background: rgba(217, 119, 6, 0.09) !important;
    color: var(--clinical-warning, #d97706) !important;
}

.ctx-live-dose-badge.is-capped {
    border-color: var(--clinical-alert, #dc2626) !important;
    background: rgba(220, 38, 38, 0.08) !important;
    color: var(--clinical-alert, #dc2626) !important;
}

.ctx-live-dose-tag {
    font-size: 0.68rem !important;
    font-weight: 500 !important;
    opacity: 0.85 !important;
    letter-spacing: 0.2px !important;
}

/* ==========================================================================
   SIDEBAR SEPARATORS (DASHED)
   ========================================================================== */

/* Desktop Default (Expanded): Horizontal Dashed Divider */
.settings-nav-separator,
.patient-nav-separator {
    width: 100%;
    height: 0;
    min-height: 0;
    border-top: 1.5px dashed var(--border-color);
    background-color: transparent !important;
    margin: 6px 0;
    flex-shrink: 0;
    opacity: 0.5;
}

/* Desktop Collapsed (Icon Stack): Centered 32px Horizontal Dashed Divider */
.sidebar.collapsed .settings-nav-separator,
.sidebar.collapsed .patient-nav-separator {
    width: 32px;
    margin: 6px auto;
}

/* Mobile View Rules */
@media (max-width: 767px) {
    /* 1. Mobile Collapsed: Clean Vertical Dashed Divider in the button row */
    .sidebar-footer:not(.is-expanded) .settings-nav-separator,
    .sidebar-header:not(.is-expanded) .patient-nav-separator {
        width: 0 !important;
        height: 22px !important;
        min-height: 22px !important;
        border-top: none !important;
        border-left: 1.5px dashed var(--border-color) !important;
        background-color: transparent !important;
        margin: 0 4px !important;
        flex: 0 0 0px !important;
        align-self: center !important;
        display: block !important;
        opacity: 0.5;
    }

    /* 2. Mobile Expanded: Horizontal Dashed Divider across the column list */
    .sidebar-footer.is-expanded .settings-nav-separator,
    .sidebar-header.is-expanded .patient-nav-separator {
        width: 100% !important;
        height: 0 !important;
        min-height: 0 !important;
        border-left: none !important;
        border-top: 1.5px dashed var(--border-color) !important;
        background-color: transparent !important;
        margin: 6px 0 !important;
        flex: 0 0 0px !important;
        display: block !important;
        opacity: 0.5;
    }
}

/* ==========================================================================
   CORTEXA VOICE SUITE (DESKTOP DROP-UP & MOBILE ABSOLUTE BOTTOM DOCK)
   ========================================================================== */

.ctx-voice-btn-group {
    order: 4 !important;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin: 0 0 0 auto !important;
    align-self: center !important;
}

/* Voice Assistant Trigger Button */
.ctx-voice-mode-trigger-btn,
.ctx-voice-trigger-btn {
    background: transparent !important;
    border: 1px solid transparent !important;
    outline: none !important;
    box-shadow: none !important;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 8px;
    transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
    flex-shrink: 0;
}

.ctx-voice-mode-trigger-btn:hover,
.ctx-voice-trigger-btn:hover {
    color: var(--accent-blue);
    background-color: var(--bg-hover);
    border-color: var(--border-color) !important;
}

.ctx-voice-mode-trigger-btn .material-symbols-rounded,
.ctx-voice-trigger-btn .material-symbols-rounded {
    font-size: 20px !important;
    line-height: 1 !important;
}

/* Desktop: Floats above 'Ask Cortexa' bar with matching 10px margin */
.ctx-voice-dropdown-menu {
    position: absolute !important;
    bottom: calc(100% + 10px) !important;
    right: 0 !important;
    left: auto !important;
    top: auto !important;
    width: 275px !important;
    max-width: calc(100vw - 24px) !important;
    background: var(--bg-surface) !important;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-color) !important;
    border-radius: 14px !important;
    box-shadow: 0 12px 36px var(--shadow-alpha, rgba(0, 0, 0, 0.45)) !important;
    padding: 6px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 3px !important;
    z-index: 1000000 !important;
    animation: contextMenuPop 0.18s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    box-sizing: border-box !important;
}


.ctx-voice-dropdown-menu.hidden {
    display: none !important;
}

.ctx-voice-menu-section-label {
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-secondary);
    padding: 4px 10px 2px 10px;
    user-select: none;
}

.ctx-voice-menu-divider {
    width: 100%;
    height: 0;
    border-top: 1px solid var(--border-color);
    margin: 4px 0 2px 0;
}

.ctx-voice-dropdown-menu .ctx-deck-menu-item {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    width: 100% !important;
    padding: 8px 10px !important;
    border-radius: 8px !important;
    background: transparent !important;
    border: 1px solid transparent !important;
    color: var(--text-primary) !important;
    cursor: pointer !important;
    font-family: inherit !important;
    box-sizing: border-box !important;
    text-align: left !important;
    transition: background-color 0.15s ease !important;
}

.ctx-voice-dropdown-menu .ctx-deck-menu-item:hover {
    background: var(--bg-hover) !important;
}

.ctx-voice-menu-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.ctx-v-title {
    font-size: 0.86rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-primary);
}

.ctx-v-sub {
    font-size: 0.7rem;
    color: var(--text-secondary);
    line-height: 1.25;
    margin-top: 1px;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: block !important;
    max-width: 100% !important;
}

.sub-desktop { display: inline !important; }
.sub-mobile { display: none !important; }

.ctx-v-check {
    font-size: 16px !important;
    color: var(--accent-blue);
    flex-shrink: 0;
}

.ctx-v-check.hidden {
    display: none !important;
}

/* Speaking Wave Animation */
@keyframes ctxVoiceSpeakingWave {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.22); opacity: 0.75; color: var(--accent-blue); }
}
.ctx-speaking-active {
    animation: ctxVoiceSpeakingWave 1.2s infinite ease-in-out !important;
    color: var(--accent-blue) !important;
}

/* Mobile: Floating compact card anchored above the lower border with rounded edges */
@media (max-width: 767px) {
    .sub-desktop { display: none !important; }
    .sub-mobile { display: inline !important; }

    .ctx-voice-dropdown-menu {
        position: fixed !important;
        bottom: calc(12px + env(safe-area-inset-bottom, 8px)) !important;
        left: 12px !important;
        right: 12px !important;
        top: auto !important;
        width: auto !important;
        max-width: calc(100vw - 24px) !important;
        margin: 0 auto !important;
        box-sizing: border-box !important;
        background: var(--bg-surface) !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 20px !important;
        padding: 10px 12px !important;
        box-shadow: 0 16px 48px var(--shadow-alpha, rgba(0, 0, 0, 0.45)) !important;
        z-index: 10000000 !important;
        animation: ctxVoiceSheetSlideUp 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
    }
}

@keyframes ctxVoiceCardPop {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(6px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes ctxVoiceSheetSlideUp {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ========================================================================== */
/* SIDEBAR ANIMATED ICON HOVER ENGINES (PRESCRIPTION & CLINICAL DOCUMENTS)    */
/* ========================================================================== */

.sidebar-action-pill-btn:hover .rx-letter-r {
    stroke-dasharray: 28;
    stroke-dashoffset: 28;
    animation: rxDrawClean 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.sidebar-action-pill-btn:hover .rx-slash-cross {
    stroke-dasharray: 12;
    stroke-dashoffset: 12;
    animation: rxDrawClean 0.25s cubic-bezier(0.4, 0, 0.2, 1) 0.25s forwards;
}

.sidebar-action-pill-btn:hover .rx-slash-tick {
    stroke-dasharray: 12;
    stroke-dashoffset: 12;
    animation: rxDrawClean 0.25s cubic-bezier(0.4, 0, 0.2, 1) 0.4s forwards;
}

.sidebar-action-pill-btn:hover .doc-lines path {
    stroke-dasharray: 24;
    stroke-dashoffset: 24;
    animation: docDrawSmooth 0.5s ease forwards;
}

.sidebar-action-pill-btn:hover .doc-lines path:nth-child(1) { 
    animation-delay: 0s; 
}

.sidebar-action-pill-btn:hover .doc-lines path:nth-child(2) { 
    animation-delay: 0.12s; 
}

.sidebar-action-pill-btn:hover .doc-lines path:nth-child(3) { 
    animation-delay: 0.24s; 
}

@keyframes rxDrawClean {
    0% { 
        stroke-dashoffset: 28; 
        opacity: 0.1; 
    }
    100% { 
        stroke-dashoffset: 0; 
        opacity: 1; 
    }
}

@keyframes docDrawSmooth {
    0% { 
        stroke-dashoffset: 24; 
        opacity: 0.2; 
    }
    100% { 
        stroke-dashoffset: 0; 
        opacity: 1; 
    }
}

/* ========================================================================== */
/* CORTEXA MINIMALIST CLINICAL PRESCRIPTION PAD                               */
/* ========================================================================== */

.rx-sheet {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 24px;
    max-width: 760px;
    margin: 0 auto;
    box-shadow: 0 4px 18px var(--shadow-alpha, rgba(0, 0, 0, 0.04));
    font-family: inherit;
}

/* Individual Drug Row (Stationery Line Style) */
.rx-row-item {
    padding: 12px 14px;
    border-radius: 8px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: background 0.15s ease;
}

.rx-row-item:last-child {
    border-bottom: none;
}

.rx-row-item.is-clickable {
    cursor: pointer;
    user-select: none;
}

.rx-row-item.is-clickable:hover {
    background: var(--bg-hover);
}

.rx-row-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.rx-drug-name-text {
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.15px;
    line-height: 1.3;
}

/* Simple Unboxed Sig */
.rx-simple-sig {
    font-size: 0.86rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-top: 2px;
}

.rx-simple-sig b {
    color: var(--text-primary);
    font-weight: 600;
}

/* Clean Category Tag Pill */
.rx-tag {
    display: inline-flex;
    align-items: center;
    padding: 1.5px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    line-height: 1;
}

.rx-meta-pill {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Prescription Drug Card Hover Highlight */
.rx-row-card.is-clickable:hover {
    background: var(--bg-hover) !important;
    border-color: rgba(66, 133, 244, 0.35) !important;
}

/* ==========================================================================
   ACTIVE ITEMS EXPLICIT REMOVAL "X" BUTTONS
   ========================================================================== */
.ctx-inter-explicit-remove-btn,
.dropdown-item-delete-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    touch-action: manipulation;
    user-select: none;
}

@media (max-width: 767px) {
    .ctx-inter-explicit-remove-btn {
        width: 32px !important;
        height: 32px !important;
        color: var(--clinical-alert) !important;
        background: rgba(234, 67, 53, 0.08) !important;
        border-radius: 50% !important;
    }
}

/* ==========================================================================
   SECTION 32: REALISTIC CLINICAL MONOGRAPH & CARD ENHANCEMENTS
   ========================================================================== */
.clinical-card-container {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 14px !important;
    padding: 16px 18px !important;
    box-shadow: 0 4px 16px var(--shadow-alpha) !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    margin: 12px 0 0 0 !important;
}

/* Prevent accordions from squeezing the card */
.accordion-expansion-content {
    width: 100% !important;
    box-sizing: border-box !important;
}

.clinical-section-title {
    font-size: 0.78rem !important;
    font-weight: 800 !important;
    color: var(--accent-blue) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    margin-bottom: 6px !important;
    display: block !important;
}

.clinical-data-section {
    width: 100% !important;
    box-sizing: border-box !important;
}

.clinical-section-body {
    width: 100% !important;
    box-sizing: border-box !important;
}

.clinical-badge.alert {
    background: rgba(234, 67, 53, 0.12) !important;
    color: var(--clinical-alert, #ea4335) !important;
    border: 1px solid rgba(234, 67, 53, 0.3) !important;
}

.clinical-badge.warning {
    background: rgba(251, 188, 4, 0.12) !important;
    color: var(--clinical-warning, #fbbc04) !important;
    border: 1px solid rgba(251, 188, 4, 0.3) !important;
}

.clinical-badge.normal {
    background: rgba(66, 133, 244, 0.12) !important;
    color: var(--accent-blue, #4285f4) !important;
    border: 1px solid rgba(66, 133, 244, 0.3) !important;
}

    @media (max-width: 767px) {
        .ctx-workspace-gen-btn {
            width: 32px !important;
            height: 32px !important;
            padding: 0 !important;
        }
        .ctx-workspace-gen-btn .gen-btn-text {
            display: none !important;
        }
    }

/* ==========================================================================
   PATIENTS NAV ICON DYNAMIC HOVER ENGINE
   ========================================================================== */
.sidebar-action-pill-btn .patients-animated-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    overflow: visible;
}

/* Rest State (Desktop & Mobile): Rect is at y=24, completely hiding the fill (hollow) */
.sidebar-action-pill-btn .patients-animated-icon .liquid-rect {
    y: 24;
    transition: y 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hover State: Rect slides up to y=0, creating a smooth bottom-to-top liquid fill */
.sidebar-action-pill-btn:hover .patients-animated-icon .liquid-rect {
    y: 0;
}

/* Active Tab State: Keeps it hollow at rest, fills only on hover */
.sidebar-action-pill-btn.active .patients-animated-icon .liquid-rect {
    y: 24;
}

.sidebar-action-pill-btn.active:hover .patients-animated-icon .liquid-rect {
    y: 0;
}

/* Patient Card Group in Archive */
.ctx-patient-archive-group {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    margin-bottom: 14px;
    overflow: hidden;
    box-shadow: 0 4px 16px var(--shadow-alpha);
    transition: border-color 0.2s ease;
}

.ctx-patient-archive-group.expanded {
    border-color: var(--accent-blue);
}

.ctx-patient-archive-header {
    width: 100%;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
}

.ctx-patient-archive-body {
    padding: 12px 16px 16px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-main);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item-wrapper[data-type="patient"]:hover .ctx-history-sidebar-icon {
    transform: scale(1.18);
    color: var(--accent-blue, #4285f4);
}

.patients-animated-icon {
    overflow: visible;
}

.patients-animated-icon .page-person-1,
.patients-animated-icon .page-person-2 {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    transform-origin: center;
}

/* Page 2 starts hidden and offset to the right */
.patients-animated-icon .page-person-2 {
    opacity: 0;
    transform: translateX(12px) scale(0.9);
    pointer-events: none;
}

/* Hover State: Page 1 slides out left, Page 2 slides in from right */
.sidebar-action-pill-btn:hover .patients-animated-icon .page-person-1 {
    opacity: 0;
    transform: translateX(-12px) scale(0.9);
    pointer-events: none;
}

.sidebar-action-pill-btn:hover .patients-animated-icon .page-person-2 {
    opacity: 1;
    transform: translateX(0) scale(1);
    pointer-events: auto;
}

.sidebar-action-pill-btn.active .patients-animated-icon {
    transform: scale(1.08);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Universal Search Clear Delete Buttons */
.search-clear-btn {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 0 4px;
    color: var(--text-secondary, #9aa0a6);
    transition: color 0.2s ease;
}

.search-clear-btn .material-symbols-rounded {
    font-size: 1.15rem;
    line-height: 1;
    color: inherit;
    transition: color 0.2s ease;
}

/* Red Hover Effect */
.search-clear-btn:hover,
.search-clear-btn:hover .material-symbols-rounded {
    color: var(--clinical-alert, #ea4335) !important;
}

/* ======================================================================
   REPAIRED: PATIENT HISTORY & STAGED RISK FACTOR CHIPS (MOBILE SAFE)
   ====================================================================== */

.clinical-card-container,
.ctx-hybrid-card-pane,
.ctx-hybrid-card-wrapper {
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

/* 1. Active Risk Tag Cluster: Wrap nicely in a row */
[id*="_active_risks_target"],
.active-risks-cluster,
.risk-chips-wrapper {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 6px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    margin-top: 6px !important;
}

/* 2. Individual Active Chip Tag: Single line, no boundary overflow */
[id*="_active_risks_target"] > *,
.ctx-active-risk-chip {
    max-width: 100% !important;
    min-width: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 3px 8px !important;
    border-radius: 6px !important;
    box-sizing: border-box !important;
    white-space: nowrap !important;
}

/* Truncate text labels with ellipsis without breaking badge spans */
.risk-tag-chip,
.risk-chip-label,
.ctx-active-risk-name {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: calc(100vw - 120px) !important;
    display: inline-block !important;
    min-width: 0 !important;
    vertical-align: middle !important;
}

/* 3. Dropdown Menu Containers & Checkbox Alignment */
.risk-engine-dropdown-container,
[id*="_risk_mega_menu"],
[id*="_risk_autocomplete_dropdown"] {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: visible !important;
}

.risk-engine-dropdown-content {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.risk-matrix-option {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 8px 10px !important;
    cursor: pointer !important;
}

.risk-matrix-option input[type="checkbox"] {
    flex-shrink: 0 !important;
    width: 18px !important;
    height: 18px !important;
    margin: 0 !important;
}

/* Text inside option row: Single line with ellipsis */
.risk-matrix-option .risk-option-text,
.risk-matrix-option > span:last-child {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-size: 0.85rem !important;
    line-height: 1.3 !important;
    display: block !important;
}

/* 4. Strict Desktop vs Mobile Badge Switching (Fixes HIGHH / MODM / LOWL) */
@media (max-width: 767px) {
    .risk-desktop-tag,
    .risk-desktop-text,
    .risk-desktop-label,
    .risk-severity-full {
        display: none !important;
    }
    
    .risk-mobile-tag,
    .risk-mobile-icon,
    .risk-mobile-label,
    .risk-severity-letter {
        display: inline-block !important;
    }

    .ctx-archived-patient-history-strip {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 6px !important;
        overflow-x: hidden !important;
        overflow-y: visible !important;
        white-space: normal !important;
    }

    .ctx-archived-patient-history-strip,
    .ctx-archived-patient-history-strip * {
        white-space: normal !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .ctx-archived-patient-history-strip > span:first-child,
    .ctx-archived-patient-history-strip > strong:first-child,
    .ctx-archived-patient-history-strip > b:first-child {
        display: block !important;
        width: 100% !important;
        flex: 0 0 100% !important;
        font-size: 0.72rem !important;
        font-weight: 800 !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
        color: var(--accent-blue) !important;
        margin-bottom: 2px !important;
    }

    .ctx-archived-patient-history-strip > div {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 6px !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }
}

@media (min-width: 768px) {
    .risk-desktop-tag,
    .risk-desktop-text,
    .risk-desktop-label,
    .risk-severity-full {
        display: inline-block !important;
    }

    .risk-mobile-tag,
    .risk-mobile-icon,
    .risk-mobile-label,
    .risk-severity-letter {
        display: none !important;
    }
}

/* ==========================================================================
   IPAD & MOBILE FULL-WIDTH SHEET EXPANSION (BOTH ORIENTATIONS)
   ========================================================================== */
@media (max-width: 1024px), (pointer: coarse) {
    /* Clinical AI Tools & Modes Bottom Sheet */
    #ctx_deck_mobile_sheet {
        padding: 0 !important;
        align-items: flex-end !important;
    }

    #ctx_deck_mobile_sheet .ctx-sheet-card {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 24px 24px 0 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }

    /* Voice & Assistant Options Full-Width Bottom Sheet */
    .ctx-deck-dropdown-menu#ctxVoiceModeDropdown.ctx-mobile-voice-sheet,
    #ctxVoiceModeDropdown {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100vw !important;
        max-width: 100vw !important;
        margin: 0 !important;
        border-radius: 24px 24px 0 0 !important;
        box-sizing: border-box !important;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.4) !important;
        z-index: 9999999 !important;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* ==========================================================================
   KILL BROWSER AUTOFILL YELLOW BACKGROUNDS
   ========================================================================== */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
input:-webkit-autofill:active {
    /* Infinitely delays the browser's autofill color from applying */
    transition: background-color 9999s ease-in-out 0s !important;
    /* Forces the text to match your app's theme instead of defaulting to black */
    -webkit-text-fill-color: var(--text-primary) !important;
    background-color: transparent !important;
}