* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #2f54eb;
  --primary-dark: #1d39c4;
  --bg: #f5f6fa;
  --sidebar-bg: #20242f;
  --text: #26292f;
  --text-dim: #8a909e;
  --border: #e5e8ef;
}
body {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg); color: var(--text); height: 100vh; overflow: hidden;
}
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-wrap { height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2f54eb 0%, #1d39c4 100%); }
.login-card { background: #fff; padding: 42px 40px; border-radius: 16px; width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); text-align: center; }
.login-logo { font-size: 44px; margin-bottom: 8px; }
.login-card h1 { font-size: 21px; margin-bottom: 4px; }
.login-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 26px; }
.login-card input { width: 100%; padding: 12px 14px; margin-bottom: 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; outline: none; }
.login-card input:focus { border-color: var(--primary); }
.login-error { color: #e02020; font-size: 13px; min-height: 18px; margin-bottom: 8px; }

.btn-primary { background: var(--primary); color: #fff; border: none; padding: 12px 22px;
  border-radius: 8px; font-size: 15px; cursor: pointer; width: 100%; transition: background .15s; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: #a3b1e8; cursor: not-allowed; }

/* ---------- 布局 ---------- */
.chat-wrap { display: flex; height: 100vh; }
.sidebar { width: 260px; background: var(--sidebar-bg); color: #cfd3dd; display: flex; flex-direction: column; }
.sidebar-head { padding: 18px 16px; font-size: 15px; font-weight: 600; color: #fff; }
.data-note { font-size: 11px; font-weight: 400; color: #8a93a6; line-height: 1.6; margin-top: 8px; }
.btn-new { margin: 0 12px 12px; padding: 10px; background: var(--primary); color: #fff; border: none;
  border-radius: 8px; font-size: 14px; cursor: pointer; }
.btn-new:hover { background: var(--primary-dark); }
.conv-list { flex: 1; overflow-y: auto; padding: 0 8px; }
.conv-item { display: flex; align-items: center; padding: 9px 10px; border-radius: 7px; cursor: pointer;
  font-size: 13px; margin-bottom: 2px; }
.conv-item:hover { background: #2b303d; }
.conv-item.active { background: #34405a; color: #fff; }
.conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-del { background: none; border: none; color: #8a909e; font-size: 15px; cursor: pointer; visibility: hidden; }
.conv-item:hover .conv-del { visibility: visible; }
.conv-del:hover { color: #ff7875; }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid #2b303d; font-size: 13px;
  display: flex; justify-content: space-between; align-items: center; }
.btn-link { background: none; border: none; color: #8a909e; cursor: pointer; font-size: 13px; }
.btn-link:hover { color: #fff; }

/* ---------- 主区 ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.messages { flex: 1; overflow-y: auto; padding: 24px 8%; }
.welcome { max-width: 680px; margin: 40px auto; text-align: center; }
.welcome h2 { font-size: 22px; margin-bottom: 10px; }
.welcome p { color: var(--text-dim); margin-bottom: 18px; }
.examples { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.example { background: #fff; border: 1px solid var(--border); border-radius: 20px; padding: 9px 16px;
  font-size: 13px; cursor: pointer; transition: all .15s; }
.example:hover { border-color: var(--primary); color: var(--primary); }

.msg { display: flex; flex-direction: column; margin-bottom: 18px; max-width: 860px; }
.msg.user { align-items: flex-end; margin-left: auto; }
.msg.assistant { align-items: flex-start; margin-right: auto; }
.bubble { padding: 11px 16px; border-radius: 12px; font-size: 14.5px; line-height: 1.65; max-width: 100%; }
.msg.user .bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.assistant .bubble { background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble.thinking { color: var(--text-dim); }
.bubble.thinking::after { content: '▋'; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* markdown */
.md p { margin: 4px 0; }
.md h4 { margin: 10px 0 4px; font-size: 15px; }
.md ul { margin: 6px 0 6px 22px; }
.md li { margin: 2px 0; }
.md code { background: #f0f2f8; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.md-gap { height: 6px; }
.md-code { background: #282c34; color: #dfe3ea; padding: 12px; border-radius: 8px; overflow-x: auto; margin: 8px 0; font-size: 13px; }
.md-table { border-collapse: collapse; margin: 10px 0; font-size: 13.5px; display: block; overflow-x: auto; max-width: 100%; }
.md-table td { border: 1px solid var(--border); padding: 6px 12px; white-space: nowrap; }
.md-table .md-th td { background: #f0f3fb; font-weight: 600; }

/* 查询过程 */
.steps { margin-bottom: 6px; font-size: 12.5px; max-width: 100%; }
.steps summary { cursor: pointer; color: var(--text-dim); user-select: none; padding: 4px 0; }
.steps summary:hover { color: var(--primary); }
.step { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin: 6px 0; }
.step-info { margin-bottom: 4px; font-size: 12px; }
.step-ok { color: #389e0d; }
.step-err { color: #e02020; }
.step-sql { font-size: 12px; background: #f7f8fb; padding: 8px; border-radius: 6px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.live-step { font-size: 12.5px; color: var(--text-dim); padding: 3px 0; }
.live-step code { background: #f0f2f8; padding: 1px 5px; border-radius: 4px; }

/* 输入区 */
.composer { display: flex; gap: 10px; padding: 14px 8% 6px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 14.5px; font-family: inherit; outline: none; max-height: 140px; }
.composer textarea:focus { border-color: var(--primary); }
.composer .btn-primary { width: auto; padding: 12px 26px; }
.tip { text-align: center; color: #b3b8c4; font-size: 11.5px; padding-bottom: 10px; }

/* ---------- 修改密码弹窗 ---------- */
.sidebar-actions { display: flex; gap: 12px; }
.modal-mask { position: fixed; inset: 0; background: rgba(15,18,28,.55); z-index: 50;
  display: flex; align-items: center; justify-content: center; }
.modal-card { background: #fff; border-radius: 14px; width: 340px; padding: 28px 28px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-card h3 { font-size: 17px; margin-bottom: 18px; text-align: center; }
.modal-card input { width: 100%; padding: 11px 13px; margin-bottom: 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; outline: none; }
.modal-card input:focus { border-color: var(--primary); }
.modal-msg { font-size: 13px; min-height: 20px; margin-bottom: 10px; text-align: center; }
.modal-msg.err { color: #e02020; }
.modal-msg.ok { color: #389e0d; }
.modal-btns { display: flex; gap: 10px; }
.btn-ghost { flex: 1; background: #f2f4f9; color: var(--text); border: none; padding: 11px 0;
  border-radius: 8px; font-size: 14px; cursor: pointer; }
.btn-ghost:hover { background: #e5e8f0; }
.modal-btns .btn-primary { flex: 1.4; padding: 11px 0; }
