/* Правая часть: шапка с «пилюлей», лента сообщений, markdown, карточки вопроса и одобрения, поле ввода. */
.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.chat-head { display: grid; grid-template-columns: minmax(44px, 1fr) minmax(0, auto) minmax(44px, 1fr); align-items: center; gap: 8px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); }
.chat-head > :first-child { justify-self: start; }
.chat-head > :last-child { justify-self: end; }
.back { visibility: hidden; pointer-events: none; }
@media (max-width: 760px) { .back { visibility: visible; pointer-events: auto; } }
.pill { display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 100%; padding: 5px 18px 5px 5px; border-radius: 999px; background: var(--raise); }
.pill .ava { width: 36px; height: 36px; }
.pill-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.messages { flex: 1; overflow-y: auto; padding: 8px 20px 12px; overscroll-behavior: contain; }
.thread { max-width: 760px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 10px; }
.stamp { align-self: center; color: var(--muted); font-size: 13px; margin: 12px 0 2px; }
.empty-chat { margin: auto; padding: 40px 16px; color: var(--muted); text-align: center; }
.msg { display: flex; max-width: 100%; }
.msg.owner { justify-content: flex-end; }
.msg.wide { display: block; }
.bubble { max-width: min(88%, 640px); padding: 12px 16px; border-radius: 20px; overflow-wrap: anywhere; }
.msg.bot .bubble { background: var(--raise); border-top-left-radius: 6px; }
.msg.owner .bubble { background: var(--bot); color: var(--bot-ink); border-bottom-right-radius: 6px; white-space: pre-wrap; }
.notice { align-self: center; color: var(--muted); font-size: 13px; text-align: center; }

.note { align-self: flex-start; display: inline-flex; align-items: flex-start; gap: 8px; max-width: min(92%, 640px); padding: 8px 14px; border-radius: 14px; background: rgba(255, 255, 255, .05); color: var(--muted); font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }
.note span { white-space: pre-wrap; }
.note .icon { margin-top: 2px; color: var(--bot); }
.note b { color: var(--text); font-weight: 600; }

.status { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; padding: 2px 6px; }
.status.err { color: var(--bad); }
.status.done { color: var(--ok); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

/* markdown внутри сообщений бота */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: .55em 0; }
.md .md-title { font-weight: 700; font-size: 16px; }
.md .md-h { font-size: 16px; margin: .8em 0 .3em; }
.md ul, .md ol { margin: .5em 0; padding-left: 1.4em; }
.md li { margin: .2em 0; }
.md a { color: #8fb4ff; text-decoration: underline; text-underline-offset: 2px; }
.md code { font-family: var(--mono); font-size: .92em; background: rgba(255, 255, 255, .09); padding: 1px 5px; border-radius: 6px; }
.md pre { overflow-x: auto; background: #0e0e11; border-radius: 12px; padding: 12px; margin: .6em 0; }
.md pre code { background: none; padding: 0; }

/* карточки */
.card { width: 100%; background: var(--raise); border-radius: 22px; padding: 18px; }
.q-title { margin: 0 0 14px; font-size: 18px; line-height: 1.3; overflow-wrap: anywhere; white-space: pre-wrap; }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px 12px; border-radius: 14px; background: var(--raise2); border: 1px solid transparent; transition: border-color .15s, background .15s; }
.opt:not(:disabled):hover { border-color: #52525e; }
.letter { flex: none; width: 30px; height: 30px; border-radius: 9px; border: 1px solid #52525e; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--muted); }
.opt-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.opt.sel { background: color-mix(in srgb, var(--bot) 24%, var(--raise2)); }
.opt.sel .letter { background: var(--bot); color: var(--bot-ink); border-color: transparent; }
.opt.dim { opacity: .45; }
.card .btn { margin-top: 14px; }
.card .hint { margin-top: 12px; }
.own { white-space: pre-wrap; margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .05); color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }

.ap-head { display: flex; align-items: center; gap: 8px; color: var(--warn); font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.ap-text { margin: 0 0 12px; font-size: 16px; line-height: 1.4; overflow-wrap: anywhere; white-space: pre-wrap; }
.ap-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tag { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 10px; background: rgba(255, 255, 255, .07); color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.timer { display: inline-flex; align-items: center; gap: 6px; color: var(--warn); font-size: 13px; }
.timer b { font-variant-numeric: tabular-nums; font-weight: 600; }
.ap-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.ap-actions .btn { flex: 1 1 auto; padding: 0 14px; margin: 0; }
.ap-result { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-top: 14px; }
.ap-result.ok { color: var(--ok); }
.ap-result.no { color: var(--bad); }
.ap-result.off { color: var(--muted); }
@media (max-width: 480px) { .ap-actions { flex-direction: column; } }

/* поле ввода */
.composer { padding: 8px 20px 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.compose-box { max-width: 760px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; background: var(--raise); border-radius: 26px; padding: 7px; }
#input { flex: 1; margin-left: 4px; min-width: 0; background: none; border: 0; outline: 0; resize: none; padding: 9px 0; max-height: 160px; line-height: 1.4; font-size: 16px; }
#input::placeholder { color: #70707c; }
@media (max-width: 760px) { #input[data-long="1"]:placeholder-shown { min-height: 64px; } }
.send { width: 40px; height: 40px; border-radius: 50%; background: var(--bot); color: var(--bot-ink); display: grid; place-items: center; flex: none; }
.send:disabled { background: var(--raise2); color: #70707c; }
@media (max-width: 760px) { .messages { padding-left: 14px; padding-right: 14px; } .composer { padding-left: 12px; padding-right: 12px; } }

/* скрепка, плашка файла, секретная карточка */
.attach { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; color: var(--muted); }
.attach:not(:disabled):hover { color: var(--text); background: var(--raise2); }
.attach:disabled { opacity: .4; }
.msg.owner .file-chip { display: inline-flex; align-items: center; gap: 10px; }
.file-chip .icon { flex: none; }
.file-name { min-width: 0; overflow-wrap: anywhere; }
.secret-name { font-weight: 600; overflow-wrap: anywhere; }
.secret-replace { color: var(--warn, #f0b429); overflow-wrap: anywhere; }
.host-new { font-weight: 700; text-decoration: underline; }
.secret .field-input { margin-top: 14px; }
.file-out { display: flex; align-items: center; gap: 12px; }
.file-out .icon { flex: none; }
.file-out-text { min-width: 0; }
.file-out-note { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.file-out-btn { flex: none; padding: 8px 14px; border-radius: 12px; background: var(--bot); color: var(--bot-ink); text-decoration: none; font-size: 14px; }
.shot-box { display: flex; flex-direction: column; gap: 6px; }
.shot-link { display: block; }
.shot { display: block; max-width: 100%; max-height: 320px; border-radius: 12px; cursor: zoom-in; }
.shot-title { font-weight: 600; }
