/* ==========================================================================
   KiloIdea 助手「小K」聊天挂件样式
   视觉令牌：主色 #3B5BDB，无 emoji，克制专业。跟随站点明暗主题。
   仅作用于 #kib-assistant 作用域，不污染站点其它样式。
   ========================================================================== */
#kib-assistant {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 2147483000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
#kib-assistant * { box-sizing: border-box; }

/* 悬浮按钮 */
#kib-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #3B5BDB;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(59, 91, 219, .4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s ease;
}
#kib-fab:hover { transform: scale(1.06); }
#kib-fab svg { width: 24px; height: 24px; }

/* 对话面板 */
#kib-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: #fff;
  color: #1a1a1a;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #e6e8ef;
}
#kib-assistant.open #kib-panel { display: flex; }

/* 头 */
#kib-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #3B5BDB;
  color: #fff;
}
#kib-header .title { font-weight: 600; font-size: 14px; }
#kib-header .sub { font-size: 11px; opacity: .85; margin-top: 2px; }
#kib-close {
  background: transparent; border: none; color: #fff;
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
}

/* 消息区 */
#kib-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.kib-msg {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.kib-msg.user { align-self: flex-end; background: #3B5BDB; color: #fff; border-bottom-right-radius: 4px; }
.kib-msg.bot { align-self: flex-start; background: #f0f2f8; color: #1a1a1a; border-bottom-left-radius: 4px; }
.kib-msg.thinking { opacity: .7; font-style: italic; }
.kib-msg.error { background: #fdecec; color: #b42318; }

/* 输入区 */
#kib-input {
  display: flex; gap: 8px;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid #e6e8ef;
}
#kib-text {
  flex: 1;
  resize: none;
  border: 1px solid #d6dae6;
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: #1a1a1a;
  outline: none;
  max-height: 120px;
}
#kib-text:focus { border-color: #3B5BDB; }
#kib-send {
  background: #3B5BDB;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 16px;
  font-size: 13px;
  cursor: pointer;
}
#kib-send:disabled { opacity: .5; cursor: not-allowed; }
#kib-foot { font-size: 10px; text-align: center; color: #9aa0ad; padding: 0 0 8px; }

/* 暗色主题（跟随 html.dark） */
#kib-assistant.dark #kib-panel { background: #1f2024; color: #f2f2f2; border-color: #333; }
#kib-assistant.dark .kib-msg.bot { background: #2b2d33; color: #f2f2f2; }
#kib-assistant.dark #kib-input { border-top-color: #333; }
#kib-assistant.dark #kib-text { background: #2b2d33; color: #f2f2f2; border-color: #3a3d45; }
#kib-assistant.dark #kib-foot { color: #6b7280; }

/* 移动端适配（窄屏 ≤480px）：面板占满底部，避免定位偏移与窄边距 */
@media (max-width: 480px) {
  #kib-assistant { right: 16px; bottom: 16px; }
  #kib-panel {
    position: fixed;
    left: 0; right: 0; top: 0; bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
    bottom: 0;
  }
  /* 面板展开时隐藏悬浮按钮，避免遮挡 */
  #kib-assistant.open #kib-fab { display: none; }
  /* 16px 字号防止 iOS 聚焦时页面缩放 */
  #kib-text { font-size: 16px; }
  #kib-send { font-size: 15px; padding: 0 18px; }
}
