/* Веб-чат (плагин v0.27). Цвета VNSOFT; в Telegram подменяются цветами темы Telegram. */
:root {
  --bg: #0b0f16; --bg2: #0f1520; --card: #151d2b; --field: #121a27; --fg: #e8eef5; --muted: #8fa0b5; --line: #223047;
  --acc: #3ddc8c; --acc2: #2563d8; --bad: #ff6b6b; --warn: #ffb648;
  --me: linear-gradient(135deg, #0e8f55, #14809a 60%, #2563d8);
  --radius: 14px; --side: 280px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not(.in-tg) {
    --bg: #f5f7fa; --bg2: #eceff4; --card: #ffffff; --field: #ffffff; --fg: #111a27; --muted: #5d6b80; --line: #d7dee8;
    --acc: #0b7d4b; color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: 9px 14px;
  background: var(--acc); color: #04140c; font-weight: 600; }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); }
button.danger { background: var(--bad); color: #fff; }
button.link { background: none; padding: 4px 6px; color: var(--muted); font-weight: 500; }
button.link:hover { color: var(--fg); }
button.icon { background: none; color: var(--muted); padding: 6px 9px; font-weight: 400; }
button.icon:hover { color: var(--fg); background: var(--bg2); }
button.icon.sm { padding: 2px 6px; font-size: 13px; }
a { color: var(--acc); }
.meta { color: var(--muted); font-size: 13px; }

/* загрузка, вход, нет доступа */
.splash, .center { height: 100%; display: grid; place-content: center; justify-items: center; text-align: center; padding: 24px 16px; gap: 6px; }
.splash img, .center .logo { width: 88px; height: 88px; border-radius: 50%; box-shadow: 0 0 0 3px var(--line); }
.center { max-width: 440px; margin: 0 auto; }
.center h1 { margin: 10px 0 0; font-size: 24px; }
.center p { color: var(--muted); margin: 6px 0 12px; }
.btn { display: inline-block; padding: 11px 18px; border-radius: 12px; background: var(--me); color: #fff; text-decoration: none; font-weight: 600; }

/* раскладка */
.layout { display: flex; height: 100dvh; }
.side { width: var(--side); flex: none; display: flex; flex-direction: column; background: var(--bg2); border-right: 1px solid var(--line); }
.side-h { display: flex; align-items: center; gap: 10px; padding: 14px 14px 8px; }
.side-h b { flex: 1; font-size: 16px; }
.ava { width: 32px; height: 32px; border-radius: 50%; flex: none; }
.new { margin: 6px 12px 10px; background: transparent; color: var(--fg); border: 1px solid var(--line); text-align: left; }
.new:hover { background: var(--card); }
.chats { flex: 1; overflow-y: auto; padding: 0 8px; }
.chat { display: flex; align-items: center; gap: 2px; padding: 8px 10px; border-radius: 10px; cursor: pointer; color: var(--muted); }
.chat:hover, .chat.on { background: var(--card); color: var(--fg); }
.chat .ct { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat button { opacity: 0; }
.chat:hover button, .chat.on button { opacity: 1; }
.side-f { border-top: 1px solid var(--line); padding: 8px 10px 12px; display: grid; gap: 2px; }
.side-f .link { text-align: left; }
.me { display: flex; justify-content: space-between; align-items: center; padding: 6px 6px 0; font-size: 14px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); min-height: 52px; }
.title { flex: 1; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.only-m { display: none; }

/* сообщения */
.msgs { flex: 1; overflow-y: auto; padding: 18px 16px 8px; scroll-behavior: smooth; }
.msg { display: flex; gap: 12px; max-width: 800px; margin: 0 auto 18px; }
.msg .col { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.msg.me { justify-content: flex-end; }
.msg.me .col { align-items: flex-end; }
.msg.me .body { background: var(--me); color: #fff; padding: 10px 14px; border-radius: var(--radius) var(--radius) 4px var(--radius);
  max-width: 85%; white-space: pre-wrap; word-wrap: break-word; }
.msg.bot .body { padding-top: 4px; overflow-wrap: anywhere; }
.msg.refused .body { color: var(--warn); }
.body p { margin: 0 0 10px; }
.body p:last-child { margin-bottom: 0; }
.body h3, .body h4, .body h5, .body h6 { margin: 14px 0 6px; line-height: 1.3; }
.body ul, .body ol { margin: 4px 0 10px; padding-left: 22px; }
.body li { margin: 2px 0; }
.body code { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; font-size: 13.5px; }
.body pre { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; }
.body pre code { border: 0; padding: 0; background: none; white-space: pre; }
.body pre .copy { position: absolute; top: 6px; right: 6px; font-size: 12px; padding: 3px 8px; background: var(--bg2); color: var(--muted); }
.body blockquote { margin: 6px 0; padding: 2px 12px; border-left: 3px solid var(--acc); color: var(--muted); }
.body hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.tbl { overflow-x: auto; margin: 6px 0 10px; }
.tbl table { border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; }
.acts { display: flex; gap: 6px; align-items: center; margin-top: 4px; opacity: .75; }
.acts .link { font-size: 13px; padding: 2px 4px; }
.status { color: var(--muted); font-size: 13px; margin-top: 4px; }
.status:empty { display: none; }
.typing i { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 50%; background: var(--muted); animation: dot 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: scale(.7); } 40% { opacity: 1; transform: scale(1); } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 13px; }
.chip.loading { opacity: .7; }

/* пустой чат */
.empty { max-width: 640px; margin: 8vh auto 0; text-align: center; }
.empty .logo { width: 72px; height: 72px; border-radius: 50%; }
.empty h2 { margin: 12px 0 18px; font-size: 26px; }
.ideas { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.idea { background: var(--card); color: var(--fg); border: 1px solid var(--line); text-align: left; font-weight: 500; padding: 12px 14px; }
.idea:hover { border-color: var(--acc); }

/* поле ввода */
.composer { padding: 8px 16px calc(12px + env(safe-area-inset-bottom)); }
.composer .files, .composer .box, .composer .hint { max-width: 800px; margin: 0 auto; }
.files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px !important; }
.files:empty { display: none; }
.box { display: flex; align-items: flex-end; gap: 6px; background: var(--field); border: 1px solid var(--line); border-radius: 18px; padding: 6px; }
.box:focus-within { border-color: var(--acc); }
.box textarea { flex: 1; resize: none; border: 0; outline: 0; background: transparent; color: var(--fg); font: inherit; padding: 8px 4px; max-height: 220px; }
.send { width: 40px; height: 40px; padding: 0; border-radius: 12px; font-size: 16px; }
.send.stop { background: var(--fg); color: var(--bg); }
.attach { font-size: 18px; }
.hint { color: var(--muted); font-size: 12px; text-align: center; margin-top: 6px !important; }

/* окна */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: min(520px, 100%); max-height: 85dvh; overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.modal-h { display: flex; align-items: center; justify-content: space-between; }
.modal-h h3 { margin: 0; }
.modal textarea, .modal input { width: 100%; background: var(--field); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font: inherit; }
.modal-a { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.rules { margin: 8px 0; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); opacity: 0; background: var(--card); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 12px; z-index: 60; transition: .25s; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: var(--bad); color: var(--bad); }
.scrim { display: none; }

/* телефон и мини-приложение */
@media (max-width: 760px) {
  .side { position: fixed; inset: 0 auto 0 0; width: min(86vw, 320px); z-index: 40; transform: translateX(-102%); transition: transform .22s ease; }
  body.drawer .side { transform: none; }
  body.drawer .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 30; }
  .only-m { display: inline-block; }
  .msgs { padding: 14px 12px 6px; }
  .composer { padding: 6px 10px calc(10px + env(safe-area-inset-bottom)); }
  .ideas { grid-template-columns: 1fr; }
  .empty { margin-top: 4vh; }
  .chat button { opacity: 1; }
  .msg.bot .ava { width: 26px; height: 26px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
