/* Пример чата с ИИ-ассистентом: нейтральный «мессенджер» в рамке телефона. Все классы начинаются с cd-.
   Внутри «экрана» — только синий/серый/белый (не цвета сайта), системный шрифт. Рамка меняется под тему страницы,
   экран всегда светлый. Переменные --cd-* можно переопределять снаружи. */
.cd{--cd-blue:#0b84fe;--cd-gray:#e9e9eb;--cd-ink:#111113;--cd-mut:#6c6c70;--cd-screen:#fff;--cd-link:#0a64c8;
  --cd-frame:#1d1d20;--cd-frame-edge:#34343a;--cd-shadow:0 28px 50px -26px rgba(0,0,0,.5);
  margin:0;display:flex;flex-direction:column;align-items:center;gap:12px;
  font:15px/1.35 system-ui,-apple-system,"SF Pro Text","Segoe UI",Roboto,Helvetica,Arial,sans-serif}
@media (prefers-color-scheme:dark){.cd{--cd-frame:#2e2e33;--cd-frame-edge:#55555c;--cd-shadow:0 28px 50px -24px rgba(0,0,0,.85)}}
:root[data-theme="dark"] .cd{--cd-frame:#2e2e33;--cd-frame-edge:#55555c;--cd-shadow:0 28px 50px -24px rgba(0,0,0,.85)}
:root[data-theme="light"] .cd{--cd-frame:#1d1d20;--cd-frame-edge:#34343a;--cd-shadow:0 28px 50px -26px rgba(0,0,0,.5)}

/* пропорции современного телефона 19.5:9, тонкая рамка; на компьютере ширина 300 px, на узком экране — на всю ширину блока */
.cd-phone{box-sizing:border-box;display:flex;width:min(300px,100%);aspect-ratio:9/19.5;padding:5px;border-radius:44px;background:var(--cd-frame);
  box-shadow:var(--cd-shadow),0 0 0 1.5px var(--cd-frame-edge) inset}
.cd-screen{position:relative;display:flex;flex-direction:column;flex:1;min-width:0;border-radius:39px;overflow:hidden;
  background:var(--cd-screen);color:var(--cd-ink)}
.cd-status{display:flex;align-items:center;justify-content:space-between;padding:14px 26px 6px;font-size:12px;font-weight:600;letter-spacing:.01em}
.cd-island{width:84px;height:24px;border-radius:14px;background:#111}
.cd-icons{display:flex;align-items:center;gap:5px}
.cd-sig{width:14px;height:9px;background:linear-gradient(90deg,#111 0 2px,transparent 2px 4px,#111 4px 6px,transparent 6px 8px,#111 8px 10px,transparent 10px 12px,#111 12px 14px);
  clip-path:polygon(0 100%,0 70%,28% 70%,28% 45%,57% 45%,57% 20%,86% 20%,86% 0,100% 0,100% 100%)}
.cd-bat{width:20px;height:9px;border:1.5px solid #111;border-radius:3px;position:relative}
.cd-bat:after{content:"";position:absolute;inset:1.5px 4px 1.5px 1.5px;background:#111;border-radius:1px}
.cd-head{display:flex;align-items:center;justify-content:center;gap:8px;padding:6px 14px 8px;font-size:13px;font-weight:600;border-bottom:1px solid rgba(0,0,0,.08)}
.cd-avatar{width:22px;height:22px;border-radius:50%;background:linear-gradient(160deg,#c9c9ce,#9e9ea4)}

.cd-thread,.cd-stage{flex:1 1 auto;min-height:0;display:flex;flex-direction:column;justify-content:flex-end;gap:6px;padding:12px 12px 10px;overflow:hidden}
.cd-stage{display:none}
.cd.is-animating .cd-thread{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.cd.is-animating .cd-stage{display:flex}

.cd-msg{display:flex;flex-direction:column;max-width:88%;gap:2px}
.cd-me{align-self:flex-end;align-items:flex-end}
.cd-ai{align-self:flex-start;align-items:flex-start}
.cd-bubble{padding:8px 12px;border-radius:18px;font-size:14px;line-height:1.35;overflow-wrap:anywhere}
.cd-me .cd-bubble{background:var(--cd-blue);color:#fff;border-bottom-right-radius:5px}
.cd-ai .cd-bubble{background:var(--cd-gray);color:var(--cd-ink);border-bottom-left-radius:5px}
.cd-bubble p{margin:0}
.cd-time{font-size:10px;color:var(--cd-mut);padding:0 6px}
.cd-list{list-style:none;margin:7px 0 0;padding:0;display:flex;flex-direction:column;gap:7px}
.cd-list li{display:flex;flex-direction:column}
.cd-list a{color:var(--cd-link);font-weight:600;text-decoration:underline;text-underline-offset:2px;text-decoration-thickness:1px}
.cd-list a:focus-visible{outline:2px solid var(--cd-blue);outline-offset:2px;border-radius:3px}
.cd-meta{font-size:12px;color:var(--cd-mut)}
.cd-src{margin:8px 0 0!important;font-size:11px;line-height:1.3;color:var(--cd-mut)}

.cd-input{display:flex;align-items:flex-end;gap:8px;padding:8px 10px 18px;border-top:1px solid rgba(0,0,0,.06)}
/* строка ввода растёт вверх, пока вопрос печатается (до 4 строк), как в мессенджере */
.cd-field{box-sizing:border-box;flex:1;min-width:0;min-height:34px;max-height:calc(4 * 1.3em + 16px);padding:7px 13px;border:1px solid rgba(0,0,0,.14);border-radius:18px;
  font-size:14px;line-height:1.3;white-space:pre-wrap;overflow-wrap:anywhere;overflow:hidden}
.cd-hint{color:#9a9aa0}
.cd-typed{color:var(--cd-ink)}
.cd-caret{display:none;width:1.5px;height:1.05em;margin-left:1px;vertical-align:text-bottom;background:var(--cd-blue);animation:cd-blink 1s steps(2) infinite}
.cd-send{flex:none;width:30px;height:30px;margin-bottom:2px;border-radius:50%;background:#c7c7cc;position:relative;transition:background .15s}
.cd-send:after{content:"";position:absolute;left:50%;top:50%;width:8px;height:8px;margin:-2px 0 0 -4px;border:solid #fff;border-width:2px 0 0 2px;transform:rotate(45deg)}
.cd.is-typing .cd-hint{display:none}
.cd.is-typing .cd-caret{display:inline-block}
.cd.is-typing .cd-send{background:var(--cd-blue)}

.cd-caption{max-width:34em;text-align:center;font-size:.85rem;line-height:1.4;color:var(--muted,#6c6c70)}

/* анимации: только когда включён JS и пользователь не просил меньше движения */
.cd-pop{animation:cd-pop .22s ease-out both;transform-origin:bottom}
.cd-rise{animation:cd-rise .28s ease-out both}
.cd-dots{display:inline-flex;gap:4px;align-items:center;height:16px}
.cd-dots i{width:7px;height:7px;border-radius:50%;background:#8e8e93;animation:cd-bounce 1s ease-in-out infinite}
.cd-dots i:nth-child(2){animation-delay:.15s}.cd-dots i:nth-child(3){animation-delay:.3s}
@keyframes cd-pop{from{opacity:0;transform:translateY(8px) scale(.94)}to{opacity:1;transform:none}}
@keyframes cd-rise{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
@keyframes cd-bounce{0%,60%,100%{transform:translateY(0);opacity:.5}30%{transform:translateY(-5px);opacity:1}}
@keyframes cd-blink{50%{opacity:0}}
@media (max-width:440px){.cd-phone{width:100%}}
@media (prefers-reduced-motion:reduce){.cd-pop,.cd-rise,.cd-dots i,.cd-caret{animation:none!important}}
