.assistant-context {
  position: relative;
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.assistant-context > .context-head {
  position: relative;
  z-index: 8;
}

.assistant-sources {
  position: static;
}

.assistant-sources > summary {
  display: grid;
  width: 19px;
  height: 19px;
  place-items: center;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  cursor: pointer;
  list-style: none;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
}

.assistant-sources > summary::-webkit-details-marker {
  display: none;
}

.assistant-sources > summary span {
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
}

.assistant-sources[open] > summary,
.assistant-sources > summary:hover {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--ink);
}

.assistant-sources-popover {
  position: absolute;
  z-index: 30;
  top: 28px;
  right: 0;
  left: 0;
  padding: 15px;
  overflow: hidden;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-16);
  backdrop-filter: blur(18px);
  corner-shape: squircle;
}

.assistant-sources-popover header {
  display: grid;
  gap: 8px;
}

.assistant-sources-popover header > strong {
  max-width: 240px;
  font-size: 12px;
  line-height: 1.42;
}

.assistant-sources-live {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.assistant-sources-live i {
  width: 6px;
  height: 6px;
  background: var(--success, #4f8660);
  border-radius: 50%;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--success, #4f8660) 13%, transparent);
}

.assistant-sources-live.is-loading i {
  background: var(--accent);
  animation: assistant-pulse 700ms ease-in-out infinite alternate;
}

.assistant-sources-live.is-partial i {
  background: var(--warning, #a97928);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--warning, #a97928) 13%, transparent);
}

.assistant-sources-flow {
  display: grid;
  grid-template-columns: max-content minmax(22px, 1fr) max-content;
  align-items: center;
  gap: 8px;
  margin: 16px 0 12px;
}

.assistant-sources-flow span {
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.assistant-sources-flow span:last-child {
  color: var(--ink);
  font-weight: 700;
}

.assistant-sources-flow i {
  position: relative;
  height: 1px;
  background: var(--line-strong);
}

.assistant-sources-flow i::after {
  position: absolute;
  top: -2px;
  right: 0;
  width: 5px;
  height: 5px;
  border-top: 1px solid var(--muted);
  border-right: 1px solid var(--muted);
  content: "";
  transform: rotate(45deg);
}

.assistant-sources-list {
  border-top: 1px solid var(--line);
}

.assistant-sources-list article {
  display: grid;
  min-width: 0;
  grid-template-columns: 27px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.assistant-source-index {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  color: var(--on-dark);
  background: var(--surface-dark);
  border-radius: 50%;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.assistant-sources-list article.is-loading .assistant-source-index {
  background: var(--accent);
  animation: assistant-pulse 700ms ease-in-out infinite alternate;
}

.assistant-sources-list article.is-error .assistant-source-index {
  color: var(--muted);
  background: var(--surface-2);
}

.assistant-source-copy {
  min-width: 0;
}

.assistant-source-copy strong,
.assistant-source-copy small {
  display: block;
}

.assistant-source-copy strong {
  font-size: 11px;
}

.assistant-source-copy small {
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant-source-value {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 450;
  font-variant-numeric: tabular-nums;
}

.assistant-sources-popover footer {
  padding-top: 10px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.assistant-context-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 4px 12px;
  padding: 0 10px;
  color: var(--muted-2);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-8);
}

/* «Новый диалог» — кнопка, а не строка списка: она заводит новое, а не
   открывает существующее, и путать её с диалогами ниже нельзя. */
.assistant-new-chat {
  display: inline-flex;
  width: calc(100% - 8px);
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 0 4px 10px;
  padding: 4px 10px;
  font-size: 12px;
}

.assistant-new-chat .icon {
  box-sizing: border-box;
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  padding: 0;
  color: currentColor;
  background: transparent;
  border-radius: 0;
}

.assistant-context-search .icon {
  width: 15px;
  height: 15px;
}

.assistant-context-search input {
  min-width: 0;
  height: 36px;
  flex: 1;
  padding: 0;
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 13px;
}

.assistant-context-list {
  min-height: 0;
  flex: 1;
  padding: 0 0 18px;
  overflow: auto;
  overflow-x: hidden;
}

.assistant-chat-row {
  min-height: 34px;
  grid-template-columns: 8px minmax(0, 1fr);
  gap: 8px;
  margin: 0 4px;
  padding: 5px 8px;
  background: transparent;
  border-radius: var(--radius-8);
}

.assistant-chat-row:hover {
  background: var(--surface);
}

.assistant-chat-row .row-title {
  overflow: hidden;
  font-size: var(--font-size-sm, 13px);
  font-weight: 540;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant-chat-marker {
  width: 5px;
  height: 5px;
  background: var(--line-strong);
}

.assistant-context-state {
  display: grid;
  min-height: 100px;
  place-items: center;
  gap: 8px;
  padding: 18px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.assistant-context-state.error {
  color: var(--danger-ink);
}

.assistant-context-state .text-btn {
  color: var(--ink);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.assistant-context-label {
  margin-top: 10px;
}

.assistant-chat-row.active .assistant-chat-marker {
  background: var(--accent);
}

.assistant-screen {
  display: block;
  min-height: 100%;
  background: var(--paper);
}

.assistant-screen .eyebrow {
  font-size: 11px;
}

.assistant-main {
  position: relative;
  min-width: 0;
  min-height: 100%;
  /* Без нижней отбивки: лента доходит до низа экрана, композер лежит
     поверх неё (v1-поведение), а не отрезает часть окна себе. */
  padding: 42px clamp(24px, 5vw, 70px) 0;
}

/* Затухание — на ВСЮ ширину области, а не только под композером: узкая
   подложка обрывалась по бокам, и контент за её краями упирался в низ
   экрана резкой границей. Кликам не мешает. */
.assistant-main::after {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: 0;
  left: 0;
  height: 132px;
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--paper) 0%, transparent) 0%,
    color-mix(in srgb, var(--paper) 78%, transparent) 42%,
    var(--paper) 78%
  );
  content: "";
  pointer-events: none;
}

.assistant-body {
  height: 100%;
}

.assistant-empty {
  width: min(680px, 100%);
  margin: 0 auto;
  padding-top: clamp(28px, 8svh, 92px);
  /* Запас держит сам стартовый блок: у ленты чата он свой. */
  padding-bottom: 132px;
}

.assistant-empty h1 {
  max-width: 680px;
  margin: 0;
  font-size: clamp(42px, 6vw, 72px);
  letter-spacing: -.055em;
  line-height: .94;
}

.assistant-empty h1 em {
  color: var(--accent);
  font-family: var(--serif);
  font-weight: 400;
}

.assistant-empty > p {
  max-width: 620px;
  margin: 20px 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

/* Примеры вопросов — тихая подсказка: ни плиток, ни рамок, ни перекрестий.
   Список ссылок пунктиром, читается как продолжение текста над ним. */
.assistant-query-list {
  display: grid;
  max-width: 620px;
  gap: 9px;
  margin: 30px 0 0;
  padding: 0;
  list-style: none;
}

.assistant-query {
  min-height: 0;
  padding: 0;
  color: var(--ink-2);
  background: transparent;
  border: 0;
  font-size: 14px;
  line-height: 1.45;
  text-align: left;
  text-decoration-color: color-mix(in srgb, currentColor 38%, transparent);
  text-decoration-line: underline;
  text-decoration-style: dashed;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.assistant-query:hover {
  color: var(--ink);
  text-decoration-color: currentColor;
}

.assistant-query:focus-visible {
  border-radius: var(--radius-4);
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.assistant-query-loading,
.assistant-query-error {
  display: flex;
  max-width: 720px;
  min-height: 92px;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
  margin-top: 38px;
  padding: 16px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-16);
  font-size: 12px;
}

.assistant-query-loading {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  justify-content: flex-start;
}

.assistant-loading-dots {
  display: flex;
  width: 34px;
  align-items: center;
  justify-content: space-between;
}

.assistant-loading-dots i {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  animation: assistant-pulse 700ms ease-in-out infinite alternate;
}

.assistant-loading-dots i:nth-child(2) {
  animation-delay: 120ms;
}

.assistant-loading-dots i:nth-child(3) {
  animation-delay: 240ms;
}

.assistant-composer {
  position: absolute;
  right: auto;
  bottom: 24px;
  left: 50%;
  z-index: 4;
  width: min(680px, calc(100% - 48px));
  max-width: 680px;
  min-width: 0;
  transform: translateX(-50%);
}

.assistant-attachment {
  max-width: 100%;
  margin: 0 8px 8px;
  overflow-x: clip;
}

.assistant-attachment-chip {
  display: inline-flex;
  max-width: min(360px, 100%);
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-8);
  font-size: 11px;
}

.assistant-attachment-chip img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: var(--radius-8);
}

.assistant-attachment-chip > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant-screen .simple-composer {
  display: flex;
  min-width: 0;
  align-items: flex-end;
  gap: 6px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-16);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.assistant-screen .simple-composer:focus-within {
  border-color: var(--line-strong);
}

.assistant-screen .simple-composer.dragging {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.assistant-screen-readonly .simple-composer {
  background: var(--surface-2);
  box-shadow: none;
}

.assistant-screen-readonly .simple-composer > :not(textarea) {
  opacity: .45;
}

.assistant-screen .simple-composer textarea {
  min-width: 0;
  height: 38px;
  max-height: 128px;
  flex: 1;
  padding: 9px 6px 6px;
  resize: none;
  overflow: auto;
  background: transparent;
  border: 0;
  outline: 0;
  font: inherit;
  line-height: 1.35;
}

.assistant-send {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--on-dark);
  background: var(--surface-dark);
  border-radius: 50%;
}

.assistant-send:hover {
  background: var(--accent);
}

/* Пока идёт ответ, кнопка просто гаснет. Свой спиннер ей не нужен: колесо
   уже крутится в пузыре ожидания, и два вращения на экране спорят. */
.assistant-send:disabled,
.assistant-send.loading {
  color: var(--muted-2);
  background: var(--surface-2);
  cursor: default;
  opacity: 1;
}

.assistant-send.loading:hover,
.assistant-send:disabled:hover {
  background: var(--surface-2);
}

.assistant-screen-chat .assistant-main {
  height: 100%;
  padding-top: 24px;
  /* Без overflow: hidden — он срезал тень композера. Прокрутку держит
     сама лента (.assistant-log) внутри флекс-колонки. */
}

.assistant-conversation {
  display: flex;
  height: 100%;
  min-height: 0;
  flex-direction: column;
}

.assistant-conversation-head {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  justify-content: space-between;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.assistant-conversation-head h1 {
  max-width: 700px;
  margin: 2px 0 0;
  font-size: clamp(24px, 3vw, 38px);
  letter-spacing: -.05em;
  line-height: 1.05;
}

.assistant-conversation-kicker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.assistant-conversation-kicker .eyebrow {
  margin-bottom: 0;
}

.assistant-log {
  min-height: 0;
  flex: 1;
  /* Нижний запас — под плавающий композер: последнее сообщение доступно
     прокруткой целиком, а не прячется под ним. */
  padding: 24px max(0px, calc((100% - 820px) / 2)) 132px;
  overflow: auto;
  overscroll-behavior-y: contain;
}

.assistant-message {
  width: fit-content;
  max-width: min(720px, 88%);
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-16);
}

.assistant-message-user {
  margin-left: auto;
  background: var(--surface-dark);
  border-color: var(--surface-dark);
  color: var(--on-dark);
  border-bottom-right-radius: var(--radius-4);
}

.assistant-message-bot {
  margin-right: auto;
  color: var(--ink);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  border-bottom-left-radius: var(--radius-4);
}

.assistant-message-bot.assistant-message-with-references {
  width: min(720px, 88%);
}

.assistant-message-text {
  line-height: 1.58;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.assistant-markdown a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.assistant-markdown-list {
  display: grid;
  gap: 4px;
  margin: 8px 0;
  padding: 0;
  list-style: none;
  white-space: normal;
}

/* Маркер — абсолютный, а НЕ колонка грида: содержимое пункта состоит из
   нескольких инлайновых узлов (текст, <strong>, кнопка-сноска), и в
   grid-контейнере каждый из них становился отдельным grid-item — текст
   попадал в 16-пиксельную колонку и рассыпался по букве в столбик. */
.assistant-markdown-list > li {
  position: relative;
  padding-left: 18px;
}

.assistant-markdown-list > li::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 16px;
  color: var(--muted);
  content: "•";
  line-height: inherit;
}

ol.assistant-markdown-list {
  counter-reset: assistant-list;
}

ol.assistant-markdown-list > li {
  counter-increment: assistant-list;
}

ol.assistant-markdown-list > li::before {
  content: counter(assistant-list) ".";
  font-variant-numeric: tabular-nums;
}

/* Сноска — часть строки, а не самостоятельный блок: иначе она отрывается
   от своего пункта (её рвал тот же грид). */
.assistant-citation {
  white-space: nowrap;
}

.assistant-citation {
  display: inline;
  padding: 0;
  color: var(--accent);
  background: transparent;
  font: inherit;
  font-weight: 750;
}

.assistant-message-image {
  display: block;
  width: min(280px, 100%);
  max-height: 260px;
  margin-bottom: 10px;
  object-fit: contain;
  border-radius: var(--radius-8);
}

.assistant-trace {
  margin-top: 12px;
  padding-top: 10px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.45;
}

.assistant-references {
  --reference-visual-w: 132px;
  /* Минимум карточки считается от плитки, а не подбирается на глаз: поля
     8 + 46, плитка, зазор 10 и не меньше 170 px на две строки названия.
     С прежним минимумом 210 px под название оставалось 104, и карточка,
     которая существует ради «вот эта работа», обрывала её на «Ульяновск.
     макет для…». Лучше один столбец, чем два безымянных. */
  --reference-min-w: calc(var(--reference-visual-w) + 236px);
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--reference-min-w)), 1fr));
  gap: 9px;
  margin: 14px -4px -3px;
  padding: 4px;
  overflow-x: clip;
}

.assistant-reference {
  position: relative;
  min-width: 0;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-12);
  overflow: hidden;
  transition: opacity .16s ease, transform .16s ease, border-color .16s ease;
}

.assistant-reference:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.assistant-reference-main {
  position: relative;
  display: grid;
  min-width: 0;
  /* Ширина колонки и ширина плитки — одно число, а не два похожих. Когда
     плитку увеличили с 72 до 132 px, трек сетки остался прежним: плитка
     вылезла в колонку текста и накрыла собой полстроки заголовка. */
  grid-template-columns: var(--reference-visual-w) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px 46px 8px 8px;
  color: inherit;
  text-decoration: none;
}

.assistant-reference-main:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Плитка ссылки — не иконка, а превью работы: по ней узнают макет и листают
   кадры. На 72×58 не читался ни заголовок афиши, ни цена в меню, и человек
   открывал работу только чтобы понять, та ли она. */
.assistant-reference-visual {
  position: relative;
  display: grid;
  width: var(--reference-visual-w);
  height: 106px;
  place-items: center;
  overflow: hidden;
  color: var(--muted-2);
  background: var(--surface-2);
  border-radius: var(--radius-8);
}

/* Картинка помещается целиком, а не обрезается: карточка называет работу, и
   срезанный край меняет её узнаваемость — у афиши уходит заголовок, у меню
   колонка цен. Поля закрывает фон плитки, он для этого и есть. */
.assistant-reference-visual img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.assistant-reference-visual b {
  position: absolute;
  top: 4px;
  left: 4px;
  display: grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  padding: 0 4px;
  color: white;
  background: rgba(19, 19, 19, .82);
  border-radius: var(--radius-8);
  font-size: 11px;
}

.assistant-reference-copy {
  min-width: 0;
}

.assistant-reference-copy strong,
.assistant-reference-copy small,
.assistant-reference-copy span {
  display: block;
}

.assistant-reference-copy strong {
  display: -webkit-box;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.assistant-reference-copy small {
  margin-top: 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant-reference-variants-toggle {
  display: block;
  max-width: calc(100% - 136px);
  margin: -4px 46px 8px 90px;
  padding: 2px 0;
  overflow: hidden;
  color: var(--muted-2);
  background: none;
  border: 0;
  font: inherit;
  font-size: 10px;
  line-height: 1.3;
  text-overflow: ellipsis;
  text-decoration-color: color-mix(in srgb, currentColor 42%, transparent);
  text-decoration-line: underline;
  text-decoration-style: dashed;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  white-space: nowrap;
  cursor: pointer;
}

.assistant-reference-variants-toggle:hover,
.assistant-reference-variants-toggle:focus-visible {
  color: var(--ink);
}

.assistant-reference-variants {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--line);
  animation: assistant-variants-in .14s ease-out both;
}

.assistant-reference-variants[hidden] {
  display: none;
}

.assistant-reference-variant {
  display: grid;
  min-width: 0;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  padding: 4px;
  overflow: hidden;
  color: var(--muted);
  text-decoration: none;
  border-radius: var(--radius-8);
  font-size: 10px;
  line-height: 1.3;
}

.assistant-reference-variant:hover,
.assistant-reference-variant:focus-visible {
  color: var(--ink);
  background: var(--surface-2);
}

.assistant-reference-variant-thumb {
  display: grid;
  width: 38px;
  height: 30px;
  place-items: center;
  overflow: hidden;
  color: var(--muted-2);
  background: var(--surface-2);
  border-radius: var(--radius-4);
}

.assistant-reference-variant-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.assistant-reference-variant > span:last-child {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

@keyframes assistant-variants-in {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }
}

.assistant-reference-reason {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.assistant-reference-open {
  position: absolute;
  top: 6px;
  right: 6px;
  color: var(--muted-2);
}

.assistant-reference-reject {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 0;
  color: var(--muted-2);
  background: none;
  border: 0;
  font: inherit;
  font-size: 10px;
  line-height: 1.2;
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
  text-decoration-line: underline;
  text-decoration-style: dashed;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  cursor: pointer;
}

.assistant-reference-reject:hover,
.assistant-reference-reject:focus-visible {
  color: var(--ink);
}

.assistant-reference.has-variants.is-variants-open .assistant-reference-reject {
  top: 52px;
  bottom: auto;
}

.assistant-reference-undo {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  color: var(--muted);
  background: var(--paper);
  font-size: 11px;
}

.assistant-reference-undo button {
  padding: 3px 0;
  color: var(--ink);
  background: none;
  border: 0;
  font: inherit;
  text-decoration-color: currentColor;
  text-decoration-line: underline;
  text-decoration-style: dashed;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  cursor: pointer;
}

.assistant-reference.is-rejected .assistant-reference-main,
.assistant-reference.is-rejected .assistant-reference-reject {
  opacity: 0;
}

.assistant-reference.is-dismissed {
  opacity: 0;
  transform: scale(.98);
}

.assistant-clarification {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  padding: 2px 0 2px 10px;
  border-left: 1px solid var(--line-strong);
}

.assistant-clarification strong {
  font-size: 12px;
  font-weight: 600;
}

.assistant-clarification > span {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
}

.assistant-clarification button {
  padding: 2px 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  font: inherit;
  font-size: 11px;
  text-decoration-color: color-mix(in srgb, currentColor 46%, transparent);
  text-decoration-line: underline;
  text-decoration-style: dashed;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  cursor: pointer;
}

.assistant-clarification button:hover,
.assistant-clarification button:focus-visible {
  color: var(--accent);
}

.assistant-clarification .assistant-clarification-default {
  color: var(--muted-2);
}

.assistant-clarification button:disabled {
  cursor: default;
  opacity: .46;
}

.assistant-clarification.is-resolving,
.assistant-clarification.is-resolved {
  opacity: .72;
}

.assistant-reference-open .icon {
  width: 11px;
  height: 11px;
}

.assistant-message-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -10px 0 18px 3px;
  color: var(--muted);
}

.assistant-message-actions .icon-btn {
  width: 28px;
  height: 28px;
}

.assistant-iterations {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.assistant-user-turn {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
}

.assistant-user-actions {
  margin-right: 3px;
  margin-left: auto;
}

/* Правка — тот же бабл: подсвечиваем каретку и границу, но не строим
   вокруг сообщения отдельный интерфейс. Габариты не меняются, поэтому
   лента под сообщением не сдвигается. */
.assistant-message-text.is-editing {
  outline: none;
  caret-color: white;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .32);
  border-radius: var(--radius-4);
  padding: 2px 4px;
  margin: -2px -4px;
}

.assistant-edit-hint {
  color: var(--muted);
  font-size: 10px;
  line-height: 20px;
  white-space: nowrap;
}

/* Ожидание ответа — не строчка, а лента шагов: видно, ЧТО делается сейчас и
   что уже сделано. Пузырь живёт по общим правилам реплики: те же отступы,
   тот же фон. Раньше строка сидела в нём криво и липла к верхнему краю. */
.assistant-thinking {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.assistant-progress {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.assistant-progress li {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  font-size: 13px;
  line-height: 1.3;
}

.assistant-progress-mark {
  box-sizing: border-box;
  width: 13px;
  height: 13px;
  border-radius: 50%;
}

.assistant-progress li.is-live .assistant-progress-mark {
  border: 2px solid color-mix(in srgb, var(--accent) 24%, transparent);
  border-top-color: var(--accent);
  animation: assistant-spin 720ms linear infinite;
}

.assistant-progress li.is-done .assistant-progress-mark {
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
}

.assistant-progress-copy {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-2);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant-progress li.is-done .assistant-progress-copy {
  color: var(--muted);
}

.assistant-progress-meta {
  padding-left: 24px;
  color: var(--muted-2);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* Цена ответа — самая тихая строка в пузыре: её ищут глазами специально,
   а не читают по дороге. */
.assistant-answer-cost {
  margin-top: 10px;
  color: var(--muted-2);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.assistant-chat-loading,
.assistant-chat-error {
  display: grid;
  min-height: 220px;
  place-items: center;
  gap: 12px;
  color: var(--muted);
  text-align: center;
}

@keyframes assistant-spin {
  to { transform: rotate(360deg); }
}

@keyframes assistant-pulse {
  to { opacity: .3; }
}

@media (max-width: 1180px) {
  .assistant-main {
    padding-right: 32px;
    padding-left: 32px;
  }

  .assistant-composer {
    width: min(680px, calc(100% - 64px));
  }
}

@media (max-width: 900px) {
  .assistant-main {
    min-height: 100%;
  }
}

@media (max-width: 720px) {
  .assistant-main {
    padding: 26px 16px 124px;
  }

  .assistant-empty h1 {
    font-size: clamp(45px, 16vw, 72px);
  }

  .assistant-empty {
    padding-top: 20px;
  }

  .assistant-empty > p {
    font-size: 14px;
  }

  .assistant-query-list {
    margin-top: 22px;
  }

  .assistant-query {
    font-size: 13px;
  }

  .assistant-composer {
    position: fixed;
    right: 12px;
    bottom: calc(12px + var(--mobile-dock-h, 58px) + env(safe-area-inset-bottom));
    left: 12px;
    width: auto;
    max-width: none;
    transform: none;
  }

  .assistant-screen .simple-composer {
    padding: 8px;
  }

  .assistant-screen-chat .assistant-main {
    height: calc(100% - var(--mobile-dock-h, 58px));
    padding-top: 16px;
  }

  .assistant-log {
    /* Тот же запас под плавающий композер, что и на десктопе. */
    padding: 18px 0 118px;
  }

  .assistant-message {
    max-width: 94%;
  }

  .assistant-query-loading {
    min-height: 76px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .assistant-loading-dots i,
  .assistant-sources-live.is-loading i,
  .assistant-sources-list article.is-loading .assistant-source-index,
  .assistant-progress li.is-live .assistant-progress-mark,
  .assistant-reference-variants {
    animation: none;
  }

  .assistant-progress li.is-live .assistant-progress-mark {
    border-top-color: currentColor;
  }
}

/* Пришли ссылкой из журнала разбора — сообщение должно само сказать «вот я».
   Обёртки у реплик разные (.assistant-answer, .assistant-user-turn), поэтому
   подсветка цепляется к самому помеченному узлу, а не к списку классов. */
.assistant-log .is-linked {
  animation: assistant-linked 2200ms ease-out;
}

@keyframes assistant-linked {
  0%, 55% {
    border-radius: var(--radius-12);
    box-shadow: 0 0 0 2px var(--accent),
      0 0 0 7px color-mix(in srgb, var(--accent) 16%, transparent);
  }

  100% {
    border-radius: var(--radius-12);
    box-shadow: 0 0 0 0 transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .assistant-log .is-linked {
    animation: none;
    box-shadow: 0 0 0 2px var(--accent);
  }
}

/* Архив — тихая ссылка внизу колонки, а не половина шапки: заходят туда
   изредка, а место наверху нужно самим диалогам. */
.assistant-archive-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  margin: 0 4px;
  padding: 9px 8px;
  color: var(--muted);
  background: transparent;
  border-top: 1px solid var(--line);
  border-radius: 0;
  font-size: 12px;
  text-align: left;
}

.assistant-archive-toggle:hover,
.assistant-archive-toggle.active {
  color: var(--ink);
}

.assistant-archive-toggle .icon {
  width: 14px;
  height: 14px;
}

/* Действия строки живут под курсором: список читают, а не разбирают. */
/* Строка всегда во всю ширину: действия НЕ отбирают у неё место, а всплывают
   поверх правого края. Раньше они были соседней колонкой, и от наведения
   название укорачивалось — список дёргался под курсором. */
.assistant-chat-line {
  position: relative;
}

.assistant-chat-line .assistant-chat-row {
  width: calc(100% - 8px);
  min-width: 0;
}

/* Подсветку держит СТРОКА, а не кнопка: курсор над всплывшими действиями
   уходит с кнопки, и фон иначе гас ровно в момент, когда по нему целятся. */
.assistant-chat-line:hover .assistant-chat-row {
  background: var(--surface);
}

.assistant-chat-actions {
  position: absolute;
  top: 50%;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 1px;
  padding-left: 24px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%);
  transition: opacity 120ms ease;
  /* Длинное название уходит под кнопки — растворяем его, а не обрезаем в упор. */
  background: linear-gradient(
    to right,
    transparent,
    var(--surface) 24px
  );
}

.assistant-chat-line:hover .assistant-chat-actions,
.assistant-chat-line:focus-within .assistant-chat-actions {
  opacity: 1;
  pointer-events: auto;
}

.assistant-chat-action {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: var(--muted-2);
}

.assistant-chat-action:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.assistant-chat-action .icon {
  width: 13px;
  height: 13px;
}

@media (hover: none) {
  .assistant-chat-actions {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Сбой — тоже ответ, и выглядеть он обязан по-человечески. Страницу nginx
   целиком в пузырь не пускаем: она уезжает в отладку, а человек читает одну
   понятную строку и жмёт одну кнопку. */
.assistant-message-failure {
  border-color: color-mix(in srgb, var(--danger-ink) 34%, var(--line));
  background: color-mix(in srgb, var(--danger-ink) 6%, transparent);
}

.assistant-failure {
  display: grid;
  gap: 8px;
}

.assistant-failure strong {
  font-size: 14px;
}

.assistant-failure p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.assistant-failure-detail {
  color: var(--muted-2);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.assistant-failure-copy {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-8);
  font-size: 12px;
}

.assistant-failure-copy:hover {
  background: var(--surface-2);
}

.assistant-failure-copy .icon {
  width: 14px;
  height: 14px;
}

.assistant-failure-raw {
  width: 100%;
  min-height: 120px;
  padding: 8px;
  color: var(--ink-2);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-8);
  font-family: inherit;
  font-size: 11px;
  resize: vertical;
}

/* Плитка ссылки со скрабом: кадры листаются протяжкой мыши, как на карточке
   задачи. Курсор объявляет это раньше, чем человек попробует. */
.bx-v2-assistant .assistant-reference-visual.has-scrub {
  cursor: ew-resize;
}

.bx-v2-assistant .assistant-reference-visual.has-scrub img {
  pointer-events: none;
}
