:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #eef0f3;
  --line-strong: #e3e6eb;
  --text: #1f2329;
  --text-2: #646a73;
  --text-3: #9aa0a8;
  --brand: #ff2442;
  --brand-soft: #fff1f3;
  --green: #12b76a;
  --blue: #3b6ef5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 300px;
  height: 100vh;
  gap: 1px;
  background: var(--line);
}

/* ============ 通用 ============ */
button { font: inherit; cursor: pointer; }

.ghost-btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text-2);
  padding: 6px 12px;
  border-radius: 8px;
  transition: .15s;
}
.ghost-btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.ghost-btn:disabled { opacity: .45; cursor: not-allowed; }

.primary-btn {
  border: 0;
  background: var(--brand);
  color: #fff;
  padding: 8px 22px;
  border-radius: 8px;
  font-weight: 500;
  transition: .15s;
}
.primary-btn:hover:not(:disabled) { background: #e8102f; }
.primary-btn:disabled { opacity: .5; cursor: not-allowed; }

.muted { color: var(--text-3); }

/* ============ 左栏 ============ */
.sidebar {
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 12px;
}
.logo {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #ff2442, #ff6b57);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  display: grid;
  place-items: center;
  letter-spacing: .5px;
}
.brand-txt { display: flex; align-items: center; gap: 8px; }
.brand-txt strong { font-size: 15px; }
.tag {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #f2f3f5;
  color: var(--text-3);
  font-weight: 400;
}
.tag.live { background: #e8f8ef; color: var(--green); }

.account-filter {
  display: flex;
  gap: 6px;
  padding: 0 16px 10px;
  overflow-x: auto;
}
.account-chip {
  flex: 0 0 auto;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--line-strong);
  color: var(--text-2);
  font-size: 12px;
  background: #fff;
  white-space: nowrap;
  transition: .15s;
}
.account-chip.active {
  background: var(--brand-soft);
  border-color: #ffc9d2;
  color: var(--brand);
  font-weight: 500;
}

.search { padding: 0 16px 10px; }
.search input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  background: #fafbfc;
  transition: .15s;
}
.search input:focus { border-color: #ffb3c0; background: #fff; }

.conv-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 0 8px 8px;
}

.conv-item {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: .12s;
}
.conv-item:hover { background: #f7f8fa; }
.conv-item.active { background: var(--brand-soft); }

.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #eef1f5;
  color: var(--text-2);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.conv-main { min-width: 0; }
.conv-line1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.conv-name {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-time { font-size: 11px; color: var(--text-3); flex: 0 0 auto; }
.conv-preview {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.conv-tags { display: flex; gap: 4px; margin-top: 4px; }
.mini-tag {
  font-size: 10.5px;
  padding: 0 5px;
  border-radius: 3px;
  background: #f2f3f5;
  color: var(--text-3);
  font-weight: 400;
}
.mini-tag.intent { background: #eef4ff; color: var(--blue); }
.mini-tag.region { background: #f4f1ff; color: #7c5cff; }

.badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  display: grid;
  place-items: center;
  align-self: start;
  margin-top: 3px;
}

.sidebar-foot { padding: 10px 16px 16px; border-top: 1px solid var(--line); }
.sidebar-foot .ghost-btn { width: 100%; font-size: 12.5px; }

/* ============ 中栏 ============ */
.chat {
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.chat-title h2 { margin: 0; font-size: 15px; font-weight: 600; }
.chat-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.msg-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 20px 22px 8px;
  background: #fcfcfd;
}

.empty-state {
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  color: var(--text-3);
  gap: 8px;
}
.empty-icon { font-size: 30px; opacity: .5; }

.msg-list { display: flex; flex-direction: column; gap: 14px; max-width: 720px; margin: 0 auto; }

.day-sep {
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  margin: 6px 0 2px;
}

.msg-row { display: flex; gap: 10px; align-items: flex-start; }
.msg-row.out { flex-direction: row-reverse; }

.msg-row .avatar { width: 32px; height: 32px; font-size: 12px; flex: 0 0 auto; }

.bubble-wrap { max-width: 78%; display: flex; flex-direction: column; gap: 3px; }
.msg-row.out .bubble-wrap { align-items: flex-end; }

.bubble {
  padding: 9px 13px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-row.in .bubble { border-top-left-radius: 3px; }
.msg-row.out .bubble {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  border-top-right-radius: 3px;
}
.bubble.failed { background: #fff5f5; border-color: #ffc9c9; color: #c92a2a; }

.msg-meta {
  font-size: 10.5px;
  color: var(--text-3);
  display: flex;
  gap: 6px;
  align-items: center;
}
.sender-tag {
  font-size: 10px;
  padding: 0 4px;
  border-radius: 3px;
  background: #f2f3f5;
  color: var(--text-2);
}
.sender-tag.ai { background: #eef4ff; color: var(--blue); }

/* 输入区 */
.composer {
  border-top: 1px solid var(--line);
  padding: 10px 22px 14px;
  flex: 0 0 auto;
  background: #fff;
}
.quick-bar { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.quick-chip {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text-2);
  transition: .12s;
}
.quick-chip:hover { border-color: #ffb3c0; color: var(--brand); }

.composer textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 13.5px;
  resize: none;
  outline: none;
  transition: .15s;
  background: #fafbfc;
}
.composer textarea:focus { border-color: #ffb3c0; background: #fff; }

.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}
.hint { font-size: 11.5px; color: var(--text-3); }
.hint.err { color: #c92a2a; }

/* ============ 右栏 ============ */
.inspector {
  background: var(--panel);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.panel { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel h3 {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: .3px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kv { margin: 0; display: flex; flex-direction: column; gap: 9px; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; }
.kv dt { color: var(--text-3); flex: 0 0 auto; }
.kv dd { margin: 0; text-align: right; color: var(--text); font-weight: 500; }

.ai-panel { flex: 1; }
.ai-body {
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 13px;
  line-height: 1.7;
  min-height: 96px;
  white-space: pre-wrap;
  color: var(--text);
}
.ai-body.loading { color: var(--text-3); }
.ai-actions { display: flex; gap: 8px; margin-top: 10px; }
.ai-actions .ghost-btn { flex: 1; font-size: 12.5px; padding: 6px 8px; }

.ai-extra { display: block; margin-top: 12px; }
.ai-extra span { font-size: 11.5px; color: var(--text-3); display: block; margin-bottom: 4px; }
.ai-extra input {
  width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  font: inherit;
  font-size: 12.5px;
  outline: none;
  background: #fafbfc;
}
.ai-extra input:focus { border-color: #ffb3c0; background: #fff; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #dfe2e7; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #cdd2d9; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1180px) {
  .app { grid-template-columns: 250px minmax(0, 1fr); }
  .inspector { display: none; }
}
