:root{
    --primary: #4D87E2;
    --accent: #FE8864;
    --bubble-bg: #D3C5ED;
    --input-bg: #E8EBFF;
    --white: #ffffff;
    --muted: #6b6b6b;
    --shadow: rgba(0,0,0,0.12);
}

* { box-sizing: border-box; }
body {
    margin:0;
    font-family: 'Cairo', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    background: linear-gradient(180deg,#f9fbff, #f2f6ff);
    color: #222;
    direction: rtl;
}

.app-shell{
    width:100%;
    max-width:420px;
    margin:24px auto;
    border-radius:12px;
    box-shadow: 0 8px 30px var(--shadow);
    height:90vh;
    display:flex;
    flex-direction:column;
    overflow:hidden;
}

.app-header{

    padding:12px 14px;
    display:flex;
    align-items:center;
    justify-content:center;
    position:relative;
    border-bottom: 1px solid #eee;
}

.title{
    margin:0;
    font-size:18px;
    color: var(--accent);
    font-weight:700;
    text-align:center;
}

.back-btn{
    position:absolute;
    left:14px;
    top:50%;
    transform:translateY(-50%);
    background:transparent;
    border:none;
    font-size:20px;
    color: var(--accent);
    cursor:pointer;
    padding:6px 8px;
    border-radius:6px;
}

.chat-window{
    flex:1;
    padding:12px;
    overflow-y:auto;
}

.message{
    display:flex;
    align-items:flex-end;
    gap:8px;
    margin-bottom:10px;
    max-width:90%;
}

.message.ai{
    justify-content:flex-start;
    margin-left:0;
    margin-right:auto;
    align-items:flex-start;
}

.message.ai .ai-logo{
    width:36px;
    height:36px;
    object-fit:cover;
    border-radius:8px;
    margin-top:2px;
    border:2px solid rgba(0,0,0,0.04);
}

.message .msg-text{
    padding:10px 12px;
    border-radius:12px;
    line-height:1.4;
    font-size:14px;
    word-break:break-word;
}

.message.ai .msg-text{
    color:var(--accent);
    border: 1px solid var(--bubble-bg);
    border-radius:10px;
    padding:10px 12px;
}

.message.user{
    justify-content:flex-end;
    margin-left:auto;
    margin-right:0;
}

.message.user .msg-text{
    background: var(--primary);
    color: var(--white);
    border-radius:12px;
}

.typing{
    display:block;
    padding:10px 12px;
    background: #fff7ed;
    color: #7a5c3b;
    border-radius:10px;
    margin-bottom:8px;
    font-size:13px;
    text-align:center;
}

.composer{
    display:flex;
    gap:8px;
    padding:12px;
    background: transparent;
    width: 100%;
}


.composer input{
    flex:1;
    padding:12px 14px;
    background: var(--input-bg);
    border:1px solid #dcdcdc;
    border-radius:18px;
    outline:none;
    font-size:15px;
    color:#111;
}


.send-btn{
    background: var(--primary);
    color:#fff;
    border:none;
    padding:10px 14px;
    border-radius:10px;
    font-weight:700;
    cursor:pointer;
}

.send-btn:disabled{
    opacity:0.6;
    cursor:not-allowed;
}

.back-btn:active{
    transform:translateY(-50%) scale(.98);
}

@media (max-width:420px){
    .app-shell{ margin:6px; width:calc(100% - 12px); height:100vh; border-radius:0; }
    .back-btn{ left:10px; }
    .title{ font-size:16px; }
}
