:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --line: #e8eaee;
  --text: #1f2329;
  --text-2: #6b7280;
  --accent: #1a7f5a;
  --accent-soft: #e8f5ef;
  --user-bg: #1a7f5a;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; height: 100vh; overflow: hidden; }

/* ---------- 侧栏 ---------- */
.sidebar {
  width: 260px;
  flex: 0 0 260px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 14px; }
.logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #1a7f5a, #2fa878);
  color: #fff; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-weight: 650; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--text-2); margin-top: 1px; }

.btn-new {
  width: 100%; padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  font-size: 13px; font-weight: 550; cursor: pointer; text-align: left;
  transition: background .15s, border-color .15s;
}
.btn-new:hover { background: var(--accent-soft); border-color: #cfe9dd; }

.section-label {
  font-size: 11px; color: var(--text-2); margin: 18px 6px 8px;
  letter-spacing: .3px;
}

.conv-list { flex: 1; overflow-y: auto; min-height: 0; }

.conv-item {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer;
  color: var(--text); font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-item:hover { background: #f2f4f7; }
.conv-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.conv-item .del {
  margin-left: auto; opacity: 0; color: var(--text-2);
  border: none; background: none; cursor: pointer; font-size: 15px; line-height: 1;
}
.conv-item:hover .del { opacity: 1; }

.sidebar-foot { border-top: 1px solid var(--line); padding-top: 12px; }

.btn-kb {
  width: 100%; padding: 9px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  font-size: 13px; cursor: pointer; display: flex; align-items: center; gap: 6px;
}
.btn-kb:hover { background: #f2f4f7; }
.badge {
  margin-left: auto; background: var(--accent-soft); color: var(--accent);
  font-size: 11px; padding: 1px 7px; border-radius: 9px;
}

.kb-panel { margin-top: 10px; }
.upload-box {
  display: block; text-align: center; padding: 14px 8px;
  border: 1px dashed #cfd4dc; border-radius: 8px;
  color: var(--text-2); font-size: 12px; cursor: pointer;
}
.upload-box:hover { border-color: var(--accent); color: var(--accent); }
.kb-list { margin-top: 8px; max-height: 160px; overflow-y: auto; }
.kb-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-2); padding: 5px 4px;
  border-bottom: 1px solid #f2f4f7;
}
.kb-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-item button {
  margin-left: auto; border: none; background: none; color: #b0b6c0;
  cursor: pointer; font-size: 13px;
}
.kb-item button:hover { color: #d14343; }

.hidden { display: none !important; }

/* ---------- 主区 ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 52px; flex: 0 0 52px;
  border-bottom: 1px solid var(--line); background: var(--panel);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
}
.topbar-left { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #2fa878; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.switch { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.switch input { accent-color: var(--accent); }
.model-select {
  border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px;
  font-size: 12.5px; background: #fff; color: var(--text); cursor: pointer;
  font-family: inherit;
}

.messages { flex: 1; overflow-y: auto; padding: 28px 0 12px; }
.welcome { max-width: 720px; margin: 40px auto 0; padding: 0 28px; }
.welcome h1 { font-size: 24px; font-weight: 650; margin-bottom: 8px; }
.welcome p { color: var(--text-2); font-size: 14px; line-height: 1.7; }

.preset-grid {
  margin-top: 26px; display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
}
.preset {
  text-align: left; padding: 14px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.preset:hover { border-color: #bfe0d1; box-shadow: var(--shadow); transform: translateY(-1px); }
.preset-t { display: block; font-size: 13.5px; font-weight: 550; color: var(--text); }
.preset-d { display: block; font-size: 12px; color: var(--text-2); margin-top: 3px; }

.msg { max-width: 720px; margin: 0 auto 22px; padding: 0 28px; display: flex; gap: 12px; }
.msg .avatar {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 650; color: #fff;
}
.msg.user .avatar { background: #4b5563; }
.msg.assistant .avatar { background: linear-gradient(135deg, #1a7f5a, #2fa878); }
.msg .bubble { flex: 1; min-width: 0; padding-top: 4px; }
.msg .role { font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.msg .content { font-size: 14px; line-height: 1.75; word-wrap: break-word; }
.msg .content p { margin: 0 0 10px; }
.msg .content p:last-child { margin-bottom: 0; }
.msg .content code {
  background: #f2f4f7; padding: 1.5px 5px; border-radius: 4px;
  font-family: "Cascadia Code", Consolas, monospace; font-size: 12.5px;
}
.msg .content pre {
  background: #1f2329; color: #e6e8eb; padding: 12px 14px; border-radius: 8px;
  overflow-x: auto; margin: 10px 0;
}
.msg .content pre code { background: none; padding: 0; color: inherit; }
.msg .content ul, .msg .content ol { padding-left: 20px; margin: 8px 0; }
.msg .content li { margin: 4px 0; }
.msg .content h3 { font-size: 15px; margin: 12px 0 6px; }
.msg .content strong { font-weight: 650; }
.cursor {
  display: inline-block; width: 7px; height: 15px; background: var(--accent);
  vertical-align: -2px; animation: blink 1s steps(2) infinite; border-radius: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

.typing { color: var(--text-2); font-size: 13px; }

.notice {
  display: inline-block; margin-bottom: 8px; padding: 4px 10px;
  background: #fff7e6; color: #ad6800; border: 1px solid #ffe1a8;
  border-radius: 6px; font-size: 12px;
}

/* ---------- 输入区 ---------- */
.composer { flex: 0 0 auto; padding: 8px 28px 18px; }
.composer-inner {
  max-width: 720px; margin: 0 auto; display: flex; gap: 10px; align-items: flex-end;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 10px 10px 16px; box-shadow: var(--shadow);
  transition: border-color .15s;
}
.composer-inner:focus-within { border-color: #9fd3bd; }
#input {
  flex: 1; border: none; outline: none; resize: none;
  font-family: inherit; font-size: 14px; line-height: 1.6;
  color: var(--text); background: transparent; max-height: 160px;
}
.btn-send {
  flex: 0 0 auto; border: none; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 550;
  padding: 8px 16px; cursor: pointer; transition: background .15s;
}
.btn-send:hover { background: #157049; }
.btn-send:disabled { background: #c3cad3; cursor: not-allowed; }
.hint { max-width: 720px; margin: 8px auto 0; text-align: center; font-size: 11px; color: #9aa1ab; }

@media (max-width: 820px) {
  .sidebar { display: none; }
  .preset-grid { grid-template-columns: 1fr; }
  .msg, .composer { padding-left: 16px; padding-right: 16px; }
}


/* ---------------- 登录 ---------------- */
.login-gate{
  position:fixed; inset:0; z-index:9999; overflow:hidden;
  display:flex; align-items:center; justify-content:center;
  background:#f4f5f7;
}
.login-gate.hidden{ display:none; }

.login-bg{ position:absolute; inset:0; pointer-events:none; }
.login-bg .blob{ position:absolute; border-radius:50%; filter:blur(72px); opacity:.5; }
.login-bg .b1{
  width:540px; height:540px; left:-150px; top:-190px;
  background:radial-gradient(circle,#ffd9a8 0%,rgba(255,217,168,0) 68%);
}
.login-bg .b2{
  width:600px; height:600px; right:-190px; bottom:-230px;
  background:radial-gradient(circle,#c3dcff 0%,rgba(195,220,255,0) 68%);
}

/* ---------- 卡片 ---------- */
.login-card{
  position:relative; width:380px; max-width:calc(100vw - 40px);
  padding:30px 30px 0; border-radius:16px;
  background:#fff; border:1px solid rgba(16,24,40,.05);
  box-shadow:0 2px 4px rgba(16,24,40,.03), 0 20px 48px -18px rgba(16,24,40,.20);
  display:flex; flex-direction:column;
  animation:cardIn .3s cubic-bezier(.22,.9,.3,1) both;
}
@keyframes cardIn{ from{opacity:0; transform:translateY(8px)} to{opacity:1; transform:none} }

/* 右下角扫码切换 */
.qr-switch{
  position:absolute; right:14px; bottom:6px;
  width:34px; height:34px; display:grid; place-items:center;
  border:1px solid #d6f0e0; border-radius:10px; cursor:pointer;
  background:#f2fbf6; color:#07c160;
  box-shadow:0 1px 3px rgba(16,24,40,.06);
  transition:background .15s, color .15s, border-color .15s, transform .12s;
}
.qr-switch:hover{ background:#e6f8ee; color:#06ad56; border-color:#bfe8d0; }
.qr-switch:active{ transform:scale(.94); }

/* ---------- 头部 ---------- */
.login-head{ text-align:center; padding:14px 0 0; }
/* 透明猫头：不要底、不要描边，只用投影让它"立"起来 */
.login-logo{
  width:104px; height:104px; object-fit:contain;
  display:block; margin:-4px auto 10px;
  filter:drop-shadow(0 10px 16px rgba(80,60,40,.22));
}
.login-head h1{
  margin:0; font-size:23px; font-weight:600; letter-spacing:.5px; color:#1a1d21;
}
/* 品牌副标题 */
.login-sub{
  margin:7px 0 0; font-size:12.5px; color:#9aa0a6; letter-spacing:1.2px;
}

/* 纯分隔线（头部与表单之间） */
.rule{ height:1px; background:#eceef1; margin:20px 0 18px; }

/* ---------- 三种登录方式切换 ---------- */
.login-tabs{
  display:flex; gap:4px; padding:4px; margin:16px 0 18px;
  background:#f2f3f5; border-radius:11px;
}
.tab{
  flex:1; height:36px; border:0; border-radius:8px; cursor:pointer;
  background:transparent; color:#6b7280; font-size:13px; font-family:inherit;
  transition:background .15s, color .15s, box-shadow .15s;
}
.tab:hover:not(.active){ color:#374151; }
.tab.active{
  background:#fff; color:#1a1d21; font-weight:500;
  box-shadow:0 1px 3px rgba(16,24,40,.12);
}

.pane.hidden{ display:none; }
.link-row{
  display:flex; align-items:center; justify-content:center; gap:5px;
  margin-top:14px; font-size:12.5px; color:#9aa0a6;
}
.link{
  border:0; background:none; padding:0; cursor:pointer;
  font-size:12.5px; color:#2f6bff; font-family:inherit;
}
.link:hover{ text-decoration:underline; }

.pane-head{
  display:flex; align-items:baseline; gap:8px;
  margin:-2px 0 14px; font-size:15px; font-weight:600; color:#1a1d21;
}
.pane-head span{ font-size:12px; font-weight:400; color:#9aa0a6; }

.pane-tip{
  margin:12px 0 0; font-size:11.5px; color:#9aa0a6;
  text-align:center; line-height:1.55;
}

/* 企业微信面板 */
.wx-box{
  display:flex; align-items:center; gap:14px;
  padding:16px; margin-bottom:14px;
  background:#f7fbf8; border:1px solid #e2f2e9; border-radius:12px;
}
.wx-icon{
  width:54px; height:54px; flex:0 0 auto; border-radius:10px;
  display:grid; place-items:center; font-size:24px; color:#07c160;
  background:#fff; border:1px solid #e2f2e9;
}
.wx-text{ display:flex; flex-direction:column; gap:4px; }
.wx-text strong{ font-size:14px; color:#1a1d21; font-weight:600; }
.wx-text span{ font-size:12px; color:#8a929e; line-height:1.45; }

/* 分隔文字 */
.or-line{
  display:flex; align-items:center; gap:12px;
  margin:18px 0 16px;
}
.or-line::before, .or-line::after{
  content:""; flex:1; height:1px; background:#eceef1;
}
.or-line span{ font-size:12px; color:#9aa0a6; letter-spacing:.4px; white-space:nowrap; }

/* ---------- 表单 ---------- */
.login-body{ display:flex; flex-direction:column; }
.field{ position:relative; margin-bottom:12px; }
.field input{
  width:100%; height:50px; padding:0 16px;
  font-size:15px; color:#1a1d21; font-family:inherit;
  background:#f2f3f5; border:1px solid transparent; border-radius:10px;
  outline:none; transition:background .15s, border-color .15s, box-shadow .15s;
}
.field input::placeholder{ color:#9aa0a6; }
.field input:hover{ background:#eceef1; }
.field input:focus{
  background:#fff; border-color:#2f6bff;
  box-shadow:0 0 0 3px rgba(47,107,255,.13);
}
#lgPwd{ padding-right:48px; }
.eye{
  position:absolute; right:6px; top:50%; transform:translateY(-50%);
  width:36px; height:36px; display:grid; place-items:center;
  border:0; border-radius:9px; background:transparent; cursor:pointer;
  color:#a3acba; transition:color .15s, background .15s;
}
.eye:hover{ color:#5b6675; background:#e6e9ee; }
.eye.on{ color:#2f6bff; }

.login-err{
  min-height:18px; margin:0 0 10px;
  font-size:12.5px; color:#e5484d; line-height:18px;
}
.login-err:empty{ min-height:0; margin:0 0 12px; }
.login-err.ok{ color:#0a7d43; }
.login-err.shake{ animation:shake .34s ease; }
@keyframes shake{
  0%,100%{transform:translateX(0)} 25%{transform:translateX(-5px)}
  55%{transform:translateX(4px)} 80%{transform:translateX(-2px)}
}

/* 主按钮：未填完是灰的，填完变蓝（和参考一致） */
.login-btn{
  position:relative; width:100%; height:50px; border:0; border-radius:10px;
  cursor:pointer; color:#fff; font-size:15.5px; font-weight:500;
  letter-spacing:3px; font-family:inherit;
  background:#2f6bff; transition:background .16s, filter .16s, transform .12s;
}
.login-btn:hover:not(:disabled){ filter:brightness(1.05); }
.login-btn:active:not(:disabled){ transform:translateY(1px); }
.login-btn:disabled{ opacity:.75; cursor:default; }
.login-btn .btn-spin{
  display:none; position:absolute; right:16px; top:50%; margin-top:-8px;
  width:16px; height:16px; border-radius:50%;
  border:2px solid rgba(255,255,255,.45); border-top-color:#fff;
  animation:spin .8s linear infinite;
}
.login-btn.loading .btn-spin{ display:block; }
@keyframes spin{ to{ transform:rotate(360deg) } }

/* 企业微信 */
.wx-btn{
  display:flex; align-items:center; justify-content:center; gap:9px;
  width:100%; height:50px; border:0; border-radius:10px; cursor:pointer;
  background:#07c160; color:#fff; font-size:15px; font-weight:500; font-family:inherit;
  transition:background .16s, transform .12s;
}
.wx-btn:hover{ background:#06ad56; }
.wx-btn:active{ transform:translateY(1px); }
.wx-btn .wx-ico{ flex:0 0 auto; }

.login-foot{
  margin:20px -30px 0; padding:14px 56px 16px 30px;
  text-align:center; font-size:11.5px; color:#a9b1bd;
  border-top:1px solid #f2f3f5; border-radius:0 0 16px 16px; background:#fcfcfd;
}

.login-copy{
  position:absolute; left:0; right:0; bottom:16px; text-align:center;
  font-size:11.5px; color:#b3bac4;
}

@media (max-height:600px){
  .login-card{ padding:20px 26px 0; }
  .login-logo{ width:62px; height:62px; margin-bottom:10px; }
  .login-head h1{ font-size:20px; }
  .or-line{ margin:12px 0 12px; }
  .field input, .login-btn, .wx-btn{ height:44px; }
  .login-foot{ margin:14px -26px 0; padding:10px 26px 12px; }
  .login-copy{ display:none; }
}

.user-chip{
  font-size:13px; color:#334155; padding:4px 10px; border-radius:8px;
  background:#f1f5f9; white-space:nowrap;
}
.user-chip:hover{ background:#e2e8f0; color:#0f172a; }
.user-chip.hidden, .btn-ghost.hidden{ display:none; }
.btn-ghost{
  padding:4px 10px; font-size:12.5px; border:1px solid #cbd5e1; border-radius:8px;
  background:#fff; color:#475569; cursor:pointer;
}
.btn-ghost:hover{ background:#f8fafc; }


/* 品牌头像（侧栏左上角） */
img.logo{
  width:36px; height:36px; object-fit:contain;
  flex:0 0 auto; filter:drop-shadow(0 2px 4px rgba(80,60,40,.20));
}

/* ---------------- 搬本机旧技能：选择弹窗 ---------------- */
.imp-mask{position:fixed;inset:0;background:rgba(20,22,26,.42);backdrop-filter:blur(2px);
  display:flex;align-items:center;justify-content:center;z-index:9000;padding:24px}
.imp-card{background:#fff;border-radius:16px;width:min(560px,100%);max-height:82vh;
  display:flex;flex-direction:column;box-shadow:0 18px 60px rgba(0,0,0,.22);overflow:hidden}
.imp-h{display:flex;align-items:baseline;gap:9px;padding:18px 20px 6px}
.imp-h b{font-size:15.5px;color:var(--ink,#16181d)}
.imp-h span{font-size:12px;color:var(--ink4,#9aa1ab)}
.imp-lead{margin:0 20px 10px;font-size:12.5px;line-height:1.7;color:var(--ink3,#6b7280)}
.imp-list{flex:1;overflow:auto;padding:0 12px 6px;border-top:1px solid var(--line,#ececf0);
  border-bottom:1px solid var(--line,#ececf0);margin-top:4px}
.imp-row{display:flex;align-items:center;gap:9px;padding:9px 8px;border-radius:9px;
  font-size:13px;cursor:pointer}
.imp-row:hover{background:#fafafb}
.imp-row.dup{opacity:.62}
.imp-row input{width:15px;height:15px;accent-color:#1a7f5a;flex:0 0 auto}
.imp-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--ink,#16181d)}
.imp-tag{font-size:10.5px;padding:1px 6px;border-radius:5px;background:#f0f2f4;color:#6b7280}
.imp-sz{font-size:11px;color:var(--ink4,#9aa1ab);min-width:52px;text-align:right}
.imp-dup{font-size:10.5px;color:#b08442;background:#fdf5e8;padding:1px 6px;border-radius:5px}
.imp-f{display:flex;align-items:center;gap:8px;padding:14px 20px;flex-wrap:wrap}
.imp-btn{height:32px;padding:0 13px;border-radius:9px;border:1px solid var(--line2,#e6e7eb);
  background:#fff;color:var(--ink2,#3d4450);font-size:12.5px;cursor:pointer;font-family:inherit}
.imp-btn:hover{background:#fafafb}
.imp-btn.primary{background:#1a7f5a;border-color:#1a7f5a;color:#fff}
.imp-btn.primary:disabled{opacity:.55;cursor:default}
.imp-msg{flex:1;font-size:12px;color:var(--ink3,#6b7280);min-width:80px}

/* 登录框：记住账号 + 免登录说明 */
.login-remember{display:flex;align-items:center;gap:10px;margin:2px 0 10px;
  font-size:12px;color:var(--ink3,#6b7280)}
.login-remember label{display:flex;align-items:center;gap:6px;cursor:pointer;flex:0 0 auto}
.login-remember input{width:14px;height:14px;accent-color:#1a7f5a;cursor:pointer}
.login-keep{color:var(--ink4,#9aa1ab);margin-left:auto;font-size:11.5px}
