/* ================================================================
   AgenticTodoApp — Shared Theme & Component Styles
   This file is the single source of truth for the app's look-and-feel.
   Loaded by both the web app (App.razor) and MAUI app (index.html).
   ================================================================ */

/* ── Theme Variables (Light) ── */
:root {
    --app-bg: linear-gradient(135deg, #f0ecf5 0%, #ebe7f2 50%, #e5e0ef 100%);
    --app-text: #1a1a1a;
    --card-bg: rgba(255, 255, 255, 0.95);
    --card-border: #eee;
    --accent: #667eea;
    --accent-hover: #764ba2;
    --accent-gradient: linear-gradient(135deg, #667eea, #764ba2);
    --muted-text: #888;
    --panel-radius: 1.25rem;
    --card-radius: 0.875rem;
    --panel-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    --input-bg: #f5f5f7;
    --input-border: #e0e0e0;

    /* AI.Components CSS variable overrides */
    --chat-user-bg: linear-gradient(135deg, #667eea, #764ba2);
    --chat-user-color: #fff;
    --chat-assistant-bg: #f1f3f5;
    --chat-assistant-color: #333;
    --chat-accent: #667eea;
    --chat-border: #eee;
    --chat-input-bg: transparent;
    --chat-tool-bg: rgba(102, 126, 234, 0.08);
    --chat-loading-color: #888;

    /* Todo component variables */
    --todo-card-bg: #fff;
    --todo-card-border: #eee;
    --todo-card-hover-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    --todo-card-completed-bg: #f9f9f9;
    --todo-title-color: #2d3436;
    --todo-completed-text: #aaa;
    --todo-description-color: #666;
    --todo-id-color: #999;
    --todo-input-bg: #f5f5f7;
    --todo-input-border: #e0e0e0;
    --todo-input-color: #1a1a1a;
    --todo-input-focus-bg: #fff;
    --todo-select-bg: #f5f5f7;
    --todo-select-color: #555;
    --todo-cancel-bg: #f0f0f0;
    --todo-cancel-color: #666;
    --todo-cancel-hover-bg: #e0e0e0;
    --todo-action-hover-bg: rgba(0, 0, 0, 0.05);
    --todo-delete-hover-bg: rgba(231, 76, 60, 0.1);
    --todo-drag-handle-color: #ccc;
    --todo-drag-handle-active: #667eea;
    --todo-drag-over-border: #667eea;
    --todo-drag-over-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
    --todo-checkmark-border: #ccc;
    --todo-checkmark-hover: #667eea;
    --todo-category-manager-bg: #f9f9fc;
    --todo-category-title-color: #555;
    --todo-category-input-bg: #fff;
    --todo-manage-btn-color: #888;
    --todo-manage-btn-hover-bg: #f0f0f5;
    --todo-empty-color: #888;

    /* Priority/category pill variables */
    --pill-critical-bg: #fff0f0;
    --pill-critical-color: #e74c3c;
    --pill-high-bg: #fff8f0;
    --pill-high-color: #e67e22;
    --pill-medium-bg: #f0f0ff;
    --pill-medium-color: #667eea;
    --pill-low-bg: #f0f0f0;
    --pill-low-color: #888;
    --pill-category-bg: #e0f7fa;
    --pill-category-color: #00796b;
    --pill-due-bg: #f3e5f5;
    --pill-due-color: #7b1fa2;
    --pill-overdue-bg: #fff0f0;
    --pill-overdue-color: #e74c3c;
}

/* ── Theme Variables (Dark — system preference) ── */
@media (prefers-color-scheme: dark) {
    :root {
        --app-bg: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
        --app-text: #e0e0e0;
        --card-bg: rgba(30, 30, 50, 0.92);
        --card-border: #333;
        --muted-text: #999;
        --panel-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
        --input-bg: #1e1e30;
        --input-border: #444;

        --chat-assistant-bg: #2a2a3e;
        --chat-assistant-color: #ddd;
        --chat-border: #333;
        --chat-tool-bg: rgba(102, 126, 234, 0.12);
        --chat-loading-color: #999;

        --todo-card-bg: #22223a;
        --todo-card-border: #333;
        --todo-card-hover-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
        --todo-card-completed-bg: #1a1a2e;
        --todo-title-color: #e0e0e0;
        --todo-completed-text: #666;
        --todo-description-color: #999;
        --todo-id-color: #555;
        --todo-input-bg: #1e1e30;
        --todo-input-border: #444;
        --todo-input-color: #e0e0e0;
        --todo-input-focus-bg: #22223a;
        --todo-select-bg: #1e1e30;
        --todo-select-color: #ccc;
        --todo-cancel-bg: #2a2a3e;
        --todo-cancel-color: #aaa;
        --todo-cancel-hover-bg: #333350;
        --todo-action-hover-bg: rgba(255, 255, 255, 0.08);
        --todo-delete-hover-bg: rgba(231, 76, 60, 0.15);
        --todo-drag-handle-color: #555;
        --todo-drag-handle-active: #8888ee;
        --todo-drag-over-border: #667eea;
        --todo-drag-over-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
        --todo-checkmark-border: #555;
        --todo-checkmark-hover: #8888ee;
        --todo-category-manager-bg: #1e1e30;
        --todo-category-title-color: #ccc;
        --todo-category-input-bg: #22223a;
        --todo-manage-btn-color: #ccc;
        --todo-manage-btn-hover-bg: #2a2a3e;
        --todo-empty-color: #888;

        --pill-critical-bg: #3d1515;
        --pill-critical-color: #ff8a8a;
        --pill-high-bg: #3d2a10;
        --pill-high-color: #ffbe76;
        --pill-medium-bg: #1a1a3d;
        --pill-medium-color: #8c9eff;
        --pill-low-bg: #2a2a2a;
        --pill-low-color: #999;
        --pill-category-bg: #0a2a2e;
        --pill-category-color: #4dd0e1;
        --pill-due-bg: #1e1a30;
        --pill-due-color: #b39ddb;
        --pill-overdue-bg: #3d1515;
        --pill-overdue-color: #ff8a8a;
    }
}

/* ── Theme Variables (Dark — manual toggle via html.dark) ── */
html.dark {
    --app-bg: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --app-text: #e0e0e0;
    --card-bg: rgba(30, 30, 50, 0.92);
    --card-border: #333;
    --muted-text: #999;
    --panel-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    --input-bg: #1e1e30;
    --input-border: #444;

    --chat-assistant-bg: #2a2a3e;
    --chat-assistant-color: #ddd;
    --chat-border: #333;
    --chat-tool-bg: rgba(102, 126, 234, 0.12);
    --chat-loading-color: #999;

    --todo-card-bg: #22223a;
    --todo-card-border: #333;
    --todo-card-hover-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    --todo-card-completed-bg: #1a1a2e;
    --todo-title-color: #e0e0e0;
    --todo-completed-text: #666;
    --todo-description-color: #999;
    --todo-id-color: #555;
    --todo-input-bg: #1e1e30;
    --todo-input-border: #444;
    --todo-input-color: #e0e0e0;
    --todo-input-focus-bg: #22223a;
    --todo-select-bg: #1e1e30;
    --todo-select-color: #ccc;
    --todo-cancel-bg: #2a2a3e;
    --todo-cancel-color: #aaa;
    --todo-cancel-hover-bg: #333350;
    --todo-action-hover-bg: rgba(255, 255, 255, 0.08);
    --todo-delete-hover-bg: rgba(231, 76, 60, 0.15);
    --todo-drag-handle-color: #555;
    --todo-drag-handle-active: #8888ee;
    --todo-drag-over-border: #667eea;
    --todo-drag-over-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
    --todo-checkmark-border: #555;
    --todo-checkmark-hover: #8888ee;
    --todo-category-manager-bg: #1e1e30;
    --todo-category-title-color: #ccc;
    --todo-category-input-bg: #22223a;
    --todo-manage-btn-color: #ccc;
    --todo-manage-btn-hover-bg: #2a2a3e;
    --todo-empty-color: #888;

    --pill-critical-bg: #3d1515;
    --pill-critical-color: #ff8a8a;
    --pill-high-bg: #3d2a10;
    --pill-high-color: #ffbe76;
    --pill-medium-bg: #1a1a3d;
    --pill-medium-color: #8c9eff;
    --pill-low-bg: #2a2a2a;
    --pill-low-color: #999;
    --pill-category-bg: #0a2a2e;
    --pill-category-color: #4dd0e1;
    --pill-due-bg: #1e1a30;
    --pill-due-color: #b39ddb;
    --pill-overdue-bg: #3d1515;
    --pill-overdue-color: #ff8a8a;
}

/* ── Theme Variables (Light — manual toggle via html.light) ── */
/* Needed when system prefers dark but user toggles to light */
html.light {
    --app-bg: linear-gradient(135deg, #f0ecf5 0%, #ebe7f2 50%, #e5e0ef 100%);
    --app-text: #1a1a1a;
    --card-bg: rgba(255, 255, 255, 0.95);
    --card-border: #eee;
    --muted-text: #888;
    --panel-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    --input-bg: #f5f5f7;
    --input-border: #e0e0e0;

    --chat-assistant-bg: #f1f3f5;
    --chat-assistant-color: #333;
    --chat-border: #eee;
    --chat-tool-bg: rgba(102, 126, 234, 0.08);
    --chat-loading-color: #888;

    --todo-card-bg: #fff;
    --todo-card-border: #eee;
    --todo-card-hover-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    --todo-card-completed-bg: #f9f9f9;
    --todo-title-color: #2d3436;
    --todo-completed-text: #aaa;
    --todo-description-color: #666;
    --todo-id-color: #999;
    --todo-input-bg: #f5f5f7;
    --todo-input-border: #e0e0e0;
    --todo-input-color: #1a1a1a;
    --todo-input-focus-bg: #fff;
    --todo-select-bg: #f5f5f7;
    --todo-select-color: #555;
    --todo-cancel-bg: #f0f0f0;
    --todo-cancel-color: #666;
    --todo-cancel-hover-bg: #e0e0e0;
    --todo-action-hover-bg: rgba(0, 0, 0, 0.05);
    --todo-delete-hover-bg: rgba(231, 76, 60, 0.1);
    --todo-drag-handle-color: #ccc;
    --todo-drag-handle-active: #667eea;
    --todo-drag-over-border: #667eea;
    --todo-drag-over-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
    --todo-checkmark-border: #ccc;
    --todo-checkmark-hover: #667eea;
    --todo-category-manager-bg: #f9f9fc;
    --todo-category-title-color: #555;
    --todo-category-input-bg: #fff;
    --todo-manage-btn-color: #888;
    --todo-manage-btn-hover-bg: #f0f0f5;
    --todo-empty-color: #888;

    --pill-critical-bg: #fff0f0;
    --pill-critical-color: #e74c3c;
    --pill-high-bg: #fff8f0;
    --pill-high-color: #e67e22;
    --pill-medium-bg: #f0f0ff;
    --pill-medium-color: #667eea;
    --pill-low-bg: #f0f0f0;
    --pill-low-color: #888;
    --pill-category-bg: #e0f7fa;
    --pill-category-color: #00796b;
    --pill-due-bg: #f3e5f5;
    --pill-due-color: #7b1fa2;
    --pill-overdue-bg: #fff0f0;
    --pill-overdue-color: #e74c3c;
}

/* ── Shared Layout ── */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--app-bg);
    color: var(--app-text);
}

.app-main {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── Navbar (web) / Header (MAUI) ── */
.app-navbar {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.app-header h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: #2d3436;
    font-size: 1.25rem;
    font-weight: 600;
}

.app-brand:hover {
    color: #2d3436;
    opacity: 0.9;
}

.brand-icon {
    font-size: 1.4rem;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-greeting {
    color: #555;
    font-size: 0.875rem;
}

.auth-link {
    color: #2d3436;
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.35rem 0.75rem;
    border-radius: 0.375rem;
    background: rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.1);
    transition: background 0.2s ease;
}

.auth-link:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #2d3436;
}

.theme-toggle {
    background: rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #555;
}

.theme-toggle:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: scale(1.05);
}

@media (max-width: 575.98px) {
    .app-main {
        padding: 0.75rem;
    }

    .app-navbar {
        padding: 0.5rem 0.75rem;
    }

    .brand-text {
        font-size: 1rem;
    }

    .user-greeting {
        display: none;
    }
}

/* ── Light Mode Navbar ── */
html.light .app-navbar {
    background: rgba(255, 255, 255, 0.6);
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

html.light .app-brand {
    color: #2d3436;
}

html.light .app-brand:hover {
    color: #2d3436;
}

html.light .user-greeting {
    color: #555;
}

html.light .auth-link {
    color: #2d3436;
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.1);
}

html.light .auth-link:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #2d3436;
}

html.light .theme-toggle {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.1);
    color: #555;
}

html.light .theme-toggle:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* ── TodoPage Light Mode (manual toggle) ── */
html.light .chat-column { background: transparent; }
html.light .mobile-chat-backdrop { background: rgba(0, 0, 0, 0.3); }

/* ── Account Page Dark Mode (manual toggle) ── */
html.dark .account-page { color: white; }
html.dark .account-info { background: rgba(255, 255, 255, 0.1); }
html.dark .danger-zone { background: rgba(0, 0, 0, 0.25); border-color: rgba(255, 255, 255, 0.15); }
html.dark .danger-zone h2 { color: white; }
html.dark .btn-cancel { color: rgba(255, 255, 255, 0.9); background: rgba(255, 255, 255, 0.15); border-color: rgba(255, 255, 255, 0.3); }
html.dark .btn-cancel:hover:not(:disabled) { background: rgba(255, 255, 255, 0.25); }
html.dark .confirmation-dialog { background: rgba(0, 0, 0, 0.15); border-color: rgba(255, 255, 255, 0.1); }
html.dark .error-message { color: #fecaca; }

/* ── Account Page Light Mode (manual toggle — overrides @media dark) ── */
html.light .account-page { color: #1a1a1a; }
html.light .account-info { background: rgba(0, 0, 0, 0.05); }
html.light .danger-zone { background: rgba(255, 255, 255, 0.9); border-color: rgba(0, 0, 0, 0.1); }
html.light .danger-zone h2 { color: #b91c1c; }
html.light .btn-cancel { color: #1a1a1a; background: rgba(0, 0, 0, 0.05); border-color: rgba(0, 0, 0, 0.2); }
html.light .btn-cancel:hover:not(:disabled) { background: rgba(0, 0, 0, 0.1); }
html.light .confirmation-dialog { background: rgba(239, 68, 68, 0.08); border-color: rgba(0, 0, 0, 0.1); }
html.light .error-message { color: #dc2626; }

/* ── NotFound Page Dark Mode (manual toggle) ── */
html.dark .not-found-page { color: white; }
html.dark .not-found-message { color: rgba(255, 255, 255, 0.85); }
html.dark .not-found-link { background: rgba(255, 255, 255, 0.25); color: white; border-color: rgba(255, 255, 255, 0.4); }
html.dark .not-found-link:hover { background: rgba(255, 255, 255, 0.35); }

/* ── NotFound Page Light Mode (manual toggle — overrides @media dark) ── */
html.light .not-found-page { color: #1a1a1a; }
html.light .not-found-message { color: #555; }
html.light .not-found-link { background: rgba(102, 126, 234, 0.1); color: #667eea; border-color: rgba(102, 126, 234, 0.3); }
html.light .not-found-link:hover { background: rgba(102, 126, 234, 0.2); }

/* ── Privacy Page Dark Mode (manual toggle) ── */
html.dark .privacy-policy { color: rgba(255, 255, 255, 0.9); }
html.dark .privacy-policy h1 { color: white; }
html.dark .privacy-updated { color: rgba(255, 255, 255, 0.5); }
html.dark .privacy-policy h2 { color: white; border-bottom-color: rgba(255, 255, 255, 0.15); }
html.dark .privacy-policy a { color: #a8edea; }
html.dark .privacy-policy a:hover { color: white; }

/* ── Privacy Page Light Mode (manual toggle — overrides @media dark) ── */
html.light .privacy-policy { color: #333; }
html.light .privacy-policy h1 { color: #1a1a1a; }
html.light .privacy-updated { color: #888; }
html.light .privacy-policy h2 { color: #1a1a1a; border-bottom-color: rgba(0, 0, 0, 0.1); }
html.light .privacy-policy a { color: #667eea; }
html.light .privacy-policy a:hover { color: #764ba2; }

/* ── Dark Mode Navbar ── */
@media (prefers-color-scheme: dark) {
    .app-navbar {
        background: rgba(255, 255, 255, 0.1);
        border-bottom-color: rgba(255, 255, 255, 0.15);
    }
    .app-brand, .app-brand:hover { color: white; }
    .user-greeting { color: rgba(255, 255, 255, 0.9); }
    .auth-link {
        color: white;
        background: rgba(255, 255, 255, 0.15);
        border-color: rgba(255, 255, 255, 0.2);
    }
    .auth-link:hover { background: rgba(255, 255, 255, 0.25); color: white; }
    .theme-toggle {
        background: rgba(255, 255, 255, 0.15);
        border-color: rgba(255, 255, 255, 0.2);
        color: white;
    }
    .theme-toggle:hover { background: rgba(255, 255, 255, 0.25); }
}

html.dark .app-navbar {
    background: rgba(255, 255, 255, 0.1);
    border-bottom-color: rgba(255, 255, 255, 0.15);
}

html.dark .app-brand, html.dark .app-brand:hover { color: white; }
html.dark .user-greeting { color: rgba(255, 255, 255, 0.9); }

html.dark .auth-link {
    color: white;
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
}
html.dark .auth-link:hover { background: rgba(255, 255, 255, 0.25); color: white; }

html.dark .theme-toggle {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
    color: white;
}
html.dark .theme-toggle:hover { background: rgba(255, 255, 255, 0.25); }

/* ── Home Page Dark Mode (manual toggle) ── */
/* Scoped CSS :global() isn't stripped by Blazor, so html.dark overrides go here */
html.dark .hero-title { color: white; }
html.dark .hero-accent {
    background: linear-gradient(135deg, #a8edea, #fed6e3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
html.dark .hero-subtitle { color: rgba(255, 255, 255, 0.85); }
html.dark .btn-primary-hero { background: white; color: #667eea; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15); }
html.dark .btn-primary-hero:hover { color: #764ba2; box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2); }
html.dark .btn-secondary-hero { color: white; border-color: rgba(255, 255, 255, 0.4); }
html.dark .btn-secondary-hero:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.7); color: white; }
html.dark .features-heading { color: white; }
html.dark .feature-card { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.15); }
html.dark .feature-card:hover { background: rgba(255, 255, 255, 0.15); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15); }
html.dark .feature-card h3 { color: white; }
html.dark .feature-card p { color: rgba(255, 255, 255, 0.75); }
html.dark .cta h2 { color: white; }
html.dark .cta p { color: rgba(255, 255, 255, 0.75); }
html.dark .hero-card { background: rgba(30, 30, 50, 0.92); box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5); }
html.dark .assistant-demo { background: #2a2a3e; color: #ddd; }
html.dark .demo-todo-item { border-color: #333; background: #22223a; }
html.dark .demo-title { color: #e0e0e0; }
html.dark .demo-done { color: #666; }
html.dark .demo-pill-critical { background: #3d1515; color: #ff8a8a; }
html.dark .demo-pill-high { background: #3d2a10; color: #ffbe76; }
html.dark .demo-pill-medium { background: #1a1a3d; color: #8c9eff; }
html.dark .demo-pill-date { background: #1e1a30; color: #b39ddb; }
html.dark .site-footer a { color: rgba(255, 255, 255, 0.6); }
html.dark .site-footer a:hover { color: white; }

/* ── Chat Message Enhancements ── */
.chat-message-user {
    border-radius: 1.25rem;
    border-bottom-right-radius: 0.25rem;
    padding: 0.75rem 1rem;
}

.chat-message-assistant {
    border-radius: 1.25rem;
    border-bottom-left-radius: 0.25rem;
}

/* Markdown in assistant messages */
.chat-message-assistant code {
    background: rgba(0, 0, 0, 0.06);
    padding: 0.15rem 0.35rem;
    border-radius: 0.25rem;
    font-size: 0.82em;
    font-family: 'Consolas', 'Monaco', monospace;
}

.chat-message-assistant pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin: 0.4rem 0;
    overflow-x: auto;
    font-size: 0.82em;
}

.chat-message-assistant blockquote {
    border-left: 3px solid #667eea;
    margin: 0.4rem 0;
    padding: 0.2rem 0.75rem;
    color: var(--muted-text);
    font-style: italic;
}

/* Tool call styling */
.chat-tool-call,
.chat-tool-result {
    font-size: 0.8rem;
    padding: 0.35rem 0.65rem;
    border-radius: 0.5rem;
    background: var(--chat-tool-bg);
    margin: 0.25rem 0;
    border-left: 3px solid var(--accent);
}

/* ── Chat Input (pill-shaped) ── */
.chat-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--chat-border, #e0e0e0);
    background: var(--card-bg);
    box-sizing: border-box;
}

.chat-input textarea {
    flex: 1;
    box-sizing: border-box;
    border: 1px solid var(--input-border, #e0e0e0);
    border-radius: 1.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    line-height: 1.4;
    height: 2.5rem;
    min-height: 2.5rem;
    max-height: 6rem;
    overflow-y: hidden;
    resize: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--input-bg, #f5f5f7);
    color: var(--app-text, inherit);
}

.chat-input textarea::placeholder {
    color: var(--muted-text, #888);
}

.chat-input textarea:focus {
    outline: none;
    border-color: var(--accent, #667eea);
}

.chat-input textarea:disabled {
    opacity: 0.6;
}

.chat-send-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    box-sizing: border-box;
    border: none;
    border-radius: 50%;
    background: var(--accent-gradient, #667eea);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.chat-send-button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.chat-send-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Chat Messages Area ── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    -webkit-overflow-scrolling: touch;
}

/* ── Chat Loading / Typing Indicator ── */
.chat-loading {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    color: var(--chat-loading-color, #666);
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.typing-dots {
    display: inline-flex;
    gap: 0.2rem;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--muted-text);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ── Chat Empty State ── */
.chat-empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--muted-text);
}

.chat-empty-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    opacity: 0.6;
}

.chat-empty p {
    margin: 0.5rem 0;
    font-size: 0.9rem;
}

.chat-empty .chat-empty-hint {
    font-size: 0.82rem;
    opacity: 0.7;
}

/* ── AG-UI Dojo Component Overrides ──
   Map Dojo component classes to app styling within .chat-panel flex layout.
   Dojo renders: .messages-container > .chat-message.{role}-message > (content)
   Input: .agent-input > textarea + .send-button
   Loading: .agent-loading-indicator > .agent-loading-dots */

.chat-panel .messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    padding-left: calc(1.25rem + env(safe-area-inset-left, 0px));
    padding-right: calc(1.25rem + env(safe-area-inset-right, 0px));
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

.chat-panel .chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeInUp 0.3s ease-out;
}

.chat-panel .user-message {
    align-self: flex-end;
}

.chat-panel .user-message {
    background: var(--accent-gradient, linear-gradient(135deg, #667eea, #764ba2));
    color: #fff;
    padding: 0.65rem 1rem;
    border-radius: 1rem 1rem 0.25rem 1rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

.chat-panel .assistant-message {
    align-self: flex-start;
    background: var(--chat-assistant-bg, rgba(255, 255, 255, 0.08));
    color: var(--app-text, inherit);
    padding: 0.65rem 1rem;
    border-radius: 1rem 1rem 1rem 0.25rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

.chat-panel .agent-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    padding-left: calc(1rem + env(safe-area-inset-left, 0px));
    padding-right: calc(1rem + env(safe-area-inset-right, 0px));
    border-top: 1px solid var(--chat-border, #e0e0e0);
    background: var(--card-bg);
    box-sizing: border-box;
    flex-shrink: 0;
}

.chat-panel .agent-input textarea {
    flex: 1;
    box-sizing: border-box;
    border: 1px solid var(--input-border, #e0e0e0);
    border-radius: 1.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    line-height: 1.4;
    height: 2.5rem;
    min-height: 2.5rem;
    max-height: 6rem;
    overflow-y: hidden;
    resize: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--input-bg, #f5f5f7);
    color: var(--app-text, inherit);
}

.chat-panel .agent-input textarea::placeholder {
    color: var(--muted-text, #888);
}

.chat-panel .agent-input textarea:focus {
    outline: none;
    border-color: var(--accent, #667eea);
    box-shadow: none;
}

.chat-panel .agent-input textarea:disabled {
    opacity: 0.6;
}

.chat-panel .agent-input .send-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    box-sizing: border-box;
    border: none;
    border-radius: 50%;
    background: var(--accent-gradient, #667eea);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.chat-panel .agent-input .send-button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.chat-panel .agent-input .send-button:disabled {
    background: var(--accent-gradient, #667eea);
    opacity: 0.4;
    cursor: not-allowed;
}

.chat-panel .agent-loading-indicator {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    color: var(--chat-loading-color, #666);
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.chat-panel .agent-loading-dots span {
    background: var(--muted-text);
}

/* ── Suggestion Chips ── */
.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}

.suggestion-chip {
    background: linear-gradient(135deg, #f0f0ff, #e8e0ff);
    border: 1px solid #d4c8f0;
    border-radius: 2rem;
    padding: 0.5rem 1rem;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #5a4a8a;
}

.suggestion-chip:hover {
    background: linear-gradient(135deg, #e0e0ff, #d8d0f0);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

@media (prefers-color-scheme: dark) {
    .suggestion-chip {
        background: linear-gradient(135deg, #2a2a40, #302848);
        border-color: #444;
        color: #b8a8e0;
    }
    .suggestion-chip:hover {
        background: linear-gradient(135deg, #353550, #3a3058);
    }
}

html.dark .suggestion-chip {
    background: linear-gradient(135deg, #2a2a40, #302848);
    border-color: #444;
    color: #b8a8e0;
}

html.dark .suggestion-chip:hover {
    background: linear-gradient(135deg, #353550, #3a3058);
}

html.light .suggestion-chip {
    background: linear-gradient(135deg, #f0f0ff, #e8e0ff);
    border-color: #d4c8f0;
    color: #5a4a8a;
}

html.light .suggestion-chip:hover {
    background: linear-gradient(135deg, #e0e0ff, #d8d0f0);
}

/* ── Todo Header ── */
.todo-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--card-border, #eee);
}

.todo-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.35rem;
}

.todo-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sort-select {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    padding: 0.3rem 0.5rem;
    font-size: 0.78rem;
    color: var(--muted-text);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s ease;
}

.sort-select:focus {
    border-color: var(--accent);
}

.refresh-btn {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: transparent;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.refresh-btn:hover {
    background: var(--hover-bg);
    transform: rotate(90deg);
}

.add-todo-btn {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: none;
    background: var(--accent-gradient);
    color: white;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
    flex-shrink: 0;
}

.add-todo-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.add-todo-btn:active {
    transform: scale(0.95);
}

.todo-title {
    font-weight: 700;
    margin: 0;
    color: var(--todo-title-color, #2d3436);
}

.todo-count {
    font-size: 0.82rem;
    color: var(--muted-text);
}

/* ── Chat Header ── */
.chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    background: var(--accent-gradient);
    color: white;
    flex-shrink: 0;
    border-radius: var(--panel-radius, 1.25rem) var(--panel-radius, 1.25rem) 0 0;
}

.chat-header-icon {
    font-size: 2rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 0.75rem;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-header-info {
    flex: 1;
    min-width: 0;
}

.chat-header-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.chat-header-subtitle {
    font-size: 0.8rem;
    opacity: 0.8;
}

.new-chat-btn {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.5rem;
    color: white;
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    line-height: 1;
    font-size: 0.95rem;
}

.new-chat-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.new-chat-btn:active {
    transform: scale(0.95);
}
