
    :root{
        --blue:#048bff;
        --blue-hover:#006bbf;
        --bg:#f3f5fa;
        --panel:#ffffff;
        --panel-2:#f7f9fc;
        --text:#0b1220;
        --sub:#667085;
        --border:#e5e7eb;
        --border-2:#eef2f7;
        --shadow:0 10px 30px rgba(16,24,40,.10);
        --shadow-2:0 6px 18px rgba(16,24,40,.08);
        --radius:18px;
        --radius-2:14px;
        --red:#ff4d4d;
        --red-hover:#cc0000;
        --disabled:#cbd5e1;
        --transition:all .2s cubic-bezier(.4,0,.2,1);
        --maxw: 880px;
        --sidebar-max: 340px;
    }

    @media (prefers-color-scheme: dark){
        :root:not(.theme-light){
            --bg:#0b0f19;
            --panel:#0f1524;
            --panel-2:#121b2f;
            --text:#e6eaf2;
            --sub:#a8b0c2;
            --border:#1f2a44;
            --border-2:#1a233a;
            --shadow:0 12px 34px rgba(0,0,0,.45);
            --shadow-2:0 10px 24px rgba(0,0,0,.35);
            --disabled:#334155;
        }
    }
    .theme-dark{
        --bg:#0b0f19;
        --panel:#0f1524;
        --panel-2:#121b2f;
        --text:#e6eaf2;
        --sub:#a8b0c2;
        --border:#1f2a44;
        --border-2:#1a233a;
        --shadow:0 12px 34px rgba(0,0,0,.45);
        --shadow-2:0 10px 24px rgba(0,0,0,.35);
        --disabled:#334155;
    }

    *{box-sizing:border-box;font-family:'Poppins',sans-serif}
    body{
        margin:0;height:100vh;display:flex;flex-direction:column;
        background:var(--bg);color:var(--text);
    }

    /* Layout wrapper like ChatGPT: centered thread, fixed composer */
    #app{
        flex:1;display:flex;min-height:0;
    }

    /* Sidebar (ChatGPT-ish) */
    #sidebar{
        position:fixed;left:0;top:0;bottom:0;
        width:min(90vw, var(--sidebar-max));
        background:var(--panel);
        border-right:1px solid var(--border);
        box-shadow:var(--shadow);
        transform:translateX(-102%);
        transition:transform .25s cubic-bezier(.4,0,.2,1);
        z-index:30;
        display:flex;flex-direction:column;
        overflow:hidden;
    }
    #sidebar.open{transform:translateX(0)}
    #sidebar-overlay{
        position:fixed;inset:0;background:rgba(0,0,0,.45);
        display:none;z-index:25;
    }

    .sb-top{
        padding:14px 14px 10px;border-bottom:1px solid var(--border);
        display:flex;gap:10px;align-items:center;justify-content:space-between;
        flex-shrink:0;
    }
    .sb-top h3{margin:0;font-size:14px;font-weight:600;color:var(--text)}
    .icon-btn{
        border:none;background:transparent;color:var(--text);
        padding:8px;border-radius:10px;cursor:pointer;transition:var(--transition);
        display:grid;place-items:center;
    }
    .icon-btn:hover{background:var(--panel-2)}
    .sb-search{
        padding:10px 14px;flex-shrink:0;
    }
    #sidebar-search{
        width:100%;padding:11px 12px;border-radius:12px;
        border:1px solid var(--border);background:var(--panel-2);color:var(--text);
        outline:none;transition:var(--transition);font-size:13px;
    }
    #sidebar-search:focus{border-color:rgba(4,139,255,.6);box-shadow:0 0 0 3px rgba(4,139,255,.12);background:var(--panel)}
    .sb-list{padding:0 10px 12px;overflow:auto;flex:1}
    #sidebar-list{list-style:none;margin:0;padding:0}
    .chat-history-item{
        padding:10px 10px;border-radius:12px;margin:6px 0;
        cursor:pointer;display:flex;align-items:center;gap:10px;
        transition:var(--transition);
        border:1px solid transparent;
        position:relative;
    }
    .chat-history-item:hover{background:var(--panel-2);border-color:var(--border-2)}
    .chat-history-item.active{
        background:rgba(4,139,255,.10);
        border-color:rgba(4,139,255,.25);
    }
    .chat-item-content{flex:1;min-width:0}
    .chat-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
    .chat-snippet{font-size:12px;color:var(--sub);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:2px}
    .delete-chat-btn{
        opacity:0;pointer-events:none;
        border:none;background:transparent;color:var(--sub);
        padding:6px;border-radius:10px;cursor:pointer;transition:var(--transition);
        display:grid;place-items:center;
    }
    .chat-history-item:hover .delete-chat-btn{opacity:1;pointer-events:auto}
    .delete-chat-btn:hover{background:rgba(255,77,77,.10);color:var(--red)}
    .sb-footer{
        padding:12px;border-top:1px solid var(--border);flex-shrink:0;
        display:flex;flex-direction:column;gap:10px;
    }
    .sb-primary{
        display:flex;gap:10px;align-items:center;justify-content:space-between;
    }
    .primary-btn{
        width:100%;
        border:1px solid var(--border);
        background:var(--panel-2);
        color:var(--text);
        border-radius:12px;
        padding:10px 12px;
        cursor:pointer;
        transition:var(--transition);
        display:flex;gap:10px;align-items:center;justify-content:center;
        font-weight:600;font-size:13px;
    }
    .primary-btn:hover{background:var(--panel);border-color:rgba(4,139,255,.25)}
    .settings-btn{
        width:100%;
        border:1px solid var(--border);
        background:var(--panel);
        color:var(--text);
        border-radius:12px;
        padding:10px 12px;
        cursor:pointer;
        transition:var(--transition);
        display:flex;gap:10px;align-items:center;justify-content:flex-start;
        font-weight:600;font-size:13px;
    }
    .settings-btn:hover{background:var(--panel-2)}

    /* Main chat area */
    #main{
        background:var(--panel);
        flex:1;min-width:0;display:flex;flex-direction:column;min-height:0;
        width:100%;
    }

    .topbar{
        position:sticky;top:0;z-index:10;
        background:var(--bg);
        border:none;
        border-bottom:1px solid var(--border);
        padding:12px 14px 10px;
    }
    .topbar-inner{
        max-width:var(--maxw);
        margin:0 auto;
        display:flex;align-items:center;justify-content:space-between;
        gap:12px;
    }
    .brand-pill{
        display:flex;align-items:center;gap:10px;
        background:var(--panel);
        border:1px solid var(--border);
        border-radius:999px;
        padding:6px 10px;
        box-shadow:var(--shadow-2);
    }
    .brand-pill img{width:30px;height:30px;border-radius:50%}
    .brand-pill .name{
        font-weight:700;font-size:14px;color:var(--blue);
        margin-right:6px;
    }
    .top-actions{
        display:flex;gap:8px;align-items:center;
        background:var(--panel);
        border:1px solid var(--border);
        border-radius:999px;
        padding:6px;
        box-shadow:var(--shadow-2);
    }
    .round-btn{
        width:40px;height:40px;border:none;border-radius:999px;
        background:transparent;color:var(--text);
        display:grid;place-items:center;cursor:pointer;transition:var(--transition);
    }
    .round-btn:hover{background:var(--panel-2)}

    #chat-box{
        flex:1;min-height:0;
        width:100%;
        max-width:var(--maxw);
        margin:0 auto;
        padding:14px 14px 120px;
        overflow:auto;
        scroll-behavior:smooth;
        background: var(--panel);
        display:flex;flex-direction:column;
        gap:6px;
    }

    .row{
        margin-left:4px;display:flex;gap:12px;align-items:flex-start;
    }
    .row.user{margin-left:0px;margin-right:4px;justify-content:flex-end}

    .bubble{
        width:auto;
        max-width:min(680px, 78%);
        padding:12px 14px;
        border-radius:16px;
        border:1px solid var(--border);
        background:var(--panel);
        box-shadow:0 1px 0 rgba(16,24,40,.05);
        font-size:14px;
        line-height:1.55;
        word-wrap:break-word;
    }
    .row.user .bubble{
        background:rgba(4,139,255,.10);
        border-color:rgba(4,139,255,.25);
    }
    .bubble a{color:var(--blue)}
    .bubble.no-bg{
        background:transparent;border:none;box-shadow:none;padding:0;
    }

    .bot-image,.user-image,.bot-file{
        max-height:300px;
        border-radius:8px;
        border:1px solid var(--border);
        background:var(--panel);
    }

    .message-button{
        width:100%;
        border:1px solid var(--border);
        color:var(--text);
        padding:10px 12px;
        border-radius:24px;
        background:var(--panel);
        cursor:pointer;
        transition:var(--transition);
        font-size:13px;
        text-align:left;
        margin-top:2px;
    }
    .message-button:hover{border-color:rgba(4,139,255,.35);color:var(--blue);background:var(--panel-2)}

    #initial{
        max-width:var(--maxw);
        margin:0 auto;
        margin-top:80px;
        width:100%;
        padding:40px 14px 0;
        background:var(--panel);
        display:none;
        flex-direction:column;
        align-items:center;
        text-align:center;
        gap:10px;
    }
    body.start #initial{display:flex}
    #initial h2{
        margin:0;
        font-size:26px;
        font-weight:800;
        color:var(--text);
    }
    #initial p{margin:0;color:var(--sub);font-size:14px}

    #composer{
        position:fixed;
        left:0;right:0;bottom:0;
        padding:12px 12px 16px;
        background:linear-gradient(to top, var(--bg) 65%, rgba(0,0,0,0));
        z-index:20;
    }
    .composer-inner{
        max-width:var(--maxw);
        margin:0 auto;
        display:flex;
        gap:10px;
        align-items:flex-end;
        background:var(--panel);
        border:1px solid var(--border);
        border-radius:18px;
        padding:10px;
        box-shadow:var(--shadow);
    }
    #plus-button{
        width:40px;height:40px;border-radius:12px;border:none;
        background:var(--panel-2);color:var(--text);
        display:grid;place-items:center;cursor:pointer;transition:var(--transition);
        flex:0 0 auto;
    }
    #plus-button:hover{background:rgba(4,139,255,.12);color:var(--blue)}
    #user-input{
        flex:1;
        border:none;
        outline:none;
        resize:none;
        background:transparent;
        color:var(--text);
        font-size:14px;
        line-height:1.5;
        max-height:160px;
        padding:8px 6px 8px 4px;
    }
    #send-button{
        width:44px;height:44px;border-radius:14px;border:none;
        background:var(--blue);color:#fff;
        display:grid;place-items:center;
        cursor:pointer;transition:var(--transition);
        flex:0 0 auto;
    }
    #send-button:hover{background:var(--blue-hover)}
    #send-button:disabled{background:var(--disabled);cursor:not-allowed}

    #bottom-sheet{
        position:fixed;left:0;right:0;bottom:0;
        background:var(--panel);
        border:1px solid var(--border);
        border-bottom:none;
        border-top-left-radius:18px;
        border-top-right-radius:18px;
        box-shadow:0 -8px 24px rgba(16,24,40,.12);
        display:none;
        z-index:40;
        padding:14px;
        transform:translateY(100%);
        transition:transform .22s cubic-bezier(.4,0,.2,1);
        max-width:520px;
        margin:0 auto;
    }
    #bottom-sheet.open{display:block;transform:translateY(0)}
    .sheet-row{display:flex;gap:10px}
    .option-btn{
        flex:1;
        border:1px solid var(--border);
        background:var(--panel-2);
        border-radius:14px;
        padding:12px 10px;
        display:flex;flex-direction:column;align-items:center;gap:6px;
        cursor:pointer;
        transition:var(--transition);
        font-size:12px;
        color:var(--text);
    }
    .option-btn:hover{background:var(--panel);border-color:rgba(4,139,255,.25);color:var(--blue)}
    .option-btn svg{width:22px;height:22px}

    /* Standard modal system (Settings + Confirm) */
    .modal{
        position:fixed;inset:0;
        display:none;
        z-index:60;
    }
    .modal.open{display:block}
    .modal .backdrop{
        position:absolute;inset:0;background:rgba(0,0,0,.45);
    }
    .modal .dialog{
        position:absolute;
        left:50%;top:50%;
        transform:translate(-50%,-50%);
        width:min(92vw, 640px);
        background:var(--panel);
        border:1px solid var(--border);
        border-radius:18px;
        box-shadow:var(--shadow);
        overflow:hidden;
    }
    .dialog-header{
        padding:14px 16px;
        border-bottom:1px solid var(--border);
        display:flex;align-items:center;justify-content:space-between;gap:10px;
    }
    .dialog-header h3{margin:0;font-size:15px;font-weight:800}
    .dialog-body{padding:16px}
    .dialog-footer{
        padding:12px 16px;
        border-top:1px solid var(--border);
        display:flex;gap:10px;justify-content:flex-end;
        background:linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,0));
    }
    .btn{
        border:1px solid var(--border);
        background:var(--panel-2);
        color:var(--text);
        border-radius:12px;
        padding:10px 12px;
        cursor:pointer;
        transition:var(--transition);
        font-weight:700;
        font-size:13px;
    }
    .btn:hover{background:var(--panel);border-color:rgba(4,139,255,.25)}
    .btn.primary{
        background:var(--blue);
        border-color:var(--blue);
        color:#fff;
    }
    .btn.primary:hover{background:var(--blue-hover);border-color:var(--blue-hover)}
    .btn.danger{
        background:rgba(255,77,77,.12);
        border-color:rgba(255,77,77,.3);
        color:var(--red);
    }
    .btn.danger:hover{background:rgba(255,77,77,.18);border-color:rgba(255,77,77,.45)}
    .muted{color:var(--sub);font-size:13px;line-height:1.5;margin:0}

    /* Settings content (ChatGPT-ish list) */
    .settings-card{
        border:1px solid var(--border);
        background:var(--panel);
        border-radius:16px;
        overflow:hidden;
    }
    .settings-row{
        display:flex;align-items:flex-start;justify-content:space-between;gap:12px;
        padding:14px 14px;
        border-top:1px solid var(--border);
        cursor:pointer;
        transition:var(--transition);
    }
    .settings-row:first-child{border-top:none}
    .settings-row:hover{background:var(--panel-2)}
    .settings-left{display:flex;gap:12px;align-items:flex-start}
    .settings-ico{
        width:36px;height:36px;border-radius:12px;
        display:grid;place-items:center;
        background:var(--panel-2);
        border:1px solid var(--border);
        flex:0 0 auto;
    }
    .settings-txt h4{margin:0;font-size:13px;font-weight:800}
    .settings-txt p{margin:3px 0 0;color:var(--sub);font-size:12px}
    .chev{opacity:.7}

    /* Confirm delete chat modal specifics */
    .danger-title{display:flex;gap:10px;align-items:center}
    .pill-red{
        width:34px;height:34px;border-radius:12px;
        display:grid;place-items:center;
        background:rgba(255,77,77,.12);
        border:1px solid rgba(255,77,77,.28);
        color:var(--red);
        flex:0 0 auto;
    }

    /* Loading dots */
    .thinking{
        display:inline-flex;gap:6px;align-items:center;
    }
    .dot{
        width:6px;height:6px;border-radius:50%;
        background:var(--blue);
        animation:bounce 1.2s infinite ease-in-out both;
    }
    .dot:nth-child(2){animation-delay:-.2s}
    .dot:nth-child(3){animation-delay:-.4s}
    @keyframes bounce{
        0%,80%,100%{transform:scale(0)}
        40%{transform:scale(1)}
    }

    @media (max-width: 640px){
        #chat-box{padding-bottom:140px}
        .bubble{max-width:85%}
    }