:root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --text: #17191d;
    --muted: #717782;
    --border: #e3e6eb;
    --accent: #6e54ff;
    --accent-2: #5a42dd;
    --assistant: #ffffff;
    --user: #ece8ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif; }
body { display: flex; justify-content: center; }
.app-shell { width: min(100%, 980px); min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto auto; background: var(--panel); }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
.brand { font-size: 1.2rem; font-weight: 800; }
.sub { color: var(--muted); font-size: .84rem; margin-top: 2px; }
.status-wrap { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .87rem; white-space: nowrap; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.status-dot.online { background: #20a464; }
.status-dot.offline { background: #b5bac4; }
.messages { padding: 24px 18px 30px; overflow-y: auto; background: linear-gradient(#fafbfc, #f6f7f9); }
.empty { max-width: 560px; margin: 12vh auto 0; text-align: center; color: var(--muted); line-height: 1.9; }
.message { display: flex; margin: 10px 0; }
.message.user { justify-content: flex-start; }
.message.assistant { justify-content: flex-end; }
.bubble { max-width: min(82%, 760px); padding: 11px 14px; border: 1px solid var(--border); border-radius: 16px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.user .bubble { background: var(--user); border-bottom-right-radius: 5px; }
.assistant .bubble { background: var(--assistant); border-bottom-left-radius: 5px; box-shadow: 0 2px 10px rgba(20,24,32,.04); }
.meta { color: var(--muted); font-size: .73rem; margin-top: 6px; }
.file-card { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 12px; padding: 9px 11px; margin-bottom: 8px; background: rgba(255,255,255,.72); }
.file-icon { font-size: 1.25rem; }
.file-name { font-weight: 700; font-size: .9rem; }
.preview-img { display: block; max-width: min(100%, 420px); max-height: 360px; object-fit: contain; border-radius: 12px; margin-bottom: 8px; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); background: #fff; }
.quick { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 7px 12px; font-size: .86rem; color: var(--text); }
.quick:hover { border-color: #c9c1ff; background: #faf9ff; }
.composer { padding: 10px 14px 14px; background: #fff; border-top: 1px solid var(--border); }
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
textarea { flex: 1; min-height: 46px; max-height: 160px; resize: none; border: 1px solid var(--border); border-radius: 14px; padding: 11px 13px; outline: none; font: inherit; font-size: 16px; background: #fbfbfc; }
textarea:focus { border-color: #b3a8ff; box-shadow: 0 0 0 3px rgba(110,84,255,.10); }
.attach-btn, .send-btn { min-width: 46px; min-height: 46px; border: 0; border-radius: 13px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.attach-btn { background: #f0f1f4; color: #333; font-size: 1.4rem; }
.send-btn { padding: 0 18px; background: var(--accent); color: #fff; font-weight: 700; }
.send-btn:hover { background: var(--accent-2); }
.send-btn:disabled { opacity: .55; cursor: wait; }
.attachment-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--border); background: #fafafa; padding: 8px 10px; border-radius: 10px; margin-bottom: 8px; font-size: .86rem; }
.attachment-bar button { border: 0; background: transparent; font-size: 1.25rem; line-height: 1; }
.hint { color: var(--muted); font-size: .72rem; margin-top: 7px; padding-inline: 3px; }
@media (max-width: 640px) {
    .topbar { padding: 13px 14px; }
    .messages { padding: 16px 10px 22px; }
    .bubble { max-width: 90%; }
    .quick-actions { padding-inline: 10px; overflow-x: auto; flex-wrap: nowrap; }
    .quick { flex: 0 0 auto; }
    .composer { padding: 9px 9px 12px; }
    .send-btn { padding: 0 13px; }
}
