/* ВШИТ В БИНАРНИК (include_str!). Правка на диске НЕ ВИДНА без пересборки:
   cargo build -p monolith-studio --profile release-studio && systemctl restart monolith-studio
   Подробности — web/ЧИТАЙ_ПЕРЕД_ПРАВКОЙ.md */
/* Стили рендера, взятые у интерфейса агента: блоки кода, превью HTML, картинки. */
.msg-bubble code {
  background: #0d0f14;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 13px;
}
.msg-bubble pre {
  background: #0d0f14;
  border-radius: 8px;
  padding: 12px 14px;
  margin: 8px 0;
  overflow-x: auto;
  font-size: 13px;
  position: relative;
  border: 1px solid #232734;
}
.msg-bubble pre code {
  background: transparent;
  padding: 0;
  font-family: "SF Mono", Consolas, monospace;
}
.msg-bubble blockquote {
  border-left: 3px solid #4a9eff;
  padding-left: 12px;
  margin: 8px 0;
  color: #aaa;
}
.msg-bubble table { display: block; width: max-content; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-collapse: collapse; margin: 8px 0; font-size: 13px; white-space: normal; }
.msg-bubble img { max-width: 100%; border-radius: 8px; margin: 6px 0; cursor: pointer; }
.code-copy {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,0.4);
  border: none;
  color: #aaa;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}
.code-copy:hover { background: #2a2f3d; color: #fff; }
.html-preview-btn {
  position: absolute;
  top: 6px;
  right: 38px;
  background: rgba(74,158,255,0.2);
  border: 1px solid #4a9eff;
  color: #4a9eff;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
}
/* === Fullscreen image / html preview === */
.img-fullscreen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.92);
  z-index: 1000;
  display: flex;
  flex-direction: column;
}
.img-fullscreen-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px 16px;
  background: #0a0c11;
  border-bottom: 1px solid #232734;
  position: relative;
  z-index: 2;
}
.img-fullscreen-name { color: #aaa; font-size: 14px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.img-fullscreen-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: 12px;
}
.img-fullscreen-btn:active { background: rgba(255,255,255,0.3); }
.img-fullscreen img { flex: 1; min-height: 0; object-fit: contain; width: 100%; }
.img-fullscreen iframe { flex: 1; min-height: 0; border: none; background: #fff; }
/* === Active UI === */
.aui-block {
  margin: 8px 0;
  padding: 12px;
  background: #1a1d28;
  border: 1px solid #2a2f3d;
  border-left: 3px solid #4a9eff;
  border-radius: 8px;
  max-width: 460px;
}
.aui-text {
  color: #c0c0c0;
  font-size: 14px;
  margin-bottom: 10px;
}
.aui-buttons-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.aui-btn {
  background: #2a2f3d;
  border: 1px solid #3a4050;
  color: #e0e0e0;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.aui-btn:hover { background: #353a4a; border-color: #4a9eff; }
.aui-btn:active { transform: scale(0.97); }
.aui-btn-yes { background: #1f3a2e; border-color: #2d6447; color: #4ade80; }
.aui-btn-no { background: #3a1f1f; border-color: #6e2d2d; color: #f87171; }
.aui-btn-submit { background: #2552a1; border-color: #4a9eff; color: #fff; margin-top: 8px; }
.aui-btn-other { background: transparent; color: #888; border-color: #2a2f3d; }
.aui-select {
  width: 100%;
  background: #1f2330;
  border: 1px solid #2a2f3d;
  border-radius: 6px;
  padding: 8px 12px;
  color: #e0e0e0;
  font-size: 14px;
}
.aui-cb-cont {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.aui-cb {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
}
.aui-cb input { width: 16px; height: 16px; accent-color: #4a9eff; }
.aui-text-input {
  width: 100%;
  background: #1f2330;
  border: 1px solid #2a2f3d;
  border-radius: 6px;
  padding: 8px 12px;
  color: #e0e0e0;
  font-size: 14px;
  outline: none;
  margin-bottom: 8px;
}
.aui-text-input:focus { border-color: #4a9eff; }
.aui-responded {
  border-left-color: #4ade80;
}
.aui-result {
  color: #4ade80;
  font-size: 14px;
  font-weight: 500;
  padding: 2px 0;
}
.aui-error {
  color: #f87171;
  font-size: 13px;
}
/* === Фикс overflow для code-блоков === */
.msg { min-width: 0; }
.msg-bubble pre { max-width: 100%; overflow-x: auto; }
.msg-bubble pre code { white-space: pre; }
/* === Code header (lang + actions) === */
.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #0a0c11;
  border: 1px solid #232734;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 4px 8px 4px 12px;
  margin-top: 8px;
  font-size: 11px;
  color: #888;
}
.code-header + pre {
  border-radius: 0 0 8px 8px !important;
  border-top: none !important;
  margin-top: 0 !important;
}
.code-lang {
  font-family: "SF Mono", Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.code-header-actions { display: flex; gap: 2px; }
.code-action-btn {
  background: transparent;
  border: none;
  color: #888;
  cursor: pointer;
  width: 26px; height: 26px;
  border-radius: 4px;
  font-size: 14px;
}
.code-action-btn:hover { background: #2a2f3d; color: #fff; }
/* === HTML preview block === */
.code-block-html {
  background: #0d0f14;
  border: 1px solid #232734;
  border-radius: 8px;
  margin: 8px 0;
  overflow: hidden;
  max-width: 100%;
}
.code-block-tabs {
  display: flex;
  align-items: center;
  background: #0a0c11;
  padding: 4px 6px;
  gap: 4px;
  border-bottom: 1px solid #232734;
}
.code-tab {
  background: transparent;
  border: none;
  color: #888;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
}
.code-tab:hover { background: #1a1d28; color: #ccc; }
.code-tab-active { background: #4a9eff; color: #fff; }
.code-block-actions { margin-left: auto; display: flex; gap: 2px; }
.code-preview-box { background: #fff; min-height: 240px; max-height: 60vh; overflow: hidden; }
.code-preview-box iframe { width: 100%; height: 60vh; min-height: 240px; border: none; background: #fff; }
.code-raw-box pre { margin: 0 !important; border-radius: 0 !important; border: none !important; }
/* === Code fullscreen === */
.code-fullscreen { z-index: 1001; }
.lib-viewer pre {
  background: #0d0f14;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 13px;
}
.lib-viewer code { background: #0d0f14; padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.lib-viewer table { border-collapse: collapse; margin: 8px 0; }
/* === Attachments bar (preview before send) === */
.attachments-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 12px;
  background: #161922;
  border-top: 1px solid #232734;
}
/* Кнопка подгрузки старых сообщений (виртуализация чата) */
.load-prev-btn {
  display: block;
  margin: 8px auto 12px;
  padding: 8px 16px;
  background: #2a2a2e;
  color: #cfcfd4;
  border: 1px solid #3a3a40;
  border-radius: 18px;
  font-size: 13px;
  cursor: pointer;
  opacity: 0.85;
}
.load-prev-btn:active { background: #34343a; }