* { box-sizing: border-box; }
:root {
  --orange: #ff8a3d;
  --orange-deep: #f26f1d;
  --ink: #1f1c19;
  --ink-soft: #736a62;
  --line: rgba(31, 28, 25, .1);
  --bg: #f6f4f1;
}
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased;
}
a { color: inherit; }

.app { display: grid; grid-template-columns: 312px 1fr; height: 100vh; }

/* ---------- 侧栏 ---------- */
.side {
  background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.side-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 12px; }
.logo {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(145deg, #ffb26b, var(--orange-deep)); font-size: 18px;
  box-shadow: 0 6px 14px rgba(242, 111, 29, .28);
}
.logo-text { display: flex; flex-direction: column; gap: 1px; }
.logo-text strong { font-size: 14px; }
.logo-text span { font-size: 11px; color: var(--ink-soft); }

.filters { display: flex; gap: 4px; padding: 4px 12px 10px; }
.filters button {
  flex: 1; border: 0; background: transparent; font: inherit; font-size: 12.5px;
  color: var(--ink-soft); padding: 7px 6px; border-radius: 9px; cursor: pointer;
}
.filters button.active { background: #fff2e4; color: var(--orange-deep); font-weight: 600; }
.filters b { font-weight: 600; opacity: .65; margin-left: 2px; }

.list { flex: 1; overflow-y: auto; padding: 2px 8px 8px; }
.item {
  display: flex; gap: 10px; padding: 11px 12px; border-radius: 12px; cursor: pointer;
  align-items: flex-start; transition: background .14s ease;
}
.item:hover { background: #faf8f5; }
.item.active { background: #fff2e4; }
.item .av {
  width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center;
  background: #f2ede7; font-size: 15px; color: var(--ink-soft); font-weight: 600;
}
.item.waiting .av { background: #fff0df; color: var(--orange-deep); }
.item.human .av { background: #e9f5ec; color: #1f9254; }
.item-main { flex: 1; min-width: 0; }
.item-top { display: flex; justify-content: space-between; gap: 8px; }
.item-title { font-size: 13.2px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-time { font-size: 10.5px; color: #a89e95; flex: none; }
.item-sub { font-size: 12px; color: var(--ink-soft); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-tag {
  display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 5px; margin-right: 5px;
  background: #f1ece6; color: #8a7f74;
}
.item.waiting .item-tag { background: #ffe7cd; color: #b4610e; }
.item.human .item-tag { background: #dff3e6; color: #1f7a45; }

.side-foot {
  border-top: 1px solid var(--line); padding: 11px 18px; display: flex;
  justify-content: space-between; font-size: 11.5px; color: var(--ink-soft);
}

/* ---------- 主区 ---------- */
.main { display: flex; flex-direction: column; min-height: 0; background: #fff; }
.empty { margin: auto; text-align: center; color: var(--ink-soft); padding: 32px; }
.empty-emoji { font-size: 52px; margin-bottom: 10px; }
.empty h2 { font-size: 17px; color: var(--ink); margin: 0 0 8px; }
.empty p { font-size: 13px; line-height: 1.8; margin: 0; }

.conv { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.conv[hidden], .empty[hidden] { display: none !important; }
.conv-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 24px; border-bottom: 1px solid var(--line);
}
.conv-head h1 { font-size: 15.5px; margin: 0 0 3px; }
.conv-head p { margin: 0; font-size: 11.5px; color: var(--ink-soft); }
.conv-actions { display: flex; align-items: center; gap: 10px; }
.pill {
  font-size: 11.5px; padding: 5px 11px; border-radius: 999px;
  background: #f1ece6; color: #8a7f74;
}
.pill.waiting { background: #ffe7cd; color: #b4610e; }
.pill.human { background: #dff3e6; color: #1f7a45; }
.ghost {
  border: 1px solid var(--line); background: #fff; font: inherit; font-size: 12.5px;
  padding: 7px 13px; border-radius: 9px; cursor: pointer; color: var(--ink-soft);
}
.ghost:hover { background: #faf8f5; }

.thread { flex: 1; overflow-y: auto; padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; background: #fcfbf9; }
.bubble-row { display: flex; gap: 9px; max-width: 72%; }
.bubble-row.agent { align-self: flex-end; flex-direction: row-reverse; }
.bubble-row .who { font-size: 11px; color: var(--ink-soft); margin-bottom: 4px; }
.bubble {
  padding: 10px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.65;
  background: #fff; border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word;
}
.bubble-row.agent .bubble { background: linear-gradient(135deg, #fff3e6, #ffe9d5); border-color: rgba(242, 111, 29, .25); }
.bubble-row.user .bubble { background: #fff; }
.bubble-wrap { display: flex; flex-direction: column; }
.sys-line { align-self: center; font-size: 11.5px; color: #a3713d; background: #fff6ea; padding: 5px 12px; border-radius: 999px; }

.composer { border-top: 1px solid var(--line); padding: 14px 24px 18px; }
.composer textarea {
  width: 100%; resize: none; border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 13px; font: inherit; font-size: 13.5px; outline: none; line-height: 1.6;
  background: #fcfbf9; transition: border-color .15s ease;
}
.composer textarea:focus { border-color: rgba(242, 111, 29, .5); background: #fff; }
.composer-bar { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; }
.hint { font-size: 11.5px; color: #a89e95; }
.send {
  border: 0; cursor: pointer; font: inherit; font-weight: 600; font-size: 13px; color: #fff;
  background: linear-gradient(140deg, #ffa65c, var(--orange-deep));
  padding: 9px 22px; border-radius: 10px;
  box-shadow: 0 8px 18px rgba(242, 111, 29, .25);
}
.send:disabled { opacity: .5; cursor: default; box-shadow: none; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .side.mobile-show { display: flex; }
}
