/* Webot 控制台设计系统（重新设计版） */
:root {
  /* 专业深色色板（低饱和、视觉友好、高可读性） */
  --bg: #0e1218; --bg-deep: #0a0d12;
  --panel: #141a22; --panel-2: #1a212c;
  --border: #222a36; --border-2: #2d3745;
  --text: #e6eaf0; --muted: #8b95a5; --faint: #5c6675;
  --accent: #5b8def; --accent-soft: #1c2a42;
  --ok: #34c48c; --warn: #e8a13c; --err: #e05d5d; --purple: #9d8bf5;
  --radius: 10px; --radius-sm: 6px;
  --mono: "SF Mono", "Cascadia Code", Consolas, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 14px; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }

/* ---------- 登录 ---------- */
.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(1200px 600px at 30% 20%, #16202f 0%, var(--bg) 55%); }
.login-box { background: var(--panel); padding: 36px 32px; border-radius: 16px; border: 1px solid var(--border); width: 340px; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.login-box .brand { text-align: center; margin-bottom: 24px; }
.login-box input { width: 100%; padding: 11px 12px; margin-bottom: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px; }
.login-box input:focus { outline: none; border-color: var(--accent); }
.login-box button { width: 100%; padding: 11px; border-radius: 8px; font-size: 14px; }
.err { color: var(--err); margin-top: 10px; font-size: 12px; text-align: center; }

/* ---------- 品牌 ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), #7aa5ff); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; flex-shrink: 0; box-shadow: 0 4px 14px rgba(79,140,255,.3); }
.brand h2 { font-size: 16px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ---------- 布局 ---------- */
#app { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 208px; background: var(--panel); border-right: 1px solid var(--border); padding: 16px 12px; display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar .brand { padding: 4px 8px 16px; }
.nav-btn { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 9px 12px; margin-bottom: 2px; background: none; border: none; border-radius: 8px; color: var(--text); cursor: pointer; font-size: 13.5px; transition: background .15s; }
.nav-btn:hover { background: var(--panel-2); }
.nav-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-ico { width: 20px; text-align: center; }
.nav-badge { margin-left: auto; background: var(--err); color: #fff; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; }
.sidebar-foot { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.conn-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex-shrink: 0; }
.dot.ok { background: var(--ok); box-shadow: 0 0 6px rgba(62,207,142,.5); }
.dot.warn { background: var(--warn); box-shadow: 0 0 6px rgba(245,166,35,.5); }
.dot.err { background: var(--err); box-shadow: 0 0 6px rgba(242,95,92,.5); }
.dot.purple { background: var(--purple); }

/* ---------- 内容 ---------- */
.content { flex: 1; overflow-y: auto; padding: 24px 28px; }
.view-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.view-head h1 { font-size: 20px; }
h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 12px; letter-spacing: .3px; }

/* ---------- 健康条 ---------- */
.health-bar { display: flex; gap: 20px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 18px; margin-bottom: 20px; align-items: center; }
.health-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.health-item .dot { width: 10px; height: 10px; }

/* ---------- 卡片 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; transition: border-color .15s; }
.card:hover { border-color: var(--border-2); }
.card .num { font-size: 26px; font-weight: 700; line-height: 1.2; }
.card .label { color: var(--muted); font-size: 12px; margin-top: 4px; }
.card .sub { color: var(--faint); font-size: 11px; margin-top: 2px; }

/* ---------- 面板/网格 ---------- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 .panel { margin-bottom: 0; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-3 .panel { margin-bottom: 0; }
.kpi-rows { display: flex; flex-direction: column; gap: 6px; }
.kpi-rows .kpi { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; }
.kpi-rows .kpi b { font-size: 16px; font-weight: 700; }
.kpi-rows .kpi .muted { font-size: 11px; }
@media (max-width: 1000px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .grid-2 .panel, .grid-3 .panel { margin-bottom: 16px; } }

/* ---------- 表格 ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 500; white-space: nowrap; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: var(--panel-2); }
.tbl td { color: var(--text); }
.status { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.status.pending { background: #1f2c44; color: #8ab4ff; }
.status.processing { background: #38301f; color: #e8c96a; }
.status.succeeded { background: #17332a; color: var(--ok); }
.status.failed { background: #351f1f; color: var(--err); }
.status.retrying { background: #33271a; color: var(--warn); }
.status.paused { background: #29213f; color: var(--purple); }
.status.alert { background: #351f1f; color: var(--err); }
.status.online { background: #17332a; color: var(--ok); }
.status.unknown { background: #232a37; color: var(--muted); }

/* ---------- 工具条/表单 ---------- */
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.toolbar select, .toolbar input { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; color: var(--text); padding: 8px 10px; font-size: 13px; }
.toolbar select:focus, .toolbar input:focus { outline: none; border-color: var(--accent); }
button:focus-visible, .nav-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button { background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 8px; color: var(--text); padding: 8px 14px; cursor: pointer; font-size: 13px; transition: all .15s; }
button:hover { border-color: var(--accent); color: var(--accent); }
button.primary { background: var(--accent); border: none; color: #fff; }
button.primary:hover { background: #4a7de0; color: #fff; }
button.warning { background: #e05d5d; border: none; color: #fff; }
button.warning:hover { background: #c94e4e; color: #fff; }
button.mini { padding: 3px 9px; font-size: 12px; }
button.ghost { background: transparent; }
button.block { width: 100%; }
textarea, input[type="text"], input[type="password"], input[type="number"] { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); padding: 8px 10px; width: 100%; margin: 6px 0; font-size: 13px; }
textarea:focus, input:focus { outline: none; border-color: var(--accent); }
.row { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.row label { color: var(--muted); font-size: 12px; }
.chk { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; }
.ok { color: var(--ok); font-size: 12px; margin-top: 8px; }
.empty-hint { color: var(--faint); text-align: center; padding: 24px 0; font-size: 13px; }

/* ---------- 事件/轨迹列表 ---------- */
.event-list { font-size: 12px; color: var(--muted); max-height: 320px; overflow-y: auto; }
.event-list .ev { padding: 5px 0; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: center; }
.ev-badge { padding: 1px 7px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 11px; white-space: nowrap; }
.trace-list { max-height: 520px; overflow-y: auto; font-size: 12.5px; }
.trace-item { padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--text); cursor: pointer; border-radius: 8px; transition: background .1s; }
.trace-item:hover { background: var(--panel-2); }
.trace-item summary { list-style: none; cursor: pointer; }
.trace-item summary::-webkit-details-marker { display: none; }
.trace-summary { margin-top: 4px; color: var(--faint); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trace-full { background: var(--bg-deep); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; margin: 6px 0; overflow-x: auto; font-family: var(--mono); font-size: 11px; white-space: pre-wrap; word-break: break-all; max-height: 400px; overflow-y: auto; }
.trace-kind { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.tk-llm_req { background: #1f2c44; color: #8ab4ff; }
.tk-llm_resp { background: #17332a; color: var(--ok); }
.tk-tool_use { background: #33271a; color: var(--warn); }
.tk-handover { background: #29213f; color: var(--purple); }

/* ---------- 客户 ---------- */
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; color: #fff; flex-shrink: 0; }
.cust-cell { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 10px; background: #232d40; color: #9fb6d8; font-size: 11px; margin: 1px 3px 1px 0; }
.chip.tag { background: #25324a; color: #9fb6d8; }

/* ---------- 抽屉 ---------- */
.drawer-mask { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 92vw; background: var(--panel); border-left: 1px solid var(--border); z-index: 50; display: flex; flex-direction: column; box-shadow: -20px 0 60px rgba(0,0,0,.4); animation: slideIn .22s ease; }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.drawer-head h3 { margin: 0; color: var(--text); font-size: 15px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.d-sec { margin-bottom: 18px; }
.d-sec h4 { font-size: 12px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.d-send { display: flex; gap: 8px; align-items: center; }
.d-send input { flex: 1; }
.conv-msg { padding: 6px 10px; margin: 4px 0; border-radius: 8px; font-size: 13px; }
.conv-msg.in { background: #1a2636; border-left: 3px solid var(--accent); }
.conv-msg.out { background: #16342a; border-left: 3px solid var(--ok); }
.conv-msg .who { font-size: 11px; color: var(--muted); display: block; margin-bottom: 2px; }

/* ---------- 键值列表 ---------- */
.kv-list { font-size: 13px; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }
.kv .v { color: var(--text); font-weight: 500; text-align: right; max-width: 60%; word-break: break-all; }

/* ---------- 趋势图 ---------- */
.trend { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 8px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.trend-bars { display: flex; gap: 3px; align-items: flex-end; height: 110px; width: 100%; justify-content: center; }
.trend-bar { width: 8px; border-radius: 3px 3px 0 0; background: var(--accent); opacity: .85; transition: height .3s; }
.trend-bar.cust { background: var(--accent); }
.trend-bar.msg { background: var(--ok); }
.trend-bar.ok { background: #2e8b6d; }
.trend-bar.fail { background: var(--err); }
.trend-label { font-size: 11px; color: var(--muted); }
.trend-legend { display: flex; gap: 14px; margin-bottom: 8px; font-size: 11.5px; color: var(--muted); }
.trend-legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.tl-cust::before { background: var(--accent); }
.tl-msg::before { background: var(--ok); }
.tl-ok::before { background: #2e8b6d; }
.tl-fail::before { background: var(--err); }

/* ---------- Agent 配置折叠 ---------- */
details.agent-cfg { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; padding: 8px 12px; }
details.agent-cfg summary { cursor: pointer; font-size: 13px; }
details.agent-cfg textarea { margin-top: 8px; }
.flow-item { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; cursor: pointer; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.flow-item:hover { background: var(--panel-2); }
.flow-item.active { border-color: #5b8def; background: rgba(79,140,255,.08); }
.tx-card.active, .agent-card.active, .flow-card.active { border-color: #5b8def !important; background: rgba(79,140,255,.08) !important; box-shadow: 0 0 0 1px #5b8def33; }
.llm-messages { display: flex; flex-direction: column; gap: 4px; }
.llm-msg { padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel-2); }
.llm-msg .msg-tool { color: #b8860b; font-family: var(--mono, monospace); font-size: 12px; }
.llm-msg .msg-reason { color: #8e8e8e; font-style: italic; }
.msg-system { border-left: 3px solid #8b95a5; }
.msg-user { border-left: 3px solid #5b8def; }
.msg-assistant { border-left: 3px solid #2ecc71; }
.msg-tool { border-left: 3px solid #e8a13c; }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a4658; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 事务页三栏（宽/中/窄屏自适应） ---------- */
.tx-layout { display: flex; gap: 10px; align-items: flex-start; }
.tx-col-flow { width: 150px; flex-shrink: 0; }
.tx-col-tx { width: 250px; flex-shrink: 0; }
.tx-col-detail { flex: 1; min-width: 0; }
/* 宽屏（大屏显示器 ≥1500px）：加宽事务列，卡片容纳更多信息 */
@media (min-width: 1500px) {
  .tx-col-flow { width: 172px; }
  .tx-col-tx { width: 310px; }
}
/* 中屏（901-1199px）：适度压缩，保证轨迹面板空间 */
@media (max-width: 1199px) and (min-width: 901px) {
  .tx-col-flow { width: 138px; }
  .tx-col-tx { width: 228px; }
}

/* ---------- 表格列头排序 ---------- */
.tbl th.sortable { cursor: pointer; user-select: none; position: relative; padding-right: 18px; }
.tbl th.sortable:hover { color: var(--accent); }
.tbl th.sortable::after { content: "⇅"; position: absolute; right: 4px; font-size: 10px; opacity: .55; }
.tbl th.sortable.asc::after { content: "↑"; opacity: 1; color: var(--accent); }
.tbl th.sortable.desc::after { content: "↓"; opacity: 1; color: var(--accent); }
.tbl th.num, .tbl td.num { text-align: right; }

/* ---------- 费用筛选分组 ---------- */
.cost-filters { gap: 10px 6px; align-items: center; }
.cost-filter-group { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }

@media (max-width: 900px) {
  .sidebar { width: 64px; padding: 16px 8px; }
  .sidebar .brand div:last-child, .sidebar .brand-sub, .nav-btn span:not(.nav-ico), .sidebar-foot span:not(.dot) { display: none; }
  .nav-btn { justify-content: center; padding: 9px 0; }
  .content { padding: 16px; }
  /* 事务页窄屏：FLOW + 事务两列并排（不再纵向堆叠三行），轨迹全宽在下方 */
  .tx-layout { flex-wrap: wrap; }
  .tx-col-flow, .tx-col-tx { width: calc(50% - 5px); }
  .tx-col-detail { width: 100%; }
  /* 客户表格横向滚动 */
  .content .tbl-wrap { overflow-x: auto; }
}

/* ---------- 回合聚合（初始输入 → 回合：LLM 回复 / TOOL_USE / TOOL_RESULT） ---------- */
.turn-ctx { font-size: 11px; line-height: 1.55; }
.turn-ctx .llm-msg { margin: 3px 0; }
.turn-thought { font-size: 11px; color: #c8d0dc; line-height: 1.55; margin: 2px 0; }
.turn-action { font-size: 11px; color: #e8c96a; margin: 2px 0; word-break: break-all; }
.turn-tool-use { font-size: 11px; padding: 2px 0; color: #e8c96a; word-break: break-all; }
.turn-tool-result { font-size: 11px; padding: 3px 6px; border-radius: 5px; margin: 2px 0 4px; background: #1e2229; word-break: break-all; }
.turn-tool-result.ok { border-left: 2px solid #34c48c88; }
.turn-tool-result.err { border-left: 2px solid #e05d5d88; }
.turn-tool-result.pending { border-left: 2px solid #8b95a5; color: #8b93a7; }
.turn-decision { display: flex; flex-direction: column; gap: 2px; }
.run-init pre.prompt-box { margin: 2px 0; }

/* ---------- 会话列表（v17 抽屉式：默认收起，点击展开浮层） ---------- */
.chat-layout { position: relative; overflow: hidden; }
.session-mask { position: absolute; inset: 0; background: rgba(5,8,14,.5); z-index: 20; border-radius: var(--radius); }
.session-panel { position: absolute; top: 0; left: 0; bottom: 0; width: 280px; z-index: 30; background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; transform: translateX(-104%); transition: transform .22s ease; box-shadow: 10px 0 28px rgba(0,0,0,.35); }
.session-panel.open { transform: translateX(0); }
.session-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; font-size: 12px; border-bottom: 1px solid var(--border); }
.session-head button { margin-left: auto; padding: 0 6px; font-size: 12px; }
.session-list { flex: 1; overflow-y: auto; padding: 6px; }
.session-item { padding: 8px 10px; border-radius: 8px; cursor: pointer; margin-bottom: 2px; border: 1px solid transparent; transition: background .1s; }
.session-item:hover { background: var(--panel-2); }
.session-item.active { background: var(--accent-soft); border-color: var(--accent); }
.session-title { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-preview { font-size: 11px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-meta { display: flex; align-items: center; gap: 6px; font-size: 10.5px; margin-top: 3px; }
.session-status { font-size: 10.5px; font-weight: 600; }
.session-del { margin-left: auto; padding: 0 4px; font-size: 10px; visibility: hidden; }
.session-item:hover .session-del { visibility: visible; }
.session-empty { text-align: center; padding: 20px 0; font-size: 12px; }
.badge-count { margin-left: 6px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; }

/* ---------- Agent / 工具可视化 ---------- */
.tool-chip {
  display: inline-block; padding: 2px 8px; margin: 2px 4px 2px 0;
  background: var(--panel-2, #1c2534); border: 1px solid var(--border-2, #2d3748);
  border-radius: 10px; font-size: 11px; font-family: monospace; cursor: help;
}
.prompt-box {
  background: var(--panel-2, #1c2534); border: 1px solid var(--border-2, #2d3748);
  border-radius: 6px; padding: 8px; font-size: 11px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-all; max-height: 240px; overflow: auto;
  margin: 4px 0;
}

/* ===== v10 业务工作台 ===== */
.card.todo { cursor: pointer; transition: transform .1s; }
.card.todo:hover { transform: translateY(-2px); }
.card.todo.urgent { border-color: #e05d5d; }
.card.todo.new { border-color: #34c48c; }
.card.todo.warn { border-color: #e8a13c; }
.card.todo.hot { border-color: #9d8bf5; }
.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel-row { display: flex; align-items: center; gap: 8px; }
.funnel-label { width: 90px; font-size: 12px; color: var(--text-2); text-align: right; }
.funnel-bar { height: 18px; border-radius: 4px; background: linear-gradient(90deg, #5b8def, #38bdf8); min-width: 4px; }
.funnel-count { font-size: 13px; font-weight: 600; }
.lifecycle { display: flex; flex-direction: column; gap: 6px; }
.life-row { display: flex; justify-content: space-between; padding: 4px 8px; border-radius: 4px; background: var(--bg-2); }
.life-label { font-size: 13px; }
.life-count { font-weight: 600; }
.chat-item { padding: 10px 12px; border: 1px solid var(--border-2); border-radius: 8px; margin-bottom: 8px; }
.chat-item.urgent { border-color: #e05d5d; background: rgba(245,95,92,.05); }
.chat-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.chat-preview { font-size: 13px; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; }

/* ===== 对话视图（会话列表 + 消息流 + 输入区） ===== */
.chat-layout { display: flex; gap: 12px; height: calc(100vh - 170px); min-height: 420px; }

/* 右侧消息区 */
.chat-main { flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; }
.msg-stream { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; }
.chat-empty { margin: auto; text-align: center; color: var(--faint); font-size: 14px; line-height: 2; }

/* 日期分组 */
.chat-day-sep { display: flex; align-items: center; gap: 12px; margin: 14px 0 10px; color: var(--faint); font-size: 11.5px; }
.chat-day-sep::before, .chat-day-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* 消息行 */
.chat-msg { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 14px; max-width: 100%; }
.chat-msg.mine { flex-direction: row-reverse; }
.chat-avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; color: #fff; }
.chat-avatar.user { background: var(--accent); }
.chat-avatar.ai { background: var(--ok); }
.chat-avatar.sys { background: #8b95a5; }
.chat-body { max-width: 68%; display: flex; flex-direction: column; }
.chat-msg.mine .chat-body { align-items: flex-end; }
.chat-meta { font-size: 11px; color: var(--faint); margin-bottom: 3px; padding: 0 4px; }
.chat-bubble { padding: 9px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.65; word-break: break-word; white-space: pre-wrap; }
.chat-process-list { margin-bottom: 4px; display: flex; flex-direction: column; gap: 3px; }
.chat-process { font-size: 11.5px; line-height: 1.5; padding: 3px 8px; border-left: 2px solid var(--border-2); background: var(--bg-deep); border-radius: 0 6px 6px 0; color: #8b95a5; word-break: break-word; white-space: pre-wrap; max-height: 140px; overflow: auto; }
.chat-process.think { color: #8b95a5; font-style: italic; }
.chat-process.tool { color: #e8a13c; font-style: normal; }
.chat-msg.mine .chat-bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.theirs .chat-bubble { background: var(--panel-2); border: 1px solid var(--border-2); border-bottom-left-radius: 4px; }
.chat-bubble img { max-width: 260px; border-radius: 8px; display: block; margin-top: 4px; background: #fff; }
/* 验证请求卡片（<qr_request> / <sms_request> XML 协议） */
.verify-card { border-radius: 10px; padding: 10px 12px; margin: 2px 0; border: 1px solid var(--border-2); background: var(--bg-deep); }
.verify-title { font-weight: 700; font-size: 13.5px; margin-bottom: 6px; }
.verify-tip { font-size: 13px; color: var(--muted, #888); }
.verify-qr img { max-width: 220px; border-radius: 8px; display: block; background: #fff; padding: 4px; cursor: zoom-in; }
.verify-success-card { border-color: #4caf50; background: rgba(76,175,80,.08); }
.verify-success-card .verify-title { color: #2e7d32; }
/* 登录验证直接通道（方案 B）：验证卡片区（独立于对话流） */
.verify-panel { padding: 8px 10px; border-bottom: 1px solid var(--border-2); background: var(--bg-deep); }
.verify-panel.hidden { display: none; }
.verify-code-row { display: flex; gap: 6px; margin-top: 8px; align-items: center; }
.verify-code-input { flex: 1; padding: 7px 10px; border: 1px solid var(--border-2); border-radius: 6px; font-size: 14px; letter-spacing: 2px; }
/* 图片预览 lightbox（点击二维码放大，方便手机扫码） */
.img-preview-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.78); display: flex; align-items: center; justify-content: center; z-index: 9999; opacity: 0; pointer-events: none; transition: opacity .15s ease; }
.img-preview-overlay.show { opacity: 1; pointer-events: auto; }
.img-preview-box { position: relative; max-width: 92vw; max-height: 92vh; }
.img-preview-box img { max-width: 92vw; max-height: 92vh; border-radius: 10px; background: #fff; padding: 6px; box-shadow: 0 8px 40px rgba(0,0,0,.5); }
.img-preview-close { position: absolute; top: -14px; right: -14px; width: 34px; height: 34px; border-radius: 50%; border: none; background: rgba(255,255,255,.9); color: #333; font-size: 15px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.img-preview-close:hover { background: #fff; }
.chat-bubble .md-code { display: block; background: var(--bg-deep); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; margin: 6px 0; font-family: var(--mono); font-size: 12px; overflow: auto; white-space: pre-wrap; word-break: break-all; max-height: 320px; }
.chat-bubble code { font-family: var(--mono); font-size: 12px; background: var(--bg-deep); border-radius: 4px; padding: 1px 5px; }
.chat-bubble a { color: var(--accent); text-decoration: underline; }
.chat-bubble strong { font-weight: 700; }
.chat-bubble em { font-style: italic; }
.chat-bubble ul { padding-left: 18px; margin: 4px 0; }
.chat-bubble li { margin: 2px 0; }

/* 正在输入 / 停止生成 */
.chat-typing { display: inline-flex; gap: 4px; align-items: center; padding: 10px 14px; }
.chat-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.chat-typing i:nth-child(2) { animation-delay: .2s; }
.chat-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }
.chat-interrupted { font-size: 12px; color: var(--warn); cursor: pointer; margin-top: 4px; }

/* 输入区 */
.chat-composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); }
.chat-composer textarea { flex: 1; resize: none; min-height: 38px; max-height: 120px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); padding: 9px 12px; font-size: 13.5px; line-height: 1.5; margin: 0; font-family: inherit; }
.chat-composer textarea:focus { outline: none; border-color: var(--accent); }
.chat-composer button { padding: 9px 20px; height: 38px; flex-shrink: 0; }
.chat-composer button:disabled { opacity: .55; cursor: not-allowed; border-color: var(--border-2); color: var(--muted); }

