/* Снаппи — агент по макету Figma 715:2835 */

.dialog--ai-chat {
  position: fixed;
  inset: auto 16px 16px auto;
  width: 500px;
  max-width: calc(100vw - 32px);
  height: min(640px, calc(100vh - 32px));
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 24px;
  background: var(--bg-elevated, #141415);
  color: var(--text-primary, #f0f0f1);
  color-scheme: dark;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  box-sizing: border-box;
  z-index: 120;
}

[data-theme="light"] .dialog--ai-chat,
:root:not([data-theme="dark"]) .dialog--ai-chat {
  color-scheme: light;
  background: #ffffff;
  color: #12131a;
  border: 1px solid rgba(18, 19, 26, 0.08);
  box-shadow: 0 24px 64px rgba(18, 19, 26, 0.14);
}

.dialog--ai-chat[data-ai-mode="full"] {
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  border-radius: 0;
  background: var(--bg-primary, #16171c);
  box-shadow: none;
  border: 0;
}

[data-theme="light"] .dialog--ai-chat[data-ai-mode="full"],
:root:not([data-theme="dark"]) .dialog--ai-chat[data-ai-mode="full"] {
  background: var(--bg-primary, #ffffff);
}

.dialog--ai-chat::backdrop {
  background: transparent;
}

.dialog--ai-chat[data-ai-mode="full"]::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
}

.ai-chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.ai-chat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
}

.dialog--ai-chat[data-ai-mode="full"] .ai-chat__head {
  border-bottom: 0.625px solid rgba(255, 255, 255, 0.05);
  justify-content: flex-end;
}

.dialog--ai-chat[data-ai-mode="full"] .ai-chat__brand {
  display: none;
}

.ai-chat__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.ai-chat__avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #7177f8;
  overflow: hidden;
}

.ai-chat__avatar img {
  width: 16px;
  height: 16px;
  object-fit: contain;
  display: block;
}

.ai-chat__brand-text {
  min-width: 0;
}

.ai-chat__title {
  margin: 0;
  font: 500 12px/16px var(--font, "Golos Text", sans-serif);
  color: #f0f0f1;
}

.ai-chat__sub {
  margin: 2px 0 0;
  font: 400 10px/16px var(--font, "Golos Text", sans-serif);
  color: #626c77;
}

.ai-chat__head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.ai-chat__tool {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.ai-chat__tool img {
  display: block;
  width: 15px;
  height: 15px;
  object-fit: contain;
}

.ai-chat__tool .ai-chat__icon-shrink {
  display: none;
}

.dialog--ai-chat[data-ai-mode="full"] .ai-chat__tool .ai-chat__icon-expand {
  display: none;
}

.dialog--ai-chat[data-ai-mode="full"] .ai-chat__tool .ai-chat__icon-shrink {
  display: block;
}

.ai-chat-fab {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 16px;
  background: #7177f8;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(113, 119, 248, 0.35);
  padding: 0;
}

.ai-chat-fab[hidden] {
  display: none !important;
}

.ai-chat-fab img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}

.ai-chat__messages {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: stretch;
  scroll-behavior: auto;
  overflow-anchor: none;
}

.dialog--ai-chat[data-ai-mode="full"] .ai-chat__messages {
  padding: 16px 48px;
  align-items: flex-end;
}

.ai-chat__row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 100%;
  min-width: 0;
}

.dialog--ai-chat[data-ai-mode="full"] .ai-chat__row {
  max-width: 860px;
}

.ai-chat__stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}

.ai-chat__row--user {
  justify-content: flex-end;
  margin-left: auto;
}

.ai-chat__row--user .ai-chat__msg {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 16px 4px 16px 16px;
  color: #f0f0f1;
}

.ai-chat__user-mark {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  font: 600 11px/1 var(--font, "Golos Text", sans-serif);
  color: #aaa;
}

.ai-chat__msg {
  max-width: 100%;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 4px 16px 16px 16px;
  font: 400 13px/21px var(--font, "Golos Text", sans-serif);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  box-sizing: border-box;
}

.ai-chat__msg--md {
  white-space: normal;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
}

.ai-chat__msg--md > *:first-child {
  margin-top: 0;
}

.ai-chat__msg--md > *:last-child {
  margin-bottom: 0;
}

.ai-chat__msg--md p,
.ai-chat__msg--md ul,
.ai-chat__msg--md ol {
  margin: 0.55em 0;
}

.ai-chat__msg--md h1,
.ai-chat__msg--md h2,
.ai-chat__msg--md h3,
.ai-chat__msg--md h4 {
  margin: 0.75em 0 0.35em;
  font-weight: 650;
  line-height: 1.25;
  color: var(--text-primary);
}

.ai-chat__msg--md h1 { font-size: 1.2em; }
.ai-chat__msg--md h2 { font-size: 1.1em; }
.ai-chat__msg--md h3,
.ai-chat__msg--md h4 { font-size: 1.02em; }

.ai-chat__msg--md ul,
.ai-chat__msg--md ol {
  padding-left: 1.25em;
}

.ai-chat__msg--md li {
  margin: 0.2em 0;
  overflow-wrap: anywhere;
}

.ai-chat__msg--md strong {
  font-weight: 650;
}

.ai-chat__msg--md a {
  color: var(--accent, #5b7cff);
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ai-chat__msg--md hr {
  border: none;
  border-top: 1px solid color-mix(in srgb, var(--text-primary) 14%, transparent);
  margin: 0.8em 0;
}

.ai-chat__msg--md code {
  font: 500 12px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 1px 5px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--text-primary) 10%, transparent);
}

.ai-chat__code {
  margin: 0.6em 0;
  padding: 10px 12px;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  border-radius: 10px;
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
}

.ai-chat__code code {
  padding: 0;
  background: none;
  font: 500 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}

.ai-chat__table-wrap {
  margin: 0.65em 0;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--text-primary) 12%, transparent);
}

.ai-chat__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  line-height: 1.35;
  min-width: 0;
}

.ai-chat__table th,
.ai-chat__table td {
  padding: 7px 9px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid color-mix(in srgb, var(--text-primary) 10%, transparent);
}

.ai-chat__table th {
  font-weight: 650;
  background: color-mix(in srgb, var(--text-primary) 7%, transparent);
  white-space: nowrap;
}

.ai-chat__table tr:last-child td {
  border-bottom: none;
}

.ai-chat__msg--user {
  background: rgba(255, 255, 255, 0.06);
}

.ai-chat__msg--assistant {
  background: rgba(255, 255, 255, 0.03);
  color: #aaa;
}

.ai-chat__msg--error {
  justify-self: stretch;
  background: color-mix(in srgb, #ff6b6b 16%, transparent);
  color: #ffb0b0;
  font-size: 13px;
}

.ai-chat__msg--system {
  justify-self: stretch;
  background: transparent;
  color: color-mix(in srgb, var(--text-primary) 55%, transparent);
  font-size: 13px;
  padding: 4px 0;
}

.ai-chat__cards {
  justify-self: stretch;
  display: grid;
  gap: 8px;
  margin: 2px 0 4px;
  min-width: 0;
  max-width: 100%;
}

.ai-chat__card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent, #5b7cff) 12%, transparent), transparent 55%),
    color-mix(in srgb, var(--text-primary) 7%, transparent);
  border: none;
  outline: none;
  box-shadow: none;
  transition: transform 0.15s ease, background 0.15s ease;
}

.ai-chat__card:hover,
.ai-chat__card:focus,
.ai-chat__card:focus-visible {
  transform: translateY(-1px);
  border: none;
  outline: none;
  box-shadow: none;
}

.ai-chat__card-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--text-primary) 10%, transparent);
  font: 600 15px/1 var(--font);
  color: var(--text-secondary, #888);
}

.ai-chat__card-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ai-chat__card-body {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.ai-chat__card-title {
  font: 600 14px/1.3 var(--font);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-chat__card-sub {
  font: 400 12px/1.3 var(--font);
  color: color-mix(in srgb, var(--text-primary) 55%, transparent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-chat__card-badge {
  font: 600 10px/1 var(--font);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 5px 7px;
  border-radius: 999px;
  border: none;
  outline: none;
  box-shadow: none;
  color: color-mix(in srgb, var(--text-primary) 70%, transparent);
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
}

.ai-chat__card--pattern {
  background:
    linear-gradient(135deg, color-mix(in srgb, #2aa89a 14%, transparent), transparent 55%),
    color-mix(in srgb, var(--text-primary) 7%, transparent);
}

.ai-chat__card--pattern .ai-chat__card-badge {
  color: color-mix(in srgb, #2aa89a 85%, var(--text-primary));
  background: color-mix(in srgb, #2aa89a 14%, transparent);
}

.ai-chat__card--flow .ai-chat__card-badge {
  color: color-mix(in srgb, var(--accent, #5b7cff) 80%, var(--text-primary));
  background: color-mix(in srgb, var(--accent, #5b7cff) 12%, transparent);
}

.ai-chat__widgets {
  display: grid;
  gap: 10px;
  margin: 0;
  min-width: 0;
  max-width: 100%;
}

.ai-chat__sw {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  width: 100%;
  max-width: 843px;
}

.ai-chat__sw-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ai-chat__sw-count,
.ai-chat__sw-dl {
  font: 400 10px/15px var(--font, "Golos Text", sans-serif);
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #666670;
  background: none;
  border: none;
  padding: 0;
}

.ai-chat__sw-dl {
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.ai-chat__sw-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.ai-chat__sw-chips::-webkit-scrollbar {
  display: none;
}

.ai-chat__sw-chip {
  flex: 0 0 auto;
  height: 23px;
  padding: 0 10px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #666670;
  font: 600 10px/15px var(--font, "Golos Text", sans-serif);
  cursor: pointer;
}

.ai-chat__sw-chip.is-active {
  background: #f0f0f1;
  color: #0c0c0d;
}

.ai-chat__sw-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.ai-chat__screen {
  position: relative;
  flex: 0 0 auto;
  width: 140px;
  height: 296px;
  display: block;
  text-decoration: none;
  color: inherit;
  scroll-snap-align: start;
  border-radius: 16px;
  overflow: hidden;
  background: #1a1a1b;
}

.ai-chat__screen:hover {
  transform: translateY(-1px);
}

.ai-chat__screen-frame {
  display: block;
  width: 140px;
  height: 296px;
  overflow: hidden;
  background: #1a1a1b;
}

.ai-chat__screen-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.ai-chat__screen--web {
  width: 148px;
  height: 92px;
}

.ai-chat__screen--web .ai-chat__screen-frame {
  width: 148px;
  height: 92px;
}

.ai-chat__screen-logo {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  overflow: hidden;
  border: 0.625px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.25);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.ai-chat__screen-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ai-chat__screen-cap {
  display: none;
}

.ai-chat__sw-more {
  flex: 0 0 auto;
  width: 93px;
  height: 296px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  color: #f0f0f1;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  scroll-snap-align: start;
}

.ai-chat__sw-more img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}

.ai-chat__sw-more span {
  font: 400 12px/16px var(--font, "Golos Text", sans-serif);
  text-align: center;
}

.ai-chat__suggest {
  padding: 4px 16px 8px;
}

.ai-chat__suggest[hidden] {
  display: none !important;
}

.ai-chat__suggest-label {
  margin: 0;
  font: 400 12px/16px var(--font, "Golos Text", sans-serif);
  color: #626c77;
}

.dialog--ai-chat[data-ai-mode="full"] .ai-chat__suggest-label {
  font: 400 10px/15px ui-monospace, "JetBrains Mono", monospace;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #404048;
}

.ai-chat__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 8px;
}

.ai-chat__chip {
  border: none;
  border-radius: 12px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  color: #626c77;
  font: 400 11px/17px var(--font, "Golos Text", sans-serif);
  cursor: pointer;
}

.ai-chat__chip:hover {
  color: #f0f0f1;
  background: rgba(255, 255, 255, 0.06);
}

.ai-chat__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 8px 16px 16px;
  padding: 8px 8px 8px 14px;
  min-width: 0;
  max-width: calc(100% - 32px);
  width: auto;
  box-sizing: border-box;
  background: color-mix(in srgb, var(--text-primary, #fff) 5%, transparent);
  border: 1px solid color-mix(in srgb, var(--text-primary, #fff) 10%, transparent);
  border-radius: 16px;
  position: relative;
}

[data-theme="light"] .ai-chat__form,
:root:not([data-theme="dark"]) .ai-chat__form {
  background: #f2f3f7;
  border-color: rgba(18, 19, 26, 0.1);
}

.dialog--ai-chat .ai-chat__input,
.ai-chat__form .ai-chat__input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 32px;
  max-height: 96px;
  resize: none;
  margin: 0;
  padding: 7px 0;
  border: none;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--text-primary, #f0f0f1);
  font: 400 13px/18px var(--font, "Golos Text", sans-serif);
  color-scheme: inherit;
}

.ai-chat__input::placeholder {
  color: color-mix(in srgb, var(--text-primary, #f0f0f1) 45%, transparent);
}

[data-theme="light"] .ai-chat__input::placeholder,
:root:not([data-theme="dark"]) .ai-chat__input::placeholder {
  color: #626c77;
}

.dialog--ai-chat .ai-chat__input:focus,
.ai-chat__form .ai-chat__input:focus {
  outline: none;
  box-shadow: none !important;
  background: transparent !important;
}

.ai-chat__send {
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  border: none;
  border-radius: 12px;
  background: color-mix(in srgb, var(--text-primary, #fff) 8%, transparent);
  color: var(--text-primary, #fff);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  flex: 0 0 auto;
  transition: background 160ms ease, opacity 160ms ease, color 160ms ease;
}

.ai-chat__send img {
  width: 16px;
  height: 16px;
  object-fit: contain;
  display: block;
  opacity: 0.55;
  transition: opacity 160ms ease, filter 160ms ease;
}

.ai-chat__send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: color-mix(in srgb, var(--text-primary, #fff) 8%, transparent);
}

.ai-chat__send:not(:disabled) {
  background: #8b80f9;
  color: #fff;
  opacity: 1;
}

.ai-chat__send:not(:disabled) img {
  opacity: 1;
  filter: brightness(0) invert(1);
}

.ai-chat__status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

@media (max-width: 560px) {
  .dialog--ai-chat {
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    border-radius: 0;
  }
}

[data-theme="light"] .ai-chat__head,
:root:not([data-theme="dark"]) .ai-chat__head {
  background: rgba(18, 19, 26, 0.03);
}

[data-theme="light"] .dialog--ai-chat[data-ai-mode="full"] .ai-chat__head,
:root:not([data-theme="dark"]) .dialog--ai-chat[data-ai-mode="full"] .ai-chat__head {
  border-bottom-color: rgba(18, 19, 26, 0.08);
}

[data-theme="light"] .ai-chat__title,
:root:not([data-theme="dark"]) .ai-chat__title {
  color: #12131a;
}

[data-theme="light"] .ai-chat__tool,
[data-theme="light"] .ai-chat__chip,
:root:not([data-theme="dark"]) .ai-chat__tool,
:root:not([data-theme="dark"]) .ai-chat__chip {
  background: rgba(18, 19, 26, 0.05);
  color: #626c77;
}

[data-theme="light"] .ai-chat__chip:hover,
:root:not([data-theme="dark"]) .ai-chat__chip:hover {
  color: #12131a;
  background: rgba(18, 19, 26, 0.08);
}

[data-theme="light"] .ai-chat__msg--assistant,
:root:not([data-theme="dark"]) .ai-chat__msg--assistant {
  color: #12131a;
  background: rgba(18, 19, 26, 0.03);
}

[data-theme="light"] .ai-chat__row--user .ai-chat__msg,
[data-theme="light"] .ai-chat__msg--user,
:root:not([data-theme="dark"]) .ai-chat__row--user .ai-chat__msg,
:root:not([data-theme="dark"]) .ai-chat__msg--user {
  background: rgba(18, 19, 26, 0.08);
  color: #12131a;
}

[data-theme="light"] .ai-chat__user-mark,
:root:not([data-theme="dark"]) .ai-chat__user-mark {
  background: rgba(18, 19, 26, 0.08);
  color: #626c77;
}

[data-theme="light"] .ai-chat__send:disabled,
:root:not([data-theme="dark"]) .ai-chat__send:disabled {
  background: rgba(18, 19, 26, 0.08);
  color: #12131a;
}

[data-theme="light"] .ai-chat__send:not(:disabled),
:root:not([data-theme="dark"]) .ai-chat__send:not(:disabled) {
  background: #8b80f9;
  color: #fff;
}
