/* AI 助手：底部 agent + 预对话引导 */

.ai-assist {
  --ai-ink: #1a1d24;
  --ai-muted: rgba(255, 255, 255, 0.88);
  --ai-pill: rgba(28, 32, 40, 0.55);
  --ai-bar: #ffffff;
  --ai-hint: rgba(80, 88, 100, 0.9);
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1200;
  pointer-events: none;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 0 16px calc(18px + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
}

.ai-assist.is-visible {
  display: flex;
}

.ai-assist__stage {
  width: min(560px, 100%);
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  pointer-events: auto;
}

/* 紧凑对话区：与输入条同宽，高度有限，不做大弹窗 */
.ai-assist__thread {
  display: none;
  flex-direction: column;
  gap: 8px;
  max-height: min(240px, 36vh);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 4px 2px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.ai-assist.is-open.is-chatting .ai-assist__thread {
  display: flex;
  animation: ai-assist-rise 0.22s ease-out;
}

.ai-assist__bubble {
  max-width: 92%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

.ai-assist__bubble--assistant {
  align-self: flex-start;
  background: rgba(28, 32, 40, 0.72);
  color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom-left-radius: 6px;
}

.ai-assist__bubble--user {
  align-self: flex-end;
  background: #fff;
  color: #1a1d24;
  border-bottom-right-radius: 6px;
}

/* 预对话：建议问题（开始对话后隐藏） */
.ai-assist__prompts {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.ai-assist.is-open:not(.is-chatting) .ai-assist__prompts {
  display: flex;
  animation: ai-assist-rise 0.28s ease-out;
}

.ai-assist__prompt {
  appearance: none;
  border: none;
  margin: 0;
  max-width: 100%;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ai-pill);
  color: var(--ai-muted);
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s ease, background 0.15s ease;
}

.ai-assist__prompt:hover {
  background: rgba(28, 32, 40, 0.72);
  transform: translateY(-1px);
}

.ai-assist__prompt:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.65);
  outline-offset: 2px;
}

/* 输入条（预对话展开后显示）：主行 + Auto/模型 */
.ai-assist__composer {
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 10px 10px 8px;
  border-radius: 22px;
  background: var(--ai-bar);
  box-shadow: 0 10px 36px rgba(16, 22, 32, 0.22);
  animation: ai-assist-rise 0.28s ease-out;
  position: relative;
  transition: box-shadow 0.15s ease, outline-color 0.15s ease;
}

.ai-assist__composer.is-dragover {
  outline: 2px dashed rgba(37, 99, 235, 0.55);
  outline-offset: -2px;
  box-shadow: 0 10px 36px rgba(37, 99, 235, 0.18);
}

.ai-assist.is-open .ai-assist__composer {
  display: flex;
}

.ai-assist__composer-main {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
}

.ai-assist__plus {
  position: relative;
  flex: 0 0 auto;
}

.ai-assist__plus-btn {
  appearance: none;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #5a6472;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ai-assist__plus-btn:hover,
.ai-assist__plus.is-open .ai-assist__plus-btn {
  background: rgba(0, 0, 0, 0.06);
  color: #1f2937;
}

.ai-assist__plus-icon--close {
  display: none;
}

.ai-assist__plus.is-open .ai-assist__plus-icon--add {
  display: none;
}

.ai-assist__plus.is-open .ai-assist__plus-icon--close {
  display: block;
}

.ai-assist__plus-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  min-width: 220px;
  padding: 8px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.16);
  z-index: 8;
}

.ai-assist__plus-menu[hidden] {
  display: none !important;
}

.ai-assist__plus-item {
  appearance: none;
  width: 100%;
  border: none;
  background: transparent;
  color: #1f2937;
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.25;
}

.ai-assist__plus-item:hover,
.ai-assist__plus-more.is-open > .ai-assist__plus-item--more {
  background: rgba(15, 23, 42, 0.06);
}

.ai-assist__plus-item-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #374151;
  flex-shrink: 0;
}

.ai-assist__plus-item-label {
  flex: 1 1 auto;
  min-width: 0;
}

.ai-assist__plus-chevron {
  flex-shrink: 0;
  opacity: 0.45;
}

.ai-assist__plus-more {
  position: relative;
}

.ai-assist__plus-submenu {
  position: absolute;
  left: calc(100% + 6px);
  top: 0;
  min-width: 160px;
  padding: 8px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
  z-index: 9;
}

.ai-assist__plus-submenu[hidden] {
  display: none !important;
}

@media (max-width: 520px) {
  .ai-assist__plus-submenu {
    left: 12px;
    right: 12px;
    top: calc(100% + 4px);
    min-width: 0;
  }
}

.ai-assist__input {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  color: var(--ai-ink);
  line-height: 1.4;
  padding: 8px 6px;
}

.ai-assist__input::placeholder {
  color: rgba(90, 98, 112, 0.7);
}

.ai-assist__toolbar {
  display: none;
}

.ai-assist__toolbar-spacer {
  flex: 1 1 auto;
  min-width: 8px;
}

.ai-assist__model {
  position: relative;
  flex: 0 0 auto;
}

.ai-assist__model-btn {
  appearance: none;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: rgba(15, 23, 42, 0.04);
  color: #334155;
  border-radius: 999px;
  padding: 5px 10px 5px 8px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 140px;
}

.ai-assist__model-btn:hover,
.ai-assist__model.is-open .ai-assist__model-btn {
  background: rgba(15, 23, 42, 0.08);
  border-color: rgba(15, 23, 42, 0.16);
}

.ai-assist__model-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}

.ai-assist__model-btn[data-mode="manual"] .ai-assist__model-dot {
  background: #3b82f6;
}

.ai-assist__model-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-assist__model-caret {
  width: 10px;
  height: 10px;
  opacity: 0.55;
  flex-shrink: 0;
}

.ai-assist__model-menu {
  display: none;
  position: absolute;
  right: 0;
  left: auto;
  bottom: calc(100% + 8px);
  width: min(280px, 78vw);
  max-height: min(320px, 45vh);
  overflow: auto;
  padding: 6px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.18);
  z-index: 5;
}

.ai-assist__model.is-open .ai-assist__model-menu {
  display: block;
}

.ai-assist__model-item {
  appearance: none;
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: #0f172a;
}

.ai-assist__model-item:hover,
.ai-assist__model-item.is-active {
  background: rgba(15, 23, 42, 0.06);
}

.ai-assist__model-item-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
}

.ai-assist__model-item-desc {
  font-size: 11px;
  color: #64748b;
  line-height: 1.3;
}

.ai-assist__icon-btn {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #5a6472;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ai-assist__icon-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #2f3744;
}

.ai-assist__send {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: #e8eaee;
  color: #8a93a0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.ai-assist__send.is-ready {
  background: #1f2937;
  color: #fff;
}

.ai-assist__send.is-ready:hover {
  background: #111827;
}

.ai-assist__legal {
  display: none;
  margin: 2px 8px 0;
  text-align: center;
  font-size: 11px;
  line-height: 1.4;
  color: var(--ai-hint);
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.35);
}

.ai-assist.is-open .ai-assist__legal {
  display: block;
}

.ai-assist.is-open.is-chatting .ai-assist__legal {
  display: none;
}

.ai-assist__legal a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* 底部 agent 入口：对话框式宽条，避免只剩一个小圆点 */
.ai-assist__agent {
  align-self: stretch;
  width: 100%;
  min-height: 64px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  pointer-events: auto;
  background: linear-gradient(145deg, rgba(42, 51, 64, 0.96) 0%, rgba(18, 23, 31, 0.98) 100%);
  color: #fff;
  box-shadow: 0 12px 36px rgba(10, 14, 22, 0.38);
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  padding: 10px 18px 10px 12px;
  text-align: left;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.ai-assist__agent:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(10, 14, 22, 0.46);
}

.ai-assist__agent:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 3px;
}

.ai-assist.is-open .ai-assist__agent {
  display: none;
}

.ai-assist__agent-avatar {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ai-assist__agent-face {
  width: 30px;
  height: 30px;
}

.ai-assist__agent-copy {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-assist__agent-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}

.ai-assist__agent-hint {
  font-size: 12px;
  opacity: 0.78;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-assist__close {
  position: absolute;
  right: max(12px, calc(50% - 280px - 8px));
  bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(20, 24, 32, 0.55);
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.ai-assist.is-open .ai-assist__close {
  display: inline-flex;
}

.ai-assist__close:hover {
  background: rgba(20, 24, 32, 0.75);
}

.ai-assist__model-manage {
  appearance: none;
  width: calc(100% - 4px);
  margin: 6px 2px 2px;
  border: 1px dashed rgba(15, 23, 42, 0.18);
  background: rgba(15, 23, 42, 0.03);
  color: #475569;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.ai-assist__model-manage:hover {
  background: rgba(15, 23, 42, 0.07);
  color: #0f172a;
}

/* —— 模型库管理弹层 —— */
.ai-models-overlay {
  position: fixed;
  inset: 0;
  z-index: 1400;
  background: rgba(10, 14, 22, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.ai-models-overlay[hidden] {
  display: none !important;
}

.ai-models-dialog {
  width: min(720px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  padding: 16px 16px 20px;
  color: #0f172a;
}

.ai-models-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.ai-models-head h2 {
  margin: 0;
  font-size: 18px;
}

.ai-models-close {
  appearance: none;
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: #64748b;
  width: 36px;
  height: 36px;
}

.ai-models-hint {
  margin: 0 0 12px;
  font-size: 12px;
  color: #64748b;
  line-height: 1.45;
}

.ai-models-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.ai-models-btn {
  appearance: none;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #0f172a;
  color: #fff;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.ai-models-btn--ghost {
  background: #fff;
  color: #334155;
}

.ai-models-tier {
  margin-bottom: 18px;
}

.ai-models-tier h3 {
  margin: 0 0 10px;
  font-size: 13px;
  color: #475569;
  font-weight: 700;
}

.ai-models-empty {
  margin: 0;
  font-size: 12px;
  color: #94a3b8;
}

.ai-models-card {
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  background: #f8fafc;
}

.ai-models-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.ai-models-order {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  min-width: 28px;
}

.ai-models-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 13px;
  background: #fff;
}

.ai-models-input--label {
  flex: 1 1 auto;
  font-weight: 600;
}

.ai-models-order-btns {
  display: inline-flex;
  gap: 4px;
}

.ai-models-order-btns button {
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}

.ai-models-order-btns button.is-danger {
  color: #b91c1c;
}

.ai-models-field {
  display: block;
  font-size: 11px;
  color: #64748b;
  margin-bottom: 8px;
}

.ai-models-field .ai-models-input {
  margin-top: 4px;
}

.ai-models-caps {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  margin: 4px 0 10px;
}

.ai-models-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ai-models-caps-preview {
  font-size: 11px;
  color: #64748b;
}

.ai-models-status {
  margin: 8px 0 0;
  font-size: 12px;
  color: #475569;
}

.ai-models-status.is-error {
  color: #b91c1c;
}


@media (max-width: 480px) {
  .ai-assist {
    padding-left: 12px;
    padding-right: 12px;
  }

  .ai-assist__prompt {
    font-size: 12px;
    padding: 9px 14px;
  }

  .ai-assist__close {
    right: 12px;
  }
}
