/* 企业微信侧边栏 H5 —— PC 侧边栏宽度约 300px，同时兼容移动端 */
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e6e8eb;
  --text: #1a1a1a;
  --text-2: #8a8f99;
  --brand: #2f7cf6;
  --brand-d: #1f68dd;
  --ok: #22a06b;
  --warn: #f0a020;
  --err: #e5484d;
  --radius: 10px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── 顶部 ── */
.topbar {
  flex: 0 0 auto;
  height: 42px;
  padding: 0 10px 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  min-width: 0;
}
.topbar-title span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-2);
  flex: 0 0 auto;
  transition: background .2s;
}
.dot.ok   { background: var(--ok); box-shadow: 0 0 0 3px rgba(34,160,107,.15); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(240,160,32,.15); }
.dot.err  { background: var(--err); box-shadow: 0 0 0 3px rgba(229,72,77,.15); }

.icon-btn {
  border: 0; background: transparent; color: var(--text-2);
  font-size: 18px; line-height: 1; padding: 4px 6px; cursor: pointer;
  border-radius: 6px;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }

/* ── 调试面板 ── */
.debug {
  flex: 0 0 auto;
  background: #fbfbfc;
  border-bottom: 1px solid var(--line);
  padding: 8px 12px 10px;
  font-size: 11.5px;
  max-height: 42vh;
  overflow: auto;
}
.debug-row {
  display: flex;
  gap: 8px;
  padding: 2px 0;
  color: var(--text-2);
}
.debug-row span { flex: 0 0 62px; }
.debug-row b {
  color: var(--text); font-weight: 500;
  word-break: break-all;
  flex: 1; min-width: 0;
}
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.debug-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.debug-err {
  margin-top: 8px; padding: 7px 9px;
  background: #fff1f0; border: 1px solid #ffd6d4; border-radius: 7px;
  color: #b32b2f; font-size: 11.5px; white-space: pre-wrap; word-break: break-all;
}
.mini-btn {
  border: 1px solid var(--line); background: #fff; color: var(--text-2);
  font-size: 11px; padding: 3px 8px; border-radius: 6px; cursor: pointer;
}
.mini-btn:hover { border-color: #c9ccd1; color: var(--text); }

/* ── 输入区 ── */
.composer {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  gap: 8px;
  min-height: 0;
  background: var(--card);
}
.hint-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; color: var(--text-2);
}
.badge {
  background: #eef4ff; color: var(--brand-d);
  padding: 2px 7px; border-radius: 5px; font-size: 11px; font-weight: 500;
  max-width: 65%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.counter.over { color: var(--err); font-weight: 600; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: #fafbfc; color: #4a4f57;
  font-size: 11.5px; padding: 3px 9px; border-radius: 20px; cursor: pointer;
  white-space: nowrap;
}
.chip:hover { border-color: var(--brand); color: var(--brand-d); background: #f2f7ff; }

textarea {
  flex: 1 1 auto;
  min-height: 84px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 10px;
  font: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .15s;
}
textarea:focus { border-color: var(--brand); }
textarea::placeholder { color: #b3b8c0; }

.send-row { display: flex; }
.send-btn {
  width: 100%;
  height: 38px;
  border: 0; border-radius: 8px;
  background: var(--brand); color: #fff;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.send-btn:hover:not(:disabled) { background: var(--brand-d); }
.send-btn:disabled { background: #c9d3e4; cursor: not-allowed; }
.send-btn.sending { background: var(--brand-d); }
.send-btn.done { background: var(--ok); }
.send-btn.fail { background: var(--err); }

/* ── 发送记录 ── */
.history {
  flex: 0 0 auto;
  max-height: 34vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-top: 1px solid var(--line);
  overflow: hidden;
}
.history-head {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px 5px;
  font-size: 11.5px; color: var(--text-2); font-weight: 500;
}
.history-list {
  list-style: none; margin: 0; padding: 0 12px 10px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
}
.history-empty { color: #b3b8c0; font-size: 11.5px; text-align: center; padding: 8px 0; }
.history-item {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 12px;
}
.history-item.ok   { border-left-color: var(--ok); }
.history-item.fail { border-left-color: var(--err); }
.history-item.wait { border-left-color: var(--warn); }
.history-item .hi-text {
  color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-all;
}
.history-item .hi-meta {
  margin-top: 3px; font-size: 11px; color: var(--text-2);
  display: flex; justify-content: space-between; gap: 8px;
}
.history-item .hi-err { color: var(--err); font-size: 11px; margin-top: 2px; word-break: break-all; }

/* ── 中转状态 pill ── */
.topbar-right { display: flex; align-items: center; gap: 4px; }
.relay-pill {
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 20px;
  background: #f3f4f6;
  color: var(--text-2);
  white-space: nowrap;
}
.relay-pill.on { background: #eaf7f0; color: var(--ok); }

/* ── 远程指令横幅 ── */
.banner {
  flex: 0 0 auto;
  padding: 8px 12px;
  background: #fff8e6;
  border-bottom: 1px solid #ffe1a8;
  font-size: 11.5px;
  color: #7a5200;
  line-height: 1.6;
}
.banner-msg { word-break: break-all; }
.banner-actions { display: flex; gap: 6px; margin-top: 6px; }

/* ── AI 候选 ── */
.ai {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
  padding: 0;
  overflow: hidden;
}
.ai-head {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #3d4652;
  background: #f4f6fa;
  user-select: none;
}
.ai-head::-webkit-details-marker { display: none; }
.ai-head::after { content: '▾'; color: #a8afb9; font-size: 11px; }
.ai[open] .ai-head::after { content: '▴'; }
.ai-mode {
  margin-left: auto;
  margin-right: 8px;
  font-weight: 400;
  font-size: 10.5px;
  color: var(--text-2);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1px 7px;
}
.ai-body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 7px; }
.ai-body input {
  width: 100%;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 9px;
  font: inherit;
  font-size: 12px;
  outline: none;
  background: #fff;
}
.ai-body input:focus { border-color: var(--brand); }
.ai-actions { display: flex; gap: 6px; }
.mini-btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.mini-btn.primary:hover:not(:disabled) { background: var(--brand-d); border-color: var(--brand-d); color: #fff; }
.mini-btn:disabled { opacity: .6; cursor: not-allowed; }

.ai-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.ai-empty {
  font-size: 11.5px;
  color: var(--text-2);
  text-align: center;
  padding: 8px 4px;
  line-height: 1.6;
}
.ai-empty.err { color: var(--err); text-align: left; }
.ai-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: .12s;
}
.ai-card:hover { border-color: var(--brand); background: #f7fbff; }
.ai-text {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text);
  word-break: break-word;
}
.ai-meta {
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 10.5px;
  color: #a8afb9;
}
.ai-use { color: var(--brand); opacity: 0; transition: .12s; }
.ai-card:hover .ai-use { opacity: 1; }

/* 窄屏（手机企微）微调 */
@media (max-width: 360px) {
  .composer { padding: 8px 10px; }
  .debug { padding: 6px 10px 8px; }
}
