/* Основа: цвета, кнопки, поля, каркас из двух колонок и левая колонка со списком ботов. Тёмная тема, системные шрифты. */
:root {
  --bg: #0b0b0d; --side: #121215; --raise: #1b1b20; --raise2: #26262c; --line: #2b2b32;
  --text: #f2f2f5; --muted: #9393a0; --accent: #4d8dff; --warn: #f2b441; --ok: #58c878; --bad: #ff8a8d;
  --bot: #8b6cf5; --bot-ink: #ffffff;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { display: block; flex: none; }
.muted { color: var(--muted); }
.avatar { display: block; width: 100%; height: 100%; }

/* кнопки */
.btn { height: 44px; padding: 0 18px; border-radius: 14px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background .15s, opacity .15s; }
.btn.sm { height: 34px; padding: 0 12px; border-radius: 10px; font-size: 14px; }
.btn.wide { width: 100%; }
.btn.primary { background: var(--text); color: #111114; }
.btn.primary:not(:disabled):hover { background: #fff; }
.btn.soft { background: var(--raise2); }
.btn.soft:hover { background: #30303a; }
.btn.ghost { color: var(--muted); border: 1px solid var(--line); }
.btn.ghost:hover { color: var(--text); }
.btn.danger { background: #5b1f23; color: #ffb4b6; }
.btn:disabled { opacity: .4; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--raise); color: var(--text); flex: none; }
.icon-btn:hover { background: var(--raise2); }
.icon-btn.sm { width: 32px; height: 32px; background: transparent; color: var(--muted); }
.icon-btn.sm:hover { color: var(--text); background: var(--raise2); }

/* поля */
.field { margin-bottom: 16px; }
.field-label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px 2px; }
.field-input { width: 100%; background: var(--raise); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; min-height: 46px; outline: none; font-size: 16px; }
.field-input:focus { border-color: #5d5d6b; }
textarea.field-input { resize: vertical; line-height: 1.4; }
.field-input.mono { font-family: var(--mono); font-size: 13px; }
select.field-input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 2px 0; }
.form-error { color: var(--bad); font-size: 14px; margin: 8px 0; }
.form-ok { color: var(--ok); margin: 12px 0 0; text-align: center; }

/* каркас */
.shell { position: relative; display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.sidebar { flex: 0 0 420px; width: 420px; display: flex; flex-direction: column; background: var(--side); border-right: 1px solid var(--line); min-width: 0; }
.side-head { display: flex; align-items: center; gap: 10px; padding: 16px 16px 10px; padding-top: max(16px, env(safe-area-inset-top)); }
.search { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px; border-radius: 22px; background: var(--raise); color: var(--muted); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); font-size: 16px; }
.search input::-webkit-search-cancel-button { display: none; }
.search input::placeholder { color: var(--muted); }
.add { background: var(--text); color: #111114; }
.add:hover { background: #fff; }

.bot-list { list-style: none; margin: 0; padding: 6px 8px; flex: 1; overflow-y: auto; }
.bot-row { width: 100%; display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-radius: 18px; text-align: left; }
.bot-row:hover { background: rgba(255, 255, 255, .04); }
.bot-row.active { background: var(--raise); }
.ava { width: 56px; height: 56px; flex: none; display: block; }
.bot-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bot-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bot-name { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.bot-last { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread { width: 11px; height: 11px; border-radius: 50%; background: var(--accent); flex: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 5px; font-size: 12px; line-height: 18px; padding: 1px 8px; border-radius: 10px; background: rgba(255, 255, 255, .07); color: var(--muted); }
.chip-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.busy { color: #8fb4ff; }
.chip.busy .chip-dot { animation: pulse 1.1s ease-in-out infinite; }
.chip.wait { color: var(--warn); }
.chip.err { color: var(--bad); }
.chip.done { color: var(--ok); }
.empty { padding: 28px 16px; color: var(--muted); text-align: center; }

.side-foot { display: flex; align-items: center; gap: 12px; padding: 14px 18px; padding-bottom: max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.me-ava { width: 40px; height: 40px; border-radius: 50%; background: var(--raise2); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.me-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1 0 calc(100% - 52px); } /* имя занимает строку целиком, кнопки уходят на вторую */
.side-foot .btn { flex: none; }
.side-foot { flex-wrap: wrap; row-gap: 8px; }

/* подсказки */
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 80; max-width: min(520px, calc(100% - 32px)); padding: 12px 18px; border-radius: 14px; background: #34343c; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }
.conn { position: fixed; top: 0; left: 0; right: 0; z-index: 90; padding: 8px 16px; text-align: center; font-size: 14px; background: #5a4310; color: #ffe2a3; }

@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

/* средний экран: колонка уже */
@media (max-width: 1000px) { .sidebar { flex-basis: 340px; width: 340px; } }

/* телефон: список и чат - два отдельных экрана */
@media (max-width: 760px) {
  .sidebar { flex: 1 1 100%; width: 100%; border-right: 0; }
  .chat { position: fixed; inset: 0; z-index: 5; transform: translateX(100%); visibility: hidden; transition: transform .22s ease, visibility 0s .22s; }
  .shell.view-chat .chat { transform: none; visibility: visible; transition: transform .22s ease; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
