/* ============================================================
 * Kioto 分身 · 对话弹窗样式（移植自 upstairslife Chat.vue）
 * 跟随 html.dark-theme 类切换暗色模式
 * ============================================================ */

#kioto-chat-root {
  font-family: "Noto Sans SC", system-ui, -apple-system, sans-serif;
}

/* ── 悬浮按钮 ── */
#kioto-chat-root .chat-fab {
  position: fixed;
  right: 32px;
  bottom: 32px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #3eaf7c, #2f9368);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(62, 175, 124, .35);
  transition: transform .2s, box-shadow .2s;
  z-index: 1000;
}
#kioto-chat-root .chat-fab:hover { transform: scale(1.06); box-shadow: 0 8px 26px rgba(62, 175, 124, .45); }
#kioto-chat-root .chat-fab.dark { background: linear-gradient(135deg, #3ecf8f, #05a34f); }
#kioto-chat-root .chat-fab-icon {
  width: 24px;
  height: 24px;
  display: block;
  object-fit: contain;
}
#kioto-chat-root .chat-fab-close {
  color: #fff;
}

/* ── 弹窗 ── */
#kioto-chat-root .chat-panel {
  --bg: #ffffff;
  --panel: #f7f7f8;
  --panel-2: #f0f0f2;
  --border: rgba(0, 0, 0, .08);
  --ink: #333338;
  --ink2: #6a6a72;
  --ink3: #9a9aa2;
  --accent: #3eaf7c;
  --user-grad: linear-gradient(135deg, #3eaf7c, #2f9368);
  --code-bg: #f4f4f6;
  position: fixed;
  right: 24px;
  bottom: 92px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100dvh - 120px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  background: var(--bg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .22);
  z-index: 1001;
  transition: background .3s, color .3s, opacity .2s, transform .22s cubic-bezier(.2,1.4,.4,1);
  opacity: 0;
  transform: translateY(16px) scale(.97);
  pointer-events: none;
}
#kioto-chat-root .chat-panel.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
#kioto-chat-root .chat-panel.dark {
  --bg: #141416;
  --panel: #1d1d21;
  --panel-2: #232327;
  --border: rgba(255, 255, 255, .09);
  --ink: #e8e8ec;
  --ink2: #9a9aa0;
  --ink3: #6a6a70;
  --accent: #3ecf8f;
  --code-bg: #1a1a1e;
}

/* ── 头部 ── */
#kioto-chat-root .chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#kioto-chat-root .chat-title { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; color: var(--ink); }
#kioto-chat-root .chat-logo-img { height: 18px; width: auto; display: block; }
#kioto-chat-root .chat-actions { display: flex; gap: 8px; }
#kioto-chat-root .chat-btn {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink2);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .18s;
}
#kioto-chat-root .chat-btn:hover { color: var(--accent); transform: translateY(-1px); }

/* ── 消息区 ── */
#kioto-chat-root .chat-box {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px 8px;
  position: relative;
}
#kioto-chat-root .chat-box::-webkit-scrollbar { width: 6px; }
#kioto-chat-root .chat-box::-webkit-scrollbar-thumb { background: rgba(120, 120, 160, .25); border-radius: 99px; }

#kioto-chat-root .welcome { text-align: center; padding: 40px 16px 16px; pointer-events: none; }
#kioto-chat-root .welcome-title { font-size: 20px; font-weight: 600; color: var(--accent); margin-bottom: 8px; }
#kioto-chat-root .welcome-tip { font-size: 13px; color: var(--ink3); }

#kioto-chat-root .chat-inner { max-width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
#kioto-chat-root .msg { display: flex; gap: 10px; max-width: 88%; }
#kioto-chat-root .msg.user { align-self: flex-end; flex-direction: row-reverse; }
#kioto-chat-root .msg .ava {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
  border: 1px solid var(--border);
  overflow: hidden;
}
#kioto-chat-root .msg .ava-bot {
  background-image: url('/assets/img/avatar.jpg');
  background-size: cover;
  background-position: center;
  border: none;
}
#kioto-chat-root .msg .ava-user { background: var(--panel-2); }
#kioto-chat-root .ava-img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
#kioto-chat-root .msg .bub {
  position: relative;
  padding: 9px 14px;
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
  border-radius: 16px;
}
#kioto-chat-root .msg.user .bub { background: var(--user-grad); color: #fff; border-bottom-right-radius: 6px; }
#kioto-chat-root .msg.bot .bub { background: var(--panel); border: 1px solid var(--border); border-bottom-left-radius: 6px; }

/* Markdown 内容 */
#kioto-chat-root .msg .bub p { margin: 0 0 6px; }
#kioto-chat-root .msg .bub p:last-child { margin-bottom: 0; }
#kioto-chat-root .msg .bub h1, #kioto-chat-root .msg .bub h2, #kioto-chat-root .msg .bub h3 { font-size: 15px; font-weight: 600; margin: 10px 0 6px; }
#kioto-chat-root .msg .bub ul, #kioto-chat-root .msg .bub ol { margin: 4px 0 8px; padding-left: 22px; }
#kioto-chat-root .msg .bub li { margin: 3px 0; }
#kioto-chat-root .msg .bub code {
  background: var(--code-bg);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
#kioto-chat-root .msg.bot .bub code { color: #2f7d5c; }
#kioto-chat-root .chat-panel.dark .msg.bot .bub code { color: #7ee0b0; }
#kioto-chat-root .msg.user .bub code { background: rgba(255, 255, 255, .22); color: #fff; }
#kioto-chat-root .msg .bub pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  overflow-x: auto;
  margin: 8px 0;
}
#kioto-chat-root .msg .bub pre code { background: none; padding: 0; }
#kioto-chat-root .msg .bub a { color: var(--accent); text-decoration: underline; }
#kioto-chat-root .msg .bub blockquote {
  border-left: 3px solid var(--accent);
  margin: 8px 0;
  padding: 2px 12px;
  color: var(--ink2);
  background: rgba(62, 175, 124, .1);
  border-radius: 0 8px 8px 0;
}
#kioto-chat-root .msg .bub table { border-collapse: collapse; margin: 8px 0; font-size: 13px; display: block; overflow-x: auto; }
#kioto-chat-root .msg .bub th, #kioto-chat-root .msg .bub td { border: 1px solid var(--border); padding: 5px 10px; text-align: left; }
#kioto-chat-root .msg .bub hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
#kioto-chat-root .msg .bub img { max-width: 100%; border-radius: 10px; }

/* 骨架屏 */
#kioto-chat-root .sk-wrap { display: flex; flex-direction: column; gap: 8px; min-width: 180px; }
#kioto-chat-root .sk-line {
  height: 13px;
  border-radius: 7px;
  background: linear-gradient(90deg, rgba(120, 120, 160, .10) 25%, rgba(120, 120, 160, .22) 50%, rgba(120, 120, 160, .10) 75%);
  background-size: 200% 100%;
  animation: kioto-sk-shimmer 1.6s infinite linear;
}
#kioto-chat-root .sk-l1 { width: 100%; }
#kioto-chat-root .sk-l2 { width: 82%; }
#kioto-chat-root .sk-l3 { width: 55%; }
@keyframes kioto-sk-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

#kioto-chat-root .meta { font-size: 10px; color: var(--ink3); margin-top: 6px; padding-left: 4px; }

/* ── 输入区 ── */
#kioto-chat-root .chat-foot { flex-shrink: 0; padding: 8px 12px 12px; border-top: 1px solid var(--border); }
#kioto-chat-root .suggest-wrap {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 0 auto 12px;
}
#kioto-chat-root .sugg {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--ink2);
  font-size: 12.5px;
  cursor: pointer;
  transition: all .18s;
  min-width: 0;
}
#kioto-chat-root .sugg:hover { color: var(--accent); transform: translateY(-1px); }
#kioto-chat-root .sugg i { color: var(--accent); font-size: 12px; flex-shrink: 0; line-height: 1; }
#kioto-chat-root .sugg span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
#kioto-chat-root .chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 auto 10px; }
#kioto-chat-root .chip {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--ink2);
  cursor: pointer;
  transition: all .18s;
}
#kioto-chat-root .chip:hover { color: var(--accent); transform: translateY(-1px); }
#kioto-chat-root .inputbar {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 6px 6px 6px 14px;
  transition: border-color .2s;
}
#kioto-chat-root .inputbar:focus-within { border-color: rgba(62, 175, 124, .55); }
#kioto-chat-root .inputbar textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-size: 14px;
  line-height: 1.6;
  font-family: inherit;
  background: transparent;
  padding: 8px 4px;
  color: var(--ink);
  max-height: 120px;
  overflow: hidden;
}
#kioto-chat-root .inputbar textarea::placeholder { color: var(--ink3); }
#kioto-chat-root .send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--user-grad);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s, opacity .15s;
}
#kioto-chat-root .send:hover { transform: scale(1.06); }
#kioto-chat-root .send:disabled { opacity: .4; cursor: not-allowed; transform: none; }
#kioto-chat-root .hint { text-align: center; font-size: 11px; color: var(--ink3); margin-top: 8px; }
#kioto-chat-root .hint-mock { color: #b08d8a; }
#kioto-chat-root .hint-ok { color: var(--accent); }

/* ── 历史抽屉 ── */
#kioto-chat-root .hist-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
#kioto-chat-root .hist-mask.show { opacity: 1; pointer-events: auto; }
#kioto-chat-root .hist-panel {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: var(--panel);
  border-right: 1px solid var(--border);
  transition: left .28s cubic-bezier(.4, 0, .2, 1);
  z-index: 6;
  padding: 18px;
  overflow-y: auto;
  box-sizing: border-box;
}
#kioto-chat-root .hist-panel.show { left: 0; }
#kioto-chat-root .hist-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--ink);
}
#kioto-chat-root .hist-close { border: none; background: none; color: var(--ink3); font-size: 14px; cursor: pointer; padding: 2px 6px; }
#kioto-chat-root .hist-close:hover { color: var(--accent); }
#kioto-chat-root .hist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all .15s;
}
#kioto-chat-root .hist-item:hover { transform: translateY(-1px); }
#kioto-chat-root .hist-item.active { border-color: rgba(62, 175, 124, .6); }
#kioto-chat-root .hist-info { min-width: 0; }
#kioto-chat-root .hist-title {
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
#kioto-chat-root .hist-date { font-size: 11px; color: var(--ink3); margin-top: 2px; }
#kioto-chat-root .hist-del { border: none; background: none; color: var(--ink3); cursor: pointer; font-size: 13px; padding: 2px 7px; border-radius: 8px; flex-shrink: 0; }
#kioto-chat-root .hist-del:hover { color: #d6336c; background: rgba(214, 51, 108, .12); }
#kioto-chat-root .hist-empty { text-align: center; color: var(--ink3); font-size: 13px; padding: 40px 0; }
#kioto-chat-root .hist-new-wrap { margin-top: 14px; }
#kioto-chat-root .hist-new {
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  border: none;
  background: var(--user-grad);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
#kioto-chat-root .hist-new:hover { opacity: .92; }

/* ── 移动端 ── */
@media (max-width: 640px) {
  #kioto-chat-root .chat-fab { right: 16px; bottom: 16px; width: 48px; height: 48px; }
  #kioto-chat-root .chat-panel {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    height: calc(100dvh - 110px);
    border-radius: 16px;
  }
  #kioto-chat-root .msg { max-width: 92%; }
  #kioto-chat-root .msg .bub { font-size: 15px; }
  #kioto-chat-root .suggest-wrap { grid-template-columns: 1fr; margin-bottom: 10px; }
  #kioto-chat-root .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  #kioto-chat-root .chip { flex-shrink: 0; }
  #kioto-chat-root .inputbar textarea { font-size: 16px; }
}
