/* 舷窗 · 本地航空航天知识助手 */
.agent {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 96;
  display: flex;
  flex-direction: column;
  width: min(360px, calc(100vw - 32px));
  max-height: min(590px, calc(100vh - 36px));
  border: 1px solid rgba(112, 224, 255, .22);
  border-radius: 14px;
  background:
    linear-gradient(160deg, rgba(10, 24, 43, .97), rgba(5, 12, 26, .985));
  box-shadow: 0 24px 70px rgba(0, 0, 0, .48), 0 0 0 1px rgba(255, 255, 255, .025) inset;
  color: var(--text, #e8f4ff);
  overflow: hidden;
  backdrop-filter: blur(18px);
  transition: width .22s ease, box-shadow .22s ease;
  font-family: var(--sans, system-ui, -apple-system, "Segoe UI", sans-serif);
}
.agent.is-dragging { transition: none; box-shadow: 0 24px 80px rgba(0, 0, 0, .56); }
.agent.is-collapsed { width: 272px; }
.agent.is-collapsed .agent__body { display: none; }
.agent.is-collapsed .agent__head { border-bottom: 0; }

.agent__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px 11px 14px;
  border-bottom: 1px solid rgba(112, 224, 255, .12);
  background: linear-gradient(90deg, rgba(16, 42, 66, .85), rgba(8, 18, 34, .72));
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.agent__head:active { cursor: grabbing; }
.agent__brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.agent__orb {
  width: 27px; height: 27px; flex: 0 0 27px; border-radius: 50%;
  border: 1px solid rgba(112, 224, 255, .5);
  background: radial-gradient(circle at 35% 30%, #bff4ff, #24a9cc 38%, #07304d 72%);
  box-shadow: 0 0 16px rgba(63, 207, 240, .3), inset 0 0 8px rgba(255, 255, 255, .24);
  position: relative;
}
.agent__orb::after {
  content: ""; position: absolute; inset: -5px -2px; border: 1px solid rgba(126, 231, 255, .25);
  border-radius: 50%; transform: rotate(-28deg); border-left-color: transparent; border-right-color: transparent;
}
.agent__brand strong {
  display: block; font-size: 12.5px; letter-spacing: .08em; color: #eafaff;
  font-weight: 600; line-height: 1.25;
}
.agent__brand small {
  display: block; margin-top: 2px; font-family: var(--mono, ui-monospace, monospace);
  font-size: 8px; letter-spacing: .08em; color: #71b7ce; white-space: nowrap;
}
.agent__head-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.agent__head-btn {
  width: 25px; height: 25px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(122, 211, 235, .2); border-radius: 7px;
  background: rgba(255, 255, 255, .035); color: #9bd9e8; cursor: pointer;
  font-size: 14px; line-height: 1; transition: background .18s, border-color .18s;
}
.agent__head-btn:hover { background: rgba(95, 219, 250, .13); border-color: rgba(122, 231, 255, .45); }
.agent__head-btn:focus-visible, .agent__send:focus-visible, .agent__suggestion:focus-visible, .agent__input:focus-visible {
  outline: 2px solid rgba(93, 225, 255, .7); outline-offset: 2px;
}

.agent__body { display: flex; flex-direction: column; min-height: 0; }
.agent__messages {
  height: 286px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 13px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(109, 210, 236, .3) transparent;
}
.agent__messages::-webkit-scrollbar { width: 5px; }
.agent__messages::-webkit-scrollbar-thumb { background: rgba(109, 210, 236, .3); border-radius: 4px; }

.agent-msg { max-width: 92%; font-size: 11.5px; line-height: 1.68; }
.agent-msg--bot {
  align-self: flex-start;
  padding: 9px 11px;
  border: 1px solid rgba(102, 207, 230, .14);
  border-radius: 2px 10px 10px 10px;
  background: rgba(32, 70, 94, .28);
  color: #d8eef4;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.agent-msg--user {
  align-self: flex-end;
  padding: 8px 11px;
  border: 1px solid rgba(118, 208, 255, .18);
  border-radius: 10px 2px 10px 10px;
  background: linear-gradient(135deg, rgba(35, 111, 142, .42), rgba(22, 74, 101, .26));
  color: #effcff;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.agent-msg--fallback { border-color: rgba(255, 177, 100, .26); background: rgba(92, 63, 35, .26); color: #ffe8cf; }
.agent-msg__source {
  display: block;
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px solid rgba(126, 213, 235, .1);
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 8px;
  letter-spacing: .04em;
  color: #6fa5b7;
}
.agent-msg__source::before { content: "KB · "; color: #4d879c; }
.agent-msg--fallback .agent-msg__source { display: none; }

.agent__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 12px 9px;
}
.agent__suggestion {
  border: 1px solid rgba(109, 205, 230, .16);
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(18, 52, 72, .3);
  color: #9bd7e6;
  font-size: 9px;
  line-height: 1.3;
  cursor: pointer;
  transition: border-color .18s, background .18s, color .18s;
}
.agent__suggestion:hover { border-color: rgba(116, 226, 250, .42); background: rgba(35, 113, 139, .24); color: #e1fbff; }

.agent__form {
  display: flex;
  gap: 7px;
  align-items: center;
  padding: 9px 11px;
  border-top: 1px solid rgba(110, 209, 235, .13);
  background: rgba(3, 11, 22, .5);
}
.agent__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 36px;
  padding: 0 11px;
  border: 1px solid rgba(112, 216, 242, .2);
  border-radius: 8px;
  background: rgba(3, 16, 30, .7);
  color: #e9f9ff;
  font-size: 11.5px;
  font-family: inherit;
  outline: none;
}
.agent__input::placeholder { color: #5b899b; }
.agent__input:focus { border-color: rgba(97, 224, 252, .55); box-shadow: 0 0 0 3px rgba(60, 202, 235, .08); }
.agent__input:disabled { opacity: .55; }
.agent__send {
  flex: 0 0 auto;
  height: 36px;
  padding: 0 13px;
  border: 1px solid rgba(92, 230, 255, .45);
  border-radius: 8px;
  background: linear-gradient(135deg, #a6f5ff, #55d5ef 55%, #24b9d6);
  color: #052632;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
  transition: filter .18s, transform .18s;
}
.agent__send:hover { filter: brightness(1.08); transform: translateY(-1px); }
.agent__send:disabled { cursor: default; opacity: .5; transform: none; filter: none; }
.agent__foot {
  margin: 0;
  padding: 6px 12px 9px;
  background: rgba(3, 11, 22, .5);
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 8px;
  line-height: 1.4;
  letter-spacing: .03em;
  color: #4e7f8e;
  text-align: center;
}

@media (max-width: 760px) {
  .agent {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
  }
  .agent.is-collapsed { width: calc(100vw - 24px); }
  .agent__messages { height: min(280px, 38vh); }
  .agent__head { padding: 10px 10px 10px 12px; }
  .agent__brand strong { font-size: 12px; }
}
@media (max-width: 380px) {
  .agent__messages { height: 240px; }
  .agent__foot { font-size: 7.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .agent, .agent__head-btn, .agent__send, .agent__suggestion { transition: none; }
}
