/* 小灵通智能助手 - 对话页 */
* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html { font-size:16px; }
body {
  font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Helvetica Neue",Helvetica,"Microsoft YaHei",sans-serif;
  background:#f4f6f8; color:#222;
  height:100vh; overflow:hidden;
}
.hidden { display:none !important; }
button { cursor:pointer; }

/* 顶栏 */
#topBar {
  position:fixed; top:0; left:0; right:0; height:50px; z-index:30;
  background:#fff; border-bottom:1px solid #eee;
  display:flex; align-items:center; justify-content:space-between; padding:0 12px;
}
#topBar .logo { position:absolute; left:50%; transform:translateX(-50%); font-size:16px; font-weight:700; white-space:nowrap; }
#topBar .logo::before { content:"🤖 "; }
#topBar .me { font-size:12px; color:#2f6bff; text-decoration:none; max-width:80px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#topBar .me img { width:32px; height:32px; border-radius:50%; object-fit:cover; display:block; border:1.5px solid #e3e8f2; background:#fff; }
.icon-btn {
  border:none; background:#f2f4f8; width:34px; height:34px; border-radius:10px;
  font-size:16px; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
}
/* 三条杠菜单图标 */
.burger { display:flex; flex-direction:column; justify-content:center; gap:4.5px; width:16px; height:16px; }
.burger i { display:block; height:2px; border-radius:1px; background:#333; }

/* 历史抽屉 */
#drawerMask { position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:40; }
#drawer {
  position:fixed; top:0; left:0; bottom:0; width:75%; max-width:300px; z-index:41;
  background:#fff; padding:16px 12px 0; display:flex; flex-direction:column;
}
#drawer h3 { font-size:14px; color:#999; margin-bottom:0; flex:0 0 auto; }
.drawer-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; flex:0 0 auto; }
#editBtn { border:none; background:none; font-size:13.5px; color:var(--blue); font-family:inherit; padding:4px 6px; }
#dayList { flex:1; overflow-y:auto; }
/* 抽屉底部用户区 */
.drawer-foot {
  flex:0 0 auto; display:flex; align-items:center; justify-content:space-between;
  margin:0 -12px; padding:12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top:1px solid #f0f0f0;
}
.u-entry { display:flex; align-items:center; gap:10px; text-decoration:none; color:#222; min-width:0; flex:1; }
.u-entry .avatar {
  width:36px; height:36px; border-radius:50%; background:#dfe3ea; flex-shrink:0;
  display:flex; align-items:center; justify-content:center; font-size:19px;
  position:relative; overflow:hidden;
}
.u-entry .avatar img {
  position:absolute; inset:0; width:100%; height:100%; object-fit:cover;
  border-radius:50%; display:none;
}
.u-entry .avatar i { font-style:normal; }
.u-entry .uname { font-size:14.5px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.dots { color:#b6bcc7; font-size:20px; letter-spacing:2px; text-decoration:none; padding:4px 8px; }
.day-item {
  padding:10px 12px; border-radius:10px; font-size:14px; color:#333;
  display:flex; align-items:center; justify-content:space-between; margin-bottom:6px; cursor:pointer;
}
.day-item:active, .day-item.on { background:#eef3ff; color:#2f6bff; }
.day-item .t { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.day-item .c { color:#bbb; font-size:12px; flex-shrink:0; margin-left:6px; }
.day-item.pinned { background:#f6f9ff; }
.day-item.sel { background:#eef3ff; }
.day-item .chk {
  width:20px; height:20px; border-radius:50%; border:1.5px solid #c9cfdb;
  margin-right:10px; flex-shrink:0; position:relative;
}
.day-item.sel .chk { border-color:#2f6bff; background:#2f6bff; }
.day-item.sel .chk::after {
  content:""; position:absolute; left:6px; top:3px; width:4px; height:8px;
  border:solid #fff; border-width:0 2px 2px 0; transform:rotate(42deg);
}

/* 通用弹层 */
.ui-mask {
  position:fixed; inset:0; background:rgba(15,23,42,.45); z-index:60;
  opacity:0; transition:opacity .25s;
}
.ui-mask.show { opacity:1; }
.ui-sheet {
  position:fixed; left:0; right:0; bottom:0; z-index:61; background:#fff;
  border-radius:18px 18px 0 0; padding:6px 12px calc(12px + env(safe-area-inset-bottom));
  transform:translateY(105%); transition:transform .28s cubic-bezier(.2,.8,.25,1);
  max-width:520px; margin:0 auto;
}
.ui-sheet.show { transform:translateY(0); }
.sheet-title { text-align:center; font-size:12px; color:#999; padding:10px 0 4px; }
.sheet-btn {
  display:block; width:100%; padding:14px; border:none; background:#fff;
  font-size:16px; color:#222; border-top:1px solid #f2f2f2; text-align:center;
}
.sheet-btn:active { background:#f5f7fa; }
.sheet-btn.danger { color:#e04545; }
.sheet-btn.cancel { margin-top:8px; background:#f7f8fa; border-radius:12px; border-top:none; font-weight:600; }

/* 长按历史对话：条目旁浮出菜单 */
.day-menu {
  position:fixed; z-index:62; background:#fff; border-radius:14px; min-width:172px;
  box-shadow:0 8px 32px rgba(15,23,42,.18); overflow:hidden;
  animation:dmIn .16s ease; transform-origin:left center;
}
@keyframes dmIn { from { opacity:0; transform:scale(.88); } to { opacity:1; transform:scale(1); } }
.dm-title { font-size:12px; color:#999; padding:11px 16px 5px; }
.dm-item {
  display:flex; align-items:center; gap:11px; width:100%; padding:12px 16px;
  border:none; background:#fff; font-size:15px; color:#333; font-family:inherit; text-align:left;
}
.dm-item:active { background:#f5f7fa; }
.dm-item.danger { color:#e04545; }
.dm-item svg { flex:0 0 auto; }

.ui-modal {
  position:fixed; top:42%; left:50%; transform:translate(-50%,-50%) scale(.92); z-index:61;
  width:76%; max-width:320px; background:#fff; border-radius:16px; padding:22px 20px 0;
  opacity:0; transition:all .22s ease; text-align:center;
}
.ui-modal.show { opacity:1; transform:translate(-50%,-50%) scale(1); }
.ui-modal .m-title { font-size:16px; font-weight:700; margin-bottom:8px; }
.ui-modal .m-text { font-size:14px; color:#666; line-height:1.6; margin-bottom:18px; }
.ui-modal .m-btns { display:flex; border-top:1px solid #f0f0f0; margin:0 -20px; }
.ui-modal .m-btns button {
  flex:1; padding:14px 0; border:none; background:#fff; font-size:16px; color:#555;
}
.ui-modal .m-btns button + button { border-left:1px solid #f0f0f0; }
.ui-modal .m-btns button.danger { color:#e04545; font-weight:600; }
.ui-modal .m-btns button:active { background:#f7f8fa; }

.ui-toast {
  position:fixed; top:42%; left:50%; transform:translate(-50%,-50%) scale(.9);
  background:rgba(20,24,35,.88); color:#fff; font-size:14px;
  padding:12px 24px; border-radius:12px; z-index:80; opacity:0; transition:all .25s;
  max-width:80%; text-align:center; pointer-events:none;
}
.ui-toast.show { opacity:1; transform:translate(-50%,-50%) scale(1); }

/* 多选操作条 */
#selBar {
  flex:0 0 auto; display:flex; align-items:center; gap:8px;
  margin:8px -12px 0; padding:10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top:1px solid #f0f0f0; background:#fff;
}
#selBar .cnt { flex:1; font-size:13px; color:#666; }
#selBar button { padding:8px 16px; border:none; border-radius:10px; background:#eef1f6; font-size:14px; }
#selBar button.danger { background:#ffecec; color:#e04545; }
#selBar button:active { filter:brightness(.95); }

/* 消息区 */
#msgList {
  position:fixed; top:50px; bottom:64px; left:0; right:0; overflow-y:auto;
  padding:14px 12px; -webkit-overflow-scrolling:touch;
}
.msg { display:flex; margin-bottom:14px; }
.msg.user { justify-content:flex-end; }
.bubble {
  max-width:82%; padding:11px 13px; border-radius:14px;
  font-size:15px; line-height:1.65; word-break:break-word; white-space:pre-wrap;
  background:#fff; box-shadow:0 1px 3px rgba(0,0,0,.05);
}
.msg.user .bubble { background:#2f6bff; color:#fff; border-top-right-radius:4px; }
.msg.bot .bubble { border-top-left-radius:4px; }
.msg.bot .avatar {
  width:34px; height:34px; border-radius:10px; overflow:hidden; background:#fff;
  margin-right:8px; flex-shrink:0; box-shadow:0 1px 3px rgba(0,0,0,.08);
}
.msg.bot .avatar img { width:100%; height:100%; object-fit:cover; display:block; }

/* 消息内按钮 */
.bubble .btns { margin-top:10px; display:flex; flex-direction:column; gap:8px; }
.bubble .btns button, .bubble .btns a {
  display:block; text-align:center; padding:9px 14px; border-radius:10px;
  border:1px solid #d0d8f0; background:#f6f9ff; color:#2f6bff;
  font-size:14px; text-decoration:none;
}
.bubble .btns button.danger { border-color:#ffc9c9; background:#fff5f5; color:#e04545; }

/* 图片消息 */
.bubble .imgs { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
.bubble .imgs img { width:72px; height:72px; object-fit:cover; border-radius:8px; }

/* 搜索结果卡 */
.search-card { padding:0; overflow:hidden; min-width:70%; }
.search-card .s-head {
  padding:10px 13px; font-size:13px; color:#666; border-bottom:1px solid #f2f2f2;
  display:flex; justify-content:space-between;
}
.s-item {
  display:flex; gap:10px; padding:11px 13px; text-decoration:none; color:#222;
  border-bottom:1px solid #f5f5f5;
}
.s-item:active { background:#f7f9ff; }
.s-item img { width:64px; height:64px; object-fit:cover; border-radius:8px; flex-shrink:0; }
.s-item .s-body { flex:1; min-width:0; }
.s-item .s-title { font-size:15px; font-weight:600; margin-bottom:4px;
  overflow:hidden; text-overflow:ellipsis; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; }
.s-item .s-sum { font-size:12px; color:#888; line-height:1.5;
  overflow:hidden; text-overflow:ellipsis; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; }
.s-item .s-meta { font-size:11px; color:#aaa; margin-top:4px; }
.s-more {
  display:block; width:100%; padding:11px; border:none; background:#fafbff;
  color:#2f6bff; font-size:14px; text-align:center;
}
.s-all {
  display:block; width:100%; padding:11px; background:#f2f7ff;
  color:#1a56d6; font-size:14px; text-align:center; text-decoration:none;
  border-top:1px solid #e6edfb; font-weight:600;
}
.s-all:active { background:#e6efff; }
.s-src-links { border-top:1px solid #eef1f8; }
.s-src-links .s-all { border-top:none; background:#fff; font-weight:400; }
.s-src-links .s-all:active { background:#f2f7ff; }
.s-empty { padding:20px 13px; text-align:center; color:#999; font-size:13px; }
/* 搜索卡底部「相关分类」快捷按钮：单行横向排列，超出可滑动 */
.search-card .s-sub {
  display:flex; flex-direction:row; flex-wrap:nowrap; align-items:center;
  gap:8px; padding:9px 13px; border-top:1px solid #eef1f8;
  overflow-x:auto; overflow-y:hidden; -webkit-overflow-scrolling:touch;
  scrollbar-width:none;
}
.search-card .s-sub::-webkit-scrollbar { display:none; }
.search-card .s-sub .s-sub-t { font-size:12px; color:#999; flex-shrink:0; }
.search-card .s-sub button {
  flex-shrink:0; white-space:nowrap;
  padding:5px 12px; border-radius:999px; border:1px solid #d0d8f0;
  background:#f6f9ff; color:#2f6bff; font-size:13px;
}
.search-card .s-sub button:active { background:#e6efff; }
.s-group {
  padding:8px 13px 4px; font-size:12px; color:#2f6bff; font-weight:600;
  background:#fafbff; border-bottom:1px solid #f0f3ff;
}
.s-item .s-tel { font-size:14px; color:#1aa85a; font-weight:600; margin-top:4px; }
/* 电话本条目：上名字（进详情），下电话+拨打按钮 */
.s-tel-item { flex-direction:column; align-items:stretch; gap:7px; background:#f6fffa; padding-top:11px; padding-bottom:11px; }
.s-tel-item .s-tel-row { display:flex; align-items:center; gap:5px; color:#222; text-decoration:none; min-width:0; }
.s-tel-item .s-tel-name { font-size:15px; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.s-tel-item .s-tel-go { font-size:12px; color:#b0b8c8; flex-shrink:0; }
.s-tel-item .s-tel-line2 { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.s-tel-item .s-tel-txt { font-size:14px; color:#555; font-weight:600; letter-spacing:.5px; white-space:nowrap; }
.s-tel-item .s-tel-num {
  flex-shrink:0; font-size:13px; font-weight:600; color:#0f9d58; text-decoration:none;
  padding:5px 14px; border:1px solid #b9ecd2; background:#e8f9f0; border-radius:999px; white-space:nowrap;
}
.s-tel-item .s-tel-num:active { background:#d2f3e3; }

/* 输入框上方快捷按钮 */
#quickBar {
  display:flex; gap:8px; overflow-x:auto; -webkit-overflow-scrolling:touch;
  padding:8px 12px;
  background:#fff; border-bottom:1px solid #f0f0f0; flex-shrink:0;
}
#quickBar::-webkit-scrollbar { display:none; }
.qbtn {
  flex:0 0 auto; display:flex; align-items:center; gap:5px;
  border:1px solid #e3e8f2; background:#f6f9ff; color:#2f4f8f;
  border-radius:18px; padding:8px 14px; font-size:14px; font-family:inherit;
}
.qbtn:active { background:#e8efff; }
.qbtn .qic { font-size:15px; }
.qbtn.q-hot { background:#fff4ec; border-color:#ffd9bd; color:#b35c17; }
.qbtn.q-hot:active { background:#ffe8d6; }

/* 发布预览卡 */
.pub-card .p-cate {
  display:inline-block; font-size:12px; color:#1aa85a; background:#e8f8ef;
  padding:2px 10px; border-radius:10px; margin-bottom:8px;
}
.pub-card .p-row { display:flex; font-size:14px; margin-bottom:6px; }
.pub-card .p-row b { width:74px; color:#888; font-weight:400; flex-shrink:0; }
.pub-card .p-row span { flex:1; word-break:break-word; }
.pub-card .imgs img { width:72px; height:72px; object-fit:cover; border-radius:8px; margin:4px 6px 0 0; }

/* 加载中 */
.typing { display:inline-flex; gap:4px; padding:4px 2px; }
.typing i { width:7px; height:7px; border-radius:50%; background:#b8c4e0; animation:tp 1s infinite; }
.typing i:nth-child(2) { animation-delay:.2s; }
.typing i:nth-child(3) { animation-delay:.4s; }
@keyframes tp { 0%,60%,100%{transform:translateY(0);opacity:.4} 30%{transform:translateY(-5px);opacity:1} }

/* 输入区 */
#inputBar {
  position:fixed; bottom:0; left:0; right:0; z-index:30; background:#fff;
  border-top:1px solid #eee; padding:5px 8px calc(5px + env(safe-area-inset-bottom));
}
#inputRow {
  display:flex; gap:8px; align-items:flex-end;
  background:#f7f8fa; border:1.5px solid #e9ecf2; border-radius:18px;
  padding:4px 6px 4px 12px;
  transition:padding .18s ease, background .18s ease;
}
#inputRow:focus-within { border-color:#2f6bff; background:#fff; padding:8px 8px 8px 14px; }
#msgInput {
  flex:1; min-height:34px; max-height:140px; border:none; background:transparent;
  padding:7px 0; font-size:15px; resize:none; outline:none; line-height:1.45;
  transition:min-height .18s ease, padding .18s ease;
}
#inputRow:focus-within #msgInput { min-height:56px; padding:15px 0; }
.in-tools { display:flex; align-items:center; gap:6px; flex-shrink:0; }
#sendBtn {
  height:32px; padding:0 16px; border:none; border-radius:12px;
  background:#2f6bff; color:#fff; font-size:14px; flex-shrink:0;
  transition:height .18s ease, padding .18s ease;
}
#inputRow:focus-within #sendBtn { height:40px; padding:0 20px; font-size:15px; }
#sendBtn:disabled { background:#b9c6ea; }

@media (min-width:720px) {
  #msgList, #inputBar, #topBar { max-width:760px; margin-left:auto; margin-right:auto; }
  #msgList { left:0; right:0; }
  #drawer { max-width:320px; }
}
