.agent-builder-widget {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  font-family: var(--font-sans);
}

.agent-builder-fab {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 16px 8px 8px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: var(--shadow-pop);
  cursor: pointer;
}

.agent-builder-fab span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  overflow: hidden;
  border-radius: 50%;
  background: #ffffff;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.agent-builder-fab span img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.agent-builder-fab strong {
  font-size: 13px;
  font-weight: 760;
  white-space: nowrap;
}

.agent-builder-drawer {
  position: absolute;
  right: 0;
  bottom: 64px;
  display: flex;
  width: min(420px, calc(100vw - 28px));
  height: min(560px, calc(100vh - 104px));
  max-height: calc(100vh - 104px);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(205, 221, 216, 0.9);
  border-radius: 18px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: var(--shadow-pop);
}

.agent-builder-drawer[hidden],
.agent-builder-notice[hidden],
.agent-builder-draft[hidden],
.agent-builder-composer [hidden] {
  display: none;
}

.agent-builder-head {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #e4eeeb;
  padding: 16px 18px;
  background: #F7F8F5;
}

.agent-builder-head span,
.agent-builder-draft-head span {
  color: #6a837c;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.agent-builder-head h2 {
  margin: 3px 0 0;
  font-size: 17px;
  line-height: 1.25;
}

.agent-builder-head button {
  width: 34px;
  height: 34px;
  border: 1px solid #d9e7e3;
  border-radius: 6px;
  background: #ffffff;
  color: #315f55;
  font-size: 20px;
  cursor: pointer;
}

.agent-builder-notice {
  flex: 0 0 auto;
  margin: 12px 14px 0;
  border: 1px solid rgba(214, 160, 52, 0.35);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff8e8;
  color: #765719;
  font-size: 12px;
  line-height: 1.55;
}

.agent-builder-log {
  display: grid;
  flex: 1 1 auto;
  align-content: start;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px;
}

.agent-builder-message {
  display: grid;
  gap: 5px;
  max-width: 92%;
}

.agent-builder-message.user {
  justify-self: end;
}

.agent-builder-message span {
  color: #789088;
  font-size: 11px;
  font-weight: 740;
}

.agent-builder-message.user span {
  text-align: right;
}

.agent-builder-message div {
  border: 1px solid #deebe7;
  border-radius: 6px;
  padding: 10px 12px;
  background: #f7fbf9;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.agent-builder-message.user div {
  border-color: var(--brand);
  background: var(--brand);
  color: #ffffff;
}

.agent-builder-draft {
  flex: 0 0 auto;
  margin: 0 14px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #f2faf7;
}

.agent-builder-draft-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.agent-builder-draft-head strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
}

.agent-builder-status {
  border-radius: 4px;
  padding: 4px 8px;
  background: #e1f2ee;
  color: #0f6e5f;
  font-size: 11px;
  font-weight: 760;
}

.agent-builder-draft p {
  margin: 0 0 10px;
  color: #46655d;
  font-size: 12px;
  line-height: 1.55;
}

.agent-builder-draft dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 10px;
  margin: 0 0 12px;
  font-size: 12px;
}

.agent-builder-draft dt {
  color: #6a837c;
  font-weight: 760;
}

.agent-builder-draft dd {
  margin: 0;
  color: #173c35;
}

.agent-builder-draft-actions,
.agent-builder-composer > div {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.agent-builder-composer {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  flex: 0 0 auto;
  align-items: end;
  gap: 10px;
  border-top: 1px solid #e4eeeb;
  padding: 12px 14px;
  background: #ffffff;
}

.agent-builder-composer > textarea {
  box-sizing: border-box;
  width: 100%;
  height: 44px;
  min-height: 44px;
  max-height: 92px;
  resize: none;
  border: 1px solid #d9e7e3;
  border-radius: 6px;
  padding: 10px 12px;
  color: #173c35;
  line-height: 1.45;
  outline: none;
}

.agent-builder-composer > textarea:focus {
  border-color: rgba(27, 61, 130, 0.55);
  box-shadow: 0 0 0 3px rgba(27, 61, 130, 0.12);
}

.agent-builder-composer > div {
  align-items: center;
  align-self: end;
  min-width: max-content;
}

.agent-builder-composer .btn {
  height: 44px;
  min-height: 44px;
  border-radius: 6px;
  padding: 0 16px;
  line-height: 1;
  white-space: nowrap;
}

.agent-builder-composer .btn.primary {
  min-width: 64px;
}

.agent-builder-voice-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid #d9e7e3;
  border-radius: 6px;
  padding: 0;
  background: #ffffff;
  color: #315f55;
  box-shadow: none;
  cursor: pointer;
}

.agent-builder-voice-btn img {
  display: block;
  width: 19px;
  height: 19px;
  object-fit: contain;
}

.agent-builder-voice-btn:hover {
  border-color: rgba(27, 61, 130, 0.45);
  background: #f3fbf8;
}

.agent-builder-voice-btn.recording {
  border-color: rgba(27, 61, 130, 0.55);
  background: #e4f5f0;
  box-shadow: 0 0 0 3px rgba(27, 61, 130, 0.12);
}

.agent-builder-voice-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .agent-builder-widget {
    right: 14px;
    bottom: 14px;
  }

  .agent-builder-fab strong {
    display: none;
  }

  .agent-builder-drawer {
    position: fixed;
    right: 10px;
    left: 10px;
    bottom: 76px;
    width: auto;
    height: min(560px, calc(100vh - 96px));
  }

  .agent-builder-composer {
    grid-template-columns: 1fr;
  }

  .agent-builder-composer > div {
    min-width: 0;
    flex-wrap: wrap;
  }
}
