* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --violet: #2D5596; --violet-d: #244A82; --ink: #16181d; --muted: #6b7280;
  --line: #e7e8ee; --soft: #f3f5fb; --bg: #fafbff;
  --panel: #fff;
  --bubble-ai: #fff;
  --r-s: 9px; --r-m: 12px; --r-l: 14px;
  --tone: none;                 /* 聊天区底纹，默认无 */
  --ava: none;                  /* 吉祥物头像，默认不显示 */
  /* **不随皮肤变**的品牌色：给付款这类必须保持严肃的界面用。 */
  --fixed-brand: #2D5596; --fixed-brand-d: #244A82;
}

/* ===== 二次元皮肤：只覆盖令牌 + 加装饰，结构一行没动 =====
   配色从品牌蓝偏移而来（樱粉主色 + 薄荷作 AI 的身份色），是换主题不是换品牌。 */
:root[data-skin="acg"] {
  --violet: #FF6F9C; --violet-d: #F0548A;
  --mint: #37BFC7;
  --ink: #2B2434;               /* 深梅紫，不用纯黑 */
  --muted: #8A7F96;
  --line: #FBD9E6; --soft: #FFF0F6; --bg: #FFF8FB;
  --panel: #FFFDFE; --bubble-ai: #F2FBFC;
  --r-s: 13px; --r-m: 17px; --r-l: 20px;
  /* 网点纸（漫画印刷的网屏）——纯 CSS，无素材 */
  --tone: radial-gradient(circle at 1px 1px, rgba(255,111,156,.16) 1px, transparent 1.6px);
  --ava: block;
  letter-spacing: .012em;
}

/* ⚠️ 换肤瞬间必须关掉过渡。
   Chromium 下 `transition: background` + `background: var(--x)`，当 --x 在祖先上被改掉时，
   计算值会**卡在初次解析的结果上再也不更新**（底色/圆角全中招），而 getComputedStyle 读
   变量本身却是新值 —— 极难查。切换那一帧硬切，hover 动效照常保留。 */
html.skin-switching, html.skin-switching * { transition: none !important; }
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); }


/* ===== 皮肤装饰（全部纯 CSS，零图片素材）===== */
.chat { background-image: var(--tone); background-size: 13px 13px; }
.appbar, .sidebar, .composer { background: var(--panel); }
.row.ai .bubble { background: var(--bubble-ai); }
.new-chat, .appbar select { border-radius: var(--r-m); }
.conv-item { border-radius: var(--r-s); }
.bubble { border-radius: var(--r-l); }
.composer textarea, .composer button, .recharge-btn { border-radius: var(--r-m); }

/* 漫画对话框的小尾巴：CSS 三角，只在二次元皮肤下出现 */
:root[data-skin="acg"] .row.ai .bubble { position: relative; }
:root[data-skin="acg"] .row.ai .bubble::before {
  content: ""; position: absolute; left: -7px; bottom: 9px;
  border: 7px solid transparent; border-right-color: var(--line); border-left: 0;
}
:root[data-skin="acg"] .row.ai .bubble::after {
  content: ""; position: absolute; left: -5.5px; bottom: 9px;
  border: 7px solid transparent; border-right-color: var(--bubble-ai); border-left: 0;
}
:root[data-skin="acg"] .recharge-btn, :root[data-skin="acg"] .composer button {
  box-shadow: 0 4px 0 var(--violet-d);
}
:root[data-skin="acg"] .recharge-btn:active, :root[data-skin="acg"] .composer button:active {
  transform: translateY(2px); box-shadow: 0 2px 0 var(--violet-d);
}

/* 吉祥物头像：圆脸 + 呆毛 + 腮红，全是 CSS。默认皮肤下 display:none。 */
.row.ai { display: flex; gap: 9px; align-items: flex-end; }
.ava { flex: 0 0 auto; display: var(--ava); width: 34px; height: 34px; position: relative;
  border-radius: 50%; background: linear-gradient(160deg, #FFF3F8, #FFE0EC); border: 2px solid var(--mint, #37BFC7); }
.ava::before {  /* 呆毛 */
  content: ""; position: absolute; top: -8px; left: 13px; width: 3px; height: 10px;
  background: var(--mint, #37BFC7); border-radius: 3px; transform-origin: bottom center;
  transform: rotate(14deg); animation: ahoge 2.6s cubic-bezier(.34,1.42,.64,1) infinite;
}
@keyframes ahoge { 0%,100% { transform: rotate(14deg) } 50% { transform: rotate(-10deg) } }
.ava i { position: absolute; }
.ava .eye { top: 13px; width: 4px; height: 6px; border-radius: 50%; background: var(--ink); animation: blinkeye 4.2s infinite; }
.ava .eye.l { left: 8px } .ava .eye.r { right: 8px }
@keyframes blinkeye { 0%,94%,100% { transform: scaleY(1) } 97% { transform: scaleY(.15) } }
.ava .blush { top: 19px; width: 6px; height: 3px; border-radius: 50%; background: #FFA9C6; opacity: .85 }
.ava .blush.l { left: 4px } .ava .blush.r { right: 4px }
.ava .mouth { top: 21px; left: 50%; transform: translateX(-50%); width: 7px; height: 4px;
  border: 1.6px solid var(--ink); border-top: 0; border-radius: 0 0 7px 7px }
@media (prefers-reduced-motion: reduce) { .ava::before, .ava .eye { animation: none } }

/* 皮肤切换按钮 */
.skin-btn { background: none; border: 1px solid var(--line); border-radius: var(--r-s);
  padding: 6px 10px; font-size: 13px; color: var(--muted); cursor: pointer; line-height: 1; }
.skin-btn:hover { color: var(--violet); border-color: var(--violet); }
@media (max-width: 600px) { .skin-btn { display: none } }

/* ===== ★ 危险界面不参与主题化 =====
   充值涉及付钱，永远用中性外观 —— 这里出现卖萌只会让人不敢付。 */
.rc-card { background: #fff; color: #16181d; }
.rc-tier, .rc-method { border-radius: 12px; }
.rc-tier.on, .rc-method.on { border-color: var(--fixed-brand); color: var(--fixed-brand); background: #f3f5fb; }
.rc-confirm { background: var(--fixed-brand); border-radius: 11px; box-shadow: none; }
.rc-confirm:hover { background: var(--fixed-brand-d); }
.rc-status { color: var(--fixed-brand); }
.rc-title, .rc-amount, .rc-tier .amt, .rc-wxid { color: #16181d; }
.rc-label, .rc-tip, .rc-close, .rc-back { color: #6b7280; }
