/* ============================================================
   NexBuild OS-Agent — 对话页样式（Monochrome Chat System）
   复用主站设计变量：墨黑 / 暖白 / 发丝线 / 衬线斜体 / 锐利边框
   ============================================================ */

.chat-body { overflow: hidden; }

.chat-app {
  display: grid;
  grid-template-columns: 288px 1fr;
  height: 100dvh;
}

/* ---------- 侧栏 ---------- */
.chat-side {
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 22px 20px;
  overflow-y: auto;
  background: var(--bg);
  z-index: 60;
}
.side-brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--ink); margin-bottom: 22px;
}
.side-brand img { width: 24px; height: 24px; }
.side-brand span { font-weight: 700; letter-spacing: 0.14em; font-size: 13px; }
.side-brand em {
  display: block; font-style: normal; font-family: var(--font-mono);
  font-size: 7px; letter-spacing: 0.4em; color: var(--muted);
}

.new-chat {
  width: 100%; padding: 12px;
  background: var(--ink); color: var(--bg);
  border: 1px solid var(--ink); cursor: pointer;
  font-family: var(--font-sans); font-size: 13px; font-weight: 600; letter-spacing: 0.12em;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
  margin-bottom: 20px;
}
.new-chat:hover { background: transparent; color: var(--ink); }

.credits-card {
  border: 1px solid var(--line-strong);
  padding: 18px; margin-bottom: 24px;
  position: relative; overflow: hidden;
}
.credits-card::after {
  content: "∞"; position: absolute; right: -8px; top: -18px;
  font-family: var(--font-serif); font-size: 72px; color: var(--ink); opacity: 0.06;
}
.label { font-size: 9px; letter-spacing: 0.26em; color: var(--faint); display: block; }
.credits-value {
  font-family: var(--font-serif); font-size: 34px; font-weight: 560;
  margin: 8px 0 14px; letter-spacing: 0.01em;
}
.redeem-btn {
  width: 100%; padding: 9px;
  background: transparent; color: var(--ink);
  border: 1px solid var(--line-strong); cursor: pointer;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em;
  transition: border-color 0.3s, background 0.3s;
}
.redeem-btn:hover { border-color: var(--ink); background: rgba(244,243,238,0.06); }
.credits-tip { font-size: 9px; color: var(--faint); margin-top: 12px; letter-spacing: 0.04em; line-height: 1.8; }

.side-block { margin-bottom: 24px; }
.side-block .label { margin-bottom: 10px; }

.mode-switch { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line-strong); }
.mode-switch button {
  padding: 10px 2px; background: transparent; color: var(--muted);
  border: none; border-right: 1px solid var(--line);
  cursor: pointer; font-family: var(--font-sans); font-size: 12px; font-weight: 500;
  transition: background 0.3s, color 0.3s;
}
.mode-switch button:last-child { border-right: none; }
.mode-switch button em {
  display: block; font-style: normal; font-family: var(--font-mono);
  font-size: 8px; color: var(--faint); margin-top: 2px;
}
.mode-switch button.active { background: var(--ink); color: var(--bg); }
.mode-switch button.active em { color: rgba(10,10,10,0.55); }

.level-switch { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line-strong); }
.level-switch button {
  padding: 10px 2px; background: transparent; color: var(--muted);
  border: none; border-right: 1px solid var(--line);
  cursor: pointer; font-family: var(--font-sans); font-size: 12px; font-weight: 500;
  transition: background 0.3s, color 0.3s;
}
.level-switch button:last-child { border-right: none; }
.level-switch button.active { background: var(--ink); color: var(--bg); }

.mode-desc { font-size: 9.5px; color: var(--faint); margin-top: 10px; letter-spacing: 0.04em; }

.side-history { flex: 1; min-height: 80px; margin-bottom: 16px; }
.side-history .label { margin-bottom: 10px; }
.side-history ul { list-style: none; }
.side-history li {
  padding: 9px 10px; border: 1px solid var(--line); margin-bottom: 6px;
  font-size: 12px; color: var(--muted); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: border-color 0.3s, color 0.3s;
}
.side-history li:hover { border-color: var(--ink); color: var(--ink); }
.side-history .empty { border: none; color: var(--faint); cursor: default; font-size: 11px; }

.side-notice { font-size: 9px; color: var(--faint); line-height: 1.9; border-top: 1px solid var(--line); padding-top: 14px; }

/* ---------- 主区 ---------- */
.chat-main { display: flex; flex-direction: column; height: 100dvh; min-width: 0; }

.chat-header {
  display: flex; align-items: center; gap: 16px;
  padding: 14px clamp(16px, 3vw, 36px);
  border-bottom: 1px solid var(--line);
  background: rgba(10,10,10,0.82);
  backdrop-filter: blur(14px);
}
.side-toggle {
  display: none; background: transparent; border: 1px solid var(--line-strong);
  color: var(--ink); font-size: 14px; padding: 6px 10px; cursor: pointer;
}
.chat-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.chat-title img { width: 28px; height: 28px; }
.chat-title h1 { font-size: 15px; font-weight: 700; letter-spacing: 0.1em; }
.chat-title p { font-size: 9px; letter-spacing: 0.2em; color: var(--faint); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.credits-badge {
  font-size: 10px; letter-spacing: 0.16em;
  border: 1px solid var(--line-strong); padding: 7px 12px; color: var(--ink);
  white-space: nowrap;
}
.credits-badge.unlimited { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.back-home { font-size: 10px; letter-spacing: 0.14em; color: var(--muted); text-decoration: none; transition: color 0.3s; white-space: nowrap; }
.back-home:hover { color: var(--ink); }

/* 头部 API 设置按钮 */
.cfg-open {
  font-size: 10px; letter-spacing: 0.16em;
  border: 1px solid var(--line-strong); padding: 7px 12px; color: var(--ink);
  background: transparent; cursor: pointer; white-space: nowrap;
  transition: background 0.3s, color 0.3s;
}
.cfg-open:hover { background: var(--ink); color: var(--bg); }

/* ---------- 消息流 ---------- */
.messages {
  flex: 1; overflow-y: auto;
  padding: clamp(20px, 4vw, 48px) clamp(16px, 4vw, 48px);
  display: flex; flex-direction: column; gap: 26px;
}
.msg-inner { max-width: 780px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 26px; }

.msg-row { display: flex; gap: 14px; animation: msgIn 0.5s var(--ease); }
@keyframes msgIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.msg-row.user { justify-content: flex-end; }
.msg-row.user .bubble {
  background: var(--ink); color: var(--bg);
  border: 1px solid var(--ink);
  max-width: 78%;
  padding: 13px 18px;
  font-size: 14.5px; line-height: 1.8;
  white-space: pre-wrap; word-break: break-word;
}
.msg-row.bot { align-items: flex-start; }
.msg-avatar {
  width: 30px; height: 30px; flex: none;
  border: 1px solid var(--line-strong);
  display: grid; place-items: center;
}
.msg-avatar img { width: 18px; height: 18px; }
.bot-body { min-width: 0; flex: 1; }
.bubble-bot {
  border: 1px solid var(--line);
  padding: 14px 18px;
  font-size: 14.5px; line-height: 1.9;
  white-space: pre-wrap; word-break: break-word;
  color: var(--ink);
}
.bubble-bot.streaming::after {
  content: "▍"; color: var(--faint); animation: blink 0.9s steps(1) infinite;
}

/* 欢迎卡 */
.welcome { border: 1px solid var(--line); padding: clamp(24px, 4vw, 44px); }
.welcome .eyebrow { margin-bottom: 18px; }
.welcome h2 { font-size: clamp(26px, 3.4vw, 40px); font-weight: 620; line-height: 1.2; margin-bottom: 14px; }
.welcome h2 .serif-italic { font-weight: 420; }
.welcome > p { color: var(--muted); font-size: 14px; max-width: 560px; margin-bottom: 26px; }
.welcome-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.welcome-grid div { background: var(--bg); padding: 16px 18px; }
.welcome-grid strong { display: block; font-size: 13px; margin-bottom: 6px; letter-spacing: 0.06em; }
.welcome-grid span { font-size: 11.5px; color: var(--muted); line-height: 1.7; }
.welcome-promo {
  margin-top: 22px; padding: 14px 18px;
  border: 1px dashed var(--line-strong);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em; color: var(--muted);
}
.welcome-promo strong { color: var(--ink); }
@media (max-width: 720px) { .welcome-grid { grid-template-columns: 1fr; } }

/* 思考过程块 */
.thinking {
  border: 1px solid var(--line); margin-bottom: 14px;
  font-family: var(--font-mono); font-size: 11.5px;
}
.thinking-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer; user-select: none;
  color: var(--muted); letter-spacing: 0.1em;
  border-bottom: 1px solid transparent;
  transition: color 0.3s;
}
.thinking-head:hover { color: var(--ink); }
.thinking-head .t-badge {
  border: 1px solid var(--line-strong); padding: 2px 8px;
  font-size: 9px; letter-spacing: 0.2em; color: var(--ink);
}
.thinking-head .t-status { margin-left: auto; font-size: 9.5px; color: var(--faint); }
.thinking-body { padding: 6px 14px 12px; display: none; }
.thinking.open .thinking-body { display: block; border-top: 1px solid var(--line); }
.thinking-step { padding: 7px 0 7px 22px; position: relative; color: var(--muted); line-height: 1.7; }
.thinking-step::before {
  content: "○"; position: absolute; left: 0; top: 7px; color: var(--faint); font-size: 10px;
}
.thinking-step.done::before { content: "●"; color: var(--ink); }
.thinking-step.done { color: var(--ink); }

/* 生成进度 */
.gen-progress { border: 1px solid var(--line-strong); padding: 18px; margin-bottom: 14px; }
.gen-progress .g-title { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.16em; color: var(--muted); margin-bottom: 14px; }
.gen-bar { height: 3px; background: rgba(244,243,238,0.12); margin-bottom: 12px; }
.gen-bar i { display: block; height: 100%; background: var(--ink); width: 0; transition: width 0.4s var(--ease); }
.gen-steps { font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); line-height: 2; }
.gen-steps .done { color: var(--ink); }
.gen-steps .active { color: var(--ink); }
.gen-steps .active::after { content: " …"; animation: blink 0.9s steps(1) infinite; }

/* 媒体卡片（图片 / 视频） */
.media-card { border: 1px solid var(--line-strong); margin-bottom: 6px; }
.media-card canvas, .media-card img { display: block; width: 100%; height: auto; background: #101010; }
.media-meta {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 11px 14px; border-top: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.12em; color: var(--faint);
}
.media-meta .m-dl {
  margin-left: auto; color: var(--ink); text-decoration: none;
  border: 1px solid var(--line-strong); padding: 4px 12px;
  transition: background 0.3s, color 0.3s;
}
.media-meta .m-dl:hover { background: var(--ink); color: var(--bg); }
.video-controls { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--line); }
.video-controls button {
  width: 34px; height: 34px; border: 1px solid var(--ink);
  background: var(--ink); color: var(--bg); cursor: pointer; font-size: 12px;
  transition: background 0.3s, color 0.3s;
}
.video-controls button:hover { background: transparent; color: var(--ink); }
.video-controls .v-time { font-family: var(--font-mono); font-size: 10px; color: var(--muted); letter-spacing: 0.1em; }
.video-controls .v-bar { flex: 1; height: 3px; background: rgba(244,243,238,0.12); }
.video-controls .v-bar i { display: block; height: 100%; background: var(--ink); width: 0; }

/* ---------- 输入区 ---------- */
.composer-wrap {
  border-top: 1px solid var(--line);
  padding: 16px clamp(16px, 4vw, 48px) 14px;
  background: rgba(10,10,10,0.9);
  backdrop-filter: blur(14px);
}
.composer {
  max-width: 780px; margin: 0 auto;
  display: flex; gap: 12px; align-items: flex-end;
  border: 1px solid var(--line-strong);
  padding: 12px 12px 12px 18px;
  transition: border-color 0.3s;
}
.composer:focus-within { border-color: var(--ink); }
.composer textarea {
  flex: 1; background: transparent; border: none; outline: none; resize: none;
  color: var(--ink); font-family: var(--font-sans); font-size: 14.5px; line-height: 1.7;
  max-height: 140px;
}
.composer textarea::placeholder { color: var(--faint); }
.send-btn {
  padding: 10px 22px; flex: none;
  background: var(--ink); color: var(--bg);
  border: 1px solid var(--ink); cursor: pointer;
  font-family: var(--font-sans); font-size: 13px; font-weight: 600; letter-spacing: 0.1em;
  transition: background 0.3s, color 0.3s;
}
.send-btn:hover { background: transparent; color: var(--ink); }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.send-btn:disabled:hover { background: var(--ink); color: var(--bg); }
.composer-hint {
  max-width: 780px; margin: 10px auto 0;
  font-size: 9.5px; letter-spacing: 0.14em; color: var(--faint);
}

/* ---------- 兑换弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(5,5,5,0.82);
  display: none; place-items: center;
  padding: 20px;
  backdrop-filter: blur(6px);
}
.modal-mask.open { display: grid; }
.modal {
  width: min(440px, 100%);
  background: var(--bg); border: 1px solid var(--line-strong);
  padding: clamp(26px, 4vw, 40px);
  animation: msgIn 0.4s var(--ease);
}
.modal-tag { font-size: 9px; letter-spacing: 0.3em; color: var(--faint); }
.modal h2 { font-size: 30px; font-weight: 620; margin: 10px 0 8px; }
.modal p { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.modal strong { color: var(--ink); }
.modal input {
  width: 100%; padding: 13px 16px;
  background: transparent; border: 1px solid var(--line-strong);
  color: var(--ink); font-family: var(--font-mono); font-size: 14px; letter-spacing: 0.1em;
  outline: none; transition: border-color 0.3s;
}
.modal input:focus { border-color: var(--ink); }
.modal input + input { margin-top: 10px; }
.modal .modal-note { margin-top: 14px; margin-bottom: 0; }
.modal-actions { display: flex; gap: 12px; margin-top: 20px; }
.modal-actions .btn { flex: 1; justify-content: center; padding: 12px; }
.modal-note { margin-top: 18px; font-size: 9.5px; color: var(--faint); line-height: 1.9; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 110px; z-index: 300;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg);
  padding: 11px 22px; font-size: 13px; font-weight: 500; letter-spacing: 0.06em;
  opacity: 0; pointer-events: none;
  transition: opacity 0.35s, transform 0.35s var(--ease);
  max-width: 86vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 平台标签 / 模型说明 ---------- */
.platform-tag {
  font-size: 8.5px; letter-spacing: 0.3em; color: var(--faint);
  margin-bottom: 2px;
}
.side-model-note {
  font-size: 9px; letter-spacing: 0.18em; color: var(--faint);
  border: 1px solid var(--line); padding: 7px 10px;
  margin-bottom: 14px; text-align: center;
}
.side-link {
  display: block; text-decoration: none; color: var(--ink);
  border: 1px solid var(--line-strong); padding: 11px 12px;
  margin-bottom: 20px;
  transition: background 0.3s, color 0.3s;
}
.side-link:hover { background: var(--ink); color: var(--bg); }
.side-link span { display: block; font-size: 10px; letter-spacing: 0.2em; font-weight: 500; }
.side-link em { display: block; font-style: normal; font-size: 8.5px; color: var(--faint); margin-top: 4px; }
.side-link:hover em { color: rgba(10,10,10,0.55); }
.mode-switch button b { display: block; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; }
.mode-switch button em {
  display: block; font-style: normal; font-family: var(--font-mono);
  font-size: 8px; color: var(--faint); margin-top: 2px;
}

/* ---------- 富文本（表格 / 代码框） ---------- */
.rt { font-size: 14px; line-height: 1.9; }
.rt p { margin: 0 0 10px; color: var(--ink); }
.rt p:last-child { margin-bottom: 0; }
.rt strong { color: var(--ink); font-weight: 700; }
.rt-table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 12.5px; }
.rt-table th, .rt-table td {
  border: 1px solid var(--line); padding: 9px 12px; text-align: left;
}
.rt-table th {
  background: rgba(244,243,238,0.06); color: var(--ink);
  font-weight: 600; letter-spacing: 0.06em; white-space: nowrap;
}
.rt-table td { color: var(--muted); }
.code-block { border: 1px solid var(--line-strong); margin: 12px 0; background: #0d0d0d; }
.code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.code-head .lang { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.24em; color: var(--muted); }
.copy-btn {
  background: transparent; border: 1px solid var(--line-strong); color: var(--ink);
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.14em;
  padding: 4px 12px; cursor: pointer; transition: background 0.3s, color 0.3s;
}
.copy-btn:hover { background: var(--ink); color: var(--bg); }
.code-block pre {
  margin: 0; padding: 14px 16px; overflow-x: auto;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.8; color: #d8d8d2;
}
.code-block pre::-webkit-scrollbar { height: 8px; }
.code-block pre::-webkit-scrollbar-thumb { background: #2c2c2a; }

/* 检索来源行 */
.src-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 10px; font-size: 9.5px; letter-spacing: 0.12em;
}
.src-label { color: var(--faint); }
.src-item {
  border: 1px solid var(--line-strong); padding: 3px 10px;
  color: var(--muted); text-decoration: none;
  transition: border-color 0.3s, color 0.3s;
}
.src-item.ok { color: var(--ink); border-color: rgba(244,243,238,0.35); }
.src-item.dim { color: var(--faint); }
a.src-item:hover { border-color: var(--ink); color: var(--ink); }

/* 图片容器 / 加载态 */
.img-holder { position: relative; min-height: 220px; background: #101010; }
.img-holder img { display: block; width: 100%; height: auto; background: #101010; opacity: 0; transition: opacity 0.6s var(--ease); }
.img-holder img.show { opacity: 1; }
.img-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 11px; letter-spacing: 0.16em; color: var(--muted);
  background: #101010;
}
.spin {
  width: 14px; height: 14px; flex: none;
  border: 1.5px solid rgba(244,243,238,0.2);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 视频逐帧序列（交叉淡入动画） */
.seq-holder { position: relative; aspect-ratio: 16 / 9; background: #101010; min-height: 220px; }
.seq-frame {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 0.45s var(--ease);
  pointer-events: none;
}
.seq-frame.active { opacity: 1; }

/* 生成说明行 */
.gen-note {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.1em;
  color: var(--faint); margin-top: 8px;
}

/* ---------- 响应式 ---------- */
.side-backdrop { display: none; }
@media (max-width: 900px) {
  .chat-app { grid-template-columns: 1fr; }
  .chat-side {
    position: fixed; left: 0; top: 0; bottom: 0; width: 288px;
    transform: translateX(-100%);
    transition: transform 0.4s var(--ease);
    background: var(--bg);
  }
  .chat-side.open { transform: none; box-shadow: 30px 0 80px rgba(0,0,0,0.6); }
  .side-backdrop {
    display: none; position: fixed; inset: 0; z-index: 50;
    background: rgba(5,5,5,0.7);
  }
  .side-backdrop.show { display: block; }
  .side-toggle { display: block; }
  .msg-row.user .bubble { max-width: 88%; }
  .chat-title h1 { font-size: 13px; }
}
