/* 智谱免费模型工坊 —— 支持三套皮肤（default / sky / hall），主题变量驱动 */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* ═══ 主题变量 ═══ */
body {
  --brand: #1f4fd8;           /* 主色（按钮/高亮） */
  --brand-deep: #1741b4;
  --bg: radial-gradient(1100px 520px at 82% -8%, rgba(110,160,255,.40), transparent 62%),
        radial-gradient(900px 480px at -8% 28%, rgba(150,195,250,.36), transparent 60%),
        radial-gradient(760px 420px at 55% 112%, rgba(120,210,235,.30), transparent 60%),
        linear-gradient(160deg, #f0f5ff 0%, #e6eeff 100%);
  --bg-fixed: none;   /* 图背景皮肤的固定层产物（画在 body::before 上，见骨架区） */
  --header-bg: rgba(255,255,255,.8);
  --header-border: 1px solid #e3e9f4;
  --card-bg: #fff;
  --card-border: 1px solid #e3e9f4;
  --card-radius: 14px;
  --card-blur: none;
  --ink: #223;
  --ink-soft: #456;
  --hint: #6e7a8c;
  --input-bg: #fff;
  --input-border: 1px solid #cdd9ee;
  --msg-ai: #f1f5fc;
  --msg-user-bg: var(--brand);
  --msg-user-ink: #fff;
  --font-title: inherit;
  --tab-active-bg: var(--brand);
  --tab-active-ink: #fff;
  --gold: #c9a24b;
}

/* 晴空蓝皮肤已移除；默认皮肤为蓝金大厅（hall），下方 body 基础变量仅作通用兜底 */


/* ── 皮肤②：软空渐变 + 毛玻璃 ── */
body[data-skin="sky"] {
  --bg: none;
  --bg-fixed: url('bg-sky.png') center / cover no-repeat, linear-gradient(160deg, #f4f7fb, #eef3ff);
  --header-bg: rgba(255,255,255,.55);
  --card-bg: rgba(255,255,255,.62);
  --card-blur: blur(10px);
  --input-bg: rgba(255,255,255,.75);
  --msg-ai: rgba(255,255,255,.66);
}
/* sky：chat-bar 压在半透蓝天空图上，文字转深藏青 + 白色微光才抠得出来 */
body[data-skin="sky"] .chat-bar label { color: #16294f; text-shadow: 0 1px 0 rgba(255,255,255,.55); }
body[data-skin="sky"] .chat-bar .hint { color: #22386a; text-shadow: 0 1px 0 rgba(255,255,255,.5); }
body[data-skin="sky"] .ghost { color: #1c2f52; border-color: rgba(90, 120, 170, .7); background: rgba(255, 255, 255, .55); }
/* sky：pp-btn 是实心蓝底，白字 + 微阴影才抠得出来（需与 .ghost 同级别选择器，否则被上面规则染成深蓝字） */
body[data-skin="sky"] .chat-bar .pp-btn { color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .35); box-shadow: 0 2px 10px rgba(15, 40, 120, .45); }
body[data-skin="sky"] .chat-bar .pp-btn:hover { color: #fff; filter: brightness(1.12); }

/* ── 皮肤③：蓝金大厅（描金复刻）── */
body[data-skin="hall"] {
  --bg: none;
  --bg-fixed: url('bg-hall.png') center / cover no-repeat, linear-gradient(160deg, #e8ecf8, #dfe5f5);
  --brand: #22306b;
  --brand-deep: #182354;
  --header-bg: rgba(22,31,74,.86);
  --header-border: 2px solid var(--gold);
  --card-bg: rgba(253,248,236,.92);
  --card-border: 2px solid var(--gold);
  --card-radius: 16px;
  --ink: #2a2f45;
  --ink-soft: #3c4468;
  --hint: #8b8264;
  --input-bg: #fffdf6;
  --input-border: 1.5px solid #cbb27a;
  --msg-ai: rgba(255,253,244,.92);
  --msg-user-bg: #22306b;
  --msg-user-ink: #f6e9c8;
  --font-title: Georgia, "Times New Roman", "STKaiti", "KaiTi", serif;
  --tab-active-bg: #22306b;
  --tab-active-ink: #e9cf8f;
}
body[data-skin="hall"] .brand { color: #ecd9a0; text-shadow: 0 1px 3px rgba(0,0,0,.4); }
body[data-skin="hall"] .tag { color: #b9c2e0; }
body[data-skin="hall"] .tab { background: rgba(253,248,236,.9); border-color: var(--gold); color: #3c4468; }
/* hall 激活页签反相：金底深蓝字，在深蓝 header 与奶油白未选态里都跳得出来 */
body[data-skin="hall"] .tab.active { background: linear-gradient(135deg, #e9cf8f, #c9a24b); color: #1a2450; border-color: var(--gold); box-shadow: 0 0 0 2px rgba(201,162,75,.55), 0 3px 10px rgba(201,162,75,.4); }
body[data-skin="hall"] #chat-model, body[data-skin="hall"] #skin { background: #fffdf6; border-color: #cbb27a; color: #22306b; font-weight: 700; }
body[data-skin="hall"] .gen-card::before, body[data-skin="hall"] .msg-wrap::before {
  /* 顶部居中的描金蝴蝶结饰带 */
  content: "❖"; position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  width: 30px; height: 26px; line-height: 26px; text-align: center;
  background: #22306b; color: #e9cf8f; border: 1.5px solid var(--gold);
  border-radius: 50%; font-size: 13px; box-shadow: 0 2px 6px rgba(30,40,90,.35);
}
body[data-skin="hall"] .gen-card, body[data-skin="hall"] .msg-wrap { position: relative; }
body[data-skin="hall"] .msg.ai { border: 1px solid #e0cfa0; }
body[data-skin="hall"] .msg.user { border: 1px solid var(--gold); }
/* hall：chat-bar 直接压在深色大厅背景图上，次要文字须提亮才看得清 */
body[data-skin="hall"] .chat-bar label { color: #f2e7cb; text-shadow: 0 1px 2px rgba(0,0,0,.45); }
body[data-skin="hall"] .chat-bar .hint { color: #e3cf98; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
body[data-skin="hall"] .ghost { color: #ecd9a0; border-color: rgba(201,162,75,.75); }
body[data-skin="hall"] .ghost:hover { color: #fff; border-color: var(--gold); }

/* ═══ 骨架样式（皮肤无关）═══ */
html { height: 100%; }
body {
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink); min-height: 100vh; display: flex; flex-direction: column;
}
/* 大图背景皮肤不再用 background-attachment: fixed（滚动时每帧重绘会抖动，手机地址栏
   伸缩还会让 cover 重裁），改由固定定位伪元素承载：fixed 元素自动升合成层只栅格化
   一次；高度锁 100lvh（大视口静态值）使地址栏收起/展开时完全不重排，零抖动 */
body::before {
  content: ""; position: fixed; top: 0; left: 0; width: 100%; height: 100vh;
  z-index: -1; background: var(--bg-fixed);
}
@supports (height: 100lvh) { body::before { height: 100lvh; } }
header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  padding: 14px 22px; background: var(--header-bg); backdrop-filter: blur(6px);
  border-bottom: var(--header-border); position: sticky; top: 0; z-index: 10;
}
.brand { font-size: 19px; font-weight: 700; color: var(--brand); font-family: var(--font-title); }
.tag { font-size: 12px; font-weight: 400; color: var(--hint); margin-left: 6px; }
#tabs { display: flex; gap: 8px; }
.tab {
  border: 1px solid #d7e0f0; background: #fff; color: var(--ink-soft); border-radius: 20px;
  padding: 7px 16px; font-size: 14px; cursor: pointer; transition: .18s;
}
.tab:hover { border-color: var(--brand); color: var(--brand); }
.tab.active { background: var(--tab-active-bg); border-color: var(--tab-active-bg); color: var(--tab-active-ink); }
/* 当前页签强标识：加粗 + 下指三角，一眼知道自己在哪个页 */
.tab.active { font-weight: 700; }
.tab.active::after { content: " ▾"; font-size: 11px; }
.skin-pick { font-size: 13px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
body[data-skin="hall"] .skin-pick { color: #dfe4f5; }
#skin { padding: 5px 8px; border-radius: 8px; border: 1px solid #cdd9ee; background: #fff; font-size: 13px; cursor: pointer; }
/* 手机端皮肤图标 & “怎么用？”提示气泡：桌面端隐藏，由下方媒体查询在手机端打开 */
.skin-mini { display: none; width: 34px; height: 34px; border-radius: 50%; border: 1px solid #d7e0f0; background: #fff; font-size: 16px; cursor: pointer; align-items: center; justify-content: center; padding: 0; }
body[data-skin="hall"] .skin-mini { background: #fdf8ec; border-color: var(--gold); }
#chat-input { min-height: 64px; line-height: 1.5; overflow-y: auto; resize: none; max-height: 108px; } /* rows=1 但桌面端保持两行起步，多行自动增高至 4 行后内部滚动 */

.view { display: none; flex: 1; padding: 18px 22px 26px; max-width: 900px; margin: 0 auto; width: 100%; }
.view.active { display: flex; flex-direction: column; }

/* ── 文本对话 ── */
.chat-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.chat-bar label { font-size: 14px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
#chat-model {
  padding: 6px 10px; border-radius: 8px; border: 1px solid #cdd9ee; background: #fff;
  font-size: 14px; color: var(--brand); font-weight: 600; cursor: pointer;
}
.hint { font-size: 12px; color: var(--hint); }
.ghost { margin-left: auto; border: 1px solid #d7e0f0; background: none; color: #678; border-radius: 8px; padding: 5px 12px; font-size: 13px; cursor: pointer; }
.ghost:hover { color: #d33; border-color: #e99; }

/* .msg-wrap：不滚动的外层，专门承接 hall 皮肤溢出顶部的 ❖ 饰带（#messages 内部滚动会把它裁掉） */
.msg-wrap {
  flex: 1; display: flex; position: relative;
  min-height: 46vh; max-height: 62vh;
}
#messages {
  flex: 1; overflow-y: auto; background: var(--card-bg); border: var(--card-border); border-radius: var(--card-radius);
  backdrop-filter: var(--card-blur); padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.msg { max-width: 82%; padding: 10px 14px; border-radius: 12px; font-size: 14.5px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--msg-user-bg); color: var(--msg-user-ink); border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--msg-ai); color: var(--ink); border-bottom-left-radius: 4px; }
.msg.sys { align-self: center; background: none; color: var(--hint); font-size: 12.5px; }
.msg.err { align-self: flex-start; background: #fff1f0; color: #c23; border: 1px solid #f3c1bd; }
.meta { display: block; margin-top: 6px; font-size: 11.5px; color: var(--hint); }
/* 提示词工程师：实心高亮胶囊按钮，从 ghost 描边里跳出来 */
.chat-bar .pp-btn {
  margin-left: 0; border: none; border-radius: 999px; padding: 7px 16px;
  font-size: 13px; font-weight: 700; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  box-shadow: 0 2px 10px rgba(31, 79, 216, .4);
}
.chat-bar .pp-btn:hover { color: #fff; filter: brightness(1.18); }
body[data-skin="hall"] .chat-bar .pp-btn { background: linear-gradient(135deg, #e9cf8f, #c9a24b); color: #22306b; box-shadow: 0 2px 10px rgba(201, 162, 75, .55); }
body[data-skin="hall"] .chat-bar .pp-btn:hover { color: #1a2450; filter: brightness(1.08); }
/* 运行中停止态：与其他任务按钮同款深色呼吸光晕（写在皮肤规则后，优先级压过渐变） */
.chat-bar .pp-btn.stop, body[data-skin="hall"] .chat-bar .pp-btn.stop {
  background: #16181d; color: #fff; cursor: pointer;
  animation: stopPulse 1.6s ease-in-out infinite;
}
.pp-head { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 6px; color: var(--brand); }
.pp-text { background: rgba(125, 145, 200, .13); border: 1px dashed rgba(125, 145, 200, .55); border-radius: 8px; padding: 8px 10px; margin: 0 0 8px; line-height: 1.7; white-space: pre-wrap; }
.copy-pp { border: 1px solid #c9d2ea; background: none; color: #4a5a86; border-radius: 999px; padding: 3px 14px; font-size: 12.5px; cursor: pointer; margin-right: 8px; }
.copy-pp:hover { color: var(--brand); border-color: var(--brand); }
.ai-text { margin-bottom: 6px; } /* 普通回答正文与复制按钮的间距 */
.regen-pp { margin-left: -2px; }
/* hall 气泡是奶油白底，提字用深金而非背景用的浅金 */
body[data-skin="hall"] .pp-head { color: #7c5e1a; }
body[data-skin="hall"] .copy-pp { color: #7c5e1a; border-color: rgba(160, 120, 40, .55); }
body[data-skin="hall"] .copy-pp:hover { color: #fff; background: #8a6a1f; border-color: #8a6a1f; }
details.think { margin-bottom: 6px; font-size: 12.5px; color: #667; }
details.think summary { cursor: pointer; color: var(--brand); }
details.think pre { white-space: pre-wrap; font-family: inherit; margin-top: 4px; color: #889; }

#chat-form { display: flex; gap: 10px; margin-top: 12px; }
#chat-input, textarea {
  flex: 1; border: var(--input-border); border-radius: 12px; padding: 10px 14px; font-size: 14.5px;
  font-family: inherit; resize: vertical; background: var(--input-bg); color: var(--ink); outline: none;
}
#chat-input:focus, textarea:focus { border-color: var(--brand); }
/* 输入框收尾：不显示右下角可调大小手柄（上条分组规则的 resize: vertical 声明在后，必须在这里压回去）；
   滚动条默认隐身，内容超过 4 行（JS 打 need-scroll 类）才显现 */
#chat-input { resize: none; scrollbar-width: none; -ms-overflow-style: none; }
#chat-input::-webkit-scrollbar { width: 0; height: 0; display: none; }
#chat-input.need-scroll { scrollbar-width: thin; }
#chat-input.need-scroll::-webkit-scrollbar { width: 5px; display: block; }
#chat-input.need-scroll::-webkit-scrollbar-thumb { background: rgba(120, 130, 160, .45); border-radius: 3px; }
#chat-send, .gen-card button {
  border: none; background: var(--brand); color: #fff; border-radius: 12px; padding: 0 26px;
  font-size: 15px; cursor: pointer; transition: .15s; min-width: 96px;
}
body[data-skin="hall"] #chat-send, body[data-skin="hall"] .gen-card button { border: 1.5px solid var(--gold); color: #f6e9c8; }
#chat-send:disabled, .gen-card button:disabled { background: #a9bdf0; cursor: wait; color: #eee; }
#chat-send:hover:not(:disabled), .gen-card button:hover:not(:disabled) { background: var(--brand-deep); }
/* 运行中→停止态：深色实心 + 呼吸光晕（元宝风） */
#chat-send.stop, .gen-card button.stop {
  background: #16181d; color: #fff; cursor: pointer;
  animation: stopPulse 1.6s ease-in-out infinite;
}
#chat-send.stop:hover, .gen-card button.stop:hover { background: #000; }
@keyframes stopPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22,24,29,.35); }
  50% { box-shadow: 0 0 0 6px rgba(22,24,29,0); }
}
body[data-skin="hall"] #chat-send.stop, body[data-skin="hall"] .gen-card button.stop { border-color: var(--gold); color: #ecd9a0; }

/* ── 生图 / 生视频 ── */
.gen-card {
  background: var(--card-bg); border: var(--card-border); border-radius: var(--card-radius);
  backdrop-filter: var(--card-blur); padding: 22px; display: flex; flex-direction: column; gap: 12px;
}
.lab { font-size: 14px; font-weight: 600; color: var(--ink-soft); font-family: var(--font-title); }
.gen-card button { padding: 10px 26px; align-self: flex-start; }
.gen-tools { display: flex; align-items: center; gap: 14px; }
.gen-tools button { align-self: auto; }
/* ＋ 号添加参考图：描边圆钮，hover 填充品牌色，无旋转 */
.plus {
  width: 38px; height: 38px; min-width: 38px !important; padding: 0 !important; border-radius: 50% !important;
  border: 1px solid #cdd9ee !important; background: var(--input-bg) !important; color: var(--brand) !important;
  box-shadow: 0 1px 3px rgba(31,79,216,.08) !important;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: .18s ease;
}
.plus:hover {
  background: var(--brand) !important; border-color: var(--brand) !important; color: #fff !important;
  transform: scale(1.08); box-shadow: 0 4px 12px rgba(31,79,216,.35) !important;
}
.plus:active { transform: scale(.94); }
body[data-skin="hall"] .plus { border-color: #cbb27a !important; color: #7a5f1e !important; background: #fffdf6 !important; }
body[data-skin="hall"] .plus:hover { background: #22306b !important; border-color: var(--gold) !important; color: #ecd9a0 !important; }
/* 拖图入卡片时的高亮态 */
.gen-card.drop-on { border-color: var(--brand) !important; box-shadow: 0 0 0 3px rgba(31,79,216,.18) inset; background: rgba(223,232,255,.55); }
body[data-skin="hall"] .gen-card.drop-on { border-color: var(--gold) !important; box-shadow: 0 0 0 3px rgba(201,162,75,.28) inset; background: rgba(253,248,236,.75); }
/* 参考图预览卡（收到图才显示；修掉 display:flex 顶掉 hidden 的 bug） */
.attach-prev[hidden] { display: none; }
.attach-prev { display: flex; align-items: center; gap: 12px; }
.attach-prev .thumb { position: relative; width: 88px; height: 88px; flex: none; }
.attach-prev img { width: 88px; height: 88px; object-fit: cover; border-radius: 12px; border: 2px solid #cdd9ee; display: block; background: #fff; }
.attach-prev button {
  position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; min-width: 0; padding: 0 !important;
  border-radius: 50%; border: none; background: #16181d; color: #fff; font-size: 11px;
  display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.attach-prev button:hover { background: #c23; }
body[data-skin="hall"] .attach-prev img { border-color: var(--gold); }
.status { font-size: 13px; color: var(--brand); min-height: 20px; }
.status.busy::before { content: "⏳ "; }
.status.fail { color: #c23; }
.status.ok { color: #1a9e4b; }
.result img, .result video { max-width: 100%; border-radius: 12px; box-shadow: 0 4px 18px rgba(31,79,216,.15); display: block; }
body[data-skin="hall"] .result img, body[data-skin="hall"] .result video { border: 2px solid var(--gold); }
.result .actions { margin-top: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.result .actions a {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  padding: 8px 18px; border-radius: 20px; font-size: 13.5px; font-weight: 600; transition: .18s;
}
.result a.act-dl {
  background: linear-gradient(135deg, var(--brand), var(--brand-deep)); color: #fff;
  box-shadow: 0 3px 10px rgba(31,79,216,.3);
}
.result a.act-dl:hover { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(31,79,216,.4); }
.result a.act-open { background: var(--input-bg); color: var(--brand); border: 1px solid #c9d7f5; }
.result a.act-open:hover { transform: translateY(-1px); border-color: var(--brand); background: #f3f7ff; }
.result .actions .hint { font-size: 12px; color: var(--hint); margin-left: 4px; }
body[data-skin="hall"] .result a.act-dl { background: linear-gradient(135deg, #2a3a7d, #182354); border: 1.5px solid var(--gold); color: #f6e9c8; box-shadow: 0 3px 10px rgba(34,48,107,.35); }
body[data-skin="hall"] .result a.act-open { background: #fffdf6; border: 1.5px solid #cbb27a; color: #7a5f1e; }
body[data-skin="hall"] .result a.act-open:hover { background: #faf3e0; border-color: var(--gold); }

/* ═══ 手机端（≤640px）：输入框吸底 + 按钮瘦身，接近原生聊天 App ═══ */
@media (max-width: 640px) {
  header { padding: 10px 12px; gap: 8px; }
  .brand { font-size: 16px; } .tag { display: none; }
  .tab { padding: 5px 11px; font-size: 12.5px; }
  .skin-mini { display: inline-flex; } .skin-pick { display: none; }
  .view { padding: 12px 12px 100px; }
  /* 工具栏：隐掉冗长的模型说明文字，下拉与按钮缩小，少换行 */
  .chat-bar { gap: 8px; margin-bottom: 10px; }
  .chat-bar .hint { display: none; }
  #chat-model { padding: 4px 8px; font-size: 12.5px; max-width: 44vw; }
  .ghost { padding: 4px 10px; font-size: 12px; }
  .chat-bar .pp-btn { padding: 5px 11px; font-size: 12px; }
  /* 消息区吃掉剩余高度，表单 fixed 吸底 */
  .msg-wrap { min-height: calc(100vh - 340px); max-height: none; }
  #chat-form {
    position: fixed; left: 0; right: 0; bottom: 0; margin-top: 0; gap: 8px; z-index: 20;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    background: var(--header-bg); backdrop-filter: blur(10px);
    border-top: 1px solid rgba(120, 130, 160, .3);
  }
  #chat-input { font-size: 16px; padding: 8px 12px; min-height: 40px; max-height: 112px; } /* ≥16px 防 iOS 聚焦缩放；单行起步更矮，自动增高至 4 行 */
  #chat-send { min-width: 64px; padding: 0 14px; font-size: 14px; }
  .msg { font-size: 14px; max-width: 92%; }
  .gen-card { padding: 14px; }
  .gen-card button { padding: 9px 18px; font-size: 14px; min-width: 80px; }
}
