.agent-fab {
  position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom));
  display: grid; place-items: center; width: 104px; height: 104px; padding: 4px; z-index: 60;
  background: #fff9ec; border: 2px solid #b9935f; border-radius: 50%;
  box-shadow: 0 8px 22px #1d332a3d, 0 0 0 4px #fff9ec80, 0 0 0 6px #c9a46a33;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}
.agent-fab:hover, .agent-fab[aria-expanded="true"] {
  border-color: #87673c; background: #fff4da;
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 12px 28px #1d332a4d, 0 0 0 5px #fff9ec99, 0 0 0 8px #c9a46a44;
}
.agent-fab img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

.agent-panel {
  position: fixed; right: max(22px, env(safe-area-inset-right)); bottom: max(132px, calc(env(safe-area-inset-bottom) + 118px));
  z-index: 61; width: min(440px, calc(100vw - 28px)); height: 548px; max-height: calc(100dvh - 115px);
  display: none; flex-direction: column;
  background: #fffcf4; color: #283c32;
  border: 1px solid #c3cbbd; border-radius: 11px;
  box-shadow: 0 12px 32px #132b2230;
  overflow: hidden;
}
.agent-panel.show { display: flex; }
.agent-panel.is-wide { width: min(690px, calc(100vw - 28px)); height: 625px; }
.ap-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 13px;
  background: #203b31; color: #fff6e1;
}
.ap-avatar { width: 34px; height: 34px; border-radius: 50%; overflow: hidden; flex: 0 0 auto; }
.ap-avatar img { width: 100%; height: 100%; object-fit: cover; }
.ap-title { flex: 1; min-width: 0; }
.ap-title b, .ap-title small { display: block; }
.ap-title b { font-size: 16px; font-weight: 700; }
.ap-title small { font-size: 12px; color: #c1d1c3; }
.ap-ico {
  min-height: 31px; padding: 4px 6px; border: 0; border-radius: 4px; background: none;
  color: #e0e7da; font-size: 13px;
}
#agentClose { min-width: 31px; line-height: 1; font-size: 22px; }
.ap-ico:hover { background: #365648; color: #fff8e3; }

.ap-body { flex: 1; overflow-y: auto; min-height: 0; padding: 14px; }
.agent-msg {
  position: relative; width: fit-content; max-width: 93%; margin-bottom: 9px; padding: 9px 12px;
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; font-size: 15px;
}
.agent-msg.bot { background: #f2efe4; color: #25392f; border-radius: 3px 9px 9px; }
.agent-msg.user { margin-left: auto; border-radius: 9px 3px 9px 9px; background: #dfeadf; color: #224737; }
.agent-panel.is-wide .agent-msg { font-size: 17px; }
.agent-typing-dots { display: flex; gap: 5px; align-items: center; }
.agent-typing-dots span { width: 6px; height: 6px; border-radius: 50%; background: #648a76; animation: agent-dot .9s ease-in-out infinite; }
.agent-typing-dots span:nth-child(2) { animation-delay: .15s; }
.agent-typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes agent-dot { 0%,100% { opacity: .35; } 50% { opacity: 1; } }

.ap-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 9px 13px; border-top: 1px solid #e9e5d8; }
.ap-quick button {
  padding: 4px 8px; border: 1px solid #d8ddcf; border-radius: 5px; background: #fffdf7;
  color: #315644; font-size: 13px;
}
.ap-quick button:hover { background: #eaf0e5; border-color: #98ac9d; }
.ap-status { padding: 3px 13px; color: #795537; font-size: 12px; }

.ap-compose { display: flex; align-items: center; gap: 7px; padding: 7px 13px 10px; }
.ap-compose input {
  flex: 1; min-width: 0; padding: 8px 9px; border: 1px solid #cbd2c5; border-radius: 5px;
  background: #fffefa; color: #25392f; font-size: 16px;
}
.ap-compose #agentSend { padding: 8px 13px; border: 1px solid #285444; border-radius: 5px; background: #285444; color: #fffdf0; font-size: 14px; }
.ap-compose #agentSend:hover { background: #1f4437; }
.ap-foot { display: flex; padding: 0 13px 9px; }
.ap-foot:has(> button:not([hidden])) { min-height: 35px; }
.ap-foot:has(> button[hidden] + button[hidden]) { padding: 0; }
.ap-foot .btn { min-height: 27px; padding: 2px 8px; font-size: 12px; }

@media (max-width: 1200px) {
  .agent-fab { width: 84px; height: 84px; }
  .agent-panel { bottom: max(112px, calc(env(safe-area-inset-bottom) + 98px)); }
}
@media (max-width: 750px) {
  .agent-fab { width: 78px; height: 78px; right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); }
  .agent-panel { right: max(12px, env(safe-area-inset-right)); bottom: max(108px, calc(env(safe-area-inset-bottom) + 96px)); max-height: calc(100dvh - 120px); }
  #agentExpand { display: none; }
}
