        :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 {
            /* Times New Roman across the app (May 2026) — falls back
               to the platform serif if not installed. */
            font-family: "Times New Roman", Times, serif;
            /* Just-off-white background (May 2026 v2) — Claude-like
               very subtle warm tint, far less yellow than the prior
               cream. Body color forced to pure black for max contrast
               on the warm surface. */
            background: #faf9f5;
            color: #000000;
            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 {
            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;
        }

        .weather-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) */

        /* Search Bar (below header) — tyrian purple background with white text */
        .search-bar {
            background: #630330;
            padding: 6px 12px;
            display: flex;
            align-items: center;
            gap: 8px;
            border-bottom: 1px solid #4a0225;
        }

        .search-bar-icon {
            font-size: 16px;
            color: #fff;
        }

        .search-bar-input {
            flex: 1;
            border: none;
            outline: none;
            font-size: 14px;
            padding: 6px 0;
            background: transparent;
            color: #fff;
        }

        .search-bar-input::placeholder {
            color: rgba(255, 255, 255, 0.7);
        }

        .search-bar-close {
            background: none;
            border: none;
            font-size: 16px;
            color: rgba(255, 255, 255, 0.8);
            cursor: pointer;
            padding: 4px 8px;
        }

        .search-bar-close:hover {
            color: #fff;
        }

        .goal-filter-dropdown {
            position: relative;
            cursor: pointer;
            padding: 4px 6px;
            border-radius: 6px;
            background: rgba(255, 255, 255, 0.15);
            display: flex;
            align-items: center;
            gap: 2px;
        }

        .goal-filter-dropdown .emoji {
            font-size: 18px;
        }

        .goal-filter-dropdown .arrow {
            font-size: 10px;
            color: rgba(255, 255, 255, 0.7);
        }

        .goal-filter-menu {
            position: absolute;
            top: 100%;
            left: 0;
            margin-top: 4px;
            background: #630330;
            border: 1px solid #4a0225;
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.3);
            z-index: 1000;
            min-width: 180px;
            padding: 4px 0;
        }

        .goal-filter-menu-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 12px;
            cursor: pointer;
            color: #fff;
            font-size: 14px;
        }

        .goal-filter-menu-item:hover {
            background: rgba(255, 255, 255, 0.1);
        }

        .goal-filter-menu-item.active {
            font-weight: bold;
        }

        .goal-filter-menu-item .emoji {
            font-size: 18px;
        }

        /* Search button active state in header */
        .search-btn-header.active {
            background: rgba(255,255,255,0.5);
        }

        /* 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;
        }

        /* Tab alert badge */
        .tab-alert-badge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 18px;
            height: 18px;
            padding: 0 5px;
            margin-left: 4px;
            background: #dc3545;
            color: white;
            font-size: 11px;
            font-weight: 700;
            border-radius: 9px;
            line-height: 1;
            vertical-align: middle;
        }

        /* Alerts tab container */
        .alerts-tab-container {
            flex: 1;
            overflow-y: auto;
            padding: 12px;
        }

        .alerts-empty-state {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 48px 16px;
            text-align: center;
        }

        /* 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: #e8f5e9;  /* Light green background — distinct from blue search bar */
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            padding: 10px;
            border: 2px solid #c8e6c9;
            border-radius: 8px;
            font-size: 15px;
            /* Force black text — the light-green background needs a dark
               foreground to stay readable in both light and dark mode. */
            color: #000;
            transition: border-color 0.3s;
        }

        .new-task-input::placeholder {
            color: rgba(0, 0, 0, 0.45);
        }

        .new-task-input:focus {
            outline: none;
            border-color: #43a047;
            background: #dcedc8;  /* Slightly darker green 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-new {
            background: rgba(34, 197, 94, 0.08);
        }
        .section-new .section-label {
            color: #22c55e;
            font-weight: 700;
        }
        
        .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-overdue-glow {
            box-shadow: 0 0 12px 2px rgba(220, 53, 69, 0.25), inset 0 0 8px 1px rgba(220, 53, 69, 0.1);
            border: 1px solid rgba(220, 53, 69, 0.35);
            border-radius: 8px;
        }
        .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-today-glow {
            box-shadow: 0 0 12px 2px rgba(212, 175, 55, 0.3), inset 0 0 8px 1px rgba(212, 175, 55, 0.08);
            border: 1px solid rgba(212, 175, 55, 0.4);
            border-radius: 8px;
        }
        .section-today.section-today-complete {
            box-shadow: 0 0 14px 3px rgba(212, 175, 55, 0.35), inset 0 0 10px 2px rgba(212, 175, 55, 0.1);
            border: 1.5px solid rgba(212, 175, 55, 0.5);
            border-radius: 8px;
            padding: 12px 16px;
        }
        .today-all-done-message {
            color: #b8860b;
            font-weight: 600;
            font-size: 14px;
            padding: 8px 0 4px 0;
            letter-spacing: 0.01em;
        }
        .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-suggested {
            background: rgba(102, 126, 234, 0.08);
        }
        .section-suggested .section-label {
            color: #667eea;
            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-this-week {
            background: rgba(16, 185, 129, 0.06);
        }
        .section-this-week .section-label {
            color: #10b981;
            font-weight: 600;
        }
        
        .section-next-week {
            background: rgba(16, 185, 129, 0.04);
        }
        .section-next-week .section-label {
            color: #059669;
            font-weight: 500;
        }
        
        .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;
        }
        
        .section-done {
            background: rgba(0, 0, 0, 0.03);
        }
        .section-done .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 Completion Toggle */
        .modal-completion-toggle {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 10px 16px;
            background: #f0f0f0;
            border: 2px solid #e0e0e0;
            border-radius: 8px;
            cursor: pointer;
            font-size: 14px;
            font-weight: 500;
            color: #333;
            width: 100%;
            transition: all 0.2s;
        }

        .modal-completion-toggle:hover {
            background: #e8e8e8;
            border-color: #ccc;
        }

        .modal-completion-toggle.completed {
            background: #e8f5e9;
            border-color: #4caf50;
            color: #2e7d32;
        }

        .modal-completion-toggle #modalCompletionIcon {
            font-size: 18px;
        }

        /* Task modal background when task is completed */
        .modal-content.task-completed {
            background: #f5f5f5;
            border: 2px solid #bdbdbd;
        }

        .modal-content.task-completed .modal-header {
            color: #757575;
        }

        /* 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;
}

/* Suggestion lightbulb icon */
.task-suggestion-bulb {
    display: inline-block;
    cursor: pointer;
    font-size: 14px;
    margin-right: 4px;
    opacity: 0.8;
    transition: opacity 0.15s;
}

.task-suggestion-bulb:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Recurrence icon — inline next to checkbox for completable occurrences */
.task-recurrence-icon {
    display: inline-block;
    font-size: 14px;
    margin-right: 4px;
    vertical-align: middle;
    line-height: 1;
}

.task-recurrence-icon-clickable {
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.15s, transform 0.15s;
}

.task-recurrence-icon-clickable:hover {
    opacity: 1;
    transform: scale(1.15);
}

/* Grey 🔁 for non-completable calendar occurrences */
.task-recurrence-icon-grey {
    opacity: 0.35;
    cursor: default;
    filter: grayscale(100%);
}

/* Recurrence pattern subtitle below task text */
.task-recurrence-pattern {
    display: block;
    font-size: 11px;
    color: #999;
    margin-top: 2px;
    line-height: 1.3;
    font-style: italic;
}

/* Inline clarification bubble below the task text. Mirrors the Flutter
   task-row clarification bubble: muted surface with a primary-color left
   border, an accent "?" prefix, tappable option chips, and a fixed
   "Reply" chip. */
.task-clarification-bubble {
    display: block;
    margin-top: 6px;
    padding: 8px 10px;
    background: #f1f5f9;
    border-left: 3px solid #6366f1;
    border-radius: 8px;
    cursor: pointer;
}
.task-clarification-question {
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
    line-height: 1.35;
}
.task-clarification-qmark {
    color: #6366f1;
    font-weight: 700;
}
.task-clarification-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}
.task-clarification-chip {
    padding: 4px 10px;
    font-size: 12px;
    color: #1e293b;
    background: transparent;
    border: 1px solid rgba(100, 116, 139, 0.4);
    border-radius: 12px;
    cursor: pointer;
    line-height: 1.2;
}
.task-clarification-chip:hover {
    background: rgba(99, 102, 241, 0.08);
}
.task-clarification-chip-reply {
    color: #6366f1;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.6);
}

/* Suggestion popup */
.suggestion-popup {
    position: fixed;
    z-index: 9999;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    padding: 12px 16px;
    max-width: 280px;
    min-width: 180px;
    font-size: 13px;
    line-height: 1.4;
}

.suggestion-popup-header {
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.suggestion-popup-reason {
    color: #555;
    margin-bottom: 10px;
}

.suggestion-popup-dismiss {
    display: block;
    width: 100%;
    padding: 6px 12px;
    background: #f0f0f0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    transition: background 0.15s;
}

.suggestion-popup-dismiss:hover {
    background: #e0e0e0;
    color: #333;
}



/* 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;
}

/* Goal Tag in Chat - styled chip with emoji + name + goal color */
.chat-goal-tag {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    margin: 8px 0;
    border-radius: 10px;
    border: 1px solid rgba(102, 126, 234, 0.3);
    font-size: 14px;
    font-weight: 600;
}

.chat-goal-emoji {
    font-size: 20px;
    flex-shrink: 0;
}

.chat-goal-name {
    font-weight: 600;
    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
   ======================================== */

/* ========================================
   FLOATING SPEECH-BUBBLE PEEK

   Docks above the permanent chat bar when a new AI message arrives.
   Yellow speech bubble with a down-pointing tail near the bottom-right so
   it visually connects to the chat avatar. Shows the first few lines with
   task/goal tags rendered using the same compact widgets as the chat
   itself (via ChatbotView.markdownToHTML).
   ======================================== */

.ai-chat-peek {
    position: fixed;
    /* Sit above the permanent chat bar (~56px tall) plus a small gap */
    bottom: calc(64px + var(--safe-area-inset-bottom, 0px));
    left: 0;
    right: 0;
    max-width: none;
    margin: 0 12px;
    padding: 12px 8px 12px 16px;
    background: #F4F4F5; /* light neutral grey */
    color: #111827; /* near-black */
    border: 1px solid #D4D4D8;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    gap: 6px;

    /* Animation initial state */
    transform: translateY(110%);
    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;
}

/* No speech-bubble tail — keep the peek a clean full-width toast. */
.ai-chat-peek::before,
.ai-chat-peek::after {
    display: none;
}

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

.ai-chat-peek.fade-out {
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.ai-chat-peek-body {
    flex: 1;
    min-width: 0;
    cursor: pointer;
    padding: 2px 0;
}

.ai-chat-peek-close {
    flex: 0 0 auto;
    background: transparent;
    border: none;
    color: rgba(17, 24, 39, 0.55);
    font-size: 20px;
    line-height: 1;
    width: 28px;
    height: 28px;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: color 0.15s ease, background 0.15s ease;
}

.ai-chat-peek-close:hover {
    color: #111827;
    background: rgba(0, 0, 0, 0.06);
}

.ai-chat-peek-content {
    color: #111827;
    font-size: 14px;
    line-height: 1.4;
    /* 5-line clamp — CSS handles the overflow ellipsis */
    display: -webkit-box;
    -webkit-line-clamp: 5;
    line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

/* Inline task/goal widgets rendered inside the peek. The chat already
   produces a `.chat-task-row` element; we scope it here so sizing works
   inside the clamped peek container. */
.ai-chat-peek-content .chat-task-row {
    margin: 4px 0;
    background: rgba(255, 255, 255, 0.75);
    border-radius: 8px;
    padding: 2px 6px;
}

.ai-chat-peek-content p {
    margin: 0 0 4px 0;
}

.ai-chat-peek-content p:last-child {
    margin-bottom: 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-peek {
        margin: 0 8px;
        left: 0;
        right: 0;
        bottom: calc(60px + 8px + 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 — still full-width, just keep the bottom offset tight. */
@media (orientation: landscape) and (max-height: 500px) {
    .ai-chat-peek {
        bottom: calc(56px + 4px + var(--safe-area-inset-bottom, 0px));
    }
}


/* 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;
}


/* ── Recurrence Controls in Task Modal ──────────────────────── */

/* Container for all recurrence controls */
.recurrence-controls {
    padding: 8px 0;
    border-top: 1px solid #e9ecef;
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 8px;
}

/* Frequency picker — dropdown and sub-control layout */
.frequency-picker {
    margin-bottom: 12px;
}

.frequency-picker .modal-input {
    max-width: 200px;
}

/* Frequency + Every row: half-width columns side by side */
.frequency-interval-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.frequency-picker-half {
    flex: 1 1 0;
    min-width: 0;
}

.frequency-picker-half .modal-input {
    max-width: none;
    width: 100%;
}

/* Yearly month multi-select — 3-letter pills, 2 rows of 6 */
.month-pill-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    margin-top: 4px;
}

@media (max-width: 360px) {
    .month-pill-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.month-pill-btn {
    height: 34px;
    border: 1.5px solid #d0d0d0;
    border-radius: 17px;
    background: #fff;
    color: #555;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0 4px;
    text-align: center;
}

.month-pill-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.month-pill-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Absolute day-of-month picker — 7-column grid of 31 numbered cells */
.day-cell-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-top: 4px;
}

.day-cell-btn {
    aspect-ratio: 1 / 1;
    min-height: 36px;
    border: 1.5px solid #d0d0d0;
    border-radius: 6px;
    background: #fff;
    color: #555;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
    text-align: center;
}

.day-cell-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.day-cell-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Day-of-week toggle buttons for weekly pattern */
.day-of-week-toggles {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.dow-toggle-btn {
    width: 40px;
    height: 34px;
    border: 1.5px solid #d0d0d0;
    border-radius: 6px;
    background: #fff;
    color: #555;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
    line-height: 34px;
    text-align: center;
}

.dow-toggle-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.dow-toggle-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
    font-weight: 600;
}

/* Monthly mode selector (absolute vs relative radio buttons) */
.recurrence-controls input[type="radio"] {
    accent-color: #667eea;
}

/* Starts on / Ends on date pickers */
.recurrence-controls .modal-input[type="date"] {
    max-width: 200px;
}

/* Repeat toggle checkbox styling */
#modalRepeatToggle {
    width: 16px;
    height: 16px;
    accent-color: #667eea;
    cursor: pointer;
}

/* Ends never checkbox */
#modalEndsNever {
    width: 16px;
    height: 16px;
    accent-color: #667eea;
    cursor: pointer;
}


/* ====================================================================
   UI STREAMLINE — NEW CONTROLS (added by UI_STREAMLINE_PROPOSALS.md)
   ==================================================================== */

/* Alert filter toggle bell — empty white by default, filled red when on */
.alert-filter-btn-header {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
}
.alert-filter-btn-header .alert-filter-icon {
    font-size: 16px;
    filter: grayscale(100%) brightness(1.7); /* empty/outlined look */
    opacity: 0.85;
    transition: filter 0.15s ease, color 0.15s ease;
}
.alert-filter-btn-header.active {
    background: rgba(220, 53, 69, 0.9) !important;
    border-color: rgba(255, 255, 255, 0.6) !important;
}
.alert-filter-btn-header.active .alert-filter-icon {
    filter: none;
    opacity: 1;
}
.alert-filter-btn-header .alert-filter-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #dc3545;
    color: white;
    border-radius: 10px;
    padding: 1px 5px;
    font-size: 10px;
    font-weight: bold;
    min-width: 16px;
    text-align: center;
    line-height: 1.4;
    pointer-events: none;
}

/* Star filter toggle — empty/outlined by default, filled amber when on.
   Mirrors the alert filter pattern; amber palette so the two badges
   don't visually compete. The badge shows the count of currently-
   starred active tasks. */
.star-filter-btn-header {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
}
.star-filter-btn-header .star-filter-icon {
    font-size: 18px;
    line-height: 1;
    filter: grayscale(100%) brightness(1.7); /* same black-on-white as bell */
    transition: filter 0.15s ease, opacity 0.15s ease;
}
.star-filter-btn-header.active {
    background: rgba(255, 179, 0, 0.9) !important;
    border-color: rgba(255, 255, 255, 0.6) !important;
}
.star-filter-btn-header.active .star-filter-icon {
    filter: none;
    opacity: 1;
}
.star-filter-btn-header .star-filter-count {
    position: absolute;
    top: 0px;
    right: -4px;
    background: #2563eb;
    color: white;
    border-radius: 10px;
    padding: 1px 5px;
    font-size: 11px;
    font-weight: bold;
    min-width: 17px;
    text-align: center;
    line-height: 1.4;
    pointer-events: none;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

/* Compact / expand toggle (SVG 4-arrow icon) */
.compact-toggle-btn-header {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.compact-toggle-btn-header .compact-icon {
    color: white;
}
.compact-toggle-btn-header.active {
    background: rgba(255, 255, 255, 0.5);
}

/* ====================================================================
   Inline fired-alert sub-rows (under each task row)

   Hidden by default; revealed only when alert mode is on (the bell
   filter in the app bar). The task's own alert icon still signals that
   the alert exists — what's hidden is the expanded text + 🔕 dismiss
   row that would otherwise push every alerted task taller.
   ==================================================================== */
.inline-alert-row {
    display: none;
    background: rgba(220, 53, 69, 0.04);
}
body.alert-mode .inline-alert-row {
    display: table-row;
}
.inline-alert-row > .inline-alert-cell {
    padding: 2px 4px 4px 48px !important; /* indent to align under task text */
    border: none;
}
.inline-alert-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}
.inline-alert-dismiss-btn {
    background: none;
    border: 1px solid rgba(220, 53, 69, 0.3);
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 14px;
    cursor: pointer;
    line-height: 1;
    flex-shrink: 0;
    transition: background 0.15s ease, transform 0.15s ease;
}
.inline-alert-dismiss-btn:hover {
    background: rgba(220, 53, 69, 0.12);
    transform: scale(1.05);
}
.inline-alert-text {
    font-size: 13px;
    color: #666;
    line-height: 1.3;
    cursor: pointer;
    flex: 1;
}
.inline-alert-text:hover {
    color: #333;
}

/* ====================================================================
   Compact view mode — hides per-row chrome, keeps sections
   Activated by toggling body.compact-mode class
   Note: checkbox is intentionally preserved so users can still mark
   tasks done without leaving compact view.
   ==================================================================== */
body.compact-mode .task-cell-star,
body.compact-mode .task-cell-edit,
body.compact-mode .task-calendar-icon-separate,
body.compact-mode .task-alert-icon-inline,
body.compact-mode .task-suggestion-bulb,
body.compact-mode .inline-alert-row {
    display: none !important;
}
body.compact-mode .task-row {
    min-height: 28px;
    padding: 1px 4px;
}
body.compact-mode .task-cell-text {
    padding: 4px 12px !important;
}
body.compact-mode .task-text {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ====================================================================
   Visual Polish: consistent radii, softer colors, typography bump
   ==================================================================== */

/* Task row — more breathing room + larger text (16pt → 17pt equivalent) */
.task-row {
    min-height: 44px;
    border-radius: 10px;
}
.task-text {
    font-size: 15px;
    line-height: 1.45;
}

/* Cards (modals, panels) — 16px corner radius */
.modal-content,
.calendar-day-section {
    border-radius: 16px;
}

/* Inputs — 12px radius */
.modal-input,
.new-task-input {
    border-radius: 12px;
}

/* Pills / chips — fully rounded */
.plan-day-btn,
.tab-alert-badge {
    border-radius: 9999px;
}

/* Softer overdue red */
.task-row.overdue .task-text,
.section-overdue .section-label,
.section-overdue .task-text {
    color: #E53935 !important;
}

/* Section labels scroll with their tasks — no pinning.
   Keeping a stale backdrop-blur header over task text looks like a bug. */
.task-section {
    position: relative;
}
.section-label {
    position: static;
    background: inherit;
}

/* Date subtitle — slightly larger, warmer grey */
.task-due-subtitle,
.task-recurrence-pattern {
    font-size: 13px !important;
    color: #64748b !important;
}

/* Dark mode color audit — ensure inline alert text is visible */
@media (prefers-color-scheme: dark) {
    .inline-alert-text {
        color: #cbd5e1;
    }
    .inline-alert-text:hover {
        color: #f1f5f9;
    }
    .inline-alert-row {
        background: rgba(239, 83, 80, 0.08);
    }

    /* Quick-add task input (Tasks tab + Calendar tab): flip to a dark fill
       with white text so it matches the dark surface, the way the home-tab
       chat input already adapts. Without this override the baked-in pale
       green background + black text ignore the system dark mode. */
    .new-task-input {
        background: #1e293b;
        border-color: #334155;
        color: #f1f5f9;
        caret-color: #f1f5f9;
    }
    .new-task-input::placeholder {
        color: rgba(241, 245, 249, 0.5);
    }
    .new-task-input:focus {
        background: #0f172a;
        border-color: #60a5fa;
    }
}

/* Dark mode: section glow overrides */
@media (prefers-color-scheme: dark) {
    .section-today.section-today-glow {
        box-shadow: 0 0 12px 2px rgba(212, 175, 55, 0.2), inset 0 0 8px 1px rgba(212, 175, 55, 0.05);
        border-color: rgba(212, 175, 55, 0.3);
    }
    .section-today.section-today-complete {
        box-shadow: 0 0 14px 3px rgba(212, 175, 55, 0.25), inset 0 0 10px 2px rgba(212, 175, 55, 0.06);
        border-color: rgba(212, 175, 55, 0.35);
    }
    .today-all-done-message {
        color: #d4af37;
    }
    .section-overdue.section-overdue-glow {
        box-shadow: 0 0 12px 2px rgba(220, 53, 69, 0.2), inset 0 0 8px 1px rgba(220, 53, 69, 0.06);
        border-color: rgba(220, 53, 69, 0.3);
    }
}


/* ====================================================================
   Weather popup (7-day daily forecast)
   Anchored below the weather icon in the header. Triggered by clicking
   the weather emoji in the header. See Application.toggleWeatherPopup.
   ==================================================================== */
.weather-popup {
    position: fixed;
    top: 56px;
    left: 8px;
    right: 8px;
    max-width: 560px;
    margin: 0 auto;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    padding: 12px 16px;
    z-index: 200;
}
.weather-popup-header {
    display: flex;
    align-items: center;
    gap: 12px;
}
.weather-popup-emoji {
    font-size: 36px;
    line-height: 1;
}
.weather-popup-current {
    flex: 1;
    min-width: 0;
}
.weather-popup-temp {
    font-size: 20px;
    font-weight: 700;
}
.weather-popup-desc {
    font-size: 14px;
    color: #444;
}
.weather-popup-loc {
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}
.weather-popup-close {
    background: none;
    border: none;
    font-size: 16px;
    color: #888;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}
.weather-popup-close:hover {
    color: #333;
}

/* Unified forecast strip: [Now] → next ~12 hours → upcoming days, in one
   continuous horizontal scroller. Today's daily periods ("This Afternoon"
   / "Tonight") are filtered out by the JS — the hourly cells cover the
   rest of today. */
.weather-popup-strip {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #eee;
    overflow-x: auto;
}
.weather-popup-strip-cell {
    flex: 0 0 auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.weather-popup-strip-cell-hour {
    min-width: 60px;
    max-width: 60px;
}
.weather-popup-strip-cell-day,
.weather-popup-strip-cell-now {
    min-width: 72px;
    max-width: 72px;
}
.weather-popup-strip-label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
}
.weather-popup-strip-cell-now .weather-popup-strip-label {
    font-weight: 800;
    color: #222;
}
.weather-popup-strip-emoji {
    font-size: 20px;
    line-height: 1;
}
.weather-popup-strip-cell-now .weather-popup-strip-emoji {
    font-size: 24px;
}
.weather-popup-strip-primary {
    font-size: 14px;
    font-weight: 700;
    color: #222;
}
.weather-popup-strip-secondary {
    font-size: 12px;
    color: #888;
    min-height: 14px;
}
/* Short forecast text (e.g. "Partly Cloudy", "Rain Likely") under each
   cell's temperature. Two-line clamp so verbose NWS descriptions don't
   make the strip grow taller unexpectedly. */
.weather-popup-strip-desc {
    font-size: 10px;
    line-height: 1.2;
    color: #666;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
    min-height: 24px;
}
.weather-popup-daily {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #eee;
    overflow-x: auto;
}
.weather-popup-daily-cell {
    flex: 0 0 auto;
    min-width: 54px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.weather-popup-daily-label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
}
.weather-popup-daily-emoji {
    font-size: 22px;
    line-height: 1;
}
.weather-popup-daily-hi {
    font-size: 14px;
    font-weight: 700;
    color: #222;
}
.weather-popup-daily-lo {
    font-size: 12px;
    color: #888;
    min-height: 14px;
}

/* Placeholder (no-data) forecast cell — greyed out with a "?" glued to the
   emoji so the strip always shows 7 days even when the backend hasn't
   delivered a daily forecast yet. */
.weather-popup-daily-cell-empty {
    opacity: 0.45;
}
.weather-popup-daily-cell-empty .weather-popup-daily-emoji {
    position: relative;
    display: inline-block;
}
.weather-popup-daily-q {
    position: absolute;
    right: -10px;
    bottom: -2px;
    font-size: 12px;
    font-weight: 700;
    color: #222;
}

/* Hourly strip — rendered below the 7-day daily strip so users see both
   the weekly trend and short-term hour-by-hour plans. */
.weather-popup-hourly {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
    overflow-x: auto;
}
.weather-popup-hourly-cell {
    flex: 0 0 auto;
    min-width: 44px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.weather-popup-hourly-label {
    font-size: 11px;
    color: #666;
}
.weather-popup-hourly-emoji {
    font-size: 18px;
    line-height: 1;
}
.weather-popup-hourly-temp {
    font-size: 13px;
    font-weight: 600;
    color: #222;
}


/* ====================================================================
   Letter toggle buttons — used for day-of-week and month-of-year
   multi-select pickers in the recurrence editor.
   Row of circular 36px buttons with a single letter each.
   ==================================================================== */
.letter-toggle-row {
    display: flex;
    justify-content: space-between;
    gap: 4px;
    flex-wrap: nowrap;
    margin-top: 4px;
}
.letter-toggle-btn {
    flex: 0 1 auto;
    min-width: 32px;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid #d0d0d0;
    background: #f5f5f5;
    color: #333;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.letter-toggle-btn:hover {
    background: #e8e8e8;
}
.letter-toggle-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}
/* Keep the legacy dow-toggle-btn class functional when it does NOT also have
   the new letter-toggle-btn class (e.g. anywhere that still renders a
   longer-text pill). The new single-letter style overrides via .letter-toggle-btn. */


/* Today button next to the due-date input in the task editor modal */
.modal-btn-today {
    flex: 0 0 auto;
    padding: 8px 14px;
    border: 1px solid #667eea;
    background: white;
    color: #667eea;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}
.modal-btn-today:hover {
    background: #f0f2ff;
}


/* Chat: inline placeholder for tasks that were just deleted */
.chat-task-deleted {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #888;
    font-style: italic;
    font-size: 13px;
}
.chat-task-deleted em {
    color: #a00;
    font-style: italic;
}


/* ── Alert section in task editor ────────────────────────────────────── */
.modal-alert-conditions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 14px;
    color: #334155;
    padding: 0 4px 4px 4px;
}

.modal-alert-add-btn {
    background: #eef2ff;
    color: #4338ca;
    border: 1px solid #c7d2fe;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.modal-alert-add-btn:hover {
    background: #e0e7ff;
}

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

.modal-alert-delete-btn {
    background: transparent;
    border: none;
    color: #b91c1c;
    font-size: 14px;
    font-weight: 600;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 4px;
}

.modal-alert-delete-btn:hover {
    background: #fee2e2;
}

.modal-alert-empty {
    font-size: 13px;
    color: #6b7280;
    font-style: italic;
    padding: 8px 4px;
}

/* Preset picker overlay (shared inline picker UI) */
.modal-picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-picker-menu {
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 8px;
    max-width: 92vw;
    width: 360px;
    display: flex;
    flex-direction: column;
}

.modal-picker-title {
    font-weight: 600;
    font-size: 14px;
    color: #334155;
    padding: 8px 12px;
}

.modal-picker-option {
    background: transparent;
    border: none;
    text-align: left;
    padding: 12px;
    font-size: 14px;
    color: #1f2937;
    cursor: pointer;
    border-radius: 8px;
}

.modal-picker-option:hover {
    background: #f1f5f9;
}

.modal-picker-cancel {
    color: #b91c1c;
    margin-top: 4px;
    border-top: 1px solid #e5e7eb;
    border-radius: 0 0 8px 8px;
}

/* ── Task Completion Animation ──────────────────────────────────── */

/* Phase 1: Strikethrough draws across (0-400ms) */
/* Phase 2: Soft halo glow radiates (300-1000ms) */
/* Phase 3: Lift, scale, rotate, fade out (1000-1700ms) */

.task-completing {
    position: relative;
    animation: task-complete-sequence 1700ms ease-out forwards;
    pointer-events: none;
}

.task-completing::after {
    content: '';
    position: absolute;
    left: 56px;
    right: 48px;
    top: 50%;
    height: 1.5px;
    background: currentColor;
    opacity: 0.4;
    transform-origin: left;
    animation: task-strikethrough 400ms ease-in-out forwards;
}

@keyframes task-strikethrough {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

@keyframes task-complete-sequence {
    /* 0-24%: strikethrough phase — row stays put */
    0% {
        transform: translateY(0) scale(1) rotate(0deg);
        opacity: 1;
        box-shadow: none;
    }
    /* 18-59%: glow phase */
    18% {
        box-shadow: 0 0 0 0 rgba(232, 197, 71, 0);
    }
    35% {
        box-shadow: 0 0 16px 4px rgba(232, 197, 71, 0.35);
    }
    59% {
        box-shadow: 0 0 24px 8px rgba(232, 197, 71, 0);
        transform: translateY(0) scale(1) rotate(0deg);
        opacity: 1;
    }
    /* 59-100%: fly away — lift, scale up slightly, rotate, fade */
    100% {
        transform: translateY(-30px) scale(1.06) rotate(-1.2deg);
        opacity: 0;
        box-shadow: none;
    }
}

/* Dark mode: mint glow instead of gold */
@media (prefers-color-scheme: dark) {
    @keyframes task-complete-sequence {
        0% {
            transform: translateY(0) scale(1) rotate(0deg);
            opacity: 1;
            box-shadow: none;
        }
        18% {
            box-shadow: 0 0 0 0 rgba(136, 212, 171, 0);
        }
        35% {
            box-shadow: 0 0 16px 4px rgba(136, 212, 171, 0.35);
        }
        59% {
            box-shadow: 0 0 24px 8px rgba(136, 212, 171, 0);
            transform: translateY(0) scale(1) rotate(0deg);
            opacity: 1;
        }
        100% {
            transform: translateY(-30px) scale(1.06) rotate(-1.2deg);
            opacity: 0;
            box-shadow: none;
        }
    }
}

/* Celebration toast styling */
.celebration-toast {
    font-style: italic;
    letter-spacing: 0.02em;
}

/* ── Completion Overlay (floating, non-blocking) ────────────────── */
.task-completion-overlay {
    opacity: 0;
    transition: none;
}
.task-completion-overlay.animating {
    animation: completion-overlay-anim 900ms ease-out forwards;
}
@keyframes completion-overlay-anim {
    0% {
        opacity: 0;
        transform: translateY(0) scale(1) rotate(0deg);
        box-shadow: 0 0 0 0 rgba(232, 197, 71, 0);
    }
    25% {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(0deg);
        box-shadow: 0 0 18px 5px rgba(232, 197, 71, 0.4);
    }
    50% {
        opacity: 0.8;
        transform: translateY(-5px) scale(1.03) rotate(-0.3deg);
        box-shadow: 0 0 24px 8px rgba(232, 197, 71, 0.2);
    }
    100% {
        opacity: 0;
        transform: translateY(-30px) scale(1.06) rotate(-1.2deg);
        box-shadow: 0 0 0 0 rgba(232, 197, 71, 0);
    }
}
@media (prefers-color-scheme: dark) {
    @keyframes completion-overlay-anim {
        0% {
            opacity: 0;
            transform: translateY(0) scale(1) rotate(0deg);
            box-shadow: 0 0 0 0 rgba(136, 212, 171, 0);
        }
        25% {
            opacity: 1;
            transform: translateY(0) scale(1) rotate(0deg);
            box-shadow: 0 0 18px 5px rgba(136, 212, 171, 0.4);
        }
        50% {
            opacity: 0.8;
            transform: translateY(-5px) scale(1.03) rotate(-0.3deg);
            box-shadow: 0 0 24px 8px rgba(136, 212, 171, 0.2);
        }
        100% {
            opacity: 0;
            transform: translateY(-30px) scale(1.06) rotate(-1.2deg);
            box-shadow: 0 0 0 0 rgba(136, 212, 171, 0);
        }
    }
}
