/* ============================================================
 * 🐶 狗头军师 · 前端样式（DSH 网页风格：左侧导航 + 主区聊天）
 * ============================================================ */
:root {
  --bg: #0f1115;
  --bg-2: #151922;
  --bg-3: #1c212c;
  --border: #262c3a;
  --border-2: #323a4c;
  --text: #e8ebf2;
  --text-2: #9aa3b5;
  --text-3: #667085;
  --accent: #7c8cf8;
  --accent-2: #5b6cf0;
  --accent-soft: rgba(124, 140, 248, 0.14);
  --green: #4ade80;
  --red: #f87171;
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 264px;
  --mono: "Cascadia Code", Consolas, "SF Mono", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

#app {
  display: flex;
  height: 100vh;
}

/* ================= 左侧导航 ================= */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.side-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px 10px;
}
.logo-emoji { font-size: 26px; }
.logo-text { display: flex; flex-direction: column; line-height: 1.25; }
.logo-text b { font-size: 15px; letter-spacing: 0.5px; }
.logo-text span { font-size: 11px; color: var(--text-3); }

.new-chat {
  margin: 8px 12px 12px;
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: filter 0.15s, transform 0.1s;
}
.new-chat:hover { filter: brightness(1.1); }
.new-chat:active { transform: scale(0.98); }

.side-label {
  padding: 4px 16px 6px;
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 1px;
}

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
}
.conv-list::-webkit-scrollbar { width: 6px; }
.conv-list::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

.conv-item {
  position: relative;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  margin-bottom: 2px;
  color: var(--text-2);
  transition: background 0.12s;
  overflow: hidden;
}
.conv-item:hover { background: var(--bg-3); }
.conv-item.active {
  background: var(--accent-soft);
  border-color: rgba(124, 140, 248, 0.35);
  color: var(--text);
}
.conv-item .conv-title {
  display: block;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 46px;
}
.conv-item .conv-preview {
  display: block;
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.conv-item .conv-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 10.5px;
  color: var(--text-3);
}
.conv-item .conv-del {
  position: absolute;
  right: 6px;
  top: 8px;
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: 13px;
  padding: 2px 5px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.12s;
}
.conv-item:hover .conv-del { opacity: 1; }
.conv-item .conv-del:hover { color: var(--red); background: rgba(248, 113, 113, 0.12); }

.side-foot {
  border-top: 1px solid var(--border);
  padding: 8px;
}
.nav-tab {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 14px;
  transition: background 0.12s;
}
.nav-tab:hover { background: var(--bg-3); }
.nav-tab.active {
  background: var(--accent-soft);
  color: var(--text);
}
.tab-ico { font-size: 16px; }

/* ================= 主区 ================= */
#main {
  flex: 1;
  height: 100%;
  overflow: hidden;
}

.view { display: none; height: 100%; }
.view.active { display: block; }

/* ---- 聊天视图 ---- */
.chat-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0 12px;
  border-bottom: 1px solid var(--border);
}
.chat-title-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.chat-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: text;
}
.chat-actions { display: flex; gap: 8px; }

.chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 20px 4px;
  scroll-behavior: smooth;
}
.chat-msgs::-webkit-scrollbar { width: 6px; }
.chat-msgs::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

.welcome {
  text-align: center;
  padding: 60px 20px 40px;
  color: var(--text-2);
}
.welcome-dog { font-size: 64px; animation: bob 3s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.welcome h2 { color: var(--text); margin: 14px 0 8px; font-size: 22px; }
.welcome p { line-height: 1.9; color: var(--text-2); }
.welcome-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}
.welcome-note {
  margin-top: 26px;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.8;
  background: var(--bg-3);
  border: 1px dashed var(--border-2);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  display: inline-block;
  max-width: 520px;
}
.tag {
  padding: 7px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 999px;
  color: var(--text-2);
  font-size: 12.5px;
  transition: all 0.12s;
}
.tag:hover { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }

.msg { display: flex; flex-direction: column; margin-bottom: 18px; }
.msg.user { align-items: flex-end; }
.msg.ai { align-items: flex-start; }

.msg-time {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--text-3);
  margin-bottom: 4px;
}
.msg.user .msg-time { justify-content: flex-end; }
.msg.ai .msg-time { justify-content: flex-start; }

.msg-edit {
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: 12px;
  padding: 0 2px;
  cursor: pointer;
}
.msg-edit:hover { color: var(--accent); }

.edited-tag {
  font-size: 10px;
  color: var(--text-3);
}

/* 消息操作区（消息下方，始终可见，手机可用） */
.msg-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.msg.user .msg-actions { justify-content: flex-end; }
.msg.ai .msg-actions { justify-content: flex-start; }
.action-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-3);
  font-size: 11.5px;
  padding: 3px 10px;
  cursor: pointer;
  transition: all 0.12s;
}
.action-btn:hover { border-color: var(--accent); color: var(--text); }
.action-btn.liked {
  border-color: #fbbf24;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.08);
}

/* 修改消息的编辑框 */
.edit-area {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 13.5px;
  line-height: 1.7;
  resize: vertical;
  outline: none;
  font-family: inherit;
}
.edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}
.btn-small { padding: 6px 12px; font-size: 12.5px; }

/* AI 回复版本切换箭头（放在操作区里） */
.reply-versions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ver-arrow {
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  color: var(--text-2);
  border-radius: 6px;
  width: 24px;
  height: 22px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.12s;
}
.ver-arrow:hover { border-color: var(--accent); color: var(--text); }
.ver-info { font-size: 10.5px; color: var(--text-3); }

.bubble {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: var(--radius);
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
}
.msg.user .bubble {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.ai .bubble {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg.ai .bubble b, .msg.ai .bubble strong { color: var(--accent); }
.msg.ai .bubble h1, .msg.ai .bubble h2, .msg.ai .bubble h3 {
  margin: 10px 0 6px; font-size: 15px; color: var(--text);
}
.msg.ai .bubble hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.msg.ai .bubble blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  color: var(--text-2);
  margin: 8px 0;
}

.msg-time {
  font-size: 10.5px;
  color: var(--text-3);
  margin-top: 4px;
  text-align: right;
}
.msg.ai .msg-time { text-align: left; }

.mock-tag {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  padding: 2px 8px;
  border-radius: 999px;
}

.typing .dot {
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--text-3);
  animation: blink 1.2s infinite;
}
.typing .dot:nth-child(2) { animation-delay: 0.2s; }
.typing .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100% { opacity: 0.2; } 40% { opacity: 1; } }
.typing-timer {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 6px;
}

/* 系统提示条（停止/超时等） */
.sys-note {
  color: var(--text-2);
  border: 1px dashed var(--border-2) !important;
  font-size: 12.5px;
}

/* ---- 输入区 ---- */
.chat-input-area {
  padding: 12px 0 16px;
  border-top: 1px solid var(--border);
}
.input-hint {
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-2);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  line-height: 1.7;
}
#chatInput {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--text);
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.6;
  resize: none;
  outline: none;
  max-height: 160px;
  transition: border-color 0.12s;
}
#chatInput:focus { border-color: var(--accent); }
.input-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}
.input-tip { font-size: 11px; color: var(--text-3); }
.send-group { display: flex; gap: 8px; align-items: center; }
.send-btn {
  padding: 9px 26px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: filter 0.15s;
}
.send-btn:hover:not(:disabled) { filter: brightness(1.1); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.stop-btn {
  padding: 9px 18px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  transition: filter 0.15s;
}
.stop-btn:hover { filter: brightness(1.12); }
.hidden { display: none !important; }

/* ================= 设置视图 ================= */
.settings-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 26px 24px 30px;
  height: 100%;
  overflow-y: auto;
}
.settings-wrap::-webkit-scrollbar { width: 6px; }
.settings-wrap::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

.settings-title {
  font-size: 20px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

/* 语言切换栏（设置页顶部） */
.lang-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 14px;
}
.lang-label { font-size: 13px; color: var(--text-2); }
.lang-switch {
  display: flex;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 500;
  padding: 4px 14px;
  border-radius: 999px;
  transition: all 0.15s;
  cursor: pointer;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

.settings-top {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 14px;
}

.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card h2 { font-size: 15px; margin-bottom: 14px; color: var(--text); }

label {
  display: block;
  font-size: 12.5px;
  color: var(--text-2);
  margin: 12px 0 6px;
}
input[type="text"], input[type="password"], input:not([type]), textarea {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.12s;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; line-height: 1.7; }

.preset-row { display: flex; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.preset {
  padding: 7px 16px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13px;
  transition: all 0.12s;
}
.preset:hover { border-color: var(--accent); color: var(--text); }
.preset.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}
#detailSlider { flex: 1; accent-color: var(--accent); height: 4px; }
.detail-label {
  min-width: 44px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(124, 140, 248, 0.35);
  padding: 4px 10px;
  border-radius: 999px;
}
.slider-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-3);
}
.tip { font-size: 11.5px; color: var(--text-3); margin-top: 8px; line-height: 1.7; }
#detailDesc { margin-top: 10px; }

.mem-desc { font-size: 12.5px; color: var(--text-2); max-width: 80%; line-height: 1.7; }

/* 开关 */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute;
  inset: 0;
  background: var(--border-2);
  border-radius: 999px;
  transition: background 0.2s;
  cursor: pointer;
}
.switch .slider::before {
  content: "";
  position: absolute;
  width: 20px; height: 20px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* 按钮 */
.ghost-btn {
  padding: 8px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13px;
  transition: all 0.12s;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--text); }
.ghost-btn.danger:hover { border-color: var(--red); color: var(--red); }
.primary-btn {
  padding: 8px 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  transition: filter 0.15s;
}
.primary-btn:hover { filter: brightness(1.1); }
.primary-btn.big { padding: 11px 26px; font-size: 14.5px; }

.icon-btn {
  background: transparent;
  border: none;
  font-size: 14px;
  color: var(--text-3);
  padding: 4px 6px;
  border-radius: 4px;
}
.icon-btn:hover { color: var(--text); background: var(--bg-3); }

.settings-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 16px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
}

.test-result { font-size: 12px; color: var(--text-2); }
.test-result.ok { color: var(--green); }
.test-result.err { color: var(--red); }

/* ================= Toast ================= */
#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 100;
  max-width: 80vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ================= 小屏适配 ================= */
@media (max-width: 720px) {
  #sidebar { width: 72px; min-width: 72px; }
  .logo-text, .side-label, .tab-txt, .new-chat { display: none; }
  .new-chat { padding: 10px; font-size: 16px; }
  .conv-item .conv-preview, .conv-item .conv-meta { display: none; }
  .conv-item .conv-title { padding-right: 0; }
  .bubble { max-width: 92%; }
  .chat-wrap { padding: 0 10px; }
}
