/* Approved chat start (Figma 43:518). Shared input and history stay independent. */
body:has(#section-chat:not(.hidden)) .dashboard-main { background: var(--color-bg); }
.chat-panel--redesigned {
  position: relative;
  border: 0;
  background: transparent;
}
/* The response controls own the single header row. Keep legacy hooks hidden. */
.chat-panel--redesigned > .chat-mobile-header,
.chat-panel--redesigned > .chat-toolbar,
.chat-panel--redesigned > .chat-toolbar-scrim { display: none !important; }
.chat-panel--redesigned .chat-composer {
  flex: 0 0 auto;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 28px;
  border: 0;
  background: transparent;
  position: relative;
}
.chat-panel--redesigned .lidfly-chat-input__field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--color-brand-text);
  border-radius: 16px;
  background: var(--color-bg-card);
}
.chat-panel--redesigned #chat-input {
  width: 100%;
  min-height: 36px;
  padding: 6px 8px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-size: 16px;
  line-height: 24px;
}
.chat-panel--redesigned #chat-input:focus { outline: none; }
.chat-panel--redesigned .lidfly-chat-input__field:focus-within {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-brand-text) 14%, transparent);
}
.chat-composer-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
.chat-composer-tools > .chat-toolbar-field {
  display: block;
  flex: 0 1 156px;
  min-width: 0;
  margin: 0;
}
.chat-composer-tools > .chat-toolbar-field.hidden { display: none; }
.chat-composer-tools .chat-workspace-field__control { display: block; min-width: 0; }
.chat-composer-tools .label-hint,
.chat-composer-tools .chat-context-hint { display: none; }
.chat-composer-tools .lf-select__trigger,
.chat-composer-tools .chat-search-select__button {
  min-height: 36px;
  height: 36px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--color-bg-subtle);
  color: var(--color-text);
  font-size: 13px;
  font-weight: 600;
  line-height: 20px;
}
.chat-composer-tools .lf-select__trigger.is-placeholder .lf-select__value { color: inherit; }
.chat-composer-tools .lf-select__panel,
.chat-composer-tools .chat-search-select__panel { z-index: 140; min-width: 0; overflow-y: auto; }
.chat-service-help { margin: 0; padding: 12px; border-top: 1px solid var(--color-border); color: var(--color-text-muted); font-size: 12px; line-height: 18px; }
.chat-composer-tools #chat-send-btn,
.chat-composer-tools #chat-dictation-btn,
.chat-composer-tools #chat-attach-btn {
  flex: 0 0 36px;
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 8px;
  border: 0;
  border-radius: 10px;
  box-shadow: none;
}
.chat-composer-tools #chat-send-btn { margin-left: auto; background: var(--color-matcha-lighter); color: var(--color-brand-text); }
.chat-composer-tools #chat-send-btn:hover:not(:disabled) { background: var(--color-brand-text); color: var(--color-bg-card); }
.chat-composer-tools #chat-attach-btn { background: transparent; color: var(--color-text-secondary); }
.chat-composer-tools #chat-attach-btn:hover { background: var(--color-bg-subtle); }
/* Микрофон стоит перед «Отправить» и забирает себе отступ, прижимающий их вправо. */
.chat-composer-tools #chat-dictation-btn { margin-left: auto; background: transparent; color: var(--color-forest); }
.chat-composer-tools #chat-dictation-btn:hover:not(:disabled) { background: var(--color-matcha-lighter); }
.chat-composer-tools #chat-dictation-btn + #chat-send-btn { margin-left: 0; }
.chat-composer-tools #chat-send-btn[hidden] { display: none; }
.chat-composer-tools #chat-send-btn svg,
.chat-composer-tools #chat-dictation-btn svg,
.chat-composer-tools #chat-attach-btn svg { width: 20px; height: 20px; }
.chat-composer-tools .chat-service-invalid .lf-select__trigger,
.chat-composer-tools .chat-service-invalid .lf-select__value,
.chat-composer-tools .chat-service-invalid .lf-select__chevron { background: var(--color-error); color: var(--color-bg-card); }
.chat-service-error { margin: 8px 0 0; color: var(--color-error); font-size: 13px; font-weight: 600; }
.chat-service-error[hidden] { display: none; }
.chat-panel--start #chat-messages { padding: clamp(32px, 8vh, 96px) 28px 24px; background: transparent; }
.chat-panel--redesigned #chat-status:empty { display: none; }
.chat-panel--start .chat-composer { padding: 0; }
@media (max-width: 768px) {
  body.chat-mobile-mode:has(#section-chat:not(.hidden)) .dashboard-main { padding: 0; }
  body.chat-mobile-mode .chat-panel--redesigned .chat-composer { position: relative; border: 0; background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; padding: 0 8px env(safe-area-inset-bottom); }
  .chat-panel--start #chat-messages { padding: 28px 16px 24px; }
  body.chat-mobile-mode .chat-panel--start .chat-composer { padding: 0; }
  .chat-panel--redesigned .lidfly-chat-input__field {
    display: grid;
    grid-template-columns: 44px repeat(3, minmax(0, 1fr)) 44px 44px;
    gap: 4px;
    padding: 4px;
  }
  .chat-panel--redesigned #chat-input { grid-column: 1 / 5; grid-row: 1; min-height: 44px; padding: 10px 8px; }
  .chat-composer-tools { display: contents; }
  body.chat-mobile-mode .chat-composer-tools > .chat-toolbar-field { width: 100%; grid-row: 2; }
  body.chat-mobile-mode .chat-composer-tools > .chat-toolbar-field:has(#chat-scope) { grid-column: 2; }
  body.chat-mobile-mode .chat-composer-tools > .chat-toolbar-field.chat-workspace-field { grid-column: 3; }
  body.chat-mobile-mode .chat-composer-tools > #chat-target-field { grid-column: 4 / 7; }
  .chat-composer-tools #chat-attach-btn { grid-column: 1; grid-row: 2; }
  .chat-composer-tools #chat-dictation-btn { grid-column: 5; grid-row: 1; margin-left: 0; }
  .chat-composer-tools #chat-send-btn { grid-column: 6; grid-row: 1; }
  .chat-composer-tools:not(:has(#chat-dictation-btn)) #chat-send-btn { grid-column: 5 / 7; justify-self: end; }
  /* Nothing to send: «Отправить» is hidden, the microphone takes its place at the edge. */
  .chat-panel--redesigned .lidfly-chat-input__field:has(#chat-send-btn[hidden]) #chat-input { grid-column: 1 / 6; }
  .chat-composer-tools:has(#chat-send-btn[hidden]) #chat-dictation-btn { grid-column: 6; }
  .chat-panel--redesigned .lidfly-chat-input__field:has(#chat-send-btn[hidden]):not(:has(#chat-dictation-btn)) #chat-input { grid-column: 1 / 7; }
  .chat-composer-tools #chat-attach-btn,
  .chat-composer-tools #chat-dictation-btn,
  .chat-composer-tools #chat-send-btn { width: 44px; height: 44px; min-height: 44px; }
  .chat-composer-tools .lf-select__trigger,
  .chat-composer-tools .chat-search-select__button,
  .chat-composer-tools .chat-workspace-field.is-unselected .lf-select__trigger {
    height: 44px; min-height: 44px; padding: 6px; gap: 4px; font-size: 12px;
  }
  .chat-panel--redesigned .chat-target-notice { grid-column: 1 / -1; }
}
