/* ==========================================================================
   assistant.css —— 全站 AI 学习助手(悬浮球 + 对话面板) + /ask 页共用样式
   ==========================================================================
   配色全部取 theme.css 的变量;本文件不定义主题,只定义助手自己的布局。
   ========================================================================== */

/* ---------------- 悬浮球 ---------------- */

.xgai-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  width: 54px;
  height: 54px;
  border: 1px solid var(--gold-2);
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #FFFDF8, #F1E6CE 60%, #E3D2AC);
  box-shadow: 0 8px 24px rgba(60, 45, 20, .18), inset 0 0 0 4px rgba(255, 253, 248, .7);
  color: var(--gold);
  font-family: var(--font-sans);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .02em;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.xgai-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 28px rgba(60, 45, 20, .24); }
.xgai-fab:active { transform: scale(.97); }
.xgai-fab.is-open { font-size: 22px; }
.xgai-fab-dot {
  position: absolute; right: 3px; top: 3px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--violet); box-shadow: 0 0 0 2px var(--paper, #F6F2E9);
}

/* ---------------- 面板 ---------------- */

.xgai-panel {
  position: fixed;
  right: 20px;
  bottom: 86px;
  z-index: 80;
  width: min(392px, calc(100vw - 32px));
  height: min(600px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: var(--panel-solid);
  border: 1px solid var(--line-2);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(50, 38, 18, .22);
  overflow: hidden;
  animation: xgai-in .18s var(--ease-out);
}
@keyframes xgai-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.xgai-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(154, 118, 52, .07), transparent);
}
.xgai-title { font-size: 14px; font-weight: 700; color: var(--white); letter-spacing: .02em; }
.xgai-title small { display: block; margin-top: 2px; font-size: 10.5px; font-weight: 400; color: var(--ink-3); letter-spacing: .06em; }
.xgai-tools { display: flex; align-items: center; gap: 6px; }
.xgai-tools a, .xgai-tools button {
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--ink-2);
  font-size: 11.5px;
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}
.xgai-tools a:hover, .xgai-tools button:hover { color: var(--gold); border-color: var(--gold-2); }

.xgai-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.xgai-msg { display: flex; }
.xgai-msg--user { justify-content: flex-end; }
.xgai-bubble {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line);
  word-break: break-word;
}
.xgai-msg--user .xgai-bubble {
  background: rgba(154, 118, 52, .10);
  border-color: rgba(154, 118, 52, .28);
}
.xgai-bubble p { margin: 0 0 6px; }
.xgai-bubble p:last-child { margin-bottom: 0; }
.xgai-bubble .xgai-gap { height: 2px; margin: 0; }
.xgai-bubble h4 { margin: 8px 0 4px; font-size: 13px; color: var(--white); }
.xgai-bubble ul { margin: 4px 0 6px; padding-left: 18px; }
.xgai-bubble li { margin: 2px 0; }
.xgai-bubble b { color: var(--gold); }

.xgai-sys {
  align-self: center;
  max-width: 92%;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(107, 74, 158, .07);
  border: 1px dashed rgba(107, 74, 158, .28);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}
.xgai-sys a, .xgai-sys button {
  display: inline-block;
  margin-top: 6px;
  color: var(--violet);
  border: 1px solid rgba(107, 74, 158, .35);
  background: transparent;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
}

.xgai-cites { margin-top: 4px; display: flex; flex-direction: column; gap: 3px; }
.xgai-cite {
  font-size: 11.5px;
  color: var(--ink-3);
  border-left: 2px solid var(--gold-3);
  padding-left: 7px;
}
.xgai-cite summary { cursor: pointer; list-style: none; color: var(--gold); }
.xgai-cite summary::-webkit-details-marker { display: none; }
.xgai-cite p { margin: 4px 0 2px; color: var(--ink-3); line-height: 1.6; }

.xgai-loading { display: inline-flex; gap: 4px; align-items: center; padding: 6px 2px; }
.xgai-loading i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--gold-2); animation: xgai-bounce 1s infinite ease-in-out;
}
.xgai-loading i:nth-child(2) { animation-delay: .15s; }
.xgai-loading i:nth-child(3) { animation-delay: .3s; }
@keyframes xgai-bounce { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.xgai-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 248, .7);
}
.xgai-input {
  flex: 1;
  resize: none;
  max-height: 96px;
  min-height: 38px;
  padding: 9px 11px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: #FFFDF8;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  outline: none;
}
.xgai-input:focus { border-color: var(--gold-2); box-shadow: 0 0 0 3px var(--gold-dim); }
.xgai-send {
  border: 1px solid var(--gold-2);
  background: var(--gold);
  color: #FFFDF8;
  font-size: 13px;
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
}
.xgai-send:disabled { opacity: .5; cursor: default; }
.xgai-note { margin: 0; padding: 0 12px 7px; font-size: 10.5px; color: var(--ink-3); text-align: center; }

/* ---------------- /ask 完整页 ---------------- */

.ask-wrap {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.ask-side { display: flex; flex-direction: column; gap: 12px; }
.ask-side-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 16px;
}
.ask-side-card h3 { margin: 0 0 8px; font-size: 14px; color: var(--white); }
.ask-side-card p { margin: 0 0 8px; font-size: 12.5px; line-height: 1.8; color: var(--ink-3); }
.ask-side-card p:last-child { margin-bottom: 0; }
.ask-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ask-chip {
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--ink-2);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}
.ask-chip:hover { border-color: var(--gold-2); color: var(--gold); }

.ask-chat {
  display: flex;
  flex-direction: column;
  min-height: 60vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-solid);
  overflow: hidden;
}
.ask-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 380px;
  max-height: 58vh;
}
.ask-msgs .xgai-bubble { max-width: 86%; font-size: 13.5px; }
.ask-msgs .xgai-msg--user { justify-content: flex-end; }
.ask-form { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); }
.ask-form .xgai-input { min-height: 44px; }

.ask-welcome { text-align: center; color: var(--ink-3); padding: 26px 12px; }
.ask-welcome h3 { color: var(--white); margin: 0 0 8px; font-size: 16px; }
.ask-welcome p { margin: 0 auto; max-width: 480px; font-size: 12.5px; line-height: 1.9; }

@media (max-width: 860px) {
  .ask-wrap { grid-template-columns: 1fr; }
  .ask-side { order: 2; }
  .ask-msgs { max-height: 54vh; }
}

@media (max-width: 640px) {
  .xgai-fab { right: 14px; bottom: 14px; width: 48px; height: 48px; font-size: 15px; }
  .xgai-panel {
    right: 0; bottom: 0; left: 0; top: 0;
    width: 100%; height: 100%;
    border-radius: 0;
    border: none;
  }
}


/* 接收论坛帖子拖拽 */
.xgai-panel.is-over { outline: 2px dashed var(--gold-2); outline-offset: -4px; }
.xgai-fab.is-over { transform: scale(1.08); box-shadow: 0 0 0 4px var(--gold-dim), 0 10px 26px rgba(60, 45, 20, .22); }
