* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --violet: #2D5596; --violet-d: #244A82; --ink: #16181d; --muted: #6b7280;
  --line: #e7e8ee; --soft: #f3f5fb; --bg: #fafbff;
}
html, body { height: 100%; }
body { font-family: -apple-system, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink); background: var(--bg); display: flex; flex-direction: column; height: 100vh; }
a { color: var(--violet); text-decoration: none; }

/* ===== 顶栏 ===== */
.appbar { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 18px; background: #fff; border-bottom: 1px solid var(--line); }
.appbar .brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 17px; color: var(--ink); }
.appbar .brand img { width: 28px; height: 28px; border-radius: 7px; }
.appbar-right { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.appbar select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px;
  background: #fff; color: var(--ink); cursor: pointer; max-width: 180px; }
.balance { color: var(--muted); white-space: nowrap; }
.recharge-btn { background: var(--violet); color: #fff; border: 0; padding: 7px 16px; border-radius: 9px;
  font-size: 14px; font-weight: 600; cursor: pointer; }
.recharge-btn:hover { background: var(--violet-d); }
.appbar .user { font-weight: 700; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar .logout { color: var(--muted); font-size: 13px; cursor: pointer; }
.appbar .logout:hover { color: var(--violet); }
.appbar-left { display: flex; align-items: center; gap: 10px; }
.sb-toggle { display: none; background: none; border: 0; font-size: 20px; color: var(--ink); cursor: pointer; line-height: 1; }
@media (max-width: 600px) { .appbar .user, .balance { display: none; } }

/* ===== 主区：侧边栏 + 聊天 ===== */
.main { flex: 1 1 auto; display: flex; min-height: 0; position: relative; }
.sidebar { flex: 0 0 248px; display: flex; flex-direction: column; background: #fff; border-right: 1px solid var(--line); }
.new-chat { margin: 12px; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  color: var(--violet); font-size: 14.5px; font-weight: 700; cursor: pointer; transition: background .14s, border-color .14s; }
.new-chat:hover { background: var(--soft); border-color: #c2d2ee; }
.conv-list { flex: 1 1 auto; overflow-y: auto; padding: 0 8px 12px; }
.conv-item { display: flex; align-items: center; gap: 6px; padding: 9px 10px; border-radius: 9px; cursor: pointer;
  color: var(--ink); font-size: 14px; transition: background .12s; }
.conv-item:hover { background: var(--soft); }
.conv-item.on { background: var(--soft); font-weight: 600; }
.conv-title { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-del { flex: 0 0 auto; border: 0; background: none; color: var(--muted); font-size: 17px; line-height: 1;
  cursor: pointer; opacity: 0; transition: opacity .12s, color .12s; }
.conv-item:hover .conv-del { opacity: 1; }
.conv-del:hover { color: #cf1322; }
.sb-download { flex: 0 0 auto; margin: 0; padding: 12px 14px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 13.5px; font-weight: 600; text-align: center; transition: color .14s, background .14s; }
.sb-download:hover { color: var(--violet); background: var(--soft); }
.chat-wrap { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.sb-mask { display: none; position: absolute; inset: 0; background: rgba(18,26,46,.4); z-index: 8; }

@media (max-width: 760px) {
  .sb-toggle { display: block; }
  .sidebar { position: absolute; top: 0; bottom: 0; left: 0; z-index: 9; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: 0 0 30px rgba(0,0,0,.15); }
  .sidebar.open { transform: translateX(0); }
  .sb-mask.show { display: block; }
}

/* ===== 聊天区 ===== */
.chat { flex: 1 1 auto; overflow-y: auto; }
.msgs { max-width: 820px; margin: 0 auto; padding: 26px 18px 8px; display: flex; flex-direction: column; gap: 16px; }
.empty { max-width: 820px; margin: 0 auto; padding: 80px 24px; text-align: center; color: var(--muted); font-size: 15px; }
.row { display: flex; }
.row.user { justify-content: flex-end; }
.bubble { max-width: 82%; padding: 11px 15px; border-radius: 14px; font-size: 15px; line-height: 1.65; word-break: break-word; }
.row.user .bubble { background: var(--violet); color: #fff; border-bottom-right-radius: 5px; white-space: pre-wrap; }
.row.ai .bubble { background: #fff; border: 1px solid var(--line); color: var(--ink); border-bottom-left-radius: 5px; }
.bubble img.genimg-out { max-width: 320px; width: 100%; border-radius: 11px; margin: 6px 0; display: block; cursor: zoom-in; }
.bubble pre { background: #0f172a; color: #d7e3f4; border-radius: 9px; padding: 11px 13px; overflow-x: auto;
  font-family: ui-monospace, Consolas, monospace; font-size: 13px; margin: 8px 0; white-space: pre-wrap; word-break: break-all; }
.bubble code { background: var(--soft); border-radius: 5px; padding: 1px 5px; font-family: ui-monospace, Consolas, monospace; font-size: 13.5px; }
.bubble pre code { background: none; padding: 0; }
.bubble .err { color: #cf1322; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: #b9c2d6; animation: blink 1.2s infinite; }
.dots i:nth-child(2){ animation-delay:.2s } .dots i:nth-child(3){ animation-delay:.4s }
@keyframes blink { 0%,60%,100%{opacity:.3} 30%{opacity:1} }

/* ===== 输入区 ===== */
.composer { flex: 0 0 auto; border-top: 1px solid var(--line); background: #fff; }
.composer-inner { max-width: 820px; margin: 0 auto; padding: 12px 18px; display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px;
  font-size: 15px; font-family: inherit; line-height: 1.5; outline: none; max-height: 180px;
  transition: border-color .15s, box-shadow .15s; }
.composer textarea:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(45,85,150,.12); }
.composer button { flex: 0 0 auto; background: var(--violet); color: #fff; border: 0; height: 44px; padding: 0 24px;
  border-radius: 12px; font-size: 15px; font-weight: 700; cursor: pointer; transition: background .15s, opacity .15s; }
.composer button:hover { background: var(--violet-d); }
.composer button:disabled { opacity: .55; cursor: default; }

/* ===== 图片放大预览 ===== */
.lightbox { position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center;
  background: rgba(12,18,34,.82); padding: 30px; cursor: zoom-out; }
.lightbox img { max-width: 96%; max-height: 92%; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }

/* ===== 充值弹窗 ===== */
.rc-overlay { position: fixed; inset: 0; z-index: 70; display: none; align-items: center; justify-content: center;
  background: rgba(18,26,46,.5); backdrop-filter: blur(3px); padding: 20px; }
.rc-card { position: relative; width: 100%; max-width: 400px; background: #fff; border-radius: 18px;
  padding: 26px 26px 22px; box-shadow: 0 30px 70px -20px rgba(20,40,90,.5); }
.rc-close { position: absolute; top: 14px; right: 16px; border: 0; background: none; font-size: 18px; color: var(--muted); cursor: pointer; }
.rc-close:hover { color: var(--ink); }
.rc-title { font-size: 18px; font-weight: 800; margin-bottom: 16px; }
.rc-label { font-size: 13px; color: var(--muted); font-weight: 600; margin: 14px 0 8px; }
.rc-tiers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.rc-tier { border: 1.5px solid var(--line); border-radius: 12px; padding: 14px 6px; background: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; transition: border-color .14s, background .14s; }
.rc-tier:hover { border-color: #c2d2ee; }
.rc-tier.on { border-color: var(--violet); background: var(--soft); }
.rc-tier .amt { font-size: 17px; font-weight: 800; color: var(--ink); }
.rc-tier .bonus { font-size: 11.5px; color: #e6722e; }
.rc-methods { display: flex; gap: 10px; flex-wrap: wrap; }
.rc-method { border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 16px; background: #fff; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--ink); transition: border-color .14s, color .14s, background .14s; }
.rc-method.on { border-color: var(--violet); color: var(--violet); background: var(--soft); }
.rc-confirm { width: 100%; margin-top: 20px; background: var(--violet); color: #fff; border: 0; padding: 12px;
  border-radius: 11px; font-size: 15.5px; font-weight: 700; cursor: pointer; transition: background .15s, opacity .15s; }
.rc-confirm:hover { background: var(--violet-d); }
.rc-confirm:disabled { opacity: .5; cursor: default; }
.rc-amount { text-align: center; font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.rc-tip { text-align: center; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.rc-qr { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.rc-qr svg, .rc-qr img { width: 200px; height: 200px; border: 1px solid var(--line); border-radius: 10px; }
.rc-wxid { font-size: 13px; color: var(--ink); font-weight: 600; }
.rc-status { text-align: center; margin-top: 14px; font-size: 14px; font-weight: 600; color: var(--violet); }
.rc-back { display: block; margin: 16px auto 0; background: none; border: 0; color: var(--muted); font-size: 13px; cursor: pointer; }
.rc-back:hover { color: var(--violet); }
