       :root {
            --primary: #0094f7;
            --bg-light: #f0f2f5;
            --ai-bubble: #e5e5ea;
            --user-bubble: #0094f7;
        }

        html, body {
            height: 100%;
            margin: 0;
            padding: 0;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
            background: var(--bg-light);
        }

        #chat-wrapper {
            max-width: 100vw;
            margin: 0 auto;
            height: 100vh;
            display: flex;
            flex-direction: column;
            background: white;
            box-shadow: 0 0 20px rgba(0,0,0,0.1);
        }

        #title-bar {
            padding: 1rem;
            background: var(--primary);
            color: white;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        #chat-box {
            flex: 1;
            padding: 1.5rem;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 1rem;
        }

        .bubble {
            max-width: 85%;
            padding: 0.8rem 1.2rem;
            border-radius: 18px;
            font-size: 14px;
            line-height: 1.5;
            word-wrap: break-word;
        }

        /* Markdown Styling inside bubbles */
        .bubble p { margin: 0.5rem 0; }
        .bubble p:first-child { margin-top: 0; }
        .bubble p:last-child { margin-bottom: 0; }

        .bubble.you {
            align-self: flex-end;
            background: var(--user-bubble);
            color: white;
            border-bottom-right-radius: 4px;
        }

        .bubble.ai {
            align-self: flex-start;
            background: var(--ai-bubble);
            color: black;
            border-bottom-left-radius: 4px;
        }

        .subtitle {
            font-size: 0.7rem;
            color: #757575;
            margin-top: -0.7rem;
            margin-bottom: 0.5rem;
        }
        .you + .subtitle { align-self: flex-end; }
        .ai + .subtitle { align-self: flex-start; }

        #input-area {
            padding: 1rem;
            border-top: 1px solid #eee;
            background: #fff;
        }

        textarea {
            width: 100%;
            box-sizing: border-box;
            resize: none;
            padding: 0.8rem;
            font-size: 1rem;
            border: 2px solid #ddd;
            border-radius: 12px;
            outline: none;
            transition: border-color 0.2s;
        }

        textarea:focus { border-color: var(--primary); }
        textarea:disabled { background: #f9f9f9; cursor: not-allowed; }

        #clear-btn {
            background: rgba(255,255,255,0.2);
            border: none;
            color: white;
            padding: 5px 10px;
            border-radius: 4px;
            cursor: pointer;
        }

        /* Typing Dots Animation */
        .typing-dots { display: flex; gap: 4px; padding: 10px 0; }
        .typing-dots span {
            width: 8px; height: 8px;
            background: #999; border-radius: 50%;
            animation: dot-pulse 1.4s infinite ease-in-out both;
        }
        .typing-dots span:nth-child(1) { animation-delay: -0.32s; }
        .typing-dots span:nth-child(2) { animation-delay: -0.16s; }
        @keyframes dot-pulse {
            0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
            40% { transform: scale(1); opacity: 1; }
        }

        /* ──────────────────────────────────────────────────────────────── */
/*  Dark‑theme support (macOS “Auto” / dark mode)                   */
/* ──────────────────────────────────────────────────────────────── */

@media (prefers-color-scheme: dark) {
    :root {
        /* Core palette – keep the same primary accent */
        --primary: #005c99;

        /* Backgrounds */
        --bg-light:   #121212;          /* Page background (dark)      */
        --wrapper-bg: #1e1e1e;          /* Chat wrapper card background*/
        --input-bg:   #2b2b2b;          /* Input area background       */
        --input-border: #444;           /* Border of textarea          */

        /* Bubbles */
        --ai-bubble:  #2e2e2e;          /* AI chat bubble (dark grey) */
        --user-bubble: #005c99;         /* User chat bubble (darker)   */

        /* Text colours */
        --text-light:  #e0e0e0;         /* Light text for dark bg      */
        --text-dark:   #1e1e1e;         /* Dark text for light bg     */

        /* Subtitle colour */
        --subtitle: #a0a0a0;
    }

    /* Page background – override the light version */
    html, body {
        background: var(--bg-light);
        color: var(--text-light);      /* Global text colour */
    }

    /* Chat wrapper card – dark background & subtle shadow */
    #chat-wrapper {
        background: var(--wrapper-bg);
        box-shadow: 0 0 20px rgba(255,255,255,0.05);
    }

    /* Title bar – keep the accent but light text */
    #title-bar {
        background: var(--primary);
        color: white;
    }

    /* Input area – dark background, lighter border */
    #input-area {
        border-top: 1px solid #444;
        background: var(--input-bg);
    }

    textarea {
        background: var(--input-bg);
        border-color: #444;
        color: var(--text-light);
    }

    textarea:focus {
        border-color: var(--primary);
    }

    /* Clear button – semi‑transparent, light text */
    #clear-btn {
        background: rgba(255,255,255,0.15);
        color: white;
    }

    /* Bubbles – adapt colours for dark mode */
    .bubble.you {
        background: var(--user-bubble);
        color: white;
    }

    .bubble.ai {
        background: var(--ai-bubble);
        color: var(--text-light);
    }

    /* Subtitle – lighter grey */
    .subtitle {
        color: var(--subtitle);
    }

    /* Typing dots – light grey */
    .typing-dots span {
        background: #bbb;
    }
}
