/* ═══════════════════════════════════════════════════════════════════════════
   AI Workspace Chat — полноценный чат-бот в Haze shell
   ═══════════════════════════════════════════════════════════════════════════ */

.ai-chat-container {
  display: flex;
  flex-direction: row;
  height: calc(100vh - 140px);
  max-height: 800px;
  border-radius: 16px;
  background: var(--surface, #1c252e);
  border: 1px solid var(--border, rgba(255,255,255,.06));
  overflow: hidden;
}

/* ── Chat sidebar ─────────────────────────────────────────────────────── */

.ai-chat-sidebar {
  width: 220px;
  min-width: 220px;
  border-right: 1px solid var(--border, rgba(255,255,255,.06));
  display: flex;
  flex-direction: column;
  background: var(--bg, #141a21);
}

.ai-chat-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
}

.ai-chat-sidebar__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-muted, #8899aa);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.ai-chat-sidebar__new {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: var(--accent, #ed5b2f);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity .15s;
}

.ai-chat-sidebar__new:hover { opacity: .85; }

.ai-chat-sidebar__list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}

.ai-chat-list__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s;
  margin-bottom: 2px;
}

.ai-chat-list__item:hover {
  background: var(--surface-hover, rgba(255,255,255,.04));
}

.ai-chat-list__item--active {
  background: var(--accent-muted, rgba(237,91,47,.14));
}

.ai-chat-list__item-role {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent-muted, rgba(237,91,47,.14));
  color: var(--accent, #ed5b2f);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-chat-list__item--contractor .ai-chat-list__item-role {
  background: rgba(56,152,236,.14);
  color: #3898ec;
}

.ai-chat-list__item-title {
  flex: 1;
  font-size: 13px;
  color: var(--fg, #e0e8f0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-chat-list__item-del {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--fg-dim, #667788);
  cursor: pointer;
  font-size: 12px;
  padding: 0 2px;
  opacity: 0;
  transition: opacity .12s, color .12s;
}

.ai-chat-list__item:hover .ai-chat-list__item-del { opacity: 1; }
.ai-chat-list__item-del:hover { color: #e74c3c; }

/* Role switcher (admin) */
.ai-chat-sidebar__roles {
  padding: 10px 14px;
  border-top: 1px solid var(--border, rgba(255,255,255,.06));
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.ai-chat-sidebar__roles-label {
  font-size: 11px;
  color: var(--fg-dim, #667788);
  width: 100%;
}

.ai-chat-role-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(255,255,255,.08));
  background: transparent;
  color: var(--fg-muted, #8899aa);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all .12s;
}

.ai-chat-role-btn:hover {
  border-color: var(--accent, #ed5b2f);
  color: var(--accent, #ed5b2f);
}

/* ── Main chat area ───────────────────────────────────────────────────── */

.ai-chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.ai-chat-header__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-chat-header__avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-muted, rgba(237,91,47,.14));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-chat-header__avatar img {
  border-radius: 10px;
  object-fit: contain;
}

.ai-chat-header__title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  line-height: 1.2;
}

.ai-chat-header__tender-select {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.ai-chat-header__tender-label {
  font-size: 12px;
  color: var(--fg-muted, #8899aa);
  white-space: nowrap;
}

.ai-chat-header__tender-dropdown {
  font-size: 12px;
  background: rgba(255,255,255,.06);
  color: var(--fg, #e0e8f0);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  padding: 2px 8px;
  max-width: 260px;
  cursor: pointer;
  outline: none;
  transition: border-color .15s;
}

.ai-chat-header__tender-dropdown:hover,
.ai-chat-header__tender-dropdown:focus {
  border-color: rgba(100,180,255,.4);
}

.ai-chat-header__tender-dropdown option {
  background: #1a2332;
  color: #e0e8f0;
}

/* ── Messages ────────────────────────────────────────────────────────────── */

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.ai-chat-msg {
  display: flex;
  gap: 10px;
  max-width: 85%;
  animation: aiChatFadeIn .25s ease;
}

@keyframes aiChatFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-chat-msg--ai {
  align-self: flex-start;
}

.ai-chat-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
  position: relative;
}

.ai-chat-msg__avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  overflow: hidden;
}

.ai-chat-msg--ai .ai-chat-msg__avatar {
  background: var(--accent-muted, rgba(237,91,47,.14));
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-chat-msg--user .ai-chat-msg__avatar {
  background: var(--surface-hover, rgba(255,255,255,.08));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-muted, #8899aa);
}

.ai-chat-msg__content {
  min-width: 0;
}

.ai-chat-msg__text {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.ai-chat-msg--ai .ai-chat-msg__text {
  background: var(--surface-hover, rgba(255,255,255,.04));
  border: 1px solid var(--border, rgba(255,255,255,.06));
  border-top-left-radius: 4px;
}

.ai-chat-msg--user .ai-chat-msg__text {
  background: var(--accent, #ed5b2f);
  color: #fff;
  border-top-right-radius: 4px;
}

.ai-chat-msg__text strong {
  font-weight: 600;
}

.ai-chat-msg__text em {
  font-style: italic;
  opacity: .8;
}

.ai-chat-msg__text code {
  background: rgba(255,255,255,.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.ai-chat-msg--user .ai-chat-msg__text code {
  background: rgba(255,255,255,.2);
}

.ai-chat-msg__time {
  font-size: 11px;
  color: var(--fg-dim, #667788);
  margin-top: 4px;
}

.ai-chat-msg--user .ai-chat-msg__time {
  text-align: right;
}

/* ── Typing indicator ────────────────────────────────────────────────────── */

.ai-chat-typing {
  display: flex;
  gap: 10px;
  align-self: flex-start;
  max-width: 85%;
}

.ai-chat-typing__dots {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--surface-hover, rgba(255,255,255,.04));
  border: 1px solid var(--border, rgba(255,255,255,.06));
  border-radius: 14px;
  border-top-left-radius: 4px;
}

.ai-chat-typing__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fg-muted, #8899aa);
  animation: aiChatBounce 1.4s infinite ease-in-out;
}

.ai-chat-typing__dot:nth-child(2) { animation-delay: .2s; }
.ai-chat-typing__dot:nth-child(3) { animation-delay: .4s; }

@keyframes aiChatBounce {
  0%, 80%, 100% { transform: scale(.7); opacity: .4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── Tool status ─────────────────────────────────────────────────────────── */

.ai-chat-tools {
  padding: 0 16px;
}

.ai-chat-tools__status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 15%, transparent);
  font-size: 13px;
  color: var(--accent, #ed5b2f);
  animation: aiChatFadeIn .2s ease;
}

.ai-chat-tools__status .ai-chat-tools__spinner {
  width: 14px;
  height: 14px;
  border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: aiChatSpin .7s linear infinite;
}

@keyframes aiChatSpin {
  to { transform: rotate(360deg); }
}

.ai-chat-tools__progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.ai-chat-tools__progress-bar {
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  overflow: hidden;
}

.ai-chat-tools__progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent, #ed5b2f);
  transition: width 0.35s ease;
}

.ai-chat-tools__progress-label {
  font-size: 12px;
  color: var(--accent, #ed5b2f);
}

.ai-chat-reconnect-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  font-size: 13px;
  animation: aiChatFadeIn .25s ease;
}

.ai-chat-reconnect-banner__btn {
  flex-shrink: 0;
  padding: 6px 12px;
  border: none;
  border-radius: 8px;
  background: var(--accent, #ed5b2f);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.ai-chat-reconnect-banner__btn:hover {
  filter: brightness(1.05);
}

/* ── File preview ────────────────────────────────────────────────────────── */

.ai-chat-files {
  padding: 0 16px 8px;
}

.ai-chat-files__list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-chat-file-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface-hover, rgba(255,255,255,.04));
  border: 1px solid var(--border, rgba(255,255,255,.08));
  font-size: 12px;
  color: var(--fg-muted, #8899aa);
  max-width: 180px;
}

.ai-chat-file-chip__icon {
  color: var(--accent, #ed5b2f);
  flex-shrink: 0;
}

.ai-chat-file-chip__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-chat-file-chip__remove {
  background: none;
  border: none;
  color: var(--fg-muted, #8899aa);
  cursor: pointer;
  padding: 0 0 0 4px;
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

.ai-chat-file-chip__remove:hover {
  color: var(--accent, #ed5b2f);
}

/* ── Input area ──────────────────────────────────────────────────────────── */

.ai-chat-input-area {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border, rgba(255,255,255,.06));
  background: var(--surface, #1c252e);
  position: relative;
}

.ai-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.ai-chat-attach-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--fg-muted, #8899aa);
  transition: color .15s, background .15s;
}

.ai-chat-attach-btn:hover {
  color: var(--accent, #ed5b2f);
  background: var(--accent-muted, rgba(237,91,47,.14));
}

.ai-chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border, rgba(255,255,255,.1));
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.45;
  background: var(--bg, #141a21);
  color: var(--fg, #e0e8f0);
  max-height: 120px;
  overflow-y: auto;
  transition: border-color .15s;
}

.ai-chat-input:focus {
  outline: none;
  border-color: var(--accent, #ed5b2f);
}

.ai-chat-input::placeholder {
  color: var(--fg-dim, #667788);
}

.ai-chat-send-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: var(--accent, #ed5b2f);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}

.ai-chat-send-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.ai-chat-send-btn:not(:disabled):hover {
  transform: scale(1.05);
}

.ai-chat-send-btn.is-stop {
  background: #c0392b;
}

.ai-chat-msg__actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity .15s;
}

.ai-chat-msg--user:hover .ai-chat-msg__actions,
.ai-chat-msg--user:focus-within .ai-chat-msg__actions {
  opacity: 1;
}

.ai-chat-msg__action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 1px solid var(--border, rgba(255,255,255,.12));
  border-radius: 8px;
  background: var(--surface-hover, rgba(255,255,255,.06));
  color: var(--fg-muted, #8899aa);
  font-size: 11px;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.ai-chat-msg__action:hover {
  background: var(--accent-muted, rgba(237,91,47,.14));
  color: var(--fg, #e8edf2);
}

@media (hover: none) {
  .ai-chat-msg__actions {
    opacity: 1;
  }
}

/* ── Quick chips ─────────────────────────────────────────────────────────── */

.ai-chat-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.ai-chat-chip {
  padding: 5px 12px;
  border-radius: 16px;
  border: 1px solid var(--border, rgba(255,255,255,.08));
  background: transparent;
  color: var(--fg-muted, #8899aa);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
  font-family: inherit;
  white-space: nowrap;
}

.ai-chat-chip:hover {
  border-color: var(--accent, #ed5b2f);
  color: var(--accent, #ed5b2f);
  background: var(--accent-muted, rgba(237,91,47,.08));
}

/* ── Drop zone ───────────────────────────────────────────────────────────── */

.ai-chat-dropzone {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--bg, #141a21) 90%, transparent);
  border: 2px dashed var(--accent, #ed5b2f);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  animation: aiChatFadeIn .15s ease;
}

.ai-chat-dropzone__content {
  text-align: center;
  color: var(--accent, #ed5b2f);
}

.ai-chat-dropzone__content p {
  margin: 8px 0 0;
  font-size: 16px;
  font-weight: 600;
}

.ai-chat-dropzone__hint {
  font-size: 13px;
  color: var(--fg-muted, #8899aa) !important;
  font-weight: 400 !important;
}

/* ── Markdown in AI messages ─────────────────────────────────────────────── */

.ai-chat-msg--ai .ai-chat-msg__text h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 12px 0 6px;
}

.ai-chat-msg--ai .ai-chat-msg__text ul,
.ai-chat-msg--ai .ai-chat-msg__text ol {
  margin: 6px 0;
  padding-left: 20px;
}

.ai-chat-msg--ai .ai-chat-msg__text li {
  margin: 2px 0;
}

.ai-chat-msg--ai .ai-chat-msg__text hr {
  border: none;
  border-top: 1px solid var(--border, rgba(255,255,255,.06));
  margin: 10px 0;
}

/* ── Action buttons (SSE type:actions) ────────────────────────────────── */

.ai-chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border, rgba(255,255,255,.06));
}

.ai-chat-actions__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid rgba(66,165,245,.4);
  background: rgba(66,165,245,.12);
  color: #42a5f5;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .2s;
}

.ai-chat-actions__btn:hover {
  background: rgba(66,165,245,.22);
  border-color: rgba(66,165,245,.6);
}

.ai-chat-actions__btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.ai-chat-actions__btn--loading {
  opacity: .65;
  border-style: dashed;
}

.ai-chat-actions__btn--done {
  border-color: rgba(102,187,106,.5);
  background: rgba(102,187,106,.12);
  color: #66bb6a;
  cursor: default;
}

.ai-chat-actions__btn--error {
  border-color: rgba(239,83,80,.5);
  background: rgba(239,83,80,.12);
  color: #ef5350;
}

.ai-chat-actions__icon {
  flex-shrink: 0;
}

body.haze-workspace.light-theme .ai-chat-actions {
  border-top-color: rgba(0,0,0,.06);
}

body.haze-workspace.light-theme .ai-chat-actions__btn {
  border-color: rgba(33,150,243,.3);
  background: rgba(33,150,243,.08);
  color: #1976d2;
}

body.haze-workspace.light-theme .ai-chat-actions__btn:hover {
  background: rgba(33,150,243,.16);
  border-color: rgba(33,150,243,.5);
}

body.haze-workspace.light-theme .ai-chat-actions__btn--done {
  border-color: rgba(76,175,80,.4);
  background: rgba(76,175,80,.08);
  color: #388e3c;
}

body.haze-workspace.light-theme .ai-chat-actions__btn--error {
  border-color: rgba(211,47,47,.4);
  background: rgba(211,47,47,.08);
  color: #d32f2f;
}

/* ── Бета-миссии: уведомления в чате (BETA-MISSIONS-1) ───────────────────── */

.ai-mission-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(102,187,106,.12);
  border: 1px solid rgba(102,187,106,.35);
  color: #a5d6a7;
  font-size: 13px;
  margin-top: 8px;
  animation: missionSlideIn .3s ease;
}

.ai-mission-toast__icon {
  font-size: 18px;
  flex-shrink: 0;
}

.ai-mission-toast__text {
  flex: 1;
}

.ai-mission-toast__points {
  font-weight: 700;
  color: #66bb6a;
}

@keyframes missionSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Бета-панель в сайдбаре ─────────────────────────────────────────────── */

.beta-panel {
  margin: 12px;
  padding: 14px;
  border-radius: 10px;
  background: rgba(255,183,77,.08);
  border: 1px solid rgba(255,183,77,.25);
}

.beta-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.beta-panel__title {
  font-size: 13px;
  font-weight: 700;
  color: #ffb74d;
}

.beta-panel__days {
  font-size: 12px;
  color: rgba(255,183,77,.7);
}

.beta-mission-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 12px;
  color: var(--text-secondary, rgba(255,255,255,.6));
}

.beta-mission-item--done {
  color: #66bb6a;
}

.beta-mission-item__check {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
}

.beta-mission-item--done .beta-mission-item__check {
  border-color: #66bb6a;
  background: rgba(102,187,106,.2);
  color: #66bb6a;
}

.beta-panel__progress {
  margin-top: 8px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,.08);
  overflow: hidden;
}

.beta-panel__progress-bar {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, #ffb74d, #66bb6a);
  transition: width .4s ease;
}

/* Light theme */
body.haze-workspace.light-theme .beta-panel {
  background: rgba(255,152,0,.06);
  border-color: rgba(255,152,0,.2);
}
body.haze-workspace.light-theme .beta-panel__title { color: #e65100; }
body.haze-workspace.light-theme .beta-panel__days { color: rgba(230,81,0,.6); }
body.haze-workspace.light-theme .beta-mission-item { color: rgba(0,0,0,.5); }
body.haze-workspace.light-theme .beta-mission-item--done { color: #2e7d32; }
body.haze-workspace.light-theme .beta-mission-item__check { border-color: rgba(0,0,0,.2); }
body.haze-workspace.light-theme .beta-mission-item--done .beta-mission-item__check {
  border-color: #2e7d32; background: rgba(46,125,50,.12); color: #2e7d32;
}
body.haze-workspace.light-theme .beta-panel__progress { background: rgba(0,0,0,.06); }

/* ── Бета-миссии: бейджи сложности в тосте ───────────────────────────────── */

.ai-mission-toast__diff {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  vertical-align: middle;
  line-height: 1.4;
}

.ai-mission-toast__diff--easy {
  background: rgba(102,187,106,.18);
  color: #81c784;
  border: 1px solid rgba(102,187,106,.3);
}

.ai-mission-toast__diff--medium {
  background: rgba(255,183,77,.15);
  color: #ffb74d;
  border: 1px solid rgba(255,183,77,.3);
}

.ai-mission-toast__diff--hard {
  background: rgba(239,83,80,.15);
  color: #ef9a9a;
  border: 1px solid rgba(239,83,80,.3);
}

.ai-mission-toast__track {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(144,202,249,.12);
  color: #90caf9;
  border: 1px solid rgba(144,202,249,.25);
  vertical-align: middle;
  line-height: 1.4;
}

/* ── Бета-миссии: список в сайдбаре ──────────────────────────────────────── */

.haze-beta-track-label {
  font-weight: 700;
  color: #66bb6a;
}

.haze-beta-missions-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.beta-mission-item__icon {
  font-size: 12px;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

.beta-mission-item__title {
  flex: 1;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.beta-mission-item__pts {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,.35);
  flex-shrink: 0;
}

.beta-mission-item--done .beta-mission-item__pts {
  color: #66bb6a;
}

.beta-mission-diff {
  font-size: 9px;
  font-weight: 600;
  padding: 0 4px;
  border-radius: 3px;
  flex-shrink: 0;
  line-height: 1.5;
}

.beta-mission-diff--easy {
  background: rgba(102,187,106,.12);
  color: #81c784;
}

.beta-mission-diff--medium {
  background: rgba(255,183,77,.1);
  color: #ffb74d;
}

.beta-mission-diff--hard {
  background: rgba(239,83,80,.1);
  color: #ef9a9a;
}

/* Light theme badges */
body.haze-workspace.light-theme .ai-mission-toast__diff--easy { background: rgba(46,125,50,.08); color: #2e7d32; border-color: rgba(46,125,50,.2); }
body.haze-workspace.light-theme .ai-mission-toast__diff--medium { background: rgba(230,81,0,.08); color: #e65100; border-color: rgba(230,81,0,.2); }
body.haze-workspace.light-theme .ai-mission-toast__diff--hard { background: rgba(198,40,40,.08); color: #c62828; border-color: rgba(198,40,40,.2); }
body.haze-workspace.light-theme .ai-mission-toast__track { background: rgba(21,101,192,.08); color: #1565c0; border-color: rgba(21,101,192,.2); }
body.haze-workspace.light-theme .haze-beta-track-label { color: #2e7d32; }
body.haze-workspace.light-theme .beta-mission-item__pts { color: rgba(0,0,0,.3); }
body.haze-workspace.light-theme .beta-mission-item--done .beta-mission-item__pts { color: #2e7d32; }
body.haze-workspace.light-theme .beta-mission-diff--easy { background: rgba(46,125,50,.06); color: #2e7d32; }
body.haze-workspace.light-theme .beta-mission-diff--medium { background: rgba(230,81,0,.06); color: #e65100; }
body.haze-workspace.light-theme .beta-mission-diff--hard { background: rgba(198,40,40,.06); color: #c62828; }

/* ── Light theme ─────────────────────────────────────────────────────────── */

body.haze-workspace.light-theme .ai-chat-container {
  background: #fff;
  border-color: rgba(0,0,0,.08);
}

body.haze-workspace.light-theme .ai-chat-msg--ai .ai-chat-msg__text {
  background: #f5f7f9;
  border-color: rgba(0,0,0,.06);
}

body.haze-workspace.light-theme .ai-chat-input {
  background: #f5f7f9;
  color: #1a2332;
  border-color: rgba(0,0,0,.12);
}

body.haze-workspace.light-theme .ai-chat-chip {
  border-color: rgba(0,0,0,.1);
  color: #556677;
}

body.haze-workspace.light-theme .ai-chat-dropzone {
  background: rgba(255,255,255,.92);
}

/* ── Free Paywall Overlay ─────────────────────────────────────────────── */

.ai-chat-paywall {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg, #141a21) 85%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: aiChatFadeIn .3s ease;
}

.ai-chat-paywall__card {
  position: relative;
  width: 420px;
  max-width: 92%;
  background: var(--surface, #1c252e);
  border: 1px solid var(--border, rgba(255,255,255,.08));
  border-radius: 20px;
  overflow: hidden;
}

/* Ghost messages (simulated conversation) */
.ai-chat-paywall__ghosts {
  padding: 20px 20px 0;
  max-height: 260px;
  overflow: hidden;
}

.ai-chat-paywall__ghost {
  display: flex;
  margin-bottom: 12px;
  animation: aiPaywallSlide .6s ease both;
}

.ai-chat-paywall__ghost--user { justify-content: flex-end; }
.ai-chat-paywall__ghost--ai { justify-content: flex-start; }

.ai-chat-paywall__ghost--user .ai-chat-paywall__ghost-text {
  background: var(--accent, #ed5b2f);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
  max-width: 70%;
}

.ai-chat-paywall__ghost--ai .ai-chat-paywall__ghost-text {
  background: var(--surface-hover, rgba(255,255,255,.04));
  border: 1px solid var(--border, rgba(255,255,255,.06));
  border-radius: 14px 14px 14px 4px;
  max-width: 85%;
}

.ai-chat-paywall__ghost-text {
  display: block;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
}

.ai-chat-paywall__ghost:nth-child(1) { animation-delay: 0s; }
.ai-chat-paywall__ghost:nth-child(2) { animation-delay: .15s; }
.ai-chat-paywall__ghost:nth-child(3) { animation-delay: .3s; }
.ai-chat-paywall__ghost:nth-child(4) { animation-delay: .45s; }

@keyframes aiPaywallSlide {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Gradient mask over ghosts */
.ai-chat-paywall__gradient {
  height: 80px;
  background: linear-gradient(to bottom, transparent, var(--surface, #1c252e));
  margin-top: -40px;
  position: relative;
  z-index: 1;
}

/* CTA section */
.ai-chat-paywall__cta {
  padding: 0 24px 28px;
  text-align: center;
  position: relative;
  z-index: 2;
}

.ai-chat-paywall__icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--accent-muted, rgba(237,91,47,.14));
  color: var(--accent, #ed5b2f);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.ai-chat-paywall__title {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 8px;
  line-height: 1.3;
}

.ai-chat-paywall__desc {
  font-size: 13px;
  color: var(--fg-muted, #8899aa);
  margin: 0 0 18px;
  line-height: 1.5;
}

.ai-chat-paywall__features {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
  text-align: left;
}

.ai-chat-paywall__feature {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--fg, #e0e8f0);
}

.ai-chat-paywall__feature svg {
  color: var(--accent, #ed5b2f);
  flex-shrink: 0;
}

.ai-chat-paywall__btn {
  display: inline-block;
  padding: 12px 28px;
  border-radius: 12px;
  background: var(--accent, #ed5b2f);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  border: none;
  font-family: inherit;
}

.ai-chat-paywall__btn:hover {
  opacity: .9;
  transform: translateY(-1px);
}

.ai-chat-paywall__note {
  font-size: 11px;
  color: var(--fg-dim, #667788);
  margin: 12px 0 0;
}

/* Paywall beta section */
.ai-chat-paywall__divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
}
.ai-chat-paywall__divider::before,
.ai-chat-paywall__divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,.08);
}
.ai-chat-paywall__divider span {
  font-size: 11px;
  color: rgba(255,255,255,.3);
}

.ai-chat-paywall__beta {
  padding: 16px;
  border-radius: 10px;
  border: 1px solid rgba(255,183,77,.2);
  background: rgba(255,183,77,.04);
}
.ai-chat-paywall__beta-title {
  font-size: 14px;
  font-weight: 700;
  color: #ffb74d;
  margin: 0 0 4px;
}
.ai-chat-paywall__beta-desc {
  font-size: 12px;
  color: var(--fg-muted, rgba(255,255,255,.5));
  margin: 0 0 10px;
  line-height: 1.5;
}
.ai-chat-paywall__beta-btn {
  display: block;
  width: 100%;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid rgba(255,183,77,.4);
  background: rgba(255,183,77,.12);
  color: #ffb74d;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.ai-chat-paywall__beta-btn:hover {
  background: rgba(255,183,77,.22);
  border-color: rgba(255,183,77,.6);
}
.ai-chat-paywall__beta-btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.ai-chat-paywall__beta-note {
  font-size: 11px;
  color: rgba(255,255,255,.3);
  margin: 8px 0 0;
  line-height: 1.4;
}
.ai-chat-paywall__beta-status {
  font-size: 11px;
  margin: 6px 0 0;
  min-height: 14px;
}

/* Light theme paywall beta */
body.haze-workspace.light-theme .ai-chat-paywall__divider::before,
body.haze-workspace.light-theme .ai-chat-paywall__divider::after {
  background: rgba(0,0,0,.08);
}
body.haze-workspace.light-theme .ai-chat-paywall__divider span {
  color: rgba(0,0,0,.3);
}
body.haze-workspace.light-theme .ai-chat-paywall__beta {
  border-color: rgba(255,152,0,.2);
  background: rgba(255,152,0,.04);
}
body.haze-workspace.light-theme .ai-chat-paywall__beta-title { color: #e65100; }
body.haze-workspace.light-theme .ai-chat-paywall__beta-desc { color: rgba(0,0,0,.5); }
body.haze-workspace.light-theme .ai-chat-paywall__beta-btn {
  border-color: rgba(230,81,0,.3);
  background: rgba(255,152,0,.08);
  color: #e65100;
}
body.haze-workspace.light-theme .ai-chat-paywall__beta-btn:hover {
  background: rgba(255,152,0,.16);
}
body.haze-workspace.light-theme .ai-chat-paywall__beta-note { color: rgba(0,0,0,.3); }

/* Light theme paywall */
body.haze-workspace.light-theme .ai-chat-paywall {
  background: rgba(255,255,255,.88);
}

body.haze-workspace.light-theme .ai-chat-paywall__card {
  background: #fff;
  border-color: rgba(0,0,0,.08);
}

body.haze-workspace.light-theme .ai-chat-paywall__ghost--user .ai-chat-paywall__ghost-text {
  background: var(--accent, #ed5b2f);
  color: #fff;
}

body.haze-workspace.light-theme .ai-chat-paywall__ghost--ai .ai-chat-paywall__ghost-text {
  background: #f5f7f9;
  border-color: rgba(0,0,0,.06);
}

body.haze-workspace.light-theme .ai-chat-paywall__gradient {
  background: linear-gradient(to bottom, transparent, #fff);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Mobile responsive (≤768px)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Container: full screen on mobile */
  .ai-chat-container {
    height: 100dvh;
    height: calc(var(--vh, 1vh) * 100);
    max-height: none;
    border-radius: 0;
    position: fixed;
    inset: 0;
    z-index: 1000;
  }

  /* Sidebar: hidden by default, overlay on toggle */
  .ai-chat-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    min-width: 280px;
    z-index: 1001;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: none;
  }

  .ai-chat-sidebar.is-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.5);
  }

  /* Sidebar backdrop */
  .ai-chat-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1000;
    -webkit-tap-highlight-color: transparent;
  }

  .ai-chat-sidebar-backdrop.is-visible {
    display: block;
  }

  /* Sidebar toggle button in header */
  .ai-chat-sidebar-toggle {
    display: flex;
  }

  /* Header: tighter padding */
  .ai-chat-header {
    padding: 10px 12px;
    gap: 8px;
  }

  .ai-chat-header__title {
    font-size: 14px;
  }

  .ai-chat-header__tender-dropdown {
    max-width: 150px;
    font-size: 11px;
  }

  .ai-chat-header__tender-label {
    display: none;
  }

  /* Messages: less padding */
  .ai-chat-messages {
    padding: 12px;
    gap: 12px;
  }

  .ai-chat-msg {
    max-width: 92%;
  }

  .ai-chat-msg__avatar {
    width: 28px;
    height: 28px;
  }

  .ai-chat-msg__text {
    padding: 8px 12px;
    font-size: 13px;
  }

  /* Input area: safe area for keyboard */
  .ai-chat-input-area {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    padding-bottom: calc(10px + var(--sat, 0px));
  }

  .ai-chat-input {
    font-size: 16px; /* prevent iOS zoom */
    max-height: 100px;
  }

  /* Chips: horizontal scroll */
  .ai-chat-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    margin: 8px -12px 0;
    padding-left: 12px;
    padding-right: 12px;
  }

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

  /* Typing: less padding */
  .ai-chat-typing__dots {
    padding: 10px 14px;
  }

  /* Tool status */
  .ai-chat-tools {
    padding: 0 12px;
  }

  /* File preview */
  .ai-chat-files {
    padding: 0 12px 8px;
  }

  .ai-chat-file-chip {
    max-width: 150px;
    font-size: 11px;
    padding: 5px 8px;
  }

  /* Paywall */
  .ai-chat-paywall__card {
    max-width: 96%;
    border-radius: 16px;
  }

  .ai-chat-paywall__ghosts {
    max-height: 180px;
    padding: 16px 16px 0;
  }

  .ai-chat-paywall__cta {
    padding: 0 16px 20px;
  }
}

/* ── Desktop: sidebar toggle hidden ── */
.ai-chat-sidebar-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--fg-muted, #8899aa);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}

.ai-chat-sidebar-toggle:hover {
  color: var(--fg, #e0e8f0);
}
