/* Помощник (chat.js): шапка с языком и темами разговора, лента сообщений, строка ввода закреплена внизу.
   Цвета только из переменных app.css: светлая и тёмная тема, акцент языка через .L-en / .L-es. */
main:has(> .ch){padding-bottom:0}
/* экран не короче окна: строка ввода всегда внизу, сообщения прижаты к ней, как в мессенджере */
.ch{display:flex;flex-direction:column;gap:14px;min-height:calc(100dvh - var(--hdr-h, 0px) - var(--bar-h, 0px) - 20px)}
.ch-head{gap:12px;padding:16px}
.ch-how{margin:0;padding-left:20px;display:grid;gap:4px;font-size:15px}
.ch-ctl{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
.ch-ctl .seg{padding:3px}
.ch-ctl .seg button{padding:6px 12px}
.ch-ctl .seg button:disabled{cursor:default}
.ch-clear{margin-left:auto;display:inline-flex;gap:6px}
.ch-clear.ib{width:36px;height:36px;color:var(--muted)}
.ch-clear.ib:hover{color:var(--bad);border-color:var(--bad)}
.ch-pick{padding-top:12px;border-top:1px solid var(--line)}
.ch-pick .chip{text-align:left}

/* разговор: тема и «Закончить» прилипают под шапкой */
.ch-talk{position:sticky;top:calc(var(--hdr-h, 0px) - 1px);z-index:5;display:flex;align-items:center;justify-content:space-between;gap:10px;
  padding:10px 12px;border-radius:12px;background:var(--lang-soft);box-shadow:0 0 0 6px var(--bg)}
.ch-talk:empty{display:none}
.ch-talk .eyebrow{color:var(--lang-ink)}
.ch-topic{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;font-size:15px;line-height:1.3}
.ch-talk .btn{flex:0 0 auto;white-space:nowrap}

/* лента */
.ch-list{display:flex;flex-direction:column;justify-content:flex-end;gap:12px;flex:1 0 40px}
.ch-me{display:flex;justify-content:flex-end}
/* свои сообщения нейтральные (как нажатый чип): язык фразы определяет ИИ, переключатель тут ни при чём */
.ch-bub{max-width:85%;padding:10px 14px;border-radius:18px 18px 4px 18px;background:var(--fg);color:var(--bg);white-space:pre-wrap;overflow-wrap:anywhere}
.ch-heard{opacity:.7;font-size:14px}
.ch-ai{display:grid;gap:12px;padding:14px;border-radius:18px 18px 18px 4px;background:var(--surface);border:1px solid var(--line);min-width:0;overflow-wrap:anywhere}
.ch-r{align-self:flex-start;max-width:92%}
.ch-say{display:grid;grid-template-columns:auto 1fr;gap:10px;align-items:center;min-width:0}
.ch-ai .ib{width:36px;height:36px}
.ch-ai .answer{padding:12px}
.ch-w{font-size:20px;font-weight:700;line-height:1.25}
.ch-ipa{font-family:var(--f-mono);font-size:13px;font-weight:500;color:var(--muted)}
.ch-ex{list-style:none;margin:0;padding:0;display:grid;gap:8px}
.ch-ex li{display:grid;grid-template-columns:auto 1fr;gap:10px;align-items:center}
.ch-ex.add li{grid-template-columns:auto 1fr auto}
.ch-ex.add li>.ib:last-child{font:500 22px/1 var(--f-body);color:var(--fg)}
.ch-ai .ch-added,.ch-ai .ch-added:disabled{background:var(--good-soft);color:var(--good);border-color:transparent;cursor:default}
.ch-cards{display:flex;flex-wrap:wrap;gap:6px}
.ch-cards .btn{max-width:100%}
.ch-fix{display:grid;gap:2px;padding:8px 10px;border-radius:10px;background:var(--surface-2);font-size:15px}
.ch-fix .bad{text-decoration:line-through;text-decoration-color:var(--bad);color:var(--muted)}
.ch-fix .good{color:var(--good);font-weight:600}
.ch-note{align-self:center;max-width:90%;text-align:center;font-size:14px;color:var(--muted)}
.ch-note b{color:var(--fg)}
.ch-err{display:flex;flex-wrap:wrap;gap:4px 12px;align-items:baseline;padding-inline:4px}
.ch-wait{display:flex;align-items:center;justify-content:space-between;gap:12px;align-self:flex-start;padding-block:10px}

/* строка ввода */
.ch-bar{position:sticky;bottom:0;z-index:5;display:flex;align-items:flex-end;gap:8px;background:var(--bg);border-top:1px solid var(--line);
  margin-inline:-16px;padding:10px 16px calc(10px + env(safe-area-inset-bottom, 0px) + var(--tg-safe-area-inset-bottom, 0px))}
.ch-bar textarea{flex:1;min-height:44px;max-height:160px;height:44px;resize:none;overflow-y:hidden;padding:10px 16px;border-radius:22px;font-size:16px;line-height:1.4}
.ch-bar textarea::placeholder{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ch-tools{display:flex;gap:6px;flex:0 0 auto}
.ch-btn{width:44px;height:44px;border-radius:50%;border:1px solid var(--line);background:var(--surface);color:var(--fg);display:inline-grid;place-items:center;cursor:pointer;padding:0;font:500 22px/1 var(--f-body)}
.ch-btn:hover{border-color:var(--muted)}
.ch-btn:disabled{opacity:.45;cursor:default}
.ch-send{background:var(--lang);color:var(--lang-on);border-color:transparent}
.ch-rec{width:auto;display:inline-flex;align-items:center;gap:6px;padding-inline:14px;border:0;background:var(--bad);color:#fff;font:600 15px var(--f-body);font-variant-numeric:tabular-nums;animation:recpulse 1.2s ease-in-out infinite}
