.saharov-ai-root,
.saharov-ai-root * {
  box-sizing: border-box;
}

.saharov-ai-root {
  --saharov-ai-bg: #0b1628;
  --saharov-ai-panel: #111f35;
  --saharov-ai-muted: #e3e8ef;
  --saharov-ai-text: #ffffff;
  --saharov-ai-text-soft: #c9d3df;
  --saharov-ai-gold: #c89b3c;
  --saharov-ai-gold-dark: #b8892f;
  --saharov-ai-line: rgba(227, 232, 239, 0.18);
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 138px;
  height: 62px;
  z-index: 2147483000;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--saharov-ai-text);
  pointer-events: none;
}

.saharov-ai-root:not(.saharov-ai-root--open) {
  top: auto !important;
  left: auto !important;
  right: 20px !important;
  bottom: 20px !important;
  width: 138px !important;
  height: 62px !important;
  max-width: 138px !important;
  max-height: 62px !important;
  overflow: visible !important;
  pointer-events: none !important;
}

.saharov-ai-root--open {
  width: min(388px, calc(100vw - 32px));
  height: min(696px, calc(100vh - 36px));
}

.saharov-ai-launcher,
.saharov-ai-root--open .saharov-ai-panel,
.saharov-ai-root--open .saharov-ai-panel * {
  pointer-events: auto;
}

.saharov-ai-root:not(.saharov-ai-root--open) .saharov-ai-panel,
.saharov-ai-root:not(.saharov-ai-root--open) .saharov-ai-panel * {
  pointer-events: none !important;
}

.saharov-ai-launcher {
  width: 138px;
  height: 62px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--saharov-ai-gold), var(--saharov-ai-gold-dark));
  color: #0b1628;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 16px 38px rgba(11, 22, 40, 0.36);
}

.saharov-ai-panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  display: none;
  width: min(388px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 112px));
  overflow: hidden;
  border: 1px solid var(--saharov-ai-line);
  border-radius: 8px;
  background: var(--saharov-ai-bg);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.44);
}

.saharov-ai-root--open .saharov-ai-panel {
  display: flex;
  flex-direction: column;
}

.saharov-ai-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--saharov-ai-line);
  background: #0f1d31;
}

.saharov-ai-title-wrap {
  min-width: 0;
}

.saharov-ai-title {
  color: var(--saharov-ai-text);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.28;
}

.saharov-ai-subtitle {
  margin-top: 4px;
  color: var(--saharov-ai-text-soft);
  font-size: 12px;
  line-height: 1.35;
}

.saharov-ai-close {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid var(--saharov-ai-line);
  border-radius: 6px;
  background: transparent;
  color: var(--saharov-ai-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.saharov-ai-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  background: linear-gradient(180deg, #0b1628 0%, #101d31 100%);
}

.saharov-ai-message {
  display: flex;
  margin-bottom: 10px;
}

.saharov-ai-message--user {
  justify-content: flex-end;
}

.saharov-ai-bubble {
  max-width: 86%;
  padding: 10px 12px;
  border: 1px solid var(--saharov-ai-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--saharov-ai-text);
  font-size: 14px;
  line-height: 1.42;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.saharov-ai-message--user .saharov-ai-bubble {
  border-color: rgba(200, 155, 60, 0.45);
  background: rgba(200, 155, 60, 0.18);
}

.saharov-ai-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--saharov-ai-line);
  background: var(--saharov-ai-panel);
}

.saharov-ai-action {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border: 1px solid var(--saharov-ai-gold);
  border-radius: 6px;
  background: var(--saharov-ai-gold);
  color: #0b1628 !important;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none !important;
}

.saharov-ai-action--secondary {
  background: transparent;
  color: var(--saharov-ai-text) !important;
}

.saharov-ai-form {
  position: relative;
  display: block;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--saharov-ai-line);
  background: var(--saharov-ai-panel);
}

.saharov-ai-composer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.saharov-ai-tools {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 6px;
}

.saharov-ai-tool,
.saharov-ai-emoji,
.saharov-ai-file-remove {
  border: 1px solid var(--saharov-ai-line);
  border-radius: 6px;
  background: transparent;
  color: var(--saharov-ai-text);
  cursor: pointer;
  font: inherit;
}

.saharov-ai-tool {
  width: 36px;
  min-height: 34px;
  font-size: 17px;
  line-height: 1;
}

.saharov-ai-tool:hover,
.saharov-ai-emoji:hover,
.saharov-ai-file-remove:hover {
  border-color: var(--saharov-ai-gold);
}

.saharov-ai-file-input {
  display: none;
}

.saharov-ai-file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.saharov-ai-file-chip {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 5px 8px;
  border: 1px solid var(--saharov-ai-line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--saharov-ai-text-soft);
  font-size: 12px;
  line-height: 1.2;
}

.saharov-ai-file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saharov-ai-file-remove {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}

.saharov-ai-emoji-panel {
  position: absolute;
  left: 16px;
  bottom: calc(100% - 4px);
  display: none;
  grid-template-columns: repeat(5, 34px);
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--saharov-ai-line);
  border-radius: 8px;
  background: #0f1d31;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.28);
}

.saharov-ai-emoji-panel--open {
  display: grid;
}

.saharov-ai-emoji {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.saharov-ai-input {
  width: 100%;
  min-height: 42px;
  max-height: 110px;
  resize: vertical;
  border: 1px solid var(--saharov-ai-line);
  border-radius: 6px;
  background: #f5f7fa;
  color: #0b1628;
  font: 14px/1.35 Arial, Helvetica, sans-serif;
  letter-spacing: 0;
  padding: 9px 10px;
  outline: none;
}

.saharov-ai-input:focus {
  border-color: var(--saharov-ai-gold);
}

.saharov-ai-send {
  min-width: 98px;
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--saharov-ai-gold);
  color: #0b1628;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  cursor: pointer;
}

.saharov-ai-send:disabled,
.saharov-ai-input:disabled,
.saharov-ai-tool:disabled {
  opacity: 0.68;
  cursor: wait;
}

@media (max-width: 560px) {
  .saharov-ai-root {
    right: 12px;
    bottom: 12px;
  }

  .saharov-ai-root:not(.saharov-ai-root--open) {
    right: 12px !important;
    bottom: 12px !important;
    width: 138px !important;
    height: 62px !important;
    max-width: 138px !important;
    max-height: 62px !important;
  }

  .saharov-ai-root--open {
    width: calc(100vw - 20px);
    height: calc(100vh - 24px);
  }

  .saharov-ai-panel {
    right: -2px;
    bottom: 72px;
    width: calc(100vw - 20px);
    height: calc(100vh - 96px);
  }

  .saharov-ai-composer {
    grid-template-columns: 1fr;
  }

  .saharov-ai-tools {
    grid-template-columns: repeat(2, 40px);
    grid-template-rows: 1fr;
  }

  .saharov-ai-send {
    width: 100%;
  }

  .saharov-ai-emoji-panel {
    left: 12px;
  }
}
