/* 黄金消费与投资审计 v2 · ChatGPT 三区布局（会话列表 / 聊天窗口 / 能力抽屉） */
:root {
  --bg: #ffffff;
  --bg-2: #f7f8fa;
  --sidebar: #f3f4f6;
  --ink: #1f2937;
  --ink-2: #6b7280;
  --ink-3: #9ca3af;
  --navy: #1a365d;
  --navy-2: #24466f;
  --gold: #b8860b;
  --gold-2: #d4af37;
  --gold-bg: #faf6ea;
  --line: #e5e7eb;
  --line-2: #eef0f2;
  --navy-bg: #eef3f9;
  --ok: #15803d;
  --err: #b91c1c;
  --radius: 12px;
  --sidebar-w: 264px;
  --drawer-w: 360px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button { font-family: inherit; }

/* ---------- 顶栏 ---------- */
.topbar {
  height: 54px; flex-shrink: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-seal svg { display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-size: 15.5px; font-weight: 700; color: var(--navy); font-family: "Kaiti SC", "STKaiti", serif; letter-spacing: .5px; white-space: nowrap; }
.brand-sub { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.topbar-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-left: 6px; }
.badge {
  font-size: 11px; color: var(--ink-2); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}
.badge-gold { color: var(--gold); background: var(--gold-bg); border-color: #eadfc3; font-weight: 700; }
.badge-green { color: var(--ok); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.btn-ghost, .btn-primary-sm {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 9px; padding: 6px 12px; font-size: 13px; cursor: pointer; transition: all .15s;
}
.btn-ghost { border: 1px solid var(--line); background: #fff; color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--navy); color: var(--navy); }
.btn-primary-sm { border: none; background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: #fff; }
.btn-primary-sm:hover { filter: brightness(1.1); }
.icon-btn {
  border: none; background: transparent; color: var(--ink-2);
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: background .15s;
}
.icon-btn:hover { background: var(--bg-2); color: var(--navy); }
.mobile-only { display: none; }

/* ---------- 三区骨架 ---------- */
.app { flex: 1; display: flex; min-height: 0; }

/* 会话列表 */
.sessions {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 12px 10px 0;
}
.new-chat {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 10px; padding: 9px 12px; font-size: 13.5px; cursor: pointer;
  text-align: left; transition: all .15s; margin-bottom: 12px;
}
.new-chat:hover { border-color: var(--gold); background: var(--gold-bg); }
.sessions-title { font-size: 11px; color: var(--ink-3); padding: 0 8px 6px; }
.sessions-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.session-item {
  position: relative;
  border-radius: 9px; padding: 8px 30px 8px 10px; cursor: pointer;
  font-size: 13px; color: var(--ink); transition: background .12s;
  display: flex; flex-direction: column; gap: 1px;
}
.session-item:hover { background: rgba(0,0,0,.05); }
.session-item.active { background: var(--navy-bg); }
.session-item.active .s-title { color: var(--navy); font-weight: 600; }
.s-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-time { font-size: 10.5px; color: var(--ink-3); }
.session-del {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border-radius: 6px; border: none;
  background: transparent; color: var(--ink-3); cursor: pointer; display: none;
  align-items: center; justify-content: center; font-size: 13px;
}
.session-item:hover .session-del { display: inline-flex; }
.session-del:hover { color: var(--err); background: rgba(0,0,0,.06); }
.sessions-foot { padding: 10px 8px 12px; border-top: 1px solid var(--line-2); }
.foot-line { font-size: 11px; color: var(--ink-2); }
.foot-line.dim { color: var(--ink-3); }
.sessions-mask { display: none; }

/* 聊天窗口 */
.chatwin { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.chat-scroll { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.chat-inner { max-width: 820px; margin: 0 auto; padding: 26px 24px 12px; display: flex; flex-direction: column; gap: 20px; }

/* 空态 */
.empty-state { max-width: 760px; margin: 0 auto; padding: 7vh 24px 30px; text-align: center; }
.empty-seal svg { display: inline-block; }
.empty-state h2 { margin: 14px 0 6px; font-size: 21px; color: var(--navy); font-family: "Kaiti SC", serif; letter-spacing: 1px; }
.empty-sub { margin: 0 0 18px; color: var(--ink-2); font-size: 14px; }
.empty-steps { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 26px; }
.empty-steps span { background: var(--bg-2); border: 1px solid var(--line); color: var(--ink-2); border-radius: 999px; font-size: 12.5px; padding: 4px 14px; }
.chip-groups { text-align: left; display: flex; flex-direction: column; gap: 14px; }
.chip-group-title { font-size: 12px; color: var(--gold); font-weight: 700; margin-bottom: 7px; letter-spacing: .5px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  max-width: 100%; text-align: left;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 12px; padding: 8px 12px; font-size: 12.8px; line-height: 1.5; cursor: pointer;
  transition: all .15s;
}
.chip:hover { border-color: var(--gold); background: var(--gold-bg); }
.chip .chip-scene { display: inline-block; font-size: 10.5px; color: var(--navy); background: var(--navy-bg); border-radius: 4px; padding: 0 5px; margin-right: 6px; }

/* 消息 */
.msg-user { display: flex; justify-content: flex-end; }
.msg-user .bubble {
  background: var(--navy-bg); border: 1px solid #d7e2ee;
  border-radius: 14px 14px 4px 14px; padding: 10px 14px;
  max-width: 78%; white-space: pre-wrap; font-size: 14.5px;
}
.msg-agent { display: flex; flex-direction: column; }
.audit-card {
  position: relative;
  background: #fff; border: 1.5px solid #e6d9b8; border-left: 4px solid var(--gold);
  border-radius: 4px 12px 12px 4px; padding: 16px 18px 12px;
  box-shadow: 0 2px 10px rgba(184, 134, 11, .07);
}
.audit-card.plain { border-color: var(--line); border-left-color: #c9d4e0; box-shadow: none; }
.audit-card::after {
  content: "审计"; position: absolute; top: 10px; right: 14px; width: 38px; height: 38px;
  border: 2px solid rgba(184,134,11,.75); color: rgba(184,134,11,.85); border-radius: 7px;
  font-size: 13px; display: flex; align-items: center; justify-content: center;
  font-family: "Kaiti SC", serif; transform: rotate(6deg); pointer-events: none;
  letter-spacing: 2px; background: rgba(250,246,234,.5);
}
.audit-card.plain::after { display: none; }
.msg-meta { font-size: 11px; color: var(--ink-3); margin-top: 6px; }

/* 审计单 markdown */
.audit-body h2, .audit-body h3, .audit-body h4 { color: var(--navy); margin: 14px 0 8px; line-height: 1.45; }
.audit-body h2 { font-size: 16.5px; border-bottom: 2px solid var(--gold-2); padding-bottom: 5px; }
.audit-body h3 { font-size: 15px; }
.audit-body h4 { font-size: 14px; }
.audit-body h2:first-child { margin-top: 0; }
.audit-body p { margin: 8px 0; font-size: 14px; }
.audit-body strong { color: var(--navy); }
.audit-body ul, .audit-body ol { margin: 6px 0; padding-left: 22px; }
.audit-body li { margin: 4px 0; font-size: 14px; }
.audit-body blockquote {
  margin: 10px 0; padding: 8px 14px; background: var(--gold-bg);
  border-left: 3px solid var(--gold); border-radius: 0 8px 8px 0; color: #a05a12; font-size: 13.5px;
}
.audit-body blockquote p { margin: 0; }
.audit-body hr { border: none; border-top: 1px dashed var(--line); margin: 14px 0; }
.audit-body em { color: var(--ink-2); }
.audit-body table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 13px; display: block; overflow-x: auto; }
.audit-body th { background: var(--navy); color: #fff; font-weight: 600; padding: 7px 10px; border: 1px solid var(--navy); text-align: left; white-space: nowrap; }
.audit-body td { border: 1px solid var(--line); padding: 7px 10px; vertical-align: top; }
.audit-body tr:nth-child(even) td { background: #f7f9fb; }
.cite { display: inline-block; font-size: 10.5px; color: var(--navy); background: var(--navy-bg); border: 1px solid #d7e2ee; border-radius: 4px; padding: 0 4px; margin: 0 1px; vertical-align: 2px; font-weight: 600; }

/* 等待动画 */
.thinking { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; }
.thinking .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); animation: pulse 1.2s ease-in-out infinite; }
.thinking .dot:nth-child(2) { animation-delay: .2s; background: var(--navy); }
.thinking .dot:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.15); } }
.caret { display: inline-block; width: 8px; height: 15px; background: var(--gold); vertical-align: -2px; margin-left: 2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Composer */
.composer { flex-shrink: 0; padding: 10px 24px 14px; background: linear-gradient(180deg, rgba(255,255,255,0), #fff 30%); }
.composer-box {
  max-width: 820px; margin: 0 auto;
  display: flex; align-items: flex-end; gap: 8px;
  border: 1.5px solid var(--line); border-radius: 16px;
  background: #fff; padding: 8px 8px 8px 6px;
  transition: border-color .15s, box-shadow .15s;
}
.composer-box:focus-within { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(26,54,93,.08); }
.composer-ic { flex-shrink: 0; }
#input {
  flex: 1; resize: none; border: none; outline: none;
  font-size: 14.5px; font-family: inherit; line-height: 1.55;
  max-height: 160px; padding: 6px 4px; background: transparent; color: var(--ink);
}
#input::placeholder { color: var(--ink-3); }
.btn-send {
  flex-shrink: 0; border: none; cursor: pointer;
  width: 38px; height: 38px; border-radius: 12px;
  background: linear-gradient(135deg, var(--gold), #c9982a); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  transition: filter .15s, opacity .15s;
}
.btn-send:hover { filter: brightness(1.07); }
.btn-send:disabled { opacity: .5; cursor: not-allowed; }
.btn-send .stop-ic { display: none; }
.btn-send.sending { background: linear-gradient(135deg, var(--err), #d64541); }
.btn-send.sending .go-ic { display: none; }
.btn-send.sending .stop-ic { display: block; }
.composer-foot { max-width: 820px; margin: 6px auto 0; display: flex; justify-content: space-between; gap: 10px; font-size: 11px; color: var(--ink-3); flex-wrap: wrap; }

/* ---------- 能力抽屉 ---------- */
.cap-drawer {
  width: 0; flex-shrink: 0; overflow: hidden;
  background: var(--bg-2); border-left: 1px solid var(--line);
  transition: width .2s ease;
  display: flex; flex-direction: column;
}
.cap-drawer.open { width: var(--drawer-w); }
.cap-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.cap-head h3 { margin: 0; font-size: 15px; color: var(--navy); }
.cap-body { flex: 1; overflow-y: auto; padding: 4px 16px 12px; }
.cap-sec { margin-bottom: 16px; }
.cap-sec-title { font-size: 12px; color: var(--gold); font-weight: 700; margin-bottom: 8px; letter-spacing: .5px; }
.cap-item { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; margin-bottom: 6px; }
.cap-item .ci-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.cap-item .ci-name .ci-count { float: right; font-size: 11px; color: var(--ink-3); font-weight: 400; }
.cap-item .ci-desc { font-size: 12px; color: var(--ink-2); margin-top: 2px; line-height: 1.5; }
.cap-scenes { display: flex; flex-wrap: wrap; gap: 5px; }
.cap-scene { font-size: 11.5px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; color: var(--ink-2); }
.cap-scene b { color: var(--navy); font-weight: 600; }
.cap-foot { padding: 10px 16px; border-top: 1px solid var(--line); font-size: 11px; color: var(--ink-3); }

/* ---------- 弹层 ---------- */
.modal-mask {
  display: none; position: fixed; inset: 0; z-index: 60;
  background: rgba(15, 23, 42, .4);
  align-items: center; justify-content: center; padding: 20px;
}
.modal-mask.open { display: flex; }
.modal {
  width: 520px; max-width: 94vw; max-height: 86vh; overflow-y: auto;
  background: #fff; border-radius: 16px; padding: 18px 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h3 { margin: 0; font-size: 15.5px; color: var(--navy); }
.scene-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.scene-tab {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 999px; padding: 3px 12px; font-size: 12.5px; cursor: pointer; transition: all .15s;
}
.scene-tab:hover { border-color: var(--gold); color: var(--navy); }
.scene-tab.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.scene-fields { display: flex; flex-direction: column; gap: 9px; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 12px; color: var(--ink-2); }
.field label b.req { color: var(--gold); }
.field input, .field select, .field textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 13.5px;
  font-family: inherit; color: var(--ink); background: #fff; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--navy); box-shadow: 0 0 0 2px rgba(26,54,93,.08); }
.modal-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.form-note { font-size: 11px; color: var(--ink-3); }

/* Toast */
.toast-box { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #1f2937; color: #fff; border-radius: 10px; padding: 9px 16px; font-size: 13px; box-shadow: 0 6px 24px rgba(0,0,0,.18); max-width: 86vw; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .mobile-only { display: inline-flex; }
  .topbar-badges { display: none; }
  .sessions {
    position: fixed; z-index: 50; top: 54px; bottom: 0; left: 0;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,.1);
  }
  .sessions.open { transform: translateX(0); }
  .sessions-mask.open { display: block; position: fixed; inset: 54px 0 0 0; z-index: 40; background: rgba(0,0,0,.25); }
  .cap-drawer { position: fixed; z-index: 50; top: 54px; bottom: 0; right: 0; width: min(92vw, var(--drawer-w)) !important; transform: translateX(100%); transition: transform .2s ease; box-shadow: -4px 0 20px rgba(0,0,0,.1); }
  .cap-drawer.open { transform: translateX(0); }
  .chat-inner { padding: 18px 14px 10px; }
  .composer { padding: 8px 12px 10px; }
}
@media print {
  .topbar, .sessions, .composer, .cap-drawer, .toast-box, .btn-new { display: none !important; }
  body, .chatwin { overflow: visible; height: auto; }
  .chat-scroll { overflow: visible; }
}
