/* ============================================================
   LiteChat 在线对话 — 与官网首页同一套设计语言的样式
   （复用 /style.css 中定义的 CSS 变量）
   ============================================================ */

.chat-body{
  background:var(--bg);
  color:var(--text);
  min-height:100vh;
  display:flex;
  flex-direction:column;
}

/* ============ 顶栏 ============ */
.cnav{
  position:sticky;top:0;z-index:80;
  background:var(--nav-bg);
  -webkit-backdrop-filter:saturate(180%) blur(20px);
  backdrop-filter:saturate(180%) blur(20px);
  border-bottom:1px solid var(--line);
}
.cnav-inner{
  max-width:var(--maxw);margin:0 auto;padding:0 20px;
  height:60px;display:flex;align-items:center;gap:16px;
}
.cnav .brand{display:flex;align-items:center;gap:9px;font-weight:700;font-size:15px;flex:none}
.cnav .brand img{width:26px;height:26px;border-radius:8px}
.cnav-meta{
  margin-left:auto;display:flex;align-items:center;flex-wrap:wrap;
  gap:4px;font-size:13px;color:var(--muted);
}
.cnav-meta .who{color:var(--muted)}
.cnav-meta .who b{color:var(--text)}
.cnav-meta a{
  color:var(--muted);padding:6px 10px;border-radius:999px;font-weight:500;
  transition:color .25s var(--ease), background .25s var(--ease);
  white-space:nowrap;
}
.cnav-meta a:hover{color:var(--text);background:var(--surface-2)}
.cnav-meta .sep{color:var(--line);opacity:.9}
@media (max-width:720px){
  .cnav-inner{height:auto;padding:10px 16px;flex-wrap:wrap}
  .cnav-meta{margin-left:0;width:100%;gap:2px}
  .cnav-meta a{padding:5px 8px;font-size:12.5px}
}

/* ============ 主体两栏 ============ */
.chat-wrap{
  flex:1;
  width:100%;
  margin:0;padding:22px;
  display:grid;
  grid-template-columns:268px minmax(0,1fr);
  gap:20px;
  align-items:start;
}
@media (max-width:860px){
  .chat-wrap{grid-template-columns:minmax(0,1fr);padding:14px;gap:14px}
}

/* ============ 对话列表 ============ */
.conv-pane{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:20px;
  padding:18px 16px;
  box-shadow:var(--shadow-1);
  position:sticky;top:82px;
}
@media (max-width:860px){ .conv-pane{position:static} }
.conv-pane h2{
  font-size:13px;font-weight:600;color:var(--muted);
  letter-spacing:.02em;margin-bottom:12px;
}
.conv-list{list-style:none;display:grid;gap:6px;max-height:52vh;overflow-y:auto;overflow-x:hidden;margin-bottom:12px}
@media (max-width:860px){ .conv-list{max-height:none} }
.conv-item{
  display:flex;align-items:center;gap:8px;
  padding:9px 10px;border-radius:12px;
  border:1px solid transparent;
  transition:background .2s var(--ease), border-color .2s var(--ease);
}
.conv-item:hover{background:var(--surface-2)}
.conv-item.active{background:var(--accent-soft);border-color:rgba(245,179,1,.35)}
.conv-item .t{
  flex:1;min-width:0;font-size:13.5px;font-weight:500;color:var(--text);
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.conv-item .c{font-size:11.5px;color:var(--muted);flex:none;font-variant-numeric:tabular-nums}

/* ============ 消息区 ============ */
.msg-pane{min-width:0}
.msg-head{
  display:flex;align-items:baseline;gap:10px;margin-bottom:14px;padding-left:4px;
}
.msg-head h1{
  font-size:1.05rem;font-weight:680;letter-spacing:-.015em;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.msg-head .cnt{font-size:12px;color:var(--muted);flex:none;font-variant-numeric:tabular-nums}

.msgs{display:grid;gap:14px;margin-bottom:20px}

.msg{display:flex}
.msg.in{justify-content:flex-start}
.msg.out{justify-content:flex-end}
.msg .col{max-width:min(760px,88%);min-width:0}
.msg.out .col{align-items:flex-end}

.bubble{
  border-radius:18px;
  padding:13px 17px;
  font-size:14.5px;
  line-height:1.78;
  word-wrap:break-word;
  overflow-wrap:anywhere;
}
.msg.in .bubble{
  background:var(--surface);
  border:1px solid var(--line);
  border-top-left-radius:6px;
  box-shadow:var(--shadow-1);
}
.msg.out .bubble{
  background:var(--accent);
  color:#3a2c00;
  border-top-right-radius:6px;
}
.msg.out .bubble a{text-decoration:underline}
.msg .plain{white-space:pre-wrap}
.msg .who{
  font-size:11.5px;color:var(--muted);letter-spacing:.02em;
  margin-bottom:5px;padding:0 4px;
}
.msg.out .who{text-align:right}

/* 思考过程 */
.reason{
  margin:0 0 8px;
  padding:11px 15px;
  border-radius:14px;
  border:1px dashed var(--line);
  background:var(--surface-2);
  font-size:13px;
  line-height:1.72;
  color:var(--muted);
  max-height:22em;
  overflow:auto;
}
.reason .rt{
  font-size:11.5px;font-weight:600;letter-spacing:.03em;
  color:var(--muted);opacity:.85;margin-bottom:6px;
}

/* ============ Markdown 正文 ============ */
.md > :first-child{margin-top:0}
.md > :last-child{margin-bottom:0}
.md p{margin:0 0 .7em}
.md h1,.md h2,.md h3,.md h4,.md h5,.md h6{
  margin:1em 0 .5em;font-weight:680;letter-spacing:-.015em;line-height:1.35;
}
.md h1{font-size:1.3em}
.md h2{font-size:1.18em}
.md h3{font-size:1.08em}
.md h4,.md h5,.md h6{font-size:1em}
.md ul,.md ol{margin:0 0 .7em;padding-left:1.5em}
.md li{margin:.22em 0}
.md li > p{margin:0}
.md a{color:#1a73e8;text-decoration:none;border-bottom:1px solid rgba(26,115,232,.35)}
.md a:hover{border-bottom-color:#1a73e8}
.msg.out .bubble .md a{color:#3a2c00;border-bottom-color:rgba(58,44,0,.4)}
.md code{
  font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace;
  font-size:.9em;
  background:var(--surface-2);
  border:1px solid var(--line);
  border-radius:5px;
  padding:.1em .38em;
}
.msg.out .bubble .md code{background:rgba(255,255,255,.42);border-color:rgba(58,44,0,.14)}
.md pre{
  background:var(--surface-2);
  border:1px solid var(--line);
  border-radius:12px;
  padding:12px 14px;
  overflow:auto;
  margin:0 0 .8em;
}
.md pre code{background:none;border:none;padding:0;font-size:12.8px;line-height:1.6}
.md blockquote{
  margin:0 0 .8em;
  padding:.35em 0 .35em 14px;
  border-left:3px solid var(--line);
  color:var(--muted);
}
.md hr{border:none;border-top:1px solid var(--line);margin:1.1em 0}
.md table{
  border-collapse:collapse;width:100%;margin:0 0 .8em;
  font-size:13.5px;display:block;overflow-x:auto;
}
.md th,.md td{border:1px solid var(--line);padding:7px 10px;text-align:left}
.md th{background:var(--surface-2);font-weight:650}
.md img{max-width:100%;border-radius:10px}
.md .task-list-item{list-style:none;margin-left:-1.3em}
.md .task-list-item input{margin-right:.45em}

/* ============ v2.4.2: 代码块工具栏（右上角 Copy） ============ */
.md .code-toolbar{
  position:relative;
  margin:0 0 .8em;
  border:1px solid var(--line);
  border-radius:12px;
  background:var(--surface-2);
  overflow:hidden;
}
/* 卡片内部的 pre：去掉自己的边框/外边距，顶部留出工具栏的位置 */
.md .code-toolbar pre,
.md .code-toolbar pre.syntax-hl{
  margin:0;
  border:none;
  border-radius:0;
  background:transparent;
  padding:30px 14px 12px;
  overflow:auto;
  tab-size:4;
}
.md .code-toolbar pre code{
  background:none;
  border:none;
  padding:0;
}
.md .code-toolbar .toolbar{
  position:absolute; top:0; right:0; left:0;
  display:flex; justify-content:flex-end;
  padding:5px 7px;
  pointer-events:none;
}
.code-toolbar .toolbar-item{pointer-events:auto}
.code-toolbar .toolbar-item a{
  display:inline-flex; align-items:center;
  font-size:11.5px; line-height:1; font-weight:500;
  color:var(--muted); text-decoration:none;
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:7px;
  padding:5px 9px;
  cursor:pointer;
  opacity:.72;                      /* 常显：截图/触屏场景都能看到「Copy」，不靠 hover */
  transition:opacity .15s var(--ease), color .15s, border-color .15s;
}
.code-toolbar:hover .toolbar-item a,
.code-toolbar .toolbar-item a:focus{opacity:1}
.code-toolbar .toolbar-item a:hover{color:var(--text); border-color:rgba(26,115,232,.45)}
@media (max-width:860px){
  .code-toolbar .toolbar-item a{opacity:1}   /* 手机没有 hover，常显 */
}

/* KaTeX 过长公式可横向滚动，避免撑破气泡 */
.md .katex-display{overflow-x:auto;overflow-y:hidden;padding:2px 0}

/* ============ 输入区 ============ */
.composer{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:20px;
  padding:16px 16px 14px;
  box-shadow:var(--shadow-1);
}
.composer .row{display:flex;flex-wrap:wrap;align-items:center;gap:10px;margin-bottom:11px}
/* v2.2.5: 下拉最长的一项带「（发图请用 App）」，窄屏要能收缩 */
.composer .row select{max-width:100%}
/* v2.2.5: 智能体会话固定模型，用一行文案替代下拉 */
.composer .fixmdl{font-size:13px;color:var(--muted);}
@media (max-width:520px){.composer .fixmdl{font-size:12px}}
/* v2.2.5: 生成失败时的「重试」按钮 */
.bubble .retry{appearance:none;margin-top:8px;padding:5px 14px;border-radius:999px;
  border:1px solid #2F6FED;background:transparent;color:#2F6FED;font-size:12.5px;cursor:pointer}
.bubble .retry:hover{background:rgba(47,111,237,.08)}
.sel{
  appearance:none;-webkit-appearance:none;
  font:inherit;font-size:13.5px;color:var(--text);
  background:var(--surface-2);
  border:1px solid var(--line);
  border-radius:11px;
  padding:8px 34px 8px 12px;
  cursor:pointer;
  background-image:url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23707784' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right 10px center;
  background-size:15px;
  max-width:100%;
}
.chk{
  display:inline-flex;align-items:center;gap:7px;
  font-size:13.5px;color:var(--muted);
  border:1px solid var(--line);
  border-radius:999px;
  padding:7px 14px;
  cursor:pointer;
  user-select:none;
  transition:border-color .25s var(--ease), color .25s var(--ease), background .25s var(--ease);
}
.chk input{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none}
/* 勾选态由 JS 同步 .on（蓝框蓝字） */
.chk.on{border-color:#1a73e8;color:#1a73e8;background:rgba(26,115,232,.06)}
.composer textarea{
  width:100%;
  font:inherit;font-size:14.5px;line-height:1.7;color:var(--text);
  background:var(--surface-2);
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px 14px;
  resize:vertical;
  min-height:88px;
  outline:none;
  transition:border-color .25s var(--ease);
}
.composer textarea:focus{border-color:rgba(26,115,232,.55)}
.composer .send-row{display:flex;align-items:center;gap:12px;margin-top:12px}
.composer .hint{font-size:12px;color:var(--muted);margin-right:auto}
.btn-send{
  display:inline-flex;align-items:center;gap:8px;
  font:inherit;font-size:14px;font-weight:600;
  background:var(--text);color:var(--bg);
  border:none;border-radius:999px;
  padding:11px 26px;cursor:pointer;
  transition:transform .3s var(--ease), box-shadow .3s var(--ease);
}
.btn-send:hover{transform:translateY(-2px);box-shadow:0 16px 30px -14px rgba(16,18,24,.6)}
.btn-send:active{transform:translateY(0)}

/* 小按钮 */
.btn-mini{
  font:inherit;font-size:12px;
  color:var(--muted);background:transparent;
  border:1px solid var(--line);border-radius:9px;
  padding:3px 9px;cursor:pointer;flex:none;
  transition:color .2s, border-color .2s;
}
.btn-mini:hover{color:#c0392b;border-color:rgba(192,57,43,.45)}
.btn-new{
  width:100%;font:inherit;font-size:13.5px;font-weight:600;
  color:var(--text);background:var(--surface-2);
  border:1px solid var(--line);border-radius:12px;
  padding:10px;cursor:pointer;
  transition:background .25s var(--ease), border-color .25s var(--ease);
}
.btn-new:hover{border-color:rgba(245,179,1,.5);background:var(--accent-soft)}

/* ============ 提示 / 空状态 ============ */
.flash{
  background:rgba(214,48,49,.07);
  border:1px solid rgba(214,48,49,.28);
  color:#c0392b;
  border-radius:14px;
  padding:11px 15px;
  font-size:13.5px;
  margin-bottom:14px;
}
.empty{
  text-align:center;color:var(--muted);font-size:13.5px;
  padding:34px 0;
}

/* ============ 登录页 ============ */
.login-body{
  background:var(--bg);color:var(--text);
  min-height:100vh;display:flex;flex-direction:column;align-items:flex-start;
  padding:24px;
}
.login-card{
  width:100%;max-width:392px;
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:24px;
  padding:34px 30px 30px;
  box-shadow:var(--shadow-2);
}
.login-card .lg-icon{
  width:60px;height:60px;margin:0 auto 18px;border-radius:18px;
  box-shadow:0 10px 26px -12px rgba(16,18,24,.4);
}
.login-card h1{font-size:1.22rem;font-weight:700;text-align:center;letter-spacing:-.02em;margin-bottom:6px}
.login-card .lg-sub{text-align:center;font-size:13px;color:var(--muted);margin-bottom:24px}
.login-card label{display:block;font-size:12.5px;color:var(--muted);margin-bottom:7px}
.login-card input{
  width:100%;font:inherit;font-size:14.5px;color:var(--text);
  background:var(--surface-2);border:1px solid var(--line);
  border-radius:13px;padding:12px 14px;margin-bottom:15px;outline:none;
  transition:border-color .25s var(--ease);
}
.login-card input:focus{border-color:rgba(26,115,232,.55)}
.login-card .btn-send{width:100%;justify-content:center;margin-top:5px}
.login-card .lg-foot{text-align:center;font-size:12px;color:var(--muted);margin-top:18px}
.login-card .lg-foot a{color:var(--muted);text-decoration:underline}

/* v2.4.0: classic 页输入区吸底 —— 消息少时不再孤零零停在页面中间。
   （SPA 页有自己的布局，body 是 .app-body，不受这条影响） */
.chat-body .composer{position:sticky;bottom:0;z-index:20}

/* v1.5.8: 「回到底部」按钮 —— 只在用户上滑、粘底关闭时出现。
   用 fixed 定位：用户上滑后输入区已经滚出屏幕，所以右下角不会遮挡。 */
.to-bottom{
  position:fixed; right:18px; bottom:22px; z-index:30;
  padding:8px 15px; border-radius:999px; cursor:pointer;
  font-size:13px; line-height:1; font-family:inherit;
  background:#fff; color:#1A73E8;
  border:1px solid #CFE0FB;
  box-shadow:0 2px 10px rgba(0,0,0,.14);
}
.to-bottom:hover{ background:#F2F7FF; border-color:#9CC4F7; }
