:root { --brand: #1f3a5f; --bg: #f6f7f9; --panel: #fff; --text: #1b1f24; --muted: #6b7280; --line: #e5e7eb; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--text); background: var(--bg); }
.chat { display: flex; flex-direction: column; height: 100%; background: var(--panel); }
.chat.fullpage { max-width: 760px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }

/* header */
.head { display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 14px; background: var(--brand); color: #fff; }
.head .avatar { width: 42px; height: 42px; border-radius: 50%; background: #fff; overflow: hidden; flex: none; }
.head .avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.head .who { flex: 1; min-width: 0; }
.head .title { font-weight: 600; font-size: 17px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head .sub { font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head .newchat { border: 1px solid rgba(255,255,255,.55); background: transparent; color: #fff; border-radius: 999px; padding: 6px 11px; font: 600 12px/1 inherit; font-family: inherit; cursor: pointer; white-space: nowrap; }
.head .newchat:hover { background: rgba(255,255,255,.15); }
.head .close { width: 42px; height: 42px; border-radius: 50%; background: transparent; border: 0; color: #fff; font-size: 34px; line-height: 1; cursor: pointer; display: grid; place-items: center; padding: 0 0 3px; flex: none; }
.head .close:hover { background: rgba(255,255,255,.18); }

/* messages */
.log { flex: 1; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #d7d9de transparent; scrollbar-gutter: stable; padding: 14px 14px 10px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.msg { max-width: 86%; padding: 10px 14px; border-radius: 14px; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.row { display: flex; align-items: flex-start; gap: 8px; max-width: 90%; align-self: flex-start; }
.row .ava { margin-top: 4px; }
.row .ava { width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 1px solid var(--line); overflow: hidden; flex: none; }
.row .ava img { width: 100%; height: 100%; display: block; object-fit: cover; }
.msg.bot { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.row .msg.bot { max-width: none; min-width: 0; }
.msg.bot p { margin: 0 0 8px; }
.msg.bot p:last-child { margin-bottom: 0; }
.msg.bot a { color: var(--brand); }
.msg.bot ul, .msg.bot ol { margin: 4px 0 6px; padding-left: 20px; }
.msg.bot li { margin: 4px 0; }
.msg.bot li::marker { color: var(--brand); }
.msg.bot li.card { list-style: none; display: flex; align-items: center; gap: 10px; margin: 8px 0 8px -16px; }
.msg.bot li.card img.pic { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; flex: none; margin: 0; }
.msg.bot li.card div { line-height: 1.35; }
.msg.bot img.pic { display: block; max-width: 100%; border-radius: 10px; margin: 6px 0; cursor: zoom-in; }
.msg.error { background: #fff4f4; border-color: #f3c2c2; }
.typing { display: inline-flex; gap: 4px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #999; animation: b 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes b { 0%, 80%, 100% { opacity: .3 } 40% { opacity: 1 } }
.caret { display: inline-block; width: 2px; height: 1em; background: var(--brand); margin-left: 2px; vertical-align: text-bottom; animation: b .8s infinite; }

/* suggested questions: 2 x 2 grid */
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 14px 10px; background: var(--bg); }
.chip { border: 1px solid var(--brand); color: var(--brand); background: #fff; border-radius: 12px; padding: 8px 10px; font-size: 13px; line-height: 1.3; cursor: pointer; text-align: center; }
.chip:hover { background: var(--brand); color: #fff; }

.quick { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 0 38px; }
.quick .chip { border-radius: 999px; padding: 6px 12px; }

/* composer + footer */
.composer { display: flex; gap: 8px; padding: 10px 12px 4px; border-top: 1px solid var(--line); background: var(--panel); }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; max-height: 120px; outline: none; }
.composer textarea:focus { border-color: var(--brand); }
.composer button { background: var(--brand); color: #fff; border: 0; border-radius: 10px; padding: 0 16px; font-weight: 600; cursor: pointer; }
.composer button:disabled { opacity: .5; cursor: default; }
.foot { font-size: 11px; color: var(--muted); padding: 0 12px 7px; background: var(--panel); line-height: 1.35; text-align: center; white-space: pre-line; }
.count { font-size: 11px; color: var(--muted); text-align: right; padding: 0 14px; background: var(--panel); }
.count:empty { display: none; }

/* lightbox for pictures */
.lightbox { position: fixed; inset: 0; background: rgba(20, 22, 30, .88); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50; cursor: zoom-out; }
.lightbox.on { display: flex; animation: lb .15s ease-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.5); background: #fff; }
.lb-close { position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.15); color: #fff; font-size: 30px; line-height: 1; cursor: pointer; }
.lb-close:hover { background: rgba(255,255,255,.3); }
@keyframes lb { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .lightbox.on { animation: none; } }
