        :root {
            /* Task Priority Colors - Urgency-based */
            --color-starred: #ffd700;
            --color-overdue: #f1c40f;      /* Yellow background for overdue */
            --color-today: #e74c3c;        /* Reddish - most urgent */
            --color-tomorrow: #ff9500;     /* Orangeish - moderately urgent */
            --color-upcoming: #f1c40f;     /* Yellowish - less urgent */
            --color-later: #9b9b9b;
            --color-suggested: rgba(102, 126, 234, 0.1);
            
            /* UI Colors */
            --color-tab-active: #667eea;
            --color-primary: #667eea;
            
            /* iOS Safe Area Support */
            --safe-area-inset-top: env(safe-area-inset-top);
            --safe-area-inset-bottom: env(safe-area-inset-bottom);
            --safe-area-inset-left: env(safe-area-inset-left);
            --safe-area-inset-right: env(safe-area-inset-right);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        /* iOS-specific fixes */
        html {
            height: -webkit-fill-available;
            overflow: hidden;
            position: fixed;
            width: 100%;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background: #f5f5f7;
            overflow: hidden;
            height: var(--viewport-height, 100vh);  /* Use actual viewport height on mobile */
            min-height: -webkit-fill-available;  /* iOS Safari fix */
            display: flex;
            flex-direction: column;
            position: fixed;  /* Prevent iOS Safari from resizing */
            width: 100%;
            top: 0;
            left: 0;
        }
        
        .app-container {
            display: flex;
            flex-direction: column;
            height: var(--viewport-height, 100vh);  /* Use actual viewport height on mobile */
            min-height: -webkit-fill-available;  /* iOS Safari fix */
            overflow: hidden;
        }

        /* Header */
        .header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 8px 12px;  /* Reduced padding for compact header */
            padding-top: calc(8px + var(--safe-area-inset-top));  /* Add safe area for iOS notch */
            padding-left: calc(12px + var(--safe-area-inset-left));
            padding-right: calc(12px + var(--safe-area-inset-right));
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            position: sticky;
            top: 0;
            z-index: 100;
        }

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

        .app-name {
            font-size: 20px;
            font-weight: 600;
        }

        .weather-icon, .traffic-icon {
            width: 24px;
            height: 24px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 4px;
            background: rgba(255,255,255,0.2);
            cursor: pointer;
            position: relative;
            font-size: 18px;
        }
        
        /* Show icon with red X overlay when unavailable */
        .weather-icon:empty::before,
        .weather-icon.unavailable::before {
            content: '☁️';
            position: relative;
            z-index: 1;
        }
        
        .weather-icon:empty::after,
        .weather-icon.unavailable::after {
            content: '✕';
            position: absolute;
            font-size: 14px;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            z-index: 2;
            color: #000; /* Black X for better visibility */
            font-weight: bold;
        }
        
        .traffic-icon:empty::before,
        .traffic-icon.unavailable::before {
            content: '🚦';
            position: relative;
            z-index: 1;
        }
        
        .traffic-icon:empty::after,
        .traffic-icon.unavailable::after {
            content: '✕';
            position: absolute;
            font-size: 14px;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            z-index: 2;
            color: #000; /* Black X for better visibility */
            font-weight: bold;
        }

        .weather-icon:hover::after, .traffic-icon:hover::after {
            content: attr(data-tooltip);
            position: absolute;
            top: 100%;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(0,0,0,0.8);
            color: white;
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 12px;
            white-space: nowrap;
            margin-top: 4px;
            z-index: 1000;
        }

        .help-btn,
        .alert-btn-header,
        .archive-btn-header,
        .settings-btn {
            width: 32px;
            height: 32px;
            background: rgba(255,255,255,0.2);
            border: 2px solid rgba(255,255,255,0.3);
            border-radius: 50%;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 16px;
            position: relative;
            z-index: 101;
        }

        .help-btn:hover,
        .alert-btn-header:hover,
        .archive-btn-header:hover,
        .settings-btn:hover {
            background: rgba(255,255,255,0.3);
        }

        /* Alert count badge on header button */
        .alert-count-badge {
            position: absolute;
            top: -4px;
            right: -4px;
            background: #dc3545;
            color: white;
            border-radius: 10px;
            padding: 2px 5px;
            font-size: 10px;
            font-weight: bold;
            min-width: 16px;
            text-align: center;
            line-height: 1;
        }

        /* Pulse animation for alert button */
        .alert-btn-header.has-alerts {
            animation: alert-pulse 2s infinite;
        }

        @keyframes alert-pulse {
            0% { 
                box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
            }
            50% { 
                box-shadow: 0 0 0 8px rgba(220, 53, 69, 0);
            }
            100% { 
                box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
            }
        }

        /* Plan Day Button */
        .plan-day-btn {
            background: white;
            color: #667eea;
            border: none;
            padding: 6px 12px;
            border-radius: 16px;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            animation: blue-halo-pulse-btn 2s infinite;
        }

        .plan-day-btn:hover {
            background: rgba(255,255,255,0.9);
        }
        
        @keyframes blue-halo-pulse-btn {
            0% { 
                box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
            }
            50% { 
                box-shadow: 0 0 0 8px rgba(102, 126, 234, 0);
            }
            100% { 
                box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
            }
        }

        /* Archive Button - Now in header (old floating button removed) */

        /* Tabs */
        .tabs {
            display: flex;
            background: white;
            border-bottom: 1px solid #e0e0e0;
            position: sticky;
            top: 56px;
            z-index: 99;
        }

        .tab {
            flex: 1;
            padding: 6px;  /* Minimal padding for compact tabs */
            background: none;
            border: none;
            cursor: pointer;
            font-size: 15px;
            font-weight: 500;
            color: #666;
            border-bottom: 2px solid transparent;  /* Thinner border */
            transition: all 0.2s ease;
        }

        .tab:hover {
            color: #667eea;
            background: rgba(102, 126, 234, 0.05);
        }

        .tab.active {
            color: var(--color-tab-active);
            border-bottom-color: var(--color-tab-active);
            background: rgba(102, 126, 234, 0.08);
            font-weight: 600;
        }

        /* Main Content */
        .content {
            flex: 1;
            overflow: hidden;
            position: relative;
            display: flex;
            flex-direction: column;
        }

        /* Scrollable Content Area (top 75%) */
        .scrollable-content {
            flex: 3;
            overflow: hidden;
            position: relative;
            display: flex;
            flex-direction: column;
        }

        .tab-content {
            display: none;
            flex: 1;
            overflow: hidden;
            flex-direction: column;
            min-height: 0; /* Allow flex children to shrink */
        }

        .tab-content.active {
            display: flex;
        }

        /* Task List */
        .task-list-container {
            flex: 1;
            overflow-y: auto;
            padding-bottom: 0;  /* Remove gap - let #taskList handle spacing */
            display: flex;
            flex-direction: column;
        }
        
        #taskList {
            flex: 1;
            overflow-y: auto;
            min-height: 0; /* Allow flex child to shrink and scroll */
            padding-bottom: 20px; /* Minimal padding for last item spacing */
        }

        .new-task-input {
            width: calc(100% - 16px);
            margin: 8px 8px;  /* Minimal margin for compact layout */
            flex-shrink: 0;
            background: #f0f8ff;  /* Light blue background */
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            padding: 10px;
            border: 2px solid #e0e0e0;
            border-radius: 8px;
            font-size: 15px;
            transition: border-color 0.3s;
        }

        .new-task-input:focus {
            outline: none;
            border-color: #667eea;
            background: #e6f3ff;  /* Slightly darker blue on focus */
        }

        .task-section {
            position: relative;
            padding: 4px 0 4px 8px;  /* Minimal padding for compact layout */
            min-height: 40px;
        }

        .section-label {
            display: block;
            padding: 4px 8px 2px 8px;  /* Reduced padding */
            font-size: 9px;
            font-weight: 700;
            letter-spacing: 0.5px;
            text-transform: uppercase;
            opacity: 0.7;
        }

        /* Task Section Colors - Simplified with color-coded labels */
        /* Progressive scale: Hot (urgent) at top → Cool (later) at bottom */
        
        /* Progressive color scale: Hot (urgent) → Cool (later) */
        
        /* RPG Rarity Colors: Legendary → Epic → Rare → Uncommon → Common */
        .section-starred {
            background: rgba(255, 149, 0, 0.08);
        }
        .section-starred .section-label {
            color: #ff9500;
            font-weight: 800;
        }
        
        .section-overdue {
            background: repeating-linear-gradient(
                45deg,
                rgba(220, 53, 69, 0.15),
                rgba(220, 53, 69, 0.15) 10px,
                rgba(0, 0, 0, 0.08) 10px,
                rgba(0, 0, 0, 0.08) 20px
            );
        }
        .section-overdue .section-label {
            color: #dc3545;
            font-weight: 800;
        }
        .section-overdue .task-text,
        .task-row.section-overdue .task-text {
            color: #d32f2f !important;
            font-weight: 500;
        }
        
        .section-today {
            background: rgba(168, 85, 247, 0.08);
        }
        .section-today .section-label {
            color: #a855f7;
            font-weight: 800;
        }
        
        .section-suggested-today {
            background: rgba(168, 85, 247, 0.06);
        }
        .section-suggested-today .section-label {
            color: #a855f7;
            font-weight: 700;
        }
        
        .section-tomorrow {
            background: rgba(59, 130, 246, 0.08);
        }
        .section-tomorrow .section-label {
            color: #3b82f6;
            font-weight: 700;
        }
        
        .section-suggested-tomorrow {
            background: rgba(59, 130, 246, 0.06);
        }
        .section-suggested-tomorrow .section-label {
            color: #3b82f6;
            font-weight: 600;
        }
        
        .section-upcoming {
            background: rgba(16, 185, 129, 0.08);
        }
        .section-upcoming .section-label {
            color: #10b981;
            font-weight: 600;
        }
        
        .section-later {
            background: #f3f4f6;
        }
        .section-later .section-label {
            color: #9ca3af;
            font-weight: 500;
        }

        .task-table {
            width: 100%;
            table-layout: fixed;
            border-collapse: collapse;
        }

        .task-row {
            min-height: 28px;
            height: auto;
            transition: background-color 0.2s;
            background: white;
            display: table;
            width: calc(100% - 4px);
            table-layout: fixed;
            margin: 2px 2px;  /* Tighter margins */
            border-radius: 6px;
            padding: 2px 4px;  /* Reduced padding between controls and text */
            box-shadow: 0 1px 2px rgba(0,0,0,0.05);
        }

        .task-row:hover {
            background: rgba(255,255,255,0.5) !important;
        }
        
        /* Simplified hover - same for all sections */
        .task-row:hover {
            background: rgba(102, 126, 234, 0.08) !important;
        }

        .task-row.completed {
            background: rgba(0, 0, 0, 0.05);
            opacity: 0.6;
        }

        .task-row.completed .task-text {
            text-decoration: line-through;
            color: #999;
        }

        /* TASK 28: Overdue task styling */
        .task-row.overdue .task-text {
            color: #d32f2f;
            font-weight: 500;
        }

        .task-row.overdue.completed .task-text {
            color: #999;
            font-weight: normal;
        }

        .task-cell-star {
            width: 28px;
            padding: 0 2px;  /* Tighter padding */
        }

        .task-cell-edit {
            width: 26px;
            padding: 0 2px;  /* Tighter padding */
        }

        .task-cell-checkbox {
            width: 22px;
            padding: 0 2px;  /* Tighter padding */
        }

        .task-cell-text {
            padding: 2px 4px;  /* Reduced padding */
            overflow: visible;
            white-space: normal;
            word-wrap: break-word;
            display: table-cell;
            vertical-align: middle;
        }

        .task-checkbox {
            width: 18px;
            height: 18px;
            margin-right: 8px;
            cursor: pointer;
            flex-shrink: 0;
        }

        .task-calendar-icon {
            width: 16px;
            height: 16px;
            margin-right: 6px;
            opacity: 0.6;
        }

        .task-calendar-icon-separate {
            font-size: 16px;
            margin-left: 4px;
            margin-right: 4px;
            opacity: 0.6;
            cursor: help;
            flex-shrink: 0;
            width: 24px;
        }

        .task-calendar-icon-inline {
            font-size: 14px;
            margin-right: 4px;
            opacity: 0.6;
            cursor: help;
            display: inline-block;
            vertical-align: middle;
        }

        .task-alert-icon-inline {
            display: inline-block;
            position: relative;
            margin-right: 4px;
            vertical-align: middle;
        }

        .task-text {
            flex: 1;
            font-size: 14px;
            white-space: normal !important;
            word-wrap: break-word !important;
            overflow-wrap: break-word !important;
            word-break: break-word !important;
            line-height: 1.4;
            max-width: 100%;
            overflow: visible !important;
            white-space: normal;
            word-wrap: break-word;
            overflow-wrap: break-word;
            cursor: text;
            padding: 2px 4px;
            border-radius: 4px;
            line-height: 1.4;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            min-width: 0;
        }

        .task-text:hover {
            background: rgba(0,0,0,0.05);
        }

        .task-text.editing {
            background: white;
            border: 1px solid #667eea;
            outline: none;
        }

        .task-edit-btn {
            background: none;
            border: none;
            cursor: pointer;
            padding: 4px;
            color: #999;
            font-size: 12px;
            flex-shrink: 0;
            width: 24px;
        }

        .task-star {
            background: none;
            border: none;
            cursor: pointer;
            font-size: 18px;
            padding: 4px;
            color: #999;
            transition: color 0.2s;
            flex-shrink: 0;
            width: 26px;
        }
        
        .task-star:hover {
            color: #666;
        }

        .task-star.starred {
            color: #ffd700;
        }
        
        .task-star.starred:hover {
            color: #ffed4e;
        }

        /* Calendar View */
        .calendar-container {
            flex: 1;
            overflow-y: auto;
            padding: 16px;
            padding-bottom: 80px;
        }

        .calendar-day-section {
            background: white;
            border-radius: 8px;
            margin-bottom: 16px;
            padding: 12px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }

        .calendar-day-header {
            font-size: 18px;
            font-weight: 600;
            margin-bottom: 12px;
            color: #333;
        }

        .calendar-day-tasks {
            max-height: 200px;
            overflow-y: auto;
        }

        .calendar-week-grid {
            display: grid;
            grid-template-columns: repeat(7, 1fr);
            gap: 8px;
            margin-top: 16px;
        }

        .calendar-week-day {
            background: white;
            border-radius: 8px;
            padding: 8px;
            min-height: 80px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
            cursor: pointer;
            transition: transform 0.2s, background 0.2s;
        }
        
        /* Current date gets thick dark blue outline */
        .calendar-week-day.is-today {
            border: 3px solid #1e40af;
            box-shadow: 0 2px 8px rgba(30, 64, 175, 0.3);
        }
        
        /* Days with tasks get a subtle background color */
        .calendar-week-day.has-tasks {
            background: #f0f8ff;
        }
        
        /* Empty placeholder for past days */
        .calendar-week-day-empty {
            background: transparent;
            min-height: 80px;
        }

        .calendar-week-day:hover {
            transform: translateY(-2px);
            box-shadow: 0 2px 6px rgba(0,0,0,0.15);
        }

        .calendar-week-day-label {
            font-size: 12px;
            font-weight: 600;
            color: #666;
            margin-bottom: 4px;
        }

        .calendar-week-day-date {
            font-size: 16px;
            font-weight: 500;
            margin-bottom: 4px;
        }

        .calendar-week-day-indicator {
            width: 6px;
            height: 6px;
            background: #667eea;
            border-radius: 50%;
            margin: 2px;
            display: inline-block;
        }
        
        .calendar-add-task-btn {
            background: #667eea;
            color: white;
            border: none;
            padding: 6px 12px;
            border-radius: 6px;
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            transition: background 0.2s;
        }
        
        .calendar-add-task-btn:hover {
            background: #5568d3;
        }
        
        .calendar-day-add-btn {
            position: absolute;
            top: 4px;
            right: 4px;
            width: 20px;
            height: 20px;
            background: #667eea;
            color: white;
            border: none;
            border-radius: 50%;
            font-size: 14px;
            font-weight: bold;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            transition: opacity 0.2s, background 0.2s;
        }
        
        .calendar-week-day {
            position: relative;
        }
        
        .calendar-week-day:hover .calendar-day-add-btn {
            opacity: 1;
        }
        
        .calendar-day-add-btn:hover {
            background: #5568d3;
        }

        /* Alert Banner Button (Floating) - positioned just below header */
        .alert-banner-button {
            position: fixed;
            top: 68px;
            right: 16px;
            width: 56px;
            height: 56px;
            background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
            border-radius: 50%;
            border: none;
            color: white;
            cursor: pointer;
            box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
            z-index: 1000;
            transition: transform 0.2s;
        }

        .alert-banner-button:hover {
            transform: scale(1.1);
        }

        .alert-banner-icon {
            font-size: 32px;
            display: block;
            width: 100%;
            height: 100%;
            line-height: 56px;
            text-align: center;
            font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
        }

        .alert-banner-icon.blink {
            animation: blink 1s infinite;
        }

        @keyframes blink {
            0%, 50%, 100% { opacity: 1; }
            25%, 75% { opacity: 0.3; }
        }

        .alert-banner-count {
            position: absolute;
            top: -4px;
            right: -4px;
            background: #dc3545;
            color: white;
            border-radius: 12px;
            padding: 2px 6px;
            font-size: 11px;
            font-weight: bold;
            min-width: 20px;
            text-align: center;
        }

        /* Old Chatbot Button and Popup Styles - REMOVED (now using permanent AI chat panel) */

        /* Modal */
        .modal {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0,0,0,0.5);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 3000;
        }

        .modal.open {
            display: flex;
        }

        .modal-content {
            background: white;
            padding: 24px;
            border-radius: 12px;
            width: 90%;
            max-width: 400px;
        }

        .modal-header {
            font-size: 20px;
            font-weight: 600;
            margin-bottom: 16px;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .modal-star-toggle {
            background: none;
            border: none;
            font-size: 24px;
            cursor: pointer;
            padding: 4px;
            color: #ccc;
            transition: color 0.2s;
        }

        .modal-star-toggle:hover {
            color: #999;
        }

        .modal-star-toggle.starred {
            color: #ffd700;
        }

        .modal-star-toggle.starred:hover {
            color: #ffed4e;
        }

        .modal-field {
            margin-bottom: 16px;
        }

        .modal-label {
            display: block;
            font-size: 14px;
            color: #666;
            margin-bottom: 4px;
        }

        .modal-input {
            width: 100%;
            padding: 8px;
            border: 1px solid #e0e0e0;
            border-radius: 6px;
            font-size: 14px;
            background: #f0f8ff;  /* Light blue background */
        }

        .modal-input:focus {
            outline: none;
            border-color: #667eea;
            background: #e6f3ff;  /* Slightly darker blue on focus */
        }



        .modal-buttons {
            display: flex;
            gap: 12px;
            justify-content: flex-end;
            margin-top: 20px;
        }

        .modal-btn {
            padding: 8px 16px;
            border-radius: 6px;
            border: none;
            cursor: pointer;
            font-size: 14px;
            font-weight: 500;
        }

        .modal-btn-cancel {
            background: #f0f0f0;
            color: #666;
        }

        .modal-btn-save {
            background: #667eea;
            color: white;
        }

        /* Modal Alert Conditions */
        .modal-alert-conditions {
            margin-bottom: 16px;
            padding: 12px;
            background: #f9f9f9;
            border-radius: 8px;
            border: 1px solid #e0e0e0;
        }

        .modal-alert-conditions-header {
            font-size: 14px;
            font-weight: 600;
            color: #666;
            margin-bottom: 8px;
        }

        .modal-alert-condition-item {
            display: flex;
            align-items: center;
            padding: 8px;
            margin: 4px 0;
            background: #f5f5f5;
            border-radius: 4px;
            transition: opacity 0.2s;
        }

        .modal-alert-condition-item input[type="checkbox"] {
            margin-right: 8px;
            cursor: pointer;
            width: 16px;
            height: 16px;
        }

        .modal-alert-condition-item span {
            flex: 1;
            font-size: 14px;
            color: #333;
        }

        /* Settings Dropdown */
        .settings-dropdown {
            position: absolute;
            top: 50px;
            right: 16px;
            background: white;
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
            display: none;
            z-index: 1001;
        }

        .settings-dropdown.open {
            display: block;
        }

        .settings-user-info {
            padding: 12px 16px;
            border-bottom: 2px solid #e0e0e0;
            background: #f8f9fa;
        }

        .settings-user-info strong {
            color: #667eea;
            font-size: 14px;
        }

        .settings-option {
            padding: 12px 16px;
            cursor: pointer;
            border-bottom: 1px solid #f0f0f0;
            color: #333;
            font-size: 14px;
        }

        .settings-option:hover {
            background: #f5f5f5;
        }

        .settings-option:last-child {
            border-bottom: none;
        }


/* ========================================
   ALERT SYSTEM STYLES
   ======================================== */

/* Task Alert Icon */
.task-alert-icon {
    position: relative;
    cursor: pointer;
    font-size: 16px;
    margin-left: 8px;
    opacity: 0.8;
    transition: opacity 0.2s;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    width: 32px;
}

.task-alert-icon:hover {
    opacity: 1;
}

/* Inline alert icon (inside text cell) */
.task-alert-icon-inline {
    position: relative;
    cursor: pointer;
    font-size: 14px;
    opacity: 0.8;
    transition: opacity 0.2s;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-right: 4px;
}

.task-alert-icon-inline:hover {
    opacity: 1;
}

.alert-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #dc3545;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
}



/* Alert Notification Panel */
.alert-notification-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 350px;
    max-height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 1000;
    display: none;
    overflow: hidden;
}

.alert-notification-panel.show {
    display: block;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.alert-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.alert-panel-title {
    font-size: 16px;
    font-weight: 600;
}

.alert-panel-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    line-height: 24px;
}



.alert-item {
    display: block;
    padding: 0;
    margin-bottom: 12px;
    background: transparent;
    border: none;
    border-radius: 0;
    cursor: default;
    transition: none;
}

.alert-item:hover {
    background: transparent;
}

.alert-icon {
    font-size: 20px;
    margin-right: 12px;
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
}

.alert-text {
    font-size: 14px;
    color: #856404;
    font-weight: 500;
    margin-bottom: 4px;
}

.alert-task-name {
    font-size: 12px;
    color: #856404;
    opacity: 0.7;
}

.alert-dismiss {
    background: none;
    border: none;
    color: #856404;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    line-height: 24px;
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.alert-dismiss:hover {
    opacity: 1;
}

/* Modal Alerts Section */
.modal-alerts {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}

.modal-alert-header {
    font-size: 14px;
    font-weight: 600;
    color: #856404;
    margin-bottom: 8px;
}

.modal-alert-item {
    font-size: 13px;
    color: #856404;
    padding: 6px 0;
    border-bottom: 1px solid rgba(133, 100, 4, 0.2);
}

.modal-alert-item:last-child {
    border-bottom: none;
}

/* Task Alerts Popup */
.task-alerts-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    z-index: 2000;
    max-width: 400px;
    /* No animation - just appear */
}

/* Alert Dismissal Checkboxes */
.dismiss-alert-checkbox,
.dismiss-condition-checkbox {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
    flex-shrink: 0;
}

.dismiss-alert-checkbox {
    accent-color: #666;
}

.dismiss-condition-checkbox {
    accent-color: #2196F3;
}

.dismiss-alert-checkbox:checked,
.dismiss-condition-checkbox:checked {
    accent-color: #4CAF50;
}

/* Fade out animation when dismissing */
.dismissing {
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .alert-notification-panel {
        right: 10px;
        left: 10px;
        width: auto;
        max-width: none;
    }
    
    .task-alerts-popup {
        left: 10px;
        right: 10px;
        width: auto;
        max-width: none;
        transform: translate(0, -50%);
    }
}


/* Alert Button (Floating in top-right corner) */
.alert-banner {
    display: none;
    position: fixed;
    top: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #ff5252 0%, #f44336 100%);
    color: white;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
    z-index: 1000;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: none;
}

.alert-banner:hover {
    background: linear-gradient(135deg, #ff1744 0%, #d32f2f 100%);
    box-shadow: 0 6px 16px rgba(244, 67, 54, 0.6);
    transform: scale(1.05);
}

.alert-banner-icon {
    font-size: 28px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}



.alert-banner-icon.blink::after {
    content: '';
    position: absolute;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(244, 67, 54, 0.4);
    animation: pulse 2s ease-in-out infinite;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

@keyframes pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.7;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.4);
        opacity: 0;
    }
}

.alert-banner-content {
    display: none;
}

.alert-banner-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #fff;
    color: #f44336;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
    border: 2px solid #f44336;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.alert-banner-text {
    display: none;
}

.alert-banner-arrow {
    display: none;
}

/* Alert Panel (Fullscreen) */
.alert-panel {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: white;
    border-radius: 0;
    box-shadow: none;
    z-index: 999;
    overflow: hidden;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.alert-panel.show {
    visibility: visible;
    opacity: 1;
}

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

.alert-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.alert-panel-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.alert-panel-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.alert-panel-close:hover {
    background: rgba(0,0,0,0.05);
    color: #333;
}

.alert-panel-body {
    overflow-y: auto;
    padding: 8px;
    flex: 1;
    min-height: 0;
}

.alert-item {
    display: block;
    padding: 0;
    margin-bottom: 12px;
    background: transparent;
    border: none;
    border-radius: 0;
    transition: none;
}

.alert-item:hover {
    background: transparent;
    box-shadow: none;
}

.alert-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
    min-width: 0;
}

.alert-text {
    font-size: 14px;
    color: #856404;
    margin-bottom: 4px;
    font-weight: 500;
}

.alert-task-name {
    font-size: 12px;
    color: #666;
    font-weight: 600;
}

.alert-dismiss {
    background: none;
    border: none;
    font-size: 20px;
    color: #856404;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    flex-shrink: 0;
    transition: all 0.2s;
}

.alert-dismiss:hover {
    background: rgba(0,0,0,0.1);
    color: #333;
}

/* Adjust body padding when banner is visible */
body.has-alert-banner {
    padding-top: 48px;
}

/* Adjust header when banner is visible */
body.has-alert-banner .header {
    margin-top: 48px;
}


/* Modal Alerts Section */
.modal-alerts {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 16px;
}

.modal-alert-header {
    font-size: 14px;
    font-weight: 600;
    color: #856404;
    margin-bottom: 8px;
}

#modalAlertItems {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-alert-item {
    background: rgba(255, 255, 255, 0.5);
    padding: 8px;
    border-radius: 4px;
    font-size: 13px;
    color: #856404;
}

/* Modal Questions Section */
.modal-questions {
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 16px;
}

.modal-question-header {
    font-size: 14px;
    font-weight: 600;
    color: #1565c0;
    margin-bottom: 8px;
}

#modalQuestionItems {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-question-item {
    background: rgba(255, 255, 255, 0.5);
    padding: 8px;
    border-radius: 4px;
    font-size: 13px;
    color: #1565c0;
}

/* Modal Alert Conditions Section */
.modal-alert-conditions {
    background: #f3e5f5;
    border-left: 4px solid #9c27b0;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 16px;
}

.modal-alert-conditions-header {
    font-size: 14px;
    font-weight: 600;
    color: #6a1b9a;
    margin-bottom: 8px;
}

#modalAlertConditionItems {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-alert-condition-item {
    background: rgba(255, 255, 255, 0.5);
    padding: 8px;
    border-radius: 4px;
    font-size: 13px;
    color: #6a1b9a;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.3s ease;
}

.modal-condition-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #9c27b0;
    flex-shrink: 0;
}

.modal-condition-label {
    flex: 1;
    cursor: pointer;
}


/* Chatbot Button (Floating in top-right corner, below alert button) */
/* Duplicate chatbot-button styles removed - using the one at line 633 instead */

@keyframes pulse-blue {
    0%, 100% {
        transform: scale(1);
        opacity: 0.7;
    }
    50% {
        transform: scale(1.4);
        opacity: 0;
    }
}


/* Chatbot Popup */
.chatbot-popup {
    position: fixed;
    bottom: 60px;
    right: 20px;
    width: 350px;
    height: 80vh;
    max-height: 900px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    z-index: 998;
}

.chatbot-popup.open {
    display: flex;
}

.chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.chatbot-close:hover {
    background: rgba(255,255,255,0.2);
}

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 98%;
    word-wrap: break-word;
    margin-bottom: 12px;
}

.chat-message.user {
    background: #d6e0ff;
    color: #333;
    align-self: flex-end;
    margin-left: auto;
    max-width: 80%;
}

.chat-message.bot {
    background: #e8f5e9;  /* Light green for regular bot messages */
    color: #333;
    align-self: flex-start;
    max-width: 98%;
}

.chat-message.typing {
    text-align: left;
    padding-left: 12px;
}

/* Clarification Message Styles */
.chat-message.clarification {
    background: #fffde7;  /* Very light yellow for clarifications */
    border: 1px solid #fff59d;
    border-left: 3px solid #ffeb3b;
    border-radius: 12px;
    padding: 12px 14px;
    margin: 8px 0;
}

.clarification-message {
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 12px;
    padding: 16px;
    margin: 8px 0;
}

.clarification-question {
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
    font-size: 15px;
}

.clarification-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.clarification-option-btn {
    background: #fff;
    border: 2px solid #667eea;
    color: #667eea;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    transition: all 0.2s;
}

.clarification-option-btn:hover {
    background: #667eea;
    color: white;
    transform: translateX(4px);
}

.clarification-option-btn:active {
    transform: translateX(2px);
}

.clarification-footer {
    font-size: 13px;
    color: #666;
    font-style: italic;
    text-align: center;
    margin-top: 8px;
}

.chatbot-input-container {
    padding: 12px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 8px;
}

.chatbot-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.chatbot-send {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.chatbot-send:hover {
    background: #5568d3;
}

/* Debug Panel */
.debug-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1e1e1e;
    color: #d4d4d4;
    border-top: 2px solid #667eea;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 12px;
    z-index: 10000;
    max-height: 400px;
    display: flex;
    flex-direction: column;
}

.debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #2d2d2d;
    border-bottom: 1px solid #3e3e3e;
    font-weight: 600;
    color: #667eea;
}

.debug-header-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.debug-copy {
    background: #667eea;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 4px;
    transition: background 0.2s;
}

.debug-copy:hover {
    background: #5568d3;
}

.debug-toggle {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    transition: transform 0.2s;
}

.debug-toggle:hover {
    background: rgba(102, 126, 234, 0.1);
    border-radius: 4px;
}

.debug-panel.collapsed .debug-toggle {
    transform: rotate(-90deg);
}

.debug-content {
    overflow-y: auto;
    padding: 12px 16px;
    flex: 1;
}

.debug-panel.collapsed .debug-content {
    display: none;
}

.debug-section {
    margin-bottom: 16px;
    padding: 12px;
    background: #252526;
    border-radius: 4px;
    border-left: 3px solid #667eea;
}

.debug-section-title {
    font-weight: 700;
    color: #4ec9b0;
    margin-bottom: 8px;
    font-size: 13px;
}

.debug-item {
    margin: 6px 0;
    padding: 6px 8px;
    background: #1e1e1e;
    border-radius: 3px;
    border-left: 2px solid #3e3e3e;
}

.debug-item-key {
    color: #9cdcfe;
    font-weight: 600;
}

.debug-item-value {
    color: #ce9178;
    margin-left: 8px;
}

.debug-item-array {
    color: #dcdcaa;
}

.debug-item-object {
    margin-left: 16px;
    padding-left: 12px;
    border-left: 1px solid #3e3e3e;
}

.debug-alert-mismatch {
    background: #5a1e1e !important;
    border-left-color: #f48771 !important;
}

.debug-warning {
    color: #f48771;
    font-weight: 700;
}

.debug-success {
    color: #4ec9b0;
    font-weight: 700;
}

.debug-count {
    display: inline-block;
    background: #667eea;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    margin-left: 8px;
}


/* Task Item Icon Reordering - checkbox, star, pencil, calendar, alert, then text */
.task-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.task-item input[type="checkbox"] {
    order: 1;
    flex-shrink: 0;
}

.task-item .task-star {
    order: 2;
    flex-shrink: 0;
}

.task-item .task-edit-btn {
    order: 3;
    flex-shrink: 0;
}

.task-item .task-calendar-icon-separate {
    order: 4;
    flex-shrink: 0;
}

.task-item .task-alert-icon {
    order: 5;
    flex-shrink: 0;
}

.task-item .task-text {
    order: 6;
    flex: 1;
    min-width: 0;
}

/* Planning Overlay - locks controls during planning */
.planning-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 2000;
    display: none;
}

/* Task Rows in Chat - each on own line, matching task list style */
.chat-task-row {
    display: block;
    margin: 4px 0;
    border-radius: 4px;
    transition: all 0.2s;
    width: 100%;
}

.chat-task-row table {
    width: 100%;
    table-layout: fixed;
}

.chat-task-row .task-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.chat-task-row:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.chat-task-row.completed {
    opacity: 0.6;
}

.chat-task-row.overdue .task-text {
    color: #d32f2f;
    font-weight: 500;
}

.chat-task-row.completed .task-text {
    text-decoration: line-through;
    color: #999;
}

/* Clarification Task Reference - for "by the way" questions */
.chat-task-reference {
    background: #f0f7ff;
    border: 1px solid #4a90e2;
    border-left: 4px solid #4a90e2;
    border-radius: 6px;
    padding: 12px 16px;
    margin: 12px 0;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-task-reference:hover {
    background: #e6f2ff;
    border-color: #357abd;
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.2);
}

.chat-task-reference .task-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.chat-task-reference .task-text {
    font-weight: 500;
    color: #2c3e50;
    flex: 1;
}

/* Clarification Option Buttons */
.chat-option-button {
    display: inline-block;
    background: #4a90e2;
    color: white;
    border: 2px solid #357abd;  /* Visible border for separation */
    border-radius: 20px;
    padding: 10px 20px;
    margin: 6px 8px 6px 0;  /* More vertical margin for separation */
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(74, 144, 226, 0.35);
}

.chat-option-button:hover {
    background: #357abd;
    border-color: #2a5f8f;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(74, 144, 226, 0.45);
}

.chat-option-button:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(74, 144, 226, 0.3);
}


/* Auth Container Styles */
.auth-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 10000;
}

.auth-container.hidden {
    display: none;
}

.auth-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.auth-title {
    color: #667eea;
    margin: 0 0 10px 0;
    font-size: 32px;
    font-weight: 600;
}

.auth-subtitle {
    color: #666;
    margin: 0 0 30px 0;
    font-size: 16px;
}

.auth-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.auth-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.auth-button:active {
    transform: translateY(0);
}

.app-container.hidden {
    display: none;
}


/* Archive Modal Content */
.archive-content {
    max-height: 60vh;
    overflow-y: auto;
    padding: 0;
}

.archive-task-item {
    padding: 12px;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s;
}

.archive-task-item:hover {
    background-color: #f9f9f9;
}

.archive-task-item:last-child {
    border-bottom: none;
}

/* Archive Modal Enhancements */
.archive-controls {
    padding: 16px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.archive-filter-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.archive-filter-input:focus {
    outline: none;
    border-color: #007AFF;
}

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

.archive-action-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    background: #007AFF;
    color: white;
    transition: background 0.2s;
}

.archive-action-btn:hover {
    background: #0056b3;
}

.archive-action-btn.delete {
    background: #ff3b30;
}

.archive-action-btn.delete:hover {
    background: #cc2e24;
}

.archive-select-header {
    padding: 12px 16px;
    background: #f8f8f8;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    font-size: 14px;
    font-weight: 500;
}

.archive-select-header input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.archive-task-item {
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: background 0.2s;
}

.archive-task-item:hover {
    background: #f8f8f8;
}

.archive-task-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    cursor: pointer;
    flex-shrink: 0;
}

.archive-task-content {
    flex: 1;
    min-width: 0;
}

.archive-task-text {
    font-weight: 500;
    margin-bottom: 4px;
    word-wrap: break-word;
}

.archive-task-meta {
    font-size: 12px;
    color: #999;
}


/* User Info Modal */
.user-info-section {
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.user-info-field {
    display: flex;
    margin-bottom: 12px;
    font-size: 14px;
}

.user-info-field label {
    font-weight: 600;
    min-width: 140px;
    color: #333;
    flex-shrink: 0;
}

.user-info-field span {
    color: #666;
    word-wrap: break-word;
    overflow-wrap: break-word;
    flex: 1;
    max-width: 100%;
}

.facts-section {
    padding: 20px;
}

.facts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.facts-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.facts-delete-all-btn {
    padding: 8px 16px;
    background: #ff3b30;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.facts-delete-all-btn:hover {
    background: #d32f2f;
}

.facts-table-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 8px;
}

.facts-table {
    width: 100%;
    border-collapse: collapse;
}

.facts-table thead {
    background: #f5f5f5;
    position: sticky;
    top: 0;
}

.facts-table th {
    padding: 12px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    border-bottom: 2px solid #ddd;
}

.facts-table td {
    padding: 12px;
    font-size: 14px;
    border-bottom: 1px solid #eee;
}

.facts-table tbody tr:hover {
    background: #f9f9f9;
}

.facts-table tbody tr:last-child td {
    border-bottom: none;
}

.fact-text {
    color: #333;
    cursor: text;
    padding: 8px 12px !important;
    border-radius: 4px;
    transition: background-color 0.2s;
    outline: none;
    min-width: 200px;
}

.fact-text:hover {
    background-color: #f0f7ff;
}

.fact-text:focus {
    background-color: #e8f4ff;
    box-shadow: 0 0 0 2px #007AFF40;
}

.fact-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.fact-action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.fact-delete-btn {
    background: #ff3b30;
    color: white;
}

.fact-delete-btn:hover {
    background: #d32f2f;
}

.fact-edit-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #007AFF;
    border-radius: 4px;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.fact-edit-input:focus {
    outline: none;
    border-color: #0056b3;
}

/* Debug Button */
.debug-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    margin-left: 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: none;
}

.debug-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

/* Debug Button in Chat */
.debug-btn-chat {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    margin-left: auto;
    margin-right: 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: none;
    color: white;
}

.debug-btn-chat:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Debug Modal */
.debug-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.debug-modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.debug-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.debug-modal-header h2 {
    margin: 0;
    font-size: 24px;
    color: #333;
}

.debug-close-btn {
    background: none;
    border: none;
    font-size: 32px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.debug-close-btn:hover {
    background: #f0f0f0;
    color: #333;
}

.debug-modal-body {
    overflow-y: auto;
    padding: 20px;
    flex: 1;
}

.debug-section {
    margin-bottom: 30px;
}

.debug-section h3 {
    margin: 0 0 10px 0;
    font-size: 18px;
    color: #555;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 5px;
}

.debug-section pre {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 15px;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #333;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .debug-btn {
        font-size: 18px;
        padding: 2px 6px;
    }
    
    .debug-btn-chat {
        font-size: 16px;
        padding: 2px 6px;
    }
    
    .debug-modal-content {
        width: 95%;
        max-height: 85vh;
    }
    
    .debug-modal-header h2 {
        font-size: 20px;
    }
    
    .debug-section pre {
        font-size: 11px;
    }
}

/* Welcome Popup Styles */
.welcome-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

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

.welcome-popup {
    background: white;
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

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

.welcome-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 24px;
    border-radius: 16px 16px 0 0;
}

.welcome-header h2 {
    margin: 0;
    font-size: 28px;
    font-weight: 600;
}

.welcome-content {
    padding: 24px;
}

.welcome-content > p {
    font-size: 16px;
    color: #333;
    margin-bottom: 24px;
    line-height: 1.5;
}

.welcome-section {
    margin-bottom: 24px;
}

.welcome-section h3 {
    font-size: 18px;
    color: #667eea;
    margin-bottom: 12px;
    font-weight: 600;
}

.welcome-section ul {
    list-style: none;
    padding: 0;
}

.welcome-section li {
    padding: 8px 0;
    padding-left: 24px;
    position: relative;
    color: #555;
    line-height: 1.5;
}

.welcome-section li::before {
    content: "•";
    position: absolute;
    left: 8px;
    color: #667eea;
    font-weight: bold;
}

.welcome-section li strong {
    color: #333;
}

.welcome-footer {
    padding: 20px 24px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: center;
}

.welcome-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 40px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.welcome-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.welcome-btn:active {
    transform: translateY(0);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .welcome-popup {
        width: 95%;
        max-height: 90vh;
    }
    
    .welcome-header h2 {
        font-size: 24px;
    }
    
    .welcome-content {
        padding: 20px;
    }
    
    .welcome-section h3 {
        font-size: 16px;
    }
}

/* Delete Account Button */
.delete-account-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.delete-account-btn:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

.delete-account-btn:active {
    transform: translateY(0);
}

/* Clarification Message Styles */
.clarification-message-simple {
    margin: 8px 0;
}

.clarification-message-simple p {
    margin-bottom: 12px;
}

.clarification-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    align-items: flex-start; /* Make buttons only as wide as their content */
}

.clarification-option-btn {
    padding: 10px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    text-align: left;
    transition: background 0.2s;
}

.clarification-option-btn:hover {
    background: #5568d3;
}

.clarification-option-btn:active {
    background: #4451b8;
}


/* Modal z-index fix - ensure modals appear above everything */
.modal {
    z-index: 10000 !important;
}

.modal-content {
    z-index: 10001 !important;
}


/* ========================================
   PERMANENT AI CHAT PANEL STYLES
   ======================================== */

/* Permanent AI Chat Panel (bottom ~33% of screen) */
.ai-chat-panel {
    flex: 2;  /* ~33% of vertical space (2 out of 6 total) */
    display: flex;
    flex-direction: column;
    background: white;
    border-top: 2px solid #667eea;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    z-index: 100;
    position: relative;
    min-height: 150px;
    transition: flex 0.25s ease-out;  /* Smooth expand/collapse animation */
}

/* Expanded AI Chat Panel - shows only header/tabs and ~2 tasks */
.ai-chat-panel.expanded {
    flex: 10;  /* Takes most of the screen */
}

/* When chat is expanded, shrink the scrollable content */
.ai-chat-panel.expanded ~ .scrollable-content,
.content:has(.ai-chat-panel.expanded) .scrollable-content {
    flex: 1;  /* Minimal space for task list */
}

.ai-chat-panel.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2001;
    flex: none;
    height: 100vh;
    border-top: none;
}

.ai-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4px 12px;  /* Very compact header - half as tall */
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 13px;
}

.ai-chat-header-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ai-chat-fullscreen-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.ai-chat-fullscreen-btn:hover {
    background: rgba(255,255,255,0.2);
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f9f9f9;
    min-height: 0;
}

.ai-chat-input-container {
    padding: 8px;  /* Reduced padding for compact layout */
    padding-bottom: calc(8px + var(--safe-area-inset-bottom));  /* Add safe area for iOS home indicator */
    padding-left: calc(8px + var(--safe-area-inset-left));
    padding-right: calc(8px + var(--safe-area-inset-right));
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 6px;
    background: white;
}

.ai-chat-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    background: #f0f8ff;  /* Light blue background */
}

.ai-chat-input:focus {
    outline: none;
    border-color: #667eea;
    background: #e6f3ff;  /* Slightly darker blue on focus */
}

.ai-chat-debug-btn {
    padding: 10px 12px;
    background: #f0f0f0;
    color: #666;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-debug-btn:hover {
    background: #e0e0e0;
    border-color: #ccc;
}

.ai-chat-send {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.ai-chat-send:hover {
    background: #5568d3;
}

/* Scrollable Content Area (top ~67%) */
.scrollable-content {
    flex: 4;  /* ~67% of vertical space (4 out of 6 total) */
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    transition: flex 0.25s ease-out;  /* Smooth expand/collapse animation */
}

/* Archive Button in Header */
.archive-btn-header {
    font-size: 16px;
}


/* AI Chat Panel Notification Styles */
.ai-chat-panel.has-notification .ai-chat-header {
    animation: header-pulse 2s infinite;
}

@keyframes header-pulse {
    0% { 
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
    }
    50% { 
        box-shadow: 0 0 0 8px rgba(102, 126, 234, 0);
    }
    100% { 
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
    }
}

.ai-chat-panel.has-question .ai-chat-header {
    animation: header-pulse-orange 2s infinite;
}

@keyframes header-pulse-orange {
    0% { 
        box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.7);
    }
    50% { 
        box-shadow: 0 0 0 8px rgba(255, 152, 0, 0);
    }
    100% { 
        box-shadow: 0 0 0 0 rgba(255, 152, 0, 0);
    }
}

/* Debug Button Styles - Always Visible with High Z-Index */
.ai-chat-debug-btn,
.debug-btn-chat {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    z-index: 10000 !important;
    position: relative;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
}

.ai-chat-debug-btn:hover,
.debug-btn-chat:hover {
    background: #5568d3;
    transform: scale(1.05);
}

.ai-chat-debug-btn:active,
.debug-btn-chat:active {
    transform: scale(0.95);
}

/* Ensure debug button in input container is visible */
.ai-chat-input-container .ai-chat-debug-btn {
    margin: 0 4px;
    flex-shrink: 0;
}

/* Ensure debug button in header is visible */
.ai-chat-header-buttons .debug-btn-chat {
    margin-left: 8px;
}

/* Visual Debug Console for Mobile */
.debug-entry {
    padding: 2px 5px;
    margin: 1px 0;
    border-left: 3px solid #0f0;
    font-size: 10px;
    line-height: 1.3;
}

.debug-entry.debug-info {
    color: #0f0;
    border-left-color: #0f0;
}

.debug-entry.debug-warn {
    color: #ff0;
    border-left-color: #ff0;
}

.debug-entry.debug-error {
    color: #f00;
    border-left-color: #f00;
    font-weight: bold;
}

.debug-entry.debug-success {
    color: #0ff;
    border-left-color: #0ff;
}


/* Debug Button Styles */
.debug-btn, .debug-btn-chat {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.debug-btn:hover, .debug-btn-chat:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
}

/* Mobile Debug Button - Fixed Bottom Left */
.debug-btn-mobile {
    position: fixed;
    bottom: calc(20px + var(--safe-area-inset-bottom, 0px));
    left: calc(20px + var(--safe-area-inset-left, 0px));
    width: 44px;
    height: 44px;
    background: rgba(74, 144, 226, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    z-index: 9999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.debug-btn-mobile:hover {
    background: rgba(74, 144, 226, 1);
    transform: scale(1.1);
}

/* Debug Modal Styles */
.debug-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.debug-modal-content {
    background: white;
    border-radius: 12px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.debug-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #4a90e2;
    color: white;
}

.debug-modal-header h2 {
    margin: 0;
    font-size: 18px;
}

.debug-close-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0 8px;
}

.debug-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.debug-section {
    margin-bottom: 20px;
}

.debug-section h3 {
    margin-bottom: 10px;
    color: #333;
}

.debug-section pre {
    background: #f5f5f5;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

.debug-subsection {
    margin-bottom: 15px;
}

.debug-subsection h4 {
    margin-bottom: 8px;
    color: #555;
}

/* AI Chat Debug Button */
.ai-chat-debug-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 8px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.ai-chat-debug-btn:hover {
    opacity: 1;
}


/* ========================================
   AI CHAT TOAST NOTIFICATION SYSTEM
   ======================================== */

/* Collapsed Chat Bar State */
.ai-chat-panel.collapsed {
    flex: none !important;
    height: 56px;
    min-height: 56px;
    max-height: 56px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* Float higher with margin and rounded corners */
    margin: 0 12px 16px 12px;
    border-radius: 28px;
    /* Add outline/shadow for visibility */
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4), 0 2px 8px rgba(0,0,0,0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    overflow: hidden;
}

.ai-chat-panel.collapsed .ai-chat-messages,
.ai-chat-panel.collapsed .ai-chat-input-container {
    display: none;
}

/* Collapsed bar header becomes the entire bar */
.ai-chat-panel.collapsed .ai-chat-header {
    height: 100%;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 28px;
}

/* Color cycling animation when alerts are present - blues and purples only */
@keyframes alertColorCycle {
    0% { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
    25% { background: linear-gradient(135deg, #5b6fd6 0%, #8b5cf6 100%); }
    50% { background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%); }
    75% { background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%); }
    100% { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
}

/* Apply animation when collapsed AND has alerts */
.ai-chat-panel.collapsed.has-alerts .ai-chat-header {
    animation: alertColorCycle 4s ease-in-out infinite;
}

/* AI Avatar container for badge positioning */
.ai-chat-avatar-container {
    position: relative;
    flex-shrink: 0;
}

/* AI Avatar in collapsed bar */
.ai-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

/* Last message preview in collapsed bar */
.ai-chat-preview {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ai-chat-preview-text {
    font-size: 14px;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.95;
}

.ai-chat-preview-time {
    font-size: 11px;
    opacity: 0.7;
}

/* Question badge over robot emoji */
.ai-chat-question-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #dc3545;
    color: white;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    border: 2px solid #4a90e2;
    z-index: 1;
}

.ai-chat-question-badge.large {
    min-width: 22px;
    height: 22px;
    font-size: 10px;
}

.ai-chat-question-badge:empty {
    display: none;
}

/* Pulse animation for chat bar when there are unanswered questions */
@keyframes chat-bar-pulse {
    0%, 100% {
        box-shadow: 0 -2px 10px rgba(74, 144, 226, 0.3);
    }
    50% {
        box-shadow: 0 -2px 20px rgba(74, 144, 226, 0.6), 0 0 30px rgba(74, 144, 226, 0.3);
    }
}

.ai-chat-panel.collapsed.has-questions {
    animation: chat-bar-pulse 2s ease-in-out infinite;
}

.ai-chat-panel.collapsed.has-questions .ai-chat-header {
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
}

/* Up chevron / drag handle */
.ai-chat-expand-hint {
    font-size: 18px;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.2s;
}

.ai-chat-panel.collapsed:hover .ai-chat-expand-hint {
    opacity: 1;
    transform: translateY(-2px);
}

/* ========================================
   FLOATING TOAST NOTIFICATION
   ======================================== */

.ai-chat-toast {
    position: fixed;
    bottom: calc(56px + 32px + var(--safe-area-inset-bottom, 0px));
    left: 24px;
    right: 24px;
    max-width: none;
    margin: 0;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    cursor: pointer;
    
    /* Animation initial state */
    transform: translateY(100%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.25s;
}

.ai-chat-toast.visible {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.ai-chat-toast.fade-out {
    opacity: 0;
    transform: translateY(0);
    transition: opacity 0.3s ease-out;
}

.ai-chat-toast-content {
    color: white;
    font-size: 15px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.ai-chat-toast-hint {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    margin-top: 6px;
    font-style: italic;
}

/* Toast hover effect */
.ai-chat-toast:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: translateY(-2px);
}

.ai-chat-toast:active {
    transform: translateY(0);
}

/* ========================================
   FULLSCREEN EXPANDED CHAT
   ======================================== */

.ai-chat-panel.fullscreen-expanded {
    position: fixed !important;
    top: 16px;
    left: 12px;
    right: 12px;
    /* Use dynamic viewport height for mobile browsers */
    bottom: 16px;
    height: calc(var(--viewport-height, 100vh) - 32px) !important;
    height: calc(100dvh - 32px) !important; /* Dynamic viewport height - excludes browser chrome */
    max-height: calc(var(--viewport-height, 100vh) - 32px) !important;
    max-height: calc(100dvh - 32px) !important;
    z-index: 2001;
    flex: none !important;
    border-radius: 20px;
    border-top: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Ensure messages and input are visible when fullscreen-expanded */
.ai-chat-panel.fullscreen-expanded .ai-chat-messages,
.ai-chat-panel.fullscreen-expanded .ai-chat-input-container {
    display: flex !important;
}

.ai-chat-panel.fullscreen-expanded .ai-chat-messages {
    flex: 1;
    flex-direction: column;
    min-height: 0; /* Allow shrinking */
}

.ai-chat-panel.fullscreen-expanded .ai-chat-input-container {
    flex-shrink: 0;
    /* Add extra padding at bottom for mobile browser chrome */
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}

/* Semi-transparent scrim behind expanded chat */
.ai-chat-scrim {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.15);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-out, visibility 0.3s;
}

.ai-chat-scrim.visible {
    opacity: 1;
    visibility: visible;
}

/* Close/minimize button for expanded chat */
.ai-chat-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 12px;
    border-radius: 4px;
    transition: background 0.2s;
    display: none;
}

.ai-chat-panel.fullscreen-expanded .ai-chat-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Fullscreen button removed - using down arrow to minimize instead */

/* Accessibility - role="status" ensures screen reader announces toast */

/* Mobile responsive adjustments */
@media (max-width: 480px) {
    .ai-chat-toast {
        left: 12px;
        right: 12px;
        bottom: calc(60px + 12px + var(--safe-area-inset-bottom, 0px));
    }
    
    .ai-chat-panel.collapsed {
        height: 56px;
        min-height: 56px;
        max-height: 56px;
    }
    
    .ai-chat-avatar {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    .ai-chat-preview-text {
        font-size: 13px;
    }
}

/* Landscape orientation */
@media (orientation: landscape) and (max-height: 500px) {
    .ai-chat-toast {
        max-width: 50%;
        left: auto;
        right: 16px;
    }
}


/* Hide header buttons when collapsed, show preview elements */
.ai-chat-panel.collapsed .ai-chat-header-buttons {
    display: none;
}

.ai-chat-panel.collapsed .ai-chat-avatar,
.ai-chat-panel.collapsed .ai-chat-preview,
.ai-chat-panel.collapsed .ai-chat-expand-hint {
    display: flex;
}

/* Show header buttons when expanded, hide preview elements */
.ai-chat-panel:not(.collapsed) .ai-chat-avatar,
.ai-chat-panel:not(.collapsed) .ai-chat-avatar-container,
.ai-chat-panel:not(.collapsed) .ai-chat-preview,
.ai-chat-panel:not(.collapsed) .ai-chat-expand-hint,
.ai-chat-panel:not(.collapsed) .ai-chat-unread-badge,
.ai-chat-panel:not(.collapsed) .ai-chat-question-badge {
    display: none;
}

/* Hide header alert badge when expanded */
.ai-chat-panel.fullscreen-expanded ~ .header .alert-count-badge,
.ai-chat-panel.fullscreen-expanded ~ .header #alertBanner {
    display: none !important;
}

.ai-chat-panel:not(.collapsed) .ai-chat-header-buttons {
    display: flex;
}

/* Header title for expanded state */
.ai-chat-panel:not(.collapsed) .ai-chat-header::before {
    content: 'AI Assistant';
    font-weight: 600;
    font-size: 14px;
}

/* Ensure header is clickable in collapsed state */
.ai-chat-panel.collapsed .ai-chat-header {
    cursor: pointer;
}

.ai-chat-panel.collapsed .ai-chat-header:hover {
    background: linear-gradient(135deg, #7a8eee 0%, #8a5bb2 100%);
}

/* Preview text styling */
.ai-chat-preview {
    flex-direction: column;
    align-items: flex-start;
}
