:root {
  --bg: #ffffff;
  --text: #1f2023;
  --muted: #8e8ea0;
  --border: #e5e5e6;
  --accent: #10a37f;
  --accent-soft: #e7f7f1;
  --side-bg: #1f2023;
  --side-text: #ececf1;
  --side-muted: #9b9ba7;
  --side-hover: #2a2b32;
  --user-bubble: #10a37f;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.05);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 260px; flex-shrink: 0; background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; padding: 12px; gap: 8px;
}
.new-chat {
  background: var(--side-hover); color: var(--side-text); border: 1px solid #3a3b42;
  padding: 12px; border-radius: 10px; cursor: pointer; font-size: 14px; text-align: left;
  transition: background .15s;
}
.new-chat:hover { background: #34353d; }
.side-section { flex: 1; overflow-y: auto; margin-top: 6px; }
.side-title { font-size: 12px; color: var(--side-muted); padding: 8px 6px 4px; text-transform: uppercase; letter-spacing: .04em; }
.side-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.side-list li {
  padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--side-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px;
}
.side-list li:hover { background: var(--side-hover); }
.side-list li .del { margin-left: auto; color: var(--side-muted); opacity: 0; font-size: 12px; }
.side-list li:hover .del { opacity: 1; }
.side-list li.fav-item { white-space: normal; }
.side-list .empty { color: var(--side-muted); font-size: 12px; padding: 6px 10px; cursor: default; }
.side-settings {
  background: transparent; color: var(--side-text); border: 1px solid #3a3b42;
  padding: 10px; border-radius: 10px; cursor: pointer; font-size: 14px; text-align: left;
}
.side-settings:hover { background: var(--side-hover); }

/* ---------- 主区域 ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.main-head { border-bottom: 1px solid var(--border); padding: 12px 20px 10px; }
.head-top { display: flex; align-items: center; justify-content: space-between; }
.head-top h1 { font-size: 18px; margin: 0; }
.ghost-btn { background: transparent; border: 1px solid var(--border); color: var(--text); padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.ghost-btn:hover { background: #f5f5f5; }

.modes { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 8px; }
.mode-tab {
  background: #f3f3f3; border: 1px solid transparent; color: var(--text);
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: 13px; transition: all .15s;
}
.mode-tab:hover { background: #e9e9e9; }
.mode-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.controls { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.ctl { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.ctl select { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text); font-size: 13px; }
.chk { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 5px; cursor: pointer; }
.mode-hint { font-size: 12px; color: var(--muted); margin-left: auto; }

/* ---------- 聊天区 ---------- */
.chat { flex: 1; overflow-y: auto; padding: 24px 0; }
.welcome { max-width: 720px; margin: 6vh auto 0; padding: 0 20px; text-align: center; }
.welcome h2 { font-size: 26px; margin: 0 0 10px; }
.welcome p { color: var(--muted); line-height: 1.6; margin: 0 0 24px; }

.msg { width: 100%; max-width: 820px; margin: 0 auto; padding: 16px 20px; display: flex; gap: 14px; }
.msg .avatar { width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.msg.user { background: #fafafa; }
.msg.user .avatar { background: var(--accent); color: #fff; }
.msg.assistant .avatar { background: #ececf1; }
.msg .body { flex: 1; min-width: 0; line-height: 1.7; font-size: 15px; }
.msg .body p { margin: 0 0 10px; }
.msg .body p:last-child { margin-bottom: 0; }
.msg .body h3 { font-size: 15px; margin: 14px 0 6px; }
.msg .body ul, .msg .body ol { margin: 6px 0 10px; padding-left: 22px; }
.msg .body li { margin: 3px 0; }
.msg .body code { background: #f0f0f0; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.msg .body pre { background: #f6f8fa; padding: 12px; border-radius: 8px; overflow-x: auto; }
.msg .body pre code { background: transparent; padding: 0; }
.msg .body .orig { background: #fff8e6; border-left: 3px solid #f0c059; padding: 8px 12px; border-radius: 6px; color: #6b5a2e; font-size: 13px; margin-bottom: 10px; }

.msg-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.msg-actions button {
  background: #fff; border: 1px solid var(--border); color: var(--muted);
  padding: 4px 10px; border-radius: 7px; cursor: pointer; font-size: 12px; transition: all .15s;
}
.msg-actions button:hover { color: var(--text); border-color: #cfcfcf; }
.cursor::after { content: '▋'; animation: blink 1s steps(2) infinite; color: var(--muted); }
@keyframes blink { 0%,50%{opacity:1} 50.01%,100%{opacity:0} }

/* ---------- 输入区 ---------- */
.composer { border-top: 1px solid var(--border); padding: 12px 20px 16px; background: var(--bg); }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.qchip { background: #f3f3f3; border: 1px solid transparent; color: var(--text); padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 12px; }
.qchip:hover { background: #e9e9e9; }
.input-row { display: flex; gap: 10px; align-items: flex-end; max-width: 820px; margin: 0 auto; }
#input {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
  font-size: 15px; font-family: inherit; line-height: 1.5; max-height: 200px; outline: none;
}
#input:focus { border-color: var(--accent); }
.send-btn { background: var(--accent); color: #fff; border: none; width: 44px; height: 44px; border-radius: 12px; cursor: pointer; font-size: 18px; flex-shrink: 0; }
.send-btn:hover { background: #0e8f6e; }
.send-btn:disabled { opacity: .5; cursor: default; }

/* ---------- 设置弹窗 ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal.hidden { display: none; }
.modal-card { background: #fff; width: 440px; max-width: 92vw; border-radius: 14px; padding: 22px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field input { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.field small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.4; }
.settings-status { font-size: 13px; min-height: 18px; margin-bottom: 10px; }
.settings-status.ok { color: var(--accent); }
.settings-status.err { color: #d9483b; }
.primary-btn { width: 100%; background: var(--accent); color: #fff; border: none; padding: 11px; border-radius: 9px; cursor: pointer; font-size: 14px; font-weight: 600; }
.primary-btn:hover { background: #0e8f6e; }

/* 通用隐藏（线上版用于隐藏保存按钮） */
.hidden { display: none !important; }
input:disabled { background: #f2f4f7; color: #8a94a6; cursor: not-allowed; }
