/* === Extracted from new.css === */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

input:focus, textarea:focus {
  outline: none;
  border-color: #c8ddec;
  box-shadow: 0 0 0 2px rgba(200, 221, 236, 0.4);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(100%);
  background-color: #ccc;
  color: #777;
  border-color: #bbb;
}

:root {
  --font-base: "Inter", sans-serif;
  --color-text-light: #222;
  --color-bg-light: #fff;
  --color-text-dark: #eee;
  --color-bg-dark: #121212;
  --max-width: 1600px;
}

.chat-shell {
  height: 100%;
  min-height: 0;
}

.chat-body {
  min-height: 0;
}

.editor {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.sidebar-toggle {
  width: 38px;
  height: 38px;
  border: 1px solid #e6edf5;
  background: #ffffff;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(16,24,40,.08);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  overflow: visible;
}

.sidebar-toggle-ico {
  transition: transform .18s ease;
  transform-origin: 50% 50%;
}

/* ===== default sidebar ===== */
.sidebar {
  flex: 0 0 260px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-self: stretch;
  height: 100%;
}

/* ===== toggle button ===== */
.sidebar-toggle{
  width: 38px;
  height: 38px;
  border: 1px solid #e6edf5;
  background: #ffffff;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(16,24,40,.08);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.sidebar-toggle-ico{
  transition: transform .18s ease;
  transform-origin: 50% 50%;
}

/* Desktop: < > */
@media (min-width: 769px){
  body:not(.is-sidebar-collapsed) .sidebar-toggle-ico{ transform: rotate(180deg); } /* "<" */
  body.is-sidebar-collapsed .sidebar-toggle-ico{ transform: rotate(0deg); }        /* ">" */
}

/* Mobile: ^ v */
@media (max-width: 768px){
  body:not(.is-sidebar-collapsed) .sidebar-toggle-ico{ transform: rotate(-90deg); } /* "^" */
  body.is-sidebar-collapsed .sidebar-toggle-ico{ transform: rotate(90deg); }       /* "v" */
}

/* ===== collapsed state (slim rail) ===== */

/* опционально, под твой layout */
body.is-sidebar-collapsed .content{ margin-left: 0; }
body.is-sidebar-collapsed #appLayout{ gap: .75rem; }

/* скрываем историю */
body.is-sidebar-collapsed .sidebar .history{ display: none; }

/* кнопки превращаем в “иконки” */
body.is-sidebar-collapsed .sidebar .btn{
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0 10px;
  justify-content: center;
  background-position: center !important;
  border-radius: 14px;
  font-size: 0;
  line-height: 0;
}
body.is-sidebar-collapsed .sidebar .btn::before{
  content: attr(data-ico);
  font-size: 13px;
  line-height: 1;
  color: #fff;
  font-weight: 700;
  letter-spacing: .2px;
}

:root{
  --app-sidebar-open: 260px;
  --app-sidebar-collapsed: 64px;
}

#appLayout > .sidebar{
  flex: 0 0 var(--app-sidebar-open);
  min-width: var(--app-sidebar-open);
}
body.is-sidebar-collapsed #appLayout > .sidebar{
  flex: 0 0 var(--app-sidebar-collapsed);
  width: var(--app-sidebar-collapsed);
  min-width: var(--app-sidebar-collapsed);
}


@media (min-width: 769px) {
  body:not(.is-sidebar-collapsed) .sidebar-toggle-ico {
    transform: rotate(180deg);
  }

  body.is-sidebar-collapsed .sidebar-toggle-ico {
    transform: rotate(0deg);
  }
}

@media (max-width: 768px) {
  body:not(.is-sidebar-collapsed) .sidebar-toggle-ico {
    transform: rotate(-90deg);
  }

  body.is-sidebar-collapsed .sidebar-toggle-ico {
    transform: rotate(90deg);
  }
}

.sidebar-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(16,24,40,.10);
  border-color: #dbe6f2;
}

.sidebar-toggle svg {
  width: 20px;
  height: 20px;
}

body.is-sidebar-collapsed .sidebar {
  flex: 0 0 64px;
  width: 64px;
  min-width: 64px;
  padding-right: 0;
}

body.is-sidebar-collapsed .content {
  margin-left: 0;
}

body.is-sidebar-collapsed #appLayout {
  gap: .75rem;
}

body.is-sidebar-collapsed .sidebar .history {
  display: none;
}

body.is-sidebar-collapsed .sidebar .btn {
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0 10px;
  justify-content: center;
  background-position: center !important;
  border-radius: 14px;
  font-size: 0;
  line-height: 0;
}

body.is-sidebar-collapsed .sidebar .btn::before {
  content: attr(data-ico);
  font-size: 13px;
  line-height: 1;
  color: #fff;
  font-weight: 700;
  letter-spacing: .2px;
}

/* ===== Кнопка «Новый чат» ===== */
.btn-new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 14px;
  border-radius: 12px;
  border: 1.5px dashed #aecde8;
  background: transparent;
  color: #1b7db7;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
  box-sizing: border-box;
}

.btn-new-chat:hover {
  background: #e6f3fb;
  border-color: #1b7db7;
  color: #145e8e;
  filter: none;
}

.btn-new-chat::after { display: none; }

.btn-new-chat__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-new-chat__label {
  flex: 1;
}

/* Свёрнутый сайдбар: только иконка */
body.is-sidebar-collapsed .sidebar .btn-new-chat {
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0 10px;
  justify-content: center;
  border-radius: 14px;
  border-style: dashed;
}

body.is-sidebar-collapsed .sidebar .btn-new-chat__label {
  display: none;
}

[data-theme="dark"] .btn-new-chat {
  border-color: #2a4a6a;
  color: #6ab4e8;
}

[data-theme="dark"] .btn-new-chat:hover {
  background: #1a3046;
  border-color: #6ab4e8;
  color: #8fc8f0;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

input:focus, textarea:focus {
  outline: none;
  border-color: #c8ddec;
  box-shadow: 0 0 0 2px rgba(200,221,236,.4);
}

button:disabled {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(100%);
  background: #ccc;
  color: #777;
  border-color: #bbb;
}

:root {
  --font-base: "Inter",sans-serif;
  --color-text-light: #222;
  --color-bg-light: #fff;
  --color-text-dark: #eee;
  --color-bg-dark: #121212;
}

body {
  font-family: Calibri, system-ui, sans-serif;
  background: var(--color-bg-light);
  color: var(--color-text-light);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-size: 18px;
  font-weight: light;
}

[data-theme="dark"] body {
  background: var(--color-bg-dark);
  color: var(--color-text-dark);
}

[data-theme="light"] body {
  background: var(--color-bg-light);
  color: var(--color-text-light);
}

:root {
  --bg: #f6fbff;
  --panel: #ffffff;
  --card: #ffffff;
  --ink: #1c2b3a;
  --text: #1c2b3a;
  --muted: #6f8194;
  --line: #e6eef5;
  --line-2: #dbe6f2;
  --field: #f6fbff;
  --field-line: #d9e8f6;
  --accent: #1c88c7;
  --accent-2: #8fd1ff;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 14px;
  --container: 1260px;
  --shadow: 0 10px 30px rgba(16,24,40,.10);
  --shadow-soft: 0 1px 0 rgba(0,0,0,.03);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --focus: rgba(28,136,199,.25);
}

*,*::before,*::after {
  box-sizing: border-box;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

.topbar-inner {
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
}

.tabs {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0;
  color: var(--muted);
  user-select: none;
}

.tab {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 5px 0;
  color: inherit;
  text-decoration: none;
  position: relative;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}

.topbar-inner .tab::after,
.topbar-inner a::after {
  display: none;
}

.tab svg {
  width: 26px;
  height: 26px;
  stroke: #85b9dd;
  transition: stroke .15s ease;
}

.tab span {
  position: relative;
  padding-bottom: 0px;
}

.tab span::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 999px;
  opacity: 0;
  transform: scaleX(.65);
  transform-origin: 50% 50%;
  transition: opacity .15s ease, transform .15s ease;
}

.tab:hover span::after,
.tab:focus-visible span::after {
  opacity: .45;
  transform: scaleX(1);
}

.tab.is-active {
  color: var(--accent);
  background: rgba(28,136,199,.10);
  border-radius: 14px;
}

.tabs .select--tab {
  flex: 1 1 0;
  min-width: 0;
}

.select--tab .select-btn {
  border: 0;
  background: transparent;
  padding: 10px 0;
  border-radius: 14px;
  justify-content: center;
  gap: 10px;
  color: inherit;
  cursor: pointer;
}

.select--tab .select-btn:hover {
  background: rgba(28,136,199,.06);
}

.select--tab.is-open .select-btn {
  color: var(--accent);
  background: rgba(28,136,199,.10);
}

.tab svg.caret {
  width: 16px;
  height: 16px;
  stroke: #85b9dd;
  flex: 0 0 auto;
}

.select--tab.is-open .tab svg.caret {
  transform: rotate(180deg);
}

.select--tab .select-menu {
  left: auto;
  right: 0;
  width: 240px;
  max-width: calc(100vw - 24px);
}

.menu-item--ico {
  display: flex;
  align-items: center;
  gap: 10px;
}

.menu-item--ico .mi-ico {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.menu-item--ico .mi-ico svg {
  width: 18px;
  height: 18px;
  stroke: #5d6b7b;
}

.select--tab .menu-item.is-active {
  background: #eef5fb;
}

.divider {
  height: 1px;
  background: var(--line);
  margin-top: 10px;
}

.editor {
  background: var(--panel);
  display: flex;
  gap: 20px;
  flex: 1 1 auto;
}

.prompt .send {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f2f7fb;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.prompt .send svg {
  width: 18px;
  height: 18px;
  stroke: #8aa3bb;
}

.prompt .send:hover {
  background: #eaf3fb;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 30%;
}

.menu-head {
  font-weight: 700;
  color: #44576d;
  padding: 6px 8px;
  margin: 2px 0 6px;
}

.menu-group {
  padding-bottom: 6px;
  margin-bottom: 6px;
}

.menu-group + .menu-group {
  border-top: 1px solid rgba(0,0,0,.04);
  padding-top: 8px;
}

.menu-item {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 10px 10px;
  border-radius: 10px;
  cursor: pointer;
  color: #2c3a4a;
}

.menu-item:hover {
  background: #eef5fb;
}

.dropdown-scroll::-webkit-scrollbar {
  width: 10px;
}

.dropdown-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.dropdown-scroll::-webkit-scrollbar-thumb {
  background: rgba(55,65,81,.18);
  border-radius: 999px;
  border: 3px solid #f7f7f7;
}

.select {
  position: relative;
  user-select: none;
}

.select-btn {
  width: -webkit-fill-available;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px;
  margin: 0px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f6f7f9;
  color: #2c3a4a;
  cursor: pointer;
}

.select-btn svg {
  width: 18px;
  height: 18px;
  stroke: #5d6b7b;
  transition: transform .15s ease;
}

.select.is-open .select-btn svg {
  transform: rotate(180deg);
}

.select-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 10px);
  background: #f7f7f7;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px;
  max-height: 290px;
  overflow: auto;
  display: none;
  z-index: 20;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.select.is-open .select-menu {
  display: block;
}

.fselect {
  position: relative;
}

.fselect-btn {
  width: 100%;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--field-line);
  background: var(--field);
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #2c3a4a;
  cursor: pointer;
}

.fselect-btn .value {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.fselect-btn svg {
  width: 18px;
  height: 18px;
  stroke: #5d6b7b;
  flex: 0 0 auto;
  transition: transform .15s ease;
}

.fselect.is-open .fselect-btn svg {
  transform: rotate(180deg);
}

.fselect-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 10px);
  background: #f7f7f7;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px;
  max-height: 240px;
  overflow: auto;
  display: none;
  z-index: 25;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.fselect.is-open .fselect-menu {
  display: block;
}

.card-accordion {
  padding: 0;
}

.card-accordion > summary {
  list-style: none;
  cursor: pointer;
}

.card-accordion > summary::-webkit-details-marker {
  display: none;
}

.card-head {
  padding: 18px 16px;
  border-bottom: 1px solid var(--line);
  color: #2c7387;
  font-size: 16px;
  letter-spacing: .2px;
  position: relative;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
}

.card-accordion:not([open]) .card-head {
  border-bottom: 0;
}

.card-title {
  display: block;
  font-size: 18px;
  line-height: 1.15;
}

.card-head .acc-ind {
  position: static;
  transform: none;
  opacity: .35;
  pointer-events: none;
  flex: 0 0 auto;
}

.card-head .acc-chev {
  width: 26px;
  height: 26px;
  stroke: var(--accent);
  transform-origin: 50% 50%;
  transition: transform .18s ease;
}

.card-accordion[open] .card-head .acc-chev {
  transform: rotate(180deg);
}

.form {
  padding: 18px 16px 16px;
}

.field {
  margin: 14px 0 0;
}

.label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: #2c3a4a;
  margin-bottom: 10px;
}

.info {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--field-line);
  background: #f5fbff;
  color: #5a7e9c;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  line-height: 1;
  cursor: help;
  position: relative;
  padding: 0;
}

.has-tip {
  position: relative;
}

.tooltip {
  position: absolute;
  left: -6px;
  top: 36px;
  width: 325px;
  background: #f7f7f7;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px;
  z-index: 30;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}

.has-tip:hover .tooltip,
.has-tip:focus-within .tooltip {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.tooltip .t {
  font-weight: 800;
  color: #6b7a8c;
  margin-bottom: 8px;
}

.tooltip .p {
  font-size: 12.5px;
  color: #7b8a9c;
  line-height: 1.35;
}

.text {
  width: 100%;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--field-line);
  background: var(--field);
  padding: 10px 12px;
  outline: none;
  color: #2c3a4a;
}

.text::placeholder {
  color: #9aaac0;
}

.text[readonly] {
  color: #2c3a4a;
}

.hint {
  font-size: 12px;
  color: #9aaac0;
  margin-top: 8px;
}

.upload {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.upload .upl {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--field-line);
  background: #f5fbff;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
}

.upload .upl svg {
  width: 20px;
  height: 20px;
  stroke: #5a7e9c;
}

.upload .upl:hover {
  background: #e9f5ff;
}

.segmented {
  display: flex;
  gap: 0;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--field-line);
  background: #f5fbff;
  width: fit-content;
  min-width: 160px;
  max-width: 100%;
}

.segmented button {
  flex: 1 1 0;
  min-width: 70px;
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: #86a9c6;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.segmented button.is-active {
  background: #ffffff;
  color: #5a7e9c;
  box-shadow: 0 1px 0 rgba(16,24,40,.06);
}

.editor .range {
  width: 100%;
  padding: 2px 0;
}

.editor .range-input {
  width: 100%;
  height: 30px;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  --p: 50%;
}

.editor .range-input:focus {
  outline: none;
}

.editor .range-input::-webkit-slider-runnable-track {
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(to right,
    rgba(153,188,207,.55) 0%,
    rgba(153,188,207,.55) var(--p),
    rgba(234,244,251,1) var(--p),
    rgba(234,244,251,1) 100%
  );
}

.editor .range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -4px;
  border-radius: 999px;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 10px rgba(11,38,56,.16), 0 0 0 4px rgba(28,136,199,.12);
  cursor: pointer;
}

.editor .range-input::-moz-range-track {
  height: 14px;
  border-radius: 999px;
  background: rgba(234,244,251,1);
}

.editor .range-input::-moz-range-progress {
  height: 14px;
  border-radius: 999px;
  background: rgba(153,188,207,.55);
}

.editor .range-input::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #ffffff;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 10px rgba(11,38,56,.16), 0 0 0 4px rgba(28,136,199,.12);
  cursor: pointer;
}

.editor input[type="range"]:not(.range-input)::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -7px;
  border-radius: 999px;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 10px rgba(11,38,56,.16), 0 0 0 4px rgba(28,136,199,.12);
  cursor: pointer;
}

.editor input[type="range"]:not(.range-input)::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 10px rgba(11,38,56,.16), 0 0 0 4px rgba(28,136,199,.12);
  cursor: pointer;
}

.editor .range-input:disabled {
  opacity: .7;
  cursor: not-allowed;
}

.editor .range-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-right: calc(72px + 12px);
  color: #2c3a4a;
}

.editor .range-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.editor .range-row .range {
  flex: 1 1 auto;
}

.editor.range-out {
  width: 72px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--field-line);
  background: #fff;
  padding: 0 10px;
  font-weight: 700;
  text-align: center;
  color: #2c3a4a;
}

.editor .range-out:focus {
  outline: none;
}

.pop {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.pop-menu[hidden] {
  display: none !important;
}

.pop-menu {
  position: absolute;
  top: auto;
  bottom: calc(100% + 10px);
  right: 0;
  z-index: 50;
  min-width: 220px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(16,24,40,.14);
}

.share-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.share-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  color: #2c3a4a;
  text-decoration: none;
  font-weight: 600;
}

.share-item:hover {
  background: #f5fbff;
}

.share-ico {
  width: 18px;
  height: 18px;
  display: inline-flex;
  color: #1b7db7;
}

.share-ico svg {
  width: 18px;
  height: 18px;
}

.share-text {
  white-space: nowrap;
}

.chat-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: var(--chat-linked-minh, 0px);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.2rem 1rem;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.chat-title {
  font-weight: 600;
  color: #1b7db7;
  letter-spacing: .2px;
  cursor: pointer;
  border-radius: 6px;
  padding: 3px 6px;
  margin-left: -6px;
  transition: background .15s ease;
  max-width: 340px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  outline: none;
  user-select: none;
}

.chat-title:hover {
  background: #eef6fc;
}

.chat-title--editing {
  cursor: text;
  background: #eef6fc;
  box-shadow: 0 0 0 2px rgba(27, 125, 183, .3);
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
  user-select: text;
}

[data-theme="dark"] .chat-title { color: #6ab4e8; }
[data-theme="dark"] .chat-title:hover { background: #1e3346; }
[data-theme="dark"] .chat-title--editing { background: #1e3346; box-shadow: 0 0 0 2px rgba(106, 180, 232, .3); }

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
}

.btn-link:hover {
  background: #f3f7fb;
  color: #2a3c4f;
}

.chat-body {
  padding: 18px 16px 12px;
  flex: 0 0 auto;
  overflow-y: scroll !important;
  background: #fff;
}

.msg-row {
  display: flex;
  align-items: flex-start;
  margin: 0;
  gap: 12px;
}

.msg-row.left {
  justify-content: flex-start;
}

.msg-row.right {
  justify-content: flex-end;
}

.msg-row.center {
  justify-content: center;
}

.msg-row.left .msg {
  margin-right: auto;
}

.msg-row.right .msg {
  margin-left: auto;
}

.msg-row.center .msg {
  margin-left: auto;
  margin-right: auto;
}

.msg {
  max-width: 680px;
  width: fit-content;
  position: relative;
}

.bubble {
  display: inline-block;
  background: #f2f5f8;
  border-radius: var(--radius);
  padding: 10px 14px;
  line-height: 1.35;
  color: var(--text);
}

.bubble ul {
  display: block;
  list-style: disc;
  margin: 1em 0;
  padding-left: 40px;
}

.bubble.center {
  background: #eef3f7;
  border-radius: 12px;
}

.msg-row.left .bubble {
  border-top-left-radius: 8px;
  background: transparent;
}

.msg-row.right .bubble {
  border-top-right-radius: 8px;
  background: var(--mt-blue-2, #e8f4f8);
  color: #194e60;
}

.plain {
  padding: 2px 0;
  line-height: 1.35;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  align-items: center;
}

.actions.right {
  justify-content: flex-end;
}

.icon-btn {
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #5f7287;
  opacity: .95;
}

.icon-btn:hover {
  color: #25384c;
}

.icon {
  width: 18px;
  height: 18px;
  display: block;
}

.msg--user .actions {
  opacity: 0;
  transform: translateY(-2px);
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}

.msg--user:hover .actions {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.msg--agent .actions {
  opacity: 1;
  pointer-events: auto;
}

.media {
  margin-top: 10px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}

.media img {
  display: block;
  width: 100%;
  height: auto;
}

.media-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 10px 0 2px;
  margin-bottom: 4px;
}

.media-actions .icon-btn {
  opacity: 1;
}

pre > code.hljs,
pre > code:not(.hljs) {
  display: block;
  padding: var(--code-pad-y) var(--code-pad-x);
  padding-left: calc(var(--code-pad-x) + var(--code-gutter-w));
  font-family: var(--mono);
  font-size: var(--code-font-size);
  line-height: var(--code-line-h);
  white-space: pre;
  min-width: max-content;
  overflow: visible;
}

.hljs {
  background: transparent;
}

.line-numbers-rows {
  position: absolute;
  top: var(--code-pad-y);
  left: 0;
  width: auto;
  padding: 0 10px;
  text-align: center;
  font-family: var(--mono);
  font-size: var(--code-font-size);
  line-height: var(--code-line-h);
  color: #7f93a7;
  user-select: none;
  pointer-events: none;
  background: #f7fbff;
  border-right: 1px solid var(--line);
  bottom: 0;
}

.line-numbers-rows span {
  display: block;
}

.code-toolbar {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 8px;
  z-index: 3;
}

.code-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: #4b6076;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
}

.code-btn:hover {
  background: #f3f7fb;
  color: #213447;
}

.pill {
  border: 1px solid var(--line);
  background: #fff;
  color: #4b6076;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pill:hover {
  background: #f3f7fb;
  color: #213447;
}

.chat-footer {
  padding: 14px 16px 16px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.composer {
  display: flex;
  gap: 10px;
  align-items: center;
  border: 1px solid #d3e5f5;
  border-radius: 10px;
  padding: 10px 10px;
  box-shadow: black;
  background: #fbfbfb;
  -webkit-box-shadow: 4px 4px 12px -8px rgba(34, 60, 80, 0.2);
  -moz-box-shadow: 4px 4px 12px -8px rgba(34, 60, 80, 0.2);
  box-shadow: 4px 4px 12px -8px rgba(34, 60, 80, 0.2);
}

.composer input {
  border: 0;
  outline: 0;
  flex: 1;
  padding: 6px 4px;
  background: #fbfbfb;
}

.composer .send {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  background: #f6f9fc;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4b6076;
}

.composer .send:hover {
  background: #eef4fa;
  color: #203246;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: #142536;
  color: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

.toast.show {
  opacity: .92;
}

/* Поверх чата / сайдбара при копировании и т.д. */
.chat-actions-toast {
  z-index: 10050;
}

.bubble :not(pre) > code {
  font-family: var(--mono);
  font-size: .95em;
  background: #fff;
  border: 1px solid var(--line);
  padding: 2px 6px;
  border-radius: 8px;
  color: #25384c;
}

.bubble a {
  color: var(--accent);
  text-decoration: none;
}

.bubble a:hover {
  text-decoration: underline;
}

pre code.hljs {
  display: block;
  overflow-x: auto;
  padding: 1em;
  margin-left: 3rem;
}

:root {
  --app-sidebar-open: 260px;
  --app-sidebar-collapsed: 64px;
  --app-gap: 0.75rem;
  --app-gap-collapsed: 0.5rem;
  --app-right-col: 27.5%;
  --app-right-col-min: 360px;
  --app-editor-gap: 1rem;
}

body.is-sidebar-collapsed #appLayout {
  gap: var(--app-gap-collapsed);
}

body.is-sidebar-collapsed #appLayout > .sidebar {
  flex: 0 0 var(--app-sidebar-collapsed);
  width: var(--app-sidebar-collapsed);
  min-width: var(--app-sidebar-collapsed);
}

.editor {
  flex-wrap: nowrap;
  gap: var(--app-editor-gap);
}

.editor > .chat-shell {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
}

.editor > .side {
  flex: 0 0 var(--app-right-col);
  width: var(--app-right-col);
  max-width: var(--app-right-col);
  min-width: var(--app-right-col-min);
}

.quick-settings {
  padding-top: 14px;
  padding-bottom: 0;
}

.quick-settings .field:first-child {
  margin-top: 0;
}

.bubble,
.plain {
  overflow-wrap: anywhere;
  word-break: break-word;
}

pre code.hljs {
  margin-left: 10;
}


/* === Extracted from style-responsive.css === */

@media (max-width: 768px) {
  .editor {
    flex-direction: column;
  }

  .editor > .chat-shell {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
  }

  .editor > .side {
    flex: 0 0 auto;
    width: 100%;
    max-width: none;
    min-width: 0;
    margin: 0;
  }

  body.is-sidebar-collapsed #appLayout > .sidebar {
    width: 100%;
    min-width: 0;
  }

  .side {
    width: 100%;
    max-width: none;
    min-width: 0;
    margin: 0 0;
  }

  .tabs {
    gap: 10px;
  }

  .tab {
    flex-direction: column;
  }

  body.is-sidebar-collapsed .sidebar {
    flex: auto;
    width: 100%;
    display: flex;
    flex-direction: row;
    min-width: 84px;
    padding-right: 0;
  }

  body {
    font-size: 16px;
  }
}


/* контейнер, где sidebar + content рядом */
.flex { display: flex; gap: 16px; align-items: stretch; }

/* сайдбар по умолчанию */
.sidebar { flex: 0 0 260px; width: 260px; }

/* свернутый сайдбар */
body.is-sidebar-collapsed .sidebar {
  flex: 0 0 64px;
  width: 64px;
}

/* прячем историю в свернутом виде */
body.is-sidebar-collapsed .sidebar .history { display: none; }

pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!
  Theme: GitHub
  Description: Light theme as seen on github.com
  Author: github.com
  Maintainer: @Hirse
  Updated: 2021-05-15

  Outdated base version: https://github.com/primer/github-syntax-light
  Current colors taken from GitHub's CSS
*/.hljs{color:#24292e;background:#fff}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#d73a49}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#6f42c1}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#005cc5}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#032f62}.hljs-built_in,.hljs-symbol{color:#e36209}.hljs-code,.hljs-comment,.hljs-formula{color:#6a737d}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#22863a}.hljs-subst{color:#24292e}.hljs-section{color:#005cc5;font-weight:700}.hljs-bullet{color:#735c0f}.hljs-emphasis{color:#24292e;font-style:italic}.hljs-strong{color:#24292e;font-weight:700}.hljs-addition{color:#22863a;background-color:#f0fff4}.hljs-deletion{color:#b31d28;background-color:#ffeef0}

/* фиксы */

.line-numbers-rows {
    position: absolute;
    top: var(--code-pad-y);
    /* left: 0; */
    width: auto;
    padding: 1rem 10px;
    font-size: 16px;
    text-align: center;
    font-family: var(--mono);
    /* font-size: var(--code-font-size); */
    line-height: var(--code-line-h);
    color: #7f93a7;
    user-select: none;
    pointer-events: none;
    background: #f7fbff;
    border-right: 1px solid var(--line);
    /* bottom: 0; */
}

pre code.hljs {
    display: block;
    overflow-x: auto;
    padding: 1em;
    font-size: 16px;
}

.container, .breadcrumb-row {
    max-width: 1600px;
    margin: 0 auto;
	width: 100%;
    padding: 0 1rem;
}

 .sidebar {
    flex: 0 0 var(--app-sidebar-open);
    min-width: var(--app-sidebar-open);
}

/* Code blocks */
pre{
  /* Адаптивные отступы/гаттер, чтобы код-блок не выглядел «перепрошитым»
     на узких ширинах и сохранял читаемость */
  --code-pad-y: 12px;
  --code-pad-x: clamp(10px, 1.6vw, 14px);
  --code-gutter-w: clamp(38px, 6vw, 54px);
  --code-line-h: 1.45;
  --code-font-size: clamp(12px, 1.2vw, 13px);

  margin: 10px 0;
  border-radius:12px;
  border:1px solid var(--line);
  overflow:auto;
  position:relative;
  background:#fbfdff;
}

pre > code.hljs,
pre > code:not(.hljs){
  display:block;
  padding: var(--code-pad-y) var(--code-pad-x);
  padding-left: calc(var(--code-pad-x) + var(--code-gutter-w));
  font-family: var(--mono);
  font-size: var(--code-font-size);
  line-height: var(--code-line-h);
  white-space: pre;
  min-width: max-content;
  overflow: visible;
}

pre > code, pre > code *{ line-height: inherit; }
.hljs{ background: transparent; }

.line-numbers-rows {
    position: absolute;
    top: var(--code-pad-y);
    left: 0;
    width: auto;
    padding: 0 10px;
    text-align: center;
    font-family: var(--mono);
    font-size: var(--code-font-size);
    line-height: var(--code-line-h);
    color: #7f93a7;
    user-select: none;
    pointer-events: none;
    background: #f7fbff;
    border-right: 1px solid var(--line);
    bottom: 0;
}
.line-numbers-rows span{ display:block; }

.code-toolbar{
  position:absolute;
  top:10px;
  right:10px;
  display:flex;
  gap:8px;
  z-index:3;
}

.code-btn{
  width:34px;
  height:34px;
  border-radius:10px;
  border:1px solid var(--line);
  background:#fff;
  color:#4b6076;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
}
.code-btn:hover{ background:#f3f7fb; color:#213447; }

.pill{
  border:1px solid var(--line);
  background:#fff;
  color:#4b6076;
  border-radius:10px;
  padding:6px 10px;
  font-size:12px;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:6px;
}
.pill:hover{ background:#f3f7fb; color:#213447; }

/* Composer */
.chat-footer{
  padding: 14px 16px 16px;
  border-top:1px solid var(--line);
  background:#fff;
}
.composer{
  display:flex;
  gap:10px;
  align-items:center;
  border:1px solid var(--line);
  border-radius:10px;
  padding:10px 10px;
  background:#fff;
}
.composer input{
  border:0;
  outline:0;
  flex:1;
  padding:6px 4px;
}

.composer .send{
  width:34px;
  height:34px;
  border:1px solid var(--line);
  background:#f6f9fc;
  border-radius:8px;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  color:#4b6076;
}
.composer .send:hover{ background:#eef4fa; color:#203246; }

/* Toast */
.toast{
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background:#142536;
  color:#fff;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  opacity:0;
  pointer-events:none;
  transition: opacity .18s ease;
}
.toast.show{ opacity: .92; }

/* Inline code */
.bubble :not(pre) > code{
  font-family: var(--mono);
  font-size: .95em;
  background:#fff;
  border:1px solid var(--line);
  padding:2px 6px;
  border-radius: 8px;
  color:#25384c;
}
.bubble a{ color: var(--accent); text-decoration:none; }
.bubble a:hover{ text-decoration: underline; }



pre code.hljs {
    display: block;
    overflow-x: auto;
    padding: 1em;
    margin-left: 3rem;
}

/* Правки пхп версии*/

.models {
    margin-top: 1rem;
}

.editor .menu-item::before {
    display: none;
}


/* Additional settings: accordion wrapper */
.settings-accordion {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  background: rgba(255,255,255,.04);
  overflow: hidden;
}

.settings-accordion > summary {
  list-style: none;
}

.settings-accordion > summary::-webkit-details-marker {
  display: none;
}

.settings-accordion .card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0px;
  cursor: pointer;
  background: none;
  border: none;
}

.settings-accordion .card-title {
  font-weight: 600;
}

.settings-accordion .toggle-icon {
  opacity: .8;
  font-size: 14px;
  line-height: 1;
}

.settings-accordion:not([open]) #additional-settings {
  display: none;
}

.settings-accordion[open] .toggle-icon {
  opacity: 1;
}

/* Server params -> our "fields" look */
#additional-settings {
 
}

#additional-settings .parameter-group {
  display: grid;
  gap: 8px;
  padding: 0px;
  border-top: 1px solid rgba(255,255,255,.08);
}

#additional-settings .parameter-group:first-child {
  border-top: 0;
  padding-top: 0;
}

#additional-settings .parameter-label-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#additional-settings .parameter-label-container label {
  font-size: 13px;
  opacity: .9;
}

#additional-settings .parameter-help-icon {
  width: 26px;
  height: 26px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  color: inherit;
  cursor: pointer;
}

/* Inputs unified */
#additional-settings .parameter-input {
  width: 100%;
  box-sizing: border-box;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.18);
  color: inherit;
  padding: 10px 12px;
  outline: none;
}

#additional-settings textarea.parameter-input {
  min-height: 90px;
  resize: vertical;
}

#additional-settings select.parameter-input {
  appearance: none;
}

/* Checkbox a bit nicer */
#additional-settings input[type="checkbox"].parameter-input {
  width: 18px;
  height: 18px;
  padding: 0;
  display: inline-block;
  justify-self: start;
  
    border-radius: 10px !important;
    border: 1px solid var(--field-line) !important;
    background: var(--field) !important;
}

/* layout */
.chat-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
  min-height: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0.2rem 1rem;
}

.chat-body {
  overflow: auto;
  min-height: 0;
  padding: 12px 14px;
}

.chat-footer {
  padding: 10px 14px 14px;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.composer .chat-textarea {
  flex: 1;
  min-height: 42px;
  max-height: 160px;
  resize: none;
}

.send.submit-button_v4 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
}

.send .icon {
  width: 20px;
  height: 20px;
}

/* 1) Растягиваем страницу/контейнер на высоту окна */

/* 2) Секция AI Studio как колонка: topbar сверху, main занимает остаток */
section.content.ai-studio{
  /*min-height: 100vh;
  min-height: 100dvh;  мобильные браузеры */
  display: flex;
  flex-direction: column;
}

/* 3) Основная область должна занять остаток высоты */
section.content.ai-studio .ai-studio-main{
  flex: 1 1 auto;
  min-height: 0; /* критично, иначе flex-дети не смогут нормально скроллиться */
}

/* 4) Чат - колонка на всю высоту main */
.chat-shell.chat-area{
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* 5) Тело чата забирает всё свободное место и скроллится */
.chat-shell #chatBody,
.chat-shell .chat-body{
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

/* 6) Футер уходит вниз */
.chat-shell .chat-footer{
  flex: 0 0 auto;
  margin-top: auto;
}

/* (опционально) чтобы футер выглядел как “прибитый” и не прилипал к контенту */
.chat-shell .chat-footer{
  background: inherit;
}

/* ── Чат: авто-увеличение при генерации (п.2 pravki-4gen-mart) ─────────
   idle: компактно, на первом экране
   generating/expanded: окно РАСТЁТ с контентом до лимита, потом scroll
   Лимиты зависят от устройства: ноут/десктоп — шире, мобилка/свёрнутый сайдбар — компактнее
   ───────────────────────────────────────────────────────────────────── */
.chat-shell[data-state="idle"] {
  height: auto;
  max-height: clamp(200px, 35vh, 280px);
  min-height: 120px;
  align-self: flex-start;
  transition: max-height 0.35s ease, min-height 0.35s ease;
}

/* Базовые значения (переопределяются media и sidebar) */
.chat-shell[data-state="generating"],
.chat-shell[data-state="expanded"] {
  height: auto;
  max-height: clamp(450px, 75vh, 750px);
  min-height: 140px;
  align-self: flex-start;
  transition: max-height 0.35s ease, min-height 0.35s ease;
}

.chat-shell[data-state="generating"] #chatBody,
.chat-shell[data-state="generating"] .chat-body,
.chat-shell[data-state="expanded"] #chatBody,
.chat-shell[data-state="expanded"] .chat-body {
  flex: 0 1 auto;
  min-height: 80px;
  max-height: clamp(350px, 65vh, 650px);
  overflow-y: auto;
}

/* Десктоп/ноутбук (≥1025px): почти весь экран */
@media (min-width: 1025px) {
  .chat-shell[data-state="generating"],
  .chat-shell[data-state="expanded"] {
    max-height: clamp(500px, 88vh, 920px);
  }

  .chat-shell[data-state="generating"] #chatBody,
  .chat-shell[data-state="generating"] .chat-body,
  .chat-shell[data-state="expanded"] #chatBody,
  .chat-shell[data-state="expanded"] .chat-body {
    max-height: clamp(400px, 82vh, 800px);
  }
}

/* Планшет / узкий ноутбук (769–1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .chat-shell[data-state="generating"],
  .chat-shell[data-state="expanded"] {
    max-height: clamp(450px, 80vh, 700px);
  }

  .chat-shell[data-state="generating"] #chatBody,
  .chat-shell[data-state="generating"] .chat-body,
  .chat-shell[data-state="expanded"] #chatBody,
  .chat-shell[data-state="expanded"] .chat-body {
    max-height: clamp(350px, 72vh, 600px);
  }
}

/* Свёрнутый сайдбар: компактнее */
body.is-sidebar-collapsed .chat-shell[data-state="generating"],
body.is-sidebar-collapsed .chat-shell[data-state="expanded"] {
  max-height: clamp(420px, 72vh, 600px) !important;
}

body.is-sidebar-collapsed .chat-shell[data-state="generating"] #chatBody,
body.is-sidebar-collapsed .chat-shell[data-state="generating"] .chat-body,
body.is-sidebar-collapsed .chat-shell[data-state="expanded"] #chatBody,
body.is-sidebar-collapsed .chat-shell[data-state="expanded"] .chat-body {
  max-height: clamp(350px, 65vh, 500px) !important;
}

.chat-shell[data-state="idle"] #chatBody,
.chat-shell[data-state="idle"] .chat-body {
  min-height: 0;
  max-height: none;
}

/* Мобильные (≤768px): компактнее */
@media (max-width: 768px) {
  .chat-shell[data-state="idle"] {
    max-height: clamp(140px, 28vh, 220px);
    min-height: 100px;
  }

  .chat-shell[data-state="generating"],
  .chat-shell[data-state="expanded"] {
    max-height: clamp(380px, 70vh, 550px);
  }

  .chat-shell[data-state="generating"] #chatBody,
  .chat-shell[data-state="generating"] .chat-body,
  .chat-shell[data-state="expanded"] #chatBody,
  .chat-shell[data-state="expanded"] .chat-body {
    max-height: clamp(300px, 60vh, 450px);
  }
}

/* Телефон (≤480px): ещё компактнее */
@media (max-width: 480px) {
  .chat-shell[data-state="idle"] {
    max-height: clamp(120px, 25vh, 180px);
    min-height: 80px;
  }

  .chat-shell[data-state="generating"],
  .chat-shell[data-state="expanded"] {
    max-height: clamp(320px, 65vh, 450px);
  }

  .chat-shell[data-state="generating"] #chatBody,
  .chat-shell[data-state="generating"] .chat-body,
  .chat-shell[data-state="expanded"] #chatBody,
  .chat-shell[data-state="expanded"] .chat-body {
    max-height: clamp(250px, 55vh, 350px);
  }
}

/* ===== Site-wide responsive refresh ===== */
:root {
  --site-shell-max: 100%;
  --site-page-gutter: clamp(16px, 2vw, 32px);
}

html, body {
  overflow-x: hidden;
}

body {
  min-height: 100dvh;
}

.container {
  width: 100%;
  max-width: 100%;
  margin-inline: auto;
  padding-inline: var(--site-page-gutter);
}

.container.container-wide {
  max-width: 100% !important;
}

.main.app-main,
main.full {
  width: 100%;
  padding-bottom: max(3rem, calc(2rem + env(safe-area-inset-bottom, 0)));
}

.app-layout {
  width: 100%;
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: clamp(1rem, 1.6vw, 2rem);
}

.app-layout > .sidebar {
  flex: 0 0 clamp(248px, 21vw, 320px);
  min-width: 248px;
}

.app-layout > .content,
.app-layout > .content2 {
  flex: 1 1 0;
  min-width: 0;
  margin-left: 0;
  overflow: visible;
}

.content,
.content2 {
  margin-bottom: clamp(1.5rem, 2vw, 2.5rem);
}

.content h1,
.content h2,
.content h3,
.content h4,
.content h5,
.content2 h1,
.content2 h2,
.content2 h3,
.content2 h4,
.content2 h5 {
  text-align: left;
}

.header {
  margin-bottom: clamp(1rem, 1.8vw, 1.5rem);
}

.header-top {
  width: 100%;
  gap: clamp(1rem, 2vw, 2.5rem);
  padding-block: clamp(0.8rem, 1.2vw, 1.15rem);
  background-position: left center;
  background-size: cover;
}

.header-top .logo {
  flex: 0 0 auto;
}

.header-top img.logo {
  width: clamp(170px, 15vw, 240px);
  height: auto;
  display: block;
}

.nav {
  flex: 1 1 auto;
  min-width: 0;
  justify-content: flex-end;
  align-items: center;
  gap: clamp(0.85rem, 1.6vw, 2rem);
  row-gap: 0.85rem;
}

.nav a {
  font-size: clamp(1rem, 0.2vw + 0.95rem, 1.08rem);
}

.breadcrumb {
  padding-block: 0.75rem;
}

.breadcrumb-row {
  gap: 0.9rem 1.5rem;
  flex-wrap: wrap;
}

.breadcrumbs-left {
  flex: 1 1 420px;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}

.crumb-balance.userbox,
.breadcrumb-row .crumb-auto {
  margin-left: auto;
}

.footer-mascot {
  height: clamp(78px, 7vw, 120px);
  width: auto;
  display: block;
}

.cards,
.model-panel {
  gap: clamp(1rem, 1.5vw, 1.5rem);
  justify-content: stretch;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}

.model-panel.active {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

.model-tabs {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.card {
  min-height: 180px;
  padding: 1.25rem 1.25rem 1.25rem 8.75rem;
  border: 1px solid #e6eef5;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.05);
}

.card::before {
  width: 112px;
  height: 112px;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

.card p {
  line-height: 1.4;
}

.flex > .sidebar,
#appLayout > .sidebar {
  top: 0.25rem;
}

@media (max-width: 1200px) {
  .app-layout {
    flex-wrap: wrap;
  }

  .app-layout > .sidebar,
  .flex > .sidebar,
  #appLayout > .sidebar {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
    position: static;
    max-height: none;
    overflow: visible;
  }

  .sidebar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.9rem;
  }

  .sidebar > .btn,
  .sidebar > .btn-new-chat {
    width: 100%;
    margin: 0;
  }

  .sidebar .history {
    grid-column: 1 / -1;
    width: 100%;
    max-height: none;
  }

  body.is-sidebar-collapsed .sidebar {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    padding-right: 0;
  }

  body.is-sidebar-collapsed .sidebar .history {
    display: flex;
  }

  body.is-sidebar-collapsed .sidebar .btn,
  body.is-sidebar-collapsed .sidebar .btn-new-chat {
    width: 100%;
    height: auto;
    min-height: 68px;
    margin: 0;
    padding: 0.8rem 0.9rem 0.8rem 4rem;
    justify-content: flex-start;
    font-size: inherit;
    line-height: 1.2;
  }

  body.is-sidebar-collapsed .sidebar .btn::before,
  body.is-sidebar-collapsed .sidebar .btn-new-chat::before {
    content: none;
  }
}

@media (max-width: 900px) {
  .header-top {
    align-items: flex-start;
  }

  .nav {
    justify-content: flex-start;
    width: 100%;
  }

  .sidebar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .crumb-balance.userbox,
  .breadcrumb-row .crumb-auto {
    width: 100%;
    margin-left: 0;
  }

  .userbox__logout {
    left: 0;
    right: auto;
    top: calc(100% + 8px);
    transform: translateY(0);
    margin-right: 0;
  }

  .userbox__name-wrap:hover .userbox__logout,
  .userbox__name-wrap:focus-within .userbox__logout,
  .userbox__name-wrap.open .userbox__logout {
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .container,
  .container.container-wide {
    padding-inline: 16px;
  }

  .nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.8rem;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  .sidebar > .btn,
  .sidebar > .btn-new-chat,
  body.is-sidebar-collapsed .sidebar .btn,
  body.is-sidebar-collapsed .sidebar .btn-new-chat {
    min-height: 64px;
    font-size: 18px;
    background-size: 40px 40px;
  }

  .cards,
  .model-panel.active {
    grid-template-columns: 1fr;
  }

  .card {
    min-height: 152px;
    padding: 1rem 1rem 1rem 6.75rem;
  }

  .card::before {
    width: 82px;
    height: 82px;
  }

  .footer-container {
    flex-direction: column;
    text-align: center;
  }

  .footer-character {
    order: -1;
  }

  .breadcrumb {
    font-size: 14px;
  }
}


/* ============================================================
   SITE-WIDE OVERHAUL — March 2026
   Issues: header, footer, full-width, pricing, contacts,
   offer, SEO text, neural networks, responsive
   ============================================================ */

/* ── 1 & 7. Header: image left-aligned, proportional ──────── */
.header-top {
  background: url("../assets/images/stars.png") no-repeat left center !important;
  background-size: auto 100% !important;
  padding-block: clamp(0.3rem, 0.5vw, 0.45rem) !important;
}

.header-top img.logo {
  width: clamp(70px, 6vw, 100px);
}

/* ── 6. Footer: always at page bottom ─────────────────────── */
html {
  height: 100%;
}

body {
  display: flex !important;
  flex-direction: column !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
}

main, .main {
  flex: 1 1 auto !important;
}

.footer {
  flex-shrink: 0 !important;
  flex-grow: 0 !important;
  margin-top: auto !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  position: relative;
  z-index: 10;
  background: #fff;
  border-top: 1px solid #e0eaf3;
  padding: 1rem var(--site-page-gutter, 1.5rem) !important;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0)) !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
}

.footer-container {
  width: 100%;
  max-width: 1400px !important;
  margin-inline: auto;
  display: flex !important;
  justify-content: space-between;
  align-items: center;
  padding-inline: var(--site-page-gutter, 1rem);
}

.footer-sep {
  opacity: 0.4;
  margin: 0 4px;
}

.footer-link {
  color: inherit !important;
  opacity: 0.7;
  text-decoration: none !important;
  font-size: inherit;
}

.footer-link:hover {
  opacity: 1;
}

/* ── 11. Full width usage ─────────────────────────────────── */
.main.app-main,
main.full,
main.main {
  width: 100%;
  max-width: 100%;
}

.app-layout,
.flex.app-layout {
  width: 100%;
  max-width: 100%;
}

.content, .content2 {
  flex: 1 1 0;
  min-width: 0;
  margin-left: 0;
}

/* ── 2. SEO text and rich text: modern readable typography ── */
.seo-text,
.rich-text {
  font-size: 16px;
  line-height: 1.7;
  color: #2c3a4a;
  max-width: 100%;
}

.seo-text h4,
.rich-text h1,
.rich-text h2,
.rich-text h3,
.rich-text h4 {
  font-weight: 700;
  margin: 1.5em 0 0.6em;
  color: #1c2b3a;
  text-align: left;
  line-height: 1.3;
}

.seo-text h4 { font-size: 1.3rem; }
.rich-text h1 { font-size: 1.8rem; }
.rich-text h2 { font-size: 1.5rem; }
.rich-text h3 { font-size: 1.25rem; }
.rich-text h4 { font-size: 1.1rem; }

.seo-text p,
.rich-text p {
  margin: 0.75em 0;
  line-height: 1.7;
}

.seo-text ul, .seo-text ol,
.rich-text ul, .rich-text ol {
  margin: 0.75em 0;
  padding-left: 1.5em;
}

.seo-text li,
.rich-text li {
  margin: 0.4em 0;
  line-height: 1.6;
}

.seo-text a,
.rich-text a {
  color: #1c88c7;
}

.seo-text a:hover,
.rich-text a:hover {
  text-decoration: underline;
}

/* ── Buttons: modern look for submit buttons on SEO pages ── */
.submit-button_v3 {
  background: linear-gradient(135deg, #1c88c7, #2aa5d4);
  color: #fff;
  border: none;
  padding: 12px 28px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 14px rgba(28, 136, 199, 0.25);
  border-bottom: none;
}

.submit-button_v3:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(28, 136, 199, 0.35);
  background: linear-gradient(135deg, #1a7ab5, #28a0cf);
}

.submit-button_v4 {
  background: #fff;
  border: 1px solid #dbe6f2;
  color: #2c3a4a;
  padding: 10px 22px;
  font-size: 15px;
  font-weight: 500;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.04);
}

.submit-button_v4:hover {
  background: #f6fbff;
  border-color: #b8cfe6;
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
}

.form-group.flex-align {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

/* ── 3. Neural networks section: modern ───────────────────── */
.models,
.models.neuro {
  margin-top: 2rem;
}

.models h1,
.models h3 {
  text-align: left;
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: #1c2b3a;
}

.model-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 1.5rem 0;
  justify-content: flex-start;
  padding: 0;
}

.model-tabs button {
  background: #fff;
  border: 1px solid #dbe6f2;
  padding: 10px 22px;
  font-size: 15px;
  font-weight: 500;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #4a6078;
  box-shadow: 0 2px 6px rgba(16, 24, 40, 0.04);
}

.model-tabs button:hover {
  background: #f0f7ff;
  border-color: #a8c8e8;
  color: #1c2b3a;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
}

.model-tabs button.active {
  background: linear-gradient(135deg, #1c88c7, #2aa5d4);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 14px rgba(28, 136, 199, 0.3);
}

.model-panel {
  display: none;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.model-panel.active {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}

.card.tab-fix,
.card-products {
  min-height: 150px;
  padding: 1.25rem 1.25rem 1.25rem 8.5rem;
  border: 1px solid #e6eef5;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.04);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.card.tab-fix:hover,
.card-products:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.1);
  background: #fafdff;
}

.card.tab-fix::before,
.card-products::before {
  border-radius: 14px;
}

.card.tab-fix span,
.card-products span {
  font-size: 18px;
  font-weight: 700;
  color: #1c2b3a;
  display: block;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.card.tab-fix p,
.card-products p {
  font-size: 14px;
  line-height: 1.5;
  color: #5a7088;
}

/* ── 8. Pricing page: modern cards ────────────────────────── */
.price-page {
  width: 100%;
}

.price-page h1 {
  text-align: left;
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #1c2b3a;
}

.price-subtitle {
  font-size: 16px;
  color: #6f8194;
  margin-bottom: 2rem;
}

.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 1.25rem;
  width: 100%;
}

.price-card-modern {
  background: #fff;
  border: 1px solid #e6eef5;
  border-radius: 18px;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.04);
}

.price-card-modern:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(16, 24, 40, 0.1);
}

.price-card-header {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid #f0f5fa;
  background: linear-gradient(135deg, #f8fbff, #f0f6fc);
}

.price-model-name {
  font-weight: 700;
  font-size: 1.15rem;
  color: #1c2b3a;
  margin-bottom: 4px;
}

.price-model-unit {
  font-size: 13px;
  color: #8a9bab;
}

.price-card-body {
  padding: 1.25rem 1.5rem;
  display: flex;
  gap: 2rem;
}

.price-metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.price-metric-label {
  font-size: 13px;
  color: #8a9bab;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.price-metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1c88c7;
}

.price-metric-value small {
  font-size: 0.7em;
  font-weight: 400;
  color: #6f8194;
}

/* ── 9. Contacts page: modern ─────────────────────────────── */
.contacts-page {
  width: 100%;
}

.contacts-hero {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #e6eef5;
}

.contacts-hero h1 {
  text-align: left;
  font-size: 1.8rem;
  font-weight: 700;
  color: #1c2b3a;
  margin-bottom: 0.5rem;
}

.contacts-lead {
  font-size: 16px;
  color: #6f8194;
}

.contacts-body {
  padding: 2rem;
  background: #fafdff;
  border: 1px solid #e6eef5;
  border-radius: 18px;
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.04);
}

/* ── 10. Oferta page: readable text ──────────────────────── */
.offer-page {
  width: 100%;
}

.offer-page h1 {
  text-align: left;
  font-size: 1.8rem;
  font-weight: 700;
  color: #1c2b3a;
  margin-bottom: 1.5rem;
}

.offer-body {
  padding: 2rem 2.5rem;
  background: #fafdff;
  border: 1px solid #e6eef5;
  border-radius: 18px;
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.04);
}

.offer-body p {
  margin: 1em 0;
  text-indent: 0;
}

.offer-body h2, .offer-body h3, .offer-body h4 {
  margin-top: 2em;
  margin-bottom: 0.75em;
  padding-bottom: 0.5em;
  border-bottom: 1px solid #e6eef5;
}

.offer-body ul, .offer-body ol {
  margin: 1em 0;
  padding-left: 1.8em;
}

.offer-body li {
  margin: 0.5em 0;
}

.offer-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
}

.offer-body th,
.offer-body td {
  padding: 10px 14px;
  border: 1px solid #dbe6f2;
  text-align: left;
}

.offer-body th {
  background: #f0f5fa;
  font-weight: 600;
}

/* ── 12. Responsive overrides ─────────────────────────────── */

@media (max-width: 1024px) {
  .price-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }

  .container,
  .container.container-wide {
    padding-inline: clamp(12px, 2vw, 24px);
  }
}

@media (max-width: 768px) {
  .header-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    background-size: auto 100% !important;
  }

  .header-top img.logo {
    width: 130px;
  }

  .app-layout,
  .flex.app-layout {
    flex-wrap: wrap !important;
  }

  .app-layout > .sidebar,
  #appLayout > .sidebar {
    flex: 1 1 100% !important;
    width: 100% !important;
    min-width: 0 !important;
    position: static !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .sidebar {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)) !important;
    gap: 0.75rem !important;
    border: none !important;
  }

  .sidebar .history {
    grid-column: 1 / -1;
    width: 100%;
    max-height: min(40vh, 300px);
    overflow-y: auto;
  }

  .content, .content2 {
    flex: 1 1 100% !important;
    width: 100% !important;
    min-width: 0 !important;
    margin-left: 0 !important;
    max-width: 100% !important;
  }

  .contacts-body,
  .offer-body {
    padding: 1.25rem;
  }

  .price-page h1,
  .contacts-hero h1,
  .offer-page h1 {
    font-size: 1.4rem;
  }

  .price-grid {
    grid-template-columns: 1fr;
  }

  .price-card-body {
    flex-direction: row;
    gap: 1.5rem;
  }

  .model-tabs button {
    padding: 8px 16px;
    font-size: 14px;
  }

  .footer {
    padding: 0.75rem 1rem !important;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0)) !important;
  }

  .footer-container {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
  }

  .footer-character {
    order: -1;
  }
}

@media (max-width: 480px) {
  .container,
  .container.container-wide {
    padding-inline: 12px !important;
  }

  .header-top {
    background-size: auto 80% !important;
    padding-inline: 12px !important;
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .nav a {
    font-size: 14px;
  }

  .sidebar {
    grid-template-columns: 1fr !important;
  }

  .card {
    min-height: auto;
    padding: 1rem 1rem 1rem 5.5rem;
  }

  .card::before {
    width: 64px;
    height: 64px;
  }

  .card.tab-fix,
  .card-products {
    min-height: auto;
    padding: 1rem 1rem 1rem 5.5rem;
  }

  .contacts-body,
  .offer-body {
    padding: 1rem;
    border-radius: 14px;
  }

  .price-card-modern {
    border-radius: 14px;
  }

  .price-metric-value {
    font-size: 1.25rem;
  }

  .model-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
  }

  .model-tabs button {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .seo-text,
  .rich-text {
    font-size: 15px;
  }

  h1, h2, h3 {
    font-size: 1.2em;
    word-break: break-word;
  }

  .breadcrumb-row {
    flex-direction: column;
    gap: 0.5rem;
  }
}

@media (max-width: 360px) {
  .container,
  .container.container-wide {
    padding-inline: 8px !important;
  }

  .card,
  .card.tab-fix,
  .card-products {
    padding: 0.75rem;
    padding-left: 0.75rem;
  }

  .card::before,
  .card.tab-fix::before,
  .card-products::before {
    display: none;
  }
}